Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QPrinter

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.gui.QPrinter

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

    public class QPrinter

extends QtJambiObject
implements QPaintDeviceInterface

The `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 `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 Mac OS X, `QPrinter` uses the built-in printer drivers. On X11, `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 `printProgram()` function can be used to specify the command or utility to use instead of the system default.

`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.
- `setNumCopies()` 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.

See also:
  `QPrintDialog`, and Printing with Qt.

Nested Class Summary
`static class` | `QPrinter.ColorMode` This enum type is used to indicate whether `QPrinter` should print in color or not.
`static class` | `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).
`static class` | `QPrinter.Orientation` This type is used to signify an object's orientation.
`static class` | `QPrinter.OutputFormat` The `OutputFormat` enum is used to describe the format `QPrinter` should use for printing.
`static class` | `QPrinter.PageOrder` This enum type is used by `QPrinter` to tell the application program how to print.
`static class` | `QPrinter.PageSize` Use `QPrinter::PaperSize` instead.
`static class` | `QPrinter.PaperSource` This enum type specifies what paper source `QPrinter` is to use.
`static class` | `QPrinter.PrinterMode` This enum describes the mode the printer should work in.
`static class` | `QPrinter.PrinterState`
`static class` | `QPrinter.PrintRange` Used to specify the print range selection option.
`static class` | `QPrinter.Unit` This enum type is used to specify the measurement unit for page and paper sizes.

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QPrinter()` Creates a new printer object with the given `mode`.
`QPrinter(QPrinter.PrinterMode mode)` Creates a new printer object with the given `mode`.
`QPrinter(QPrinterInfo printer)` Creates a new printer object with the given `printer` and `mode`.
`QPrinter(QPrinterInfo printer, QPrinter.PrinterMode mode)` Creates a new printer object with the given `printer` and `mode`.

