FormInfo : TFormInfo1;
begin
Printer.GetPrinter(PrintDevice, PrintDriver, PrintPort, hDMode);
OpenPrinter(PrintDevice, hPrinter, nil);
if hPrinter = 0 then
raise Exception.Create('联接打印机失败!');
with FormInfodo
begin
Flags := FORM_USER;
pName := PChar(PaperName);
Size.cx := PaperWidth*100;
Size.cy := PaperLength*100;
ImageableArea.Left := 0;
ImageableArea.Top := 0;
ImageableArea.Right := PaperWidth*100;
ImageableArea.Bottom := PaperLength*100;
end;
//修改纸型,如果没有就新增
if not SetForm(hPrinter, PChar(PaperName), 1, @FormInfo) then
AddForm(hPrinter, 1, @FormInfo);
ClosePrinter(hPrinter);