B4J Question Problem printing with jFX8print on POS printer (solved)

Alex Oscar Hedman

Member
Licensed User
Hello coders!
Im finishing a Market Management and POS software and I have a huge problem printing the ticket in a POS printer.
The problem is that when the shop list is long the library or the code cuts the ticket always in the same size (like 25 cm)
I cannot do a "infinite" ticket or a 1m ticket printing with this library and i tried it all.

This is a simplified code of my ticket printing.

THIS IS A SAMPLE OF THE CODE, IF THE TABLE ITEMS SIZE IS BIG THE PRINTING IS NOT COMPLETED:
    Dim PEP As Paper=Paper_static.c
   
    Dim leiout As PageLayout
    leiout=  P.CreatePageLayout(PEP, PageOrientation_Static.PORTRAIT,0, 0,0, 0)
    P.CreatePageLayout2(PEP, PageOrientation_Static.PORTRAIT,"HARDWARE_MINIMUM")
    Log(leiout.GetPrintableHeight)
   
    leiout.GetTopMargin
   
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P) '
   
    PJ.GetJobSettings.SetCopies(1)
   
    PJ.GetJobSettings.SetPrintQuality("HIGH")
    PJ.SetPrinter(P)
   
        Dim heit As Double=0
       
        Dim PANESIN As Pane
        PANESIN.Initialize("")
        PANESIN.PrefWidth=205
       
        Dim lbl As Label
        lbl.Initialize("")
        lbl.Text="TICKET CABECERA"
        lbl.TextSize=13
        lbl.Style="-fx-alignment:CENTER;-fx-font-weight:bold"';-fx-border-width:0.7;-fx-border-color:black"
        PANESIN.ADDNODE(lbl,0,0,196,15)
        heit=heit+15
                           
        Dim lbl As Label
        lbl.Initialize("f")
        lbl.STYLE="-fx-font-weight:bold"
        lbl.Text="P. UNIT ( CANT. ) DESCRIPCIÓN"
        lbl.TextSize=6.5
        PANESIN.ADDNODE(lbl,3,heit,150,14)
       
        Dim lbl As Label
        lbl.Initialize("g")
        lbl.TextSize=6.5
        lbl.Text="SUBTOT"
        lbl.Style="-fx-alignment:center_RIGHT;-fx-font-weight:bold"
        PANESIN.AddNode(lbl,154,heit,42,14)
        heit=heit+15
       
        Dim lbl As Label
        lbl.Initialize("e")
        lbl.Text=""
        lbl.TextSize=0
        lbl.STYLE="-fx-border-width:0.7;-fx-border-color:black"
        PANESIN.ADDNODE(lbl,3,heit,196,2)
        heit=heit+3
                       
        Dim TOT As Double=0
        Dim MAYORA  As Boolean=False
       
        For y=0  To tableventa.Items.Size-1
   
            Dim row() As Object=tableventa.Items.Get(y)
   
            Dim lbl As Label
            lbl.Initialize("j")
            lbl.TextSize=6.3
            lbl.Text="$ "&row(1)
            PANESIN.ADDNODE(lbl,3,heit,31,11)
                           
            Dim lbl As Label
            lbl.Initialize("k")
            lbl.TextSize=6.3
            lbl.Text="( "&NumberFormat(row(2),0,2)&" )"
            PANESIN.AddNode(lbl,34,heit,26,11)
                           
            Dim lbl As Label
            lbl.Initialize("l")
            lbl.TextSize=6.3
            lbl.Text="$ "&row(3)
            lbl.Style="-fx-alignment:center_RIGHT"';-fx-border-width:0.7;-fx-border-color:black"
            PANESIN.AddNode(lbl,159,heit,37,11)
           
            Dim lbl As Label
            lbl.Initialize("A")
            lbl.TextSize=6
            lbl.Text=row(0)
            Dim cuantosrengmas As Int=1
            If lbl.Text.Length>34 Then
                lbl.Style="fx-alignment:center_LEFT"';-fx-border-width:0.7;-fx-border-color:black"
                lbl.WrapText=True
                cuantosrengmas=2
                If lbl.text.Length>68 Then
                    cuantosrengmas=3
                End If
                PANESIN.ADDNODE(lbl,58,heit,100,11*(cuantosrengmas))
            Else
                PANESIN.ADDNODE(lbl,58,heit,100,11*(cuantosrengmas))
            End If
           
        heit=heit+(11*cuantosrengmas)
       
            TOT=TOT+row(3)
        Next
                       
            Dim lbl As Label
            lbl.Initialize("")
            lbl.TextSize=8
            lbl.Style="-fx-alignment:center_LEFT;-fx-font-weight:bold"';-fx-border-width:0.6;-fx-border-color:black"
            lbl.Text=" TOTAL: "&NumberFormat(TOT,0,2).replace(",","")
            PANESIN.ADDNODE(lbl,3,heit,196,14)
           
            heit=heit+15
           
        PANESIN.PrefHeight=heit
       
        Try
            PJ.PrintPage2(leiout,PANESIN)
        Catch
            Log(LastException)
        End Try
        PJ.EndJob
 

Alex Oscar Hedman

Member
Licensed User
I solved this problem.

the thing is that the POS printer has for default a short print, like 20cm long. When the order has a lots of products the printing never print the full ticket.

Print long POS ticket:
    Dim Printers As List = Printer_Static.GetAllPrinters
    Dim NOME As String
    printerConnected=False
    For Each PP As Printer In Printers
        NOME=PP.GetName
        If NOME.EqualsIgnoreCase(impresel)=True Then
            Dim P As Printer = PP
            printerConnected=True
            Exit
        End If
    Next
    Dim PEP As Paper
    Dim PJ As PrinterJob
    
    Dim leiout As PageLayout
    
    If printerConnected=False Then
        wait for (AbreNuevoCartel("PRINTER "&impresel&" NO CONNECTED","OK","","ATENCION","")) complete (result As Int)
        Return False
    End If
    
    Dim tiene As Boolean=False

    For Each PPc As JavaObject In P.GetPrinterAttributes.GetSupportedPapers
        PEP=Paper_static.C
        PEP.SetObject(PPc)
        Log(PEP.ToString)
        Dim VAL As String=PEP.tostring
        If VAL.contains("80 x 3276")=True  Then
            leiout=  P.CreatePageLayout(PEP, PageOrientation_Static.PORTRAIT,3,3,3,3)
            tiene=True
            Exit
        End If
    Next
    
    If tiene=False Then leiout=  P.CreatePageLayout(PEP, PageOrientation_Static.PORTRAIT,3,3,3,3)
    
    Try
        PJ = PrinterJob_Static.CreatePrinterJob2(P)
        PJ.GetJobSettings.SetCopies(1)
        PJ.GetJobSettings.SetPrintQuality("HIGH")
        PJ.SetPrinter(P)
        Sleep(0)
        PJ.PrintPage2(leiout,PANESIN)
        Sleep(0)
        PJ.EndJob
        Sleep(0)
    Catch
        Log(LastException)
    End Try


I don't know this solution it's the correct way to do it but the ticket prints up to 3 meters XD.
 
Upvote 0
Top