How to use i text 5 to get the length and width of the content in the PDF document? In another word,
gets the length and width of the red rectangle in the image
How to use i text 5 to get the length and width of the content in the PDF document? In another word,
gets the length and width of the red rectangle in the image
This answer to this question can be found on the FAQ section of the iText website.
http://developers.itextpdf.com/question/how-find-out-current-cursor-position-page
One way is to use document.add()
[source itextpdf.com]
There is a very old method called getVerticalPosition() that takes a boolean as parameter. I'm not proud of that method as it is a getter method that not only will give you the Y position on the page after using a series of document.add() operations, it can also change the current Y position (and that is not what a getter method should do).
If you pass false as a parameter, it will give you the current Y, which could be the position of the baseline of the last Chunk you've added.
If you pass true as a parameter, the method will first add a newline and give you the position of the baseline of the "next" line of text you'll be adding.