将 SSRSReport 打印到文件 (.PDF)
Print SSRSReport to file (.PDF)
我需要找到一种方法 "print" SrsReport
,在我的例子中 SalesInvoice
,作为 .PDF(或任何类型的文件)到特定位置。
为此,我修改了 SRSPrintDestinationSettings
以将 SalesInvoice-Report 输出为 .PDF:
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(@'\AXDEV\Bottomline\Test\test.pdf');
不知怎的,这被忽略了,我收到了一封电子邮件,其中附有 .PDF 格式的报告。
例如,这将 运行 在 ax 2012 上,但不会为我打印成 PDF。
SRSPrintDestinationSettings settings;
CustInvoiceJour custInvoiceJour;
SrsReportRunController controller = new SrsReportRunController();
PurchPurchaseOrderContract rdpContract = new PurchPurchaseOrderContract();
SalesInvoiceContract salesInvoiceContract = new SalesInvoiceContract();
select firstOnly1 * from custInvoiceJour where custInvoiceJour.SalesId != "";
// Define report and report design to use
controller.parmReportName(ssrsReportStr(SalesInvoice,Report));
// Use execution mode appropriate to your situation
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
rdpContract.parmRecordId(custInvoiceJour.RecId);
controller.parmReportContract().parmRdpContract(rdpContract);
// Explicitly provide all required parameters
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
controller.parmReportContract().parmRdpContract(salesInvoiceContract);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo()); // comment this code if tested in pre release
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(@'\AXDEV\Bottomline\Test\test.pdf');
//tokens = settings as SrsPrintDestinationTokens();
//controller.parmPrintDestinationTokens(null);
//Suppress report dialog
controller.parmShowDialog(false);
// Execute the report
controller.startOperation();
问题:
这是将 srsReport 打印为 .pdf 的正确方法吗?
我 passing/setting 打印机设置正确吗?
哪里写的 "Send Email"?
编辑:代码运行良好。我们正在使用一家公司的外部代码,它根本没有实现这一点。
使用 Alex Kwitny
更清晰的代码
由于您谈论的是销售发票,因此报告正在使用打印管理功能,您不能像那样简单地覆盖打印设置。
您需要覆盖控制器 class 上的 runPrintMgmt
并确定您是想要默认打印管理还是您自己的代码。
查看此 post 示例:http://www.winfosoft.com/blog/microsoft-dynamics-ax/manipulating-printer-settings-with-x
这是适合我的工作代码。我只是快速地从 scratch/memory 中根据对您的一瞥进行了编码,因此请比较差异。
我有两个标记为 (1) 和 (2) 的东西供您尝试使用您的代码,或者只是 copy/paste 我的代码。
static void JobSendToPDFInvoice(Args _args)
{
SrsReportRunController controller = new SrsReportRunController();
SRSPrintDestinationSettings settings;
CustInvoiceJour custInvoiceJour = CustInvoiceJour::findRecId(5637925275);
SalesInvoiceContract salesInvoiceContract = new SalesInvoiceContract();
Args args = new Args();
controller.parmReportName(ssrsReportStr(SalesInvoice, Report));
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
controller.parmShowDialog(false);
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId);
salesInvoiceContract.parmDocumentTitle(CustInvoiceJour.InvoiceId);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
// (1) Try by passing args
args.record(custInvoiceJour);
args.parmEnum(PrintCopyOriginal::Original);
args.parmEnumType(enumNum(PrintCopyOriginal));
controller.parmReportContract().parmRdpContract(salesInvoiceContract);
controller.parmArgs(args);
// (2) Try explicitly preventing loading from last value
// controller.parmLoadFromSysLastValue(false);
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(@'C:\Temp\Invoice.pdf');
controller.startOperation();
}
我需要找到一种方法 "print" SrsReport
,在我的例子中 SalesInvoice
,作为 .PDF(或任何类型的文件)到特定位置。
为此,我修改了 SRSPrintDestinationSettings
以将 SalesInvoice-Report 输出为 .PDF:
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(@'\AXDEV\Bottomline\Test\test.pdf');
不知怎的,这被忽略了,我收到了一封电子邮件,其中附有 .PDF 格式的报告。
例如,这将 运行 在 ax 2012 上,但不会为我打印成 PDF。
SRSPrintDestinationSettings settings;
CustInvoiceJour custInvoiceJour;
SrsReportRunController controller = new SrsReportRunController();
PurchPurchaseOrderContract rdpContract = new PurchPurchaseOrderContract();
SalesInvoiceContract salesInvoiceContract = new SalesInvoiceContract();
select firstOnly1 * from custInvoiceJour where custInvoiceJour.SalesId != "";
// Define report and report design to use
controller.parmReportName(ssrsReportStr(SalesInvoice,Report));
// Use execution mode appropriate to your situation
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
rdpContract.parmRecordId(custInvoiceJour.RecId);
controller.parmReportContract().parmRdpContract(rdpContract);
// Explicitly provide all required parameters
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
controller.parmReportContract().parmRdpContract(salesInvoiceContract);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo()); // comment this code if tested in pre release
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(@'\AXDEV\Bottomline\Test\test.pdf');
//tokens = settings as SrsPrintDestinationTokens();
//controller.parmPrintDestinationTokens(null);
//Suppress report dialog
controller.parmShowDialog(false);
// Execute the report
controller.startOperation();
问题: 这是将 srsReport 打印为 .pdf 的正确方法吗? 我 passing/setting 打印机设置正确吗? 哪里写的 "Send Email"?
编辑:代码运行良好。我们正在使用一家公司的外部代码,它根本没有实现这一点。 使用 Alex Kwitny
更清晰的代码由于您谈论的是销售发票,因此报告正在使用打印管理功能,您不能像那样简单地覆盖打印设置。
您需要覆盖控制器 class 上的 runPrintMgmt
并确定您是想要默认打印管理还是您自己的代码。
查看此 post 示例:http://www.winfosoft.com/blog/microsoft-dynamics-ax/manipulating-printer-settings-with-x
这是适合我的工作代码。我只是快速地从 scratch/memory 中根据对您的一瞥进行了编码,因此请比较差异。
我有两个标记为 (1) 和 (2) 的东西供您尝试使用您的代码,或者只是 copy/paste 我的代码。
static void JobSendToPDFInvoice(Args _args)
{
SrsReportRunController controller = new SrsReportRunController();
SRSPrintDestinationSettings settings;
CustInvoiceJour custInvoiceJour = CustInvoiceJour::findRecId(5637925275);
SalesInvoiceContract salesInvoiceContract = new SalesInvoiceContract();
Args args = new Args();
controller.parmReportName(ssrsReportStr(SalesInvoice, Report));
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
controller.parmShowDialog(false);
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId);
salesInvoiceContract.parmDocumentTitle(CustInvoiceJour.InvoiceId);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
// (1) Try by passing args
args.record(custInvoiceJour);
args.parmEnum(PrintCopyOriginal::Original);
args.parmEnumType(enumNum(PrintCopyOriginal));
controller.parmReportContract().parmRdpContract(salesInvoiceContract);
controller.parmArgs(args);
// (2) Try explicitly preventing loading from last value
// controller.parmLoadFromSysLastValue(false);
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(@'C:\Temp\Invoice.pdf');
controller.startOperation();
}