How to fit PDF to a5 landscape using ghostscript?

598 views Asked by At

The following works nicely to resize an A4 (or presumably any original size) PDF to A5 portrait orientation:

gs -sDEVICE=pdfwrite -sPAPERSIZE=a5 -dFIXEDMEDIA -dPDFFitPage \
   -dCompatibilityLevel=1.4 -o out.pdf in.pdf

But how to fit it onto A5 landscape? (e.g. scaled and centred)

I'm assuming (ha!) that there's a simple flag for this somewhere, after all they've been so kind as to provide international papersize aliases for point sizes...

So far I've tried RTM but couldn't find anything, and I've tried specifying the device size with -g5950x4200 (which at default 720 ppi is the dimensions for landscape A5), both of -g5950x4200 -g4200x5950 result in the same thing: portrait A5!

edit: using ghostscript 9.10.

1

There are 1 answers

1
KenS On

Its almost impossible to answer these kinds of questions without seeing an example file. However the most likely answer is that you haven't set AutoRotatePages to false. You can also use -dDEVICEWIDTHPOINTS= and -DDEVCIEHEIGHTPOINTS= to avoid figuring out the pixels based on the resolution.

You also don't say what version of Ghotscript you are using.

Note that you aren't resizing a PDF, precisely. Ghostscript interprets the original PDF, produces a list of marks, and then turns those into a new PDF. The new PDF merely looks like the original, its not the same file.