List icon Contents

Plugins

JxBrowser supports Chromium plugins. This guide describes how to get the information about all the installed and available Chromium plugins, how to enable or disable a specified plugin on a web page, etc.

Please use Plugins to get information about all the available plugins and enable/disable plugins on a web page.

Java
Kotlin
Plugins plugins = profile.plugins();
val plugins = profile.plugins()

By default, all plugins are enabled.

Installed plugins

To get information about all the installed and available plugins use the following code:

Java
Kotlin
plugins.list().forEach(plugin -> {
    String name = plugin.name();
    String description = plugin.description();
    String version = plugin.version();
});
plugins.list().forEach { plugin ->
    val name = plugin.name()
    val description = plugin.description()
    val version = plugin.version()
}

Filtering plugins

Every time when a web page needs to access a plugin the AllowPluginCallback is invoked. In this callback you can tell the web page whether the requested plugin is allowed.

The following example demonstrates how to deny all plugins with the application/pdf MIME type:

Java
Kotlin
plugins.set(AllowPluginCallback.class, (params) -> {
    // Get plugin MIME types.
    List<MimeType> pluginMimeTypes = params.plugin().mimeTypes();
    // Deny all plugins with the "application/pdf" MIME type.
    if (pluginMimeTypes.contains(MimeType.of("application/pdf"))) {
        return AllowPluginCallback.Response.deny();
    }
    return AllowPluginCallback.Response.allow();
});
plugins.set(AllowPluginCallback::class.java, AllowPluginCallback { params ->
    // Get plugin MIME types.
    val pluginMimeTypes = params.plugin().mimeTypes()
    // Deny all plugins with the "application/pdf" MIME type.
    if (pluginMimeTypes.contains(MimeType.of("application/pdf"))) {
        AllowPluginCallback.Response.deny()
    } else {
        AllowPluginCallback.Response.allow()
    }
})

PDF viewer

JxBrowser supports the built-in Chromium PDF Viewer plugin. You can display a PDF file available on a remote web server using URL of the PDF file, or a PDF file located in your local file system.

Chromium PDF Viewer

If you need to download PDF documents instead of displaying them, then you must disable PDF Viewer.

PDF viewer toolbar

By default, PDF Viewer displays the built-in controls such as zoom buttons, toolbar with the file name, page number, Rotate, Download, and Print buttons. You can hide these controls by adding #toolbar=0 to the end of the URL.

Chromium PDF Viewer No Controls

Disabling PDF viewer

By default, the built-in PDF Viewer is enabled. In order to disable it, use the following API introduced in 7.9:

Java
Kotlin
plugins.settings().disablePdfViewer();
plugins.settings().disablePdfViewer()

Password-protected PDF

You can open password-protected PDF files and provide password using the standard dialog:

Chromium PDF Viewer Password dialog

Since 7.27 you can set the password programmatically using RequestPdfDocumentPasswordCallback:

Java
Kotlin
browser.set(RequestPdfDocumentPasswordCallback.class, (params, tell) -> {
    tell.password("oxford not brogues");
});
browser.set(RequestPdfDocumentPasswordCallback::class.java,
    RequestPdfDocumentPasswordCallback { params, tell ->
        tell.password("oxford not brogues")
    }
)

Adobe Flash

Adobe Flash reached its end-of-life in December 2020. Chromium dropped support for Adobe Flash starting from the 88 version. So, Flash is not supported in JxBrowser 7.13 and higher.

NPAPI plugins

Starting from version 49 Chromium does not support any of NPAPI plugins including Microsoft Silverlight and Java Applet. Hence, JxBrowser does not support them either.

ActiveX

ActiveX is not supported by Chromium, so JxBrowser does not support it as well.

Widevine

Starting from 7.4 version, JxBrowser allows enabling Widevine through the Engine options.