Combining Multiple PDF Files Into One PDF File in Linux

This post is inspired (and 68% taken) from here. 😀

There are times when you need to combine multiple PDF files into one single PDF file. In Windows or Mac, it’s easy (as long as you are willing to spend some amount of money to buy the software), you can use Adobe Acrobat Professional. Sadly Adobe didn’t come up with Acrobat Professional for Linux platform, but luckily we have several options to do such job in a Linux box. Here’s one.

GhostScript is an interpreter for PostScript language and PDF files, and as far as I know, GhostScript is widely available by default on various Linux distro. In this post I will show you a simple trick to use GhostScript to combine any numbers of PDF files into one single PDF file. Although combining files with GhostScript has its own drawbacks, but still, for most purposes GhostScript does the job well.

Here’s the voodoo mantra, spell them on Linux terminal:
$ gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf ...

And below is the explanation of each mantra:

  • gs
    The GhostScript program.
  • -dBATCH
    tells the program to exit after finishing the job.
  • -dNOPAUSE
    tells the program to keep going without having conversation with the user.
  • -sDEVICE=pdfwrite
    tells the program to use its internal PDF writer to process the files.
  • -sOutputFile=finished.pdf
    tells the program where to put those scattered PDF files into one file whom name you specified.
  • file1.pdf file2.pdf …
    tells the program which PDFs you want to combine.

Tada, now you have combined PDF file, ready to brought anywhere without worry leaving one part behind.

Tiled Multiple GNOME Terminal

2015 update:

  • now I use the more superior Terminator.
  • I am now aware of tiling window manager (i3, awesome, etc.).

When I do stuff with Linux, 68% of them are terminal/shell work. And most of them needs many tty/terminals at once. In Ubuntu, or generally in GNOME Desktop Manager, arranging multiple terminal layout every time you need it can be such a pain in the ass. Here’s a simple shortcut to open multiple gnome-terminal with arranged (tiled) position:

#!/bin/sh
#

gnome-terminal –geometry=157×22+0+670 &
gnome-terminal –geometry=80×20+700 &
gnome-terminal –geometry=100×20+0 &

You can save the script into a file, and put it in $PATH directory. For example:

/usr/local/bin/multiterm

Then change the file mode bits to make that executable:

$ sudo chmod 755 /usr/local/bin/multiterm

And here is what it looks like

Multiple tiled GNOME Terminal

Multiple tiled gnome-terminal

For the sake of simplicity and ease of access, you can put a shortcut on the GNOME panel to launch the script with a single click of the mouse.