<p>Any ideas how to display a PDF file in a WPF Windows Application? </p>

<hr>

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

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

[{'answer_id': 55085, 'author': 'GEOCHET', 'author_id': 5640, 'author_profile': 'https://Stackoverflow.com/users/5640', 'pm_score': -1, 'selected': False, 'text': '<p>Check this out: <a href="http://itextsharp.sourceforge.net/" rel="nofollow noreferrer">http://itextsharp.sourceforge.net/</a>\nYou may have to use a WindowsFormsHost, but since it is open source, you might be able to make it a little more elegant in WPF.</p>\n'}, {'answer_id': 55087, 'author': 'Guy Starbuck', 'author_id': 2194, 'author_profile': 'https://Stackoverflow.com/users/2194', 'pm_score': 4, 'selected': False, 'text': '<p>You could simply host a Web Browser control on the form and use it to open the PDF.</p>\n\n<p>There\'s a new native WPF "WebBrowser" control in .NET 3.51, or you could host the Windows.Forms browser in your WPF app.</p>\n'}, {'answer_id': 55177, 'author': 'Gulzar Nazim', 'author_id': 4337, 'author_profile': 'https://Stackoverflow.com/users/4337', 'pm_score': 4, 'selected': True, 'text': '<p>Oops. this is for a winforms app. Not for WPF. I will post this anyway.</p>\n\n<p>try this</p>\n\n<pre><code>private AxAcroPDFLib.AxAcroPDF axAcroPDF1;\nthis.axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF();\nthis.axAcroPDF1.Dock = System.Windows.Forms.DockStyle.Fill;\nthis.axAcroPDF1.Enabled = true;\nthis.axAcroPDF1.Name = "axAcroPDF1";\nthis.axAcroPDF1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axAcroPDF1.OcxState")));\naxAcroPDF1.LoadFile(DownloadedFullFileName);\naxAcroPDF1.Visible = true;\n</code></pre>\n'}, {'answer_id': 581997, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>The following code expects Adobe Reader to be installed and the Pdf extension to be connected to this.\nIt simply runs it:</p>\n\n<pre><code>String fileName = "FileName.pdf";\nSystem.Diagnostics.Process process = new System.Diagnostics.Process(); \nprocess.StartInfo.FileName = fileName;\nprocess.Start();\nprocess.WaitForExit();\n</code></pre>\n'}, {'answer_id': 720372, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 4, 'selected': False, 'text': '<p>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:</p>\n\n<p><a href="http://hugeonion.com/2009/04/06/displaying-a-pdf-file-within-a-wpf-application/" rel="noreferrer">http://hugeonion.com/2009/04/06/displaying-a-pdf-file-within-a-wpf-application/</a></p>\n\n<p>I also have a 5 minute screencast of how I made it here:</p>\n\n<p><a href="http://www.screencast.com/t/JXRhGvzvB" rel="noreferrer">http://www.screencast.com/t/JXRhGvzvB</a></p>\n'}, {'answer_id': 5759095, 'author': 'odyth', 'author_id': 86524, 'author_profile': 'https://Stackoverflow.com/users/86524', 'pm_score': 3, 'selected': False, 'text': "<p>Just use a frame and a webbrowser like so</p>\n\n<pre><code>Frame frame = new Frame();\nWebBrowserbrowser = new WebBrowser();\nbrowser.Navigate(new Uri(filename));\nframe.Content = browser;\n</code></pre>\n\n<p>Then when you don't need it anymore do this to clean it up:</p>\n\n<pre><code>WebBrowser browser = frame.Content as WebBrowser;\nbrowser.Dispose();\nframe.Content = null;\n</code></pre>\n\n<p>If you don't clean it up then you might have memory leak problems depending on the version of .NET your using.  I saw bad memory leaks in .NET 3.5 if I didn't clean up.</p>\n"}, {'answer_id': 14174843, 'author': 'Mohammad', 'author_id': 633495, 'author_profile': 'https://Stackoverflow.com/users/633495', 'pm_score': 0, 'selected': False, 'text': "<p>You can also use FoxitReader. It's free and comes with an ActiveX control that registers in the web browsers (IE and others) after you install the FoxitReader application.\nSo after you install FoxitReader on the system put a WebBrowser Control and set its Source property to point to the file path of your PDF file.</p>\n"}, {'answer_id': 17381626, 'author': 'VahidN', 'author_id': 298573, 'author_profile': 'https://Stackoverflow.com/users/298573', 'pm_score': 3, 'selected': False, 'text': '<p>Try <code>MoonPdfPanel - A WPF-based PDF viewer control</code>\n<a href="http://www.codeproject.com/Articles/579878/MoonPdfPanel-A-WPF-based-PDF-viewer-control" rel="noreferrer">http://www.codeproject.com/Articles/579878/MoonPdfPanel-A-WPF-based-PDF-viewer-control</a></p>\n\n<p>GitHub: <a href="https://github.com/reliak/moonpdf" rel="noreferrer">https://github.com/reliak/moonpdf</a></p>\n'}, {'answer_id': 19423956, 'author': 'Frank Rem', 'author_id': 450467, 'author_profile': 'https://Stackoverflow.com/users/450467', 'pm_score': 1, 'selected': False, 'text': '<p>Disclosure: Here is a commercial one and I work for this company. </p>\n\n<p>I realize that an answer has already been accepted but the following does not require Adobe Reader/Acrobat and it is a WPF solution - as opposed to Winforms. I also realize this is an old question but it has just been updated so I guess it is still actual.</p>\n\n<p><a href="https://www.tallcomponents.com/pdfrasterizer3.aspx" rel="nofollow">PDFRasterizer.NET 3.0</a> allows you to render to a WPF FixedDocument. It preserves all vector graphics (PDF graphics are converted to more or less equivalent WPF elements. This is probably closest to what you need.</p>\n\n<pre><code>using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read))\n{\n  pdfDoc = new Document(file);\n\n  ConvertToWpfOptions convertOptions = new ConvertToWpfOptions();\n  RenderSettings renderSettings = new RenderSettings();\n  ...\n\n  FixedDocument wpfDoc = pdfDoc.ConvertToWpf(renderSettings, convertOptions, 0, 9, summary);\n}\n</code></pre>\n\n<p>You can pass the wpfDoc to e.g. the WPF DocumentViewer to quickly implement a viewer.</p>\n'}]
['https://Stackoverflow.com/questions/55083', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3797/']