Skip to the tool workspace
Browser 123

Handleidingen PDF

How to password-protect a PDF, and what that protects

Put a password on a PDF so nobody can open it without one. The qpdf command, the Permissions sheet in Preview on a Mac, the browser tool, and why a password that only restricts printing or copying protects almost nothing.

A PDF can carry two passwords, and they do very different things. The open password (the PDF specification calls it the user password) encrypts the content: without it the file is unreadable bytes. The owner password only sets flags such as "no printing" or "no copying", which the reading program is asked to respect. A PDF with only an owner password opens for anyone, and any program that ignores the flags ignores the protection.

So if the point is that nobody but the recipient reads it, set an open password and pick a long one. That is the part that protects anything.

Protect PDF with report.pdf loaded: the file card shows its name and size, the Set a password panel has the Password and Confirm password fields filled in with a full Strong meter, and the Permissions panel shows Allow printing, Allow copying text and Allow editing switches above the Protect PDF button

A PDF ready to encrypt with AES-256, in the browser.

The direct wayqpdfmacOS · Linux · Windows

One command. It sets an open password, a separate owner password, and AES-256:

qpdf --encrypt --user-password='open-sesame' --owner-password='owner-Kx9' --bits=256 -- report.pdf locked.pdf

Install it with brew install qpdf on a Mac or apt install qpdf on Debian and Ubuntu; Windows builds are on the qpdf releases page. The -- closes the encryption options. The older positional form, qpdf --encrypt open-sesame owner-Kx9 256 -- report.pdf locked.pdf, does the same and also worked in qpdf 12.2.0. Check what you got:

qpdf --show-encryption --password='open-sesame' locked.pdf
R = 6
P = -4
User password = open-sesame
Supplied password is user password
extract for accessibility: allowed
extract for any purpose: allowed
print low resolution: allowed
print high resolution: allowed
modify document assembly: allowed
modify forms: allowed
modify annotations: allowed
modify other: allowed
modify anything: allowed
stream encryption method: AESv3
string encryption method: AESv3
file encryption method: AESv3

R = 6 with AESv3 is AES-256, the strongest encryption a PDF can have.

On a Mac: Preview

Preview can do it without installing anything. Apple's steps (Password-protect a PDF in Preview):

  1. Open the PDF in Preview and choose File › Export…. Give the copy a new name if you want to keep the original unprotected.
  2. Click Permissions….
  3. Tick Require Password To Open Document, and type the password twice.
  4. Under Owner Password, type an owner password twice. It can be the same as the open password or a different one.
  5. Click Apply, then Save.

The checkboxes in the same sheet (Printing, Copying Text or Graphics, Inserting, Deleting or Rotating Pages and the others) are the owner restrictions: a ticked one is allowed without the owner password. For a PDF that is already protected, File › Edit Permissions… changes the passwords and the checkboxes.

We read those labels from macOS 26.5.1's own interface files rather than clicking through the sheet. The sheet belongs to PDFKit, Apple's PDF framework, and PDFKit on the same Mac wrote AES-128 (R = 4, AESv2), not AES-256. There is no practical attack on AES-128. If a policy asks for AES-256, use qpdf or the browser tool.

What each password actually protects

We protected the same three-page report each way, then asked qpdf 12.2.0 to decrypt the result without a password:

Route Encryption Opens without a password qpdf --decrypt with no password
qpdf --bits=256, open password AES-256 (R 6) No invalid password
Protect PDF (browser) AES-256 (R 6) No invalid password
Preview / PDFKit, open password AES-128 (R 4) No invalid password
Owner password only, everything restricted AES-256 (R 6) Yes Unrestricted copy written
qpdf --bits=128, RC4 RC4 (R 3) No Refused to write it at all

The fourth row is the one to understand. That file was encrypted with AES-256 and every restriction was switched on, and it still protected nothing:

qpdf --decrypt restricted.pdf free.pdf
qpdf --show-encryption free.pdf
File is not encrypted

No password was asked for. A copy-restricted file doesn't stop text extraction either: pdftotext restricted.pdf - (poppler 25.03) printed the report's first lines straight away. An empty open password means the key to the content is in everyone's hands. The restrictions only work in programs that choose to obey them. Preview does, and says "Without the proper password, you do not have permission to print this document"; qpdf and pdftotext didn't.

RC4, the cipher in old PDFs, is broken, and qpdf 12 won't write it unless you pass --allow-weak-crypto: "refusing to write a file with RC4, a weak cryptographic algorithm". If a PDF you were sent shows R = 2 or R = 3 and no AESv lines, it uses RC4.

