This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/web/knowledge-base/check-password-protected-files.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Check if PDF is password protected | Nutrient

You can check if a document is password protected by setting NutrientViewer.Configuration#maxPasswordRetries to 0 and catching when the NutrientViewer.load promise rejects. If you need to resolve passwords programmatically while loading, refer to the resolving the password programmatically guide.

NutrientViewer.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.