Encrypting and decrypting PDFs using QPDF

Saturday, March 14, 2020


If you have a password-protected PDF and want to generate a decrypted version, it’s very simple with QPDF:

$ qpdf --password=123 --decrypt input.pdf output.pdf

To avoid entering the password on the command line (perhaps you don’t want it saved in your shell history):

$ qpdf @- --decrypt input.pdf output.pdf

Then enter --password=123 and hit enter and ^D.

To encrypt a PDF, do this:

$ qpdf --encrypt userPw ownerPw 256 -- input.pdf output.pdf

Similarly, to avoid including the passwords in the command, do this:

$ qpdf --encrypt @- @- 256 -- input.pdf output.pdf

And then type the user password, hit enter, the owner password, enter, and ^D.

Tags: pdf | Posted at 22:04 | Comments (5)


Comments

KINCAIDE3 on Sunday, January 3, 2021 at 23:02

Thank you!!1

Lhaneboync on Monday, August 18, 2025 at 18:15

Can I simply say what a comfort to uncover a person that genuinely understands what they're talking about over the internet. You definitely know how to bring an issue to light and make it important. A lot more people ought to look at this and understand this side of the story. It's surprising you are not more popular since you certainly possess the gift.
https://tvoy-prazdnik.kiev.ua/yaki-linzy-pidkhodyat-dlya-shtatnykh-far-vashoho-a.html

stomatolog_moscow_wbKi on Tuesday, August 19, 2025 at 17:34

Профессионализм врачей, современное оборудование и внимательное отношение - три кита качественного стоматологического обслуживания. Все это вы найдете в <a href=http://moscow-stomatolog.ru/>http://moscow-stomatolog.ru/</a> .

TimsothyBat on Tuesday, August 19, 2025 at 20:52

What's up, yes this piece of writing is truly nice and I have learned lot of things from it regarding blogging. thanks.
http://sevinfo.com.ua/fara-pislya-dtp-yak-pidibraty-klej-dlya-skla.html

DanielJANDA on Wednesday, August 20, 2025 at 00:25

<b>Full Throttle Summer Savings Event!</b>
<b>Winding are just discounts</b> - on props and drones <b>DJI</b>, <b>GEPRC</b>, <b>RadioMaster</b>, <b>Ethix</b>, <b>TBS</b>, <b>Lumenier</b>, <b>Flywoo</b>, <b>EMAX</b> and around now good!
<a href=https://psee.io/7zu6yq><b>GetFPV’s Full Throttle Summer Savings event is on!</b></a>

Add a comment

Name:
Email: (optional, not displayed to public)
URL: (do not fill this in — leave blank!)

Comment: