Table Of Contents

Previous topic

QPaintDevice

Next topic

QPicture

QPrinter

Inheritance diagram of QPrinter

Synopsis

Functions

Detailed Description

The PySide.QtGui.QPrinter class is a paint device that paints on a printer.

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 PySide.QtGui.QWidget and PySide.QtGui.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 Mac OS X, PySide.QtGui.QPrinter uses the built-in printer drivers. On X11, PySide.QtGui.QPrinter uses the Common Unix Printing System (CUPS) or the standard Unix lpr utility to send PostScript or PDF output to the printer. As an alternative, the PySide.QtGui.QPrinter.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.

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

The most important parameters are:

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 PySide.QtGui.QAbstractPrintDialog ‘s documentation for more details.

When QPainter.begin() is called, the PySide.QtGui.QPrinter it operates on is prepared for a new page, enabling the PySide.QtGui.QPainter to be used immediately to paint the first page in a document. Once the first page has been painted, PySide.QtGui.QPrinter.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 PySide.QtGui.QPrinter.newPage() before they are painted.

The first page in a document does not need to be preceded by a call to PySide.QtGui.QPrinter.newPage() . You only need to calling PySide.QtGui.QPrinter.newPage() after QPainter.begin() if you need to insert a blank page at the beginning of a printed document. Similarly, calling PySide.QtGui.QPrinter.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, PySide.QtGui.QPrinter.abort() will try its best to stop printing. It may cancel the entire job or just part of it.

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

See also

PySide.QtGui.QPrintDialog Printing with Qt

class PySide.QtGui.QPrinter([mode=ScreenResolution])
class PySide.QtGui.QPrinter(printer[, mode=ScreenResolution])
Parameters:

Creates a new printer object with the given mode .

Creates a new printer object with the given printer and mode .

PySide.QtGui.QPrinter.OutputFormat

The QPrinter.OutputFormat enum is used to describe the format PySide.QtGui.QPrinter should use for printing.

Constant Description
QPrinter.NativeFormat PySide.QtGui.QPrinter will print output using a method defined by the platform it is running on. This mode is the default when printing directly to a printer.
QPrinter.PdfFormat PySide.QtGui.QPrinter will generate its output as a searchable PDF file. This mode is the default when printing to a file.
QPrinter.PostScriptFormat PySide.QtGui.QPrinter will generate its output as in the PostScript format. (This feature was introduced in Qt 4.2.)
PySide.QtGui.QPrinter.DuplexMode

This enum is used to indicate whether printing will occur on one or both sides of each sheet of paper (simplex or duplex printing).

Constant Description
QPrinter.DuplexNone Single sided (simplex) printing only.
QPrinter.DuplexAuto The printer’s default setting is used to determine whether duplex printing is used.
QPrinter.DuplexLongSide Both sides of each sheet of paper are used for printing. The paper is turned over its longest edge before the second side is printed
QPrinter.DuplexShortSide Both sides of each sheet of paper are used for printing. The paper is turned over its shortest edge before the second side is printed
PySide.QtGui.QPrinter.PrintRange

Used to specify the print range selection option.

Constant Description
QPrinter.AllPages All pages should be printed.
QPrinter.Selection Only the selection should be printed.
QPrinter.PageRange The specified page range should be printed.
QPrinter.CurrentPage Only the current page should be printed.

See also

QAbstractPrintDialog.PrintRange

PySide.QtGui.QPrinter.Unit

This enum type is used to specify the measurement unit for page and paper sizes.

Constant Description
QPrinter.Millimeter  
QPrinter.Point  
QPrinter.Inch  
QPrinter.Pica  
QPrinter.Didot  
QPrinter.Cicero  
QPrinter.DevicePixel  

Note the difference between Point and DevicePixel . The Point unit is defined to be 1/72th of an inch, while the DevicePixel unit is resolution dependant and is based on the actual pixels, or dots, on the printer.

PySide.QtGui.QPrinter.PrinterMode

This enum describes the mode the printer should work in. It basically presets a certain resolution and working mode.

Constant Description
QPrinter.ScreenResolution Sets the resolution of the print device to the screen resolution. This has the big advantage that the results obtained when painting on the printer will match more or less exactly the visible output on the screen. It is the easiest to use, as font metrics on the screen and on the printer are the same. This is the default value. ScreenResolution will produce a lower quality output than HighResolution and should only be used for drafts.
QPrinter.PrinterResolution This value is deprecated. Is is equivalent to ScreenResolution on Unix and HighResolution on Windows and Mac. Due do the difference between ScreenResolution and HighResolution , use of this value may lead to non-portable printer code.
QPrinter.HighResolution On Windows, sets the printer resolution to that defined for the printer in use. For PostScript printing, sets the resolution of the PostScript driver to 1200 dpi.

Note

When rendering text on a PySide.QtGui.QPrinter device, it is important to realize that the size of text, when specified in points, is independent of the resolution specified for the device itself. Therefore, it may be useful to specify the font size in pixels when combining text with graphics to ensure that their relative sizes are what you expect.

PySide.QtGui.QPrinter.Orientation

This enum type (not to be confused with Orientation ) is used to specify each page’s orientation.

Constant Description
QPrinter.Portrait the page’s height is greater than its width.
QPrinter.Landscape the page’s width is greater than its height.

This type interacts with QPrinter.PaperSize and QPrinter.setFullPage() to determine the final size of the page available to the application.

PySide.QtGui.QPrinter.PrinterState
Constant Description
QPrinter.Idle  
QPrinter.Active  
QPrinter.Aborted  
QPrinter.Error  
PySide.QtGui.QPrinter.ColorMode

This enum type is used to indicate whether PySide.QtGui.QPrinter should print in color or not.

Constant Description
QPrinter.Color print in color if available, otherwise in grayscale.
QPrinter.GrayScale print in grayscale, even on color printers.
PySide.QtGui.QPrinter.PaperSource

This enum type specifies what paper source PySide.QtGui.QPrinter is to use. PySide.QtGui.QPrinter does not check that the paper source is available; it just uses this information to try and set the paper source. Whether it will set the paper source depends on whether the printer has that particular source.

Warning

This is currently only implemented for Windows.

Constant Description
QPrinter.Auto  
QPrinter.Cassette  
QPrinter.Envelope  
QPrinter.EnvelopeManual  
QPrinter.FormSource  
QPrinter.LargeCapacity  
QPrinter.LargeFormat  
QPrinter.Lower  
QPrinter.MaxPageSource  
QPrinter.Middle  
QPrinter.Manual  
QPrinter.OnlyOne  
QPrinter.Tractor  
QPrinter.SmallFormat  
PySide.QtGui.QPrinter.PageOrder

This enum type is used by PySide.QtGui.QPrinter to tell the application program how to print.

Constant Description
QPrinter.FirstPageFirst the lowest-numbered page should be printed first.
QPrinter.LastPageFirst the highest-numbered page should be printed first.
PySide.QtGui.QPrinter.PageSize

Use QPrinter.PaperSize instead.

Constant Description
QPrinter.A0 841 x 1189 mm
QPrinter.A1 594 x 841 mm
QPrinter.A2 420 x 594 mm
QPrinter.A3 297 x 420 mm
QPrinter.A4 210 x 297 mm, 8.26 x 11.69 inches
QPrinter.A5 148 x 210 mm
QPrinter.A6 105 x 148 mm
QPrinter.A7 74 x 105 mm
QPrinter.A8 52 x 74 mm
QPrinter.A9 37 x 52 mm
QPrinter.B0 1030 x 1456 mm
QPrinter.B1 728 x 1030 mm
QPrinter.B10 32 x 45 mm
QPrinter.B2 515 x 728 mm
QPrinter.B3 364 x 515 mm
QPrinter.B4 257 x 364 mm
QPrinter.B5 182 x 257 mm, 7.17 x 10.13 inches
QPrinter.B6 128 x 182 mm
QPrinter.B7 91 x 128 mm
QPrinter.B8 64 x 91 mm
QPrinter.B9 45 x 64 mm
QPrinter.C5E 163 x 229 mm
QPrinter.Comm10E 105 x 241 mm, U.S. Common 10 Envelope
QPrinter.DLE 110 x 220 mm
QPrinter.Executive 7.5 x 10 inches, 191 x 254 mm
QPrinter.Folio 210 x 330 mm
QPrinter.Ledger 432 x 279 mm
QPrinter.Legal 8.5 x 14 inches, 216 x 356 mm
QPrinter.Letter 8.5 x 11 inches, 216 x 279 mm
QPrinter.Tabloid 279 x 432 mm
QPrinter.Custom Unknown, or a user defined size.
PySide.QtGui.QPrinter.abort()
Return type:PySide.QtCore.bool

Aborts the current print run. Returns true if the print run was successfully aborted and PySide.QtGui.QPrinter.printerState() will return QPrinter.Aborted ; otherwise returns false.

It is not always possible to abort a print job. For example, all the data has gone to the printer but the printer cannot or will not cancel the job when asked to.

PySide.QtGui.QPrinter.actualNumCopies()
Return type:PySide.QtCore.int

Returns the number of copies that will be printed. The default value is 1.

This function always returns the actual value specified in the print dialog or using PySide.QtGui.QPrinter.setNumCopies() .

Use PySide.QtGui.QPrinter.copyCount() instead.

PySide.QtGui.QPrinter.collateCopies()
Return type:PySide.QtCore.bool

Returns true if collation is turned on when multiple copies is selected. Returns false if it is turned off when multiple copies is selected. When collating is turned off the printing of each individual page will be repeated the PySide.QtGui.QPrinter.numCopies() amount before the next page is started. With collating turned on all pages are printed before the next copy of those pages is started.

PySide.QtGui.QPrinter.colorMode()
Return type:PySide.QtGui.QPrinter.ColorMode

Returns the current color mode.

PySide.QtGui.QPrinter.copyCount()
Return type:PySide.QtCore.int

Returns the number of copies that will be printed. The default value is 1.

PySide.QtGui.QPrinter.creator()
Return type:unicode

Returns the name of the application that created the document.

PySide.QtGui.QPrinter.docName()
Return type:unicode

Returns the document name.

See also

PySide.QtGui.QPrinter.setDocName() QPrintEngine.PrintEnginePropertyKey

PySide.QtGui.QPrinter.doubleSidedPrinting()
Return type:PySide.QtCore.bool

Returns true if double side printing is enabled.

Currently this option is only supported on X11.

PySide.QtGui.QPrinter.duplex()
Return type:PySide.QtGui.QPrinter.DuplexMode

Returns the current duplex mode.

Currently this option is only supported on X11.

PySide.QtGui.QPrinter.fontEmbeddingEnabled()
Return type:PySide.QtCore.bool

Returns true if font embedding is enabled.

Currently this option is only supported on X11.

PySide.QtGui.QPrinter.fromPage()
Return type:PySide.QtCore.int

Returns the number of the first page in a range of pages to be printed (the “from page” setting). Pages in a document are numbered according to the convention that the first page is page 1.

By default, this function returns a special value of 0, meaning that the “from page” setting is unset.

Note

If PySide.QtGui.QPrinter.fromPage() and PySide.QtGui.QPrinter.toPage() both return 0, this indicates that the whole document will be printed .

PySide.QtGui.QPrinter.fullPage()
Return type:PySide.QtCore.bool

Returns true if the origin of the printer’s coordinate system is at the corner of the page and false if it is at the edge of the printable area.

See PySide.QtGui.QPrinter.setFullPage() for details and caveats.

See also

PySide.QtGui.QPrinter.setFullPage() QPrinter.PaperSize

PySide.QtGui.QPrinter.getPageMargins(unit)
Parameters:unitPySide.QtGui.QPrinter.Unit

Returns the page margins for this printer in left , top , right , bottom . The unit of the returned margins are specified with the unit parameter.

PySide.QtGui.QPrinter.init(mode)
Parameters:modePySide.QtGui.QPrinter.PrinterMode
PySide.QtGui.QPrinter.isValid()
Return type:PySide.QtCore.bool

Returns true if the printer currently selected is a valid printer in the system, or a pure PDF/PostScript printer; otherwise returns false.

To detect other failures check the output of QPainter.begin() or QPrinter.newPage() .

printer = QPrinter()
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName("/foobar/nonwritable.pdf")
QPainter painter
if painter.begin(printer):  # failed to open file
    print "failed to open file, is it writable?"
    return 1

painter.drawText(10, 10, "Test")
if !printer.Page():
    print "failed in flushing page to disk, disk full?"
    return 1

painter.drawText(10, 10, "Test 2")
painter.end()
PySide.QtGui.QPrinter.newPage()
Return type:PySide.QtCore.bool

Tells the printer to eject the current page and to continue printing on a new page. Returns true if this was successful; otherwise returns false.

Calling PySide.QtGui.QPrinter.newPage() on an inactive PySide.QtGui.QPrinter object will always fail.

PySide.QtGui.QPrinter.numCopies()
Return type:PySide.QtCore.int

Returns the number of copies to be printed. The default value is 1.

On Windows, Mac OS X and X11 systems that support CUPS, this will always return 1 as these operating systems can internally handle the number of copies.

On X11, this value will return the number of times the application is required to print in order to match the number specified in the printer setup dialog. This has been done since some printer drivers are not capable of buffering up the copies and in those cases the application must make an explicit call to the print code for each copy.

Use PySide.QtGui.QPrinter.copyCount() in conjunction with PySide.QtGui.QPrinter.supportsMultipleCopies() instead.

PySide.QtGui.QPrinter.orientation()
Return type:PySide.QtGui.QPrinter.Orientation

Returns the orientation setting. This is driver-dependent, but is usually QPrinter.Portrait .

PySide.QtGui.QPrinter.outputFileName()
Return type:unicode

Returns the name of the output file. By default, this is an empty string (indicating that the printer shouldn’t print to file).

See also

PySide.QtGui.QPrinter.setOutputFileName() QPrintEngine.PrintEnginePropertyKey

PySide.QtGui.QPrinter.outputFormat()
Return type:PySide.QtGui.QPrinter.OutputFormat

Returns the output format for this printer.

PySide.QtGui.QPrinter.pageOrder()
Return type:PySide.QtGui.QPrinter.PageOrder

Returns the current page order.

The default page order is FirstPageFirst .

PySide.QtGui.QPrinter.pageRect(arg__1)
Parameters:arg__1PySide.QtGui.QPrinter.Unit
Return type:PySide.QtCore.QRectF

Returns the page’s rectangle in unit ; this is usually smaller than the PySide.QtGui.QPrinter.paperRect() since the page normally has margins between its borders and the paper.

PySide.QtGui.QPrinter.pageRect()
Return type:PySide.QtCore.QRect

Returns the page’s rectangle; this is usually smaller than the PySide.QtGui.QPrinter.paperRect() since the page normally has margins between its borders and the paper.

The unit of the returned rectangle is DevicePixel .

PySide.QtGui.QPrinter.pageSize()
Return type:PySide.QtGui.QPrinter.PageSize

Returns the printer page size. The default value is driver-dependent.

Use PySide.QtGui.QPrinter.paperSize() instead.

PySide.QtGui.QPrinter.paperRect(arg__1)
Parameters:arg__1PySide.QtGui.QPrinter.Unit
Return type:PySide.QtCore.QRectF

Returns the paper’s rectangle in unit ; this is usually larger than the PySide.QtGui.QPrinter.pageRect() .

PySide.QtGui.QPrinter.paperRect()
Return type:PySide.QtCore.QRect

Returns the paper’s rectangle; this is usually larger than the PySide.QtGui.QPrinter.pageRect() .

The unit of the returned rectangle is DevicePixel .

PySide.QtGui.QPrinter.paperSize(unit)
Parameters:unitPySide.QtGui.QPrinter.Unit
Return type:PySide.QtCore.QSizeF

Returns the paper size in unit .

PySide.QtGui.QPrinter.paperSize()
Return type:PySide.QtGui.QPrinter.PageSize

Returns the printer paper size. The default value is driver-dependent.

PySide.QtGui.QPrinter.paperSource()
Return type:PySide.QtGui.QPrinter.PaperSource

Returns the printer’s paper source. This is Manual or a printer tray or paper cassette.

PySide.QtGui.QPrinter.printEngine()
Return type:PySide.QtGui.QPrintEngine

Returns the print engine used by the printer.

PySide.QtGui.QPrinter.printProgram()
Return type:unicode

Returns the name of the program that sends the print output to the printer.

The default is to return an empty string; meaning that PySide.QtGui.QPrinter will try to be smart in a system-dependent way. On X11 only, you can set it to something different to use a specific print program. On the other platforms, this returns an empty string.

See also

PySide.QtGui.QPrinter.setPrintProgram() setPrinterSelectionOption()

PySide.QtGui.QPrinter.printRange()
Return type:PySide.QtGui.QPrinter.PrintRange

Returns the page range of the PySide.QtGui.QPrinter . After the print setup dialog has been opened, this function returns the value selected by the user.

PySide.QtGui.QPrinter.printerName()
Return type:unicode

Returns the printer name. This value is initially set to the name of the default printer.

PySide.QtGui.QPrinter.printerState()
Return type:PySide.QtGui.QPrinter.PrinterState

Returns the current state of the printer. This may not always be accurate (for example if the printer doesn’t have the capability of reporting its state to the operating system).

PySide.QtGui.QPrinter.resolution()
Return type:PySide.QtCore.int

Returns the current assumed resolution of the printer, as set by PySide.QtGui.QPrinter.setResolution() or by the printer driver.

PySide.QtGui.QPrinter.setCollateCopies(collate)
Parameters:collatePySide.QtCore.bool

Sets the default value for collation checkbox when the print dialog appears. If collate is true, it will enable setCollateCopiesEnabled() . The default value is false. This value will be changed by what the user presses in the print dialog.

PySide.QtGui.QPrinter.setColorMode(arg__1)
Parameters:arg__1PySide.QtGui.QPrinter.ColorMode

Sets the printer’s color mode to newColorMode , which can be either Color or GrayScale .

PySide.QtGui.QPrinter.setCopyCount(arg__1)
Parameters:arg__1PySide.QtCore.int

Sets the number of copies to be printed to count .

The printer driver reads this setting and prints the specified number of copies.

PySide.QtGui.QPrinter.setCreator(arg__1)
Parameters:arg__1 – unicode

Sets the name of the application that created the document to creator .

This function is only applicable to the X11 version of Qt. If no creator name is specified, the creator will be set to “Qt” followed by some version number.

PySide.QtGui.QPrinter.setDocName(arg__1)
Parameters:arg__1 – unicode

Sets the document name to name .

On X11, the document name is for example used as the default output filename in PySide.QtGui.QPrintDialog . Note that the document name does not affect the file name if the printer is printing to a file. Use the setOutputFile() function for this.

See also

PySide.QtGui.QPrinter.docName() QPrintEngine.PrintEnginePropertyKey

PySide.QtGui.QPrinter.setDoubleSidedPrinting(enable)
Parameters:enablePySide.QtCore.bool

Enables double sided printing if doubleSided is true; otherwise disables it.

Currently this option is only supported on X11.

PySide.QtGui.QPrinter.setDuplex(duplex)
Parameters:duplexPySide.QtGui.QPrinter.DuplexMode

Enables double sided printing based on the duplex mode.

Currently this option is only supported on X11.

PySide.QtGui.QPrinter.setEngines(printEngine, paintEngine)
Parameters:

This function is used by subclasses of PySide.QtGui.QPrinter to specify custom print and paint engines (printEngine and paintEngine , respectively).

PySide.QtGui.QPrinter does not take ownership of the engines, so you need to manage these engine instances yourself.

Note that changing the engines will reset the printer state and all its properties.

PySide.QtGui.QPrinter.setFontEmbeddingEnabled(enable)
Parameters:enablePySide.QtCore.bool

Enabled or disables font embedding depending on enable .

Currently this option is only supported on X11.

PySide.QtGui.QPrinter.setFromTo(fromPage, toPage)
Parameters:
  • fromPagePySide.QtCore.int
  • toPagePySide.QtCore.int

Sets the range of pages to be printed to cover the pages with numbers specified by from and to , where from corresponds to the first page in the range and to corresponds to the last.

Note

Pages in a document are numbered according to the convention that the first page is page 1. However, if from and to are both set to 0, the whole document will be printed .

This function is mostly used to set a default value that the user can override in the print dialog when you call setup() .

PySide.QtGui.QPrinter.setFullPage(arg__1)
Parameters:arg__1PySide.QtCore.bool

If fp is true, enables support for painting over the entire page; otherwise restricts painting to the printable area reported by the device.

By default, full page printing is disabled. In this case, the origin of the PySide.QtGui.QPrinter ‘s coordinate system coincides with the top-left corner of the printable area.

If full page printing is enabled, the origin of the PySide.QtGui.QPrinter ‘s coordinate system coincides with the top-left corner of the paper itself. In this case, the device metrics will report the exact same dimensions as indicated by QPrinter.PaperSize . It may not be possible to print on the entire physical page because of the printer’s margins, so the application must account for the margins itself.

PySide.QtGui.QPrinter.setNumCopies(arg__1)
Parameters:arg__1PySide.QtCore.int

Sets the number of copies to be printed to numCopies .

The printer driver reads this setting and prints the specified number of copies.

Use PySide.QtGui.QPrinter.setCopyCount() instead.

PySide.QtGui.QPrinter.setOrientation(arg__1)
Parameters:arg__1PySide.QtGui.QPrinter.Orientation

Sets the print orientation to orientation .

The orientation can be either QPrinter.Portrait or QPrinter.Landscape .

The printer driver reads this setting and prints using the specified orientation.

On Windows, this option can be changed while printing and will take effect from the next call to PySide.QtGui.QPrinter.newPage() .

On Mac OS X, changing the orientation during a print job has no effect.

PySide.QtGui.QPrinter.setOutputFileName(arg__1)
Parameters:arg__1 – unicode

Sets the name of the output file to fileName .

Setting a null or empty name (0 or “”) disables printing to a file. Setting a non-empty name enables printing to a file.

This can change the value of PySide.QtGui.QPrinter.outputFormat() . If the file name has the suffix ”.ps” then PostScript is automatically selected as output format. If the file name has the ”.pdf” suffix PDF is generated. If the file name has a suffix other than ”.ps” and ”.pdf”, the output format used is the one set with PySide.QtGui.QPrinter.setOutputFormat() .

PySide.QtGui.QPrinter uses Qt’s cross-platform PostScript or PDF print engines respectively. If you can produce this format natively, for example Mac OS X can generate PDF’s from its print engine, set the output format back to NativeFormat .

PySide.QtGui.QPrinter.setOutputFormat(format)
Parameters:formatPySide.QtGui.QPrinter.OutputFormat

Sets the output format for this printer to format .

PySide.QtGui.QPrinter.setPageMargins(left, top, right, bottom, unit)
Parameters:
  • leftPySide.QtCore.qreal
  • topPySide.QtCore.qreal
  • rightPySide.QtCore.qreal
  • bottomPySide.QtCore.qreal
  • unitPySide.QtGui.QPrinter.Unit

This function sets the left , top , right and bottom page margins for this printer. The unit of the margins are specified with the unit parameter.

PySide.QtGui.QPrinter.setPageOrder(arg__1)
Parameters:arg__1PySide.QtGui.QPrinter.PageOrder

Sets the page order to pageOrder .

The page order can be QPrinter.FirstPageFirst or QPrinter.LastPageFirst . The application is responsible for reading the page order and printing accordingly.

This function is mostly useful for setting a default value that the user can override in the print dialog.

This function is only supported under X11.

PySide.QtGui.QPrinter.setPageSize(arg__1)
Parameters:arg__1PySide.QtGui.QPrinter.PageSize

Sets the printer page size based on newPageSize .

Use PySide.QtGui.QPrinter.setPaperSize() instead.

PySide.QtGui.QPrinter.setPaperSize(arg__1)
Parameters:arg__1PySide.QtGui.QPrinter.PageSize
PySide.QtGui.QPrinter.setPaperSize(paperSize, unit)
Parameters:

Sets the paper size based on paperSize in unit .

PySide.QtGui.QPrinter.setPaperSource(arg__1)
Parameters:arg__1PySide.QtGui.QPrinter.PaperSource

Sets the paper source setting to source .

Windows only: This option can be changed while printing and will take effect from the next call to PySide.QtGui.QPrinter.newPage()

PySide.QtGui.QPrinter.setPrintProgram(arg__1)
Parameters:arg__1 – unicode

Sets the name of the program that should do the print job to printProg .

On X11, this function sets the program to call with the PostScript output. On other platforms, it has no effect.

PySide.QtGui.QPrinter.setPrintRange(range)
Parameters:rangePySide.QtGui.QPrinter.PrintRange

Sets the print range option in to be range .

PySide.QtGui.QPrinter.setPrinterName(arg__1)
Parameters:arg__1 – unicode

Sets the printer name to name .

PySide.QtGui.QPrinter.setResolution(arg__1)
Parameters:arg__1PySide.QtCore.int

Requests that the printer prints at dpi or as near to dpi as possible.

This setting affects the coordinate system as returned by, for example QPainter.viewport() .

This function must be called before QPainter.begin() to have an effect on all platforms.

PySide.QtGui.QPrinter.supportedResolutions()
Return type:

Returns a list of the resolutions (a list of dots-per-inch integers) that the printer says it supports.

For X11 where all printing is directly to postscript, this function will always return a one item list containing only the postscript resolution, i.e., 72 (72 dpi – but see QPrinter.PrinterMode ).

PySide.QtGui.QPrinter.supportsMultipleCopies()
Return type:PySide.QtCore.bool

Returns true if the printer supports printing multiple copies of the same document in one job; otherwise false is returned.

On most systems this function will return true. However, on X11 systems that do not support CUPS, this function will return false. That means the application has to handle the number of copies by printing the same document the required number of times.

PySide.QtGui.QPrinter.toPage()
Return type:PySide.QtCore.int

Returns the number of the last page in a range of pages to be printed (the “to page” setting). Pages in a document are numbered according to the convention that the first page is page 1.

By default, this function returns a special value of 0, meaning that the “to page” setting is unset.

Note

If PySide.QtGui.QPrinter.fromPage() and PySide.QtGui.QPrinter.toPage() both return 0, this indicates that the whole document will be printed .

The programmer is responsible for reading this setting and printing accordingly.