1

Normally we print HTML content using the following code:

PdfWriterPipeline      pdf  = new PdfWriterPipeline(document, writer);
HtmlPipeline           html = new HtmlPipeline(htmlContext, pdf);
CssResolverPipeline    css  = new CssResolverPipeline(cssResolver, html);

XMLWorker worker = new XMLWorker(css, true);
XMLParser p = new XMLParser(worker);
p.parse(new ByteArrayInputStream(string.getBytes()));
p.flush();
worker.close();

But this doesn't handle nested lists properly. Only the first level is printed with bullets and all others simply follow inline... without any breaks.

I've tried to adapt https://stackoverflow.com/a/26757887/173689... with iText v5.5.8.

ElementHandlerPipeline end  = new ElementHandlerPipeline(new ElementList(), null);
HtmlPipeline           html = new HtmlPipeline(htmlContext, end);
CssResolverPipeline    css  = new CssResolverPipeline(cssResolver, html);

XMLWorker worker = new XMLWorker(css, true);
XMLParser p = new XMLParser(worker);
p.parse(new ByteArrayInputStream(string.getBytes()));
p.flush();
worker.close();

for (Element e : elements) {
    document.add(e);
}

But lists still are not nested – the result is the same. What's wrong?

Community
  • 1
  • 1
Daniel Bleisteiner
  • 3,190
  • 1
  • 33
  • 47
  • LOL... just created this question because another editor advised me not to use answers asking follow up questions. But never the less... my problem was just solved: my `string` was capsuled by an outer `...` – as soon as I remove it the nesting works. – Daniel Bleisteiner Dec 09 '16 at 09:09

0 Answers0