Merging PDF files

(1/1)

Richard Marks:
This is very easy to do on Linux.

Lets say that the directory ~/pdfs/book/chapters/ contains a lot of PDF files (one for each chapter) and we want to create book.pdf that contains all the chapters in one.

We need to have the gs and pdftk packages installed.
Code:

$ sudo apt-get install gs pdftk


Now that we have the tools, lets make our pdf with one command!

Change into our working directory
Code:

$ cd ~/pdfs/book/chapters


And create our pdf
Code:

$ ls *.pdf | xargs gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=book.pdf -dBATCH


That's it. After a few minutes (or longer if you have many pdfs to merge) you will have a shiny new book.pdf containing all the other pdf files.

Tip: name the pdf files using numerical prefixes so that they merge in order.
 8)

Navigation

[0] Message Index