Skip to content

PythonQt.Qt.QPrinter

QPrinter

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

This device represents a series of pages of printed output, and is used in almost exactly the same way as other paint devices such as QWidget and QPixmap. A set of additional functions are provided to manage device-specific features, such as orientation and resolution, and to step through the pages in a document as it is generated.

When printing directly to a printer on Windows or macOS, QPrinter uses the built-in printer drivers. On X11, QPrinter uses the Common Unix Printing System (CUPS) to send PDF output to the printer. As an alternative, the printProgram() function can be used to specify the command or utility to use instead of the system default.

Note that setting parameters like paper size and resolution on an invalid printer is undefined. You can use QPrinter::isValid() to verify this before changing any parameters.

QPrinter supports a number of parameters, most of which can be changed by the end user through a print dialog. In general, QPrinter passes these functions onto the underlying QPrintEngine.

The most important parameters are:

  • setOrientation() tells QPrinter which page orientation to use.
  • setPaperSize() tells QPrinter what paper size to expect from the printer.
  • setResolution() tells QPrinter what resolution you wish the printer to provide, in dots per inch (DPI).
  • setFullPage() tells QPrinter whether you want to deal with the full page or just with the part the printer can draw on.
  • setCopyCount() tells QPrinter how many copies of the document it should print.

Many of these functions can only be called before the actual printing begins (i.e., before QPainter::begin() is called). This usually makes sense because, for example, it's not possible to change the number of copies when you are halfway through printing. There are also some settings that the user sets (through the printer dialog) and that applications are expected to obey. See QAbstractPrintDialog's documentation for more details.

When QPainter::begin() is called, the QPrinter it operates on is prepared for a new page, enabling the QPainter to be used immediately to paint the first page in a document. Once the first page has been painted, newPage() can be called to request a new blank page to paint on, or QPainter::end() can be called to finish printing. The second page and all following pages are prepared using a call to newPage() before they are painted.

The first page in a document does not need to be preceded by a call to newPage(). You only need to calling newPage() after QPainter::begin() if you need to insert a blank page at the beginning of a printed document. Similarly, calling newPage() after the last page in a document is painted will result in a trailing blank page appended to the end of the printed document.

If you want to abort the print job, abort() will try its best to stop printing. It may cancel the entire job or just part of it.

Since QPrinter can print to any QPrintEngine subclass, it is possible to extend printing support to cover new types of printing subsystem by subclassing QPrintEngine and reimplementing its interface.

