Print a report from the server

Print a report from the machine where your Genero Report Engine (GRE) is executing. This can be a local machine or a remote server.

To send a report directly to a printer, call fgl_report_selectDevice("Printer"). The report is printed silently, without prompting the user.

Note: To preview the report before printing, or to display a printer dialog, you will use the SVG output option. See View report in the Genero Report Viewer.

To specify how the report is printed:

  • Set page margins - The logical margins of the report page are read from the 4rp file (report design document). To override those margins, call the fgl_report_setPageMargins() function. For example:

    CALL fgl_report_setPageMargins(
        ".05cm", # topMargin 
        ".05cm", # bottomMargin 
        ".05cm", # leftMargin 
        ".05cm"  # rightMargin 
    )
  • Set print quality - To control the quality of the printed report, call the fgl_report_setPrinterPrintQuality() function. The quality can be draft, high, or normal. For example:
    CALL fgl_report_setPrinterPrintQuality("high")
  • Print double-sided - To specify whether the report should be print on the front and back of the paper, call the fgl_report_setPrinterSides() function. The possible values are:

    • one-sided: Each consecutive print-stream page is printed on the same side of consecutive media sheets.
    • two-sided-short-edge: Consecutive pairs of print stream pages are printed on the front and back sides of consecutive media sheets. The orientation of the pages is correct as if the pages were to be bound along the short edge of the paper.
    • two-sided-long-edge: Consecutive pairs of print stream pages are printed on the front and back sides of consecutive media sheets. The orientation of the pages is correct as if the pages were to be bound along the long edge of the paper.

    For example:

    CALL fgl_report_setPrinterSides("two-sided-long-edge")
  • Select a paper tray - To control which paper tray is used, call the fgl_report_setPrinterMediaTray() function. The paper tray can be one of the following: bottom|envelope|large-capacity|main|manual|middle|side|top. For example:
    CALL fgl_report_setPrinterMediaTray("top")
  • Print multiple copies - By default, one copy of the report is printed. To print more than one copy, call the fgl_report_setPrinterCopies() function:
    CALL fgl_report_setPrinterCopies(20)

See the Printer Functions table for the full list of functions to configure printers.

Example

#Print a report using the settings from the explanations in this topic
IF fgl_report_loadCurrentSettings(reportname) THEN
    CALL fgl_report_selectDevice("Printer")
    CALL fgl_report_setPageMargins(
        ".05cm", # topMargin 
        ".05cm", # bottomMargin 
        ".05cm", # leftMargin 
        ".05cm"  # rightMargin 
    )
    CALL fgl_report_setPrinterPrintQuality("high")
    CALL fgl_report_setPrinterSides("two-sided-long-edge")
    CALL fgl_report_setPrinterMediaTray("top")
    CALL fgl_report_setPrinterCopies(20)
    LET HANDLER = fgl_report_commitCurrentSettings()
ELSE
    EXIT PROGRAM
END IF