Hello
I'm currently rewriting some code for a replacement of a serial thermal ticketprinter to an USB one.
In the old b4j console application, the code writes serial bytes to the printer to print the ticket.
With the new printer I assume that I need to use the JFX8Print library in order to send a print command to the USB printer.
I watched different threaths on the forum how you could manage printing, but It all includes creating a pane or form.
I couldn't find a way to get this working without the needs of JavaFX, because it's a non graphic application I'm writing.
I tried it with a pane, installed openjfx on the device with the printer connected, but receives the error message: "error: package javafx.scene does not exist", even when I point to the lib folder of Javafx:
This is the sample code I wrote:
What can cause this issue?
Thank you in advance!
I'm currently rewriting some code for a replacement of a serial thermal ticketprinter to an USB one.
In the old b4j console application, the code writes serial bytes to the printer to print the ticket.
With the new printer I assume that I need to use the JFX8Print library in order to send a print command to the USB printer.
I watched different threaths on the forum how you could manage printing, but It all includes creating a pane or form.
I couldn't find a way to get this working without the needs of JavaFX, because it's a non graphic application I'm writing.
I tried it with a pane, installed openjfx on the device with the printer connected, but receives the error message: "error: package javafx.scene does not exist", even when I point to the lib folder of Javafx:
Bash command java with javafx:
sudo java -jar b4j-bridge.jar --module-path /usr/lib/jvm/bellsoft-java13-arm32-vfp-hflt/legal/ --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web
This is the sample code I wrote:
B4J code for printing text:
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Private TICKETPANE As Pane
Private fx As JFX
End Sub
Sub AppStart (Args() As String)
printText
StartMessageLoop
End Sub
Private Sub printText
Private TICKETPRINTER As Printer = Printer_Static.GetDefaultPrinter
Private TICKETPRINTERATTRIBUTES As PrinterAttributes = TICKETPRINTER.GetPrinterAttributes
Private TICKETPRINTERPAPER As Paper = TICKETPRINTERATTRIBUTES.GetDefaultPaper
Private ticketprinterjob As PrinterJob = PrinterJob_Static.CreatePrinterJob2(TICKETPRINTER)
Private ticketprinterpagelayout As PageLayout = TICKETPRINTER.CreatePageLayout(TICKETPRINTER.GetPrinterAttributes.GetDefaultPaper, PageOrientation_Static.PORTRAIT, 0.5, 0.5, 0.5, 0.5)
ticketprinterjob.GetJobSettings.SetPageLayout(ticketprinterpagelayout)
' Create the ticket
TICKETPANE.Initialize("")
TICKETPANE.PrefWidth=80
Private ticketHeaderlbl As Label
ticketHeaderlbl.Initialize("")
ticketHeaderlbl.Text="LAS VEGAS"
ticketHeaderlbl.TextSize=15
ticketHeaderlbl.Style="-fx-alignment:CENTER;-fx-font-weight:bold"
TICKETPANE.AddNode(ticketHeaderlbl,0,0,80,15)
Private ticketLocationlbl As Label
ticketLocationlbl.Initialize("")
ticketLocationlbl.Text="Mont-Noir Westouter"
ticketLocationlbl.TextSize=12
ticketLocationlbl.Style="-fx-alignment:CENTER"
TICKETPANE.AddNode(ticketLocationlbl,0,0,80,10)
Private ticketTitleReculbl As Label
ticketTitleReculbl.Initialize("")
ticketTitleReculbl.Text=$"Re${Chr(92)}u gagnant"$
ticketTitleReculbl.TextSize=15
ticketTitleReculbl.Style="-fx-alignment:CENTER;-fx-font-weight:bold"
TICKETPANE.AddNode(ticketTitleReculbl,0,0,80,15)
Try
ticketprinterjob.PrintPage(TICKETPANE)
Catch
Log(LastException)
End Try
End Sub
What can cause this issue?
Thank you in advance!