B4A Library ESC/POS Thermal Printer

Hi, I share this ESC/POS Thermal Printer lib, I only tried it with Bluetooth, and to try with USB and TCP and BLE, I didn't have the opportunity to try it, anyway for help https://github.com/DantSu/ESCPOS-ThermalPrinter- Android".
a greeting
 

Attachments

  • ESCPOSThermalPrinter.zip
    22.6 KB · Views: 476
  • Lib.zip
    63.8 KB · Views: 424

amarnath

Member
Licensed User
Longtime User
build tools: 34.0.0, android jar: android-34
Compiling debugger engine code. (8.62s)
Compiling generated Java code. Error
Cannot find: C:\Program Files\Anywhere Software\B4A\libraries\core-3.5.2.jar
 

Xfood

Expert
Licensed User
build tools: 34.0.0, android jar: android-34
Compiling debugger engine code. (8.62s)
Compiling generated Java code. Error
Cannot find: C:\Program Files\Anywhere Software\B4A\libraries\core-3.5.2.jar
try downloading the missing file from here, put it in the additional libraries folder


1730709693872.png
 

Setlodi

Active Member
Hi, roberto64

Thank you for this library. How do you change the width of the paper. It seems to be set for 58mm paper and I want to see if I can use with my printer which is 80mm.

Thanks
 
Last edited:

vecino

Well-Known Member
Licensed User
Longtime User
You don't have to do anything, you can simply write longer lines, instead of:
print(‘123456789*123456789*123456789*12345’)
you can print more:
print(‘123456789*123456789*123456789*123456789*123456789*12345’)
 

roberto64

Active Member
Licensed User
Longtime User
hello everyone, sorry I haven't replied because I had a lot to do. greetings to the whole forum
 

Setlodi

Active Member
Thanks for coming back Roberto.

I have managed to get the printer working and it is printing well, except for centering text. As you can see in the attached images, even your example seems to centering towards the left. Text is centering but it's doing so from the left margin. Would you kindly assist me sort this out.

Header Code:
    sb.Append("[C]<font size='big'>").Append(Report_Business_Name).Append("</font>").Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Address1).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Address2).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Address3).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Phone).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Email).Append(CRLF)

Thank you in advance.

printouts.jpg
 

roberto64

Active Member
Licensed User
Longtime User
Hi, unfortunately I've been very busy lately,
WARNING ⚠ : This tag has several constraints :

A line that contains <img></img> can have only one alignment tag and it must be at the beginning of the line.
<img> must be directly preceded by nothing or an alignment tag ([L][C][R]).
</img> must be directly followed by a new line \n.
You can't write text on a line that contains <img></img>.
Maximum height of printed image is 256px, If you want to print larger bitmap.
 

roberto64

Active Member
Licensed User
Longtime User

Text alignment and column separation​

Add an alignment tag on a same line of text implicitly create a new column.

Column alignment tags :

  • [L] : left side alignment
  • [C] : center alignment
  • [R] : right side alignment
Example :

  • [L]Some text : One column aligned to left
  • [C]Some text : One column aligned to center
  • [R]Some text : One column aligned to right
  • [L]Some text[L]Some other text : Two columns aligned to left. Some other text starts in the center of the paper.
  • [L]Some text[R]Some other text : Two columns, first aligned to left, second aligned to right. Some other text is printed at the right of paper.
  • [L]Some[R]text[R]here : Three columns.
  • [L][R]text[R]here : Three columns. The first is empty but it takes a third of the available space.
 

Setlodi

Active Member
Thanks for your response Roberto

In my code I have only 1 column that I'm trying to centre right. Is there anything that is missing from my code?

B4X:
    sb.Append("[C]<font size='big'>").Append(Report_Business_Name).Append("</font>").Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Address1).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Address2).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Address3).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Phone).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Email).Append(CRLF)
 

f0raster0

Well-Known Member
Licensed User
Longtime User
Thanks for your response Roberto

In my code I have only 1 column that I'm trying to centre right. Is there anything that is missing from my code?

B4X:
    sb.Append("[C]<font size='big'>").Append(Report_Business_Name).Append("</font>").Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Address1).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Address2).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Address3).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Phone).Append(CRLF)
    sb.Append("[C]").Append(Report_Business_Email).Append(CRLF)
sb.Append("[R]")
 

roberto64

Active Member
Licensed User
Longtime User
Hi, it's been a long time since I've seen this library, anyway sb.Append("[R]").Append("Title").Append(CRLF)
 

Setlodi

Active Member
Still no luck:

Header:
    sb.Append("[R]<b><font size='big'>").Append(Receipt_Business_Name).Append("</font></b>").Append(CRLF)
    sb.Append("[R]").Append(Receipt_Business_Address1).Append(CRLF)
    sb.Append("[R]").Append(Receipt_Business_Address2).Append(CRLF)
    sb.Append("[R]").Append(Receipt_Business_Address3).Append(CRLF)
    sb.Append("[R]").Append(Receipt_Business_Phone).Append(CRLF)
    sb.Append("[R]").Append(Receipt_Business_Email).Append(CRLF)

    sb.Append("[R]").Append(Receipt_Message1).Append(CRLF)
    sb.Append("[R]").Append(Receipt_Messaage2).Append(CRLF)
    sb.Append("[R]").Append(Receipt_Message3).Append(CRLF)
    sb.Append("[R]").Append(Receipt_Message4).Append(CRLF)
    sb.Append("[R]").Append(Receipt_Mess[ATTACH]160983[/ATTACH][ATTACH]160983[/ATTACH]age5).Append(CRLF)
 

Attachments

  • Till slip.png
    Till slip.png
    280.7 KB · Views: 37
Top