Categories
Delphi

Sending Bitmap to Epson printer using Delphi and ESC/POS

I have previously tried to use http://nicholas.piasecki.name/blog/2009/12/sending-a-bit-image-to-an-epson-tm-t88iii-receipt-printer-using-c-and-escpos/ and the attached Delphi translation to send a TBitmap directly to Epson TM T20, TM T80 and TM88 printers. Unfortunately it never worked.

Recently I needed to print dynamically created QR codes using the printers so it was time to revisit this. I worked directly off the C# sources provided and created a Delphi class to replicate this.

I’ve added this to a GIT repository on Bitbucket in case anyway needs to use it in future.

Project Home: https://bitbucket.org/bernd_summerswell/delphi_escpos_bitmap/

Example Usage:

This uses the Synaser library from Synapse to send the buffer directly to a COM Port.

uses
  synaser,
  ssESCPOSPrintBitmap;

var
  LBuffer : string;
  LDevice : TBlockSerial;
begin
  LBuffer := #27'@'; // Initialise the printer
  LBuffer := LBuffer + _ESCPosPrintBitmap().RenderBitmap( 'pathtobitmapfile' );
  LBuffer := #29'V'#1 // Paper cut full

  // Send LBuffer to Printer
  LDevice := TBlockSerial.Create();
    try
      LDevice.Config( 115200, 8, 'N', 1, False, False );
      LDevice.Connect( 'COM7' );
      LDevice.SendString( LBuffer  );
    finally
      LDevice.Free();
    end;
end.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.