[api-minor] Remove the disableCreateObjectURL
option from the getDocument
parameters, since it's now unused in the API
With the changes in previous patches, the `disableCreateObjectURL` option/functionality is no longer used for anything in the API and/or in the Worker code. Note however that there's some functionality, mainly related to file loading/downloading, in the GENERIC version of the default viewer which still depends on this option. Hence the `disableCreateObjectURL` option (and related compatibility code) is moved into the viewer, see e.g. `web/app_options.js`, such that it's still available in the default viewer.
This commit is contained in:
parent
cc4cc8b11b
commit
18e0b10d3c
@ -85,7 +85,6 @@ import { PDFImage } from "./image.js";
|
|||||||
|
|
||||||
var PartialEvaluator = (function PartialEvaluatorClosure() {
|
var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||||
const DefaultPartialEvaluatorOptions = {
|
const DefaultPartialEvaluatorOptions = {
|
||||||
forceDataSchema: false,
|
|
||||||
maxImageSize: -1,
|
maxImageSize: -1,
|
||||||
disableFontFace: false,
|
disableFontFace: false,
|
||||||
ignoreErrors: false,
|
ignoreErrors: false,
|
||||||
|
@ -399,7 +399,6 @@ var WorkerMessageHandler = {
|
|||||||
ensureNotTerminated();
|
ensureNotTerminated();
|
||||||
|
|
||||||
var evaluatorOptions = {
|
var evaluatorOptions = {
|
||||||
forceDataSchema: data.disableCreateObjectURL,
|
|
||||||
maxImageSize: data.maxImageSize,
|
maxImageSize: data.maxImageSize,
|
||||||
disableFontFace: data.disableFontFace,
|
disableFontFace: data.disableFontFace,
|
||||||
ignoreErrors: data.ignoreErrors,
|
ignoreErrors: data.ignoreErrors,
|
||||||
|
@ -154,9 +154,6 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
|
|||||||
* The default value is `false`.
|
* The default value is `false`.
|
||||||
* NOTE: It is also necessary to disable streaming, see above,
|
* NOTE: It is also necessary to disable streaming, see above,
|
||||||
* in order for disabling of pre-fetching to work correctly.
|
* in order for disabling of pre-fetching to work correctly.
|
||||||
* @property {boolean} [disableCreateObjectURL] - Disable the use of
|
|
||||||
* `URL.createObjectURL`, for compatibility with older browsers.
|
|
||||||
* The default value is `false`.
|
|
||||||
* @property {boolean} [pdfBug] - Enables special hooks for debugging
|
* @property {boolean} [pdfBug] - Enables special hooks for debugging
|
||||||
* PDF.js (see `web/debugger.js`). The default value is `false`.
|
* PDF.js (see `web/debugger.js`). The default value is `false`.
|
||||||
*/
|
*/
|
||||||
@ -269,10 +266,6 @@ function getDocument(src) {
|
|||||||
if (typeof params.disableAutoFetch !== "boolean") {
|
if (typeof params.disableAutoFetch !== "boolean") {
|
||||||
params.disableAutoFetch = false;
|
params.disableAutoFetch = false;
|
||||||
}
|
}
|
||||||
if (typeof params.disableCreateObjectURL !== "boolean") {
|
|
||||||
params.disableCreateObjectURL =
|
|
||||||
apiCompatibilityParams.disableCreateObjectURL || false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the main-thread verbosity level.
|
// Set the main-thread verbosity level.
|
||||||
setVerbosityLevel(params.verbosity);
|
setVerbosityLevel(params.verbosity);
|
||||||
@ -395,7 +388,6 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||||||
},
|
},
|
||||||
maxImageSize: source.maxImageSize,
|
maxImageSize: source.maxImageSize,
|
||||||
disableFontFace: source.disableFontFace,
|
disableFontFace: source.disableFontFace,
|
||||||
disableCreateObjectURL: source.disableCreateObjectURL,
|
|
||||||
postMessageTransfers: worker.postMessageTransfers,
|
postMessageTransfers: worker.postMessageTransfers,
|
||||||
docBaseUrl: source.docBaseUrl,
|
docBaseUrl: source.docBaseUrl,
|
||||||
ignoreErrors: source.ignoreErrors,
|
ignoreErrors: source.ignoreErrors,
|
||||||
@ -2505,7 +2497,6 @@ class WorkerTransport {
|
|||||||
const params = this._params;
|
const params = this._params;
|
||||||
return shadow(this, "loadingParams", {
|
return shadow(this, "loadingParams", {
|
||||||
disableAutoFetch: params.disableAutoFetch,
|
disableAutoFetch: params.disableAutoFetch,
|
||||||
disableCreateObjectURL: params.disableCreateObjectURL,
|
|
||||||
disableFontFace: params.disableFontFace,
|
disableFontFace: params.disableFontFace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -17,21 +17,6 @@ import { isNodeJS } from "../shared/is_node.js";
|
|||||||
|
|
||||||
const compatibilityParams = Object.create(null);
|
const compatibilityParams = Object.create(null);
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
const userAgent =
|
|
||||||
(typeof navigator !== "undefined" && navigator.userAgent) || "";
|
|
||||||
const isIE = /Trident/.test(userAgent);
|
|
||||||
const isIOSChrome = /CriOS/.test(userAgent);
|
|
||||||
|
|
||||||
// Checks if possible to use URL.createObjectURL()
|
|
||||||
// Support: IE, Chrome on iOS
|
|
||||||
(function checkOnBlobSupport() {
|
|
||||||
// Sometimes IE and Chrome on iOS losing the data created with
|
|
||||||
// createObjectURL(), see issues #3977 and #8081.
|
|
||||||
if (isIE || isIOSChrome) {
|
|
||||||
compatibilityParams.disableCreateObjectURL = true;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Support: Node.js
|
// Support: Node.js
|
||||||
(function checkFontFace() {
|
(function checkFontFace() {
|
||||||
// Node.js is missing native support for `@font-face`.
|
// Node.js is missing native support for `@font-face`.
|
||||||
|
@ -440,7 +440,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
|||||||
|
|
||||||
// eslint-disable-next-line no-shadow
|
// eslint-disable-next-line no-shadow
|
||||||
SVGGraphics = class SVGGraphics {
|
SVGGraphics = class SVGGraphics {
|
||||||
constructor(commonObjs, objs, forceDataSchema) {
|
constructor(commonObjs, objs, forceDataSchema = false) {
|
||||||
this.svgFactory = new DOMSVGFactory();
|
this.svgFactory = new DOMSVGFactory();
|
||||||
|
|
||||||
this.current = new SVGExtraState();
|
this.current = new SVGExtraState();
|
||||||
|
@ -2223,7 +2223,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
|||||||
}
|
}
|
||||||
const file = evt.fileInput.files[0];
|
const file = evt.fileInput.files[0];
|
||||||
|
|
||||||
if (URL.createObjectURL && !AppOptions.get("disableCreateObjectURL")) {
|
if (!AppOptions.get("disableCreateObjectURL")) {
|
||||||
let url = URL.createObjectURL(file);
|
let url = URL.createObjectURL(file);
|
||||||
if (file.name) {
|
if (file.name) {
|
||||||
url = { url, originalUrl: file.name };
|
url = { url, originalUrl: file.name };
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { apiCompatibilityParams } from "pdfjs-lib";
|
|
||||||
import { viewerCompatibilityParams } from "./viewer_compatibility.js";
|
import { viewerCompatibilityParams } from "./viewer_compatibility.js";
|
||||||
|
|
||||||
const OptionKind = {
|
const OptionKind = {
|
||||||
@ -43,6 +42,12 @@ const defaultOptions = {
|
|||||||
value: "",
|
value: "",
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
|
disableCreateObjectURL: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: false,
|
||||||
|
compatibility: viewerCompatibilityParams.disableCreateObjectURL,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
disableHistory: {
|
disableHistory: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: false,
|
value: false,
|
||||||
@ -174,12 +179,6 @@ const defaultOptions = {
|
|||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.API + OptionKind.PREFERENCE,
|
kind: OptionKind.API + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
disableCreateObjectURL: {
|
|
||||||
/** @type {boolean} */
|
|
||||||
value: false,
|
|
||||||
compatibility: apiCompatibilityParams.disableCreateObjectURL,
|
|
||||||
kind: OptionKind.API,
|
|
||||||
},
|
|
||||||
disableFontFace: {
|
disableFontFace: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: false,
|
value: false,
|
||||||
|
@ -13,11 +13,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { createObjectURL, createValidAbsoluteUrl } from "pdfjs-lib";
|
||||||
apiCompatibilityParams,
|
import { viewerCompatibilityParams } from "./viewer_compatibility.js";
|
||||||
createObjectURL,
|
|
||||||
createValidAbsoluteUrl,
|
|
||||||
} from "pdfjs-lib";
|
|
||||||
|
|
||||||
if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("CHROME || GENERIC")) {
|
if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("CHROME || GENERIC")) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -27,7 +24,7 @@ if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("CHROME || GENERIC")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DISABLE_CREATE_OBJECT_URL =
|
const DISABLE_CREATE_OBJECT_URL =
|
||||||
apiCompatibilityParams.disableCreateObjectURL || false;
|
viewerCompatibilityParams.disableCreateObjectURL || false;
|
||||||
|
|
||||||
function download(blobUrl, filename) {
|
function download(blobUrl, filename) {
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
|
@ -74,14 +74,10 @@ class PDFAttachmentViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* NOTE: Should only be used when `URL.createObjectURL` is natively supported.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_bindPdfLink(button, content, filename) {
|
_bindPdfLink(button, content, filename) {
|
||||||
if (this.downloadManager.disableCreateObjectURL) {
|
|
||||||
throw new Error(
|
|
||||||
'bindPdfLink: Unsupported "disableCreateObjectURL" value.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let blobUrl;
|
let blobUrl;
|
||||||
button.onclick = () => {
|
button.onclick = () => {
|
||||||
if (!blobUrl) {
|
if (!blobUrl) {
|
||||||
|
@ -65,8 +65,7 @@ function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
|
|||||||
this.pagesOverview = pagesOverview;
|
this.pagesOverview = pagesOverview;
|
||||||
this.printContainer = printContainer;
|
this.printContainer = printContainer;
|
||||||
this.l10n = l10n || NullL10n;
|
this.l10n = l10n || NullL10n;
|
||||||
this.disableCreateObjectURL =
|
this.disableCreateObjectURL = AppOptions.get("disableCreateObjectURL");
|
||||||
pdfDocument.loadingParams.disableCreateObjectURL;
|
|
||||||
this.currentPage = -1;
|
this.currentPage = -1;
|
||||||
// The temporary canvas where renderPage paints one page at a time.
|
// The temporary canvas where renderPage paints one page at a time.
|
||||||
this.scratchCanvas = document.createElement("canvas");
|
this.scratchCanvas = document.createElement("canvas");
|
||||||
|
@ -23,9 +23,21 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
|||||||
(typeof navigator !== "undefined" && navigator.maxTouchPoints) || 1;
|
(typeof navigator !== "undefined" && navigator.maxTouchPoints) || 1;
|
||||||
|
|
||||||
const isAndroid = /Android/.test(userAgent);
|
const isAndroid = /Android/.test(userAgent);
|
||||||
|
const isIE = /Trident/.test(userAgent);
|
||||||
const isIOS =
|
const isIOS =
|
||||||
/\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) ||
|
/\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) ||
|
||||||
(platform === "MacIntel" && maxTouchPoints > 1);
|
(platform === "MacIntel" && maxTouchPoints > 1);
|
||||||
|
const isIOSChrome = /CriOS/.test(userAgent);
|
||||||
|
|
||||||
|
// Checks if possible to use URL.createObjectURL()
|
||||||
|
// Support: IE, Chrome on iOS
|
||||||
|
(function checkOnBlobSupport() {
|
||||||
|
// Sometimes IE and Chrome on iOS losing the data created with
|
||||||
|
// createObjectURL(), see issues #3977 and #8081.
|
||||||
|
if (isIE || isIOSChrome) {
|
||||||
|
compatibilityParams.disableCreateObjectURL = true;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
// Limit canvas size to 5 mega-pixels on mobile.
|
// Limit canvas size to 5 mega-pixels on mobile.
|
||||||
// Support: Android, iOS
|
// Support: Android, iOS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user