diff --git a/package.json b/package.json index 0efe22a..202ff8b 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "pdf-thumbnails", - "version": "0.4.0", + "version": "0.5.0", "main": "src/app.js", "repository": "https://www.github.com/tind/pdf-thumbnails", "license": "MIT", "dependencies": { "canvas": "~2.9.0", - "commander": "~8.3.0", - "pdfjs-dist": "~2.12.313" + "commander": "~9.0.0", + "pdfjs-dist": "~2.13.216" }, "devDependencies": { "mocha": "~9.2.0" diff --git a/src/app.js b/src/app.js index 3559c7e..c452d59 100755 --- a/src/app.js +++ b/src/app.js @@ -31,6 +31,7 @@ program .option("-p, --pagenum ", "page number", _parseInt, 1) .option("-w, --width ", "width", _parseInt, 300) .option("-q, --quality ", "jpeg quality", _parseFloat, 1.0) + .option("-F, --standard-fonts ", "standard fonts", "/tmp/fonts/") .arguments("") .action(async (files, options, command) => { const canvasFactory = new NodeCanvasFactory(); @@ -38,7 +39,7 @@ program for (const file of files) { const outputPath = join(options.output, basename(file, ".pdf") + ".jpg"); const contents = await readFile(file); - const jpegBuffer = await getThumbnail(contents, options.pagenum, options.width, options.quality, canvasFactory); + const jpegBuffer = await getThumbnail(contents, options.pagenum, options.width, options.quality, options.standardFonts, canvasFactory); await writeFile(outputPath, jpegBuffer); } diff --git a/src/lib.js b/src/lib.js index f5a8e18..775c477 100644 --- a/src/lib.js +++ b/src/lib.js @@ -34,8 +34,8 @@ class NodeCanvasFactory { } } -async function getThumbnail(data, pageNum = 1, width = 300, quality = 1.0, canvasFactory = new NodeCanvasFactory()) { - const loadingTask = pdfjsLib.getDocument({data: data}); +async function getThumbnail(data, pageNum = 1, width = 300, quality = 1.0, standardFonts = '/tmp/fonts/', canvasFactory = new NodeCanvasFactory()) { + const loadingTask = pdfjsLib.getDocument({data: data, standardFontDataUrl: standardFonts}); const document = await loadingTask.promise; const page = await document.getPage(pageNum);