Merging Multiple PDFs into one file on Ubuntu (linux)
Today I wanted to merge two PDF files into one final PDF document. On Ubuntu, this was harder than I thought. I have done this on Windows using Adobe and it was pretty simple. I decided that I will make this post so that I can always find the command when I am looking for it.
This is a command-line approach. I did not find a nice GUI approach, but if there is anyone out there who has found one, please feel free to leave a comment.
Here are the steps to install the necessary packages:
sudo apt-get install gs
sudo apt-get install pdftk
Now here is the command that does the actual merging:
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf -dBATCH first.pdf second.pdf
You can merge more PDFs by simply adding on a third pdf etc. It merges them in the order you put it. So second.pdf will merge after the last page of first.pdf
output.pdf will contain the final PDF that you want. You should probably have all the PDFs in one directory and run the command from there although this is not necessary if you know what you are doing and you know your directory structure.
Go forth and merge!