Source: https://doc.qt.io/archives/qt-5.15/qprinter.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
A0 attribute Any (shared captured text)
A1 attribute Any (shared captured text)
A10 attribute Any (shared captured text)
A2 attribute Any (shared captured text)
A3 attribute Any (shared captured text)
A3Extra attribute Any (shared captured text)
A4 attribute Any (shared captured text)
A4Extra attribute Any (shared captured text)
A4Plus attribute Any (shared captured text)
A4Small attribute Any (shared captured text)
A5 attribute Any (shared captured text)
A5Extra attribute Any (shared captured text)
A6 attribute Any (shared captured text)
A7 attribute Any (shared captured text)
A8 attribute Any (shared captured text)
A9 attribute Any (shared captured text)
Aborted attribute Any (shared captured text)
Active attribute Any (shared captured text)
AllPages attribute Any (shared captured text)
AnsiA attribute Any (shared captured text)
AnsiB attribute Any (shared captured text)
AnsiC attribute Any (shared captured text)
AnsiD attribute Any (shared captured text)
AnsiE attribute Any (shared captured text)
ArchA attribute Any (shared captured text)
ArchB attribute Any (shared captured text)
ArchC attribute Any (shared captured text)
ArchD attribute Any (shared captured text)
ArchE attribute Any (shared captured text)
Auto attribute Any (shared captured text)
B0 attribute Any (shared captured text)
B1 attribute Any (shared captured text)
B10 attribute Any (shared captured text)
B2 attribute Any (shared captured text)
B3 attribute Any (shared captured text)
B4 attribute Any (shared captured text)
B5 attribute Any (shared captured text)
B5Extra attribute Any (shared captured text)
B6 attribute Any (shared captured text)
B7 attribute Any (shared captured text)
B8 attribute Any (shared captured text)
B9 attribute Any (shared captured text)
C5E attribute Any (shared captured text)
Cassette attribute Any (shared captured text)
Cicero attribute Any (shared captured text)
Color attribute Any (shared captured text)
ColorMode attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
Comm10E attribute Any (shared captured text)
CurrentPage attribute Any (shared captured text)
Custom attribute Any (shared captured text)
CustomSource attribute Any (shared captured text)
DLE attribute Any (shared captured text)
DevicePixel attribute Any (shared captured text)
Didot attribute Any (shared captured text)
DoublePostcard attribute Any (shared captured text)
DuplexAuto attribute Any (shared captured text)
DuplexLongSide attribute Any (shared captured text)
DuplexMode attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
DuplexNone attribute Any (shared captured text)
DuplexShortSide attribute Any (shared captured text)
Envelope attribute Any (shared captured text)
Envelope10 attribute Any (shared captured text)
Envelope11 attribute Any (shared captured text)
Envelope12 attribute Any (shared captured text)
Envelope14 attribute Any (shared captured text)
Envelope9 attribute Any (shared captured text)
EnvelopeB4 attribute Any (shared captured text)
EnvelopeB5 attribute Any (shared captured text)
EnvelopeB6 attribute Any (shared captured text)
EnvelopeC0 attribute Any (shared captured text)
EnvelopeC1 attribute Any (shared captured text)
EnvelopeC2 attribute Any (shared captured text)
EnvelopeC3 attribute Any (shared captured text)
EnvelopeC4 attribute Any (shared captured text)
EnvelopeC5 attribute Any (shared captured text)
EnvelopeC6 attribute Any (shared captured text)
EnvelopeC65 attribute Any (shared captured text)
EnvelopeC7 attribute Any (shared captured text)
EnvelopeChou3 attribute Any (shared captured text)
EnvelopeChou4 attribute Any (shared captured text)
EnvelopeDL attribute Any (shared captured text)
EnvelopeInvite attribute Any (shared captured text)
EnvelopeItalian attribute Any (shared captured text)
EnvelopeKaku2 attribute Any (shared captured text)
EnvelopeKaku3 attribute Any (shared captured text)
EnvelopeManual attribute Any (shared captured text)
EnvelopeMonarch attribute Any (shared captured text)
EnvelopePersonal attribute Any (shared captured text)
EnvelopePrc1 attribute Any (shared captured text)
EnvelopePrc10 attribute Any (shared captured text)
EnvelopePrc2 attribute Any (shared captured text)
EnvelopePrc3 attribute Any (shared captured text)
EnvelopePrc4 attribute Any (shared captured text)
EnvelopePrc5 attribute Any (shared captured text)
EnvelopePrc6 attribute Any (shared captured text)
EnvelopePrc7 attribute Any (shared captured text)
EnvelopePrc8 attribute Any (shared captured text)
EnvelopePrc9 attribute Any (shared captured text)
EnvelopeYou4 attribute Any (shared captured text)
Error attribute Any (shared captured text)
Executive attribute Any (shared captured text)
ExecutiveStandard attribute Any (shared captured text)
FanFoldGerman attribute Any (shared captured text)
FanFoldGermanLegal attribute Any (shared captured text)
FanFoldUS attribute Any (shared captured text)
FirstPageFirst attribute Any (shared captured text)
Folio attribute Any (shared captured text)
FormSource attribute Any (shared captured text)
GrayScale attribute Any (shared captured text)
HighResolution attribute Any (shared captured text)
Idle attribute Any (shared captured text)
Imperial10x11 attribute Any (shared captured text)
Imperial10x13 attribute Any (shared captured text)
Imperial10x14 attribute Any (shared captured text)
Imperial12x11 attribute Any (shared captured text)
Imperial15x11 attribute Any (shared captured text)
Imperial7x9 attribute Any (shared captured text)
Imperial8x10 attribute Any (shared captured text)
Imperial9x11 attribute Any (shared captured text)
Imperial9x12 attribute Any (shared captured text)
Inch attribute Any (shared captured text)
JisB0 attribute Any (shared captured text)
JisB1 attribute Any (shared captured text)
JisB10 attribute Any (shared captured text)
JisB2 attribute Any (shared captured text)
JisB3 attribute Any (shared captured text)
JisB4 attribute Any (shared captured text)
JisB5 attribute Any (shared captured text)
JisB6 attribute Any (shared captured text)
JisB7 attribute Any (shared captured text)
JisB8 attribute Any (shared captured text)
JisB9 attribute Any (shared captured text)
Landscape attribute Any (shared captured text)
LargeCapacity attribute Any (shared captured text)
LargeFormat attribute Any (shared captured text)
LastPageFirst attribute Any (shared captured text)
LastPageSize attribute Any (shared captured text)
LastPaperSource attribute Any (shared captured text)
Ledger attribute Any (shared captured text)
Legal attribute Any (shared captured text)
LegalExtra attribute Any (shared captured text)
Letter attribute Any (shared captured text)
LetterExtra attribute Any (shared captured text)
LetterPlus attribute Any (shared captured text)
LetterSmall attribute Any (shared captured text)
Lower attribute Any (shared captured text)
Manual attribute Any (shared captured text)
MaxPageSource attribute Any (shared captured text)
Middle attribute Any (shared captured text)
Millimeter attribute Any (shared captured text)
NPageSize attribute Any (shared captured text)
NPaperSize attribute Any (shared captured text)
NativeFormat attribute Any (shared captured text)
Note attribute Any (shared captured text)
OnlyOne attribute Any (shared captured text)
Orientation attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
OutputFormat attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
PageOrder attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
PageRange attribute Any (shared captured text)
PageSize attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
PaintDeviceMetric attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
PaperSource attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
PdfFormat attribute Any (shared captured text)
PdmDepth attribute Any (shared captured text)
PdmDevicePixelRatio attribute Any (shared captured text)
PdmDevicePixelRatioScaled attribute Any (shared captured text)
PdmDpiX attribute Any (shared captured text)
PdmDpiY attribute Any (shared captured text)
PdmHeight attribute Any (shared captured text)
PdmHeightMM attribute Any (shared captured text)
PdmNumColors attribute Any (shared captured text)
PdmPhysicalDpiX attribute Any (shared captured text)
PdmPhysicalDpiY attribute Any (shared captured text)
PdmWidth attribute Any (shared captured text)
PdmWidthMM attribute Any (shared captured text)
Pica attribute Any (shared captured text)
Point attribute Any (shared captured text)
Portrait attribute Any (shared captured text)
Postcard attribute Any (shared captured text)
Prc16K attribute Any (shared captured text)
Prc32K attribute Any (shared captured text)
Prc32KBig attribute Any (shared captured text)
PrintRange attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
PrinterMode attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
PrinterResolution attribute Any (shared captured text)
PrinterState attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
Quarto attribute Any (shared captured text)
ScreenResolution attribute Any (shared captured text)
Selection attribute Any (shared captured text)
SmallFormat attribute Any (shared captured text)
Statement attribute Any (shared captured text)
SuperA attribute Any (shared captured text)
SuperB attribute Any (shared captured text)
Tabloid attribute Any (shared captured text)
TabloidExtra attribute Any (shared captured text)
Tractor attribute Any (shared captured text)
Unit attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
Upper attribute Any (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
abort function (self) -> bool X.abort() -> bool (shared captured text)
actualNumCopies function (self) -> int X.actualNumCopies() -> int (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
collateCopies function (self) -> bool X.collateCopies() -> bool (shared captured text)
colorCount function (self) -> int X.colorCount() -> int (shared captured text)
colorMode function (self) -> Any Returns the current color mode. (shared captured text)
copyCount function (self) -> int X.copyCount() -> int (shared captured text)
creator function (self) -> str X.creator() -> str (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
depth function (self) -> int X.depth() -> int (shared captured text)
devType function (self) -> int X.devType() -> int (shared captured text)
devicePageLayout function (self) -> Any X.devicePageLayout() -> PythonQt.QtGui.QPageLayout (shared captured text)
devicePixelRatio function (self) -> int X.devicePixelRatio() -> int (shared captured text)
devicePixelRatioF function (self) -> float X.devicePixelRatioF() -> float (shared captured text)
devicePixelRatioFScale function (self) -> float X.devicePixelRatioFScale() -> float (shared captured text)
docName function (self) -> str X.docName() -> str (shared captured text)
doubleSidedPrinting function (self) -> bool X.doubleSidedPrinting() -> bool (shared captured text)
duplex function (self) -> Any Returns the current duplex mode. (shared captured text)
fontEmbeddingEnabled function (self) -> bool X.fontEmbeddingEnabled() -> bool (shared captured text)
fromPage function (self) -> int X.fromPage() -> int (shared captured text)
fullPage function (self) -> bool X.fullPage() -> bool (shared captured text)
getPageMargins function (self, left: Any, top: Any, right: Any, bottom: Any, unit: Any) -> Any X.getPageMargins(left, top, right, bottom, unit) (shared captured text)
height function (self) -> int X.height() -> int (shared captured text)
heightMM function (self) -> int X.heightMM() -> int (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
initPainter function (self, painter: Any) -> Any (shared captured text)
isValid function (self) -> bool X.isValid() -> bool (shared captured text)
logicalDpiX function (self) -> int X.logicalDpiX() -> int (shared captured text)
logicalDpiY function (self) -> int X.logicalDpiY() -> int (shared captured text)
margins function (self) -> Any X.margins() -> PythonQt.QtGui.QPagedPaintDevice::Margins (shared captured text)
metric function (self, arg__1: Any) -> int X.metric(arg__1) -> int (shared captured text)
newPage function (self) -> bool X.newPage() -> bool (shared captured text)
numCopies function (self) -> int X.numCopies() -> int (shared captured text)
orientation function (self) -> Any (shared captured text)
outputFileName function (self) -> str X.outputFileName() -> str (shared captured text)
outputFormat function (self) -> Any Returns the output format for this printer. (shared captured text)
pageLayout function (self) -> Any X.pageLayout() -> PythonQt.QtGui.QPageLayout (shared captured text)
pageOrder function (self) -> Any Returns the current page order. (shared captured text)
pageRect function (self, arg__1: Any) -> Any X.pageRect(arg__1) -> PythonQt.QtCore.QRect (shared captured text)
pageSize function (self) -> Any (shared captured text)
pageSizeMM function (self) -> Any X.pageSizeMM() -> PythonQt.QtCore.QSizeF (shared captured text)
paintEngine function (self) -> Any X.paintEngine() -> PythonQt.QtGui.QPaintEngine (shared captured text)
paintingActive function (self) -> bool X.paintingActive() -> bool (shared captured text)
paperName function (self) -> str X.paperName() -> str (shared captured text)
paperRect function (self, arg__1: Any) -> Any X.paperRect(arg__1) -> PythonQt.QtCore.QRect (shared captured text)
paperSize function (self, unit: Any) -> Any (shared captured text)
paperSource function (self) -> Any Returns the printer's paper source. (shared captured text)
physicalDpiX function (self) -> int X.physicalDpiX() -> int (shared captured text)
physicalDpiY function (self) -> int X.physicalDpiY() -> int (shared captured text)
printEngine function (self) -> Any X.printEngine() -> PythonQt.QtGui.QPrintEngine (shared captured text)
printProgram function (self) -> str X.printProgram() -> str (shared captured text)
printRange function (self) -> Any Returns the page range of the [QPrinter](https://doc.qt.io/archives/qt-5.15/qprinter.html). (shared captured text)
printerName function (self) -> str X.printerName() -> str (shared captured text)
printerState function (self) -> Any Returns the current state of the printer. (shared captured text)
redirected function (self, offset: Any) -> Any X.redirected(offset) -> PythonQt.QtGui.QPaintDevice (shared captured text)
resolution function (self) -> int X.resolution() -> int (shared captured text)
setCollateCopies function (self, collate: bool) -> None Sets the default value for collation checkbox when the print dialog appears. (shared captured text)
setColorMode function (self, arg__1: Any) -> None Sets the printer's color mode to newColorMode, which can be either Color or GrayScale. (shared captured text)
setCopyCount function (self, arg__1: int) -> None Sets the number of copies to be printed to count. (shared captured text)
setCreator function (self, arg__1: str) -> None Sets the name of the application that created the document to creator. (shared captured text)
setDocName function (self, arg__1: str) -> None Sets the document name to name. (shared captured text)
setDoubleSidedPrinting function (self, enable: bool) -> None (shared captured text)
setDuplex function (self, duplex: Any) -> None Enables double sided printing based on the duplex mode. (shared captured text)
setEngines function (self, printEngine: Any, paintEngine: Any) -> None X.setEngines(printEngine, paintEngine) (shared captured text)
setFontEmbeddingEnabled function (self, enable: bool) -> None Enabled or disables font embedding depending on enable. (shared captured text)
setFromTo function (self, fromPage: int, toPage: int) -> None X.setFromTo(fromPage, toPage) (shared captured text)
setFullPage function (self, arg__1: bool) -> None If fp is true, enables support for painting over the entire page; otherwise restricts painting to the printable area reported by the device. (shared captured text)
setMargins function (self, m: Any) -> None (shared captured text)
setNumCopies function (self, arg__1: int) -> None (shared captured text)
setOrientation function (self, arg__1: Any) -> None (shared captured text)
setOutputFileName function (self, arg__1: str) -> None Sets the name of the output file to fileName. (shared captured text)
setOutputFormat function (self, format: Any) -> None Sets the output format for this printer to format. (shared captured text)
setPageLayout function (self, pageLayout: Any) -> bool X.setPageLayout(pageLayout) -> bool (shared captured text)
setPageMargins function (self, left: Any, top: Any, right: Any, bottom: Any, unit: Any) -> Any X.setPageMargins(left, top, right, bottom, unit) (shared captured text)
setPageOrder function (self, arg__1: Any) -> None Sets the page order to pageOrder. (shared captured text)
setPageOrientation function (self, orientation: Any) -> bool X.setPageOrientation(orientation) -> bool (shared captured text)
setPageSize function (self, arg__1: Any) -> Any Sets the page size to pageSize. (shared captured text)
setPageSizeMM function (self, size: Any) -> None (shared captured text)
setPaperName function (self, paperName: str) -> None (shared captured text)
setPaperSize function (self, paperSize: Any, unit: Any) -> None X.setPaperSize(paperSize, unit) (shared captured text)
setPaperSource function (self, arg__1: Any) -> None Sets the paper source setting to source. (shared captured text)
setPrintProgram function (self, arg__1: str) -> None Sets the name of the program that should do the print job to printProg. (shared captured text)
setPrintRange function (self, range: Any) -> None Sets the print range option in to be range. (shared captured text)
setPrinterName function (self, arg__1: str) -> None Sets the printer name to name. (shared captured text)
setResolution function (self, arg__1: int) -> None Requests that the printer prints at dpi or as near to dpi as possible. (shared captured text)
setWinPageSize function (self, winPageSize: int) -> None (shared captured text)
sharedPainter function (self) -> Any X.sharedPainter() -> PythonQt.QtGui.QPainter (shared captured text)
supportedResolutions function (self) -> tuple X.supportedResolutions() -> tuple (shared captured text)
supportsMultipleCopies function (self) -> bool X.supportsMultipleCopies() -> bool (shared captured text)
toPage function (self) -> int X.toPage() -> int (shared captured text)
width function (self) -> int X.width() -> int (shared captured text)
widthMM function (self) -> int X.widthMM() -> int (shared captured text)
winPageSize function (self) -> int X.winPageSize() -> int (shared captured text)