0

I'm trying to resize a PDF document with large dimensions to A4 format with 2cm borders on each size.

This is what I managed to get so far gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -sOutputFile=output.pdf input.pdf

The problem is that even though it scales down to A4, it adds a border on left/right side. I'd like to add a border (2cm) on each of the sides (top/bottom/left/right).

I tried to search everywhere Resize A4 PDF to SRA4 and center content

Using -c "<</PageOffset [21 32]>> setpagedevice" gives me **** Unable to open the initial device, quitting.. Do you know what am I doing wrong? Or how could I get A4 PDF document with 2cm borders?

Thank you

Community
  • 1
  • 1
Jan Vorcak
  • 19,261
  • 14
  • 54
  • 90

1 Answers1

1

I'd need to see an example file and command line before I could offer any concrete help, however your use of -c isn't balanced by a -f which 'might' be the problem there.

KenS
  • 30,202
  • 3
  • 34
  • 51
  • Hi, thank you for your input. Adding `-f` really helped but now I'm trying to figure out what shall I use in `-c` in order to make 2cm padding around my PDF. – Jan Vorcak Feb 25 '15 at 14:04
  • Increase the media size, don't set -dPDFFitPage (because that will fit the content to the new page size). Add a translate (eg 57 57 translate) and then scale the content so that it fits the desired size. SO if the media is twice A4 and you want it to be A4, set ".5 .5 scale" – KenS Feb 25 '15 at 21:06
  • I should warn you that an 'initgraphics' from the PDF interpreter might invalidate the PostScript between -c and -f, in which case you will have to look at how PDFFitPage is written and adapt the code there. – KenS Feb 25 '15 at 21:07