Concatenate Multiple PDF FilesTech linux · pdf
Some of you are familiar with the situation when you have got a bunch of pdf files you want to print. Especially at university there are a lot of different lecture notes waiting to be put on paper. Printing every single file can be annoying and cost too much time (and money if you pay an extra charge for the print job). Facing this problem I found out that there is a way to put multiple pdf files together using ghostview (which should be included in every linux distribution).
You need just one command to assemble file1.pdf, file2.pdf, file3.pdf… to one file (here: output.pdf):
gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf file1.pdf file2.pdf file3.pdf
For ease of use, here is a small script. Copy to a file called “pdfconcat” and save to a folder that’s included in your $PATH.
#!/bin/sh if [ $# -lt 2 ] then echo “Usage: $0 output.pdf input1.pdf [input2.pdf] … ” exit fi OUT=$1 shift IN=$@ gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$OUT $IN
Perhaps you have to adapt the PAPERSIZE (e.g. ‘letter’ in the US).