How to display PDF in web browser control instead of opening Acrobat Reader

后端 未结 1 1338
我在风中等你
我在风中等你 2020-12-19 10:23

i am using Acrobat Reader 11.0.3 and window 7, Visual studio 2012 and already enabled Acrobat Reader in Manage Addon

and follow WPF webbrowser opens PDF file in Ado

1条回答
  •  一向
    一向 (楼主)
    2020-12-19 10:26

    You could generate a temp HTML file to embed the desired PDF:

    
    
    
    
    
    
    
    
    
    

    What's interesting, to make it work with a local (file://) PDF document, I had to specify both data attribute and src param. When it was served via http from localhost, the data alone was just enough.

    UPDATE: I could not tell why this doesn't work for the OP, so I've cooked up a very basic C# WebBrowser project demo'ing this. It works quite reliably in my environment (Win8, IE10, Acrobat Reader 11.0.3).

    UPDATE: I think I understand why this is happening. Your project uses WPF, while my sample uses Winforms. Sorry, I did not notice this in the first place. WPF WebBrowser has a different security model, it runs in IE Protected Mode by default.

    With WPF WebBrowser, I've managed to get rid of the prompt (note ), but I do confirm the Acrobat Reader control just hangs loading the file every now and then:

    
    
    
    
    
    
      
    
    
    
    
    
    
    

    Acrobat Reader control is known to have issues with Protected Mode. Rather than trying to find a workaround for this, it may be easier to host Acrobat Reader ActiveX control directly in your WPF project. Here's how it can be done:

    http://www.codeproject.com/Articles/380019/Using-Adobe-Reader-in-a-WPF-app http://hugeonion.com/2009/04/06/displaying-a-pdf-file-within-a-wpf-application/

    0 讨论(0)
提交回复
热议问题