Quantcast
Channel: Embarcadero Community - Embarcadero Community
Viewing all articles
Browse latest Browse all 1963

How to print bar code with type 128 on POS Epson printer receipt in Delphi Pascal

$
0
0

I am using Embarcadero® RAD Studio 10.2 Version 25.0.26309.314.

I have took reference of pdf file to print bar code which present at http://www.starmicronics.com/support/mannualfolder/escpos_cm_en.pdf. On page 150 in pdf, some information are provided to print bar code with some sequence or pattern (GS k m n d1 ... dk, #29 + #107 + #73 + Data + #0 + #10) which I have used in my code.

I am using below code in Delhi/Pascal to print bar code and also took reference to print bar code from http://www.mofeel.net/1102-comp-lang-pascal-delphi-misc/3077.aspx.

function WriteFile(hFile: THandle; const Buffer; nNumberOfBytesToWrite: DWORD; 
      var lpNumberOfBytesWritten: DWORD; lpOverlapped: POverlapped): BOOL; stdcall;

procedure TMyPosForm.PrintBarcode(const Data: WideString);
var
  BytesWritten: DWORD;
  sToSend: AnsiString;
begin
  sToSend := #27 + 'a' + #1;
  try
    WriteFile(vReceiptPrtPortHwnd, sToSend[1], Length(sToSend), BytesWritten, nil);
  except
  end;

  //sToSend := #29 + #107 + #2 + '1234567890123'+ #0 ;  // GS k m d1…dk NUL  for barcode EAN13 // WORKING
  //sToSend := #29 + #107 + #73 + '123456789012' + #0 + #10; // GS k m n d1…dn for barcode 128 // NOT WORKING
  sToSend := #29 + #107 + #73 + Data + #0 + #10; // NOT WORKING

  try
    WriteFile(vReceiptPrtPortHwnd, sToSend[1], Length(sToSend), BytesWritten, nil);
  except
  end ;

  // Justify  Left
  sToSend := #27 + 'a' + #0;
  try
    WriteFile(vReceiptPrtPortHwnd, sToSend[1], Length(sToSend), BytesWritten, nil);
  except
  end;
end;

In code, I am sending above ESC/POS Command combination/squesnce in Winapi.Windows WriteFile function which prints barcode on the receipt on epson based printer.

I have also asked the same question at https://stackoverflow.com/questions/46426790/esc-pos-command-combination-for-barcode-code-128-in-delphi-pascal.

If anybody has idea about this then please share. Thanks.

 


Viewing all articles
Browse latest Browse all 1963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>