Add a PDF viewer to a WPF application

后端 未结 4 741
心在旅途
心在旅途 2020-12-29 11:19

I am new to WPF, and am trying to add a PDF viewer to my WPF application, but can\'t seem to work out how to do it... I have tried following a couple of tutorials/ examples

4条回答
  •  佛祖请我去吃肉
    2020-12-29 11:59

    As already suggested by @NawedNabiZada, one tried and straightforward way is to use embedded InternetExplorer to show Adobe PDF Reader ActiveX control. So it assumes you are running on Windows and have Adobe PDF Reader installed.

    Then you create a user control, window etc. that contains following control:

    
    

    In the constructor navigate to blank page:

    pdfWebViewer.Navigate(new Uri("about:blank"));
    

    To load a PDF document to that control use this simple code:

    pdfWebViewer.Navigate(fullPathToPDF);
    

    This approach is used by many Windows software not only WPF apps including SAP client, but has a hidden problem, see this question.

    The Adobe PDF Reader Addon in Internet Explorer must be enabled for this to work. There are various problems with Acrobat Reader XI, better to use DC version. To enable Adobe PDF go to IE settings, add-ons and find Adobe PDF Reader and enable it (AR XI and above).

    For me this was the preferred way compared to the code project article you linked.

提交回复
热议问题