Skip to content

Instantly share code, notes, and snippets.

@brenopolanski
Last active May 2, 2024 06:56
Show Gist options
  • Save brenopolanski/2ae13095ed7e865b60f5 to your computer and use it in GitHub Desktop.
Save brenopolanski/2ae13095ed7e865b60f5 to your computer and use it in GitHub Desktop.
Merge multiple PDFs using Ghostscript

A simple Ghostscript command to merge two PDFs in a single file is shown below:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH 1.pdf 2.pdf

Install Ghostscript:

Type the command sudo apt-get install ghostscript to download and install the ghostscript package and all of the packages it depends on.

@rustinlewis
Copy link

Any downside to using -o?

Auto adds the -dBATCH and -dNOPAUSE ... Found in the docs here

gs -o combine.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress 1.pdf 2.pdf

@frankie303
Copy link

thank you!

@TomLaco
Copy link

TomLaco commented Jul 19, 2022

This could not be easier ! Thank you very much !

@tanimislam
Copy link

thanks!

@Steve778845
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment