Mirror

How to get the printer margins (Views: 101)


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;

<< Back to main page