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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.