diff --git a/src/plugins/pdf-to-html/index.js b/src/plugins/pdf-to-html/index.js
index c4d0355d6..e39777c52 100644
--- a/src/plugins/pdf-to-html/index.js
+++ b/src/plugins/pdf-to-html/index.js
@@ -150,11 +150,7 @@ async function plugin(server, options) {
* Remove excess title and meta elements left behind by Poppler;
* Poppler appends `-html` to the file name
*/
- const dom = new JSDOM(
- await fs.readFile(`${tempFile}-html.html`, {
- encoding: config.pdfToHtmlOptions.outputEncoding,
- })
- );
+ const dom = new JSDOM(await fs.readFile(`${tempFile}-html.html`));
const titles = dom.window.document.querySelectorAll("title");
// Overwrite title set by Poppler, which reveals directories
diff --git a/src/routes/pdf/html/schema.js b/src/routes/pdf/html/schema.js
index ed3a4f0f5..2e779c98b 100644
--- a/src/routes/pdf/html/schema.js
+++ b/src/routes/pdf/html/schema.js
@@ -96,7 +96,31 @@ const pdfToHtmlPostSchema = {
S.string()
.default("UTF-8")
.description("Sets the encoding to use for text output")
- .pattern(/^[-\w]+$/m)
+ // Encodings supported by Poppler
+ .enum([
+ "ASCII7",
+ "Big5",
+ "Big5ascii",
+ "EUC-CN",
+ "EUC-JP",
+ "GBK",
+ "ISO-2022-CN",
+ "ISO-2022-JP",
+ "ISO-2022-KR",
+ "ISO-8859-6",
+ "ISO-8859-7",
+ "ISO-8859-8",
+ "ISO-8859-9",
+ "KOI8-R",
+ "Latin1",
+ "Latin2",
+ "Shift-JIS",
+ "TIS-620",
+ "UTF-8",
+ "UTF-16",
+ "Windows-1255",
+ "ZapfDingbats",
+ ])
)
.prop(
"ownerPassword",
diff --git a/src/routes/pdf/txt/schema.js b/src/routes/pdf/txt/schema.js
index 93bbf9db5..4463125ff 100644
--- a/src/routes/pdf/txt/schema.js
+++ b/src/routes/pdf/txt/schema.js
@@ -103,7 +103,31 @@ const pdfToTxtPostSchema = {
S.string()
.default("UTF-8")
.description("Sets the encoding to use for text output")
- .pattern(/^[-\w]+$/m)
+ // Encodings supported by Poppler
+ .enum([
+ "ASCII7",
+ "Big5",
+ "Big5ascii",
+ "EUC-CN",
+ "EUC-JP",
+ "GBK",
+ "ISO-2022-CN",
+ "ISO-2022-JP",
+ "ISO-2022-KR",
+ "ISO-8859-6",
+ "ISO-8859-7",
+ "ISO-8859-8",
+ "ISO-8859-9",
+ "KOI8-R",
+ "Latin1",
+ "Latin2",
+ "Shift-JIS",
+ "TIS-620",
+ "UTF-8",
+ "UTF-16",
+ "Windows-1255",
+ "ZapfDingbats",
+ ])
)
.prop(
"ownerPassword",