Hello, I want to be able to get the height of nodes on this panel and print this panel on a thermal printer paper. It is an invoice for a restaurant menu.
B4X:
Dim pnlheight As Int = 0
For Each v As B4XView In pnlprint.GetAllViewsRecursive
If v Is CustomListView Or v Is Label Or v Is ImageView Then
pnlheight = pnlheight + v.Top + v.Height
End If
Next
Log(pnlheight&"pnlheight")
'clvtoprint.AsView.Height= pnlheight
pnlprint.Height = pnlheight
The code above, doesn't set the correct height.
B4X:
Dim pj As PrinterJob = PrinterJob_Static.CreatePrinterJob
pj.ShowPageSetupDialog(Null)
pj.PrintPage(pnlprint)
pj.EndJob
Here is a B4j library written in B4j to access the full Printer modules provided with JavaFX8. Full source code is available. At it's simplest, you can print a node using: Dim P As Printer = Printer_Static.GetDefaultPrinter Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P)...
www.b4x.com
what i can say is that in my case i had to construct an html ( with the data that i needeed) and then print it.
Here is a B4j library written in B4j to access the full Printer modules provided with JavaFX8. Full source code is available. At it's simplest, you can print a node using: Dim P As Printer = Printer_Static.GetDefaultPrinter Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P)...
www.b4x.com
what i can say is that in my case i had to construct an html ( with the data that i needeed) and then print it.
Thank you, creating an html in my case would be an overkill. I just want to adjust the panel's height to fit the items and send it to a particular thermal printer 🖨..
Just loop through the views on the CLV, and get the individual height inside the loop, create a variable that adds each of this height inside the loop.
Finally, set your panel height to the variable and maybe add some dip to it.. Like in my example above.