How to merge several PDF files?
pdftk
To merge two pdf files, file1.pdf
and file2.pdf
:
pdftk file1.pdf file2.pdf cat output mergedfile.pdf
More info available hereWay Back Machine.
To install, run:
sudo snap install pdftk
PDF-Shuffler (install)
If you want a tool with a simple GUI, try pdfshuffler. It allows for merging of PDFs as well as rearranging and deleting pages. For batch processing and/or more complicated tasks, pdftk is of course more powerful.
Ghostscript is a package (available by default in Ubuntu) that enables you to view or print PostScript and PDF files to other formats, or to convert those files to other formats.
To use Ghostscript to combine PDF files, type something like the following:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile=finished.pdf file1.pdf file2.pdf
Here is a brief explanation of the command:
gs starts the Ghostscript program.
-dBATCH once Ghostscript processes the PDF files, it should exit.
If you don't include this option, Ghostscript will just keep running.
-dNOPAUSE forces Ghostscript to process each page without pausing for user interaction.
-q stops Ghostscript from displaying messages while it works
-sDEVICE=pdfwrite
tells Ghostscript to use its built-in PDF writer to process the files.
-sOutputFile=finished.pdf
tells Ghostscript to save the combined PDF file with the specified name.
-dAutoRotatePages=/None
Acrobat Distiller parameter AutoRotatePages controls the automatic orientation selection algorithm: For instance: -dAutoRotatePages=/None or /All or /PageByPage.
Your input files don't even need to be PDF files. You can also use PostScript or EPS files, or any mixture of the three.
There is a lot you can do with Ghostscript. You can read its documentation for more details.
Source