On Ubuntu Intrepid and newer CUPS works with a PDF-based printing workflow: https://www.linuxfoundation.org/en/OpenPrinting/PDF_as_Standard_Print_Job_Format This means all incoming files are converted to PDF (if they are not PDF already) and processed in PDF format. If an incoming file is PostScript it gets converted by the pstopdf CUPS filter from http://www.openprinting.org/download/printing/pdf-printing/pstopdf This filter converts the PostScript files with the ps2pdf13 script which comes as part of Ghostscript. I have a PostScript file which contains a bounding box (4x6 photo, attached) and this displays correctly with gv and the "bbox" output device returns the correct bounding box. If I convert the file to PDF with "ps2pdf13" I get the photo in the lower left corner of an A4 page (default paper size in /etc/papersize). Same happens when I send it to the printer, which leads to only a part of the photo getting on 4x6 paper in my printer. The same problem was also reported by a Ubuntu user. See https://bugs.launchpad.net/bugs/357732 What I expect is that ps2pdf13 conserves the size of each page, so that the PDF file has always the same page sizes as the incoming PostScript file. This makes automated conversion (here in print queues) and handling of multiple-page-size documents trivial. If you have to stick to fixed paper sizes for all output pages (default size or size given on command line) for compatibility with Acrobat Distiller, please provide a "-dConservePageSizes" option to optionally allow conserving the input paper sizes for use cases as my print filter.
Created attachment 4934 [details] flphoto-small-print.ps Print output of FL-Photo: A photo in 4x6 format
Ghostscript works as designed. The sample file doesn't set the page size and Ghostscript uses default page size, usually, US Letter. Distiller also uses US Letter. There's nothing to fix here. The file has the following DSC comments: %!PS-Adobe-3.0 %%BoundingBox: 0 0 288 432 %%Creator: flPhoto v1.3.1 i.e. is is not a EPS file. The BoundingBox comment in PS file indicates the marked area on the page, rather than the media size. For multi-page documents BoundingBox is defined as thee union of the page boxes, which doesn't correspond to any real box on any page. The use of BoundingBox in PS files to set the initial page size is likely to break other files. The bug report should be filed against "flPhoto v1.3.1" that relies on default page size.
Created attachment 4935 [details] testpage-cups.ps Alex, I've been discussing the problem with Till on IRC. I agree completely with the phot file. However the bug report from the Ubuntu user seems different. The job apparently does contain a /PageSize, but we seem to be ignoring it. Possibly there is something in the job (produced initially by pswrite!) which is obscuring the request. Setting the PageSize Policy to 2 might be the problem. I've attached the job from the Ubuntu report here, but haven't had a chance to debug it yet, I'm currently running a full pdfwrite regression test, which takes ages....
Created attachment 4936 [details] testpage-a4.ps Original Ubuntu test page in A4
Alex has pointed out that the output from pswrite contains : 612 792 /letter setpagesize Which sets the media to Letter, since this comes *after* the page size request (from a PPD ?) for A4, it takes precedence. Because the PostScript file is the result of multiple conversions by CUPS, somewhere along the line the job has been created for Letter media. Selecting A4 media will not alter the fact that it was originally prepared for Letter. The original file (testpage-a4.ps) does not contain any media selection requests (though it does contain comments about selecting A4 there are no requests and the job is not EPS, so the comments are ignored). As a result any conversion will use the default media size of Letter. This of course leads to all later conversions using letter media. I don't think there is a Ghostscript bug here, the bug is really in the application generating the original PostScript which does not request any media. This is the same problem as the photo uploaded by Till, no media selection requests. The bug is in the original PostScript, not Ghostscript's handling of it. It *is* possible to add DSC comment parsing handling, CUPS should either do this itself (as other DSC parsers do) or add a prologue which will convert %%BoundingBox comments into PageSize requests.
Problem solved in the CUPS filters. pstopdf applies the PageSize setting from CUPS (from the filter command line and if not supplied there from the PPD file) to the Ghostscript command line now ("-dDEVICEWIDTHPOINTS =237 -dDEVICEHEIGHTPOINTS=525", numbers from *PaperDimension line in PPD). This sets a useful default for PostScript files without PageSize request, either the size the user has chosen in the printing dialog or the size set as printer default by the admin. Multiple-page-size documents are expected to have appropriate page size requests and with these they print correctly.
Thank you for your help, Ken and Alex, it helped me to find the solution for the problem.