4k support in Qoppa PDF Components

In version v2017R1,  support for 4K monitors was added in Qoppa PDF components jPDFViewer, jPDFNotes and jPDFEditor. The user interface was completely revised to support 4k HiDPI Display monitors with automatic DPI scaling for all dialogs and toolbars as well as newly designed vector icons that render crisp at any resolution.

Customers integrating our components in their application should only have to worry about sizing correctly their application frame.

How to size your Java Application Frame for 4k Support?

Identifying DPI Scaling Factor

Macs already do their own scaling, so there is no need for scaling.

Toolkit.getDefaultToolkit().getScreenResolution() does return a correct number and can be used to scale the application frame.

Unfortunately, the Toolkit.getDefaultToolkit().getScreenResolution() does not return the correct number on Linux. So we had to come up with our own scaling formula by relying on font size. We use the ratio of the default label font size for the current dpi to the label font size at 96 DPI (standard resolution), which is 15. This is assuming that the application is using the “System Look and Feel”.

This is how Qoppa computes the DPI scaling multiplier that can be used to resize the application frame:

double DPI_SCALING_MULTIPLIER = Math.max(1, new JLabel().getFont().getSize() / 15.0);
frame.setSize((int)(width * DPI_SCALING_MULTIPLIER, (int)(height * DPI_SCALING_MULTIPLIER));