1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-29 15:47:57 +02:00

Attempt to provide better default values for the disableFontFace/nativeImageDecoderSupport API options in Node.js

This should provide a better out-of-the-box experience when using PDF.js in a Node.js environment, since it's missing native support for both `@font-face` and `Image`.
Please note that this change *only* affects the default values, hence it's still possible for an API consumer to override those values when calling `getDocument`.

Also, prevents "ReferenceError: document is not defined" errors, when running the unit-tests in Node.js/Travis.
This commit is contained in:
Jonas Jenwald 2018-06-01 12:52:29 +02:00
parent dcc7f33ee7
commit 0ecc22cb04
4 changed files with 22 additions and 19 deletions

View file

@ -56,14 +56,8 @@ var pdfURL = '../../../web/compressed.tracemonkey-pldi-09.pdf';
// Read the PDF file into a typed array so PDF.js can load it.
var rawData = new Uint8Array(fs.readFileSync(pdfURL));
// Load the PDF file. The `disableFontFace` and `nativeImageDecoderSupport`
// options must be passed because Node.js has no native `@font-face` and
// `Image` support.
pdfjsLib.getDocument({
data: rawData,
disableFontFace: true,
nativeImageDecoderSupport: 'none',
}).then(function (pdfDocument) {
// Load the PDF file.
pdfjsLib.getDocument(rawData).then(function (pdfDocument) {
console.log('# PDF document loaded.');
// Get the first page.