Converting Pixels and Inches to PostScript Points
Pages in a PDF use points (1/72 of an inch) as the default measurement units with the origin or the coordinate system at the bottom left corner of the page. So there is a constant 72 involved in calculations when converting to or from points in PDF. This is the ratio of the “points” measurement units and “inches”.
The measurement units can be changed using the SetMeasurementUnits function to inches or millimetres.
The origin can be set to the top-left corner of the page (or any other corner) using the SetOrigin function.
A conversion factor is required to map between the image coordinates and the PDF page coordinates. Typically it is required to convert pixels to points.
Pixels to Points
If an image of 200—300 pixels is used, and it is drawn at 96 DPI onto the page, the height and width area on the page required to fit that image in points would be:
(200 / 96 * 72) x (300 / 96 * 72) = 150 x 225 points
// SizeInPixels / DPI * 72
If you want to convert from Points to Pixels then simply swap the 72 and the DPI so it now looks like this:
// SizeInPixels / 72 * DPI
Inches to Points
Converting inches to points is also often required and is a straight forward formula, in this example we’ll use a standard Letter page size of 8.5 inches x 11 inches:
(8.5 x * 72) x (11 * 72 = 612 x 792 points
// SizeInPoints = SizeInInches * 72
Pixels to Inches
If you want to convert pixels to inches then the formula is again straightforward:
// SizeInInches = PixelSize / DPI
This article refers to a deprecated product. If you are looking for support for Foxit PDF SDK, please click here.
Updated on May 16, 2022