How to edit a pdf file for free

pdftk (PDF Toolkit) is a command-line tool which enables you to edit pdf files. pdftk is freely available on Linux, MS Windows, MacOS X and FreeBSD. So using pdftk, you can edit pdf files without having to pay for a commercial pdf editor. If you would like to install pdftk on Linux, proceed as follows.

To install pdftk on Ubuntu or Debian:

$ sudo apt-get install pdftk

To install pdftk on CentOS, Fedora or RHEL:

$ sudo yum -y install gcc gcc-java
$ wget http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-1.44-src.zip
$ unzip pdftk-1.44-src.zip
$ cd pdftk-1.44-dist/pdftk
$ make -f Makefile.Redhat
$ sudo make install

To install pdftk on other platforms such as MS Windows and MacOS X, you can download pdftk ports for Windows and OS X here.

Once you have installed pdftk on your system, you can edit pdf files using pdftk as follows.

To merge pdf files:

$ pdftk input1.pdf input2.pdf input3.pdf cat output final.pdf

To extract pages from a pdf file (e.g., extract pages 3, 4 and 5 into a new pdf):

$ pdftk input.pdf cat 3-5 output final.pdf

To remove pages from a PDF file (e.g., remove page 3 and create a new pdf without the page):

$ pdftk input.pdf cat 1-2 4-end output final.pdf

To rotate each page of a multi-page pdf document 180 degrees:

$ pdftk input.pdf cat 1-endS output final.pdf

To rotate each page of a multi-page pdf document 90 degrees clockwise:

$ pdftk input.pdf cat 1-endE output final.pdf

To rotate each page of a multi-page pdf document 90 degrees counterclockwise:

$ pdftk input.pdf cat 1-endW output final.pdf

To reverse the order of pages in a multi-page pdf document:

$ pdftk input.pdf cat end-1 output final.pdf

To select pages of different pdf documents into a new pdf:

$ pdftk A=input1.pdf B=input2.pdf cat A3-5 B1-3 A10 output final.pdf

It selects pages 3, 4, 5 from input1.pdf, pages 1, 2, 3 from input2.pdf, and page 10 from input1.pdf into a new pdf.

To add a watermark to a pdf file:

$ pdftk input.pdf background watermark.pdf output final.pdf

A watermark image file (watermark.pdf) is applied to every page of input.pdf.

To merge two pdf files as odd and even pages:

$ pdftk A=odd.pdf B=even.pdf shuffle A B output final.pdf

To merge two pdf files as odd and reversed even pages:

$ pdftk A=odd.pdf B=even.pdf shuffle A Bend-1 output final.pdf

To merge two pdf files as odd and reversed/180-rotated even pages:

$ pdftk A=odd.pdf B=even.pdf shuffle A Bend-1S output final.pdf

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

2 thoughts on “How to edit a pdf file for free

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *