B4J Question How to print on thermal paper jfx8print

Reminisce

Active Member
Capture.JPG



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
 

afields

Member
Licensed User
hello!
maybe this link will help you..

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.
 
Upvote 0

Reminisce

Active Member
hello!
maybe this link will help you..

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 ?..
 
Upvote 0

Reminisce

Active Member
Thanks, i fixed it already, i created a variable that summed the height of individual nodes. Then i did..

Pnlprint.height = allheight + 5dip
 
Upvote 0

Reminisce

Active Member
I Reminisce have the same problem could you show an example of how to add the nodes ☹☹
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.
 
Upvote 0
Top