Skip to Main Content
Programming WPF, 2nd Edition
book

Programming WPF, 2nd Edition

by Chris Sells, Ian Griffiths
August 2007
Intermediate to advanced content levelIntermediate to advanced
864 pages
25h 52m
English
O'Reilly Media, Inc.
Content preview from Programming WPF, 2nd Edition

System.Printing

The System.Printing namespace defines types that provide printing services including managing settings of print jobs, discovering and selecting print queues, and configuring printers and print servers. We will explore the most commonly used types from this namespace.

PrintQueue

PrintQueue represents an output destination for printing—anytime you print something, you are sending it to a PrintQueue. The standard print dialog presents a list of available printers, and each printer in this list corresponds to a PrintQueue.

You have already seen several examples using PrintQueue—it offers a static CreateXpsDocumentWriter method that can return an XpsDocumentWriter. Although this method does not explicitly return a PrintQueue object, the writer it returns is implicitly bound to the PrintQueue of the printer the user selected in the print dialog. The examples shown earlier in this chapter call an overload of CreateXpsDocumentWriter that does not specify a target PrintQueue, causing a print dialog to be shown automatically. However, if you have a PrintQueue object, you can call one of the overloads that accepts a PrintQueue, in which case no dialog will be shown, and the document writer will target the specified queue. Example 15-33 shows one way to do this.

Example 15-33. Creating a document writer with a specific PrintQueue

LocalPrintServer local = new LocalPrintServer( ); PrintQueue pq = local.DefaultPrintQueue; XpsDocumentWriter xpsdw = PrintQueue.CreateXpsDocumentWriter(pq); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming C#, 4th Edition

Programming C#, 4th Edition

Jesse Liberty
Programming C# 10

Programming C# 10

Ian Griffiths

Publisher Resources

ISBN: 9780596510374Supplemental ContentErrata Page