How to merge PDFs in Ghostscript while preserving paper size for each individual page - Stack Overflow

admin2025-04-06  0

I'm merging PDFs using GhostScript nad I came upon an error in which the PDFs are being merged in A4 paper size and some of the the original PDF content is being displayed only in the first quarter of the page.

This is the script I'm using for merging N files into merged.pdf:

gs -dBATCH -dQUIET -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf 0.pdf 1.pdf ...n.pdf 2>&1

I managed to get it to content fill the page using the -dPDFFitPage directive, but it's only expanding content into the A4 page.

I cannot always set the paper size directly because that would lead to the same problem but in a different way.

Is there a directive or a configuration in GS that allows me to preserve paper size for each individual page?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1743872541a222180.html

最新回复(0)