Some PDFs you download are write protected. This is especially annoying if you do like to mark up the PDF in a utility like e.g. DEVONthink. It is not even possible to simply highlight something as long as the PDF is write protected.

Luckily the problem can be solved with a little command line application called qpdf.

Installation

There are multiple ways to install the software. You can either use the package manager of your operating system or you can use Docker. This will allow you to quickly use the command and discard the whole execution environment if you no longer need it.

Homebrew

I’m on a Mac and if you have Homebrew installed, you can execute brew install qpdf in your terminal application. This will download and install the qpdf command line tool that you can use to remove the PDF write protection.

Note

I’m running the following version:

#$> qpdf --version
qpdf version 10.0.1
Run qpdf --copyright to see copyright and license information.

Keep this in mind if a feature is not available or does not work.

If you’re not on a Mac you need to use the package manager of your operating system to install the application.

You can use the utility like so:

#$> cd folder-with-pdf
#$> qpdf --replace-input my.pdf

Docker

If you are already using Docker then why not employ a container to get the job done. The container I am using is pretty heavyweight if you just need to use the little qpdf utility and you may want to use a smaller container. However, if you’re additionally documenting stuff with Sphinx or use Pelican to write your blog, the heavyweight container might be a good choice for you anyway.

You can use the custom Sphinx container as follows:

#$> cd folder-with-pdf
#$> docker run --rm -it -v $(pwd):/docs authsec/sphinx qpdf --replace-input my.pdf

Note

If you’re on Windows, the current working directory needs to be specified with ${PWD}.

Like this post? Share on: TwitterFacebookEmail


Jens Frey Avatar Jens Frey is the creator of the datapile blog.

Published

Category

Infrastructure

Tags

Stay in Touch