如果你是图形打印的话,那么跳纸问题只好自己去判断跟踪页高和当前打印
位置来判断是否该换纸继续打
另一个方法是使用DOS下的行打印技术,在WINDOWS下实现比较麻烦
下面是将一个文本文件 使用行打印技术到 打印机的办法
与WINDOWS图形打印不同的是: 在行打印中需要绕过打印机驱动
procedure PrintFile(const sFileName: string);
const
BufSize = 16384;
type
TDoc_Info_1 = record
pDocName: pChar;
pOutputFile: pChar;
pDataType: pChar;
end;
var
Count, BytesWritten: integer;
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;
f: file;
Buffer: Pointer;
begin
Printer.PrinterIndex := -1;
Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
if not WinSpool.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
WinSpool.ClosePrinter(hPrinter);
exit;
end;
if not StartPagePrinter(hPrinter) then
begin
EndDocPrinter(hPrinter);
WinSpool.ClosePrinter(hPrinter);
exit;
end;
System.Assign(f, sFileName);
try
Reset(f, 1);
GetMem(Buffer, BufSize);
while not eof(f)do
begin
Blockread(f, Buffer^, BufSize, Count);
if Count > 0 then
begin
if not WritePrinter(hPrinter, Buffer, Count, BytesWritten) then
begin
EndPagePrinter(hPrinter);
EndDocPrinter(hPrinter);
WinSpool.ClosePrinter(hPrinter);
FreeMem(Buffer, BufSize);
exit;
end;
end;
end;
FreeMem(Buffer, BufSize);
EndDocPrinter(hPrinter);
WinSpool.ClosePrinter(hPrinter);
finally
System.Closefile( f );
end;
end;
上面的例子改一改就可以做成通用的行打
注意 uses 子句里一定要加上 WinSpool