Placing graphics & text on printed page - jan06call.jpg (0/1)
paul at boddie.org.uk
Fri Jan 13 02:18:16 CET 2006
Steve Holden wrote:
> Michael Galvin wrote:
> > To see an example of what I am trying to accomplish, look at this page
> > on my personal website:
> > http://mysite.verizon.net/michaelgalvin/jan06call.html
> > I now realize my attachement could not be posted on this usenet group.
> I suspect your best option would be to use ReportLab's open source
> package (www.reportlab.org) to generate PDF files.
One alternative, although I'm not convinced that it is actively
maintained any more, is the Piddle/Sping library . As mentioned
elsewhere, the Cairo bindings would provide a similar developer
experience to that, and Cairo is increasingly fashionable.
> You may, however, be able to get at the Windows device context through
> wxPython (www.wxpython.org): if you download the demonstration you'll
> see that on Windows they do send fairly arbitrary graphics to the
> Windows printer queue.
PyQt  seems to support printing fairly conveniently. Consider this
very simple example:
from qt import *
qapp = QApplication(sys.argv)
printer = QPrinter(QPrinter.PrinterResolution)
painter = QPainter(printer)
painter.drawText(painter.window(), painter.AlignCenter, "Hello")
I haven't used printing in Qt  before, so apologies must go out if
I've made fundamental mistakes in the above code which did, admittedly,
produce output that resembled my expectations. Another route might be
to use a Tkinter canvas - at least in times of old, such canvases were
able to dump their contents as PostScript.
More information about the Python-list