Imagine a scenario (which happened to me): your employer gives you the documentation relating to your financial situation and, at a certain point, you have to give it to your financial advisor.
Problem: the document is in PDF and is password-protected (which is good), but you can give it to your financial advisor only by loading it on a platform. How do you tell your financial advisor the password?
These are the scenarios I imagined to solve the problem:
You can load the file on the platform and tell the financial advisor the password via email or phone.
You can name the file as password_******
so that they can understand what the password is.
You can print the file, scan it, and create a new PDF (problem: in my case, these were 30 pages!!).
Now, as a Cyber Security enthusiast, I didn’t want to share the password with anyone, even if it was a unique one, for obvious reasons. Also, I didn’t want to waste time and paper to print 30 pages just to create another PDF.
So, the only (right) solution was to find something to remove the password from the file, so that it could be opened by my financial advisor.
In this article, I show you how you can remove a password from a PDF in a couple of minutes, and for free.
How to remove a password from a PDF file
Before arriving at the solution I’m showing you, I’ve navigated a lot on the Internet.
Let me tell you one thing: you can find a lot of online services that can remove a password from a PDF file, but, in my case, I didn’t want to use one of them for a simple reason: the file was about my financial situation, so I didn't want to leave somehow a track or a record of my financial situation on a third party database (which is not my financial advisor’s one).
So, in this scenario, I found qpdf which is a library that can convert a PDF file into an equivalent one. It has only one disadvantage: it can be used only via a terminal.
But don’t worry, is very easy to use it.
Let’s see.
Qpdf can be installed and used on any OS, but here we’ll see the procedure to do so on Ubuntu.
If you are a Windows user, don’t worry: you can install WSL)
So, in a Linux environment, install qpdf by typing:
$ sudo apt-get install qpdf
Now, at this point, we have to be careful if we don’t want to make mistakes. If you are using Ubuntu on Windows (via WSL) you have to move your PDF file to the environment where Ubuntu actually works. You should see something like the following:
The Linux environment on Windows created by WSL. Image by Federico Trotta.
So, as you can see, I have Ubuntu 18.04 under the Linux environment. This folder has been created by WSL when you install it.
So, at this point suppose that:
- Your file is called my_file and it is located on the following path:
C:/Home/Linux/Ubuntu-18.04/my_file.pdf
- my_file is protected with the following password: my_fileExample
Qpdf will create a copy of the file named my_file_free located in C:/Home/Linux/Ubuntu-18.04/my_file_free.pdf
Now, via terminal, you just need to type the following:
$ qpdf --decrypt --password=my_fileExample C:/Home/Linux/Ubuntu-18.04/my_file.pdf C:/Home/Linux/Ubuntu-18.04/my_file_free.pdf
And the job is done. So the scheme is:
$ qpdf --decrypt --password=<YOUR PASSWORD> file.PDF new_file.PDF
Conclusions
I hope this article helps you remove a password from a PDF.
Let me tell you that protecting your files with passwords is very important to protect your data, but in special cases, this procedure may cause you a lot of headaches.
The article "How To Easily Remove a Password From a PDF file" has been primarily created form my blog here.
Hi, my name is Federico and I am a freelance Technical Writer:
Do you want to start a documentation project, collaborating with me? Contact me!
Do you want to know more about my work? You can start with my case studies and my portfolio.
Top comments (6)
Except that is a CLI tool, how does it differ from opening it in PDF viewer and use print as PDF ?
It solved my issues for a decade, now.
Didn't think about that possibility.
Thanks, Christophe!
Anyway, your way is great if you have a bunch of files protected with the same password, something like medical analysis results that are always secured with a "password" made of your name and birthday.
Which is a poor but still good thing for security in term of global data leaks.
Even if it can be brute forced easily on one file with such known pattern. It would take time on millions of files
Thank you! Eventually, you gave me an idea for a little personal project to expand these concepts :) :)
I hope I won't be quoted in a security bulletin as the origin of your idea to brute force thousands of password protected documents you had access by error 😅🤣😂
You never know what people can do "for the sake of Science" 😂😂😂😂😂😂😂😂😂😂