Print ZPL file to Zebra printer results into ASCII dump

206 Views Asked by At

I am trying to send a ZPL file to a Zebra printer, but the contents of the file are being printed as ASCII text without being interpreted.

I have tried some of the solutions provided in the following Stackoverflow threads, but none of them seem to work:

Delphi printing to Zebra printer

Sending commands directly to Zebra EPL

Delphi print memo to zebra printer

Note that the ZPL file is provided to us by the parcel service, and I am not sure if the problems I am experiencing are related to the UTF8 encoded strings mentioned in one of the threads.

I am using Delphi 11.3.

Any ideas?

1

There are 1 best solutions below

0
On BEST ANSWER

I installed another instance of the printer and used the ‘generic/text’ driver only.

Finally, this small code fragment did the job:

var
  F: TextFile;
  I: Integer;
begin
  Printer.PrinterIndex := ComboBox1.ItemIndex;
  AssignPrn(F);
  ReWrite(F);
  for I := 0 to FileToPrint.Count - 1 do
    WriteLn(F, FileToPrint[I]);
  CloseFile(F);
end;

Note:

  • ComboBox1 contains the printers available in Windows. It was populated by using ComboBox1.Items := Printer.Printers;

  • FileToPrint is a TStringList, containing the actual ZPL file by using FileToPrint.LoadFromFile(OpenDialog1.FileName);

Thank you, KIKO Software, Dale M, and Delphi Coder, for your comments. Your feedback helped me explore some paths that I had not considered before. As a result, I decided to install an additional printer instance using the ‘generic/text’ driver.