I am training to merge multiple files using ghostscript, nevertheless the problem arises because the pdf files are in different paper size.

So far, I've found this one command:

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf file1.pdf file2.pdf file3.pdf [...] lastfile.pdf

With same paper size it works, otherwise it does not.

Any suggestion are welcome?

Thanks for reading :)

1 Answer 1


Do you want all pages in the resulting document to have the same paper size? For that, you would need to resize the page of one of the two documents. This question deals with resizing one PDF using ghostscript.

Otherwise, just leave out the -sPAPERSIZE switch, so your command will look like:

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf file1.pdf file2.pdf file3.pdf lastfile.pdf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .