List icon Contents

From 7.38.2 to 7.39.0

Printing settings

In JxBrowser 7.39.0, we have removed the Scaling.fitToPage() and Scaling.fitToPaper() methods. These methods were used to configure the printing of PDF files with a system printer. When printing an HTML page or using the built-in PDF printer, the methods were no-op, confusing developers.

Instead, we introduce a new Fit.fit() method, which is available only for printing PDF files with system printers:

7.38.2 and earlier:

Java
Kotlin
browser.set(PrintPdfCallback.class, (params, tell) -> {
    SystemPrinter<PdfSettings> printer = params.printers().list().get(0);
    PdfSettings settings = printer.printJob().settings();
    settings.scaling(Scaling.fitToPage());
    ...
    tell.proceed(printer);
});
browser.set(
    PrintPdfCallback::class.java,
    PrintPdfCallback { params: PrintPdfCallback.Params, tell: PrintPdfCallback.Action? ->
        val printer = params.printers().list()[0]
        val settings = printer.printJob().settings()
        settings.scaling(Scaling.fitToPage());
        ...
        tell.proceed(printer);
    })

7.39.0:

Java
Kotlin
browser.set(PrintPdfCallback.class, (params, tell) -> {
    SystemPrinter<PdfSettings> printer = params.printers().list().get(0);
    PdfSettings settings = printer.printJob().settings();
    settings.fit(Fit.FIT_TO_PAGE);
    ...
    tell.proceed(printer);
});
browser.set(
    PrintPdfCallback::class.java,
    PrintPdfCallback { params: PrintPdfCallback.Params, tell: PrintPdfCallback.Action? ->
        val printer = params.printers().list()[0]
        val settings = printer.printJob().settings()
        settings.fit(Fit.FIT_TO_PAGE)
        ...
        tell.proceed(printer);
    })