你的纸必须很长,比如10米的
然后设置纸张大小,比如设成 20厘米长(每次打20厘米长的图象),
设置页的上下边距为 0,然后打印
//添加新纸型,你也可以在打印机里手动添加新纸型
procedure TForm1.Button1Click(Sender: TObject);
var
PrintDevice, PrintDriver, PrintPort : array[0..255] of Char;
hDMode : THandle;
hPrinter: THandle;
FormInfo: TFormInfo1;
PaperSize: TSize;
PaperRect: TRect;
errcode: integer;
s: string;
begin
Printer.GetPrinter(PrintDevice, PrintDriver, PrintPort, hDMode);
OpenPrinter(PrintDevice, hPrinter, nil);
if hPrinter = 0 then
raise Exception.Create('Failed to open printer!');
FormInfo.Flags := FORM_USER;
FormInfo.pName := PChar('新格式3');
PaperSize.cx := 20000;//看 API 说明
PaperSize.cy := 20000;
PaperRect.Left := 1;
PaperRect.Top := 1;
PaperRect.Right := 20000;
PaperRect.Bottom := 20000;
FormInfo.Size := PaperSize;
FormInfo.ImageableArea := PaperRect;
if not AddForm(hPrinter, 1, @FormInfo) then
begin
errcode := GetLastError;
if errcode <> ERROR_FILE_EXISTS then
// Form name exists?
begin
case errcode of
ERROR_ACCESS_DENIED: s := 'Access is denied';
ERROR_INVALID_HANDLE: s := 'The handle is invalid';
ERROR_NOT_READY: s := 'The device is not ready';
ERROR_INVALID_FORM_SIZE : s:= 'Invalid From Size';
ERROR_CALL_NOT_IMPLEMENTED:
s := 'Function "AddForm" is not supported on this system';
else
s := 'Failed to add a Form (paper) name!';
end;
//raise Exception.Create(s);
showmessage(s);
end;
end;
ClosePrinter(hPrinter);
end;
//选择新纸型,注意,必须用win2000的打印机驱动才可以,
//否则无效,你也可以手动选择
procedure TForm1.Button2Click(Sender: TObject);
var
Device, Driver, Port: array[0..80] of Char;
DevMode: THandle;
pDevmode: PDeviceMode;
begin
Printer.GetPrinter(Device, Driver, Port, DevMode);
if DevMode <> 0 then
begin
pDevMode := GlobalLock( DevMode );
if pDevmode <> nil then
begin
pDevmode^.dmFields := pDevmode^.dmFields or
DM_FORMNAME or
DM_PAPERSIZE;
pDevmode^.dmPaperSize := DMPAPER_USER;
StrLCopy( pDevmode^.dmFormName, PChar('新格式3'), CCHFORMNAME-1 );
GlobalUnlock( Devmode );
end;
end;
end;
选择完打印就可以了,10米长的纸是按照每次20厘米(你自己设)走纸的