With the Linux command line / Terminal, it is easy to merge, split and edit PDF files. There is a useful tool for that called pdftk which is like the Swiss knife for PDF-related functions.
To install pdftk, open the Linux Terminal and type in
Merging PDF files:
To merge different PDF files into one using pdftk, the syntax is:
In this example, different files from 1 to 6, etc are merged into a single output file named doc.pdf. This file has all the pages from the individual source files. So, the command is:
Another example of merging files:
Besides merging, you can also selectively choose pages to omit or include.
Suppose you want to exclude the 4th page of the source PDF file named doc.pdf, then it can be done as follows:
This output file will have all the pages except the one excluded. Pretty cool.
Encrypting and password-protecting PDFs:
pdftk also can encrypt the source PDFs and set a password to open them. To do that, specify the encryption strength.
So, to add 128-bit encryption to a source PDF named doc.pdf, and set a password hello! to open it, the command will be:
The encryption strength has to be specified after the . and the user_pw parameter for adding a password to open the file.
Splitting a PDF file into pages:
To split a PDF file named doc.pdf into individual pages,Â use the burst parameter:
This burst function will show the individual pages as different files.
Besides these basic operations, pdftk can also rotate pages, repair PDFs, and do a lot more.
To list its various functions, type in
Also, just using pdftk without any parameters or input files will list its commonly used functions.
This tiny utility makes it easy to manage and edit PDF files all through a few simple commands.