QPrinter supports a number of settable parameters, most of which can be changed by the end user when the application calls QPrinter::setup().
.PP
The most important parameters are:
.TP
setOrientation() tells QPrinter which page orientation to use (virtual).
.TP
setPageSize() tells QPrinter what page size to expect from the printer.
.TP
setResolution() tells QPrinter what resolution you wish the printer to provide (in dpi).
.TP
setFullPage() tells QPrinter whether you want to deal with the full page or just with the part the printer can draw on. The default is FALSE, so that by default you should be able to paint on (0,0). If TRUE the origin of the coordinate system will be in the top left corner of the paper and most probably the printer will not be able to paint something there due to it's physical margins.
.TP
setNumCopies() tells QPrinter how many copies of the document it should print.
.TP
setMinMax() tells QPrinter and QPrintDialog what the allowed range for fromPage() and toPage() are.
Except where noted, you can only call the set functions before setup(), or between TQPainter::end() and setup(). (Some may take effect between setup() and begin(), or between begin() and end(), but that's strictly undocumented and such behaviour may differ depending on platform.)
colorMode() tells the application program whether to print in color or grayscale. (If you print in color and the printer does not support color, TQt will try to approximate. The document may take longer to print, but the quality should not be made visibly poorer.)
Once you start printing, calling newPage() is essential. You will probably also need to look at the TQPaintDeviceMetrics for the printer (see the print function in the Application walk-through). In previous versions, paint device metrics were valid only after the QPrinter has been set up, i.e. after setup() has returned successfully. This is no longer the case and paint device metrics can be requested safely before set up.
If you want to abort the print job, abort() will try its best to stop printing. It may cancel the entire job or just some of it.
.PP
If your current locale converts "," to ".", you will need to set a locale (via the standard C setlocale() function) that doen't do this before using QPrinter. The "C" locale works well for this.
.PP
The TrueType font embedding for Qt's postscript driver uses code by David Chappell of Trinity College Computing Center.
.PP
Copyright 1995, Trinity College Computing Center. Written by David Chappell.
.PP
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty.
.PP
TrueType font support. These functions allow PPR to generate PostScript fonts from Microsoft compatible TrueType font files.
.PP
The functions in this file do most of the work to convert a TrueType font to a type 3 PostScript font.
.PP
Most of the material in this file is derived from a program called" ttf2ps" which L. S. Ng posted to the usenet news group" comp.sources.postscript". The author did not provide a copyright notice or indicate any restrictions on use.
.PP
Last revised 11 July 1995.
.PP
See also Graphics Classes and Image Processing Classes.
.SS "Member Type Documentation"
.SH "QPrinter::ColorMode"
This enum type is used to indicate whether QPrinter should print in color or not.
.TP
\fCQPrinter::Color\fR - print in color if available, otherwise in grayscale.
.TP
\fCQPrinter::GrayScale\fR - print in grayscale, even on color printers. Might be a little faster than Color. This is the default.
This enum type specifies what paper size QPrinter should use. QPrinter does not check that the paper size is available; it just uses this information, together with QPrinter::Orientation and QPrinter::setFullPage(), to determine the printable area (see TQPaintDeviceMetrics).
\fCQPrinter::A0\fR - 841 x 1189 mm This value is not supported on windows.
.TP
\fCQPrinter::A1\fR - 594 x 841 mm This value is not supported on windows.
.TP
\fCQPrinter::A2\fR - 420 x 594 mm
.TP
\fCQPrinter::A3\fR - 297 x 420 mm
.TP
\fCQPrinter::A4\fR - 210 x 297 mm, 8.26 x 11.7 inches
.TP
\fCQPrinter::A5\fR - 148 x 210 mm
.TP
\fCQPrinter::A6\fR - 105 x 148 mm
.TP
\fCQPrinter::A7\fR - 74 x 105 mm
.TP
\fCQPrinter::A8\fR - 52 x 74 mm
.TP
\fCQPrinter::A9\fR - 37 x 52 mm
.TP
\fCQPrinter::B0\fR - 1030 x 1456 mm
.TP
\fCQPrinter::B1\fR - 728 x 1030 mm
.TP
\fCQPrinter::B10\fR - 32 x 45 mm
.TP
\fCQPrinter::B2\fR - 515 x 728 mm
.TP
\fCQPrinter::B3\fR - 364 x 515 mm
.TP
\fCQPrinter::B4\fR - 257 x 364 mm
.TP
\fCQPrinter::B5\fR - 182 x 257 mm, 7.17 x 10.13 inches
.TP
\fCQPrinter::B6\fR - 128 x 182 mm
.TP
\fCQPrinter::B7\fR - 91 x 128 mm
.TP
\fCQPrinter::B8\fR - 64 x 91 mm
.TP
\fCQPrinter::B9\fR - 45 x 64 mm
.TP
\fCQPrinter::C5E\fR - 163 x 229 mm
.TP
\fCQPrinter::Comm10E\fR - 105 x 241 mm, US Common #10 Envelope
.TP
\fCQPrinter::DLE\fR - 110 x 220 mm
.TP
\fCQPrinter::Executive\fR - 7.5 x 10 inches, 191 x 254 mm
.TP
\fCQPrinter::Folio\fR - 210 x 330 mm
.TP
\fCQPrinter::Ledger\fR - 432 x 279 mm
.TP
\fCQPrinter::Legal\fR - 8.5 x 14 inches, 216 x 356 mm
.TP
\fCQPrinter::Letter\fR - 8.5 x 11 inches, 216 x 279 mm
.TP
\fCQPrinter::Tabloid\fR - 279 x 432 mm
.TP
\fCQPrinter::Custom\fR
.TP
\fCQPrinter::NPageSize\fR - (internal)
.PP
With setFullPage(FALSE) (the default), the metrics will be a bit smaller; how much depends on the printer in use.
.SH "QPrinter::PaperSource"
This enum type specifies what paper source QPrinter is to use. 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.
.PP
Note: this is currently only implemented for Windows.
.TP
\fCQPrinter::OnlyOne\fR
.TP
\fCQPrinter::Lower\fR
.TP
\fCQPrinter::Middle\fR
.TP
\fCQPrinter::Manual\fR
.TP
\fCQPrinter::Envelope\fR
.TP
\fCQPrinter::EnvelopeManual\fR
.TP
\fCQPrinter::Auto\fR
.TP
\fCQPrinter::Tractor\fR
.TP
\fCQPrinter::SmallFormat\fR
.TP
\fCQPrinter::LargeFormat\fR
.TP
\fCQPrinter::LargeCapacity\fR
.TP
\fCQPrinter::Cassette\fR
.TP
\fCQPrinter::FormSource\fR
.SH "QPrinter::PrintRange"
This enum is used to specify which print range the application should use to print.
.TP
\fCQPrinter::AllPages\fR - All pages should be printed
.TP
\fCQPrinter::Selection\fR - Only the selection should be printed.
.TP
\fCQPrinter::PageRange\fR - From page, to page option.
.PP
See also setPrintRange() and printRange().
.SH "QPrinter::PrinterMode"
This enum describes the mode the printer should work in. It basically presets a certain resolution and working mode.
.TP
\fCQPrinter::ScreenResolution\fR - 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.
.TP
\fCQPrinter::PrinterResolution\fR - Use the physical resolution of the printer on Windows. On Unix, set the postscript resolution to 72 dpi.
.TP
\fCQPrinter::HighResolution\fR - Use printer resolution on windows, set the resolution of the postscript driver to 600dpi.
\fCQPrinter::Compatible\fR - Almost the same as PrinterResolution, but keeps some peculiarities of the TQt 2.x printer driver. This is useful for applications ported from TQt 2.x to TQt 3.x.
This enum describes various printer options that appear in the printer setup dialog. It is used to enable and disable these options in the setup dialog.
.TP
\fCQPrinter::PrintToFile\fR - Describes if print to file should be enabled.
.TP
\fCQPrinter::PrintSelection\fR - Describes if printing selections should be enabled.
.TP
\fCQPrinter::PrintPageRange\fR - Describes if printing page ranges (from, to) should be enabled
.PP
See also setOptionEnabled() and isOptionEnabled().
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QPrinter::QPrinter ( PrinterMode m = ScreenResolution )"
Constructs a printer paint device with mode \fIm\fR.
.PP
See also QPrinter::PrinterMode.
.SH "QPrinter::~QPrinter ()"
Destroys the printer paint device and cleans up.
.SH "bool QPrinter::abort ()"
Aborts the print job. Returns TRUE if successful; otherwise returns FALSE.
.PP
See also aborted().
.SH "bool QPrinter::aborted () const"
Returns TRUE if the print job was aborted; otherwise returns FALSE.
.PP
See also abort().
.SH "ColorMode QPrinter::colorMode () const"
Returns the current color mode. The default color mode is Color.
Returns the width of the left margin and the height of the top margin of the printer. On Unix, this is a best-effort guess, not based on perfect knowledge.
.PP
If you have called setFullPage( TRUE ), margins().width() may be treated as the smallest sane left margin you can use, and margins().height() as the smallest sane top margin you can use.
.PP
If you have called setFullPage( FALSE ) (this is the default), margins() is automatically subtracted from the pageSize() by QPrinter.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets \fItop\fR, \fIleft\fR, \fIbottom\fR and \fIright\fR to the margins of the printer. On Unix, this is a best-effort guess, not based on perfect knowledge.
.PP
If you have called setFullPage( TRUE ), the four values specify the smallest sane margins you can use.
.PP
If you have called setFullPage( FALSE ) (this is the default), the margins are automatically subtracted from the pageSize() by QPrinter.
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 the application in those cases have to make an explicit call to the print code for each copy.
Returns the name of the program that sends the print output to the printer.
.PP
The default is to return a null 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.
.PP
On Windows, this function returns the name of the printer device driver.
.PP
See also setPrintProgram() and setPrinterSelectionOption().
.SH "PrintRange QPrinter::printRange () const"
Returns the PageRange of the QPrinter. After the print setup dialog has been opened, this function returns the value selected by the user.
Sets the name of the application that created the document to \fIcreator\fR.
.PP
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.
Sets QPrinter to have the origin of the coordinate system at the top-left corner of the paper if \fIfp\fR is TRUE, or where it thinks the top-left corner of the printable area is if \fIfp\fR is FALSE.
The default is FALSE. You can (probably) print on (0,0), and TQPaintDeviceMetrics will report something smaller than the size indicated by PageSize. (Note that QPrinter may be wrong on Unix systems - it does not have perfect knowledge of the physical printer.)
If you set \fIfp\fR to TRUE, TQPaintDeviceMetrics will report the exact same size as indicated by PageSize, but you cannot print on all of that - you must take care of the output margins yourself.
Sets the printer margins to the sizes specified in \fItop\fR, \fIleft\fR, \fIbottom\fR and \fIright\fR.
.PP
This function currently only has an effect on Unix systems.
.PP
See also margins().
.SH "void QPrinter::setMinMax ( int minPage, int maxPage )\fC [virtual]\fR"
Sets the min-page and max-page settings to \fIminPage\fR and \fImaxPage\fR respectively.
.PP
The min-page and max-page restrict the from-page and to-page settings. When the printer setup dialog appears, the user cannot select a from page or a to page that are outside the range specified by min and max pages.
.PP
See also minPage(), maxPage(), setFromTo(), and setup().
.SH "void QPrinter::setNumCopies ( int numCopies )\fC [virtual]\fR"
Sets the number of copies to be printed to \fInumCopies\fR.
.PP
The printer driver reads this setting and prints the specified number of copies.
The orientation can be either QPrinter::Portrait or QPrinter::Landscape.
.PP
The printer driver reads this setting and prints using the specified orientation. On Windows this setting won't take effect until the printer dialog is shown (using QPrinter::setup()).
.PP
Windows only! This option can be changed while printing and will take effect from the next call to newPage()
Sets the name of the output file to \fIfileName\fR.
.PP
Setting a null or empty name (0 or "") disables output to a file, i.e. calls setOutputToFile(FALSE). Setting a non-empty name enables output to a file, i.e. calls setOutputToFile(TRUE).
.PP
This function is currently only supported under X11.
The page order can be QPrinter::FirstPageFirst or QPrinter::LastPageFirst. The application programmer is responsible for reading the page order and printing accordingly.
.PP
This function is useful mostly for setting a default value that the user can override in the print dialog when you call setup().
.PP
Bugs and limitations:
.TP
This value is not kept in sync with the Windows or Mac OS X printer dialogs.
Sets the name of the program that should do the print job to \fIprintProg\fR.
.PP
On X11, this function sets the program to call with the PostScript output. On other platforms, it has no effect.
.PP
See also printProgram().
.SH "void QPrinter::setPrintRange ( PrintRange range )"
Sets the default selected page range to be used when the print setup dialog is opened to \fIrange\fR. If the PageRange specified by \fIrange\fR is currently disabled the function does nothing.
The default printer will be used if no printer name is set.
.PP
Under X11, the \fCPRINTER\fR environment variable defines the default printer. Under any other window system, the window system defines the default printer.
Sets the printer to use \fIoption\fR to select the printer. \fIoption\fR is null by default (which implies that TQt should be smart enough to guess correctly), but it can be set to other values to use a specific printer selection option.
The value depends on the \fCPrintingMode\fR used in the QPrinter constructor. By default, the dpi value of the screen is used.
.PP
This function must be called before setup() to have an effect on all platforms.
.PP
See also resolution() and setPageSize().
.SH "void QPrinter::setWinPageSize ( short winPageSize )"
Windows only, using this function is not portable! Sets the windows page size value that is used by the \fCDEVMODE\fR struct. The \fIwinPageSize\fR value must be one of the DMPAPER_ defines from wingdi.h.