Method Summary
`boolean` | `abort()` Aborts the current print run.
`boolean` | `collateCopies()` Returns true if collation is turned on when multiple copies is selected.
`QPrinter.ColorMode` | `colorMode()` Returns the current color mode.
`java.lang.String` | `creator()` Returns the name of the application that created the document.
`int` | `depth()` Returns the bit depth (number of bit planes) of the paint device.
`java.lang.String` | `docName()` Returns the document name.
`boolean` | `doubleSidedPrinting()` Returns true if double side printing is enabled.
`QPrinter.DuplexMode` | `duplex()` Returns the current duplex mode.
`boolean` | `fontEmbeddingEnabled()` Returns true if font embedding is enabled.
`int` | `fromPage()` Returns the number of the first page in a range of pages to be printed (the "from page" setting).
`boolean` | `fullPage()` 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.
`com.trolltech.qt.gui.QMarginsF` | `getPageMargins(QPrinter.Unit unit)` Returns the page margins for this printer.
`int` | `height()` Returns the height of the paint device in default coordinate system units (e.
`int` | `heightMM()` Returns the height of the paint device in millimeters.
`boolean` | `isValid()` Returns true if the printer currently selected is a valid printer in the system, or a pure PDF/PostScript printer; otherwise returns false.
`int` | `logicalDpiX()` Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes.
`int` | `logicalDpiY()` Returns the vertical resolution of the device in dots per inch, which is used when computing font sizes.
`int` | `metric(QPaintDevice.PaintDeviceMetric arg__1)` Returns the metric information for the given paint device `metric`.
`boolean` | `newPage()` Tells the printer to eject the current page and to continue printing on a new page.
`int` | `numColors()` Returns the number of different colors available for the paint device.
`int` | `numCopies()` Returns the number of copies to be printed.
`QPrinter.Orientation` | `orientation()` Returns the orientation setting.
`java.lang.String` | `outputFileName()` Returns the name of the output file.
`QPrinter.OutputFormat` | `outputFormat()` Returns the output format for this printer.
`QPrinter.PageOrder` | `pageOrder()` Returns the current page order.
`QRect` | `pageRect()` Returns the page's rectangle; this is usually smaller than the `paperRect()` since the page normally has margins between its borders and the paper.
`QRectF` | `pageRect(QPrinter.Unit arg__1)` Returns the page's rectangle in `unit`; this is usually smaller than the `paperRect()` since the page normally has margins between its borders and the paper.
`QPrinter.PageSize` | `pageSize()` Returns the printer page size.
`QPaintEngine` | `paintEngine()` Returns a pointer to the paint engine used for drawing on the device.
`boolean` | `paintingActive()` Returns true if the device is currently being painted on, i.
`QRect` | `paperRect()` Returns the paper's rectangle; this is usually larger than the `pageRect()`.
`QRectF` | `paperRect(QPrinter.Unit arg__1)` Returns the paper's rectangle in `unit`; this is usually larger than the `pageRect()`.
`QPrinter.PageSize` | `paperSize()` Returns the printer paper size.
`QSizeF` | `paperSize(QPrinter.Unit unit)` Returns the paper size in `unit`.
`QPrinter.PaperSource` | `paperSource()` Returns the printer's paper source.
`int` | `physicalDpiX()` Returns the horizontal resolution of the device in dots per inch.
`int` | `physicalDpiY()` Returns the horizontal resolution of the device in dots per inch.
`QPrintEngine` | `printEngine()` Returns the print engine used by the printer.
`java.lang.String` | `printerName()` Returns the printer name.
`QPrinter.PrinterState` | `printerState()` Returns the current state of the printer.
`java.lang.String` | `printProgram()` Returns the name of the program that sends the print output to the printer.
`QPrinter.PrintRange` | `printRange()` Returns the page range of the `QPrinter`.
`int` | `resolution()` Returns the current assumed resolution of the printer, as set by `setResolution()` or by the printer driver.
`void` | `setCollateCopies(boolean collate)` Sets the default value for collation checkbox when the print dialog appears.
`void` | `setColorMode(QPrinter.ColorMode arg__1)` Sets the printer's color mode to `newColorMode`, which can be either `Color` or `GrayScale`.
`void` | `setCreator(java.lang.String arg__1)` Sets the name of the application that created the document to `creator`.
`void` | `setDocName(java.lang.String arg__1)` Sets the document name to `name`.
`void` | `setDoubleSidedPrinting(boolean enable)` Enables double sided printing if `doubleSided` is true; otherwise disables it.
`void` | `setDuplex(QPrinter.DuplexMode duplex)` Enables double sided printing based on the `duplex` mode.
`protected void` | `setEngines(QPrintEngine printEngine, QPaintEngine paintEngine)` This function is used by subclasses of `QPrinter` to specify custom print and paint engines (`printEngine` and `paintEngine`, respectively).
`void` | `setFontEmbeddingEnabled(boolean enable)` Enabled or disables font embedding depending on `enable`.
`void` | `setFromTo(int fromPage, int toPage)` 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.
`void` | `setFullPage(boolean arg__1)` If `fp` is true, enables support for painting over the entire page; otherwise restricts painting to the printable area reported by the device.
`void` | `setNumCopies(int arg__1)` Sets the number of copies to be printed to `numCopies`.
`void` | `setOrientation(QPrinter.Orientation arg__1)` Sets the print orientation to `orientation`.
`void` | `setOutputFileName(java.lang.String arg__1)` Sets the name of the output file to `fileName`.
`void` | `setOutputFormat(QPrinter.OutputFormat format)` Sets the output format for this printer to `format`.
`void` | `setPageMargins(double left, double top, double right, double bottom, QPrinter.Unit unit)` This function sets the `left`, `top`, `right` and `bottom` page margins for this printer.
`void` | `setPageOrder(QPrinter.PageOrder arg__1)` Sets the page order to `pageOrder`.
`void` | `setPageSize(QPrinter.PageSize arg__1)` Sets the printer page size based on `newPageSize`.
`void` | `setPaperSize(QPrinter.PageSize arg__1)` Sets the printer paper size to `arg_1` if that size is supported.
`void` | `setPaperSize(QSizeF paperSize, QPrinter.Unit unit)` Sets the paper size based on `paperSize` in `unit`.
`void` | `setPaperSource(QPrinter.PaperSource arg__1)` Sets the paper source setting to `source`.
`void` | `setPrinterName(java.lang.String arg__1)` Sets the printer name to `name`.
`void` | `setPrintProgram(java.lang.String arg__1)` Sets the name of the program that should do the print job to `printProg`.
`void` | `setPrintRange(QPrinter.PrintRange range)` Sets the print range option in to be `range`.
`void` | `setResolution(int arg__1)` Requests that the printer prints at `dpi` or as near to `dpi` as possible.
`java.util.List` | `supportedResolutions()` Returns a list of the resolutions (a list of dots-per-inch integers) that the printer says it supports.
`int` | `toPage()` Returns the number of the last page in a range of pages to be printed (the "to page" setting).
`int` | `width()` Returns the width of the paint device in default coordinate system units (e.
`int` | `widthMM()` Returns the width of the paint device in millimeters.

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QPrinter

    public QPrinter()

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

### QPrinter

    public QPrinter(QPrinter.PrinterMode mode)

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

### QPrinter

    public QPrinter(QPrinterInfo printer)

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

### QPrinter

    public QPrinter(QPrinterInfo printer,
                    QPrinter.PrinterMode mode)

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

Method Detail

### abort

    public final boolean abort()

  Aborts the current print run. Returns true if the print run was successfully aborted and `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.

### collateCopies

    public final boolean collateCopies()

  Returns true if collation is turned on when multiple copies is selected. Returns false if it is turned off when multiple copies is selected.

See also:
  `setCollateCopies()`.

### colorMode

    public final QPrinter.ColorMode colorMode()

  Returns the current color mode.

See also:
  `setColorMode()`.

### creator

    public final java.lang.String creator()

  Returns the name of the application that created the document.

See also:
  `setCreator()`.

### depth

    public final int depth()

  Returns the bit depth (number of bit planes) of the paint device.

  Specified by:
    `depth` in interface `QPaintDeviceInterface`

### docName

    public final java.lang.String docName()

  Returns the document name.

See also:
  `setDocName()`, and `QPrintEngine::PrintEnginePropertyKey` .

### doubleSidedPrinting

    public final boolean doubleSidedPrinting()

  Returns true if double side printing is enabled.

  Currently this option is only supported on X11.

See also:
  `setDoubleSidedPrinting()`.

### duplex

    public final QPrinter.DuplexMode duplex()

  Returns the current duplex mode.

  Currently this option is only supported on X11.

See also:
  `setDuplex()`.

### fontEmbeddingEnabled

    public final boolean fontEmbeddingEnabled()

  Returns true if font embedding is enabled.

  Currently this option is only supported on X11.

See also:
  `setFontEmbeddingEnabled()`.

### fromPage

    public final int fromPage()

  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 `fromPage()` and `toPage()` both return 0, this indicates that the whole document will be printed.

See also:
  `setFromTo()`, and `toPage()`.

### fullPage

    public final boolean fullPage()

  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 `setFullPage()` for details and caveats.

See also:
  `setFullPage()`, and `PaperSize` .

### height

    public final int height()

  Returns the height of the paint device in default coordinate system units (e. . pixels for `QPixmap` and `QWidget`).

See also:
  `heightMM()`.

  Specified by:
    `height` in interface `QPaintDeviceInterface`

### heightMM

    public final int heightMM()

  Returns the height of the paint device in millimeters.

See also:
  `height()`.

  Specified by:
    `heightMM` in interface `QPaintDeviceInterface`

### isValid

    public final boolean isValid()

  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 QPainter::nextPage().
  The following code example is written in c++.

          QPrinter printer;
          printer.setOutputFormat(QPrinter::PdfFormat);
          printer.setOutputFileName("/foobar/nonwritable.pdf");
          QPainter painter;
          if (! painter.begin(&printer)) { // failed to open file
              qWarning("failed to open file, is it writable?");
              return 1;
          }
          painter.drawText(10, 10, "Test");
          if (! printer.newPage()) {
              qWarning("failed in flushing page to disk, disk full?");
              return 1;
          }
          painter.drawText(10, 10, "Test 2");
          painter.end();

See also:
  `setPrinterName()`.

### logicalDpiX

    public final int logicalDpiX()

  Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from `widthMM()`.

  Note that if the `logicalDpiX()` doesn't equal the `physicalDpiX()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `logicalDpiY()`, and `physicalDpiX()`.

  Specified by:
    `logicalDpiX` in interface `QPaintDeviceInterface`

### logicalDpiY

    public final int logicalDpiY()

  Returns the vertical resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from `heightMM()`.

  Note that if the `logicalDpiY()` doesn't equal the `physicalDpiY()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `logicalDpiX()`, and `physicalDpiY()`.

  Specified by:
    `logicalDpiY` in interface `QPaintDeviceInterface`

### newPage

    public final boolean newPage()

  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.

### numColors

    public final int numColors()

  Returns the number of different colors available for the paint device. Since this value is an int, it will not be sufficient to represent the number of colors on 32 bit displays, in this case INT_MAX is returned instead.

  Specified by:
    `numColors` in interface `QPaintDeviceInterface`

### numCopies

    public final int numCopies()

  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.

See also:
  `setNumCopies()`.

### orientation

    public final QPrinter.Orientation orientation()

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

See also:
  `setOrientation()`.

### outputFileName

    public final java.lang.String outputFileName()

  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:
  `setOutputFileName()`, and `QPrintEngine::PrintEnginePropertyKey` .

### outputFormat

    public final QPrinter.OutputFormat outputFormat()

  Returns the output format for this printer.

See also:
  `setOutputFormat()`.

### pageOrder

    public final QPrinter.PageOrder pageOrder()

  Returns the current page order.

  The default page order is `FirstPageFirst`.

See also:
  `setPageOrder()`.

### pageRect

    public final QRect pageRect()

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

  The unit of the returned rectangle is `DevicePixel` .

See also:
  `paperSize()`.

### pageRect

    public final QRectF pageRect(QPrinter.Unit arg__1)

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

See also:
  `paperSize()`.

### pageSize

    public final QPrinter.PageSize pageSize()

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

  Use `paperSize()` instead.

See also:
  setPageSize().

### paintingActive

    public final boolean paintingActive()

  Returns true if the device is currently being painted on, i. . someone has called `QPainter::begin()` but not yet called `QPainter::end()` for this device; otherwise returns false.

See also:
  `QPainter::isActive()`.

  Specified by:
    `paintingActive` in interface `QPaintDeviceInterface`

### paperRect

    public final QRect paperRect()

  Returns the paper's rectangle; this is usually larger than the `pageRect()`.

  The unit of the returned rectangle is `DevicePixel` .

See also:
  `pageRect()`.

### paperRect

    public final QRectF paperRect(QPrinter.Unit arg__1)

  Returns the paper's rectangle in `unit`; this is usually larger than the `pageRect()`.

See also:
  `pageRect()`.

### paperSize

    public final QPrinter.PageSize paperSize()

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

See also:
  `setPaperSize()`, `pageRect()`, and `paperRect()`.

### paperSize

    public final QSizeF paperSize(QPrinter.Unit unit)

  Returns the paper size in `unit`.

See also:
  `setPaperSize()`.

### paperSource

    public final QPrinter.PaperSource paperSource()

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

See also:
  `setPaperSource()`.

### physicalDpiX

    public final int physicalDpiX()

  Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer's resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.

  Note that if the `physicalDpiX()` doesn't equal the `logicalDpiX()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `physicalDpiY()`, and `logicalDpiX()`.

  Specified by:
    `physicalDpiX` in interface `QPaintDeviceInterface`

### physicalDpiY

    public final int physicalDpiY()

  Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer's resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.

  Note that if the `physicalDpiY()` doesn't equal the `logicalDpiY()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `physicalDpiX()`, and `logicalDpiY()`.

  Specified by:
    `physicalDpiY` in interface `QPaintDeviceInterface`

### printEngine

    public final QPrintEngine printEngine()

  Returns the print engine used by the printer.

### printProgram

    public final java.lang.String printProgram()

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

  The default is to return an empty string; meaning that `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:
  `setPrintProgram()`, and setPrinterSelectionOption().

### printRange

    public final QPrinter.PrintRange printRange()

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

See also:
  `setPrintRange()`.

### printerName

    public final java.lang.String printerName()

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

See also:
  `setPrinterName()`.

### printerState

    public final QPrinter.PrinterState 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).

### resolution

    public final int resolution()

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

See also:
  `setResolution()`.

### setCollateCopies

    public final void setCollateCopies(boolean collate)

  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.

See also:
  `collateCopies()`.

### setColorMode

    public final void setColorMode(QPrinter.ColorMode arg__1)

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

See also:
  `colorMode()`.

### setCreator

    public final void setCreator(java.lang.String arg__1)

  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.

See also:
  `creator()`.

### setDocName

    public final void setDocName(java.lang.String arg__1)

  Sets the document name to `name`.

  On X11, the document name is for example used as the default output filename in `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:
  `docName()`, and `QPrintEngine::PrintEnginePropertyKey` .

### setDoubleSidedPrinting

    public final void setDoubleSidedPrinting(boolean enable)

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

  Currently this option is only supported on X11.

See also:
  `doubleSidedPrinting()`.

### setDuplex

    public final void setDuplex(QPrinter.DuplexMode duplex)

  Enables double sided printing based on the `duplex` mode.

  Currently this option is only supported on X11.

See also:
  `duplex()`.

### setEngines

    protected final void setEngines(QPrintEngine printEngine,
                                    QPaintEngine paintEngine)

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

  `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.

See also:
  `printEngine()`, `paintEngine()`, and `setOutputFormat()`.

### setFontEmbeddingEnabled

    public final void setFontEmbeddingEnabled(boolean enable)

  Enabled or disables font embedding depending on `enable`.

  Currently this option is only supported on X11.

See also:
  `fontEmbeddingEnabled()`.

### setFromTo

    public final void setFromTo(int fromPage,
                                int toPage)

  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().

See also:
  `fromPage()`, and `toPage()`.

### setFullPage

    public final void setFullPage(boolean arg__1)

  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 `QPrinter`'s coordinate system coincides with the top-left corner of the printable area.

  If full page printing is enabled, the origin of the `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 `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.

See also:
  `fullPage()`, `setPaperSize()`, `width()`, `height()`, and Printing with Qt.

### setNumCopies

    public final void setNumCopies(int arg__1)

  Sets the number of copies to be printed to `numCopies`.

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

See also:
  `numCopies()`.

### setOrientation

    public final void setOrientation(QPrinter.Orientation arg__1)

  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 `newPage()`.

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

See also:
  `orientation()`.

### setOutputFileName

    public final void setOutputFileName(java.lang.String arg__1)

  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 `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 `setOutputFormat()`.

  `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` .

See also:
  `outputFileName()`, setOutputToFile(), and `setOutputFormat()`.

### setOutputFormat

    public final void setOutputFormat(QPrinter.OutputFormat format)

  Sets the output format for this printer to `format`.

See also:
  `outputFormat()`.

### setPageMargins

    public final void setPageMargins(double left,
                                     double top,
                                     double right,
                                     double bottom,
                                     QPrinter.Unit 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.

### setPageOrder

    public final void setPageOrder(QPrinter.PageOrder arg__1)

  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.

See also:
  `pageOrder()`.

### setPageSize

    public final void setPageSize(QPrinter.PageSize arg__1)

  Sets the printer page size based on `newPageSize`.

  Use `setPaperSize()` instead.

See also:
  pageSize().

### setPaperSize

    public final void setPaperSize(QPrinter.PageSize arg__1)

  Sets the printer paper size to `arg_1` if that size is supported. The result is undefined if `newPaperSize` is not supported.

  The default paper size is driver-dependent.

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

See also:
  `paperSize()`, `PaperSize` , `setFullPage()`, `setResolution()`, `pageRect()`, and `paperRect()`.

### setPaperSize

    public final void setPaperSize(QSizeF paperSize,
                                   QPrinter.Unit unit)

  Sets the paper size based on `paperSize` in `unit`.

See also:
  `paperSize()`.

### setPaperSource

    public final void setPaperSource(QPrinter.PaperSource arg__1)

  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 `newPage()`

See also:
  `paperSource()`.

### setPrintProgram

    public final void setPrintProgram(java.lang.String arg__1)

  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.

See also:
  `printProgram()`.

### setPrintRange

    public final void setPrintRange(QPrinter.PrintRange range)

  Sets the print range option in to be `range`.

See also:
  `printRange()`.

### setPrinterName

    public final void setPrinterName(java.lang.String arg__1)

  Sets the printer name to `name`.

See also:
  `printerName()`, and `isValid()`.

### setResolution

    public final void setResolution(int arg__1)

  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.

See also:
  `resolution()`, and `setPaperSize()`.

### supportedResolutions

    public final java.util.List supportedResolutions()

  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 `PrinterMode` ).

### toPage

    public final int toPage()

  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 `fromPage()` and `toPage()` both return 0, this indicates that the whole document will be printed.

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

See also:
  `setFromTo()`, and `fromPage()`.

### width

    public final int width()

  Returns the width of the paint device in default coordinate system units (e. . pixels for `QPixmap` and `QWidget`).

See also:
  `widthMM()`.

  Specified by:
    `width` in interface `QPaintDeviceInterface`

### widthMM

    public final int widthMM()

  Returns the width of the paint device in millimeters.

See also:
  `width()`.

  Specified by:
    `widthMM` in interface `QPaintDeviceInterface`

### metric

    public int metric(QPaintDevice.PaintDeviceMetric arg__1)

  Returns the metric information for the given paint device `metric`.

See also:
  `PaintDeviceMetric` .

  Specified by:
    `metric` in interface `QPaintDeviceInterface`

### paintEngine

    public QPaintEngine paintEngine()

  Returns a pointer to the paint engine used for drawing on the device.

  Specified by:
    `paintEngine` in interface `QPaintDeviceInterface`

### getPageMargins

    public final com.trolltech.qt.gui.QMarginsF getPageMargins(QPrinter.Unit unit)

  Returns the page margins for this printer. The unit of the returned margins are specified with the unit parameter. This function was introduced in Qt 4.4.

  Parameters:
    `unit` - Specifies the unit of the returned margins.
  Returns:
    The page margins for this printer.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD