Hi Pioneers,
I have created a report named “ProdTrans”, I have a requirement to place a button on report named “PDF”, by clicking on
which, the enduser can save the report in PDF format. I have searched Internet, several Blogs etc. etc. but till now I have not
got any such codings (error-free), for this mechanism. I kindly request you to please "Provide me the coding for such
mechanism"…Guys If you have used / developed / worked for REPORT 2 PDF, then kindly reply me…
Please reply pioneers…I am looking forward for help.
Hi,
I see 2 solutions :
-in the printer box that open when you want to print a report, you can select print to file avec select pdf format ==> fast and simple no coding required
-you can use the reportrun class to generate your report directly in pdf without preview :
quickly on a button clicked() method:
filename = strfmt("%1%2",reportname,".pdf");
path = “\\Server\Directory”";
report = new ReportRun(new Args(ReportStr(yourReport)));
report.query().interactive(false);
report.report().interactive(false);
report.args().caller(null);
report.args().parm(yourParm);
report.printJobSettings().setTarget(PrintMedium::File);
report.printJobSettings().format(PrintFormat::PDF);
report.printJobSettings().warnIfFileExists(false);
report.printJobSettings().fileName(strfmt("%1%2",path,filename));
report.run();
see also: http://dynamics-ax-live.blogspot.fr/2009/09/how-to-run-report-by-code.html or http://stackoverflow.com/questions/3840492/print-report-in-microsoft-dynamics-ax-2009-through-x
hope it helps, please verify solution if it solves your problem
regards
Thomas
Hi Vishal,
Thanks for your valuable suggestions, I checked with your code, but I am getting an error reg. “Invalid Lexical” on " element.printJobSettings().fileName(@’C:\temp\myfile.pdf’); ".
Kindly suggest me.