i am using Acrobat Reader 11.0.2
and follow http://stackoverflow.com/questions/16228365/wpf-webbrowser-opens-pdf-file-in-adobe-reader-window
still have error after trying two methods
Navigation to the webpage was canceled
even if using administrator account to open WPF program
private void CheckAndFixWebBrowserRenderingEngine() { RegistryKey baseRegistryKey = Registry.LocalMachine; string renderingEngineSubKeyString = @"SOFTWARE"; // 64bit operationg systems have another registry path if (Environment.Is64BitOperatingSystem) { renderingEngineSubKeyString += @"\Wow6432Node"; } renderingEngineSubKeyString += @"\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"; //var assemblyValueKey = System.IO.Path.GetFileName(App.ResourceAssembly.Location); var assemblyValueKey = System.IO.Path.GetFileName(System.Windows.Application.ResourceAssembly.Location); var renderingEngingeValue = 9999; // check other values below try { RegistryKey sk1 = baseRegistryKey.CreateSubKey(renderingEngineSubKeyString); var value = sk1.GetValue(assemblyValueKey); if (value == null || value.ToString() != renderingEngingeValue.ToString()) { sk1.SetValue(assemblyValueKey, renderingEngingeValue); //LogHandler.Instance.Add(string.Format("Did update webbrowser rendering engine from {0} to 9000.", value == null ? "[missing]" : value)); } } catch (Exception ex) { //LogHandler.Instance.Add("Could not check webbrowser rendering engine in registry."); //LogHandler.Instance.Add(ex.ToString(), Logging.LoggingPriorities.Exception); } /* 9999 (0x270F) Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive. 9000 (0x2328) Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. 8888 (0x22B8) Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive. 8000 (0x1F40) Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. 7000 (0x1B58) Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. */ } public ReportForm() { this.formID = "Test Report"; //base.Initialization(); InitializeComponent(); CheckAndFixWebBrowserRenderingEngine(); String PDFPath = @"C:\Users\LAB-User2\Downloads\Elimination_Methods_in_Polynomial_Computer_Alge(Bookos.org).pdf"; WebBro1.Navigate("file:///" + PDFPath);
Method 2
i have also tried another method which add reference windowformintegration and use UserControl of winform and it only work in a small WPF project, when i integrate in my
big WPF project, it failed
String PDFPath = @"C:\Users\LAB-User2\Downloads\Elimination_Methods_in_Polynomial_Computer_Alge(Bookos.org).pdf";
//WebBro1.Navigate("file:///" + PDFPath);
webBrowser1.Navigate("file:///" + PDFPath);
<WindowsFormsHost Margin="1" x:Name="windowsFormsHost1" Height="600" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="1000"/>
var uc = new UserControl1();
this.windowsFormsHost1.Child = uc;
application.UI.CreateNewForm("Test Report", new Client.Reporting.Pages2.ClientStatement.ReportForm()); public partial class ReportForm : BaseForm public void CreateNewForm(string title, BaseForm form) mw.CreateNewForm(title, form); public class BaseMainWindow : MetroWindow { public virtual void CreateNewForm(string title, BaseForm form) { }
Designer