Save AOT Report as pdf on Report level code in Ax 2009

Write this code on Report Fetch method

public boolean fetch()
{
boolean retCode = false;
ReportValidation bankAccountTableRec;
QueryRun qrun;
int a=1;
int cpt = 0;

;
// Use the queryRun object that is associated with the
// report; element refers to the report.
qrun = new QueryRun(element);

// Verify that the report dialog works.
if (! qrun.prompt())
{
return retCode;
}

// Loop through each record from the data source query of the report.
while (qrun.next())
{
// Get the BankAccountTable fields from the query record.
bankAccountTableRec = qrun.get(TableNum(ReportValidation));

// Exclude ODDBANK from the visible report.
if (bankAccountTableRec.Price != 0)
{
// Include the current record in the report.
element.send(bankAccountTableRec);
}

}

if(Some checkbox test codition)

{

element.printJobSettings().setTarget(Printmedium::File);

element.printJobSettings().format(Printformat::PDF);
element.printJobSettings().fileName(@’F:\JKG\JKG.pdf’);

}

else

{
element.printJobSettings().setTarget(Printmedium::Screen);

}
retCode = true;

// retCode = super(); // Do not call super() when you override the fetch method.
return retCode;

}

 

OUTPUT

rpt2pdf