QPDF is a portable command line tool for processing PDF files.

The program can password-protect PDFs, or remove the encryption from an already protected file. There's an option to generate a linearized file (a web-optimised document, which can display the first page without downloading the whole thing). You can specify pages and page ranges from individual files, then export them to a new PDF. And QPDF offers advanced control over PDF streams (compression, normalization, object streams and more).

There's good attention to detail here. This isn't necessarily just about giving a PDF file a password; you can also set the encryption key length, and decide whether viewers can print the document, modify it, extract text or images, to allow annotations, and more.

Figuring out how to use all this takes some effort, even for a command line program. There are a lot of options, and the detailed documentation assumes you know precisely what you're doing.

For all that, you should have everything figured out with a little thought. A command like

qpdf --encrypt user-password owner-password 40 --print=n -- test.pdf test2.pdf

will take a file test.pdf, give it a 40-bit key, assign user and owner passwords, and disable printing, before exporting the results as test2.pdf. And while this may look complicated, work it out once and you can create a batch file or script to apply the same rules to multiple files, automatically, whenever you like.

Verdict ratingsratingsratingsratingsratings

QPDF has a good set of PDF processing tools, in particular for adding or removing password protection, and splitting or merging files. It's a little awkward to use, but if you're looking to automate your PDF handling with scripts then the program should be able to help.