Check If a Document Is Password Protected
You can check if a document is password protected by setting PSPDFKit.Configuration#maxPasswordRetries
to 0
and catching when the PSPDFKit.load
promise rejects:
PSPDFKit.load({ maxPasswordRetries: 0 // Your configuration. }) .then((instance) => { console.log("PSPDFKit for Web successfully loaded!!", instance); return instance; }) .catch((err) => { if (err.message === "INVALID_PASSWORD") { console.log("Attempted to load a password-protected document."); } });
This has been tested with PSPDFKit for Web 2020.4.2.