还有其它方法能实现无限长无缝打印(象DOS那样不分页的连续打印)? (100分)

  • 主题发起人 主题发起人 bkfx
  • 开始时间 开始时间
B

bkfx

Unregistered / Unconfirmed
GUEST, unregistred user!
打印机为 Epson 1900K / 1600K
 
自己用 PRINTER.Canvas.TextOut()打印输出就行了。
 
不行的,一样是分页的!
 
那你就按DOS方式写打印程序好了.
其实历史问题中已有明确答案.
只要打印机有硬字库的,都可以.不然只能打英文.
 
还有跟打印机的设置有关系。
我的1600K3可以设置为自动跳过页缝,即使是连续打印到页缝位置时还是会自动分页。(241纸)
 
试试writeln();
就我个人的看法使用TPrinter.Canvas.TextOut(),最终还是在调用系统中打印纸大小的默认设置,
如果没有使用Tprinter.newpage(),打完一页就会停下来。
writeln()是一个兼容过程,我没试过,但愿可以。
 
我以前曾用过以下的方法,应该说很不错,但我想知道是否还有其他的方法?
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(oldprinter);
myprinter.free;
end
end;

-------------------.
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.
 
bkfx:
我想其他人给的方法不会超过你自己给出的方法了.
离线包的答案最多也就是你已知道的方法.
因为printer.EndDoc总是要将纸送出来的.
 
何必非要连续打印,告诉客户分页打印又清晰又好看,就分页打印吧!呵呵![:D]
 
TO xiaoyu_online:
这是由于要使用经济的连续卷纸(无孔的那种),并且打印的数据内容长度不一(不能分页),同时
这也可以节省纸张方面的开支!
 
我也是,我的朋友用习惯了,一定要连续卷纸,我也在等答案。
 
我上面提到的代码虽然麻烦些,但挺实用。我就是想找些更简便的实现方法!
 
gz
是有这问题,Windows 总会强制送纸!找个好办法....
 
方法一:
下载一个RawPrinter控件:
然后看例子即可。
方法二:
用打印机的esc指令,直接控制打印的打印一样非常容易使用。
 
RawPrinter - v. 1.1
http://www.grupoalbor.com/delphi/?opc=componentes
----------------------------------------------------
RawPrinter的英文介绍:
Files in this archive give you a very simplified way
to send raw data to the printer using Windows API.
It works just like good olddo
S-printing :))
but goes through the Windows Printer Spooler.
This means you can:
- print text in real text mode (which is usually much faster)
- include any commands your printer supports
(like PCL, IBM Proprinter or EPSON codes)
To use it, you have got two options:
1. RawPrinting.pas unit
This one includes a one simple procedure to send
a whole print job as one string parameter,
2. TRawPrinter component
You can put it on your form and use methods like:
begin
Doc, EndDoc, Write, NextPage etc.
See the RawPrinter.pas file to find more info about it.

To install the component on Delphi palette - just add
the RawPrinter unit to one of your packages.

All this stuff is freeware.
You cando
with it whatever you want to,
justdo
n't remove the copyright.
If you have any questions, comments or found any bugs
- feel free to send me an e-mail.
-----
Przemyslaw Jankowski
pjank@home.pl
 
用文件方式打开LPT1 或 PRN 设备打印,但如果要控制打印格式或字体(如中文),
需要打印机支持(如,1600KIII等就带有汉字库、条码库等),我在其它语言中也用
的这种方式实现。
 
RawPrinter 的安装方法:
Component --> Install Component ... --> Into new package
 
to bkfx:
老兄,你是了一的版主吧.
我在论坛VCL版留言了,我急需Theme Engine3.3.1.
可是我无法登录临时FTP.
请帮忙!
 
不是。
Theme Engine3.3.1 可到 www.51delphi.com 下载,它的 Theme Engine 更新比 0Dayz 要快!
 
后退
顶部