将SSRSReport打印到文件(.PDF)
我需要找到一种方法将将SSRSReport打印到文件(.PDF),pdf,printing,axapta,dynamics-ax-2012,x++,Pdf,Printing,Axapta,Dynamics Ax 2012,X++,我需要找到一种方法将srsrsrsreport(在我的例子中是saleinvoice)作为.PDF(或任何类型的文件)打印到特定位置 为此,我修改了SRSPrintDestinationSettings以.PDF格式输出SalesInvoice报告: settings = controller.parmReportContract().parmPrintSettings(); settings.printMediumType(SRSPrintMediumType::File); settings
srsrsrsreport
(在我的例子中是saleinvoice
)作为.PDF(或任何类型的文件)打印到特定位置
为此,我修改了SRSPrintDestinationSettings
以.PDF格式输出SalesInvoice报告:
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();
问题:
这是将SRS报告打印到.pdf的正确方法吗?
我是否正确通过/设置打印机设置?
哪里写着“发送电子邮件”
编辑:代码运行良好。我们使用的是一家公司的外部代码,它根本没有实现这一点。
使用Alex Kwitny的清洁代码因为您谈论的是销售发票,报告使用的是打印管理功能,您不能简单地覆盖这样的打印设置 您需要覆盖控制器类上的
runPrintMgmt
,并在那里确定是要使用默认打印管理还是您自己的代码
请参阅本文以获取示例:这里是我的工作代码。我只是在浏览了一下你的基础上,快速地从零开始/记忆中编写了这个代码,所以比较一下差异 我有两个标记为(1)和(2)的东西供您尝试使用代码,或者只是复制/粘贴我的代码
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();
}
不,所以我真的需要覆盖它。我想我可以绕过这个;/。谢谢你的链接。我会尽快尝试。我不相信你需要这么做,请看下面我的答案。他使用的是
srsrreportruncontroller
,而不是SrsPrintMgmtController
代码与我的代码相同,但更好:D。代码应该对其他所有人都适用。问题是我的公司使用了一种叫做底线的技术。看起来它还不支持PDF输出。我将不得不修改它。谢谢你的帮助