concept coordinate system in category itext

appears as: coordinate system, coordinate systems, The coordinate system
iText in Action, Second Edition

This is an excerpt from Manning's book iText in Action, Second Edition.

In this chapter, you’re adding content at absolute positions. These absolute positions are defined with (x,y) coordinates with the lower-left corner of the page as the origin of the coordinate system.

  • The coordinate system in Java’s Graphics2D is different from the default coordinate system in PDF’s graphics state. The origin of user space in Java Graphics is the upper-left corner of the component’s drawing area. The X coordinate increases to the right; the Y coordinate increases downward.
  • 14.3.3. Changing the coordinate system

    In chapter 3, you learned that the origin of the coordinate system can usually be found in the lower-left corner of the page. For an A4 page in portrait orientation, the upper-right corner has the coordinates (595,842). We amended this in chapter 5, where you created a superhero PDF with page size A0 with the origin of the coordinate system centered in the middle of the page.

    Figure 14.4 is similar. The origin of the coordinate system is marked by two lines, where Y = 0 (the X axis) and X = 0 (the Y axis).

    Translating the coordinate system in direction (dX, dY) is done like this:

    x' = 1 * x + 0 * y + dX
    y' = 0 * x + 1 * y + dY

    These formulas scale the coordinate system with factors sX in the X direction and sY in the Y direction:

    x' = sX * x + 0 * y + 0
    y' = 0 * x + sY * y + 0

    To rotate the coordinate system with an angle φ, you need to use the following equations: