Check if document is password-protected

Q: How can I check and reject if a document is password-protected?

A: This can be done by setting PSPDFKit.Configuration#maxPasswordRetries to 0 and catch when the PSPDFKit.load promise rejects.

  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.