Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Slow printing of pdf files (after conversion to ps) under Linux

864 views
Skip to first unread message

Graham Nicholls

unread,
Aug 17, 2004, 8:59:20 AM8/17/04
to
My sig is unfortunate, as the client keeps throwing it back in my face, so I
might have to change it to "The answers No, bugger off!", unless I can fix
this.

Basically printing pdf files to networked HPLJ 4xxx printers is very slow.
As the printers don't understand pdf, I have to convert them to postscript
first, using acroread -toPostScript <filename>, and printing the resultant
ps file. A typical file is taking upto 1 minute to print.

The problem seems to be that the printer needs (not unreasonably) the whole
file before it can start to print. A single page pdf which is approx. 120K
becomes 900K when "ps-ified" - this seems large. The original does have a
couple of embedded images, but these can't be removed. Sending the file to
the printer is what takes the time - I've written a c program to do this so
I can time it (netcat gave similar results, but I wanted something as
simple as possible), and the printer takes ages to accept the data. The
network card on all machines runs at 100Mbit full duplex, and I'm trying
this from an old SuSE 7.2 multiprocessor machine as well as a SuSE 9.1
installation on a fast PC with lots of memory and a 2.6.7 kernel.

Using my np program, with varying buffer sizes gives essentially the same
result - the printer accepts a certain amount to data, then stops receiving
for a while. I've tried printing to printers with 80Mb of RAM, but with no
discernable difference. Using ssh to send the data across the same network
takes a second or so, so its clearly the printer causing the problem.

One approach I've tried is to convert the file to pcl using ghostscript, but
gs itself takes 11-14 seconds to convert the file, incidentally reducing
the size to around 200k from the 980k of the ps version, and then the
printer still takes a while to accept the data.

If the file (on an SMB share) is printed from windows, it prints virtually
instantaneously - I suspect (but haven't yet sniffed the network to be
sure) that windows is converting the file to pcl in its printer driver -
but I could of course be wrong (there has to be a first time, I
suppose ;-).

Any ideas/pointers, tools to do a fast conversion, etc would be greatly
appreciated.
Thanks
Graham Nicholls
--
With Linux, the answer's always "Yes"

Bob Tennent

unread,
Aug 17, 2004, 9:18:17 AM8/17/04
to
On Tue, 17 Aug 2004 13:59:20 +0100, Graham Nicholls wrote:

> Basically printing pdf files to networked HPLJ 4xxx printers is very slow.
> As the printers don't understand pdf, I have to convert them to postscript
> first, using acroread -toPostScript <filename>, and printing the resultant
> ps file. A typical file is taking upto 1 minute to print.

Try using ghostscript's pdf2ps to convert the file.

Bob T.

P.T. Breuer

unread,
Aug 17, 2004, 9:54:16 AM8/17/04
to
In comp.os.linux.misc Graham Nicholls <gra...@rockcons.co.uk> wrote:
> Basically printing pdf files to networked HPLJ 4xxx printers is very slow.

Laserjets understand PS - they should be fast as a rocket. In fact they
are - I have had dozens over the years, and I use them always.

> As the printers don't understand pdf,

?? DO printers understand pdf nowadays? What a hoot!

> I have to convert them to postscript

Well, you don't - PS is the normal printing language in unix. When you
send anything to a unix "printer" (that's a virtual device), it is
expected to be already in PS, and it will be translated to the printers
language and sent to it.

You should be sending PS to the "unix printer" - that is normal. One
can set up other virtual printers to accept text or pdf or whatever,
but the norm is PS.

> first, using acroread -toPostScript <filename>, and printing the resultant

Well, that's a strange way to convert PDF to PS, but I suppose it
works! What was wrong with "pdf2ps"? Or how about generating PS in the
first place? What on earth generates pdf?

> ps file. A typical file is taking upto 1 minute to print.

Well, that seems very reasonable to me! Or do you mean a page? Not a
file?

> The problem seems to be that the printer needs (not unreasonably) the whole
> file before it can start to print.

Well it shouldn't. It should print as soon as it reads the "showpage"
command in the PS, at the bottom of each page. If your printer is
waiting for 8 pages to be sent to it before printing one, something is
wrong.

You can test by telnetting directly to it and typing "/showpage" (or
whatever the PS syntax is - I am not going to check). Does it print or
doesn't it?

> A single page pdf which is approx. 120K
> becomes 900K when "ps-ified" - this seems large.

To me not - pdf is only compressed PS. But it IS possible - PS
compresses very well precisely because it is repetitive ascii. I expect
about a 10-1 compression ration with gzip. Gzip compression is
generally a bit better than that silly pdf compression (surprisingly!),
but it is in the ballpark

> The original does have a
> couple of embedded images, but these can't be removed.

Well, that will not slow down the printing. I would blame the kind f PS
you are generating. Fix it.

Peter

Larry T.

unread,
Aug 17, 2004, 10:14:04 AM8/17/04
to
Hi Graham,

I have a different approach that is used by my clients to speed up and
automate the pdf/create/print process but I had a questions for you. What
is the source of the PDF? Are you producing it from some other data,
manually (using ghostscript) or do you require an automated higher volume
process. That's where my OctoTools software ( www.octotools.com) comes in
to play and may be of help. Thanks for your time.

Larry T. (larry"at"jbmsystems"dot"com)

Graham Nicholls

unread,
Aug 17, 2004, 11:14:51 AM8/17/04
to
P.T. Breuer wrote:

> In comp.os.linux.misc Graham Nicholls <gra...@rockcons.co.uk> wrote:
>> Basically printing pdf files to networked HPLJ 4xxx printers is very
>> slow.
>
> Laserjets understand PS - they should be fast as a rocket. In fact they
> are - I have had dozens over the years, and I use them always.
>
>> As the printers don't understand pdf,
>
> ?? DO printers understand pdf nowadays? What a hoot!
>

I've no idea, and don't care - the point being that the printer is expecting
ps. What a larf!

>> I have to convert them to postscript
>
> Well, you don't - PS is the normal printing language in unix. When you
> send anything to a unix "printer" (that's a virtual device), it is
> expected to be already in PS, and it will be translated to the printers
> language and sent to it.

Well, yes I do. How does a pdf file get converted otherwise - magically,
perhaps? Somewhere along the line it is getting converted, unless the
printer does understand pdf - which it doesn't - it just prints the source.
A printer filter is converting to ps to send to the printer. I need to
speed up the process (pstops is quick, but produces a large file, which
takes a long time to be sent to the printer), and reduce the file size.
I wondered if the network was the problem, but using a pair of netcats (one
listening, one sending) I can send the file across our network in sub one
second.

>
> You should be sending PS to the "unix printer" - that is normal. One
> can set up other virtual printers to accept text or pdf or whatever,
> but the norm is PS.
>
>> first, using acroread -toPostScript <filename>, and printing the
>> resultant

It works - whats the problem?


>> Well, that's a strange way to convert PDF to PS, but I suppose it
> works!

pdftops creates a 728k file which is slow to print. The file is a single
page with 2 embedded images.
Another poster (thanks, Bob!) suggested using gs to create the postscript,
which produces a file half the size - which prints in half the time.

I'm intrigued as to why, especially as , as you mention later, pdf is merely
compressed ps, several tools produce different ps output - is it merely the
embedding of fonts - I've tried to prevent this with switches in the
command line, but to no avail in the case of pdftops.

> What was wrong with "pdf2ps"? Or how about generating PS in the
> first place? What on earth generates pdf?

The tools I'm using don't have the option to generate ps directly, but
create pdf, which is a format widely readable, and common on the net. Are
you suggesting that pdf is not a useful file format?

>
>> ps file. A typical file is taking upto 1 minute to print.
>
> Well, that seems very reasonable to me! Or do you mean a page? Not a
> file?

My apologies, of course. I mean a page takes a minute to print - the file
in question is just one page.


>
>> The problem seems to be that the printer needs (not unreasonably) the
>> whole file before it can start to print.

Actually, that seems to be only a part of the problem.


>
> Well it shouldn't. It should print as soon as it reads the "showpage"
> command in the PS, at the bottom of each page. If your printer is
> waiting for 8 pages to be sent to it before printing one, something is
> wrong.
>
> You can test by telnetting directly to it and typing "/showpage" (or
> whatever the PS syntax is - I am not going to check). Does it print or
> doesn't it?
>
>> A single page pdf which is approx. 120K
>> becomes 900K when "ps-ified" - this seems large.
>
> To me not - pdf is only compressed PS. But it IS possible - PS
> compresses very well precisely because it is repetitive ascii. I expect
> about a 10-1 compression ration with gzip. Gzip compression is
> generally a bit better than that silly pdf compression (surprisingly!),
> but it is in the ballpark
>
>> The original does have a
>> couple of embedded images, but these can't be removed.
>
> Well, that will not slow down the printing. I would blame the kind f PS
> you are generating. Fix it.

Well, AFAICS, it is is what is slowing the printing. We are creating pdf
files for viewing, storing & then printing. When it comes to printing, the
file is sent to the spooler, which converts it to ps before sending ps to
the printer. It seems to be the process of sendding to the printer which
is taking the time, as I alluded to in the OP. The file created using gs is
half the size, approximately of the one made by acroread, and prints much
faster. Admittedly, most docs are smaller, and thus much faster, but this
is a problem as there may be many docs of this type.

>

> Peter

Michael Hemmer

unread,
Aug 17, 2004, 11:38:13 AM8/17/04
to
Graham Nicholls wrote:
> I'm intrigued as to why, especially as , as you mention later, pdf is merely
> compressed ps,

It isn't. PostScript is a complete programming language (albeit with a
clear focus on output functions) and offers conditionals, loops and
what-have-you, while PDF does not. (This has been discussed here and in
comp.lang.postscript on several occasions in the past, so Google is
bound to find you some more elaborate discussion of this issue than I am
able to provide.)

Michael

Jorma Heimonen

unread,
Aug 17, 2004, 11:45:36 AM8/17/04
to
Graham Nicholls wrote:
> My apologies, of course. I mean a page takes a minute to print - the file
> in question is just one page.

If the file has complex images it may take a long time to print in
a PS printer.

On the other hand, I have been using
acroread, gs and the pdftops of xpdf to convert PDF files
of various sizes and complexity to PS under Linux.
They usually print out at about the printer's engine speed
(~20 pages / minute) on a LaserJet 8000. The printer is
connected via its internal LAN connection to a 100MB ethernet.
And the file sizes are large, the PDF's are from 1 MB to
15 MB and the corresponding PS's from 10 to 150 MB.

So, either your files are very complex and difficult and
rendering them takes a long time or you have a massive network
problem somewhere.

Jorma

Graham Nicholls

unread,
Aug 17, 2004, 12:23:25 PM8/17/04
to
Jorma Heimonen wrote:

As I mentioned, the network is not the problem - using netcat the file takes
1 second to traverse the net. Interestingly, it takes 25-30 seconds to get
to the printer. How can I tell how complex the file is? Is PS a por
format for inclding images (I assumed they were handled as a bitmap)?
Graham
> Jorma

Ross Presser

unread,
Aug 17, 2004, 2:35:30 PM8/17/04
to

There are many issues that can be raised regarding PS and images.
Sidestepping them for a moment ... is it possible that your images in the
PDF are very high resolution (say, 600dpi, or perhaps even higher), and
that when acroread or ps2pdf convert the pdf to PS, it uses full
resolution, but when ghostscript did it it assumed a much lower resolution?

If you could be permitted to post a sample PDF on a web site somwhere, it
might help people analyze the problem. Of course it's totally
understandable if you cannot do that because of privacy concerns.

Michael Sweet

unread,
Aug 17, 2004, 6:33:36 PM8/17/04
to
Graham Nicholls wrote:
> My sig is unfortunate, as the client keeps throwing it back in my
> face, so I might have to change it to "The answers No, bugger off!",
> unless I can fix this.
>
> Basically printing pdf files to networked HPLJ 4xxx printers is very
> slow. As the printers don't understand pdf, I have to convert them to
> postscript first, using acroread -toPostScript <filename>, and
> printing the resultant ps file. A typical file is taking upto 1
> minute to print.
> ...

IIRC, SuSE 7.2 has CUPS, so setup your LaserJet printers through it
and print the PDF file directly (CUPS will convert to PS/PCL as
needed) Depending on the age of the printers, you might want to
use the PCL driver since older HP printers have slow processors and
even slower interfaces.

--
______________________________________________________________________
Michael Sweet, Easy Software Products mike at easysw dot com
Printing Software for UNIX http://www.easysw.com

Graham Nicholls

unread,
Aug 18, 2004, 4:11:31 AM8/18/04
to
Michael Sweet wrote:

> Graham Nicholls wrote:
>> My sig is unfortunate, as the client keeps throwing it back in my
>> face, so I might have to change it to "The answers No, bugger off!",
>> unless I can fix this.
>>
>> Basically printing pdf files to networked HPLJ 4xxx printers is very
>> slow. As the printers don't understand pdf, I have to convert them to
>> postscript first, using acroread -toPostScript <filename>, and
>> printing the resultant ps file. A typical file is taking upto 1
>> minute to print.
>> ...
>
> IIRC, SuSE 7.2 has CUPS, so setup your LaserJet printers through it
> and print the PDF file directly (CUPS will convert to PS/PCL as
> needed) Depending on the age of the printers, you might want to
> use the PCL driver since older HP printers have slow processors and
> even slower interfaces.
>

I'm using lprNG (I don't much like CUPS, to be honest). I will switch to
CUPS to take a look, but of course, all its doing is converting the pdf to
PS and sending that - all of which I'm doing anyway. I can't see it making
any difference, unless the method of communicating with the printer is
different.

Graham

Graham Nicholls

unread,
Aug 18, 2004, 4:31:07 AM8/18/04
to
Ross Presser wrote:

I've got permission from the client and uploaded the page in question to my
own site - it is availabel here:

http://www.rockcons.co.uk/down_list.php?path=pub/pdf&ftproot=pub

The other file is a ps file generated by pdf2ps. I'll take a look at the
image sizes, but I still reckon the problem is something to do with the
printer - it takes ages to receive the file using: netcat printer 9100 <
file
Netcat takes 25 seconds or so to send to th printer, but running 2 netcats
across the same network, admittedly to a different host, the file transfers
in about a second. I've checked the ports on the printer & sending machine,
but both are running at 100Mbit/sec & full duplex.

Graham

George N. White III

unread,
Aug 18, 2004, 8:32:48 AM8/18/04
to

As others pointed out, you should look at the PS code being generated, but
I doubt you will be able to match the performance of Win32, where acroread
interprets the PDF code without the overhead of loading ghostscript. To
make a fair comparison, some of the money saved by using linux should be
put towards newer printers.

There are 3 commonly used tools to convert PDF to PS or PCL on linux:

Adobe "acroread -toPostScript", ghostscript, and pdftops (from
foolabs' xpdf).

Acroread has a number of options to control the generated PS (-fast,
-binary, -level?, -printerhalftones, etc). Have you tried palying with
these? The other programs offer similar flexibility. Ghostscript is
overkill, and xpdf is actively being maintained, so I'd try pdftops next,
but it sounds like you need to upgrade your hardware.

--
George N. White III <aa...@chebucto.ns.ca>
Head of St. Margarets Bay, Nova Scotia, Canada

Michael Sweet

unread,
Aug 18, 2004, 8:34:47 AM8/18/04
to
Graham Nicholls wrote:
> ...

> I'm using lprNG (I don't much like CUPS, to be honest). I will
> switch to CUPS to take a look, but of course, all its doing is
> converting the pdf to PS and sending that - all of which I'm doing

