How could I merge / convert multiple PDF files into one large PDF file?
I tried the following, but the content of the target file was not as expected:
convert file1.pdf file2.pdf merged.pdf
I need a very simple/basic command line (CLI) solution. Best would be if I could pipe the output of the merge / convert straight into pdf2ps
( as originally attempted in my previously asked question here: Linux piping ( convert -> pdf2ps -> lp) ).
Try the good ghostscript:
or even this way for an improved version for low resolution PDFs (thanks to Adriano for pointing this out):
In both cases the ouput resolution is much higher and better than this way using convert:
In this way you wouldn't need to install anything else, just work with what you already have installed in your system (at least both come by default in my rhel).
Hope this helps,
UPDATE: first of all thanks for all your nice comments!! just a tip that may work for you guys, after googling, I found a superb trick to shrink the size of PDFs, I reduced with it one PDF of 300 MB to just 15 MB with an acceptable resolution! and all of this with the good ghostscript, here it is:
cheers!!
You can use the convert command directly,
e.g.
You can use sejda-console, free and open source. Unzip it and run
sejda-console merge -f file1.pdf file2.pdf -o merged.pdf
It preserves bookmarks, link annotations, acroforms etc.. it actually has quite a lot of options you can play with, just run
sejda-console merge -h
to see them all.I like the idea of Chasmo, but I preffer to use the advantages of things like
Giving multiple source files to
convert
leads to merging them into a common pdf. This command merges all files with.pdf
extension in the actual directory intomerged.pdf
in the parent dir.Apache PDFBox http://pdfbox.apache.org/
PDFMerger This application will take a list of pdf documents and merge them, saving the result in a new document.
I am biased being one of the developers of PyMuPDF (a Python binding of MuPDF).
You can easily do what you want with it (and much more). Skeleton code works like this:
That's about it. Several options are available for selecting only pages ranges, maintaining a joint table of contents, reversing page sequence or changing page rotation, etc., etc.
We are on PyPi.