I am trying to print directly to a printer using esc / p commands (EPSON TM-T70) without using a printer driver. The code is found here .
However, if I try to print any lines, they are truncated. For instance:
MyPrinter := TRawPrint.Create(nil); try MyPrinter.DeviceName := 'EPSON TM-T70 Receipt'; MyPrinter.JobName := 'MyJob'; if MyPrinter.OpenDevice then begin MyPrinter.WriteString('This is page 1'); MyPrinter.NewPage; MyPrinter.WriteString('This is page 2'); MyPrinter.CloseDevice; end; finally MyPrinter.Free; end;
Will print only "This isThis"! I would normally not use MyPrinter.NewPage to send a line break command, but no matter why it truncates the line?
Also note the RawPrint WriteString function:
Result := False; if IsOpenDevice then begin Result := True; if not WritePrinter(hPrinter, PChar(Text), Length(Text), WrittenChars) then begin RaiseError(GetLastErrMsg); Result := False; end; end;
If I put a breakpoint and go through the code, then WrittenChars will be set to 14, which is correct. Why is this so?
source share