Printer (gb.qt4)

This class allows to print documents on printers, or save them in a file.

This class is creatable.

Constants
A3   Paper size of 297 × 420 mm.
A4   Paper size of 210 × 297 mm, 8.26 × 11.69 inches.
A5   Paper size of 148 × 210 mm.
B5   Paper size of 182 × 257 mm, 7.17 × 10.13 inches.
Custom   Custom paper size.
Executive   Paper size of 7.5 × 10 inches, 191 × 254 mm.
Horizontal   Both sides of each sheet of paper are used for printing. The paper is turned over its horizontal edge.
Landscape   The page's width is greater than its height.
Legal   Paper size of 8.5 × 14 inches, 216 × 356 mm.
Letter   Paper size of 8.5 × 11 inches, 216 × 279 mm.
Portrait   The page's height is greater than its width.
Simplex  
Vertical   Both sides of each sheet of paper are used for printing. The paper is turned over its vertical edge.

Static properties
Default   Return the name of the default printer.
List   Return the list of printers.

Properties
CollateCopies   Return or set if multiple copies are collated or not.
CopyCount   Return or set the number of copies that will be printed.
Count   Return or define the number of pages in the printed document.
Duplex   Return or set the printing duplex mode.
FirstPage   Return or set the first page that must be printed.
FullPage   Return or set if drawing page will be done inside the margins (FullPage is FALSE), or on the entire page (FullPage is TRUE).
GrayScale   Return or set if printing is done by using gray scale, or full colors.
LastPage   Return or set the last page that must be printed.
Name   Return or set the printer name.
NumCopies   Return or set the number of copies that will be printed.
Orientation   Return or set the printing orientation.
OutputFile   Return or set the path of the PDF or PostScript output file.
Page   Return the current page that must be printed.
Paper   Return or set the kind of paper used for printing.
PaperHeight   Return or set the custom paper height in millimeters.
PaperWidth   Return or set the custom paper width in millimeters.
Resolution   Return or set the printer resolution, in DPI (Dots Per Inches).
ReverseOrder   Return or set if the document pages will be printed in reverse order.

Methods
Cancel   Abort the current printing job.
Configure   Open the printer configuration dialog.
Print   Run the printing process.

Events
Begin   This event is raised when the print starts.
Draw   This event is raised for each page that must be printed.
End   This event is raised when the print is finished.
Paginate   This event is raised so that you can paginate your document in the background.

Printing a document

To print a document:
  • Instanciate a Printer object.

  • Call the Configure method. A printing configuration dialog is displayed.

  • Call the Print method to run the printing process.

  • The Begin event is raised when the print starts. You should define the number of pages to print inside the Begin event handler, by setting the Count property.

  • If you don't define the Count property during the Begin event handler, the Paginate event will be raised again and again until that property is finally defined.

  • The Draw event is raised for each page that must be printed.

  • The End event is raised when the print terminates.

Paint.Begin is automatically called just before the Begin event, and Paint.End just after the End event.

You don't have to call them "by hand".

See also