Calculate height of iTextSharp PDF document?

♀尐吖头ヾ 提交于 2019-12-12 15:24:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!