To encrypt a PDF with a password, set an open password when you export or save it: in Word choose File > Save As > PDF > Options > Encrypt the document with a password, on a Mac use File > Export > Permissions in Preview, or run qpdf --encrypt from a terminal. Anyone who opens the file afterwards must type that password first.
Pick the route that matches what you already have: a Word document (Word), an existing PDF on a Mac (Preview), or any PDF on any system, including scripted use (qpdf). The steps below come from Microsoft's, Apple's and qpdf's own documentation.
Encrypt a PDF with a password in Word
This works when you are creating the PDF from a Word document. Word encrypts the PDF as it writes the file.
- Open the document and select File > Save As (or Save a Copy).
- Select Browse and choose where to save.
- In the file type drop-down, select PDF.
- Select More Options > Options.
- Tick Encrypt the document with a password and select OK.
- In the Encrypt PDF Document box, type the password and enter it again to confirm.
- Select Save.
Microsoft's page describes the option as restricting access so only people with the password can open the PDF. It does not say which encryption algorithm Word uses, so if you need a specific one (for a compliance requirement, for example), use qpdf below, where you choose the key length yourself. Menu names can differ slightly between Word versions and between Windows and Mac.
Encrypt an existing PDF on a Mac (Preview)
Preview can add a password to a PDF you already have. The steps from Apple's documentation:
- Open the PDF in Preview.
- Choose File > Export. Give the copy a new name if you want to keep the unprotected original.
- Click the Permissions button.
- Select Require Password To Open Document, then enter the password and retype it.
- Optionally, use the checkboxes to choose which actions (such as printing or changing the document) are allowed without a password. Leave a box unselected to require the owner password for that action.
- Enter and retype an Owner Password. Apple says it can be the same as the opening password or different.
- Click Apply, then Save.
The new settings take effect the next time someone opens the PDF. To change them later, open the file and choose File > Edit Permissions, make your changes, and click Apply.
Encrypt a PDF from the command line with qpdf
qpdf is a free command-line tool for Windows, macOS and Linux. It is the better choice for batches of files, scripts, and cases where you must pick the key length. The positional form of the command is:
qpdf --encrypt user-password owner-password key-length -- input.pdf output.pdf
A concrete example with 256-bit encryption (replace both example passwords with your own):
qpdf --encrypt "open-me-2026" "owner-only-2026" 256 -- report.pdf report-encrypted.pdf
What each part means:
open-me-2026is the password people type to open the file.owner-only-2026is the owner password. qpdf's documentation says that for 256-bit encryption it refuses to create a file with an empty owner password unless you add--allow-insecure, because a blank owner password makes the restrictions ineffective. Give it a real value.256is the key length. The allowed values are40,128and256.- The standalone
--ends the encryption options. Without it, qpdf reads the filenames as options.
Since qpdf 11.7.0 there is also a flag form: --encrypt --user-password=... --owner-password=... --bits=256 --. If you want to overwrite the original instead of writing a second file, --replace-input takes the place of the output filename. qpdf writes to a temporary file first and leaves your input untouched if an error occurs.
One caution: a password typed on the command line can end up in your shell history and be visible to other processes on the machine. For anything sensitive, use a throwaway shell session or one of the GUI routes above.
Which key length to choose: 40, 128 or 256 bit
This is where the qpdf documentation is most direct:
| Key length | Algorithm | What the qpdf docs say |
|---|---|---|
| 40-bit | Always RC4 | The key is only 5 bytes and can be brute-forced, so these files are not secure regardless of password strength. |
| 128-bit | RC4 by default, or AES (PDF 1.6 and later) | RC4 is the default "for compatibility reasons". |
| 256-bit | Always AES | The docs advise: if you are going to use AES, just use 256-bit encryption instead. |
In practice, choose 256-bit unless you know a program that must open the file cannot handle it. If you want background on the cipher itself, see what AES encryption is.
Open password vs owner password
A PDF can carry two passwords, and they do different jobs.
- Open (user) password. Required to view the file. This is the one that keeps the content secret.
- Owner (permissions) password. Controls restrictions such as printing, copying or editing.
Do not rely on restrictions for secrecy. The qpdf documentation states that the security of the restrictions is "solely enforced by the software": any program that can read the file has the encryption key, so restrictions only deter people who don't know how to bypass them. If a file must stay confidential, the open password is what protects it, and it is only as strong as the password you pick.
Choose a password worth encrypting with
Encryption does not help if the password is easy to guess. Use a long random one and store it in a password manager (see how password managers work). You can generate one in your browser with the larely password generator. For how length and randomness translate into guessing effort, read password entropy explained and how long it takes to crack a password.
You will also need to share the password separately from the file. Sending both in the same email defeats the purpose, so use a different channel, such as a phone call or a messaging app.
Check that the encryption worked
Close the file and open the new copy in a PDF viewer, ideally a different one from the program that created it. It should ask for a password before showing any page. If it opens without a prompt, you most likely opened the original instead of the encrypted copy.
Do the same check on the file you plan to send, not on the one you just created, in case the wrong copy was attached. Encrypting a file does not hide its filename or size, so avoid putting sensitive details in the filename.
Remove the password later
If you know the password, qpdf can write an unencrypted copy:
qpdf --password=open-me-2026 --decrypt report-encrypted.pdf report-plain.pdf
--password supplies the password for the encrypted input, and --decrypt produces an output file with no encryption. In Preview, the equivalent is File > Edit Permissions. Delete the plain copy when you are done if the file is sensitive.
If it still fails
- The Encrypt option is missing in Word. Microsoft's steps reach it through More Options > Options after you choose PDF as the file type. Check that you selected PDF first.
- qpdf treats your filenames as options. You left out the closing
--after the key length. - qpdf refuses a 256-bit file. You gave an empty owner password. Provide one, or accept the risk with
--allow-insecure. - An older viewer cannot open the file. Try re-encrypting at 128-bit (qpdf supports AES at that length from PDF 1.6). Avoid 40-bit and RC4, which the qpdf documentation describes as insecure.
To encrypt other kinds of files, not just PDFs, see how to encrypt a file with GPG.
Frequently asked questions
- Can I encrypt a PDF without buying Adobe Acrobat?
- Yes. Word can encrypt a PDF as you save it (File > Save As > PDF > Options > Encrypt the document with a password), Preview on a Mac can add a password through File > Export > Permissions, and the free qpdf command-line tool works on Windows, macOS and Linux.
- What is the difference between the open password and the owner password?
- The open (user) password is required to view the file at all. The owner password governs restrictions such as printing or editing. Those restrictions are enforced by the viewing software, not by the encryption itself, so software that ignores them can bypass them. Only the open password keeps the content secret.
- What happens if I forget the password of an encrypted PDF?
- Nothing built into the format recovers it. With a strong random password and modern encryption the content stays locked, which is the point. Keep the password in a password manager, and keep an unencrypted original somewhere safe if you may need it later.
- Should I use 128-bit or 256-bit encryption?
- Use 256-bit if every program that must open the file supports it. The qpdf documentation notes that 40-bit encryption always uses the RC4 algorithm and can be brute-forced, that 128-bit uses RC4 by default for compatibility, and that 256-bit always uses AES.