2 summary:: QPen PDF export and printing of vector graphics
3 categories:: GUI>Printing
4 related:: Classes/QPen, Classes/Pen
7 QPenPrinter allows QPen to operate on a printer device. The graphics can be exported to PDF by using "print to file" as printer device.
14 Create a new QPenPrinter object.
16 returns:: an instance of QPenPrinter
19 Convenience function to show a print dialog and print.
22 A link::Classes/Function:: to be evaluated when the user presses "Print", with the printer object as QPen painter target.
23 See strong::aPrintFunc:: in link::#-print:: below.
26 An optional link::Classes/Function:: to be evaluated if the user presses "Cancel".
35 Shows a Print Dialog to allow the user to configure the printer object. This is asynchronous and the method will return immediately.
36 When the user presses the "Print" button, strong::aOkFunc:: is called with this QPenPrinter object as argument.
39 A link::Classes/Function:: to be evaluated when the user presses "Print".
41 argument:: aCancelFunc
42 An optional link::Classes/Function:: to be evaluated if the user presses "Cancel".
46 This method does the actual printing or PDF export. It evaluates strong::aPrintFunc:: with the printer object as QPen painter target. This QPenPrinter object is passed as the argument.
48 All the ordinary link::Classes/QPen:: commands can be used inside the function.
51 A link::Classes/Function:: to be evaluated to draw the graphics.
54 If this method is called without configuring the printer object first, it will print on the default printer with default settings.
56 This method is typically called from within the strong::aOkFunc:: of link::#-showDialog:: above. After showDialog has configured the printer once, this method can be called multiple times to reuse the last printer configuration.
58 The point at (0@0) will coincide with the origin of link::#-pageRect::, which is offset by the page margins. So you don't need to translate the Pen.
62 Starts a new page. Typically called within the strong::aPrintFunc:: of link::#-print::.
65 subsection:: Properties
70 returns:: a link::Classes/Rect::
74 Get the page bounds, which is the printable area and usually smaller than link::#-paperRect:: due to margins.
76 returns:: a link::Classes/Rect::
79 The strong::origin:: of the Rect is relative to the paper, and will be non-zero due to margins.
83 Get the page size as a Size.
85 returns:: a link::Classes/Size::
88 This can be used to scale the graphics to fit the page if the bounds of the graphics is known:
90 x = penPrinter.pageSize.width / bounds.width;
92 // ... draw stuff here ...
95 subsection:: Page range
96 The methods below returns the page range selected by the user. Page number starts at 1. When both methods returns 0 it means "print all pages".
101 returns:: an link::Classes/Integer::
106 returns:: an link::Classes/Integer::
122 Pen.addRect(p.pageSize.asRect);
127 Keep the QPenPrinter object to save configuration state:
131 The code below can then be called multiple times:
142 Pen.addRect(p.pageSize.asRect);
146 "Printing cancelled!".postln;