mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-05-31 07:11:00 +02:00
Merge pull request #21308 from calixteman/bug2036265
Add a pref to postMessage when mozPrintCallback has completed (bug 2036265)
This commit is contained in:
commit
80c8e62e65
@ -369,6 +369,11 @@ const defaultOptions = {
|
||||
value: typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING"),
|
||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||
},
|
||||
postMessageAfterPrintCallback: {
|
||||
/** @type {boolean} */
|
||||
value: false,
|
||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||
},
|
||||
printResolution: {
|
||||
/** @type {number} */
|
||||
value: 150,
|
||||
|
||||
@ -23,6 +23,7 @@ import {
|
||||
BasePrintServiceFactory,
|
||||
getXfaHtmlForPrinting,
|
||||
} from "./print_utils.js";
|
||||
import { AppOptions } from "./app_options.js";
|
||||
|
||||
// Creates a placeholder with div and canvas with right size for the page.
|
||||
function composePage(
|
||||
@ -31,6 +32,7 @@ function composePage(
|
||||
size,
|
||||
printContainer,
|
||||
printResolution,
|
||||
shouldPostMessageAfterPrintCallback,
|
||||
optionalContentConfigPromise,
|
||||
printAnnotationStoragePromise
|
||||
) {
|
||||
@ -94,6 +96,9 @@ function composePage(
|
||||
currentRenderTask = null;
|
||||
}
|
||||
obj.done();
|
||||
if (shouldPostMessageAfterPrintCallback) {
|
||||
window.postMessage("ready", "*");
|
||||
}
|
||||
},
|
||||
function (reason) {
|
||||
if (!(reason instanceof RenderingCancelledException)) {
|
||||
@ -112,6 +117,9 @@ function composePage(
|
||||
} else {
|
||||
obj.done();
|
||||
}
|
||||
if (shouldPostMessageAfterPrintCallback) {
|
||||
window.postMessage("error", "*");
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
@ -171,6 +179,9 @@ class FirefoxPrintService {
|
||||
return;
|
||||
}
|
||||
|
||||
const shouldPostMessageAfterPrintCallback = AppOptions.get(
|
||||
"postMessageAfterPrintCallback"
|
||||
);
|
||||
for (let i = 0, ii = pagesOverview.length; i < ii; ++i) {
|
||||
composePage(
|
||||
pdfDocument,
|
||||
@ -178,6 +189,7 @@ class FirefoxPrintService {
|
||||
pagesOverview[i],
|
||||
printContainer,
|
||||
_printResolution,
|
||||
shouldPostMessageAfterPrintCallback,
|
||||
_optionalContentConfigPromise,
|
||||
_printAnnotationStoragePromise
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user