B4J Library Printer Example - Print text with the jFX8 Printer library

This is an example of printing text using the jFX8 Print library with TextFlow and Text class objects.

By parsing the text and measuring and creating text classes per line as required by wrapping it creates multiple pages and prints them to one print job.

There are also options to break on word, highlight alternate rows with color, underline rows solid or dashed, remove double empty lines and add audit columns to enable simple auditing tasks.

Provided that the textflow is the top most view in the printed node, the text is selectable in a PDF viewer.


This example was printed to PDF and the annotations added with Foxit pdf reader. I am all in favour of saving paper.


A straight forward print of text from a String variable. It will also print from a file.​

jFX8Print Library - B4xlib
TextFlow Library - B4xlib

I haven't created a gui for it I may do it later but if anyone fancies it, feel free.

Let me know how you get on with it.


  • PrinterExamples1.zip
    20.1 KB · Views: 209
Last edited:


Licensed User
Longtime User
Added VirtualMachineArgs and PackagerProperties required if using SetFileDestination in Java 11+:

#VirtualMachineArgs: --add-opens javafx.graphics/javafx.print=ALL-UNNAMED --add-opens javafx.graphics/com.sun.prism.j2d.print=ALL-UNNAMED
#PackagerProperty: VMArgs = --add-opens javafx.graphics/javafx.print=b4j --add-opens javafx.graphics/com.sun.prism.j2d.print=b4j