mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 04:47:21 +02:00
Compare commits
No commits in common. "293506ada7c98fb3b46ec01b373f9fd391c587c8" and "69595a29192b7704733404a42a2ebb537601117b" have entirely different histories.
293506ada7
...
69595a2919
@ -172,10 +172,6 @@
|
|||||||
"enum": [-1, 0, 3, 15],
|
"enum": [-1, 0, 3, 15],
|
||||||
"default": 0
|
"default": 0
|
||||||
},
|
},
|
||||||
"capCanvasAreaFactor": {
|
|
||||||
"type": "integer",
|
|
||||||
"default": 200
|
|
||||||
},
|
|
||||||
"enablePermissions": {
|
"enablePermissions": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
|||||||
@ -79,8 +79,6 @@ import { XRef } from "./xref.js";
|
|||||||
const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
|
const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
|
||||||
|
|
||||||
class Page {
|
class Page {
|
||||||
#resourcesPromise = null;
|
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
pdfManager,
|
pdfManager,
|
||||||
xref,
|
xref,
|
||||||
@ -110,6 +108,7 @@ class Page {
|
|||||||
this.systemFontCache = systemFontCache;
|
this.systemFontCache = systemFontCache;
|
||||||
this.nonBlendModesSet = nonBlendModesSet;
|
this.nonBlendModesSet = nonBlendModesSet;
|
||||||
this.evaluatorOptions = pdfManager.evaluatorOptions;
|
this.evaluatorOptions = pdfManager.evaluatorOptions;
|
||||||
|
this.resourcesPromise = null;
|
||||||
this.xfaFactory = xfaFactory;
|
this.xfaFactory = xfaFactory;
|
||||||
|
|
||||||
const idCounters = {
|
const idCounters = {
|
||||||
@ -126,23 +125,10 @@ class Page {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#createPartialEvaluator(handler) {
|
/**
|
||||||
return new PartialEvaluator({
|
* @private
|
||||||
xref: this.xref,
|
*/
|
||||||
handler,
|
_getInheritableProperty(key, getArray = false) {
|
||||||
pageIndex: this.pageIndex,
|
|
||||||
idFactory: this._localIdFactory,
|
|
||||||
fontCache: this.fontCache,
|
|
||||||
builtInCMapCache: this.builtInCMapCache,
|
|
||||||
standardFontDataCache: this.standardFontDataCache,
|
|
||||||
globalColorSpaceCache: this.globalColorSpaceCache,
|
|
||||||
globalImageCache: this.globalImageCache,
|
|
||||||
systemFontCache: this.systemFontCache,
|
|
||||||
options: this.evaluatorOptions,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#getInheritableProperty(key, getArray = false) {
|
|
||||||
const value = getInheritableProperty({
|
const value = getInheritableProperty({
|
||||||
dict: this.pageDict,
|
dict: this.pageDict,
|
||||||
key,
|
key,
|
||||||
@ -166,7 +152,7 @@ class Page {
|
|||||||
// For robustness: The spec states that a \Resources entry has to be
|
// For robustness: The spec states that a \Resources entry has to be
|
||||||
// present, but can be empty. Some documents still omit it; in this case
|
// present, but can be empty. Some documents still omit it; in this case
|
||||||
// we return an empty dictionary.
|
// we return an empty dictionary.
|
||||||
const resources = this.#getInheritableProperty("Resources");
|
const resources = this._getInheritableProperty("Resources");
|
||||||
|
|
||||||
return shadow(
|
return shadow(
|
||||||
this,
|
this,
|
||||||
@ -175,12 +161,12 @@ class Page {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#getBoundingBox(name) {
|
_getBoundingBox(name) {
|
||||||
if (this.xfaData) {
|
if (this.xfaData) {
|
||||||
return this.xfaData.bbox;
|
return this.xfaData.bbox;
|
||||||
}
|
}
|
||||||
const box = lookupNormalRect(
|
const box = lookupNormalRect(
|
||||||
this.#getInheritableProperty(name, /* getArray = */ true),
|
this._getInheritableProperty(name, /* getArray = */ true),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -198,7 +184,7 @@ class Page {
|
|||||||
return shadow(
|
return shadow(
|
||||||
this,
|
this,
|
||||||
"mediaBox",
|
"mediaBox",
|
||||||
this.#getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX
|
this._getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +193,7 @@ class Page {
|
|||||||
return shadow(
|
return shadow(
|
||||||
this,
|
this,
|
||||||
"cropBox",
|
"cropBox",
|
||||||
this.#getBoundingBox("CropBox") || this.mediaBox
|
this._getBoundingBox("CropBox") || this.mediaBox
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +224,7 @@ class Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get rotate() {
|
get rotate() {
|
||||||
let rotate = this.#getInheritableProperty("Rotate") || 0;
|
let rotate = this._getInheritableProperty("Rotate") || 0;
|
||||||
|
|
||||||
// Normalize rotation so it's a multiple of 90 and between 0 and 270.
|
// Normalize rotation so it's a multiple of 90 and between 0 and 270.
|
||||||
if (rotate % 90 !== 0) {
|
if (rotate % 90 !== 0) {
|
||||||
@ -253,7 +239,10 @@ class Page {
|
|||||||
return shadow(this, "rotate", rotate);
|
return shadow(this, "rotate", rotate);
|
||||||
}
|
}
|
||||||
|
|
||||||
#onSubStreamError(reason, objId) {
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_onSubStreamError(reason, objId) {
|
||||||
if (this.evaluatorOptions.ignoreErrors) {
|
if (this.evaluatorOptions.ignoreErrors) {
|
||||||
warn(`getContentStream - ignoring sub-stream (${objId}): "${reason}".`);
|
warn(`getContentStream - ignoring sub-stream (${objId}): "${reason}".`);
|
||||||
return;
|
return;
|
||||||
@ -273,7 +262,7 @@ class Page {
|
|||||||
if (Array.isArray(content)) {
|
if (Array.isArray(content)) {
|
||||||
return new StreamsSequenceStream(
|
return new StreamsSequenceStream(
|
||||||
content,
|
content,
|
||||||
this.#onSubStreamError.bind(this)
|
this._onSubStreamError.bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Replace non-existent page content with empty content.
|
// Replace non-existent page content with empty content.
|
||||||
@ -333,7 +322,20 @@ class Page {
|
|||||||
if (this.xfaFactory) {
|
if (this.xfaFactory) {
|
||||||
throw new Error("XFA: Cannot save new annotations.");
|
throw new Error("XFA: Cannot save new annotations.");
|
||||||
}
|
}
|
||||||
const partialEvaluator = this.#createPartialEvaluator(handler);
|
|
||||||
|
const partialEvaluator = new PartialEvaluator({
|
||||||
|
xref: this.xref,
|
||||||
|
handler,
|
||||||
|
pageIndex: this.pageIndex,
|
||||||
|
idFactory: this._localIdFactory,
|
||||||
|
fontCache: this.fontCache,
|
||||||
|
builtInCMapCache: this.builtInCMapCache,
|
||||||
|
standardFontDataCache: this.standardFontDataCache,
|
||||||
|
globalColorSpaceCache: this.globalColorSpaceCache,
|
||||||
|
globalImageCache: this.globalImageCache,
|
||||||
|
systemFontCache: this.systemFontCache,
|
||||||
|
options: this.evaluatorOptions,
|
||||||
|
});
|
||||||
|
|
||||||
const deletedAnnotations = new RefSetCache();
|
const deletedAnnotations = new RefSetCache();
|
||||||
const existingAnnotations = new RefSet();
|
const existingAnnotations = new RefSet();
|
||||||
@ -376,7 +378,19 @@ class Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async save(handler, task, annotationStorage, changes) {
|
async save(handler, task, annotationStorage, changes) {
|
||||||
const partialEvaluator = this.#createPartialEvaluator(handler);
|
const partialEvaluator = new PartialEvaluator({
|
||||||
|
xref: this.xref,
|
||||||
|
handler,
|
||||||
|
pageIndex: this.pageIndex,
|
||||||
|
idFactory: this._localIdFactory,
|
||||||
|
fontCache: this.fontCache,
|
||||||
|
builtInCMapCache: this.builtInCMapCache,
|
||||||
|
standardFontDataCache: this.standardFontDataCache,
|
||||||
|
globalColorSpaceCache: this.globalColorSpaceCache,
|
||||||
|
globalImageCache: this.globalImageCache,
|
||||||
|
systemFontCache: this.systemFontCache,
|
||||||
|
options: this.evaluatorOptions,
|
||||||
|
});
|
||||||
|
|
||||||
// Fetch the page's annotations and save the content
|
// Fetch the page's annotations and save the content
|
||||||
// in case of interactive form fields.
|
// in case of interactive form fields.
|
||||||
@ -400,11 +414,8 @@ class Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadResources(keys) {
|
async loadResources(keys) {
|
||||||
// TODO: add async `#getInheritableProperty` and remove this.
|
// TODO: add async `_getInheritableProperty` and remove this.
|
||||||
await (this.#resourcesPromise ??= this.pdfManager.ensure(
|
await (this.resourcesPromise ??= this.pdfManager.ensure(this, "resources"));
|
||||||
this,
|
|
||||||
"resources"
|
|
||||||
));
|
|
||||||
|
|
||||||
await ObjectLoader.load(this.resources, keys, this.xref);
|
await ObjectLoader.load(this.resources, keys, this.xref);
|
||||||
}
|
}
|
||||||
@ -439,7 +450,19 @@ class Page {
|
|||||||
const contentStreamPromise = this.getContentStream();
|
const contentStreamPromise = this.getContentStream();
|
||||||
const resourcesPromise = this.loadResources(RESOURCES_KEYS_OPERATOR_LIST);
|
const resourcesPromise = this.loadResources(RESOURCES_KEYS_OPERATOR_LIST);
|
||||||
|
|
||||||
const partialEvaluator = this.#createPartialEvaluator(handler);
|
const partialEvaluator = new PartialEvaluator({
|
||||||
|
xref: this.xref,
|
||||||
|
handler,
|
||||||
|
pageIndex: this.pageIndex,
|
||||||
|
idFactory: this._localIdFactory,
|
||||||
|
fontCache: this.fontCache,
|
||||||
|
builtInCMapCache: this.builtInCMapCache,
|
||||||
|
standardFontDataCache: this.standardFontDataCache,
|
||||||
|
globalColorSpaceCache: this.globalColorSpaceCache,
|
||||||
|
globalImageCache: this.globalImageCache,
|
||||||
|
systemFontCache: this.systemFontCache,
|
||||||
|
options: this.evaluatorOptions,
|
||||||
|
});
|
||||||
|
|
||||||
const newAnnotsByPage = !this.xfaFactory
|
const newAnnotsByPage = !this.xfaFactory
|
||||||
? getNewAnnotationsMap(annotationStorage)
|
? getNewAnnotationsMap(annotationStorage)
|
||||||
@ -647,7 +670,19 @@ class Page {
|
|||||||
RESOURCES_KEYS_TEXT_CONTENT
|
RESOURCES_KEYS_TEXT_CONTENT
|
||||||
);
|
);
|
||||||
|
|
||||||
const partialEvaluator = this.#createPartialEvaluator(handler);
|
const partialEvaluator = new PartialEvaluator({
|
||||||
|
xref: this.xref,
|
||||||
|
handler,
|
||||||
|
pageIndex: this.pageIndex,
|
||||||
|
idFactory: this._localIdFactory,
|
||||||
|
fontCache: this.fontCache,
|
||||||
|
builtInCMapCache: this.builtInCMapCache,
|
||||||
|
standardFontDataCache: this.standardFontDataCache,
|
||||||
|
globalColorSpaceCache: this.globalColorSpaceCache,
|
||||||
|
globalImageCache: this.globalImageCache,
|
||||||
|
systemFontCache: this.systemFontCache,
|
||||||
|
options: this.evaluatorOptions,
|
||||||
|
});
|
||||||
|
|
||||||
return partialEvaluator.getTextContent({
|
return partialEvaluator.getTextContent({
|
||||||
stream: contentStream,
|
stream: contentStream,
|
||||||
@ -716,7 +751,19 @@ class Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (annotation.hasTextContent && isVisible) {
|
if (annotation.hasTextContent && isVisible) {
|
||||||
partialEvaluator ??= this.#createPartialEvaluator(handler);
|
partialEvaluator ||= new PartialEvaluator({
|
||||||
|
xref: this.xref,
|
||||||
|
handler,
|
||||||
|
pageIndex: this.pageIndex,
|
||||||
|
idFactory: this._localIdFactory,
|
||||||
|
fontCache: this.fontCache,
|
||||||
|
builtInCMapCache: this.builtInCMapCache,
|
||||||
|
standardFontDataCache: this.standardFontDataCache,
|
||||||
|
globalColorSpaceCache: this.globalColorSpaceCache,
|
||||||
|
globalImageCache: this.globalImageCache,
|
||||||
|
systemFontCache: this.systemFontCache,
|
||||||
|
options: this.evaluatorOptions,
|
||||||
|
});
|
||||||
|
|
||||||
textContentPromises.push(
|
textContentPromises.push(
|
||||||
annotation
|
annotation
|
||||||
@ -740,7 +787,7 @@ class Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get annotations() {
|
get annotations() {
|
||||||
const annots = this.#getInheritableProperty("Annots");
|
const annots = this._getInheritableProperty("Annots");
|
||||||
return shadow(this, "annotations", Array.isArray(annots) ? annots : []);
|
return shadow(this, "annotations", Array.isArray(annots) ? annots : []);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -880,10 +927,6 @@ function find(stream, signature, limit = 1024, backwards = false) {
|
|||||||
* The `PDFDocument` class holds all the (worker-thread) data of the PDF file.
|
* The `PDFDocument` class holds all the (worker-thread) data of the PDF file.
|
||||||
*/
|
*/
|
||||||
class PDFDocument {
|
class PDFDocument {
|
||||||
#pagePromises = new Map();
|
|
||||||
|
|
||||||
#version = null;
|
|
||||||
|
|
||||||
constructor(pdfManager, stream) {
|
constructor(pdfManager, stream) {
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||||
assert(
|
assert(
|
||||||
@ -900,6 +943,8 @@ class PDFDocument {
|
|||||||
this.pdfManager = pdfManager;
|
this.pdfManager = pdfManager;
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.xref = new XRef(stream, pdfManager);
|
this.xref = new XRef(stream, pdfManager);
|
||||||
|
this._pagePromises = new Map();
|
||||||
|
this._version = null;
|
||||||
|
|
||||||
const idCounters = {
|
const idCounters = {
|
||||||
font: 0,
|
font: 0,
|
||||||
@ -1020,7 +1065,7 @@ class PDFDocument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PDF_VERSION_REGEXP.test(version)) {
|
if (PDF_VERSION_REGEXP.test(version)) {
|
||||||
this.#version = version;
|
this._version = version;
|
||||||
} else {
|
} else {
|
||||||
warn(`Invalid PDF header version: ${version}`);
|
warn(`Invalid PDF header version: ${version}`);
|
||||||
}
|
}
|
||||||
@ -1045,7 +1090,10 @@ class PDFDocument {
|
|||||||
return shadow(this, "numPages", num);
|
return shadow(this, "numPages", num);
|
||||||
}
|
}
|
||||||
|
|
||||||
#hasOnlyDocumentSignatures(fields, recursionDepth = 0) {
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_hasOnlyDocumentSignatures(fields, recursionDepth = 0) {
|
||||||
const RECURSION_LIMIT = 10;
|
const RECURSION_LIMIT = 10;
|
||||||
|
|
||||||
if (!Array.isArray(fields)) {
|
if (!Array.isArray(fields)) {
|
||||||
@ -1058,10 +1106,10 @@ class PDFDocument {
|
|||||||
}
|
}
|
||||||
if (field.has("Kids")) {
|
if (field.has("Kids")) {
|
||||||
if (++recursionDepth > RECURSION_LIMIT) {
|
if (++recursionDepth > RECURSION_LIMIT) {
|
||||||
warn("#hasOnlyDocumentSignatures: maximum recursion depth reached");
|
warn("_hasOnlyDocumentSignatures: maximum recursion depth reached");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.#hasOnlyDocumentSignatures(
|
return this._hasOnlyDocumentSignatures(
|
||||||
field.get("Kids"),
|
field.get("Kids"),
|
||||||
recursionDepth
|
recursionDepth
|
||||||
);
|
);
|
||||||
@ -1353,7 +1401,7 @@ class PDFDocument {
|
|||||||
* the catalog, if present, should overwrite the version from the header.
|
* the catalog, if present, should overwrite the version from the header.
|
||||||
*/
|
*/
|
||||||
get version() {
|
get version() {
|
||||||
return this.catalog.version || this.#version;
|
return this.catalog.version || this._version;
|
||||||
}
|
}
|
||||||
|
|
||||||
get formInfo() {
|
get formInfo() {
|
||||||
@ -1363,7 +1411,7 @@ class PDFDocument {
|
|||||||
hasXfa: false,
|
hasXfa: false,
|
||||||
hasSignatures: false,
|
hasSignatures: false,
|
||||||
};
|
};
|
||||||
const { acroForm } = this.catalog;
|
const acroForm = this.catalog.acroForm;
|
||||||
if (!acroForm) {
|
if (!acroForm) {
|
||||||
return shadow(this, "formInfo", formInfo);
|
return shadow(this, "formInfo", formInfo);
|
||||||
}
|
}
|
||||||
@ -1390,7 +1438,7 @@ class PDFDocument {
|
|||||||
const sigFlags = acroForm.get("SigFlags");
|
const sigFlags = acroForm.get("SigFlags");
|
||||||
const hasSignatures = !!(sigFlags & 0x1);
|
const hasSignatures = !!(sigFlags & 0x1);
|
||||||
const hasOnlyDocumentSignatures =
|
const hasOnlyDocumentSignatures =
|
||||||
hasSignatures && this.#hasOnlyDocumentSignatures(fields);
|
hasSignatures && this._hasOnlyDocumentSignatures(fields);
|
||||||
formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
|
formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
|
||||||
formInfo.hasSignatures = hasSignatures;
|
formInfo.hasSignatures = hasSignatures;
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
@ -1403,22 +1451,22 @@ class PDFDocument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get documentInfo() {
|
get documentInfo() {
|
||||||
const { catalog, formInfo, xref } = this;
|
|
||||||
|
|
||||||
const docInfo = {
|
const docInfo = {
|
||||||
PDFFormatVersion: this.version,
|
PDFFormatVersion: this.version,
|
||||||
Language: catalog.lang,
|
Language: this.catalog.lang,
|
||||||
EncryptFilterName: xref.encrypt?.filterName ?? null,
|
EncryptFilterName: this.xref.encrypt
|
||||||
|
? this.xref.encrypt.filterName
|
||||||
|
: null,
|
||||||
IsLinearized: !!this.linearization,
|
IsLinearized: !!this.linearization,
|
||||||
IsAcroFormPresent: formInfo.hasAcroForm,
|
IsAcroFormPresent: this.formInfo.hasAcroForm,
|
||||||
IsXFAPresent: formInfo.hasXfa,
|
IsXFAPresent: this.formInfo.hasXfa,
|
||||||
IsCollectionPresent: !!catalog.collection,
|
IsCollectionPresent: !!this.catalog.collection,
|
||||||
IsSignaturesPresent: formInfo.hasSignatures,
|
IsSignaturesPresent: this.formInfo.hasSignatures,
|
||||||
};
|
};
|
||||||
|
|
||||||
let infoDict;
|
let infoDict;
|
||||||
try {
|
try {
|
||||||
infoDict = xref.trailer.get("Info");
|
infoDict = this.xref.trailer.get("Info");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof MissingDataException) {
|
if (err instanceof MissingDataException) {
|
||||||
throw err;
|
throw err;
|
||||||
@ -1517,7 +1565,7 @@ class PDFDocument {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #getLinearizationPage(pageIndex) {
|
async _getLinearizationPage(pageIndex) {
|
||||||
const { catalog, linearization, xref } = this;
|
const { catalog, linearization, xref } = this;
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||||
assert(
|
assert(
|
||||||
@ -1560,7 +1608,7 @@ class PDFDocument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPage(pageIndex) {
|
getPage(pageIndex) {
|
||||||
const cachedPromise = this.#pagePromises.get(pageIndex);
|
const cachedPromise = this._pagePromises.get(pageIndex);
|
||||||
if (cachedPromise) {
|
if (cachedPromise) {
|
||||||
return cachedPromise;
|
return cachedPromise;
|
||||||
}
|
}
|
||||||
@ -1570,7 +1618,7 @@ class PDFDocument {
|
|||||||
if (xfaFactory) {
|
if (xfaFactory) {
|
||||||
promise = Promise.resolve([Dict.empty, null]);
|
promise = Promise.resolve([Dict.empty, null]);
|
||||||
} else if (linearization?.pageFirst === pageIndex) {
|
} else if (linearization?.pageFirst === pageIndex) {
|
||||||
promise = this.#getLinearizationPage(pageIndex);
|
promise = this._getLinearizationPage(pageIndex);
|
||||||
} else {
|
} else {
|
||||||
promise = catalog.getPageDict(pageIndex);
|
promise = catalog.getPageDict(pageIndex);
|
||||||
}
|
}
|
||||||
@ -1594,7 +1642,7 @@ class PDFDocument {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this.#pagePromises.set(pageIndex, promise);
|
this._pagePromises.set(pageIndex, promise);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1609,7 +1657,7 @@ class PDFDocument {
|
|||||||
// Clear out the various caches to ensure that we haven't stored any
|
// Clear out the various caches to ensure that we haven't stored any
|
||||||
// inconsistent and/or incorrect state, since that could easily break
|
// inconsistent and/or incorrect state, since that could easily break
|
||||||
// subsequent `this.getPage` calls.
|
// subsequent `this.getPage` calls.
|
||||||
this.#pagePromises.delete(0);
|
this._pagePromises.delete(0);
|
||||||
await this.cleanup();
|
await this.cleanup();
|
||||||
|
|
||||||
throw new XRefParseException();
|
throw new XRefParseException();
|
||||||
@ -1648,7 +1696,7 @@ class PDFDocument {
|
|||||||
// Clear out the various caches to ensure that we haven't stored any
|
// Clear out the various caches to ensure that we haven't stored any
|
||||||
// inconsistent and/or incorrect state, since that could easily break
|
// inconsistent and/or incorrect state, since that could easily break
|
||||||
// subsequent `this.getPage` calls.
|
// subsequent `this.getPage` calls.
|
||||||
this.#pagePromises.delete(numPages - 1);
|
this._pagePromises.delete(numPages - 1);
|
||||||
await this.cleanup();
|
await this.cleanup();
|
||||||
|
|
||||||
if (reason instanceof XRefEntryException && !recoveryMode) {
|
if (reason instanceof XRefEntryException && !recoveryMode) {
|
||||||
@ -1695,7 +1743,7 @@ class PDFDocument {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#pagePromises.set(pageIndex, promise);
|
this._pagePromises.set(pageIndex, promise);
|
||||||
}
|
}
|
||||||
catalog.setActualNumPages(pagesTree.size);
|
catalog.setActualNumPages(pagesTree.size);
|
||||||
}
|
}
|
||||||
@ -1823,17 +1871,20 @@ class PDFDocument {
|
|||||||
if (!formInfo.hasFields) {
|
if (!formInfo.hasFields) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const annotationGlobals = await this.annotationGlobals;
|
|
||||||
|
const [annotationGlobals, acroForm] = await Promise.all([
|
||||||
|
this.pdfManager.ensureDoc("annotationGlobals"),
|
||||||
|
this.pdfManager.ensureCatalog("acroForm"),
|
||||||
|
]);
|
||||||
if (!annotationGlobals) {
|
if (!annotationGlobals) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const { acroForm } = annotationGlobals;
|
|
||||||
|
|
||||||
const visitedRefs = new RefSet();
|
const visitedRefs = new RefSet();
|
||||||
const allFields = Object.create(null);
|
const allFields = Object.create(null);
|
||||||
const fieldPromises = new Map();
|
const fieldPromises = new Map();
|
||||||
const orphanFields = new RefSetCache();
|
const orphanFields = new RefSetCache();
|
||||||
for (const fieldRef of acroForm.get("Fields")) {
|
for (const fieldRef of await acroForm.getAsync("Fields")) {
|
||||||
await this.#collectFieldObjects(
|
await this.#collectFieldObjects(
|
||||||
"",
|
"",
|
||||||
null,
|
null,
|
||||||
|
|||||||
@ -660,18 +660,11 @@ class OutputScale {
|
|||||||
* @returns {boolean} Returns `true` if scaling was limited,
|
* @returns {boolean} Returns `true` if scaling was limited,
|
||||||
* `false` otherwise.
|
* `false` otherwise.
|
||||||
*/
|
*/
|
||||||
limitCanvas(width, height, maxPixels, maxDim, capAreaFactor = -1) {
|
limitCanvas(width, height, maxPixels, maxDim) {
|
||||||
let maxAreaScale = Infinity,
|
let maxAreaScale = Infinity,
|
||||||
maxWidthScale = Infinity,
|
maxWidthScale = Infinity,
|
||||||
maxHeightScale = Infinity;
|
maxHeightScale = Infinity;
|
||||||
|
|
||||||
if (capAreaFactor >= 0) {
|
|
||||||
const cappedWindowArea = OutputScale.getCappedWindowArea(capAreaFactor);
|
|
||||||
maxPixels =
|
|
||||||
maxPixels > 0
|
|
||||||
? Math.min(maxPixels, cappedWindowArea)
|
|
||||||
: cappedWindowArea;
|
|
||||||
}
|
|
||||||
if (maxPixels > 0) {
|
if (maxPixels > 0) {
|
||||||
maxAreaScale = Math.sqrt(maxPixels / (width * height));
|
maxAreaScale = Math.sqrt(maxPixels / (width * height));
|
||||||
}
|
}
|
||||||
@ -692,23 +685,6 @@ class OutputScale {
|
|||||||
static get pixelRatio() {
|
static get pixelRatio() {
|
||||||
return globalThis.devicePixelRatio || 1;
|
return globalThis.devicePixelRatio || 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getCappedWindowArea(capAreaFactor) {
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
|
||||||
return Math.ceil(
|
|
||||||
window.innerWidth *
|
|
||||||
window.innerHeight *
|
|
||||||
this.pixelRatio ** 2 *
|
|
||||||
(1 + capAreaFactor / 100)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Math.ceil(
|
|
||||||
window.screen.availWidth *
|
|
||||||
window.screen.availHeight *
|
|
||||||
this.pixelRatio ** 2 *
|
|
||||||
(1 + capAreaFactor / 100)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// See https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
|
// See https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
|
||||||
|
|||||||
@ -389,9 +389,7 @@ describe("PDF viewer", () => {
|
|||||||
pages = await loadAndWait(
|
pages = await loadAndWait(
|
||||||
"issue18694.pdf",
|
"issue18694.pdf",
|
||||||
".textLayer .endOfContent",
|
".textLayer .endOfContent",
|
||||||
"page-width",
|
"page-width"
|
||||||
null,
|
|
||||||
{ capCanvasAreaFactor: -1 }
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -461,12 +459,7 @@ describe("PDF viewer", () => {
|
|||||||
describe("Detail view on zoom", () => {
|
describe("Detail view on zoom", () => {
|
||||||
const BASE_MAX_CANVAS_PIXELS = 1e6;
|
const BASE_MAX_CANVAS_PIXELS = 1e6;
|
||||||
|
|
||||||
function setupPages(
|
function setupPages(zoom, devicePixelRatio, setups = {}) {
|
||||||
zoom,
|
|
||||||
devicePixelRatio,
|
|
||||||
capCanvasAreaFactor,
|
|
||||||
setups = {}
|
|
||||||
) {
|
|
||||||
let pages;
|
let pages;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@ -483,10 +476,7 @@ describe("PDF viewer", () => {
|
|||||||
}`,
|
}`,
|
||||||
...setups,
|
...setups,
|
||||||
},
|
},
|
||||||
{
|
{ maxCanvasPixels: BASE_MAX_CANVAS_PIXELS * devicePixelRatio ** 2 },
|
||||||
maxCanvasPixels: BASE_MAX_CANVAS_PIXELS * devicePixelRatio ** 2,
|
|
||||||
capCanvasAreaFactor,
|
|
||||||
},
|
|
||||||
{ height: 600, width: 800, devicePixelRatio }
|
{ height: 600, width: 800, devicePixelRatio }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -513,8 +503,6 @@ describe("PDF viewer", () => {
|
|||||||
const bottomRight = ctx.getImageData(width - 3, height - 3, 1, 1).data;
|
const bottomRight = ctx.getImageData(width - 3, height - 3, 1, 1).data;
|
||||||
return {
|
return {
|
||||||
size: width * height,
|
size: width * height,
|
||||||
width,
|
|
||||||
height,
|
|
||||||
topLeft: globalThis.pdfjsLib.Util.makeHexColor(...topLeft),
|
topLeft: globalThis.pdfjsLib.Util.makeHexColor(...topLeft),
|
||||||
bottomRight: globalThis.pdfjsLib.Util.makeHexColor(...bottomRight),
|
bottomRight: globalThis.pdfjsLib.Util.makeHexColor(...bottomRight),
|
||||||
};
|
};
|
||||||
@ -540,7 +528,7 @@ describe("PDF viewer", () => {
|
|||||||
for (const pixelRatio of [1, 2]) {
|
for (const pixelRatio of [1, 2]) {
|
||||||
describe(`with pixel ratio ${pixelRatio}`, () => {
|
describe(`with pixel ratio ${pixelRatio}`, () => {
|
||||||
describe("setupPages()", () => {
|
describe("setupPages()", () => {
|
||||||
const forEachPage = setupPages("100%", pixelRatio, -1);
|
const forEachPage = setupPages("100%", pixelRatio);
|
||||||
|
|
||||||
it("sets the proper devicePixelRatio", async () => {
|
it("sets the proper devicePixelRatio", async () => {
|
||||||
await forEachPage(async (browserName, page) => {
|
await forEachPage(async (browserName, page) => {
|
||||||
@ -555,63 +543,8 @@ describe("PDF viewer", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when zooming with a cap on the canvas dimensions", () => {
|
|
||||||
const forEachPage = setupPages("10%", pixelRatio, 0);
|
|
||||||
|
|
||||||
it("must render the detail view", async () => {
|
|
||||||
await forEachPage(async (browserName, page) => {
|
|
||||||
await page.waitForSelector(
|
|
||||||
".page[data-page-number='1'] .textLayer"
|
|
||||||
);
|
|
||||||
|
|
||||||
const before = await page.evaluate(extractCanvases, 1);
|
|
||||||
expect(before.length)
|
|
||||||
.withContext(`In ${browserName}, before`)
|
|
||||||
.toBe(1);
|
|
||||||
|
|
||||||
const factor = 50;
|
|
||||||
const handle = await waitForDetailRendered(page);
|
|
||||||
await page.evaluate(scaleFactor => {
|
|
||||||
window.PDFViewerApplication.pdfViewer.updateScale({
|
|
||||||
drawingDelay: 0,
|
|
||||||
scaleFactor,
|
|
||||||
});
|
|
||||||
}, factor);
|
|
||||||
await awaitPromise(handle);
|
|
||||||
|
|
||||||
const after = await page.evaluate(extractCanvases, 1);
|
|
||||||
// The page dimensions are 595x841, so the base canvas is a scale
|
|
||||||
// version of that but the number of pixels is capped to
|
|
||||||
// 800x600 = 480000.
|
|
||||||
expect(after.length)
|
|
||||||
.withContext(`In ${browserName}, after`)
|
|
||||||
.toBe(2);
|
|
||||||
expect(after[0].width)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toBe(582 * pixelRatio);
|
|
||||||
expect(after[0].height)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toBe(823 * pixelRatio);
|
|
||||||
|
|
||||||
// The dimensions of the detail canvas are capped to 800x600 but
|
|
||||||
// it depends on the visible area which depends itself of the
|
|
||||||
// scrollbars dimensions, hence we just check that the canvas
|
|
||||||
// dimensions are capped.
|
|
||||||
expect(after[1].width)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toBeLessThan(810 * pixelRatio);
|
|
||||||
expect(after[1].height)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toBeLessThan(575 * pixelRatio);
|
|
||||||
expect(after[1].size)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toBeLessThan(800 * 600 * pixelRatio ** 2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when zooming in past max canvas size", () => {
|
describe("when zooming in past max canvas size", () => {
|
||||||
const forEachPage = setupPages("100%", pixelRatio, -1);
|
const forEachPage = setupPages("100%", pixelRatio);
|
||||||
|
|
||||||
it("must render the detail view", async () => {
|
it("must render the detail view", async () => {
|
||||||
await forEachPage(async (browserName, page) => {
|
await forEachPage(async (browserName, page) => {
|
||||||
@ -683,7 +616,7 @@ describe("PDF viewer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("when starting already zoomed in past max canvas size", () => {
|
describe("when starting already zoomed in past max canvas size", () => {
|
||||||
const forEachPage = setupPages("300%", pixelRatio, -1);
|
const forEachPage = setupPages("300%", pixelRatio);
|
||||||
|
|
||||||
it("must render the detail view", async () => {
|
it("must render the detail view", async () => {
|
||||||
await forEachPage(async (browserName, page) => {
|
await forEachPage(async (browserName, page) => {
|
||||||
@ -721,7 +654,7 @@ describe("PDF viewer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("when scrolling", () => {
|
describe("when scrolling", () => {
|
||||||
const forEachPage = setupPages("300%", pixelRatio, -1);
|
const forEachPage = setupPages("300%", pixelRatio);
|
||||||
|
|
||||||
it("must update the detail view", async () => {
|
it("must update the detail view", async () => {
|
||||||
await forEachPage(async (browserName, page) => {
|
await forEachPage(async (browserName, page) => {
|
||||||
@ -756,7 +689,7 @@ describe("PDF viewer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("when scrolling little enough that the existing detail covers the new viewport", () => {
|
describe("when scrolling little enough that the existing detail covers the new viewport", () => {
|
||||||
const forEachPage = setupPages("300%", pixelRatio, -1);
|
const forEachPage = setupPages("300%", pixelRatio);
|
||||||
|
|
||||||
it("must not re-create the detail canvas", async () => {
|
it("must not re-create the detail canvas", async () => {
|
||||||
await forEachPage(async (browserName, page) => {
|
await forEachPage(async (browserName, page) => {
|
||||||
@ -799,7 +732,7 @@ describe("PDF viewer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("when scrolling to have two visible pages", () => {
|
describe("when scrolling to have two visible pages", () => {
|
||||||
const forEachPage = setupPages("300%", pixelRatio, -1);
|
const forEachPage = setupPages("300%", pixelRatio);
|
||||||
|
|
||||||
it("must update the detail view", async () => {
|
it("must update the detail view", async () => {
|
||||||
await forEachPage(async (browserName, page) => {
|
await forEachPage(async (browserName, page) => {
|
||||||
@ -872,7 +805,7 @@ describe("PDF viewer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("pagerendered event", () => {
|
describe("pagerendered event", () => {
|
||||||
const forEachPage = setupPages("100%", pixelRatio, -1, {
|
const forEachPage = setupPages("100%", pixelRatio, {
|
||||||
eventBusSetup: eventBus => {
|
eventBusSetup: eventBus => {
|
||||||
globalThis.__pageRenderedEvents = [];
|
globalThis.__pageRenderedEvents = [];
|
||||||
|
|
||||||
@ -1033,7 +966,7 @@ describe("PDF viewer", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("when immediately cancelled and re-rendered", () => {
|
describe("when immediately cancelled and re-rendered", () => {
|
||||||
const forEachPage = setupPages("100%", 1, -1, {
|
const forEachPage = setupPages("100%", 1, {
|
||||||
eventBusSetup: eventBus => {
|
eventBusSetup: eventBus => {
|
||||||
globalThis.__pageRenderedEvents = [];
|
globalThis.__pageRenderedEvents = [];
|
||||||
eventBus.on("pagerendered", ({ pageNumber, isDetailView }) => {
|
eventBus.on("pagerendered", ({ pageNumber, isDetailView }) => {
|
||||||
@ -1098,7 +1031,7 @@ describe("PDF viewer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("when cancelled and re-rendered after 1 microtick", () => {
|
describe("when cancelled and re-rendered after 1 microtick", () => {
|
||||||
const forEachPage = setupPages("100%", 1, -1, {
|
const forEachPage = setupPages("100%", 1, {
|
||||||
eventBusSetup: eventBus => {
|
eventBusSetup: eventBus => {
|
||||||
globalThis.__pageRenderedEvents = [];
|
globalThis.__pageRenderedEvents = [];
|
||||||
eventBus.on("pagerendered", ({ pageNumber, isDetailView }) => {
|
eventBus.on("pagerendered", ({ pageNumber, isDetailView }) => {
|
||||||
|
|||||||
@ -361,7 +361,6 @@ const PDFViewerApplication = {
|
|||||||
// Set some specific preferences for tests.
|
// Set some specific preferences for tests.
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
||||||
Object.assign(opts, {
|
Object.assign(opts, {
|
||||||
capCanvasAreaFactor: x => parseInt(x),
|
|
||||||
docBaseUrl: x => x,
|
docBaseUrl: x => x,
|
||||||
enableAltText: x => x === "true",
|
enableAltText: x => x === "true",
|
||||||
enableAutoLinking: x => x === "true",
|
enableAutoLinking: x => x === "true",
|
||||||
@ -486,8 +485,7 @@ const PDFViewerApplication = {
|
|||||||
|
|
||||||
const enableHWA = AppOptions.get("enableHWA"),
|
const enableHWA = AppOptions.get("enableHWA"),
|
||||||
maxCanvasPixels = AppOptions.get("maxCanvasPixels"),
|
maxCanvasPixels = AppOptions.get("maxCanvasPixels"),
|
||||||
maxCanvasDim = AppOptions.get("maxCanvasDim"),
|
maxCanvasDim = AppOptions.get("maxCanvasDim");
|
||||||
capCanvasAreaFactor = AppOptions.get("capCanvasAreaFactor");
|
|
||||||
const pdfViewer = (this.pdfViewer = new PDFViewer({
|
const pdfViewer = (this.pdfViewer = new PDFViewer({
|
||||||
container,
|
container,
|
||||||
viewer,
|
viewer,
|
||||||
@ -517,7 +515,6 @@ const PDFViewerApplication = {
|
|||||||
enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"),
|
enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"),
|
||||||
maxCanvasPixels,
|
maxCanvasPixels,
|
||||||
maxCanvasDim,
|
maxCanvasDim,
|
||||||
capCanvasAreaFactor,
|
|
||||||
enableDetailCanvas: AppOptions.get("enableDetailCanvas"),
|
enableDetailCanvas: AppOptions.get("enableDetailCanvas"),
|
||||||
enablePermissions: AppOptions.get("enablePermissions"),
|
enablePermissions: AppOptions.get("enablePermissions"),
|
||||||
pageColors,
|
pageColors,
|
||||||
|
|||||||
@ -168,11 +168,6 @@ const defaultOptions = {
|
|||||||
value: 2,
|
value: 2,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
capCanvasAreaFactor: {
|
|
||||||
/** @type {number} */
|
|
||||||
value: 200,
|
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
|
||||||
},
|
|
||||||
cursorToolOnLoad: {
|
cursorToolOnLoad: {
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
value: 0,
|
value: 0,
|
||||||
|
|||||||
@ -140,18 +140,10 @@ class PDFPageDetailView extends BasePDFPageView {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { viewport, capCanvasAreaFactor } = this.pageView;
|
const { viewport, maxCanvasPixels } = this.pageView;
|
||||||
|
|
||||||
const visibleWidth = visibleArea.maxX - visibleArea.minX;
|
const visibleWidth = visibleArea.maxX - visibleArea.minX;
|
||||||
const visibleHeight = visibleArea.maxY - visibleArea.minY;
|
const visibleHeight = visibleArea.maxY - visibleArea.minY;
|
||||||
let { maxCanvasPixels } = this.pageView;
|
|
||||||
|
|
||||||
if (capCanvasAreaFactor >= 0) {
|
|
||||||
maxCanvasPixels = Math.min(
|
|
||||||
maxCanvasPixels,
|
|
||||||
OutputScale.getCappedWindowArea(capCanvasAreaFactor)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// "overflowScale" represents which percentage of the width and of the
|
// "overflowScale" represents which percentage of the width and of the
|
||||||
// height the detail area extends outside of the visible area. We want to
|
// height the detail area extends outside of the visible area. We want to
|
||||||
|
|||||||
@ -81,9 +81,6 @@ import { XfaLayerBuilder } from "./xfa_layer_builder.js";
|
|||||||
* @property {number} [maxCanvasDim] - The maximum supported canvas dimension,
|
* @property {number} [maxCanvasDim] - The maximum supported canvas dimension,
|
||||||
* in either width or height. Use `-1` for no limit.
|
* in either width or height. Use `-1` for no limit.
|
||||||
* The default value is 32767.
|
* The default value is 32767.
|
||||||
* @property {number} [capCanvasAreaFactor] - Cap the canvas area to the
|
|
||||||
* viewport increased by the value in percent. Use `-1` for no limit.
|
|
||||||
* The default value is 200%.
|
|
||||||
* @property {boolean} [enableDetailCanvas] - When enabled, if the rendered
|
* @property {boolean} [enableDetailCanvas] - When enabled, if the rendered
|
||||||
* pages would need a canvas that is larger than `maxCanvasPixels` or
|
* pages would need a canvas that is larger than `maxCanvasPixels` or
|
||||||
* `maxCanvasDim`, it will draw a second canvas on top of the CSS-zoomed one,
|
* `maxCanvasDim`, it will draw a second canvas on top of the CSS-zoomed one,
|
||||||
@ -191,8 +188,6 @@ class PDFPageView extends BasePDFPageView {
|
|||||||
this.maxCanvasPixels =
|
this.maxCanvasPixels =
|
||||||
options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels");
|
options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels");
|
||||||
this.maxCanvasDim = options.maxCanvasDim || AppOptions.get("maxCanvasDim");
|
this.maxCanvasDim = options.maxCanvasDim || AppOptions.get("maxCanvasDim");
|
||||||
this.capCanvasAreaFactor =
|
|
||||||
options.capCanvasAreaFactor ?? AppOptions.get("capCanvasAreaFactor");
|
|
||||||
this.#enableAutoLinking = options.enableAutoLinking !== false;
|
this.#enableAutoLinking = options.enableAutoLinking !== false;
|
||||||
|
|
||||||
this.l10n = options.l10n;
|
this.l10n = options.l10n;
|
||||||
@ -453,6 +448,7 @@ class PDFPageView extends BasePDFPageView {
|
|||||||
if (!this.textLayer) {
|
if (!this.textLayer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
try {
|
try {
|
||||||
await this.textLayer.render({
|
await this.textLayer.render({
|
||||||
@ -784,8 +780,7 @@ class PDFPageView extends BasePDFPageView {
|
|||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
this.maxCanvasPixels,
|
this.maxCanvasPixels,
|
||||||
this.maxCanvasDim,
|
this.maxCanvasDim
|
||||||
this.capCanvasAreaFactor
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,9 +122,6 @@ function isValidAnnotationEditorMode(mode) {
|
|||||||
* @property {number} [maxCanvasDim] - The maximum supported canvas dimension,
|
* @property {number} [maxCanvasDim] - The maximum supported canvas dimension,
|
||||||
* in either width or height. Use `-1` for no limit.
|
* in either width or height. Use `-1` for no limit.
|
||||||
* The default value is 32767.
|
* The default value is 32767.
|
||||||
* @property {number} [capCanvasAreaFactor] - Cap the canvas area to the
|
|
||||||
* viewport increased by the value in percent. Use `-1` for no limit.
|
|
||||||
* The default value is 200%.
|
|
||||||
* @property {boolean} [enableDetailCanvas] - When enabled, if the rendered
|
* @property {boolean} [enableDetailCanvas] - When enabled, if the rendered
|
||||||
* pages would need a canvas that is larger than `maxCanvasPixels` or
|
* pages would need a canvas that is larger than `maxCanvasPixels` or
|
||||||
* `maxCanvasDim`, it will draw a second canvas on top of the CSS-zoomed one,
|
* `maxCanvasDim`, it will draw a second canvas on top of the CSS-zoomed one,
|
||||||
@ -338,7 +335,6 @@ class PDFViewer {
|
|||||||
}
|
}
|
||||||
this.maxCanvasPixels = options.maxCanvasPixels;
|
this.maxCanvasPixels = options.maxCanvasPixels;
|
||||||
this.maxCanvasDim = options.maxCanvasDim;
|
this.maxCanvasDim = options.maxCanvasDim;
|
||||||
this.capCanvasAreaFactor = options.capCanvasAreaFactor;
|
|
||||||
this.enableDetailCanvas = options.enableDetailCanvas ?? true;
|
this.enableDetailCanvas = options.enableDetailCanvas ?? true;
|
||||||
this.l10n = options.l10n;
|
this.l10n = options.l10n;
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
@ -1006,7 +1002,6 @@ class PDFViewer {
|
|||||||
imageResourcesPath: this.imageResourcesPath,
|
imageResourcesPath: this.imageResourcesPath,
|
||||||
maxCanvasPixels: this.maxCanvasPixels,
|
maxCanvasPixels: this.maxCanvasPixels,
|
||||||
maxCanvasDim: this.maxCanvasDim,
|
maxCanvasDim: this.maxCanvasDim,
|
||||||
capCanvasAreaFactor: this.capCanvasAreaFactor,
|
|
||||||
enableDetailCanvas: this.enableDetailCanvas,
|
enableDetailCanvas: this.enableDetailCanvas,
|
||||||
pageColors,
|
pageColors,
|
||||||
l10n: this.l10n,
|
l10n: this.l10n,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user