[reportlab-users] PDFs generated by ReportLab not printing

King Simon-NFHD78 simon.king at motorola.com
Fri May 22 07:24:28 EDT 2009


Andy Robinson wrote

> 2009/5/22 King Simon-NFHD78 <simon.king at motorola.com>:

> > I don't really understand why someone would be able to open

> a PDF file

> > in Acrobat Reader (for example), and yet be unable to print it. I'm

> > assuming that printers don't generally understand the PDF format

> > directly, and that Acrobat converts it to Postscript before

> sending it

> > to the printer driver. Is that too simplistic a view?

>

> It's exactly right.

>

> Acrobat Reader was deliberately forgiving in the early days and could

> recover from small errors in the graphics codes; everybody wishes they

> hadn't been, though i suppose it's better than the history of web

> browsers ;-)

>

> If you're using a typical Windows PC or some printing technology which

> rasterises on the computer like Mac's preview, and/or a typical inkjet

> or a cheap laser, the viewer sends an image to the printer. But if

> you're using a Postscript printer, it exports postscript. In this

> case a small bug like a missing graphics state operator in PDF can

> transfer the same bug to Postscript; and Postscript interpreters can

> then choke.

>

> The test for this is to export a Postscript file from Acrobat Reader;

> then run that through Distiller, and see the offending commands. In

> my experience the error messages are pretty much the same as the ones

> that come out of a good printer on the error page.

>

> - Andy


Ah ha - the plot thickens. I had assumed that the printer I've been
using was a Postscript printer, but actually it is a PCL one. I don't
have access to a postscript printer, but we do have a linux server with
a "virtual" Postscript printer with a shell script that uses ps2pdf to
create PDFs. I tried printing to that printer, and the PDFs that came
out were mostly blank, apart from the following error message:

ERROR: invalidrestore
OFFENDING COMMAND: restore
STACK:
-savelevel-
-savelevel-

I can't see an option to Save a Postscript file directly from Acrobat
Reader except by using the "Print to file" option. If I do that, Acrobat
says "The document could not be printed", but it still creates a
postscript file. If I try to feed that postscript file through ps2pdf, I
get the same error:

%%[ ProductName: GNU Ghostscript ]%%
%%[Page: 1]%%
%%[ Error: invalidrestore; OffendingCommand: restore ]%%
GNU Ghostscript 7.05: Unrecoverable error, exit code 1

So it really does look like there is something wrong with the postscript
commands inside my PDF. Now that I can reproduce the problem, I'll start
eliminating parts of the report to see if I can figure out exactly which
part triggers the problem. I'll let you know what I find out.

Thanks for all your help,

Simon


More information about the reportlab-users mailing list