需要通过 XML 修改 PrintTickets 的帮助
通过 System.Printing 框架(主要类是 PrintQueue、PrintTicket 和 PrinterCapabilties)进行一些控制打印的工作。 就像我最近所做的大多数事情一样,关于它的信息非常少。 我希望在这个问题中汇编一些好的信息来帮助充实这个主题。
PrintTickets 使开发人员能够很好地处理最常见的打印配置设置。 这很幸运,因为我不想用旧的 DEVMODE 方式来做(您可以将 DEVMODE 二进制流与 PrintTickets 相互转换,这很方便!)。
问题是打印机有很多,每种都有独特的配置。 这些不属于为 PrintTickets 创建的良好属性和枚举范围。 如果您必须配置其设置超出此界面的打印机,则必须将 PrintTicket 序列化为 xml 并在那里进行修改。
当您使用 PrintTicket xml 时,您的生活将受到三种或更多模式的支配:两种由 Microsoft 控制,一种或多种由打印机制造商控制。 这两个 MS 架构是
- PrintSchemaFramework http://schemas.microsoft.com/windows/ 2003/08/printing/printschemaframework
- PrintSchemaKeywords http://schemas. microsoft.com/windows/2003/08/printing/printschemakeywords
我在处理原始 xml 时遇到的第一个问题是我找不到任何涵盖这些架构的 XSD。
有谁知道我可以在哪里获取这些模式的 XSD?
我遇到的第二个大问题是将用户输入映射到 PrintTicket xml。 最佳情况下,我希望获取用户的输入(例如“纸盘 3”),并通过 PrintCapability 进行映射,以确定为该功能设置的选项值。 打印功能的文档有些不清楚,我担心它充满了边缘情况,如果我做得不对,这些情况会回来咬我。
有人有任何修改 PrintTicket XML 的好例子吗?
这是本 wiki 的一个很好的起点...
问题 1 的更新:
将一封电子邮件发送到我从 WinHEC PPT 中获得的地址,该地址可追溯到2005 年,并得到了 Windows 体验 - 文档和打印项目经理 Justin Hutchings 的实际答复(很酷,不是吗?):
请问,
打印架构命名空间没有 XSD。 您应该查看打印模式规范 1.0 并使用它来验证您的一致性。 http://www.microsoft.com/whdc/xps/downloads.mspx
我们还在 PrintVerifier 中内置了 PrintSchema 验证。 有关获取和配置 Print Verifier 的详细信息,请访问以下 URL:
Doing some work on controlling printing via the System.Printing framework (main classes are PrintQueue, PrintTicket and PrinterCapabilities). Like with most stuff I've been working on lately, there's damn little information about it. I'm hoping to compile some good information in this question to help flesh out this subject.
PrintTickets give developers a good handle on most common configuration settings for printing. That's fortunate, because I'd hate to have to do it the old DEVMODE way (you can convert DEVMODE binary stream to and from PrintTickets, which is convenient!).
The problem is that there are LOTS of printers, each with unique configurations. These don't fall within the nice properties and enumerations created for PrintTickets. If you have to configure a printer whose settings lay beyond this interface, you have to serialize your PrintTicket to xml and modify it there.
When you are working with PrintTicket xml, your life is ruled by three or more schemas: Two by Microsoft and one or more by the printer manufacturer. The two MS schemas are
- PrintSchemaFramework http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework
- PrintSchemaKeywords http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords
One of the first issues I've had dealing with the raw xml is that I can't find any XSDs covering these schemas.
Does anybody know where I can get the XSDs for these schemas?
The second big issue I've encountered was mapping user input to the PrintTicket xml. Optimally, I would want to take a user's input, say "Tray 3", and map that through the PrintCapabilities to determine the value of the option to set for that feature. The documentation for the print capabilities is somewhat unclear, and I'm afraid that its full of edge cases that will come back and bite me if I don't do it right.
Does anybody have any good examples for modifying PrintTicket XML?
That's a good starting point for this wiki...
Update on question 1:
Sent an email off to an address I got from a WinHEC PPT dated back in 2005, and got an actual response from Justin Hutchings, the program manager for Windows Experience - Documents and Printing (cool, no?):
Will,
There are no XSDs for the Print Schema namespaces. You should review the Print Schema Specification 1.0 and validate your conformance using that. http://www.microsoft.com/whdc/xps/downloads.mspx
We also have PrintSchema validation built into PrintVerifier. More information on obtaining and configuring Print Verifier is available at these urls:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
Microsoft 网站上现在有打印架构规范(日期为 2013 年 7 月 28 日),网址为
http://msdn.microsoft.com/en-us/windows/hardware/gg463385.aspx
它有 300 多个规范,还包括 http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
查看有关选择托盘的线程:
http://social.msdn.microsoft.com/forums/en-US/windowsxps/thread/f5859148-26f1-4e89-949c-180413bcc898/
CAnderson 和 Jo0815 正在询问 PrintQueue 的 PrintCapability 来询问用于与输入箱相关的功能。 之后,它们将 DefaultPrintTicket 中的 XML 加载到 XMLDocument 中,以插入节点来指定 bin,将 XMLDocument 写入流中,然后从该流构建新的 PrintTicket。 (与 创建 WholePrintTicket 类的过程。)
相同的技术可以应用于标准 PrintTicket 未公开的其他功能。
Check out the thread about selecting trays at:
http://social.msdn.microsoft.com/forums/en-US/windowsxps/thread/f5859148-26f1-4e89-949c-180413bcc898/
CAnderson and Jo0815 are interrogating the PrintQueue's PrintCapabilities to ask for the features related to input bins. After that, they load up the XML from the DefaultPrintTicket into an XMLDocument to insert nodes to specify the bin, write the XMLDocument into stream, and then build a new PrintTicket from that stream. (Probably more straight forward approach as compared to the process of concatenating and then removing duplicates described in Procedure for Creating a WholePrintTicket Class.)
The same techniques can be applied to the other features not exposed by the standard PrintTicket.