开发者

Itext PDF manipulation in java

开发者 https://www.devze.com 2023-03-19 23:17 出处:网络
I have a requirement to convert a PDF from HTML using itext lib in java. My input HTML page has a tabular structure and it has separate header and footer. I\'ve converted this page to PDF , however as

I have a requirement to convert a PDF from HTML using itext lib in java. My input HTML page has a tabular structure and it has separate header and footer. I've converted this page to PDF , however as my HTML page has a footer associated with it, I'm trying to relocate footer of my generated PDF to location where a开发者_StackOverflowctual data of a particular page ends(i.e if a page contains only 10 lines of data from header then I'm trying to add footer after 10th line). PDFEventHelper class helped me to add header and footer,but I'm getting struck with this relocation requirement. Can anybody tell me how to deal with such scenarios?? does anyone knows how to read blank(unwritten) sectors on PDF page ?? Thanks in advance.


The Document passed into your onEndPage override is actually a PdfDocument.

Once you've cast the parameter to a PdfDocument, you can call PdfDocument.getVerticalPosition(true) to determine where the last Element was laid out and draw your footer accordingly. Note that this only gives the Y position, but that's all you really need for a footer.

The parameter passed to getVerticalPosition is called "ensureNewLine". I strongly suspect what you pass won't matter because this is the End Page Event, and any trailing lines will have already been written/finished/closed/whatever-its-called.

0

精彩评论

暂无评论...
验证码 换一张
取 消