Output to a printer (PHP)

Set up and configure output to a printer from your reporting application. The report is printed silently, without prompting the user.

  • Send output directly to the printer - you can send the output to a printer without previewing by calling the selectDevice() function as part of your report configuration function with the parameter "Printer":
    $greRunnerObj->selectDevice('Printer')
  • Set page margins - the logical margins of the report page are read from the 4rp file (Report Design document.) The setPageMargins() function overrides those margins:

    $greRunnerObj->setPageMargins(
        '.05cm',#  topMargin String,
        '.05cm',#  bottomMargin String,
        '.05cm',#  leftMargin String,
        '.05cm' #  rightMargin String
    );
  • Set print quality - the setPrinterPrintQuality() function is used to control the quality used by the printer. By default this is not set. Setting this option reduces the set of usable printers to those matching it.
    One of these values are passed to the function as a parameter: draft|high|normal. The value is passed as a String, for example:
    $greRunnerObj->setPrinterPrintQuality('high');
  • Print double-sided - the function setPrinterSides() is used to specify whether the report pages should be one-sided or two-sided. By default this is not set. Setting this option reduces the set of usable printers to those matching it.

    One of these values are passed to the function as a parameter. The value is passed as a String:

    • 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.
    $greRunnerObj->setPrinterSides('two-sided-long-edge');
  • Select a paper tray - the function setPrinterMediaTray() controls what tray of the printer to use.

    One of these String values is passed to the function as a parameter: bottom|envelope|large-capacity|main|manual|middle|side|top.

    $greRunnerObj->setPrinterMediaTray('top');
  • Identify the printer and paper source - the functions setSVGPrinterName() and setSVGPaperSource() determine where your report is printed:
    $greRunnerObj->setSVGPrinterName('Balzac');
    $greRunnerObj->setSVGPaperSource('Tray 2');
  • Silently print the report (optional) - the function configureSVGPreview('PrintOnNamedPrinter') bypasses the preview and prints silently on the named printer:
    $greRunnerObj->configureSVGPreview('PrintOnNamedPrinter');

For the full list of properties and methods, refer to the Genero Report Writer PHP API documentation.