system.print.createPrintJob
Provides a general printing facility for printing the contents of a window or component to a printer. The general workflow for this function is that you create the print job, set the options you'd like on it, and then call print() on the job. For printing reports or tables, use those components' dedicated print() functions.
The PrintJob object that this function returns has the following properties that can be set:
Property |
Description |
showPrintDialog |
If true (1), then the print dialog window will be shown before printing. This allows users to specify printing options like orientation, printer, paper size, margins, etc. [default: 1] |
fitToPage |
If the component is too wide or tall to fit on a page, it will be proportionately zoomed out until it fits into the page. [default: 1] |
zoomFactor |
If greater than zero, this zoom factor will be used to zoom the printed image in or out. For example, if this is 0.5, the printed image will be half size. If used, this zoom factor overrides the fitToPage parameter. [default: -1.0] |
orientation |
Either system.print.PORTRAIT or system.print.LANDSCAPE [default: system.print.PORTRAIT] |
pageWidth |
The width of the paper in inches. [default: 8.5] |
pageHeight |
The height of the paper in inches. [default: 11] |
leftMargin, rightMargin, topMargin, bottomMargin |
The margins, specified in inches. [default: 0.75] |
You can set all of the margins at once with job.setMargins(number) , and you initiate the printing with job.print() .
system.print. createPrintJob( component )
-
Parameters
Component component - The component that you'd like to print.
-
Returns
JythonPrintJob - A print job that can then be customized and started.
-
Scope
Client
#Put
this
code on a button to print out an image of the container the button is in
job = system.print.createPrintJob(event.source.parent)
job.setMargins(
0.5
)
job.zoomFactor =
0.75
job.print()