0

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

Izac
  • 71
  • 10
  • That is an example of one of the things we were unable to resolve in iText 5 and fixed in iText 7. – Bruno Lowagie Dec 22 '17 at 15:35
  • So there is no way to do this in 5 but it is supported in 7? Is this in itext-core or is a plugin required? Do you have a relevant example in any of the documentation? – Izac Dec 22 '17 at 15:44
  • Please read https://stackoverflow.com/questions/47895935/converting-html-to-pdf-using-itext/47896272#47896272 It has plenty of pointers to the official documentation. Out of curiosity: how come you didn't find that information on the official web site? Is there something we can do to improve the web site so that developers can find that information more easily? – Bruno Lowagie Dec 22 '17 at 15:52

0 Answers0