【问题标题】:Printing bar codes on Star TSP100 in Delphi 7在 Delphi 7 中的 Star TSP100 上打印条形码
【发布时间】:2013-08-05 11:38:37
【问题描述】:

我有一个 Star Micronics TSP100 printer,我正试图通过 Delphi 7 中的 OPOS 使用它。我似乎无法让它打印条形码。

我可以打开、声明和启用、打印文本和剪切,但不能打印条形码。

我尝试了很多方法来导入 Active X 控件来处理打印机,就像我对 Bixolon 三星 POS 打印机所做的那样,效果很好。

欢迎任何指点。
代码:

procedure TForm1.OpenbtnClick(Sender: TObject);
begin
  showmessage(inttostr( posprinter1.Open('StarTSP100')));
end;

procedure TForm1.ClaimbtnClick(Sender: TObject);
begin
   showmessage(inttostr( posprinter1.ClaimDevice(0)));
end;

procedure TForm1.EnablebtnClick(Sender: TObject);
begin
  POSPrinter1.DeviceEnabled := True;
end;

procedure TForm1.PrintbtnClick(Sender: TObject);
begin
  POSPrinter1.PrintNormal(2,'A Test' + #10);
end;

procedure TForm1.PrintBCbtnClick(Sender: TObject);
begin
  POSPrinter1.PrintBarCode(2, '1234567890', 108, 1000, trunc(POSPrinter1.RecLineWidth * 0.8), -2, -13);
end;

procedure TForm1.CutbtnClick(Sender: TObject);
begin
  POSPrinter1.CutPaper(100);
end;

end.

【问题讨论】:

  • PrintBarCode 的返回值是多少?
  • 返回值 0 - 打印机来回移动纸张但不做任何标记
  • 抱歉,当使用​​高度 96 时返回值为 0 - 使用高度 1000 返回 106。

标签: delphi printing activex barcode


【解决方案1】:

您可以通过CapRecBarCode方法检查打印机是否支持条码打印。

您将条形码尺寸设置为 1000 高 x (RecLineWidth * 0.8) 宽。如果条形码对于纸张来说太大,或者如果您分配的空间对于条形码字符串的长度来说是两个小,则它往往不会被打印。

可能 1000 的高度太大,所以没有打印出来,如果是这种情况,PrintBarcode 的返回值将是106 - Illegal。尝试一个更小的数字,我们使用6096 作为高度。

【讨论】:

  • CapRecBarCode 返回真。我已将高度值更改为 60 并再次更改为 96,没有区别。此外,在发送剪切纸之前,它不会打印任何普通文本。
  • 另外我想知道我应该在 Delphi 中注册哪个 OCX
  • 附加换行符时打印
  • @ReOsless 只是想对您的提示表示感谢并解决了问题
【解决方案2】:

我测试了自动代码并发现了问题。 您必须设置 MapMode = 4; (默认 MapMode = 1) 之后就可以打印Code 39,EAN,代码打印了。

procedure TForm1.PrintBCbtnClick(Sender: TObject);
begin
POSPrinter1.MapMode := 4;  
POSPrinter1.PrintBarCode(2, '1234567890', 108, 1000, trunc(POSPrinter1.RecLineWidth * 0.8), -2, -13);
end;

【讨论】:

    猜你喜欢
    • 2012-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-14
    相关资源
    最近更新 更多