Board index » delphi » Printer's Margins

Printer's Margins

Hi,

When using TPrinter component I can start to print from (0,0) coordinates
of the paper. The problem is, Widnows has (not printer) it's own margins.
You may change them at My Computer/Printers/Properties/Page/Unprintable Area.
If I specify 5mm in Unprintable Area, then when printing using TPrinting
it also will start at (5,0). I know a few programs can handle this situation.

Any helps or suggestions will be appreciated.

Sincerely Yours,
Sergei Anisimov

e-mail: a...@arctech.spb.ru

 

Re:Printer's Margins


Quote
Sergei V. Anisimov wrote:

> Hi,

> When using TPrinter component I can start to print from (0,0) coordinates
> of the paper. The problem is, Widnows has (not printer) it's own margins.
> You may change them at My Computer/Printers/Properties/Page/Unprintable Area.
> If I specify 5mm in Unprintable Area, then when printing using TPrinting
> it also will start at (5,0). I know a few programs can handle this situation.

> Any helps or suggestions will be appreciated.

> Sincerely Yours,
> Sergei Anisimov

> e-mail: a...@arctech.spb.ru

Hello Sergei,

I'm not quite sure what you are after. Maybe this will be of some use.

Var
  GutterPoint, PaperSize : TPoint;
  LogPixX, LogPixY : Word;

  With Printer Do
  Begin
    BeginDoc;
    Escape(Canvas.Handle, GetPrintingOffset, 0, Nil, @GutterPoint);
    Escape(Canvas.Handle, GetPhysPageSize, 0, Nil, @PaperSize);

    LogPixX:=GetDeviceCaps(Canvas.Handle, LOGPIXELSX);
    LogPixY:=GetDeviceCaps(Canvas.Handle, LOGPIXELSY);
    minTopMargin:=GutterPoint.Y/LogPixY;
    minLeftMargin:=GutterPoint.X/LogPixX;
    minRightMargin:=PaperSize.X/LogPixX - minLeftMargin -
PageWidth/LogPixX;
    minBottomMargin:=PaperSize.Y/LogPixY - minTopMargin  -
PageHeight/LogPixY;

    xOffset:=Trunc((YOUR_LEFT_MARGIN_IN_INCHES-minLeftMargin)*LogPixX);
    yOffset:=Trunc((YOUR_TOP_MARGIN_IN_INCHES-minTopMargin)*LogPixY);

   { Now print your stuff, using the original values and offset. }

    EndDoc
  End;

HTH

Ray Cramer
R...@Pol.ac.uk

Other Threads