开发者

Save Dynamically generated PDF from Web browser control

开发者 https://www.devze.com 2023-04-08 05:43 出处:网络
I have a web browser control in my windows form. I am trying to automate some process in a website. During this process, the invoice pdf has be开发者_运维百科en generated dynamically and shown in the

I have a web browser control in my windows form. I am trying to automate some process in a website. During this process, the invoice pdf has be开发者_运维百科en generated dynamically and shown in the web browser control. I need to save that pdf locally. Please note: there is no direct link to download the pdf. I googled a lot past couple of days and haven't found any solution yet.

Can someone help me on this?

Thanks.


I would recommend handling the WebBrowser.Navigating event. One of the parameters of this event is WebBrowserNavigatingEventArgs which has a property called Url. If you're lucky, that property will end in .pdf. If you're not lucky you might have to perform a manual HEAD request and inspect the returned MIME-type to see if its a PDF.

Another thing that you could try is handling the WebBrowser.FileDownload event but I'm not sure if it will be raised for PDFs viewed in-browser. If you have absolute control over the machine this is running on I would recommend disabling viewing of PDFs in the browser and just handle this event instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号