OiO.lk Blog pdf Define output rectangle when creating PDF from PostScript with GhostScript
pdf

Define output rectangle when creating PDF from PostScript with GhostScript


I have some old PostScript files and try to convert them to PDF files with GhostScript. Unfortunately the PostScript files use some custom paper size (16" x 20") as following:

featurebegin{
%%BeginFeature: *CustomPageSize

1440 1152 0 0 0
  5 -2 roll exch 5 2 roll
  3 -2 roll exch 3 2 roll
  [ {}
    {90 rotate 0 currentpagedevice /PageSize get 0 get neg translate}
    {180 rotate currentpagedevice /PageSize get 
     dup 0 get neg exch 1 get neg translate}
    {270 rotate currentpagedevice /PageSize get 1 get neg 0 translate}
  ] exch get
  4 dict dup begin 6 1 roll
  /Install exch def
  2 array astore /PageOffset exch def
  2 array astore /PageSize exch def
  /ImagingBBox null def
  end setpagedevice
%%EndFeature
}featurecleanup

The "useful" content of the PostScript files will match on paper size A4, so my resulting PDF file shows the content in the left upper corner and have a big border to the right and at the bottom (Example image of created PDF file).

How can I tell GhsotScript to use a rectangle in the upper left corner with a size matching paper size A4 to avoid this big border coming from the custom paper size?

I tried different approaches with combinations of the parameters -dFitPage, dFIXEDMEDIA, -sPAPERSIZE=a4, -dDEVICEWIDTHPOINTS, -dDEVICEHEIGHTPOINTS but nothing works as expected.

The best result I’ve got is a PDF file using the correct paper size (A4), but the content was used from the lower left corner. So I see just a part of my useful content.

I need no scaling of the content, I just want to define the rectangle that should be used for creating the PDF file. Is this possible with GhostScript?



You need to sign in to view this answers

Exit mobile version