Merge pull request #15943 from Snuffleupagus/deprecate-direct-PDFDataRangeTransport
[api-minor] Deprecate calling `getDocument` directly with a `PDFDataRangeTransport`-instance
This commit is contained in:
commit
a27d7ba524
@ -233,8 +233,7 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef { string | URL | TypedArray | ArrayBuffer |
|
* @typedef { string | URL | TypedArray | ArrayBuffer | DocumentInitParameters
|
||||||
* PDFDataRangeTransport | DocumentInitParameters
|
|
||||||
* } GetDocumentParameters
|
* } GetDocumentParameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -258,7 +257,14 @@ function getDocument(src) {
|
|||||||
source = { url: src };
|
source = { url: src };
|
||||||
} else if (isArrayBuffer(src)) {
|
} else if (isArrayBuffer(src)) {
|
||||||
source = { data: src };
|
source = { data: src };
|
||||||
} else if (src instanceof PDFDataRangeTransport) {
|
} else if (
|
||||||
|
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
|
||||||
|
src instanceof PDFDataRangeTransport
|
||||||
|
) {
|
||||||
|
deprecated(
|
||||||
|
"`PDFDataRangeTransport`-instance, " +
|
||||||
|
"please use a parameter object with `range`-property instead."
|
||||||
|
);
|
||||||
source = { range: src };
|
source = { range: src };
|
||||||
} else {
|
} else {
|
||||||
if (typeof src !== "object") {
|
if (typeof src !== "object") {
|
||||||
|
@ -3265,7 +3265,7 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadingTask = getDocument(transport);
|
const loadingTask = getDocument({ range: transport });
|
||||||
const pdfDocument = await loadingTask.promise;
|
const pdfDocument = await loadingTask.promise;
|
||||||
expect(pdfDocument.numPages).toEqual(14);
|
expect(pdfDocument.numPages).toEqual(14);
|
||||||
|
|
||||||
@ -3310,7 +3310,7 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadingTask = getDocument(transport);
|
const loadingTask = getDocument({ range: transport });
|
||||||
const pdfDocument = await loadingTask.promise;
|
const pdfDocument = await loadingTask.promise;
|
||||||
expect(pdfDocument.numPages).toEqual(14);
|
expect(pdfDocument.numPages).toEqual(14);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user