Calculate height of an iTextSharp PDF document?

How can I calculate the height of a PDF document when using iTextSharp?


I use iTextSharp to place various images in a PDF using Absolute Position. However, I noticed that SetAbsolutePosition() positions the Y parameter from the bottom, so I need to calculate the height in order to be able to do something like:

 Y = PdfHeight - i 
+3
c # pdf-generation itextsharp
source share
1 answer

You have to do this using PageSize, like this ...

 int yPos = pdfDocument.PageSize.Height - i - elementHeight; 

i = the position you would set Y if it were at the top of the page

elementHeight = the height of the element that you are positioning (e.g. image)

+3
source share

All Articles