[PyQt] Re: Thermal Printer on QPrinter

Eduardo Willians edujurista at gmail.com
Wed Jan 21 20:51:41 GMT 2009


> Perhaps Eric4 just sends characters to a printer, as someone suggested for a
> solution to your problem. This might be one way to achieve what you want,
> though you miss out on the abstraction provided by Qt if you do this.
>
> I experimented a little with printing to custom paper sizes, modifying your
> original code to create a PDF file (using Qt 4.4 because that provides the
> setPaperSize() method that we need):
>
> from PyQt4.QtCore import QSizeF
> from PyQt4.QtGui import *
> import sys
> app = QApplication(sys.argv)
> printer=QPrinter()
> printer.setFullPage(True)
> printer.setPaperSource(printer.Auto)
> doc=QTextDocument("Hello World!")
> printer.setOutputFormat(printer.PdfFormat)
> printer.setOutputFileName("temp000.pdf")
> printer.setPaperSize(QSizeF(72, 144), printer.Millimeter)
> doc.print_(printer)
>
> This could be used as the basis for what you need if, after removing the
> setOutputFormat() and setOutputFileName() calls, it actually sends correct
> output to the printer. Of course, there's the issue of the automatic page
> numbering, but that's another issue...

Thank you very much, David. I''l try this.

Eduardo Willians


More information about the PyQt mailing list