Friday, September 25, 2009

How to print a report straight to the printer (and not to screen)

When a user runs a report, it's a good idea to first print it to screen. When the outcome is not what was expected, the user can change his criteria or parameters and run the report again. When the report meets the expectations, a hardcopy can be printed. Save paper, think green!

But sometimes, you'll want a report to go straight to the printer, without a user intervention. For example when you run a report by code (in a production environment, an automatic generated loading list, ...).

In these scenario's, you'll want to adjust the printer settings.

1. Set the desired printer
Add following code in the init method of your report


Make sure a printer by that name exists on the PC where the report runs.

2. Don't print to screen, print straight to printer
Add following code in the init method of your report


This will make the report go straight to the printer (instead of the screen).
You can add additional settings, like the number of copies as well.
Like this:


For automation purposes, the above code examples may be useful to run reports.


  1. Hello Willy, I'm try print straight but, the AX not open a screen to 'save as file' of type .xps. Do you have any idea?

  2. Hi,
    I set copies() and i check this parameter in fetch method in report and it has right parameter, but when it prints, it prints only 1 copy. What can be the problem?

  3. I am trying to print straight to a folder
    so Ive used the following code. SalesPackingSlipController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);

    Just wondering is there anyway to suppress the preview of the report>