The whole point of CUPS is that you get a real printer driver and
not a mess of filters to manage.

In any case, you have the choice of using a PPD that sends PS or a
PPD that sends PCL to the printer, which might make all of the
difference.

What model printer are you printing to?

Ross Presser

unread,
Aug 18, 2004, 11:51:53 AM8/18/04
to

I inspected your pdf file. The logo at the upper left is composed of
hundreds of individual small horizontal strips. This makes for very
"complex" postscript which takes the printer a long time to render. If you
could rebuild this logo as a single bitmap and have the source application
insert it into the generated pdf as such, I believe it would speed
rendering greatly.

Graham Nicholls

unread,
Aug 18, 2004, 2:20:16 PM8/18/04
to
George N. White III wrote:

>
> There are 3 commonly used tools to convert PDF to PS or PCL on linux:
>
> Adobe "acroread -toPostScript", ghostscript, and pdftops (from
> foolabs' xpdf).
>
> Acroread has a number of options to control the generated PS (-fast,
> -binary, -level?, -printerhalftones, etc). Have you tried palying with
> these?

DIdn't make any difference, but we may have an old version . Someone here
disparaged my choice of acroread, so I tried pdftops ( and pdf2ps)

> The other programs offer similar flexibility. Ghostscript is
> overkill, and xpdf is actively being maintained, so I'd try pdftops next,
> but it sounds like you need to upgrade your hardware.

The time to print was NOT caused by the time to generate ps. I did this
then printed the resultant file- using netcat or np (a program I wrote to
send to a port) the 900k file took 25 seconds to get to a HP400 OR an HP
4300. Both of these are relatively new printers running at 100Mbits/sec
full duplex. I'm mystified as to why that should take so long - is the
printer processing data before allowing any more to be sent? In which case
I'd expect the 4300 to be significantly faster, but it isn't.

Ah well. CUPS is now working, but I'm a bit uneasy about not understanding
the complete CUPS system - I'll have to study it.
>
Graham Nicholls

Graham Nicholls

unread,
Aug 18, 2004, 2:22:41 PM8/18/04
to
Ross Presser wrote:


>
> I inspected your pdf file. The logo at the upper left is composed of
> hundreds of individual small horizontal strips. This makes for very
> "complex" postscript which takes the printer a long time to render. If you
> could rebuild this logo as a single bitmap and have the source application
> insert it into the generated pdf as such, I believe it would speed
> rendering greatly.

Thanks. I had a look, too and came to the same conclusion, but still
couldn't see why
A) Windows was so much faster
B) Simply sending the file took so long.

To A I'd suggest that windows maybe renders pdf to pcl in the printer
driver? On the question of B, I'd guess that the printer is _processing_ as
it goes, not allowing more data till its good and ready, but who knows

Thanks again

Charlie

unread,
Aug 28, 2004, 7:40:28 PM8/28/04
to
"Graham Nicholls" <gra...@rockcons.co.uk> wrote in message
news:41220129$0$7917$afc3...@auth.uk.news.easynet.net...

> My sig is unfortunate, as the client keeps throwing it back in my face, so
> I
> might have to change it to "The answers No, bugger off!", unless I can fix
> this.

Actually, my Red Hat Linux 8 machine has suddenly said to me "No, I'm not
going to let you, Root, or any other account log on to me." and then "No,
I'm still not going to let you log on even though you have correctly used
the passwd root command to fix the problem." To which I replied "OK, I'm
going to wipe you out and use the disk space to install Windows 2000
Server".
Before I start getting flogged as a clueless MS apologist, let me say that I
do have Linux still installed on a different box and it is not giving me
much trouble. I will soon install it on a second one as well. :)

0 new messages