Password-Protected PDFs
PSPDFKit for Web supports opening and editing password-protected PDFs. Passwords can be included in the JSON Web Token (JWT), supplied when loading the PDF, or entered by the user when accessing the document.
Set the Default Document Password
To supply the password when loading a PDF, set the password via the initial Configuration#password
option:
PSPDFKit.load({ password: "secr3t", ..., });
PSPDFKit.load({ password: "secr3t", ... });
Note that setting this property will make loading PDF documents that are not protected by a password fail. As such, be sure to only add it for documents protected by a password.
Include the Password in the JWT (Server Only)
To include the password in the JWT used to authenticate clients, add the password
claim to your JWT:
jwt.sign( { document_id: document_id, password: "secr3t" // ... }, fs.readFileSync("./jwt.pem"), { algorithm: "RS256", expiresIn: 10 * 365 * 24 * 60 * 60 // 10 yrs } );
jwt.sign( { document_id: document_id, password: "secr3t" // ... }, fs.readFileSync("./jwt.pem"), { algorithm: "RS256", expiresIn: 10 * 365 * 24 * 60 * 60 // 10 yrs } );
User Enters the Password
If the password is neither included in the JWT or set via the Configuration#password
option, the user will be asked to enter the password via a password prompt.
