« Alternating row styles in a ListBoxBackground printing with FlowDocumentScrollViewer »

PrintTicket provider failed to retrieve PrintCapabilities


Permalink 02:05:41 pm, Categories: WPF

More Than Meets the Eye

You may have glossed over the following code in my previous post:

        PrintTicket ticket = new PrintTicket();
        ticket.PageOrientation = PageOrientation.Portrait;
        ticket.CopyCount = copies;
        PrintCapabilities capabilities = queue.GetPrintCapabilities(ticket);
        writer.WriteAsync(documentPaginator, ticket);

And I couldn't blame you for it. On the surface it doesn't appear all that significant or interesting.

But the reason behind creating and using a custom PrintTicket goes beyond setting the number of copies for the print job.

Oww, My Print Driver!

You may encounter the following exception with certain print drivers if you do not use your own PrintTicket:

"PrintTicket provider failed to retrieve PrintCapabilities. Win32 error: -2147467259"

If you do not specify your own PrintTicket for print operations, the default UserPrintTicket for the PrintQueue is used, and some print drivers fail to provide valid objects for the UserPrintTicket and DefaultPrintTicket by yielding the above exception. This is essentially a driver problem, but inevitably there will be instances where your software runs on drivers you didn't know about or in environments where driver upgrades may not be possible.

My Recommendation

Therefore, I recommend always forcing use of your own PrintTicket for all printing operations in WPF, as I did in the above code for the calls to GetPrintCapabilities and WriteAsync methods. Note that each of these methods has an overload that does not take a PrintTicket argument. These are the ones to avoid.


You can also set the value of the UserPrintTicket property on the PrintQueue, thus overriding the default UserPrintTicket with your own. Then you can omit the ticket argument to subsequent print method calls.

Feedback awaiting moderation

This post has 23420 feedbacks awaiting moderation...

Leave a comment

Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
February 2018
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28      

Development miscellany of interest. To some people. Or maybe just one person. Or maybe nobody.


XML Feeds

powered by b2evolution free blog software