プリンタードライバーを使用せずに、esc/p コマンド (EPSON TM-T70) を使用してプリンターに直接印刷しようとしています。コードはこちらにあります。
ただし、文字列を印刷しようとすると、切り捨てられます。例えば:
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;
「This isThis is」のみを出力します。通常MyPrinter.NewPage
、改行コマンドを送信するために使用することはありませんが、それにもかかわらず、なぜ文字列が切り捨てられるのでしょうか?
また、RawPrint ユニットWriteString
関数にも注意してください。
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;
そこにブレークポイントを置いてコードをステップ実行すると、WrittenChars
正しい 14 に設定されます。なぜそのように振る舞うのですか?