Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I interpret the coordinates of a rectangle in PDF?

Tags:

java

itextpdf

I would like to know more about the coordinates of a Rectangle, in particular:

  • lower left X
  • lower left Y
  • upper right X
  • upper right Y

Every time, I get confused about how to make dimensions based on these coordinates to draw rectangle.

If possible, can I get a graphical representation briefly about these coordinates positions?

like image 897
Nazeer_hanne Avatar asked Jun 10 '15 06:06

Nazeer_hanne


People also ask

Where is the origin XY of a PDF page?

In a PDF document, the location origin (0, 0) is at the bottom left corner of the PDF page. The x axis is positive horizontally to the right and y axis is positive vertically upward. A page location point represents a point in page coordinates. Page points by default is 1⁄72 inch.

How do I find the coordinates of text in a PDF online?

One way to determine the exact x,y coordinates of elements on a PDF page is to open the PDF in GIMP (the image editing tool). As you hover over different parts of the PDF(image) with the mouse, the bottom left corner displays the x,y coordinates.

What is BBox in PDF?

The BBox, or the Bounding Box, is the smallest rectangle that can enclose all the content on the page. This box is calculated by Acrobat and so it cannot be modified by a script. Ideally, a line drawn around the BBox would touch the edges of the visible content on all four sides of the page.


1 Answers

Before someone can explain what the lower-left X, lower-left Y, upper-right X and upper-right Y of a rectangle are about, you need to know about the coordinate system: Where is the Origin (x,y) of a PDF page?

The answer to that question contains all the information you need, except for the graphical representation you are asking for. This is a simple representation of the coordinate system:

enter image description here

The origin of the coordinate system is (0, 0). Positive X values are to the right of the origin, positive Y values are above the origin.

I have drawn a Rectangle and indicates where you can find the lower-left corner (with coordinate (llx, lly)) and the upper-right corner (with coordinate (urx, ury)).

The sides of the rectangle are always in parallel with the X and the Y axis, hence you only need two coordinates to define the rectangle.

like image 107
Bruno Lowagie Avatar answered Sep 21 '22 09:09

Bruno Lowagie