I use the WPF Printing Path to handle big large diagrams created in our application. The whole diagram consists of visuals.
A so called "DesignerPaginator" paginates the diagram (it is quite simple). From this point, I do the following three thing: - I print the Document with PrintDialog.PrintDocument(Paginator, Title) - I also create a XPS Document with XpsDocumentWriter.Write(Paginator, PrintTicket); which I save on the HDD - From the XPSDocument I assign XpsDocumentWriter.GetFixedDocumentSequence() to a DocumentViewer
In a nutshell, following code is important:
PrintDialog _pdialog = new PrintDialog();
System.Printing.ValidationResult result = this.PrintQueue.MergeAndValidatePrintTicket(this.PrintQueue.UserPrintTicket, this.PrintTicket);
_pdialog.PrintTicket = result.ValidatedPrintTicket;
XpsDocument _xpsDocument = new XpsDocument("C:\\test.xps",FileAccess.ReadWrite);
XpsDocumentWriter xpsdw = XpsDocument.CreateXpsDocumentWriter(_xpsDocument);
xpsdw.Write(this.Paginator, result.ValidatedPrintTicket);
documentviewer.Document = _xpsDocument.GetFixedDocumentSequence();
_xpsDocument.Close();
_pdialog.PrintQueue = this.PrintQueue;
_pdialog.PrintDocument(this.Paginator, "Model Test");
The output is the following:
XPS on HDD -> absolutely blurry. You can't recognize anything. It's like a GIF File with a 100x Zoom. FixedDocumentSequence from the XPSDocument in the DocumentViewer -> Perfect. This should be what the XPS File is meant to be Print output -> Horrible, blurry, but at least much better than the xps file
And now the mysterious part: If I print directly from the DocumentViewer (in which the FixedDocumentSequence seems perfect), I get the same blurry output from the first print.
My thought about this case is that the WPF's XPS System rasterize the content and place the stuff as low quality Bitmap within the xps Document. It's all vectors, and despite this fact the output always seems familiar to a low resolution bitmap.
I would appreciate any help. I'm out of ideas. I tried a lot to debug this problem, but it somehow seems to be something simple and delicate at the same time.