0
votes

I try to resize pdf by ghostscript command line but output pdf papersize not according to input i m using command gswin64c.exe -o E:\output.pdf -dBATCH -dNOPAUSE -dDOPDFMARKS -sDEVICE=pdfwrite -dFIXEDMEDIA -dPDFFitPage -dDEVICEWIDTHPOINTS=396 -dDEVICEHEIGHTPOINTS=612 -f E:\comic.pdf

and output pdf size is 396 x 604.653 pts

can you help me about this issue.

1
Can't help without seeing the input PDF file, would also help to know the version of Ghostscript you are using. It may be that the original PDF file has a CropBox or similar. - KenS
input pdf size is 495.12x756 pts - Ramesh kumar
input pdf size is 495.12x756 pts and Ghostscript versions 9.50 - Ramesh kumar
With respect, I didn't ask for the input PDF 'size', I need to see the actual PDF file. - KenS

1 Answers

1
votes

The answer is simple, you are trying to scale the PDF by different amounts horizontally and vertically, the PDFFitPage switch doesn't do that.

In fact there is no canned option for doing that in Ghostscript at all, you would need to write a PostScript program to do so.

If we look at your original file the page has a MediaBox of: /MediaBox[0.0 0.0 495.12 756.0], so that's (as you say) 495.12 x 756 points. You insist the output be 396x612.

So the x scale factor is 396/495.12 = 0.7998, the y scale factor is 612/756 = 0.809. So in order to scale isomorphically we need to use the scale factor of 0.7998. 756 * 0.7998 = 604.6488. Rounding errors probably explain the slight differences.