问题
How can I calculate the height of the PDF document when using iTextSharp?
I'm using iTextSharp to position various images on a PDF document using Absolute Position. However I've noticed SetAbsolutePosition()
positions the Y
parameter from the bottom, so I need to calculate the height to be able to do something like:
Y = PdfHeight - i
回答1:
You should be able to do that by using the PageSize, like this...
int yPos = pdfDocument.PageSize.Height - i - elementHeight;
i = the position you would set Y if it was from the top of the page
elementHeight = the height of the element you are positioning (e.g. an image)
来源:https://stackoverflow.com/questions/7768809/calculate-height-of-itextsharp-pdf-document