I am trying to download pdf files from the server, but Browser.LoadURL
opens the pdf file in BrowserView. I have assigned DownloadHandler
to the Browser
but it does not fire.
The PDF files are not downloaded because they are opened by a built-in PDF viewer plugin instead.
To download these files, you need to disable the PDF plugin first.
To enable/disable a specific plugin you should create your own PluginFilter implementation:
class CustomPluginFilter : PluginFilter
{
public bool IsPluginAllowed(PluginInfo pluginInfo)
{
return pluginInfo.MimeTypes.Contains("application/pdf");
}
}
This filter is then registered as shown below:
pluginManager.PluginFilter = new CustomPluginFilter();
The IsPluginAllowed()
method is invoked during loading a web page when this web page checks whether a specific plugin is allowed or not.
After the PDF plugin is disabled, DotNetBrowser will download PDF instead of displaying it.
The article that describes how to disable the plugin can be found by the following link:
http://dotnetbrowser-support.teamdev.com/documentation/plugins-manager