怎样控制串口票据打印机打印?(200分)

  • 主题发起人 主题发起人 wsh001
  • 开始时间 开始时间
W

wsh001

Unregistered / Unconfirmed
GUEST, unregistred user!
有一个EPSON TM 300的9针票据打印机,不知怎样用DELPHI程序控制此打印机打印?
望各位专家赐教!谢谢!急急!
 
自己没有带控制软件吗?
 
吴向球你好,我这只有它的驱动,别的控制软件没有,请给予指点.
 
你可以用打印机的控制码控制打印机。如:
Supported Commands|Command Name Function
HT Horizontal tab Print position
LF Print and line feed Print
CR Print and carriage return Print
DLE EOT Real-time status transmission Status
DLE ENQ Real-time request to printer Miscellaneous function
ESC SP Set right-side character spacing Character
ESC ! Select print mode(s) Character
ESC % Select/cancel user-defined character set Character
ESC &
Define user-defined characters Character 1-9
ESC [ Select bit-image mode Bit image 1-21
ESC – Turn underline mode on/off Character 1-15
ESC 2 Select default line spacing Line spacing 1-7
ESC 3 Set line spacing Line spacing 1-7
ESC < Return home Mechanism control 1-30
ESC = Select peripheral device Miscellaneous function 1-33
ESC ? Cancel user-defined characters Character 1-9
ESC @ Initialize printer Miscellaneous function 1-31
ESC D Set horizontal tab positions Print position 1-20
ESC E Turn emphasized mode on/off Character 1-15
ESC G Turndo
uble-strike mode on/off Character 1-16
ESC J Print and feed paper Print 1-5
ESC K Print and reverse feed Print 1-5
ESC R Select an international character set Character 1-12
ESC U Turn unidirectional printing mode on/off Mechanism control 1-30
ESC a Select justification Print position 1-21
ESC c 3 Select paper sensor(s) to output paper-endsignals Paper sensor 1-18
ESC c 4 Select paper sensor(s) to stop printing Paper sensor 1-18
ESC c 5 Enable/disable panel buttons Panel button 1-17
ESC d Print and feed n lines Print 1-6
ESC e Print and reverse feed n lines Print 1-6
ESC p Generate pulse Miscellaneous function 1-33
ESC t Select character code table Character 1-13
ESC { Turn upside-down printing mode on/off Character 1-16
GS I Transmit printer ID Miscellaneous function 1-32
GS V Select cut mode and cut paper Mechanism control 1-30
GS a Enable/disable Automatic Status Back (ASB) Status 1-22
GS r Transmit status Status 1-26
GS z 0 On-line recovery wait time Miscellaneous function

你可以在用这些控制码实开钱箱,切纸等功能,关于打印方面与其它打印机基本一样。
 
不知这些控制码在DELPHI里面怎么控制?
 
procedure TForm1.Button6Click(Sender: TObject);
var
prn: TextFile;
str: String;
begin

Assignfile(prn,'com1');
// or 'com1'
Rewrite(prn);
str := #27'a';
Writeln(prn, str);
//控制码 如:chr(27)+'a'
CloseFile(prn);
end;

 
函数名:WritePrintDoc
参数1:PrintNameStr 打印机名称
参数2:PrintStr 向该打印发送的数据

例:WritePrintDoc('TM-300A',Chr(27)+'i');
//实现打印机切纸功能

procedure WritePrintDoc(PrintNameStr,PrintStr:String);
Var
do
cInfo1:TDocInfo1;
Handle:THandle;
N_N:DWORD;
begin

If Not OpenPrinter(Pchar(PrintNameStr),Handle,Nil) then
Exit;
Withdo
cInfo1do

begin

pDocName:=PChar('百汇科技*超市系统');
//打印机JOB的名称
pOutputFile:=nil;
pDataType:='RAW';
end;


StartDocPrinter(Handle,1,@DocInfo1);
StartPagePrinter(Handle);
WritePrinter(Handle,PChar(PrintStr),Length(PrintStr),N_N);
EndPagePrinter(Handle);
EndDocPrinter(Handle);
ClosePrinter(Handle);
end;

 
编译不过去,TDocInfo1是什么?
 
TDocInfo1这个类在Winspool中
在程序开始的uses语句中增加Winspool就可以了
 
to blbird,caixiang78
谢谢你们两位给我提供了原码,在两位的帮助下
我的问题现在已经基本解决.
 
多人接受答案了。
 
后退
顶部