如何使用Delphi正确地将CODE128条码打印到POS热敏打印机?
我试图使用此代码直接将Code128条形码直接打印到POS打印机:
DirectToPrinter(chr(29)+chr(107)+chr(72)+Chr(123)+Chr(65)+'8600123456789', true);
根据文档: https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=128 ,我包括{(123)和代码A(65)的字符,但我想知道为什么我只得到数字打印出来,但没有行。
有什么想法吗?
顺便说一句,我正在使用Epson TM88V POS热打印机。
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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过添加字符Chr(13)并将Chr(72)替换为Chr(73),可以解决此问题(对TOM的荣誉),如下所示:
This issue is solved (kudos to Tom) by adding the number of characters chr(13) and replacing chr(72) to chr(73), like this: