0

I'm trying to code a order printing program with delphi xe 6. And I found this code on internet

  type
  TPassThroughData = record
      nLen: Word;
      Data: array[0..255] of Byte;
  end;

procedure PrintText(s: string);
var
  PTBlock: TPassThroughData;
begin
  PTBlock.nLen := Length(s);
  StrPCopy(@PTBlock.Data, s);
  Escape(Printer.Handle, PASSTHROUGH, 0, @PTBlock, nil);
end;

procedure PrintOut;
begin
  Printer.BeginDoc;
  PrintText(#27'&l12D' + 'Hello, World!');
  Printer.EndDoc;
end;

and seams its working not like I want. It prints empty line and cuts paper and no any data on paper. I'm using IBM receipt printer type4610-1nr. And I want to ask you guys any idea how I can print data on it?

existas
  • 3
  • 2
  • Does it work on other printers? Does it work without the escape code? Maybe also add line feed. And escape codes should be valid for the specific printer type, have you checked that in the documentation for the printer? – Pieter21 Sep 22 '14 at 23:04
  • 1
    Since you are using XE6 the type `String` is Unicode. I would expect that the printer can only deal with ANSI. – bummi Sep 23 '14 at 04:58
  • See also [Sending printer specific commands](http://stackoverflow.com/q/9812264/576719). You definitely need to change `String` to `AnsiString`; – LU RD Sep 23 '14 at 05:46

1 Answers1

0

Printing on a printer like the IBM 4610, is a little bit more complicated that putting string on an output stream ... I don't know what is it the Printer object here however the suggestion that I can give to you is to read carefully the Programming Guide of the printer .

Anyway to print a single line without cutting the paper, after sending the ASCII data for the line you should put this command line :

X'0A'

Keep in mind that as someone correctly stated : the printer can handle only ASCII data string, so you need to use AnsiString in Delphi XE ...

aleroot
  • 71,077
  • 30
  • 176
  • 213