打印XPS文档时的例外情况 [英] Exceptions when printing XPS documents

查看:90
本文介绍了打印XPS文档时的例外情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我负责测试.NET FrameWork 3.5中可用的新XPS打印路径的打印功能,精度和性能。我正在以下打印机以及Windows XP和Vista下进行5个打印基准测试(3个合成作业和2个实际作业)的测试:



  • Lexmark 2450
  • HP LaserJet 4+
  • HP LaserJet 5
  • HP LaserJet 3300 MFP
  • HP LaserJet 4000
  • HP LaserJet 4200
  • HP LaserJet 4250
  • HP LaserJet 4350
  • HP LaserJet 8000
  • HP LaserJet 9000
  • HP LaserJet 9050
  • X. erox WorkCentre XE80
  • Xerox WorkCentre Pro 55
  • Xerox WorkCentre Pro 265
  •  Lexmark 2450
  • HP LaserJet 4+
  • HP LaserJet 5
  • HP LaserJet 3300 MFP
  • HP LaserJet 4000
  • HP LaserJet 4200
  • HP LaserJet 4250
  • HP LaserJet 4350
  • HP LaserJet 8000
  • HP LaserJet 9000
  • HP LaserJet 9050
  • Xerox WorkCentre XE80
  • Xerox WorkCentre Pro 55
  • Xerox WorkCentre Pro 265

这两个真正的基准是用Expression Blend绘制的表格并导出到XAML文件中。在运行时,这些页面将合并到FixedDocument中,并使用XpsDocumentWriter.write()方法发送到打印机。使用"Microsoft XPS Document Writer"将三个合成基准从COM对象抽取到临时XPS文件中。虚拟打印机,从我们的测试应用程序中读取,然后合并到一个FixedDocument,最后也使用XpsDocumentWriter类发送到打印机。为了您的信息,当使用传统的GDI打印路径绘制时,可以在上述大多数打印机上打印合成基准,达到内部存储器的极限。

The two real benchmarks are forms drawn with Expression Blend and exported into XAML files.  At run time, those pages are merged into a FixedDocument and sent to the printer with the XpsDocumentWriter.write() method.  The three synthetic benchmarks are drawn from a COM object into temporary XPS files using the "Microsoft XPS Document Writer" virtual printer, read from our test application, then merged into a FixedDocument and finally sent to the printer also using the XpsDocumentWriter class.  For your information, the synthetic benchmarks can be printed on most of the above mentioned printer when drawn using the traditional GDI printing path, to the limits of their internal memory.


到目前为止,我们的两个真实基准测试在所有打印机上都通过了OK,但是,合成基准测试在某些打印机上失败了,结果差异很大。一些打印作业会抛出异常,一些打印作业在假脱机后失败,有时文档不完整。我们的综合基准测试使用了很多字体,因此非常繁重。当然,一些故障可以通过打印机的内存不足(我们已经看到使用GDI打印路径)或驱动程序非最佳地使用打印机内存来解释。但是,有时,在假脱机期间会从.NET FrameWork抛出异常。通过禁用"打印优化",可以避免大多数情况下的这些例外情况。和"高级打印特征"在打印机的高级属性中。

So far, our two real benchmarks pass OK on all the printers,  But, the synthetic benchmarks fail on some printers, and results vary a lot.  Some print jobs throw exceptions, some fail after spooling and sometimes documents are incomplete.  Our synthetic benchmarks use a lot of fonts and are therefore very heavy.  Of course some of the failures are explained by the lack of memory of the printers (we've seen that using the GDI print path too) or by the non optimal use of the printer memory by the driver.  But, sometimes, exceptions are thrown from the .NET FrameWork during spooling.  Those exceptions can most of the times be avoided by disabling the "Printing Optimizations" and "Advanced Printing Features" in the printers' advanced properties.


我想了解框架代码中究竟发生了什么以及为什么抛出异常。并且可能如何避免这个问题。结果差异很大:它们似乎依赖于:打印机(驱动程序问题?),打印机配置(驱动程序问题?),操作系统(Vista vs XP)。如果你想测试任何东西,我可以提供用作XPS文件的三个综合基准。这些文件通过了所有XPS验证测试并且显示良好。使用XPS Document Viewer(Internet Explorer)打印这些文件的效果不如我的测试应用程序,除了IE不报告异常(页面不打印,但你永远不会知道为什么......哇!)我将在下一篇文章中包含Call Stacks,以便你自己检查它们。

I'd like to understand what is happening exactly in the Framework code and why it is throwing exceptions.  And possibly how to avoid the problem.  Results vary a lot : they seem to depend: on the printer (driver issue?), on the printer configuration (driver issue?), on the OS (Vista vs XP).  I can provide the three synthetic benchmarks used as XPS files if you want to test anything.  The files passed all XPS validation tests and display well.  Printing those files with the XPS Document Viewer (Internet Explorer) don't work better than from my testing application, except that IE don't report the exceptions (the pages don't print, but you won't never know why... wow!)  I will include Call Stacks in the next posts so you can check them by yourselves.


谢谢,

Charles Perreault

Charles Perreault

推荐答案

这个例外很多见过Vista,可能与打印问题无关。仅在从VS2008以调试模式运行时才会看到此异常,并且我们认为它可能与调试器有关。但是,如果您认为相反,请随意发表评论!
This exception was seen a lot under Vista, and may be unrelated to the printing problems.  This exception was only seen when running in debug mode from VS2008, and we think it may be related to the debugger.  However, if you think the opposite, feel free to comment !
System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="System.Printing"
StackTrace:
at Microsoft.Internal.GDIExporter.UnsafeNativeMethods.DeleteObject(Void* hObject)
at Microsoft.Internal.GDIExporter.GdiSafeHandle.ReleaseHandle()
at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
at System.Runtime.InteropServices.SafeHandle.Finalize()
InnerException:



这篇关于打印XPS文档时的例外情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