0
votes

My customer wants me to add additional information to right and top border on their single page PDF. The file contains image of the product with measures and other info. I need to scale the content of the page, so that right/top margins would be clear to add extra data. I have played around with Ghostscript in Windows, but so far either the image is cropped out or nothing happens: gswin32c -sOutputFile=scaled2.pdf -dBATCH -dNOPAUSE -dDEVICEHEIGHTPOINTS=312 -dDEVICEWIDTHPOINTS=421 -dFIXEDMEDIA -dPDFFitPage -sDEVICE=pdfwrite -c "<> setpagedevice" -f 255x195x175mm_EB_Fefco0427_FSN1013.pdf

As I usually don't work with PDFs then I'm out of my debth here. After scaling Print preview for A4 landscape

I need the image in PDF scaled smaller and sitting in the bottom-right corner. PDF size should be the same.

Any other solution that works in Windows and can be handled from commandline, is also OK.

1

1 Answers

3
votes

You can look at the code presented in my answer here. That shows you how to rescale the content of a PDF file to a different media size, and how to reposition the scaled content on the nominal output medium.

I'm rather surprised that -c "<>setpagedevice" -f doesn't simply produce an error, since that's not valid PostScript.

[edit]

OK so you either need to do two passes or do the calculation of the scale yourself.

In the two pass model you first apply the scaling, which will get you a PDF file where the content still fills the page, but the page has been resized to the smaller dimensions. You then run it with the translation and the desired final media size, but don't set FitPage.

To do the scaling yourself you would need to add the scale to the BeginPage command instead of having Ghostscript do it for you. That means you are going to have to calculate the scale factors yourself.

The parameter to the setpagedevice operator would look something like :

<</BeginPage {0.5 0.5 scale 200 0 translate}>> setpagedevice

That will scale the content down by 50% in each direction, and move the origin by 100 points to the right. Obviously the translate values will depend on the scale factor and the size of the original and scaled media. I would try this to check it, but you haven't supplied an example PDF file to test.