B4J Library jPrint V 1.61

Here is a library I am currently working on.
It allows you to print from your B4J program.

At present it can print TextArea, TextField, TableView and text type files.

I am open to suggestions as to what to add, and general feedback on how it is working for you.

A word of warning, don't try to print an HTML file, unless you have an unlimited supply of paper, it wants to print basically 1 character per page. I have tested with .txt and .js and they seem to work ok.

see jPrintTest for how to call the routines.

version V 1.10

1) Added two fields to jPrint - jPrint.startTabRow and jPrint.endTabRow, these control which rows are printed from the table.
eg, printer.startTabRow = 10
printer.endTabRow = 20
will print out rows 10 to 20 when ??.print(table) is called.

if not set entire table printed, they can be set separately ie printer.startTabRow=10 will print from row 10 onwards etc.
2) Can now print the following table datatypes String, Label, Int, Float and Double.

version V1.20
Can now specify which printer when printing a file.

Version V 1.30
Added limit checks on start and end rows. - rows start and end are inclusive now.
Added datatype boolean for tables.
Added header for table print - prints 'Table : tableID' as header for each page.

Version V 1.40
Added image to tableview - it can't print it but wont cause print to fail.(just prints "--Image--" in cell.)
Added ability to print Strings - printer.print("hello")) etc. probably best used in conjunction with a StringBuilder as once string is sent, will print.
Workaround for fileprint not ejecting page. - use printer.print(" ") to same printer, as it forces form feed after print.

Version V 1.50
Added printFile2(filename,header,font)
Added word wrap on long lines.
printFile2 written to use different method to print a file. Use printer dialog to change margins etc.
see jPrintTest(v1.50) for printfile2 parameters.

Version V 1.60
This has a new routine printer.printFileNoThreads(filename,header,font)
It does not use a separate thread to run the file print. That seemed to be the cause of the problem on the HP laserjet printer failing to print.(if only this were true)
printFile(...) does not print headers or allow choice of font.
printFile2(...) allows headers and font selection and prints on a separate thread.
printFileNoThreads(...) allows headers and font choice but will hang the B4J program while printing.

Version V 1.61
Minor change to printFileNoThreads(...) setting header to "" effectively removes headers and footers from output print. (Still trying to find cause of HP laser failing to print a page)
It appears the header/footer was the problem on the HP.
If you don't get a print out from a file try the above method printFileNoThreads(...) with header set to "".


  • jPrintLib(V1.50 Beta).zip
    10.4 KB · Views: 530
  • jPrintTest(v1.50).zip
    2.2 KB · Views: 791
  • jPrintLib V1.60.zip
    10.6 KB · Views: 574
  • jPrintLibrary(1.61).zip
    10.7 KB · Views: 1,012
  • jPrintSource(1.61).zip
    3.2 KB · Views: 859
Last edited:

Kevin Hartin

Active Member
Licensed User
can jPrint do the following

1. print to a specific printer without the print dialog
2. print a series of ESCPOS commands to a receipt printer

I need to print receipts from a POS app in B4J



Well-Known Member
Licensed User
Longtime User
I don't know to be honest, it's so long since I looked at this library, I have forgotten most of what it does.
There are better libraries available now.


Licensed User
Longtime User