Sunday, 15 May 2011

Moving PostScript output on page

The easiest way to print PDF output from UNIX without installing any drivers is to convert PDF to Postscript and send directly to printer.

However, when you convert PDF to Postscript you cannot specify “shrink to fit” or “fit to printable area” option.

As a result you can get an unexpected results like:

   Where is no margins

   Output was moved to the lift/right/up/down

My latest problem was that one of the reports that I generated from Oracle Application , contained a logo at the top of the page. I converted PDF to Postcript (you can use xpdf or Ghostscript open source products) and sent it to the printer. Actual output on paper moved up and half of the logo was not printed

So how can you move the output without actually redesigning your report?

    I will show how to do it with Ghostscript

First of all use one of the utilities I mentioned above to create a PostScript output from PDF. Assuming that output files called

Assuming that Ghostscript installed under $GS_TOP variable

1. Create new file called Put it under /tmp directory

   The content of the file should be

        /PageOffset [0 0]
        /.HWMargins [0 0 0 0]

2. Run the following commands

export GS_LIB

$GS_TOP/gs/bin/gs -dSAFER -q -dNOPAUSE -dCompatibilityLevel=1.2 -dBATCH -sDEVICE=pswrite  -dSAFER /tmp/

That is all. Ghostscript will combine and files and create new files called

How to control the position of the output?

Note the following line  in file

/PageOffset [0 0]

Left 0 controls X offset (can be also negative) and right 0 controls Y offset. Just change their values to adjust the position of the output for your needs

No comments:

Post a Comment