mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +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:
parent
dcc7f33ee7
commit
0ecc22cb04
4 changed files with 22 additions and 19 deletions
|
@ -274,7 +274,9 @@ function getDocument(src) {
|
|||
const NativeImageDecoderValues = Object.values(NativeImageDecoding);
|
||||
if (params.nativeImageDecoderSupport === undefined ||
|
||||
!NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
|
||||
params.nativeImageDecoderSupport = NativeImageDecoding.DECODE;
|
||||
params.nativeImageDecoderSupport =
|
||||
(apiCompatibilityParams.nativeImageDecoderSupport ||
|
||||
NativeImageDecoding.DECODE);
|
||||
}
|
||||
if (!Number.isInteger(params.maxImageSize)) {
|
||||
params.maxImageSize = -1;
|
||||
|
@ -283,7 +285,7 @@ function getDocument(src) {
|
|||
params.isEvalSupported = true;
|
||||
}
|
||||
if (typeof params.disableFontFace !== 'boolean') {
|
||||
params.disableFontFace = false;
|
||||
params.disableFontFace = apiCompatibilityParams.disableFontFace || false;
|
||||
}
|
||||
|
||||
if (typeof params.disableRange !== 'boolean') {
|
||||
|
@ -2168,6 +2170,8 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||
disableStream: params.disableStream,
|
||||
disableAutoFetch: params.disableAutoFetch,
|
||||
disableCreateObjectURL: params.disableCreateObjectURL,
|
||||
disableFontFace: params.disableFontFace,
|
||||
nativeImageDecoderSupport: params.nativeImageDecoderSupport,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue