[PyKDE] Printing (General)

Jim Bublitz jbublitz at nwinternet.com
Tue Mar 11 21:18:01 GMT 2003


On 11-Mar-03 Ken Godee wrote:
> Nope, QPrinter allows you to set many functions of your
> device, including resolution, but won't do any layout stuff.
> Yes you can layout using Designer, then pyuic, then create
> an instance of that object in your app and grabwidget with 
> QPainter but the problem is it's only at screen resolution 
> ie. 81dpi. If you then set your QPrint device to 600dpi your
> image will print out aprx. 1/8 scale. If you try to scale up to
> 600dpi, that won't work either, it will be bigger(full scale),
> but image will still be at 81dpi. Either way destroys even
> normal size fonts, QPainter grabwidget converts widget to a
> pixmap and hands off to QPrinter which paints to your device (or
> something like that).

> I would like to print directly to the printer and not to a PDF.
> I don't really care if it's easy or not, I just want it handle
> images/fonts/lines correctly and print out at a decent
> resolution.
 
> Here's some of the following I've looked at.....
 
> Kuger (Qt based,shows promise, no images though)
> ReKall (Qt/python based, shows promise)
> DataVision (Java Based shows promise)
> JFreeReport
> ReportLab
> JReport
> GRG
> ReportManager
> Latex
> and many more.....
 
> When I started down this road I didn't think I'd have to 
> reinvent the wheel. I still can't believe I'm just not missing 
> something? So far if possible the best combo I can see is to
> try to extend python with Java (pyJava?) a couple of
> the programs out there come with complete Java Librarys
> for report generating/design with complete font scaling and
> image handling, headers, grouping, etc. But I really wanted
> to stay in the Qt camp.

As far as report generation/layout - I agree there isn't a good
general purpose solution that I'm aware of (good project
possibility for someone who's interested).

As far a QPrinter - I went back and looked at my code. I haven't
worked on this for about a year and the project wasn't completed.
Apparently I did the layout using ReportLab/platypus and somehow
(can't find the piece of code that did it) got the PDF output into
a widget (pixmap?) which I just passed into QPrinter (scaled by (.8,
.8) for some reason). I'm not sure how I did the PDF->widget stuff.
I was using the KDE PDF viewer (as a KPart) for previewing, but I
don't think that's how it was done. At any rate, I didn't have any
trouble getting good quality output from QPrinter. There were only
5 or 6 lines of actual QPrinter code - I'd forgotten that I even
used it. All of the PDF layout was in inches.

KDE (kdeprint in kdelibs) basically uses an extended QPrinter
(KPrinter) for printing - you might look at the kdeprint code or
the code for apps like KWrite or KWord and see how they do it.
There is a kdeprint module for PyKDE, but I haven't done much with
it - no examples yet.

I wish I could be more helpful, but I haven't looked at the subject
for quite a while and can't do the digging at the moment. I'm still
using a pretty kludgy system for forms printing myself.


Jim




More information about the PyQt mailing list