Skip to content
English
  • There are no suggestions because the search field is empty.

[Public] Understanding Rectangle Construction and Positioning in IronPDF

When drawing rectangles in PDF documents using IronPDF, it's important to understand that its coordinate system and behavior differ from other libraries like IronOCR and IronBarcode. While IronOCR and IronBarcode define rectangles relative to an image input, IronPDF operates within the coordinate space of the PDF document itself.

The image below illustrates how changes to the x, y, width, and height values affect rectangle positioning in IronPDF:

 

ironpdfrectangle

  1. Coordinate Origin:
    The origin point (0, 0) in a PDF document is located at the bottom-left corner of the page. However, when specifying a rectangle, this origin is treated as the top-left corner of the rectangle, which affects the direction in which the shape is drawn.

  2. Y-Coordinate Behavior:
    Increasing the y value moves the rectangle upwards, while decreasing it moves the rectangle downwards. Providing a negative y value places the rectangle below the (0, 0) point.

  3. X-Coordinate Behavior:
    Increasing the x value moves the rectangle to the right. Conversely, decreasing or supplying a negative x value shifts the rectangle to the left.

  4. Width Behavior:
    A positive width value draws the rectangle to the right from the starting point. A negative or decreasing width draws the rectangle to the left.

  5. Height Behavior:
    A positive height value extends the rectangle upwards, while a negative height draws it downwards from the starting point.