Skip to content

Commit 63af15e

Browse files
committed
Only call PDFDocumentProxy.getPermissions, in the viewer, when pdfjs.enablePermissions is set (PR 14362 follow-up)
By making this API-call *unconditionally*, we introduce a (slight) delay in the initialization of *all* documents. That seems quite unfortunate, since `pdfjs.enablePermissions` is off by default, and it thus seem better only do the API-call when actually needed; sorry about this!
1 parent 6d8d37e commit 63af15e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

web/base_viewer.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ class BaseViewer {
490490
if (pdfDocument !== this.pdfDocument) {
491491
return; // The document was closed while the permissions resolved.
492492
}
493-
if (!permissions || !this.#enablePermissions) {
493+
if (!permissions) {
494494
return;
495495
}
496496

@@ -554,7 +554,9 @@ class BaseViewer {
554554
const firstPagePromise = pdfDocument.getPage(1);
555555
// Rendering (potentially) depends on this, hence fetching it immediately.
556556
const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
557-
const permissionsPromise = pdfDocument.getPermissions();
557+
const permissionsPromise = this.#enablePermissions
558+
? pdfDocument.getPermissions()
559+
: Promise.resolve();
558560

559561
// Given that browsers don't handle huge amounts of DOM-elements very well,
560562
// enforce usage of PAGE-scrolling when loading *very* long/large documents.

0 commit comments

Comments
 (0)