PDFtk: A tool to split PDF files from the terminal

pdftk

Finding PDF documents has become commonplace , because you can't deny that just a few years ago finding a document in this format was very rare, so having software to read it was not common, much less to edit it.

At work I often use the scanner and send documents directly to my email, either to edit them or simply to send them. I have no problem with that because the company provides all the software, so I don't have the ability to add or remove any more software.

The problem lies when I have to do the work at home, as many of you will know Adobe has not extended its tools for Linux, so it is necessary to use a third-party application.

This is where an application comes in that will help us with these tasks , which, unlike others, from my point of view has everything necessary, not to mention that it is the most complete.

About PDFtk

PDFtk is a front end for the iText library . PDFtk is an open-source, cross-platform tool designed for manipulating PDF documents . This application allows you to perform various actions on PDF documents, including splitting, merging, encrypting, decrypting, decompressing, recompressing, and repairing them.

It can also be used to manipulate watermarks, metadata, or to fill PDF forms with FDF (Forms Data Format) or XFDF (XML Form Data) data.

Among its main features we can highlight:

  • Merge multiple PDF files into one
  • Insert certain pages from one PDF to another
  • Rearrange, delete pages, rotate pages within PDF
  • Split a single PDF document into multiple files
  • Password protect PDF document
  • Disable Priting functionality and more

How to install PDFtk on Linux?

This application can be easily found and installed on most Linux distributions , so its availability should not pose any problem.

To install PDFtk on Linux, we need to open a terminal and type the commands according to your Linux distribution.

If you are using Debian, Ubuntu or a derivative of these, you must type this command:

sudo apt-get install pdftk

In the case of Arch Linux, users will not be able to install software from the main Arch Linux sources, so it is necessary to use the AUR.

sudo pacman -S git
git clone https://aur.archlinux.org/pdftk.git

cd pdftk

Inside the PDFtk source folder, they must start the compilation process by executing:

makepkg

For Fedora users, it is necessary to download a package, which can be done by typing these commands:

wget http://ftp.gwdg.de/pub/opensuse/distribution/leap/42.3/repo/oss/suse/x86_64/pdftk-2.02-10.1.x86_64.rpm
wget http://ftp.gwdg.de/pub/opensuse/distribution/leap/42.3/repo/oss/suse/x86_64/libgcj48-4.8.5-24.14.x86_64.rpm

Once the download is complete, we must now install the newly obtained packages with :

sudo dnf install libgcj48-4.8.5-24.14.x86_64.rpm pdftk-2.02-10.1.x86_64.rpm -y

If you are Main_PDF

Using one of the versions of penSUSE, you install the application with :

sudo zypper install pdftk

How to use PDFtk on Linux?

As mentioned previously, PDFTk has several editing options so its use depends on you.

To merge two PDF documents into a new PDF , we run:

pdftk 1.pdf 2.pdf cat output pdfresultante.pdf

Or if you want to merge all the PDFs that are in the same folder :

pdftk * .pdf cat output combined.pdf

Now, if you want to delete a page from the document , for example, page 5, you must indicate the end of the document with -end

pdftk documento.pdf cat 1-4 20-end output pdfresultante.pdf

Split a PDF document page by page:

pdftk documento.pdf burst

To rotate a document :

pdftk documento.pdf cat 1-endS output out.pdf

Here we are indicating that all the pages rotate towards the South, that is, we are going to rotate the pages 180 degrees if you want to rotate the document 90 degrees do it with E and if you want 270 degrees with W.

If you want to learn more about the commands and some examples of this tool, you can visit the following link.


Add as preferred source in Google