使用TPrinters类,多页连续纸打印如何控制自动分页(200分)

  • 主题发起人 主题发起人 kgdu
  • 开始时间 开始时间
K

kgdu

Unregistered / Unconfirmed
GUEST, unregistred user!
使用TPrinters类
var i:integer;
begin
printer.begin
doc;
for i:=1 to 99999do
printer.canvas.textout(i*100,200,'假定这是打印内容');
printer.enddoc;

end;
以上代码打印一页后就停了下来,如何使之继续打印。有例子看下吗?
本人对delphi打印不太了解,望指点。。。。。不够分还可再加+++++
QQ:664759343 或 TEL:13640482220酬谢
 
printer.begin
Doc;
printer.Canvas.Font.Size:=11;
printer.Canvas.Font.Name:='宋体';
h:=0;
Tdytm.First;
with Tdytmdo
begin
while not(Tdytm.Eof)do
begin
with printer.Canvasdo
begin
TextOut(tdycs.FieldValues['床次1'],y,inttostr(fieldvalues['cc']));
TextOut(tdycs.FieldValues['尺码1'],y,fieldvalues['cm']);
TextOut(tdycs.FieldValues['制单1'],y,editdh.Text);
if fieldvalues['gx1']<>null then
begin
TextOut(tdycs.FieldValues['工序1'],y,inttostr(fieldvalues['gx1']));
TextOut(tdycs.FieldValues['扎号1'],y,inttostr(fieldvalues['zh']));
font.Size:=13;
TextOut(tdycs.FieldValues['件数1'],y,inttostr(fieldvalues['js']));
font.Size:=11;
TextOut(tdycs.FieldValues['工序2'],y,inttostr(fieldvalues['gx1']));
end;
case h of
0:TextOut(tdycs.FieldValues['制单2'],y,'('+editdh.Text+')');
2:TextOut(tdycs.FieldValues['制单2'],y,'('+fieldvalues['ys']+')');
4:TextOut(tdycs.FieldValues['制单2'],y,'('+inttostr(fieldvalues['js'])+'件)');
6:if fieldvalues['gh']<>null then
TextOut(tdycs.FieldValues['制单2'],y,'('+fieldvalues['gh']+')');
end;
inc(h);
TextOut(tdycs.FieldValues['床次2'],y,inttostr(fieldvalues['cc']));
TextOut(tdycs.FieldValues['尺码2'],y,fieldvalues['cm']);
TextOut(tdycs.FieldValues['制单3'],y,editdh.Text);
if fieldvalues['gx2']<>null then
begin
TextOut(tdycs.FieldValues['工序4'],y,inttostr(fieldvalues['gx2']));
TextOut(tdycs.FieldValues['扎号2'],y,inttostr(fieldvalues['zh']));
font.Size:=13;
TextOut(tdycs.FieldValues['件数2'],y,inttostr(fieldvalues['js']));
font.Size:=11;
TextOut(tdycs.FieldValues['工序3'],y,inttostr(fieldvalues['gx2']));
end;
y:=y+tdycs.FieldValues['列高']/2;
if fieldvalues['tm1']<>null then
begin
Textout(tdycs.FieldValues['床次1'],y,inttostr(fieldvalues['tm1']));
font.Name:='IntP12DlTt';
font.Size:=9;
Textout(tdycs.FieldValues['制单1'],y-5,fieldvalues['code1']);
font.Name:='宋体';
font.Size:=11;
end;
if fieldvalues['tm2']<>null then
begin
Textout(tdycs.FieldValues['床次2'],y,inttostr(fieldvalues['tm2']));
font.Name:='IntP12DlTt';
font.Size:=9;
Textout(tdycs.FieldValues['制单3'],y-5,fieldvalues['code2']);
font.Name:='宋体';
font.Size:=11;
end;
y:=y+tdycs.FieldValues['列高']/2;
TextOut(tdycs.FieldValues['床次1'],y,inttostr(fieldvalues['cc']));
TextOut(tdycs.FieldValues['尺码1'],y,fieldvalues['cm']);
TextOut(tdycs.FieldValues['制单1'],y,editdh.Text);
if fieldvalues['gx3']<>null then
begin
TextOut(tdycs.FieldValues['工序1'],y,inttostr(fieldvalues['gx3']));
TextOut(tdycs.FieldValues['扎号1'],y,inttostr(fieldvalues['zh']));
font.Size:=13;
TextOut(tdycs.FieldValues['件数1'],y,inttostr(fieldvalues['js']));
font.Size:=11;
TextOut(tdycs.FieldValues['工序2'],y,inttostr(fieldvalues['gx3']));
end;
case h of
1:TextOut(tdycs.FieldValues['制单2'],y,'('+inttostr(fieldvalues['cc'])+'床)');
3:TextOut(tdycs.FieldValues['制单2'],y,'('+inttostr(fieldvalues['zh'])+'扎)');
5:;
7:TextOut(tdycs.FieldValues['制单2'],y,'('+fieldvalues['cm']+')');
end;
inc(h);
if h>7 then
h:=0;
TextOut(tdycs.FieldValues['床次2'],y,inttostr(fieldvalues['cc']));
TextOut(tdycs.FieldValues['尺码2'],y,fieldvalues['cm']);
TextOut(tdycs.FieldValues['制单3'],y,editdh.Text);
if fieldvalues['gx4']<>null then
begin
TextOut(tdycs.FieldValues['工序4'],y,inttostr(fieldvalues['gx4']));
TextOut(tdycs.FieldValues['扎号2'],y,inttostr(fieldvalues['zh']));
font.Size:=13;
TextOut(tdycs.FieldValues['件数2'],y,inttostr(fieldvalues['js']));
font.Size:=11;
TextOut(tdycs.FieldValues['工序3'],y,inttostr(fieldvalues['gx4']));
end;
y:=y+tdycs.FieldValues['列高']/2;
if fieldvalues['tm3']<>null then
begin
Textout(tdycs.FieldValues['床次1'],y,inttostr(fieldvalues['tm3']));
font.Name:='IntP12DlTt';
font.Size:=9;
Textout(tdycs.FieldValues['制单1'],y,fieldvalues['code3']);
font.Name:='宋体';
font.Size:=11;
end;
if fieldvalues['tm4']<>null then
begin
Textout(tdycs.FieldValues['床次2'],y,inttostr(fieldvalues['tm4']));
font.Name:='IntP12DlTt';
font.Size:=9;
Textout(tdycs.FieldValues['制单3'],y,fieldvalues['code4']);
font.Name:='宋体';
font.Size:=11;
end;
y:=y+tdycs.FieldValues['列高']/2;
inc(fenye);
if fenye>10 then
begin
fenye:=0;
printer.NewPage;
y:=0 end;
end;
Tdytm.next;
end;
end;
printer.EndDoc;
这个例子,它是如何完成这个打印的呢?
 
