[reportlab-users] Printing PDF's

David Hughes reportlab-users@reportlab.com
Mon, 22 Dec 2003 16:12 +0000 (GMT Standard Time)


Back on 4th November 2003, Dave Rogers wrote:

> Hi,
> 
> I use reportlab to generate PDF files.
> 
> For some time, to print files in the background (with a Windows 
> service), I've been using the awful DDE interface to Acrobat which 
> works for awhile and then fails with no useful error message.
> 
> I'm trying to switch to Ghostscript to print my files.  However, even 
> though I've been through many many Ghostscript options, my documents 
> are getting cut off on the top or the bottom by about 3/8".
> 
> I use -sDEVICE=mswinpr2
> 
> Here's other options I've tried:
> 
> -dFIXEDMEDIA (cuts off top)
> -dFIXEDRESOLUTION (cuts off bottom)
> -dDEVICEHEIGHTPOINTS= XX (I've tried numbers higher and lower than the 
> std letter height and it always cuts off the bottom)
> 
> I use a Brother MFC 6800 and I cannot find any option to set or reduce 
> my margins in the printer setup.
> 
> Is there a reportlab setting I can change to fix this problem?
> 
> If someone knows of a better place I should post this to, please let me 
> know.
> 
> Thanks,
> 
> -- 
> Dave Rogers
> DaveRogers@StockAlerts.com
> http://StockAlerts.com


I have just discovered that the problem goes away if you drive Ghostscript 
using GSPrint, a program that comes along with GSView. Here is the first 
paragraph of its help file:

"""GSPRINT uses Ghostscript to print a PostScript file to a Windows 
printer. Using Ghostscript alone you can print using a number of inbuilt 
printer drivers for specific printers (e.g. djet500, ljet4), or you can 
use the driver mswinpr2 which talks to the Windows printer driver. The 
mswinpr2 driver (which I [Russell Lang] wrote) is very slow. GSPRINT tells 
Ghostscript to produce a bitmap, and then sends this to the Windows 
printer driver in a much more efficient way than the old mswinpr2. 

GSPRINT requires AFPL Ghostscript 6.0 or later. 
"""

In my own case, instead of creating the command with the Python code:

  device = 'mswinpr2'
  command = (mypath['gs'] +
             ' -I' + mypath['gs_lib'] + ';' + mypath['gs_fonts'] +
             ' -q -dSAFER -dBATCH  -dNOPAUSE -dNoCancel ' +
             ' -dFirstPage=%d -dLastPage=%d ' +
             ' -sDEVICE=%s  -sOutputFile="\\\\spool\%s" '+
             '  %s ') % (frompage, topage, device, printer, pathname)
             
I now use:             
           
  command = (mypath['gsprint'] +
            ' -ghostscript "' + mypath['gs'] + '"' +
            ' -I' + mypath['gs_lib'] + ';' + mypath['gs_fonts'] +
            ' -colour -from %d -to %d ' +
            ' -printer "%s" ' +
            '  %s ') % (frompage, topage, printer, pathname)
            
and everything prints except for a bottom 0.5 inch margin, on my printer. 
The behaviour is still slightly different to printing via the Acrobat 
reader, in that although there is still a physical 0.5" margin on the 
printed page. Acrobat seems to scale the viewed page image to fit the 
printable area.

GSPrint uses the AFPL licence not GNU/GPL - I don't know if that's 
significant to anyone.

Regards,

David Hughes
Forestfield Software Ltd
www.forestfield.co.uk