Search This Blog

Thursday, September 8, 2011

Genereate PDF from Report using X++

static void krishh_ReportPDF(Args _args)
{
    args                args;
    ReportRun           rr;
    Report              rb;
    PrintJobSettings    pjs;
    CustInvoiceJour     record;
    ;
    select record;
    if (record.TableId != tableNum(docuRef))
    {
        args = new Args('salesinvoice');
        args.record(record);
        args.parmEnum(PrintCopyOriginal::Copy);
        rr = new ReportRun(Args,'');
        rb  = rr.report();
        rr.suppressReportIsEmptyMessage(true);  // no more "Report is empty..." stuff
        rb.interactive(false);
        rr.query().interactive(false);
        rr.init();
        pjs = rr.printJobSettings();
        pjs.virtualPageHeight(0);
        pjs.fitToPage(true);
        pjs.setTarget(PrintMedium::File);
        pjs.viewerType(ReportOutputUserType::PDF);
        pjs.format(printFormat::PDF);
        pjs.fileName('d:\\ole2.pdf');
        rr.run();
    }
}

1 comment:

  1. hello Krishh

    I have a question and would like to know if you know how.

    I'm developing a wcf service in ax2012 that returns a pdf with the invoice, and I could not make me streaming returns a pdf

    I would appreciate if you have any idea how to do

    ReplyDelete

Thanks for visiting my blog,
I will reply for your comment within 48 hours.

Thanks,
krishna.