views:

61

answers:

1

I am using WPF and the DocumentViewer to display a document. However, when I use DocumentViewerBase.Print, it gives the "standard" Windows dialog box asking me to choose a printer with the default already selected. How can I get rid of this? I just want to use a Print method that will automatically start printing with no other prompt in between.

A: 

I believe in order to do this you would need to write your own printing routine e.g. by overriding OnPrintCommand method of the DocumentViewer. The reason is that default implementation is using PrintQueue.CreateXpsDocumentWriter method to create XpsDocumentWriter object and shows a PrintDialog in order to define its properties. For more details check the DocumentViewerBase.OnPrintCommand with reflector

serge_gubenko