打印完后如何使其"不"自动换页?(150分)

  • 主题发起人 主题发起人 liuaono1
  • 开始时间 开始时间
L

liuaono1

Unregistered / Unconfirmed
GUEST, unregistred user!
打印机为 LQ - 1600K , 页面设置为自定义,打印完后如何使其"不"自动换页?
(注:LQ - 1600KIII 打印机,连续纸模式下能做到"不"自动换页),字符串打印代码
如下,请您修改:

procedure Tkd1.PrintStrings(Strings1: TStrings);
var
MyFile: TextFile;
i: word;
begin

SetPaperSize(2230,30);
Printer.PrinterIndex := -1;
AssignPrn(MyFile);
try
Rewrite(MyFile);
printer.canvas.font.size:=14;
writeln(MyFile, ' 月未/已平衡出库单号码');
writeln(MyFile);
printer.canvas.font:=SrcList.font;
try
if Strings1.Count=0 then
writeln(MyFile, ' 未: '+'无')
else
for i := 0 to Strings1.Count-1 do

case (i mod 10) of
0 : if i=0 then
write(MyFile, ' 未: '+Strings1.Strings)
else
write(MyFile, ' '+Strings1.Strings);
9 : writeln(MyFile, ' '+Strings1.Strings);
else
write(MyFile, ' '+Strings1.Strings);
end;

finally
CloseFile(MyFile);
end;

except
on EInOutErrordo

MessageDlg('打印出错!', mtError, [mbOk], 0);
end;

end;


 
补充一句:“不”自动换页即是想使它打印完后就停下来。
大虾、小虾们,帮帮忙吧!
 
这需要打印机的逐行支持,拒我所知针式打印机都可以,但喷墨和激光则可能不行!
 
也许不行
 
动态设置页长
 
采用逐行打印试试!代码如下:
var Myprinter : TRawPrinter;
oldprinter : TPrinter;
begin

MyPrinter:=TRawPrinter.Create;
oldprinter:=setprinter(MyPrinter);
try
if Printdialog1.execute then

begin

myprinter.startraw;
myprinter.write('khsdhskhkshdksd');
myprinter.writeln;
myprinter.endraw;
end
finally
setprinter(oldprinyter);
myprinter.free;
end
end;

Here is the code for the raw printer object.
unit Rawprinter;
interface
uses printers,windows;
type TRawprinter =class(TPrinter)
public
dc2 : HDC;
procedure startraw;
procedure endraw;
procedure write(const s : string);
procedure writeln;
end;

implementation
uses sysutils,forms;
function AbortProc(Prn: HDC;
Error: Integer): Bool;
stdcall;
begin

Application.ProcessMessages;
Result := not Printer.Aborted;
end;

type
TPrinterDevice = class
Driver, Device, Port: String;
constructor Create(ADriver, ADevice, APort: PChar);
function IsEqual(ADriver, ADevice, APort: PChar): Boolean;
end;

constructor TPrinterDevice.Create(ADriver, ADevice, APort: PChar);
begin

inherited Create;
Driver := ADriver;
Device := ADevice;
Port := APort;
end;

function TPrinterDevice.IsEqual(ADriver, ADevice, APort: PChar): Boolean;
begin

Result := (Device = ADevice) and (Port = APort);
end;

procedure TRawprinter.startraw;
var
CTitle: array[0..31] of Char;
CMode : Array[0..4] of char;
do
cInfo: TDocInfo;
r : integer;
begin

StrPLCopy(CTitle, Title, SizeOf(CTitle) - 1);
StrPCopy(CMode, 'RAW');
FillChar(DocInfo, SizeOf(DocInfo), 0);
withdo
cInfodo

begin

cbSize := SizeOf(DocInfo);
lpszDocName := CTitle;
lpszOutput := nil;
lpszDatatype :=CMode;
end;

with TPrinterDevice(Printers.Objects[PrinterIndex])do

begin

DC2 := CreateDC(PChar(Driver), PChar(Device), PChar(Port), nil);
end;

SetAbortProc(dc2, AbortProc);
r:=StartDoc(dc2,do
cInfo);
end;

procedure TRawprinter.endraw;
var r : integer;
begin

r:=windows.enddoc(dc2);
end;

type passrec = packed record
l : word;
s : Array[0..255] of char;
end;

var pass : Passrec;
procedure TRawprinter.write(const s : string);
begin

pass.l:=length(s);
strpcopy(pass.s,s);
escape(dc2,PASSTHROUGH,0,@pass,nil);
end;

procedure TRawprinter.writeln;
begin

pass.l:=2;
strpcopy(pass.s,#13#10);
escape(dc2,PASSTHROUGH,0,@pass,nil);
end;

end.

 
驱动程序和打印机是同型号的吗?
 
only you :
  你的代码运行非常成功!在我给你加分之前,我想请你将 
TRawprinter.writeln 过程改成可写一行字符串的形式,即
有 writeln;
和 writeln('字符串'); 两种书写形式.
  成则再给你加 100 分!
  拜托!谢谢!!
  
 
only you的方法我怎么没有测试成功?????
我的配置:win2000,lq1600KIII,d5,驱动程序用的是lq1900K!!
为什么???
 
接受答案了.
 
后退
顶部