Sometimes, we need Morthx X++ code to run batch reports to PDF Printer,
so I wrote the following code as a backup for future work
static void Jimmy_ReportPrintToPDF(Args _args) { Args args; ReportRun rr; str reportName = "Your Report Name"; FilePath FilePath; ; try { args = new Args(reportName); rr = new ReportRun(args,'');// rr = classFactory.reportRunClass(args); FilePath = Strfmt("%1/%2%3",WinAPI::getTempPath(),reportName2Pname(reportName),".pdf"); if(WINAPI::fileExists(FilePath)) WINAPI::deleteFile(FilePath); rr.setTarget(Printmedium::File); rr.printJobSettings().format(PrintFormat::PDF); rr.printJobSettings().fileName(FilePath); // rr.printJobSettings().mailCc("Jimmyx@xxxxxx.com.cn"); // rr.printJobSettings().allPages(false); // rr.printJobSettings().from(2); // rr.printJobSettings().to(4); rr.query().interactive(false); rr.report().interactive(false); rr.run(); } catch { throw Error("Run Report Error!"); } if(WINAPI::fileExists(FilePath)) WINAPI::shellExecute(FilePath); info("Finished!"); }