sivarajankumar / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

getMargins uses inconsistent units to construct result #151

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Code inspection of getMargins suggests that the function uses inconsistent
units to construct the rectangle it returns. PDF.getMargins from the
0.1.4.9 release of AlivePDF is included below:

public function getMargins ():Rectangle
{
   return new Rectangle( lMargin, tMargin, getCurrentPage().width - rMargin
- lMargin, getCurrentPage().height - bMargin - tMargin );
}

In particular, note that the width of the rectangle is computed using the
width property of the current page, a property that is specified in pixel
units. From that pixel measurement, the right and left margins (in page
units, e.g. mm) are subtracted to obtain the width. However, the resulting
width measure is meaningless because it is computed from incompatible
measures. The height is similarly faulty.

I believe a correct solution is to instead use the w and h properties of
the page in place of the width and height properties. Because the w and h
properties specify page dimensions in the page's units (e.g. mm). As such,
getMargins would appear as folows:

public function getMargins ():Rectangle
{
   return new Rectangle( lMargin, tMargin, getCurrentPage().w - rMargin -
lMargin, getCurrentPage().h - bMargin - tMargin );
}

Original issue reported on code.google.com by eric.m.b...@gmail.com on 27 Aug 2009 at 9:18

GoogleCodeExporter commented 8 years ago
Hi there,

This is right, I will update that in the next drop :)

Thanks for noticing this inconsistency.

Thanks for using AlivePDF ;)

Thibault

Original comment by thibault.imbert on 23 Jan 2010 at 10:30