system.print.createPrintJob
This function is used in Python Scripting.
Description
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:
Property | Description |
---|---|
Show Print Dialog | 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] |
Fit To Page | If the component is too big or small to fit on a page, it will be proportionately zoomed out or in until it fits into the page. [**default: 1]** |
Zoom Factor | 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 |
Orientation | The orientation that the page will be printing at. 1 for Portrait, 0 for Landscape. [default: 1] |
Page Width | The width of the paper in inches. [default: 8.5] |
Page Height | The height of the paper in inches. [default: 11] |
Left Margin, Right Margin, Top Margin, Bottom Margin | The margins, specified in inches. [default: 0.75] |
Printer Name | The name of the printer that this will default print to, if available. |
The properties of the PrintJob object can be altered before printing the document.
Property | Retrieve the value with... | Set the value with... |
---|---|---|
Show Print Dialog | .isShowPrintDialog() | .setShowPrintDialog(boolean) |
Fit To Page | .isFitToPage() | .setFitToPage(boolean) |
Zoom Factor | .getZoomFactor() | .setZoomFactor(double) |
Orientation | .getOrientaion() | .setOrientation(int) |
Page Width | .getPageWidth() | .setPageWidth(float) |
Page Height | .getPageHeight() | .setPageHeight(float) |
Left Margin | .getLeftMargin | .setLeftMargin(float) |
Right Margin | .getRightMargin() | .setRightMargin(float) |
Top Margin | .getTopMargin() | .setTopMargin(float) |
Bottom Margin | .getBottomMargin() | .setBottomMargin(float) |
Printer Name | .getPrinterName() | .setPrinterName(string) |
All Margins* | - | .setMargins(float) |
All Margins isn't a property of the PrintJob, but rather all four of the PrintJob's Margins can be set at the same time using that function.
Client Permission Restrictions
This scripting function has no Client Permission restrictions.
Syntax
system.print. createPrintJob( component )
Parameters
Type | Parameter | Description |
---|---|---|
Component | component | The component that you'd like to print. |
Returns
JythonPrintJob
- A print job that can then be customized and started. To start the print job, use .print().
Scope
Client
Code Examples
# Put this code on a button to print out an image of the container the button is in.
# A print dialog box will be displayed, allowing the user to specify various aspects of the print job.
job = system.print.createPrintJob(event.source.parent)
job.print()
# Put this code on a button to print out an image of components in a container component,
# giving very specific print options and removing the ability for the user to configure the print job.
job = system.print.createPrintJob(event.source.parent.getComponent('Container'))
job.setShowPrintDialog(0)
job.setPageHeight(3)
job.setPageWidth(5)
job.setMargins(.5)
job.setOrientation(0)
job.print()