|
Rank: Newbie Groups: Member
Joined: 3/19/2018 Posts: 6
|
Is there any way to put ConvertHtml into an offline (local only) mode? I am processing archived HTML (typically email bodies) and do not want to follow links for two reasons:
1) potential security issues 2) in many cases the links will now be dead, so attempting to retrieve them could result in lengthy time-outs
I'd like to convert the HTML as quickly as possible, and with no attempt being made at network access.
Is this possible?
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi, There is no built-in option for you to disable network access. However it is possible for you to use a custom resource handler to intercept those requests and then immediately returns an error (for example, you can return 404 not found for all network requests) to prevent it from actually accessing the network. You will need to use this method to do so: https://www.essentialobjects.com/doc/eo.pdf.htmltopdfsession.runwebviewcallback.aspxAlso you will need to go over this topic if you are not familiar with custom resource handler: https://www.essentialobjects.com/doc/webbrowser/advanced/resource_handler.aspxThe code would be something like this:
Code: C#
//Here NoNetworkAccessHandler is a custom resource handler you
//would implement yourself that would return an error for all HTTP/HTTPS
//request
NoNetworkAccessHandler handler = new NoNetworkAccessHandler();
//Register your custom handler
session.RunWebViewCallback((WebView webView, object args) =>
{
webView.RegisterResourceHandler(handler);
});
//Perform the conversion
session.RenderAsPDF(resultPDFFileName);
//Unregister the handler
session.RunWebViewCallback((WebView webView, object args) =>
{
webView.UnregisterResourceHandler(handler);
});
Hope this helps. Please feel free to let us know if you still have any questions. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/19/2018 Posts: 6
|
That worked like a charm (I just needed to modify your WebViewCallback delegate to return null).
Thanks for your prompt and helpful support!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Ah yes. The callback needs to return null. Sorry about the overlook. Glad to hear that it works for you and thanks for the update!
|
|