I have a C#/WPF application in which I need to display a print preview for an HTML document -- essentially just like what one would see if looking at a print preview in Firefox or even IE. I know about DocumentViewer, however, I am trying to stay away from using a DocumentViewer control as it seems to be pretty slow and some of the documents I need to display can be upwards of 450+ pages and I want to load the preview as quickly as possible. Does anyone know of an elegant way of doing something like this? I'm starting to assume I'll need to create my own control, but I'm really at a loss for where to get started.
Thank you for any advice or tips you can provide for doing something like this!
You might want to use the WebBrowser control and extend it using the example provided here: http://www.codeproject.com/KB/miscctrl/wbp.aspx
[Edit: updated the answer to illustrate how to accomplish the same using the WPF WebBrowser control (System.Windows.Controls.WebBrowser)]
The underlying control is the same - it's the ActiveX component in SHDocVw.dll.
I pulled together some better reference URL's for you. Turns out there's a pretty good lead on doing something similar from the MSDN documentation for the control: http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser(v=vs.90).aspx#4 There's also this: http://support.microsoft.com/kb/329014.
You'll need to add a reference to SHDocVw, which is under the COM reference list as "Microsoft Internet Controls"
XAML:
Anyone interested in the WinForms control version (System.Windows.Forms.WebBrowser) can skip all the IServiceProvider baggage and just use the ActiveXInstance property (which the WPF control doesn't expose: