This guide shows how to work with the Printing API.


The web page can be printed using one of the following ways:

  1. Using the window.print() JavaScript function. This function can be invoked from the JavaScript code on a web page.
  2. Using the Frame.print() method of the JxBrowser API. The method requests printing of the frame. If you need to print the whole page, you should call the print() method in the main frame. For example:


The web page is not printed immediately. The PrintCallback will be invoked to tell the engine how to handle the print request. By default all print requests are canceled.

To allow the print request and display the Print Preview dialog use the following code:

browser.set(PrintCallback.class, (params, tell) -> tell.showPrintPreview());

In the Print Preview dialog you can select the preferred printing options:

Print Preview

Canceling Printing

If you need to cancel or disable printing at all use the following approach:

browser.set(PrintCallback.class, (params, tell) -> tell.cancel());
Go Top