# Dectect document with password protection

**URL:** https://pdfjs.community/t/dectect-document-with-password-protection/3528
**Category:** Technical Support
**Created:** [November 20, 2024, 7:43pm UTC](https://pdfjs.community/t/dectect-document-with-password-protection/3528 "2024-11-20T19:43:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![yavula1](https://avatars.discourse-cdn.com/v4/letter/y/ed655f/32.png) [@yavula1](https://pdfjs.community/u/yavula1)
#### Post date: [November 20, 2024, 7:43pm UTC](https://pdfjs.community/t/dectect-document-with-password-protection/3528/1 "2024-11-20T19:43:22Z")

</div>

**Which product are you using?**

PDF.js Express Plus  
**PDF.js Express Version**

**Detailed description of issue**  
People are uploading password protected documents to our portal, we need to detect the document with password protection and inform user to remove password.

**Expected behaviour**  
Identify documents who have password protection

**Does your issue happen with every document, or just one?**  
Issue with password protected documents

**Link to document**  
NA

**Code snippet**  
NA

---

<div class="post-metadata">

### Author: ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)
#### Post date: [November 20, 2024, 10:01pm UTC](https://pdfjs.community/t/dectect-document-with-password-protection/3528/3 "2024-11-20T22:01:56Z")

</div>

Hi there,

We do not have an API to detect if a document is password protected. You could programatically add the password into the [loadDocument](https://pdfjs.express/api/UI.html#.loadDocument__anchor) API to open a password protected document.

You can also use the loaderror event to handle if the document fails to load:

> **[PDF.js Express Viewer Events | Documentation](https://pdfjs.express/documentation/learn-more/events.8#document-load-error-handling)**

And then use a custom modal to display your message:  
[https://pdfjs.express/api/UI.html#.addCustomModal\_\_anchor](https://pdfjs.express/api/UI.html#.addCustomModal__anchor)

Best regards,  
Kevin Kim
