We are currently using the column text approach with PDFStamper.getOverContent to add HTML to existing PDFs at absolute positions.
private void addHTMLToPDF(PdfContentByte pdfContentByte, com.itextpdf.text.Rectangle rectangle, String html) throws IOException, DocumentException {
ColumnText ct1 = new ColumnText(pdfContentByte);
ct1.setSimpleColumn(rectangle);
pdfContentByte.rectangle(rectangle);
ElementList elements = XMLWorkerHelper.parseToElementList(html, this.STYLE);
for (Element element : elements) {
ct1.addElement(element);
}
ct1.go();
}
This works perfectly but we have issues with nested list items. According to How can I convert XHTML nested list to pdf with iText? this is an issue with ColumnText. Is this resolved in itext 7 (we are on 5) or is there a way to use the paragraph approach with an absolute rectangle for position?
Thanks
Izac