views:

528

answers:

2

I need to render pdf file to a webbrowser control like how ie render it. question is, i need to get the content of the pdf file from the webbrowser control. how can i do it? help please.

Jepe

+2  A: 

Not sure if I understand what you want, but here is my attempt to answer.

If you want to just render it, webbrowser control natively support that, you just have to Navigate method in the control and pass it the PDF file location

If you need to get the content of the PDF, you can use File.ReadAllBytes(pdfFileName)

Fadrian Sudaman
you did. tnx, i'll try it.
Jepe d Hepe
oopss. my fault. i just realized that your answer is not related to each other. what i want is render the pdf file in the webbrowser control then read its content
Jepe d Hepe
If you want to read the actual content, it is not a trivial task. You will either have to use library features offered by ghostscript, or commercial product like pdftron. Check out this two projects http://code.google.com/p/pdfviewernet/ and ITextSharp, not sure if they do it.
Fadrian Sudaman
+1  A: 

Because IE embed whatever program is registered for the pdf file type on the user's client computer, there is no standard way you can access the document. If you plan to write your own PDF viewer, I suggest you to implement IObjectSafety and IPersistFile on your document object. Then you can you can get the PDF's document's automation interface via IWebBrowser2::get_Document and use IPersistFile to save it.

Most PDF viewers offer features that are not safe for scripting (e.g. printing), so you would rarely see a PDF viewer accessible via IWebBrowser2::get_Document.

Sheng Jiang 蒋晟