Merge pull request #21308 from calixteman/bug2036265

Add a pref to postMessage when mozPrintCallback has completed (bug 2036265)
This commit is contained in:
calixteman 2026-05-29 14:32:29 +02:00 committed by GitHub
commit 80c8e62e65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View File

@ -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,

View File

@ -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
);