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
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:
Check out the thread about selecting trays at:
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.