Check a file you were sent

qpdf --show-encryption reports the encryption even when you don't know the password. It prints Incorrect password supplied, then the R = line and the encryption method. R = 6 and AESv3 is AES-256, R = 4 and AESv2 is AES-128.

Protect PDF's permission switches don't bind anyone

Protect PDF asks for one password and uses it for both the open password and the owner password. Whoever types that password to open the file is therefore the owner, and gets every permission back: qpdf reports "Supplied password is owner password" on our file with printing, copying and editing all switched off. Nobody can open the file without that password, so in practice the switches restrict no one. If you need people who can open the file to be unable to print it, use qpdf or Preview with a different owner password, and remember it is still a request, not a lock.

In the browser

  1. Open Protect PDF and drop the PDF in. It shows the file name and size.
  2. Type the password in Password and again in Confirm password. The meter under it reads Weak, Fair or Strong. The button stays off until both match and the password has at least four characters.
  3. Leave the Permissions switches as they are, unless you need them for a viewer that obeys them (see the warning above).
  4. Press Protect PDF. The encrypted copy downloads straight away, with -protected added to its name.

If it says "Couldn't encrypt this PDF. It may already have a password, so unlock it first.", the file is already encrypted. Remove the old password with Unlock PDF, then protect the unlocked copy.

Choosing the password

AES-256 can't be broken, but a password can be guessed. Anyone holding the file can try guesses on their own computer, as many as they like, and no lockout stops them. So the password is the whole protection: use a passphrase of four or five unrelated words, or a long random password from a password manager.

Send the password a different way from the file. A password in the same email as the attachment protects the PDF from nobody who can read that email. A text message or a phone call is better.

And keep it. There is no recovery: nobody can open the file for you, including us.

Taking a password off again

To remove a password you know, with qpdf:

qpdf --decrypt --password='open-sesame' locked.pdf unlocked.pdf

With the wrong password it stops with qpdf: locked.pdf: invalid password and writes nothing.

Unlock PDF with a protected PDF loaded: the file card shows its name and size, the Enter the password panel says This removes a password you know. It can't crack one you don't., with the Password field filled in and the Unlock PDF button below

A PDF that needs a password to open: type it in and press Unlock PDF.

Drop the file in and Unlock PDF checks whether it needs a password to open. If it does, type it and press Unlock PDF; the copy downloads with -unlocked added to its name. You can use either the open password or the owner password.

If it opens freely, you get Remove restrictions instead, and no password is asked for, for the reason the table shows.

Unlock PDF with a restricted PDF loaded: an info message says This PDF opens without a password, but it may still restrict printing or copying. You can strip those restrictions below., above a Remove restrictions button

A PDF that opens freely but restricts printing and copying.

Do this before using our other PDF tools

A PDF that opens freely but restricts printing or editing loads in our page tools (Merge, Split, Organize and the rest) and shows its thumbnails, but the pages they write from it come out broken. Run it through Remove restrictions first, then use the unlocked copy.

Then send the protected copy, and the password by another route. Keep the unprotected original somewhere only you can reach, or delete it.

Questions people ask

Can someone open a password-protected PDF without the password?

Not if it has a password to open it. With AES-256 or AES-128 the content is encrypted, and the only way in is to guess the password, so a long one is the whole defence. A PDF that opens freely and only restricts printing or copying is different: anyone can open it, and qpdf removed those restrictions in our test without being given any password.

Why can I still copy text from a PDF that says copying is not allowed?

Because the restriction is a flag in the file, not a lock. The text is decrypted with an empty password, and each program decides whether to obey the flag. pdftotext 25.03 printed the text of our copy-restricted test file straight away.

I forgot the password. Can Unlock PDF remove it?

No. Unlock PDF removes a password you know: it asks for it, and a wrong one is refused. It does not guess or crack passwords. Without the password, the content of an AES-encrypted PDF cannot be read.

Is Preview's encryption as strong as AES-256?

It is AES-128 rather than AES-256: Apple's PDFKit wrote AESv2 (revision 4) on macOS 26.5.1. There is no practical attack on AES-128 either. What decides whether a protected PDF stays closed is the password, with every route here.

Does a password make the PDF bigger?

Barely. Our three-page test file went from 37,330 to 38,462 bytes with AES-256, about 1 KB for the encryption dictionary. The pages are not changed or recompressed.

Tools in deze handleiding

Alles draait op je apparaat

Alle handleidingen

/
123 items
Draait in je browser·Je bestanden blijven op dit apparaat
Out0 B
Ready—