Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing from WPF too slow

Tags:

c#

wpf

I have a WPF application and I need to print from it. I had previously posted a question about printing without needing to display a confirmation window and got a great answer that I have implemented like the following

var pq = LocalPrintServer.GetDefaultPrintQueue();
var writer = PrintQueue.CreateXpsDocumentWriter(pq);
var paginator = newPass.docMain.Document.DocumentPaginator;
writer.Write(paginator);

This code works just fine and simple - it basically just picks up the local printer que and sends the XPS document. However, it is relatively slow to print. I've tried to narrow down the possibilities and it looks like the greatest speed difference is between WinXP and Win7 machines. On XP it is slow, but acceptable, at about 2-3 seconds to print while on Win7 it can be upwards of 10 seconds and 15 seconds is not uncommon. Is there a reason why this code would have such a difference in speed? Also, I've noticed that there are a few questions on here about WPF print speeds - is there a reason why WPF printing in general is slow?

like image 643
Unknown Coder Avatar asked Aug 12 '11 19:08

Unknown Coder


2 Answers

Perhaps one or more of these links will be useful in solving this issue:

http://www.bradymoritz.com/wpf-printing-performance-and-pdf

http://blogs.infosupport.com/blogs/willemm/archive/2008/11/03/WPF-Speed-tips.aspx

http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/printing-is-very-very-slow-in-windows-7/477b5aba-a93d-4c5e-ac1f-329fed6459f3

WPF: Why TOO SLOW to Get PrintDialog's .PrintableAreaWidth and .PrintableAreaHeight?

like image 146
Mamta D Avatar answered Nov 08 '22 03:11

Mamta D


Most printing speed problems that I have seen were related to the printer driver. The task of the printer driver is to translate graphical instructions (coming from WPF in this case) to instructions that the printer understands, the so-called PDL (typically PCL or PostScript). Often, the PDL supports only a subset of the graphical capabilities and consequently complex instructions result in huge PDL jobs. Transparancy flattening being a notorious one.

like image 1
Frank Avatar answered Nov 08 '22 05:11

Frank