26 Ocak 2016 Salı

AX 2009 - Run report at back ground as PDF output

Make Interactive property of report as No. It's easy make it as run for html with change  PrintMedium enum's value.

     DocuType                docuType;
    TextIo                  textIo;
    FileIOPermission        fioPermission;
    #File
    ReportRun report;
    ;

    docuType = DocuType::find("Temp");
    fileName = strfmt(@"%1My Test Report.PDF",   docuType.ArchivePath);
   
    fioPermission = new FileIOPermission(fileName ,"RW");
    fioPermission.assert();

    if(Global::isRunningOnServer())
    {
        if(WinAPIServer::fileExists(fileName))
            WINAPIServer::deleteFile(fileName);
    }
    else
    {
        if(WinAPI::fileExists(fileName))
            WINAPI::deleteFile(fileName);
    }

    report = new ReportRun(new  Args(ReportStr(KRC_InventCoverReport)));
    report.printJobSettings().setTarget(PrintMedium::File);
    report.printJobSettings().preferredTarget(PrintMedium::File);
    report.printJobSettings().format(PrintFormat::PDF);
    report.printJobSettings().fileName(fileName);
    report.query().interactive(false);
    report.run();

Hiç yorum yok:

Yorum Gönder