PDA

View Full Version : Qt4 poor printing performance



seneca
21st January 2009, 10:38
In my report designer I am printing about 200 items by QGraphicsScene::render to the QPainter associated to a QPrinter, and the output creates 2 pages. The painting/rendering performance is poor and very dependant of the printer type and the resolution selected in the printer settings. Previewing the same data on the screen renders in estimated 0.1 seconds just to have an idea.

For example when printing to a OfficeJet G85 color inkjet at normal print quality, the rendering takes about 2 or 3 seconds. When printing to a Brother 2035 laser at normal quality with 300 DPI, the rendering takes about 20 seconds, alas even about 10 times what the inkjet needs for comparable quality. Selecting high quality 600DPI on the laser will make the rendering process use more that one minute, which is inacceptable for production use, don't even think about real lists with hundrets of pages that way.

(Crystal reports to compare would render such data in subseconds on the same printers in high resolution!)

Both printers are attached to another PC in the LAN by USB, and made available as network share. During the rendering time CPU usage is quite low, hardly above the idle load. There is also no noticeable disk activity during this time.

Has anybody also seen such drastic printer dependent performance issues on different print devices?

What could be done to improve performance, should I first render everything on a pixmap and then send the page as pixmap to the printer, would that make a difference?

caduel
21st January 2009, 10:48
Just an idea: can you print to a file instead to the printer and examine that data that the printer should print?
(It could be, for example, that CR sends postscript commands and Qt an pixel-based image. In that case the data volume to transmitted for Qt would be bigger.)
Maybe you will gain other insights that way.
Let us know if you could find something out that way.

HTH

seneca
21st January 2009, 11:42
The file created for brother it total 30 kilobytes, whereas most is an embedded picture and the rest is some brother specific printer language:


<esc>%-12345X@PJL
@PJL SET REPRINT=JOB
@PJL SET HOLD=OFF
@PJL JOB NAME="Report List"
@PJL PRINTLOG ITEM = 1,PRINTER
@PJL PRINTLOG ITEM = 2,Wed,21 Jan 2009 12:35:41
@PJL PRINTLOG ITEM = 3,kochp
@PJL PRINTLOG ITEM = 4,SPEEDY
@PJL SET ECONOMODE=OFF
@PJL SET MEDIATYPE=REGULAR
@PJL SET LANG=GERMAN
@PJL SET RESOLUTION=300
@PJL ENTER LANGUAGE=PCL
<some embedded binary data here>
%-12345X@PJL EOJ NAME="Report List"
<esc>%-12345X
<eof>

Rendering takes about half time as when really printing, still about 10 seconds. Wonder what Qt is doing or waiting for all that time. I'll try to track it down with the debugger.

seneca
21st January 2009, 20:02
I was able to make a workaround now which will reduce printing time to a fair amount. For example directly printing the document will use 75 seconds (!) at 600DPI on the brother.

Instead I workaround now as:


Get share name of the printer.
If no share name found (local printer), print normal.
For shared printer, print to file. Then copy the file to the printer share name.


This way the printing lasts about 6 seconds for the network printer.

Ugly workaround, but at least a temporary solution until Qt gets a better printer interface.

seneca
22nd January 2009, 14:23
Wow.

Today I thought I give postscript a try to further improve things, e.g. create a postscript file by QPrinter and the send that file to the printer via ghostscript. Well that was the plan at least. The idea was that postscript seemed to be the "native" printer output for Qt, and thus rendering a QGraphicsScene should be very fast because it could draw everything with postscript pimitives, right?

Wrong. Completely wrong.

The printing lasts even much longer than with the windows printing engine, and postscript file Qt creates is whopping 295 Megabytes. Yes, right read fellow, 295 Megabyte for two pages of A4.

I don't get it that Qt has such a broken printing system when it comes to graphics.

The only good news I have is that theoretically it would be possible to print performant with Qt, if the painting engines would get reworked. The PDF printer engine demonstrates this by printing that very graphics scenes in no time and making only a 40 Kilobyte file out of it.

(Unfortunately the pdf engine is not yet complete, it does not print simple lines at all, and also not rectangles with certain linewidths.)

My conclusion is that the whole printing stuff is stuck somewhere between alpha and beta when it comes to the graphics framework of Qt4.