Compare commits

..

No commits in common. "293506ada7c98fb3b46ec01b373f9fd391c587c8" and "69595a29192b7704733404a42a2ebb537601117b" have entirely different histories.

9 changed files with 136 additions and 206 deletions

View File

@ -172,10 +172,6 @@
"enum": [-1, 0, 3, 15],
"default": 0
},
"capCanvasAreaFactor": {
"type": "integer",
"default": 200
},
"enablePermissions": {
"type": "boolean",
"default": false

View File

@ -79,8 +79,6 @@ import { XRef } from "./xref.js";
const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
class Page {
#resourcesPromise = null;
constructor({
pdfManager,
xref,
@ -110,6 +108,7 @@ class Page {
this.systemFontCache = systemFontCache;
this.nonBlendModesSet = nonBlendModesSet;
this.evaluatorOptions = pdfManager.evaluatorOptions;
this.resourcesPromise = null;
this.xfaFactory = xfaFactory;
const idCounters = {
@ -126,23 +125,10 @@ class Page {
};
}
#createPartialEvaluator(handler) {
return 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,
});
}
#getInheritableProperty(key, getArray = false) {
/**
* @private
*/
_getInheritableProperty(key, getArray = false) {
const value = getInheritableProperty({
dict: this.pageDict,
key,
@ -166,7 +152,7 @@ class Page {
// 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
// we return an empty dictionary.
const resources = this.#getInheritableProperty("Resources");
const resources = this._getInheritableProperty("Resources");
return shadow(
this,
@ -175,12 +161,12 @@ class Page {
);
}
#getBoundingBox(name) {
_getBoundingBox(name) {
if (this.xfaData) {
return this.xfaData.bbox;
}
const box = lookupNormalRect(
this.#getInheritableProperty(name, /* getArray = */ true),
this._getInheritableProperty(name, /* getArray = */ true),
null
);
@ -198,7 +184,7 @@ class Page {
return shadow(
this,
"mediaBox",
this.#getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX
this._getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX
);
}
@ -207,7 +193,7 @@ class Page {
return shadow(
this,
"cropBox",
this.#getBoundingBox("CropBox") || this.mediaBox
this._getBoundingBox("CropBox") || this.mediaBox
);
}
@ -238,7 +224,7 @@ class Page {
}
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.
if (rotate % 90 !== 0) {
@ -253,7 +239,10 @@ class Page {
return shadow(this, "rotate", rotate);
}
#onSubStreamError(reason, objId) {
/**
* @private
*/
_onSubStreamError(reason, objId) {
if (this.evaluatorOptions.ignoreErrors) {
warn(`getContentStream - ignoring sub-stream (${objId}): "${reason}".`);
return;
@ -273,7 +262,7 @@ class Page {
if (Array.isArray(content)) {
return new StreamsSequenceStream(
content,
this.#onSubStreamError.bind(this)
this._onSubStreamError.bind(this)
);
}
// Replace non-existent page content with empty content.
@ -333,7 +322,20 @@ class Page {
if (this.xfaFactory) {
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 existingAnnotations = new RefSet();
@ -376,7 +378,19 @@ class Page {
}
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
// in case of interactive form fields.
@ -400,11 +414,8 @@ class Page {
}
async loadResources(keys) {
// TODO: add async `#getInheritableProperty` and remove this.
await (this.#resourcesPromise ??= this.pdfManager.ensure(
this,
"resources"
));
// TODO: add async `_getInheritableProperty` and remove this.
await (this.resourcesPromise ??= this.pdfManager.ensure(this, "resources"));
await ObjectLoader.load(this.resources, keys, this.xref);
}
@ -439,7 +450,19 @@ class Page {
const contentStreamPromise = this.getContentStream();
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
? getNewAnnotationsMap(annotationStorage)
@ -647,7 +670,19 @@ class Page {
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({
stream: contentStream,
@ -716,7 +751,19 @@ class Page {
}
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(
annotation
@ -740,7 +787,7 @@ class Page {
}
get annotations() {
const annots = this.#getInheritableProperty("Annots");
const annots = this._getInheritableProperty("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.
*/
class PDFDocument {
#pagePromises = new Map();
#version = null;
constructor(pdfManager, stream) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
@ -900,6 +943,8 @@ class PDFDocument {
this.pdfManager = pdfManager;
this.stream = stream;
this.xref = new XRef(stream, pdfManager);
this._pagePromises = new Map();
this._version = null;
const idCounters = {
font: 0,
@ -1020,7 +1065,7 @@ class PDFDocument {
}
if (PDF_VERSION_REGEXP.test(version)) {
this.#version = version;
this._version = version;
} else {
warn(`Invalid PDF header version: ${version}`);
}
@ -1045,7 +1090,10 @@ class PDFDocument {
return shadow(this, "numPages", num);
}
#hasOnlyDocumentSignatures(fields, recursionDepth = 0) {
/**
* @private
*/
_hasOnlyDocumentSignatures(fields, recursionDepth = 0) {
const RECURSION_LIMIT = 10;
if (!Array.isArray(fields)) {
@ -1058,10 +1106,10 @@ class PDFDocument {
}
if (field.has("Kids")) {
if (++recursionDepth > RECURSION_LIMIT) {
warn("#hasOnlyDocumentSignatures: maximum recursion depth reached");
warn("_hasOnlyDocumentSignatures: maximum recursion depth reached");
return false;
}
return this.#hasOnlyDocumentSignatures(
return this._hasOnlyDocumentSignatures(
field.get("Kids"),
recursionDepth
);
@ -1353,7 +1401,7 @@ class PDFDocument {
* the catalog, if present, should overwrite the version from the header.
*/
get version() {
return this.catalog.version || this.#version;
return this.catalog.version || this._version;
}
get formInfo() {
@ -1363,7 +1411,7 @@ class PDFDocument {
hasXfa: false,
hasSignatures: false,
};
const { acroForm } = this.catalog;
const acroForm = this.catalog.acroForm;
if (!acroForm) {
return shadow(this, "formInfo", formInfo);
}
@ -1390,7 +1438,7 @@ class PDFDocument {
const sigFlags = acroForm.get("SigFlags");
const hasSignatures = !!(sigFlags & 0x1);
const hasOnlyDocumentSignatures =
hasSignatures && this.#hasOnlyDocumentSignatures(fields);
hasSignatures && this._hasOnlyDocumentSignatures(fields);
formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
formInfo.hasSignatures = hasSignatures;
} catch (ex) {
@ -1403,22 +1451,22 @@ class PDFDocument {
}
get documentInfo() {
const { catalog, formInfo, xref } = this;
const docInfo = {
PDFFormatVersion: this.version,
Language: catalog.lang,
EncryptFilterName: xref.encrypt?.filterName ?? null,
Language: this.catalog.lang,
EncryptFilterName: this.xref.encrypt
? this.xref.encrypt.filterName
: null,
IsLinearized: !!this.linearization,
IsAcroFormPresent: formInfo.hasAcroForm,
IsXFAPresent: formInfo.hasXfa,
IsCollectionPresent: !!catalog.collection,
IsSignaturesPresent: formInfo.hasSignatures,
IsAcroFormPresent: this.formInfo.hasAcroForm,
IsXFAPresent: this.formInfo.hasXfa,
IsCollectionPresent: !!this.catalog.collection,
IsSignaturesPresent: this.formInfo.hasSignatures,
};
let infoDict;
try {
infoDict = xref.trailer.get("Info");
infoDict = this.xref.trailer.get("Info");
} catch (err) {
if (err instanceof MissingDataException) {
throw err;
@ -1517,7 +1565,7 @@ class PDFDocument {
]);
}
async #getLinearizationPage(pageIndex) {
async _getLinearizationPage(pageIndex) {
const { catalog, linearization, xref } = this;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
@ -1560,7 +1608,7 @@ class PDFDocument {
}
getPage(pageIndex) {
const cachedPromise = this.#pagePromises.get(pageIndex);
const cachedPromise = this._pagePromises.get(pageIndex);
if (cachedPromise) {
return cachedPromise;
}
@ -1570,7 +1618,7 @@ class PDFDocument {
if (xfaFactory) {
promise = Promise.resolve([Dict.empty, null]);
} else if (linearization?.pageFirst === pageIndex) {
promise = this.#getLinearizationPage(pageIndex);
promise = this._getLinearizationPage(pageIndex);
} else {
promise = catalog.getPageDict(pageIndex);
}
@ -1594,7 +1642,7 @@ class PDFDocument {
})
);
this.#pagePromises.set(pageIndex, promise);
this._pagePromises.set(pageIndex, promise);
return promise;
}
@ -1609,7 +1657,7 @@ class PDFDocument {
// Clear out the various caches to ensure that we haven't stored any
// inconsistent and/or incorrect state, since that could easily break
// subsequent `this.getPage` calls.
this.#pagePromises.delete(0);
this._pagePromises.delete(0);
await this.cleanup();
throw new XRefParseException();
@ -1648,7 +1696,7 @@ class PDFDocument {
// Clear out the various caches to ensure that we haven't stored any
// inconsistent and/or incorrect state, since that could easily break
// subsequent `this.getPage` calls.
this.#pagePromises.delete(numPages - 1);
this._pagePromises.delete(numPages - 1);
await this.cleanup();
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);
}
@ -1823,17 +1871,20 @@ class PDFDocument {
if (!formInfo.hasFields) {
return null;
}
const annotationGlobals = await this.annotationGlobals;
const [annotationGlobals, acroForm] = await Promise.all([
this.pdfManager.ensureDoc("annotationGlobals"),
this.pdfManager.ensureCatalog("acroForm"),
]);
if (!annotationGlobals) {
return null;
}
const { acroForm } = annotationGlobals;
const visitedRefs = new RefSet();
const allFields = Object.create(null);
const fieldPromises = new Map();
const orphanFields = new RefSetCache();
for (const fieldRef of acroForm.get("Fields")) {
for (const fieldRef of await acroForm.getAsync("Fields")) {
await this.#collectFieldObjects(
"",
null,

View File

@ -660,18 +660,11 @@ class OutputScale {
* @returns {boolean} Returns `true` if scaling was limited,
* `false` otherwise.
*/
limitCanvas(width, height, maxPixels, maxDim, capAreaFactor = -1) {
limitCanvas(width, height, maxPixels, maxDim) {
let maxAreaScale = Infinity,
maxWidthScale = Infinity,
maxHeightScale = Infinity;
if (capAreaFactor >= 0) {
const cappedWindowArea = OutputScale.getCappedWindowArea(capAreaFactor);
maxPixels =
maxPixels > 0
? Math.min(maxPixels, cappedWindowArea)
: cappedWindowArea;
}
if (maxPixels > 0) {
maxAreaScale = Math.sqrt(maxPixels / (width * height));
}
@ -692,23 +685,6 @@ class OutputScale {
static get pixelRatio() {
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

View File

@ -389,9 +389,7 @@ describe("PDF viewer", () => {
pages = await loadAndWait(
"issue18694.pdf",
".textLayer .endOfContent",
"page-width",
null,
{ capCanvasAreaFactor: -1 }
"page-width"
);
});
@ -461,12 +459,7 @@ describe("PDF viewer", () => {
describe("Detail view on zoom", () => {
const BASE_MAX_CANVAS_PIXELS = 1e6;
function setupPages(
zoom,
devicePixelRatio,
capCanvasAreaFactor,
setups = {}
) {
function setupPages(zoom, devicePixelRatio, setups = {}) {
let pages;
beforeEach(async () => {
@ -483,10 +476,7 @@ describe("PDF viewer", () => {
}`,
...setups,
},
{
maxCanvasPixels: BASE_MAX_CANVAS_PIXELS * devicePixelRatio ** 2,
capCanvasAreaFactor,
},
{ maxCanvasPixels: BASE_MAX_CANVAS_PIXELS * devicePixelRatio ** 2 },
{ height: 600, width: 800, devicePixelRatio }
);
});
@ -513,8 +503,6 @@ describe("PDF viewer", () => {
const bottomRight = ctx.getImageData(width - 3, height - 3, 1, 1).data;
return {
size: width * height,
width,
height,
topLeft: globalThis.pdfjsLib.Util.makeHexColor(...topLeft),
bottomRight: globalThis.pdfjsLib.Util.makeHexColor(...bottomRight),
};
@ -540,7 +528,7 @@ describe("PDF viewer", () => {
for (const pixelRatio of [1, 2]) {
describe(`with pixel ratio ${pixelRatio}`, () => {
describe("setupPages()", () => {
const forEachPage = setupPages("100%", pixelRatio, -1);
const forEachPage = setupPages("100%", pixelRatio);
it("sets the proper devicePixelRatio", async () => {
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", () => {
const forEachPage = setupPages("100%", pixelRatio, -1);
const forEachPage = setupPages("100%", pixelRatio);
it("must render the detail view", async () => {
await forEachPage(async (browserName, page) => {
@ -683,7 +616,7 @@ describe("PDF viewer", () => {
});
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 () => {
await forEachPage(async (browserName, page) => {
@ -721,7 +654,7 @@ describe("PDF viewer", () => {
});
describe("when scrolling", () => {
const forEachPage = setupPages("300%", pixelRatio, -1);
const forEachPage = setupPages("300%", pixelRatio);
it("must update the detail view", async () => {
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", () => {
const forEachPage = setupPages("300%", pixelRatio, -1);
const forEachPage = setupPages("300%", pixelRatio);
it("must not re-create the detail canvas", async () => {
await forEachPage(async (browserName, page) => {
@ -799,7 +732,7 @@ describe("PDF viewer", () => {
});
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 () => {
await forEachPage(async (browserName, page) => {
@ -872,7 +805,7 @@ describe("PDF viewer", () => {
});
describe("pagerendered event", () => {
const forEachPage = setupPages("100%", pixelRatio, -1, {
const forEachPage = setupPages("100%", pixelRatio, {
eventBusSetup: eventBus => {
globalThis.__pageRenderedEvents = [];
@ -1033,7 +966,7 @@ describe("PDF viewer", () => {
}
describe("when immediately cancelled and re-rendered", () => {
const forEachPage = setupPages("100%", 1, -1, {
const forEachPage = setupPages("100%", 1, {
eventBusSetup: eventBus => {
globalThis.__pageRenderedEvents = [];
eventBus.on("pagerendered", ({ pageNumber, isDetailView }) => {
@ -1098,7 +1031,7 @@ describe("PDF viewer", () => {
});
describe("when cancelled and re-rendered after 1 microtick", () => {
const forEachPage = setupPages("100%", 1, -1, {
const forEachPage = setupPages("100%", 1, {
eventBusSetup: eventBus => {
globalThis.__pageRenderedEvents = [];
eventBus.on("pagerendered", ({ pageNumber, isDetailView }) => {

View File

@ -361,7 +361,6 @@ const PDFViewerApplication = {
// Set some specific preferences for tests.
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
Object.assign(opts, {
capCanvasAreaFactor: x => parseInt(x),
docBaseUrl: x => x,
enableAltText: x => x === "true",
enableAutoLinking: x => x === "true",
@ -486,8 +485,7 @@ const PDFViewerApplication = {
const enableHWA = AppOptions.get("enableHWA"),
maxCanvasPixels = AppOptions.get("maxCanvasPixels"),
maxCanvasDim = AppOptions.get("maxCanvasDim"),
capCanvasAreaFactor = AppOptions.get("capCanvasAreaFactor");
maxCanvasDim = AppOptions.get("maxCanvasDim");
const pdfViewer = (this.pdfViewer = new PDFViewer({
container,
viewer,
@ -517,7 +515,6 @@ const PDFViewerApplication = {
enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"),
maxCanvasPixels,
maxCanvasDim,
capCanvasAreaFactor,
enableDetailCanvas: AppOptions.get("enableDetailCanvas"),
enablePermissions: AppOptions.get("enablePermissions"),
pageColors,

View File

@ -168,11 +168,6 @@ const defaultOptions = {
value: 2,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
capCanvasAreaFactor: {
/** @type {number} */
value: 200,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
cursorToolOnLoad: {
/** @type {number} */
value: 0,

View File

@ -140,18 +140,10 @@ class PDFPageDetailView extends BasePDFPageView {
return;
}
const { viewport, capCanvasAreaFactor } = this.pageView;
const { viewport, maxCanvasPixels } = this.pageView;
const visibleWidth = visibleArea.maxX - visibleArea.minX;
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
// height the detail area extends outside of the visible area. We want to

View File

@ -81,9 +81,6 @@ import { XfaLayerBuilder } from "./xfa_layer_builder.js";
* @property {number} [maxCanvasDim] - The maximum supported canvas dimension,
* in either width or height. Use `-1` for no limit.
* 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
* 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,
@ -191,8 +188,6 @@ class PDFPageView extends BasePDFPageView {
this.maxCanvasPixels =
options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels");
this.maxCanvasDim = options.maxCanvasDim || AppOptions.get("maxCanvasDim");
this.capCanvasAreaFactor =
options.capCanvasAreaFactor ?? AppOptions.get("capCanvasAreaFactor");
this.#enableAutoLinking = options.enableAutoLinking !== false;
this.l10n = options.l10n;
@ -453,6 +448,7 @@ class PDFPageView extends BasePDFPageView {
if (!this.textLayer) {
return;
}
let error = null;
try {
await this.textLayer.render({
@ -784,8 +780,7 @@ class PDFPageView extends BasePDFPageView {
width,
height,
this.maxCanvasPixels,
this.maxCanvasDim,
this.capCanvasAreaFactor
this.maxCanvasDim
);
}
}

View File

@ -122,9 +122,6 @@ function isValidAnnotationEditorMode(mode) {
* @property {number} [maxCanvasDim] - The maximum supported canvas dimension,
* in either width or height. Use `-1` for no limit.
* 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
* 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,
@ -338,7 +335,6 @@ class PDFViewer {
}
this.maxCanvasPixels = options.maxCanvasPixels;
this.maxCanvasDim = options.maxCanvasDim;
this.capCanvasAreaFactor = options.capCanvasAreaFactor;
this.enableDetailCanvas = options.enableDetailCanvas ?? true;
this.l10n = options.l10n;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
@ -1006,7 +1002,6 @@ class PDFViewer {
imageResourcesPath: this.imageResourcesPath,
maxCanvasPixels: this.maxCanvasPixels,
maxCanvasDim: this.maxCanvasDim,
capCanvasAreaFactor: this.capCanvasAreaFactor,
enableDetailCanvas: this.enableDetailCanvas,
pageColors,
l10n: this.l10n,