Skip to main content What is Dynamics 365? Guided tours Customer stories Try our products Build your own agents CRM ERP Sales Service Sales Customer Insights Customer Service Contact Center Field Service Supply Chain Management Commerce Finance Project Operations Human Resources Business Central Pricing Business application topics Training & certifications Documentation Migrate to the cloud Private equity Migrate to Dynamics 365 Events Dynamics 365 Blog Product updates Onboarding and implementation Community Find a partner Software Development Companies Partner resources Microsoft Marketplace Product documentation Technical support On-premises product support Contact us Try for free Sign in
1 min read

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 = new reportRun(args);
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.

Get started with Dynamics 365

Drive more efficiency, reduce costs, and create a hyperconnected business that links people, data, and processes across your organization—enabling every team to quickly adapt and innovate.