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 Nutrient Web SDK 2020.4.2.