mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-11-30 16:37:18 +01:00
[api-major] Remove the maxImageSize option from getDocument
This option is removed now, since: - It was originally added for the Boot to Gecko (B2G) project, later renamed to Firefox OS, which was discontinued in 2016. This option was needed then, since B2G was intended to also run on low-end hardware. - Outside of one example, which is a left-over from the B2G viewer, this option has been unused in the PDF.js project itself for a decade. - This option has never been covered by *any* tests. - The result of setting this option to a non-default value is that some images will not renderer, with only a console warning, which could easily make PDF.js appear "broken" to an end-user. - Image decoding performance, in particular for large and/or complex images, has been significantly improved compared to a decade ago. - If such an option was requested today, it seems unlikely that we'd actually consider adding it.
This commit is contained in:
@@ -19,7 +19,6 @@ if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
|
||||
}
|
||||
|
||||
const TEXT_LAYER_MODE = 0; // DISABLE
|
||||
const MAX_IMAGE_SIZE = 1024 * 1024;
|
||||
const CMAP_URL = "../../node_modules/pdfjs-dist/cmaps/";
|
||||
const CMAP_PACKED = true;
|
||||
|
||||
@@ -57,7 +56,6 @@ const PDFViewerApplication = {
|
||||
// Loading document.
|
||||
const loadingTask = pdfjsLib.getDocument({
|
||||
url,
|
||||
maxImageSize: MAX_IMAGE_SIZE,
|
||||
cMapUrl: CMAP_URL,
|
||||
cMapPacked: CMAP_PACKED,
|
||||
});
|
||||
|
||||
+1
-12
@@ -93,7 +93,6 @@ import { Stream } from "./stream.js";
|
||||
import { stringToPDFString } from "./string_utils.js";
|
||||
|
||||
const DefaultPartialEvaluatorOptions = Object.freeze({
|
||||
maxImageSize: -1,
|
||||
disableFontFace: false,
|
||||
ignoreErrors: false,
|
||||
isOffscreenCanvasSupported: false,
|
||||
@@ -570,8 +569,7 @@ class PartialEvaluator {
|
||||
localImageCache,
|
||||
localColorSpaceCache,
|
||||
}) {
|
||||
const { maxImageSize, ignoreErrors, isOffscreenCanvasSupported } =
|
||||
this.options;
|
||||
const { ignoreErrors, isOffscreenCanvasSupported } = this.options;
|
||||
|
||||
const { dict } = image;
|
||||
const imageRef = dict.objId;
|
||||
@@ -582,15 +580,6 @@ class PartialEvaluator {
|
||||
warn("Image dimensions are missing, or not numbers.");
|
||||
return;
|
||||
}
|
||||
if (maxImageSize !== -1 && w * h > maxImageSize) {
|
||||
const msg = "Image exceeded maximum allowed size and was removed.";
|
||||
|
||||
if (!ignoreErrors) {
|
||||
throw new Error(msg);
|
||||
}
|
||||
warn(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
let optionalContent;
|
||||
if (dict.has("OC")) {
|
||||
|
||||
@@ -151,9 +151,6 @@ const RENDERING_CANCELLED_TIMEOUT = 100; // ms
|
||||
* `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
|
||||
* PDF data cannot be successfully parsed, instead of attempting to recover
|
||||
* whatever possible of the data. The default value is `false`.
|
||||
* @property {number} [maxImageSize] - The maximum allowed image size in total
|
||||
* pixels, i.e. width * height. Images above this value will not be rendered.
|
||||
* Use -1 for no limit, which is also the default value.
|
||||
* @property {boolean} [isOffscreenCanvasSupported] - Determines if we can use
|
||||
* `OffscreenCanvas` in the worker. Primarily used to improve performance of
|
||||
* image conversion/rendering.
|
||||
@@ -255,10 +252,6 @@ function getDocument(src = {}) {
|
||||
const standardFontDataUrl = getFactoryUrlProp(src.standardFontDataUrl);
|
||||
const wasmUrl = getFactoryUrlProp(src.wasmUrl);
|
||||
const ignoreErrors = src.stopAtErrors !== true;
|
||||
const maxImageSize =
|
||||
Number.isInteger(src.maxImageSize) && src.maxImageSize > -1
|
||||
? src.maxImageSize
|
||||
: -1;
|
||||
const isOffscreenCanvasSupported =
|
||||
typeof src.isOffscreenCanvasSupported === "boolean"
|
||||
? src.isOffscreenCanvasSupported
|
||||
@@ -388,7 +381,6 @@ function getDocument(src = {}) {
|
||||
docBaseUrl,
|
||||
enableXfa,
|
||||
evaluatorOptions: {
|
||||
maxImageSize,
|
||||
disableFontFace,
|
||||
ignoreErrors,
|
||||
isOffscreenCanvasSupported,
|
||||
|
||||
@@ -864,14 +864,6 @@ const defaultOptions = new Map([
|
||||
kind: OptionKind.API,
|
||||
},
|
||||
],
|
||||
[
|
||||
"maxImageSize",
|
||||
{
|
||||
/** @type {number} */
|
||||
value: -1,
|
||||
kind: OptionKind.API,
|
||||
},
|
||||
],
|
||||
[
|
||||
"pdfBug",
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user