将销售报价报告打印到PDF AX 2009

时间:2013-05-30 15:59:01

标签: axapta dynamics-ax-2009 ax

我目前正在使用AX 2009 SP1 Rollup 7.我正在尝试创建PDF,当我的方法运行时,将CustQuotationJour表中的报价ID发送到SalesQuotation报表。

该方法正常,但报告将发送到“打印预览”屏幕,而不是创建PDF。我假设其SalesQuotation报告重置我的打印设置还原为屏幕。我的猜测是在fetch方法中,但我不应该修改它,对吗?

我可能缺少其他打印设置吗? 提前致谢

ReportRun                   salesQuotationReport;
Args                        args = new Args();
PrintJobSettings            printJobSettings;
CustQuotationJour           custQuotationJour;
;

custQuotationJour = CustQuotationJour::findFromSalesQuotationQuotation(_quotationId);


args.name(reportStr(SalesQuotation));
args.record(custQuotationJour);
salesQuotationReport = new ReportRun(args);
salesQuotationReport.init();

printJobSettings = salesQuotationReport.printJobSettings();
printJobSettings.setTarget(PrintMedium::File);
printJobSettings.preferredTarget(PrintMedium::File);
printJobSettings.format(PrintFormat::PDF);
printJobSettings.preferredFileFormat(PrintFormat::PDF);
printJobSettings.fileName(_path);

salesQuotationReport.unpackPrintJobSettings(printJobSettings.packPrintJobSettings());
salesQuotationReport.run();

2 个答案:

答案 0 :(得分:3)

所以这是我的评论转换成答案......

添加以下行;

printSettings.lockDestinationProperties(true);

这将阻止报告中的任何代码覆盖您的printSettings。

答案 1 :(得分:0)

我在AX 2012上做过类似的销售确认,但这有效:)

该方法位于CustComfirmJour表中,因此this指的是已确认的记录。

FileName saveAs(FileName fileName)
{
    SalesConfirmController      salesConfirmController;
    SalesConfirmContract        salesConfirmContract;
    SRSPrintDestinationSettings printSettings;
    Args                        args = new Args();
    ;
    args.record(this);
    salesConfirmController = new SalesConfirmController();
    salesConfirmController.parmReportName(ssrsReportStr(SalesConfirm,Report));
    salesConfirmController.parmArgs(args);
    salesConfirmController.parmReportContract().parmRdlContract().parmLanguageId(this.LanguageId);
    salesConfirmContract = salesConfirmController.parmReportContract().parmRdpContract();
    salesConfirmContract.parmRecordId(this.RecId);
    printSettings = salesConfirmController.parmReportContract().parmPrintSettings();
    printSettings.printMediumType(SRSPrintMediumType::File);
    printSettings.overwriteFile(true);
    printSettings.fileFormat(SRSReportFileFormat::PDF);
    fileName = printSettings.fileName(fileName);
    salesConfirmController.runReport();
    return fileName;
}

这在AX 2009中无效。

此处Axaptapedia中记录的方法应该有效但不行!

FileName saveAs(FileName fileName)
{
    ReportRun                   report;
    PrintJobSettings            printSettings;
    Args                        args = new Args(reportStr(SalesConfirm));
    ;
    args.record(this);
    report = classfactory.reportRunClass(args);
    report.init();
    printSettings = report.printJobSettings();
    printSettings.setTarget(PrintMedium::File);
    printSettings.preferredTarget(PrintMedium::File);
    printSettings.format(PrintFormat::PDF);
    printSettings.preferredFileFormat(PrintFormat::PDF);
    printSettings.fileName(fileName);
    printSettings.lockDestinationProperties(true); //Did the trick!?!
    report.unpackPrintJobSettings(printSettings.packPrintJobSettings());
    report.run();
    return fileName;
}

运行:

static void SalesConfirmSaveAs(Args _args)
{
    CustConfirmJour jour;
    select firstonly jour;
    jour.saveAs(@"V:\Temp\confirm.pdf");
}

输出进入屏幕!

也许报告本身搞乱了?

更新:已添加printSettings.lockDestinationProperties(true);但尚未测试。