How to: Print a Range of Pages from a Report (MorphX Reporting Tools) [AX 2012]

Updated: March 8, 2011

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

Print a specified range of pages from a report by using the PrintJobSettings.allPages, PrintJobSettings.from, and PrintJobSettings.to methods.

In the following example, pages 2–4 from a report are printed to a .pdf file. The ReportRun.setTarget method specifies a file as the print medium. The printJobSettings.format and printJobSettings.fileName methods specify the file format and the file name.

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();

}

Community Additions

ADD
Show: