create pdf for AX reports automatically through code

Hi, Can anyone help me in saving any AX report automatically as a pdf or html document by taking arguements through code into the file system without opening the report and saving it manually. Regards, Giridhar Raj.

Hi,

This may by an answer for your question.

static void printToPDF(Args _args)
{
Args args;
ReportRun rr;
str reportName = ‘Cust’;
;

args = new Args(reportName);

rr = new ReportRun(args,’’);

rr.setTarget(Printmedium::File);
rr.printJobSettings().format(PrintFormat::PDF);

rr.printJobSettings().fileName(“C:\Cust_ReportRange.pdf”);

rr.printJobSettings().allPages(false);
rr.printJobSettings().from(2);
rr.printJobSettings().to(4);

// Disables forms that enable users to modify
// the report query and print settings.
rr.query().interactive(false);
rr.report().interactive(false);

rr.run();

}

I hope that it’s help you. More informations are in Developer Help.

Have a Look at this!

public void init()

{

super();

element.printJobSettings().setTarget(PrintMedium::File); // print format is on file

element.printJobSettings().preferredTarget(PrintMedium::File);

element.printJobSettings().format(PrintFormat::HTML);

element.printJobSettings().preferredFileFormat(PrintFormat::HTML); //file extension is pdf

element.printJobSettings().fileName(“c:\Naresh\Report1.html”); // file location and name

element.printJobSettings().warnIfFileExists(true); // dont show the option to overwrite report file

element.printJobSettings().allPages(true); // dont print all pages of report

element.printJobSettings().from(1); // print from page 2

element.printJobSettings().to(5); //print to page 5

element.query().interactive(true); // disable all dialogue

element.report().interactive(true);

}