How To Remove Password From A PDF File in Linux
The other day I had to share a password-protected PDF file to a friend of mine. Instead of disclosing the password, I wanted to remove the password and sent the file to him. I started to looking for some easy ways to remove the password protection from the pdf files on Internet. After a quick google search, I learned the following four methods to remove password from a PDF file in Linux. The funny thing is I had already done it few years ago and I almost forgot it. If you’re wondering how to remove password from a PDF file in Linux, read on! It is not that difficult.
Remove Password From A PDF File in Linux
Method 1 – Using Qpdf
The Qpdf is a PDF transformation software which is used to encrypt and decrypt PDF files, convert PDF files to another equivalent pdf files. Qpdf is available in the default repositories of most Linux distributions, so you can install it using the default package manager.
For example, Qpdf can be installed on Arch Linux and its variants using pacman as shown below.
$ sudo pacman -S qpdf
On Debian, Ubuntu, Linux Mint:
$ sudo apt-get install qpdf
Now let us remove the password from a pdf file using qpdf.
I have a password-protected PDF file named “secure.pdf”. Whenever I open this file, it prompts me to enter the password to display its contents.
I know the password of the above pdf file. However, I don’t want to share the password with anyone. So what I am going to do is to simply remove the password of the PDF file using Qpdf utility with following command.
$ qpdf --password='123456' --decrypt secure.pdf output.pdf
Quite easy, isn’t it? Yes, it is! Here, 123456 is the password of the secure.pdf file. Replace the password with your own.
Method 2 – Using Pdftk
Pdftk is yet another great software for manipulating pdf documents. Pdftk can do almost all sort of pdf operations, such as;
- Encrypt and decrypt pdf files.
- Merge PDF documents.
- Collate PDF page Scans.
- Split PDF pages.
- Rotate PDF files or pages.
- Fill PDF forms with X/FDF data and/or flatten forms.
- Generate FDF data stencils from PDF forms.
- Apply a background watermark or a foreground stamp.
- Report PDF metrics, bookmarks and metadata.
- Add/update PDF bookmarks or metadata.
- Attach files to PDF pages or the PDF document.
- Unpack PDF attachments.
- Burst a PDF file into single pages.
- Compress and decompress page streams.
- Repair corrupted PDF file.
Pddftk is available in AUR, so you can install it using any AUR helper programs on Arch Linux its derivatives.
$ yay -S pdftk
On Debian, Ubuntu, Linux Mint, run:
$ sudo apt-get instal pdftk
On CentOS, Fedora, Red Hat:
First, Install EPEL repository:
$ sudo yum install epel-release
$ sudo dnf install epel-release
Then install PDFtk application using command:
$ sudo yum install pdftk
$ sudo dnf install pdftk
Once pdftk installed, you can remove the password from a pdf document using command:
$ pdftk secure.pdf input_pw 123456 output output.pdf
Replace ‘123456’ with your correct password. This command decrypts the “secure.pdf” file and create an equivalent non-password protected file named “output.pdf”.
- How To Merge PDF Files In Command Line On Linux
- How To Split or Extract Particular Pages From A PDF File
- How To Create A Video From PDF Files In Linux
Method 3 – Using Poppler
Poppler is a PDF rendering library based on the xpdf-3.0 code base. It contains the following set of command line utilities for manipulating PDF documents.
- pdfdetach – lists or extracts embedded files.
- pdffonts – font analyzer.
- pdfimages – image extractor.
- pdfinfo – document information.
- pdfseparate – page extraction tool.
- pdfsig – verifies digital signatures.
- pdftocairo – PDF to PNG/JPEG/PDF/PS/EPS/SVG converter using Cairo.
- pdftohtml – PDF to HTML converter.
- pdftoppm – PDF to PPM/PNG/JPEG image converter.
- pdftops – PDF to PostScript (PS) converter.
- pdftotext – text extraction.
- pdfunite – document merging tool.
For the purpose of this guide, we only use the “pdftops” utility which is used to remove password of a pdf file.
To install Poppler on Arch Linux based distributions, run:
$ sudo pacman -S poppler
On Debian, Ubuntu, Linux Mint:
$ sudo apt-get install poppler-utils
On RHEL, CentOS, Fedora:
$ sudo yum install poppler-utils
Once Poppler installed, run the following command to decrypt the password protected pdf file and create a new equivalent file named output.pdf.
$ pdftops -upw 123456 secure.pdf output.pdf
Again, replace ‘123456’ with your pdf password.
As you might noticed in all above methods, we just converted the password protected pdf file named “secure.pdf” to another equivalent pdf file named “output.pdf”. Technically speaking, we really didn’t remove the password from the source file, instead we decrypted it and saved it as another equivalent pdf file without password protection.
Method 4 – Print to a file
This is the easiest method among all of the above methods. You can use your existing PDF viewer such as Atril document viewer, Evince etc., and print the password protected pdf file to another file.
Open the password protected file in your PDF viewer application. Go to File -> Print. And save the pdf file in any location of your choice.
And, that’s all. Hope this was useful. Do you know/use any other methods to remove the password protection from PDF files? Let us know in the comment section below.
More good stuffs to come. Stay tuned!
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!