Visual Studio的Crystal报表运行时基础是否支持分配打印机?



我已经使用Crystal报告基本运行时2008(10.5)超过3年了。大约一年前,我升级到微软Visual Studio(13)的最新开发版本,并安装了service pack 2。但我发现设置PrintOptions。如果报表已经具有打印机名称,则报表文档上的PrinterName不起作用。这里和这里都有轮廓。

// This is the old and reliable way - didn't work for version 13
Settings = new PrinterSettings();
Settings.PrinterName = "HP Printer";
_report.PrintOptions.PrinterName = Settings.PrinterName;
// for version 13 you have to assign the printer settings
if(_report.PrintOptions.PrinterName != Settings.PrinterName)
    _report.PrintToPrinter(Settings, new PageSettings(), false);

在运行时更改打印机名称的唯一方法是创建一个新的打印机设置对象并分配所需的打印机名称。这样做的问题是,它给最基本的打印作业增加了一分钟以上的时间。我不得不执行一个艰难的回滚到10.5版本,我仍然在使用visual studio 2013。

有人使用过更新后的服务包(9或10)吗?

他们修复bug的文档没有提到这个问题已经修复。我正在考虑再次升级,以解决版本10.5中缺少的一些功能。

我读到SAP不会修复任何与printtopprinter有关的东西!

打印机分配的问题(bug)仍然存在,改变的是它不再需要2-3分钟来分配整个打印机设置对象。此外,SAP建议现在有更好的打印方式。

因此,如果打印机名称分配不"接受",我试图通过仅使用printtopprinter过载来避免它:

// Attempt to assign just the printer name
_report.PrintOptions.PrinterName = Settings.PrinterName;
// Check if the name change worked, if not, PrintToPrinter with the settings object
if(_report.PrintOptions.PrinterName != Settings.PrinterName)
    _report.PrintToPrinter(Settings, new PageSettings(), false); // print with settings
else
    _report.PrintToPrinter(Settings.Copies, Settings.Collate, 0, 0); // print with printer name

SAP建议使用_report.ReportClientDocument.PrintOutputController.PrintReport(options)而不是_report. printtopprinter(…)。我的可重复测试表明,这种方法在假脱机作业方面至少要快三倍!(我用stopWatch,一遍又一遍地打印相同的18页静态报告。printtopprinter每次运行大约需要9秒,而下面的方法平均为3秒)

// Create the printer options
var options = new PrintReportOptions
{
    PrinterName = Settings.PrinterName,
    Collated = Settings.Collate,
    NumberOfCopies = Settings.Copies,
    JobTitle = _report.Name,       
};
// pass the options to the print method
_report.ReportClientDocument.PrintOutputController.PrintReport(options);

最新更新