Skip to content

Commit

Permalink
fix(plugins/pdf-to-txt): charset and content can't be altered with ocr (
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Mar 26, 2023
1 parent b2af657 commit 5550aa2
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/plugins/pdf-to-txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ async function plugin(server, options) {
);

req.conversionResults.body = results.join(" ");
res.type("text/plain; charset=utf-8");
} else {
// Prune params that pdfToTxt cannot accept
Object.keys(query).forEach((value) => {
Expand Down Expand Up @@ -205,20 +206,20 @@ async function plugin(server, options) {
/* istanbul ignore next: unable to test unknown errors */
throw err;
}
}

// Certain querystring options alter output to HTML rather than TXT
let contentType = "text/plain";
if (
query.boundingBoxXhtml ||
query.boundingBoxXhtmlLayout ||
query.generateHtmlMetaFile
) {
contentType = "text/html";
// Certain querystring options alter output to HTML rather than TXT
let contentType = "text/plain";
if (
query.boundingBoxXhtml ||
query.boundingBoxXhtmlLayout ||
query.generateHtmlMetaFile
) {
contentType = "text/html";
}
res.type(
`${contentType}; charset=${config.pdfToTxtOptions.outputEncoding.toLowerCase()}`
);
}
res.type(
`${contentType}; charset=${config.pdfToTxtOptions.outputEncoding.toLowerCase()}`
);
});
}

Expand Down

0 comments on commit 5550aa2

Please sign in to comment.