我这里给出设置纸张和方向的方法。
Function MainPrintSet(MainQuickrep: TQuickrep): Boolean;
Var
Device, Driver, Port : array[0..255] of char;
ADevMode : THandle;
DevMode : PDeviceMode;
begin
Try
Result := True;
MainQuickrep.Units := Pixels;
If GetPrintIndex<>Printer.PrinterIndex then
DefaultPrinterFlag:=True;
MainQuickrep.PrinterSettings.PrinterIndex := printer.PrinterIndex;
MainQuickrep.Page.Orientation := printer.Orientation;//方向
with Printerdo
GetPrinter(Device, Driver, Port, ADevMode);
if ADevMode<>0 then
begin
DevMode := GlobalLock(ADevMode);
Case DevMode^.dmPaperSize of//纸张
DMPAPER_LETTER: MainQuickrep.Page.PaperSize := Letter;
DMPAPER_LETTERSMALL: MainQuickrep.Page.PaperSize :=
LetterSmall;
DMPAPER_TABLOID: MainQuickrep.Page.PaperSize := Tabloid;
DMPAPER_lEDGER: MainQuickrep.Page.PaperSize := Ledger;
DMPAPER_lEGAL: MainQuickrep.Page.PaperSize := Legal;
DMPAPER_STATEMENT: MainQuickrep.Page.PaperSize := Statement;
DMPAPER_EXECUTIVE: MainQuickrep.Page.PaperSize := Executive;
DMPAPER_A3: MainQuickrep.Page.PaperSize := A3;
DMPAPER_A4: MainQuickrep.Page.PaperSize := A4;
DMPAPER_A4SMALL: MainQuickrep.Page.PaperSize := A4Small;
DMPAPER_A5: MainQuickrep.Page.PaperSize := A5;
DMPAPER_B4: MainQuickrep.Page.PaperSize := B4;
DMPAPER_B5: MainQuickrep.Page.PaperSize := B5;
DMPAPER_FOLIO: MainQuickrep.Page.PaperSize := Folio;
DMPAPER_QUARTO: MainQuickrep.Page.PaperSize := Quarto;
DMPAPER_10X14: MainQuickrep.Page.PaperSize := qr10X14;
DMPAPER_11X17: MainQuickrep.Page.PaperSize := qr11X17;
DMPAPER_NOTE: MainQuickrep.Page.PaperSize := Note;
DMPAPER_ENV_9: MainQuickrep.Page.PaperSize := Env9;
DMPAPER_ENV_10: MainQuickrep.Page.PaperSize := Env10;
DMPAPER_ENV_11: MainQuickrep.Page.PaperSize := Env11;
DMPAPER_ENV_12: MainQuickrep.Page.PaperSize := Env12;
DMPAPER_ENV_14: MainQuickrep.Page.PaperSize := Env14;
else
begin
GlobalUnlock(ADevMode);
Result:=false;
Exit;
end;
end;
GlobalUnlock(ADevMode);
end;
Except
Result:=false;
GlobalUnlock(ADevMode);
Exit;
end;
end;