Home > Back-end >  Spcomm and comport serial pos printing problems
Spcomm and comport serial pos printing problems

Time:09-20

D7 and xe7 tried, epson tm - t58 serial printer, dress not installed driver are tried,
Question:
1, comport printing digital English is no problem, Chinese characters will be garbled xe7 win7x86
 procedure TForm1. Button4Click (Sender: TObject); 
The begin
ComPort1. Close;
ComPort1. Open;
end;

Procedure TForm1. Button9Click (Sender: TObject);
Var
S: a string;
The begin
ComPort1. ClearBuffer (true, true);

S:=memo1. Text;
ComPort1. WriteStr (s);
end;

Procedure TForm1. Button10Click (Sender: TObject);
The begin
ComPort1. Close;
end;

2, when two controls the print is a line of a meal, as printers print yourself parameters "brush" just come out, how to do,
(print their parameters: turn off the power supply, holding down the feed button boot)

CodePudding user response:

Either epson print instruction,
Or take the mature printing control and the implementation of print,

CodePudding user response:

See cport source (I was) of 4.0 writestr () is not support unicodestring, just come to extract the low byte unicode, high byte abandoned,
Printers, however, generally do not think you such a direct serial write string, no code?

The function TCustomComPort. WriteStrAsync (var Str: string; Var AsyncPtr: PAsync) : Integer;
Var sa: Ansistring; Var I: integer;
The begin
If Length (Str) & gt; 0 then
The begin
Setlength (sa, length (STR));
{$IFDEF Unicode}
If length (sa) & gt; 0 then
The begin
For I:=1 to length (STR) do sa: [I]=ansichar (byte (STR [I]));
Move (sa [1], the STR [1], the length (sa));
end;
{$ENDIF}
Result:=WriteAsync (Str [1], the Length (Str), AsyncPtr)
End
The else
Result:=0;
end;
//perform synchronous write operation
The function TCustomComPort. WriteStr (Str: string) : Integer;
Var
AsyncPtr: PAsync;
The begin
InitAsync (AsyncPtr);
Try
WriteStrAsync (Str, AsyncPtr);
Result:=WaitForAsync (AsyncPtr);
The finally
DoneAsync (AsyncPtr);
end;
end;

CodePudding user response:

Generally printer tprinter class can be used to print, whether to print the image or text, directly on the canvas painting, stylus printer, of course, don't know much about it

CodePudding user response:

In the impression, the printer can only identify ASCII, you send refers to this should be sent to the printer is ASCII

So, you need to make sure the print mechanism and process!
1. The printer startup instruction
2. System converting text encoding printer code
3. The end of the printed instructions

Based on the description of the building Lord, printer to recognize English characters, I suspect that the original poster is poor converts text to a standard ANSI code in this step, should be in XE7 ANSISTRING
  • Related