【问题标题】:How can I print a Code-128 barcode with a TOposPosPrinter control?如何使用 TOposPosPrinter 控件打印 Code-128 条码?
【发布时间】:2021-11-14 14:37:11
【问题描述】:

请帮忙!

我正在尝试使用来自 CRM/RCS-Dayton 的 TOposPosPrinter 控件打印 Code-128 条形码。

虽然我在打印纯文本、打印徽标和剪纸方面没有任何问题,但遗憾的是条形码根本无法使用。

OPOSPOSPrinter1 := TOPOSPOSPrinter.Create(nil);
If IniOposLogoYn = true then printLogo;
OPOSPosPrinter1.Open(IniOposPrinterName);
OPOSPosPrinter1.AsyncMode := false;
OPOSPOSPrinter1.ClaimDevice(1000);
OPOSPOSPrinter1.DeviceEnabled := True;
OPOSPosPrinter1.PrintNormal(2, getWideString(BonTekst));
OPOSPosPrinter1.PrintBarCode(2, '12345678901234', 1, 500, 500, 1, 1);
OPOSPosPrinter1.CutPaper(100);
Sleep(50); 
OPOSPosPrinter1.DeviceEnabled := False;
OPOSPosPrinter1.ReleaseDevice;
OPOSPosPrinter1.Close;
OPOSPOSPrinter1.Free;

这只是我正在使用的代码的一个片段,除了 OPOSPosPrinter1.PrintBarCode 的行之外,一切都运行良好...

我正在为这个应用程序使用 Delphi 7。

任何想法如何解决这个问题?

【问题讨论】:

  • 我不知道 TOPOSPOSPrinter 库。你能自己调试一下看看发生了什么吗?你能向作者寻求帮助吗?
  • 我当然试过了,但我找不到原因……
  • 文档对PrintBarCode() 参数的含义有何评论
  • 这是我能找到的唯一文档,它只是函数的签名:function PrintBarCode(Station: Integer; const Data: WideString; Symbology: Integer; Height: Integer; Width: Integer; Alignment :整数;TextPosition:整数):整数;安全呼叫;
  • 所以,因为它是一个函数,它可能会返回一个错误代码,但你不检查返回值!是否有理由要求 500 作为高度和宽度?也许 100 的高度会更接近您的需要? (只是推测,因为您没有解释任何代码)。打印机的品牌和型号是什么?

标签: delphi delphi-7


【解决方案1】:

文档就在附近,就在 de C++ 标头中...

OPOSPosPrinter1.PrintBarCode(2, '2420000004934', 110, 200, 200, -2, -13);

这条线完全符合我的要求...打印 CODE-128 条码...

【讨论】:

  • 很好,但我仍然建议您检查每次调用打印机的返回值是否存在最终错误!有时纸卷用完、卡纸等等。
猜你喜欢
  • 2018-04-21
  • 2013-03-26
  • 2014-04-22
  • 2015-05-06
  • 2022-01-19
  • 2012-12-04
  • 2012-05-13
  • 2014-08-07
  • 2012-06-08
相关资源
最近更新 更多