locked
How to display a pdf file in wpf application in C# RRS feed

  • Question

  • Hi Everyone,

    Could you please help me in finding out a solution for displaying a pdf file in wpf window?

    Thanks

    Jo

    Saturday, October 22, 2011 10:48 PM

Answers

  • Hi s251984,

    You can do this, by using a WebBrowser control.  Then, in your code you just load the PDF into the webbrowser control from a string of HTML which has the name of your PDF file in it.  Like this:

      webBrowser1.NavigateToString(@"<HTML><IFRAME SCROLLING=""YES"" SRC=""MyPDF.pdf""></IFRAME></HTML>");
    


     


    Tom Overton
    • Proposed as answer by Tom_Overton Sunday, October 23, 2011 10:59 AM
    • Marked as answer by s251984 Sunday, October 23, 2011 4:03 PM
    Saturday, October 22, 2011 11:07 PM
  • Hi Tom,

    Thanks very much for your help.

    Jo

    • Marked as answer by s251984 Sunday, October 23, 2011 10:34 AM
    Sunday, October 23, 2011 10:34 AM

All replies

  • Hi s251984,

    You can do this, by using a WebBrowser control.  Then, in your code you just load the PDF into the webbrowser control from a string of HTML which has the name of your PDF file in it.  Like this:

      webBrowser1.NavigateToString(@"<HTML><IFRAME SCROLLING=""YES"" SRC=""MyPDF.pdf""></IFRAME></HTML>");
    


     


    Tom Overton
    • Proposed as answer by Tom_Overton Sunday, October 23, 2011 10:59 AM
    • Marked as answer by s251984 Sunday, October 23, 2011 4:03 PM
    Saturday, October 22, 2011 11:07 PM
  • Hi Tom,

    Thanks very much for your help.

    Jo

    • Marked as answer by s251984 Sunday, October 23, 2011 10:34 AM
    Sunday, October 23, 2011 10:34 AM
  • No problem Jo.  Did you end up using that method or did you find another way to make it work?

    I noticed you tend to mark your own last response as answers instead of the actual answers.  For the benefit of others that may look at threads in the future for help with similar situations please mark those answers that helped solve the problem.

    Thanks for your understanding and your support and use of MSDN forums!


    Tom Overton
    • Edited by Tom_Overton Sunday, October 23, 2011 10:59 AM
    Sunday, October 23, 2011 10:36 AM
  • Sorry..I didn't notice that. I marked the right one as answered.

    Thanks a lot

    Jo

    Sunday, October 23, 2011 4:04 PM
  •   webBrowser1.NavigateToString(@"<HTML><IFRAME SCROLLING=""YES"" SRC=""MyPDF.pdf""></IFRAME></HTML>");
    

    This works but what is the difference with: 

     

    webBrowser.Navigate(new System.Uri(@"c:\MyPDF.pdf"));
    

    ?

     


    Al3xI98O
    • Edited by Al3xI98O Tuesday, October 25, 2011 7:43 AM
    Tuesday, October 25, 2011 7:42 AM