Welcome Guest Search | Active Topics | Sign In | Register

WebBrowser Control WinForm manage PDF Visualization Options
asterd
Posted: Tuesday, December 3, 2013 10:04:59 AM
Rank: Member
Groups: Member

Joined: 12/3/2013
Posts: 16
Good Evening,

i want to know if there is a way to manage pdf view inside WebView of WebBrowser Control.
I Cannot find an handler that return the response so i can check content-type and manage pdf as i want (like automatically download in a temp folder and so on..)

Can you help me please???
eo_support
Posted: Tuesday, December 3, 2013 10:09:24 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Thanks for posting in the forum. That is not yet supported because currently WebView does not load any plug-ins and display PDF inside WebView needs a plug-in (usually Adobe Reader). As such it is not possible to do that now. Sorry about it! However supporting plug-ins is definitely on our list and hopefully we will support it in our next release.
asterd
Posted: Tuesday, December 3, 2013 10:27:05 AM
Rank: Member
Groups: Member

Joined: 12/3/2013
Posts: 16
Thank you very match for the quick response,
i hope the plugin will coming as soon as possible.. but waiting for this functionality, there is no way to get the Response object?? something like page.WebView.OnResponseDone where i can read the mime type, the content type or have access to the PostData and byte[] of the response?
eo_support
Posted: Tuesday, December 3, 2013 10:37:30 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

I believe there are two possible ways to do this. If you can determine if the response is a PDF from your Url, you can use a custom resource handler:

http://www.essentialobjects.com/doc/6/advanced/resource_handler.aspx

A custom resource handler allows you to intercept a Url and perform your own logic. So you can completely take over the request from the WebView/WebBrowser control.

However if there is no way to tell whether the request will result in a PDF response, then you have to let the WebView to handle the request. I believe in that case the request is handled as a download so you can use BeforeDownload, DownloadUpdate and DownloadCompleted event to monitor the request. The PDF file will be downloaded into a temp file. You can then decide what to do with that file.

Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!
asterd
Posted: Tuesday, December 3, 2013 10:48:55 AM
Rank: Member
Groups: Member

Joined: 12/3/2013
Posts: 16
Hi,

unfortunately there is no way to know if it is a pdf request so i can't use the RequestHandler.
Either, the BeforeDownload and all method related to download are not called from the WebView when i navigate to a page that has to render a pdf file (you can try searching a "test filetype:pdf" on google and click on some links)... so i think that, at this moment, your component cannot manage this behavior.

It is strange because, using CEF, there are a lot of possibilities (without using plugin) to catch and manage the response...
I hope this behavior will be as soon as possible added to this product because i think is a very good product but this limit is very big related to a browser component, don't you think?

Anyway.. thank you so much for the support!
eo_support
Posted: Tuesday, December 3, 2013 10:59:40 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Thank you very much for the feedback. We will look into this and see why the download event are not called, and also to see if there is anyway to add the ability to intercept and manage the response, not just the request. We understand that it is an important feature. We will reply here again when we have an update.
eo_support
Posted: Monday, December 9, 2013 10:08:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

We have posted a new build on our download page that added ShouldForceDownload event. You can handle this event to force the WebView always handle PDF as a download:

http://www.essentialobjects.com/doc/6/advanced/response_handler.aspx

The event is triggered after all the headers have been received (thus MIME type is known), but the body has not been received yet. If you set ForceDownload of the event argument to true, then the WebView goes directly to download the file instead of trying to display it. You can then use the download events to implement your custom handling logic.

Thanks!
asterd
Posted: Tuesday, December 10, 2013 3:49:25 AM
Rank: Member
Groups: Member

Joined: 12/3/2013
Posts: 16
Thank you very much for this fix!! it works very well and solve my problem!!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.