An Open Access Peon

07 September 2007

Setting the output page size with ps2pdf

Ghostscript's ps2pdf utility converts Postscript format files into Adobe PDF. One drawback with this utility is that, by default, it always outputs in Ghostscript's default page size, regardless of the postscript document's page layout. This is probably sensible if the document is destined for printing, but at the moment PDF is also the best cross-platform way to express large spaces of graphics (in this case directed-tree graphs).

I've managed to get around this - mostly - as follows:

  1. Use ImageMagick's identify to get the Postscript document dimensions:
    $ identify test.ps
    test.ps PS 609x1528 609x1528+0+0 PseudoClass 256c 909kb 0.020u 0:01

  2. Execute ps2pdf with the -dDEVICEWIDTHPOINTS and -dDEVICEHEIGHTPOINTS arguments
    $ ps2pdf -dDEVICEWIDTHPOINTS=679 -dDEVICEHEIGHTPOINTS=1598 test.ps test.pdf
What I haven't been able to work out is how to suppress the margins in the resulting PDF. To avoid the Postscript document being cropped I added 70 points to the width and height.

8 Comments:

  • Probably far too late now, but I ran into the same problem and was looking for solutions when I ran across this posting. Eventually I realised just using epstopdf instead seemed to circumvent any page resizing problems.

    By Anonymous Anonymous, at 3:54 pm  

  • Hey, thanks for the epstopdf tip! It helped me out a lot!

    By Anonymous Anonymous, at 11:04 pm  

  • Thanks for the tip - you just saved my ass. ;)

    By Anonymous Anonymous, at 7:56 am  

  • another ass saved! thanks

    By Anonymous Anonymous, at 7:11 pm  

  • epstopdf works fine!!!! go for it ...

    By Anonymous Anonymous, at 3:27 am  

  • epstopdf win, thanks!

    By Anonymous Anonymous, at 4:34 am  

  • Another +1 for epstopdf! Thanks.

    By Anonymous Anonymous, at 5:50 pm  

  • You can also try:

    ps2pdf -dEPSCrop ...

    By Anonymous Anonymous, at 5:57 pm  

Post a Comment

<< Home