Ask Reuben

DBPRINT=FGLSERVER

How can I print to the printer connected to my Work Station ?

How can I prompt the user to select a printer ?

START REPORT TO PRINTER

The START REPORT TO PRINTER command prints the report on the printer specified by the DBPRINT environment variable.  With historical TUI applications on UNIX systems, this would typically be the same printer lp printed to.

In transforming to GUI rendering with the Genero Desktop Client, the question would get asked how do I print to the printer connected to my Workstation?  Remembering that with GUI applications and the client server architecture, the fglrun process is running on the Application Server and the gdc process is running on your front end Workstation.  The fglrun process only knows about the printer connected to the Application Server.

The technique is to set the DBPRINT environment variable to a special value “FGLSERVER”.  This routes the report output through to the printer configured on the Genero Desktop Client.  The Report Configuration page allows the user to change values but is typically left on the default values of using the default printer.

What the developer can do is override the values on the Report Configuration page with two standard front-calls.  The setReportPrinter front-call can be used to control the printer and the setReportFont can be used to control the font.  Refer to to the documentation for the expected parameter values and note the special values that can also be used. The typical usage might be to use one of the special values like so …

CALL ui.Interface.frontCall("standard","setReportPrinter","<ASK_ALWAYS>",[result])

… so that the user is prompted with a dialog allowing them to select the printer.  This is the same dialog as if you were to go File->Print in any other application on your desktop.


shellExec Print

If the report file has already been generated, there is a handy feature to print the report file again.  The shellExec front-call has an optional second argument.  If the normal shellExec can be thought of as the equivalent of double-clicking a file in Windows Explorer and opening it with the program associated to the file extension, if you use the second optional argument to Print then this is the equivalent of right-clicking on the file in Windows Explorer and selecting Print.

CALL ui.Interface.frontCall("standard", "shellExec",[filename, "Print"], [result])


Print Immediately in a Web Environment

When using the Genero Web Client and now the Genero Browser Client, there is no equivalent ability to print immediately to a printer connected to the Work Station.  Remember in web environments, there are rules about what a web page can and can’t do.  One of them is that a web page can’t start printing pages without any form of user action.  If you wonder why this is, ask yourself what could a malicious web site do if it had the ability?  Would you want ads to start printing on your printer?

Your options are to :-

  • Save the report to file and display the report file via launchUrl front-call so that the user can manually select to print
  • OR configure your printer so that it is known to the application server and then set DBPRINT to the appropriate value (not FGLSERVER) so that  START REPORT TO PRINTER can print to it.  In corporate environments this is the path normally chosen, that is put your printer on the network.

Genero Report Writer

Genero Report Writer uses START REPORT TO XML HANDLER and so you can’t rely on DBPRINT=FGLSERVER as START REPORT TO PRINTER is not used.

Immediate printing to a server side printer is controlled by the fgl_report_selectDevice method where you can pass a value of “Printer” and then use the various fgl_report_setPrinter* methods to control various printer options such as what tray etc.  The important method being fgl_report_setPrinterName to set what printer.  Like with Web environments, the printer must be known to the Application Server.

There is also a solution for printing to a client side printer similar to what DBPRINT=FGLSERVER accomplishes.  With fgl_report_selectDevice use the “SVG” argument and then use fgl_report_configureSVGPreview to control the Print Dialog behaviour.  So …

CALL fgl_report_selectDevice("SVG")
CALL fgl_report_configureSVGPreview("ShowPrintDialog")

… to select and configure a printer.

With Genero Report Writer in Web you have the same restriction of not being able to print immediately to a client slide printer.  You either print immediately to a server side printer, or the user has to manually select print e.g. File->Print from the report viewer.  If using fgl_report_selectDevice("Browser") the user can use the printer icon in the viewer as pictured below to print the file.