PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, September 16, 2022

[FIXED] How to print CODE128 barcode to POS Thermal printer properly using Delphi?

 September 16, 2022     barcode, delphi, epson, pascal, printing     No comments   

Issue

I am trying to print code128 barcode directly to POS printer using this code:

DirectToPrinter(chr(29)+chr(107)+chr(72)+Chr(123)+Chr(65)+'8600123456789', true);

According to the documentation here: https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=128, I have included { (123) and character for code A (65), but I wonder why I am getting only digits printed out but no lines.

Any idea?

By the way, I am using EPSON TM88V POS Thermal Printer.

nction tform1.DirectToPrinter(S: AnsiString; NextLine: Boolean): Boolean;
var
  Buff: TPrnBuffRec;
  TestInt: Integer;
  i: integer;
   Device: PChar;
  Driver: PChar;
  Port: PChar;
begin
  TestInt := PassThrough;
  if Escape(Printer.Handle, QUERYESCSUPPORT, SizeOf(TESTINT), @testint, nil) > 0 then
  begin
    if NextLine then  S := S + #13 + #10;
    StrPCopy(Buff.Buff_1, S);
    Buff.bufflength := StrLen(Buff.Buff_1);
    Escape(Printer.Canvas.Handle, Passthrough, 0, @buff, nil);
    Result := True;
  end
  else
    Result := False;
end;


Solution

This issue is solved (kudos to Tom) by adding the number of characters chr(13) and replacing chr(72) to chr(73), like this:

DirectToPrinter( chr(29)+chr(107)+chr(73)+chr(13)+chr(123)+Chr(65)+'8600123456789', true ); 


Answered By - Vladimir
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing