Last updated on July 29, 2020 by Dan Nanni
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. 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.
pdftk
on LinuxTo install pdftk
on Ubuntu or Debian, simply use apt-get
:
$ sudo apt-get install pdftk
To install pdftk
on CentOS, Fedora or RHEL, you can build it from the source as follows.
$ 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 ported versions of pdftk
ports for Windows and MacOS.
pdftk
Once you have installed pdftk
on your system, you can edit PDF files using pdftk
as follows.
$ pdftk input1.pdf input2.pdf input3.pdf cat output final.pdf
For example, the following command extracts pages 3, 4, 5 and makes them into a new PDF file.
$ pdftk input.pdf cat 3-5 output final.pdf
For example, the command below removes page 3 and creates a new PDF without the page.
$ pdftk input.pdf cat 1-2 4-end output final.pdf
$ pdftk input.pdf cat 1-endsouth output final.pdf
$ pdftk input.pdf cat 1-endeast output final.pdf
$ pdftk input.pdf cat 1-endwest output final.pdf
$ pdftk input.pdf cat end-1 output final.pdf
The command below extracts pages 3, 4, 5 from input1.pdf
, extracts pages 1, 2, 3 from input2.pdf
, extracts page 10 from input1.pdf
, and converts these into a new PDF file called final.pdf
.
$ pdftk A=input1.pdf B=input2.pdf cat A3-5 B1-3 A10 output final.pdf
The command below applies a watermark image file (watermark.pdf
) to every page of input.pdf
.
$ pdftk input.pdf background watermark.pdf output final.pdf
$ pdftk A=odd.pdf B=even.pdf shuffle A B output final.pdf
$ pdftk A=odd.pdf B=even.pdf shuffle A Bend-1 output final.pdf
$ pdftk A=odd.pdf B=even.pdf shuffle A Bend-1S output final.pdf
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean