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.

1666452662065.png


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


1666452390351.png
1666475847789.png


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

Dependencies:
jFX8Print Library - B4xlib
TextFlow Library - B4xlib
jReflection

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.
 

Attachments

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

stevel05

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

B4X:
#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
 
Top