Read pdf contents using webbrowser control in C# [closed]

帅比萌擦擦* 提交于 2019-12-13 10:16:15

问题


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


回答1:


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)




回答2:


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.



来源:https://stackoverflow.com/questions/2459273/read-pdf-contents-using-webbrowser-control-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!