Friday, January 24, 2014

Save report to pdf through X++

/*Try this code for your report to make the PDF
Try this code for your report to make the PDF directly ..
Write this code in INIT method of report.*/


public void init()
{
    super();

    element.printJobSettings().setTarget(PrintMedium::Mail); // set the target of where to print

    element.printJobSettings().preferredTarget(PrintMedium::Mail); // indicate the preferred target, this verifies that the printing will go to e-mail

    element.printJobSettings().setTarget(PrintMedium::File); // set the target of where to print, in this case to file

    element.printJobSettings().preferredTarget(PrintMedium::File); // indicate the preferred target, this verifies that the printing will go to file


    element.printJobSettings().format(PrintFormat::PDF); // specify the format of the file, in this case PDF

    //path = 'c:\\Temp\\' + element.name()+ '.pdf'; // location and name of PDF file created, the name is pulled from the name of the report

    //element.printJobSettings().fileName(path);

    element.printJobSettings().fileName('c:\\Temp\\' + element.design().caption()+ '.pdf');

    element.printJobSettings().preferredMailFormat(PrintFormat::PDF); // attach the PDF file to the e-mail
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...