2007. október 17., szerda

How to get the printer margins


Problem/Question/Abstract:

Does anybody know how to get, programmatically, the location of the canvas on the piece of paper that emerges from the printer? i.e. the size of the top, left, right and bottom margins?

Answer:

procedure TPrtPvw.GetOffsetPrinter;
var
  pt: TPoint;
  tmpAncho, tmpAlto: longint;
begin
  Escape(hPrinter, GETPRINTINGOFFSET, 0, nil, @pt);
  gOffSetLeft := pt.X;
  gOffSetTop := pt.Y;
  Escape(hPrinter, GETPHYSPAGESIZE, 0, nil, @pt);
  tmpAncho := pt.X;
  tmpAlto := pt.Y;
  gOffSetRight := tmpAncho - gOffSetLeft - Printer.PageWidth;
  gOffSetBottom := tmpAlto - gOffSetTop - Printer.PageHeight;
end;

Nincsenek megjegyzések:

Megjegyzés küldése