Skip to content

1.2.2 Coordinate system

Felix Schütt edited this page Jul 6, 2017 · 4 revisions

While PDF does allow us to place any elements on the page how we want, it requires us to define the coordinates for these elements. Thus, we should care about how the PDF coordinate system works.

Basics

PDF uses a two-dimensional, cartesian (non-projected) coordinate system. Meaning, the location of a point is defined by two coordinates, X and Y, which mark the horizontal (X) and the vertical (Y) offset to a defined center of a given coordinate space. This is an common model of points in computer graphics as well as in typography.

The center point on an empty page resides in the bottom left corner of the page. This coincides with the mathematical model of the first quadrant in a cartesian coordinate system. While common in math, it is unusual in the computer graphics world. When X values increase, our point shifts to the right of the page, when Y values increase it shifts to the top of the page. Points that are out of range of the page are allowed, but not drawn.

Units of measurement

The units of measurement in a PDF is "point". Point is a typographical unit of measure, which is however not standardized. Since PostScript and PDF have take over the market of professional print products, it is widely accepted as a de-facto standard. The definition of a "point" is that 12 point = 1 pica and 6 pica = 1 inch.

1 point 1pt 0.16pc
1 pica 12pt 1pc
1 inch 72pt 6pc

A common abbreviation is that 72 point = 1 inch or 1 point = 1/72 inch (0.352 mm). This is unfortunate for common readers since you usually work with a metric or imperial system. However, we can use computers to easily do this conversion for us. Points are a helpful measurement for fine measurements, such as line thickness or character width.

Coordinate system rules

How coordinates are noted is context-dependent. There are a few universal rules, however:

  • Coordinates can be written either as integer or floating-point number
  • X coordinates are always written before Y coordinates
  • In a description of a rectangle, the first coordinate is the lower left corner, the second coordinate is the upper right corner

These assumptions are true if we have not manipulated the coordinate system (a common thing to do for scaling, rotating and transforming shapes / images, etc.). Transforming is possible to do seperately for X and Y axis, so that we can skew the coordinate space. We'll take a look at this later on, but it's important to understand that in PDF you don't manipulate the object, you manipulate their coordinate space.