Merge pull request #14364 from Snuffleupagus/BaseViewer-conditional-getPermissions

Only call `PDFDocumentProxy.getPermissions`, in the viewer, when `pdfjs.enablePermissions` is set (PR 14362 follow-up)
This commit is contained in:
Tim van der Meij 2021-12-12 14:00:04 +01:00 committed by GitHub
commit d47b6735b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -490,7 +490,7 @@ class BaseViewer {
if (pdfDocument !== this.pdfDocument) {
return; // The document was closed while the permissions resolved.
}
if (!permissions || !this.#enablePermissions) {
if (!permissions) {
return;
}
@ -554,7 +554,9 @@ class BaseViewer {
const firstPagePromise = pdfDocument.getPage(1);
// Rendering (potentially) depends on this, hence fetching it immediately.
const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
const permissionsPromise = pdfDocument.getPermissions();
const permissionsPromise = this.#enablePermissions
? pdfDocument.getPermissions()
: Promise.resolve();
// Given that browsers don't handle huge amounts of DOM-elements very well,
// enforce usage of PAGE-scrolling when loading *very* long/large documents.