Merge pull request #21409 from Snuffleupagus/PDFViewer-#setPrintingAllowed

Add a `PDFViewer` helper method for setting `#printingAllowed` and dispatching the event
This commit is contained in:
Tim van der Meij 2026-06-09 19:43:26 +02:00 committed by GitHub
commit 29ad297626
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -720,6 +720,11 @@ class PDFViewer {
});
}
#setPrintingAllowed(isAllowed) {
this.#printingAllowed = isAllowed;
this.eventBus.dispatch("printingallowed", { source: this, isAllowed });
}
/**
* Currently only *some* permissions are supported.
* @returns {Object}
@ -731,22 +736,14 @@ class PDFViewer {
textLayerMode: this.#textLayerMode,
};
if (!permissions) {
this.#printingAllowed = true;
this.eventBus.dispatch("printingallowed", {
source: this,
isAllowed: this.#printingAllowed,
});
this.#setPrintingAllowed(true);
return params;
}
this.#printingAllowed =
this.#setPrintingAllowed(
permissions.includes(PermissionFlag.PRINT_HIGH_QUALITY) ||
permissions.includes(PermissionFlag.PRINT);
this.eventBus.dispatch("printingallowed", {
source: this,
isAllowed: this.#printingAllowed,
});
permissions.includes(PermissionFlag.PRINT)
);
if (
!permissions.includes(PermissionFlag.COPY) &&
@ -922,7 +919,6 @@ class PDFViewer {
this.#annotationEditorUIManager = null;
this.#annotationEditorMode = AnnotationEditorType.NONE;
this.#printingAllowed = true;
}