帮下,,,无人会
 
你怎么发这么多啊,直接用行打就可以了,在网上找能找得到,不过不是每台打印机都支持行打的,如松下KX1121打出来的汉字就是乱码,不知道应该怎么设置,EpsonLQ300K则没有问题。用Printers所说也可以实现行打,不过我没有实现过。
 
帮我找下可以吗?救救我啊!这几天要交啦!老板这半个月也不用我上班。死任务解决这个问题
 
以下代码是新鲜出炉地,我用打印到文件的方式试过,可以正常打印,不过调整格式你得慢慢来了,用尺子量好慢慢处理吧。家里没有打印机,具体效果不知道了。
type
TDoc_Info_1 = record
pDocName: pChar;
pOutputFile: pChar;
pDataType: pChar;
end;
var
BytesWritten: DWORD;
hPrinter: THandle;
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDeviceMode: THandle;
do
cInfo: TDoc_Info_1;
OutPutString: string;
begin
Printer.PrinterIndex := -1;
Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
if not OpenPrinter(@Device, hPrinter, nil) then
exit;
do
cInfo.pDocName := 'MyDocument';
do
cInfo.pOutputFile := nil;
do
cInfo.pDatatype := 'RAW';
if StartDocPrinter(hPrinter, 1, @DocInfo) = 0 then
begin
ClosePrinter(hPrinter);
exit;
end;
if not StartPagePrinter(hPrinter) then
begin
EndDocPrinter(hPrinter);
ClosePrinter(hPrinter);
exit;
end;
try
OutPutString := 'This Is RAW Format Output' + #13 + '这个是已经换行了';
WritePrinter(hPrinter, PChar(OutPutString), Length(OutPutString), BytesWritten);
finally
EndPagePrinter(hPrinter);
EndDocPrinter(hPrinter);
ClosePrinter(hPrinter);
hPrinter := 0;
end;
end;
 
DocInfo: TDocInfo1A;
未定义 可具体说明一下吗?thank you
 
DocInfo: TDocInfo1A;
未定义 可具体说明一下吗?thank you
 
在引用里面添加
uses
WinSpool, Printers;
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
618
import
I
后退
顶部