Display a PDF in WPF Application [closed]

Any ideas how to display a PDF file in a WPF Windows Application?


I am using the following code to run the browser but the Browser.Navigate method does not do anything!

WebBrowser browser = new WebBrowser();
browser.Navigate("http://www.google.com");
this.AddChild(browser); // this is the System.Windows.Window

Solution 1:

You can get the Acrobat Reader control working in a WPF app by using the WindowsFormHost control. I have a blog post about it here:

http://hugeonion.com/2009/04/06/displaying-a-pdf-file-within-a-wpf-application/

I also have a 5 minute screencast of how I made it here:

http://www.screencast.com/t/JXRhGvzvB

Solution 2:

You could simply host a Web Browser control on the form and use it to open the PDF.

There's a new native WPF "WebBrowser" control in .NET 3.51, or you could host the Windows.Forms browser in your WPF app.

Solution 3:

Oops. this is for a winforms app. Not for WPF. I will post this anyway.

try this

private AxAcroPDFLib.AxAcroPDF axAcroPDF1;
this.axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF();
this.axAcroPDF1.Dock = System.Windows.Forms.DockStyle.Fill;
this.axAcroPDF1.Enabled = true;
this.axAcroPDF1.Name = "axAcroPDF1";
this.axAcroPDF1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axAcroPDF1.OcxState")));
axAcroPDF1.LoadFile(DownloadedFullFileName);
axAcroPDF1.Visible = true;