Foxit Quick PDF Library

How to map PDF coordinates to Delphi graphics canvas coordinates

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.

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.

For an image or a Canvas in Delphi the surface is divided into an integral number of pixels horizontally/vertically.

So a conversion factor is required to map between the image coordinates and the PDF page coordinates.

Alternatively the PDF page can be sized to a particular image size, and this would be done based on a certain DPI value.

For example, if an image/canvas of 200×300 pixels was used, and it is drawn at 96 DPI onto the page, the PDF page would be:

(200 / 96 * 72) x (300 / 96 * 72) = 150 x 225 points

The size of the PDF page can be set using the SetPageDimensions function using the units specified by the previous call to SetMeasurementUnits.

This way each “point” on the page corresponds to a pixel on the original image.

Using a specific example the AddNoteAnnotation function has two measurements. The first is the position of the note annotation on the page, given by the Left/Top parameters. Then there is the popup annotation itself (the window containing the note). The position is specified using the PopupLeft/PopupTop parameters and the size is specified using the PopupWidth/PopupHeight parameters. These measurements are specified in the same units as set by the SetMeasurementUnits function.

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

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: