Unable to print reports as PDF files on the AX server using batch processing
We came across an issue reported to us where they were trying to automate printing of reports as PDF files using batch processing on the server. Printing reports directly worked fine and they were able to save the PDF files it generated successfully on the file system, but it only failed when using Batch.
The issue occurred because the server had not been configured to allow printing on the server. For reference here is the snippet of code that was being run to print the report on the server:
reportRun.query().interactive(False);
reportRun.report().interactive(False);
reportRun.setTarget(printMedium::File);
reportRun.printJobSettings().setTarget(PrintMedium::File);
reportRun.printJobSettings().preferredTarget(PrintMedium::File);
reportRun.printJobSettings().format(PrintFormat::PDF);
reportRun.printJobSettings().warnIfFileExists(False);
reportRun.printJobSettings().suppressScalingMessage(True);
reportRun.printJobSettings().packPrintJobSettings();
reportRun.printJobSettings().fileName(filename);
reportRun.run();
Although you are not physically printing a report to a printer and saving it to file instead, the print x++ api’s that are used require the same privileges as though you are printing to a printer on the server.
We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!