How do I add or remove a PDF password?
To protect a PDF, type a password and choose what readers may do: print, copy, edit or comment. To unlock one, type the password it already has. This tool cannot guess a password you do not know. Protection uses 128-bit RC4, which opens in almost every reader but is weaker than AES-256.
Can I unlock a PDF if I forgot the password?
No. Unlocking only works with a password that already opens the file, either the open password or the owner password. The tool checks it first. A wrong password returns "Incorrect password. Please try again." and no file is made. Nothing here tries to crack or guess passwords.
How secure is a password-protected PDF?
It keeps casual readers out, but it is not the strongest option. This tool uses 128-bit RC4, which works in practically every reader. The current PDF standard prefers AES-256. For documents where strong secrecy matters, use desktop software that offers AES-256.
Can people still print or copy a protected PDF?
Only if you allow it. Each box you tick switches on one permission, and allowing printing only ever gives low-resolution printing. Mainstream readers follow these settings, but they are instructions, not encryption. Any program that opens the file can choose to ignore them.
What Protect writes into the file
Protect asks Ghostscript to rewrite the PDF with the standard PDF security handler, revision 3, and a 128-bit key: -dEncryptionR=3 -dKeyLength=128. Revision 3 uses the RC4 cipher. When we inspected a protected test file, its encryption dictionary read /Filter /Standard /V 2 /R 3 /Length 128, and pdfinfo reported algorithm:RC4. The output is a PDF 1.4 file.
RC4 at 128 bits opens in practically every PDF reader, old and new. It is not AES. The current PDF 2.0 standard deprecates RC4 in favour of AES-256, so use desktop software that offers AES-256 for documents where strong confidentiality matters.
Two passwords, one of which you never see
A PDF can carry two passwords. The user password, also called the open password, is the one a reader asks for before showing the document. The owner password, also called the permissions password, is meant to let its holder change or ignore the permission settings.
The password you type here becomes the user password. For the owner password, the tool generates a fresh random 32-character value for every file and discards it. Nobody, including you, can use it later, which stops someone who only knows the open password from simply lifting the restrictions with the owner password.
Permission flags, as read back from the protected file
Each checkbox switches on one bit in the permission value /P. Everything else stays off. We protected the same file three times and read the flags back with qpdf:
| Permission | No boxes ticked (P = -3904) | Print only (P = -3900) | All four boxes (P = -3844) |
|---|---|---|---|
| Print at low resolution | Not allowed | Allowed | Allowed |
| Print at high resolution | Not allowed | Not allowed | Not allowed |
| Copy or extract text and images | Not allowed | Not allowed | Allowed |
| Change page content | Not allowed | Not allowed | Allowed |
| Add or change comments | Not allowed | Not allowed | Allowed |
| Fill in form fields | Not allowed | Not allowed | Not allowed |
| Insert, delete or rotate pages | Not allowed | Not allowed | Not allowed |
| Extract text for accessibility tools | Not allowed | Not allowed | Not allowed |
What the flags mean in practice
- Allow printing only ever grants low-resolution printing. Some readers may then print a lower-quality, rasterised copy.
- Accessibility extraction is never granted, so some screen readers may not read the protected file. Leave the document unprotected, or protect it elsewhere, if it must stay accessible.
- Permission flags are honoured by mainstream readers, but they are instructions, not encryption. Any program that can open the file can choose to ignore them.
Unlocking: what it needs and what you get
Unlock first checks with pdfinfo that the password you type opens the file, as either the open password or the owner password. Only then does Ghostscript write a new copy with no encryption and no permission restrictions, and the copy must have the same number of pages as the original. qpdf reported the unlocked copies as File is not encrypted. The tool cannot find or guess a password you do not know.
The check matters because Ghostscript 10.08 does not report a wrong password as an error. Given one, it exits normally and writes a single blank page, which the tool used to offer as the unlocked file. A wrong password now returns "Incorrect password. Please try again." and no file is created.
| Test file | Password typed | Result |
|---|---|---|
| RC4 128-bit, made with Protect | The correct open password | Unencrypted copy, all pages present. |
| AES-256, made with qpdf | The correct open password | Unencrypted copy, text readable. |
| AES-256, made with qpdf | A wrong password | "Incorrect password. Please try again." No file. |
| Opens without a password, printing and copying restricted | The owner password | Unencrypted copy, all pages present. |
| Opens without a password, printing and copying restricted | Any other text | "Incorrect password. Please try again." No file. Removing restrictions needs the owner password. |
After unlocking
- The tool compares page counts before offering the download, but open the unlocked copy and check it before you delete the original.
- Merging and splitting refuse any encrypted file, including restriction-only files that open without a password. Unlock those first.
Side effects of the rewrite
- Digital signatures do not survive. A signed test file, protected and then decrypted again with qpdf, contained no signature at all.
- File size changes because the whole document is rewritten. Our 11.2 KB test file came out at 5.0 KB once protected.
- Protect refuses a file that already needs a password to open, and both actions refuse a file that cannot be opened at all, instead of writing a blank page.
- The Producer field becomes GPL Ghostscript with its version number.
- Passwords can be 1 to 128 characters. Your password is used for that single run and is not kept in your session; only the original file name, the output size and where the output is stored are kept.
- One file per run, up to 50 MB on the Free plan and 100 MB on Pro and AI. Each successful protect or unlock uses one daily check.
Last updated . How this was checked: we protected and unlocked synthetic test PDFs with the exact Ghostscript 10.08 commands this tool builds, then read the encryption dictionary and permission flags with qpdf 12 and pdfinfo. AES-256 and restriction-only test files were made with qpdf.