AX 2009 Reports To PDF automatically

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.

Please Reply…

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 Thomas,

Thanks for your prompt reply. I have checked the link sent by you (http://dynamics-ax-live.blogspot.fr/2009/09/how-to-run-report-by-code.html%20or%20http://stackoverflow.com/questions/3840492/print-report-in-microsoft-dynamics-ax-2009-through-x)

But the page is not displaying the information.

Please check.

Check this.

split the links at the ‘%20or%20’ position::

http://dynamics-ax-live.blogspot.fr/2009/09/how-to-run-report-by-code.html

http://stackoverflow.com/questions/3840492/print-report-in-microsoft-dynamics-ax-2009-through-x)

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.