Yevhen
Yevhen

Reputation: 801

Printout special symbols on thermal printer

I have trouble printing special symbols(€, £, ¥, ý) on an EPSON TM-T88V thermal printer over esc/pos commands. Here is part of code:

FPrintoutLines := TStringList.Create;
try
  FPrintoutLines.Add(#$1B'@');
  FPrintoutLines.Add(#$1B't'#16);
  FPrintoutLines.Add('€, £, ¥, ý'+#$A);
  Print
finally
  FPrintoutLines.Free;  
end;

On Windows XP I have correct printout with all symbols, the problem is with Windows 7 and 8.

I build a stringlist with commands, then send this line by line to the printer. This it works perfectly for all other symbols and images but not for special symbols.

Can somebody help me, how can I print this symbols from any Windows?

Here is the code that prints the lines:

var
  vCurrentLine : AnsiString;
begin
...
for i := 0 to FPrintoutLines.Count - 1 do begin
  vCurrentLine := AnsiString(FPrintoutLines[i]);

  if (PrintRawData(hPrn, PAnsiChar(vCurrentLine), Length(vCurrentLine)) < 0) then begin
    log('PrintRawData error', 'NativePrint');
    EndRawPrintPage(hPrn);
    EndRawPrintJob(hPrn);
    Exit;
  end;

end;

Upvotes: 1

Views: 1860

Answers (1)

Yevhen
Yevhen

Reputation: 801

I have found the way. Here is the function for to convert string before send it to printer. Now it works correctly on all Windows

function TNativePrint.WideStringToString(const AStr : UnicodeString; vCodePage : Word) : AnsiString;
var
  vLen: Integer;
begin
  vLen := Length(AStr);

  if (vLen = 0) then begin
    result := '';
    exit;
  end;

  SetAnsiString(@result, @AStr[1], vLen, vCodePage);
end;

Upvotes: 0

Related Questions