Search code examples
javaitext7html2pdf

iText7: Parsing html with ul in td does not show list-style element


We are about to find out if iText7 fits our needs.

Our workflow is as follow: we send an html body (almost tables; build by php) and some css with REST to a Java prototype app. There the html is put through the HtmlConverter and onto the PdfDocument.

Most of the output of the resulting pdf looks fine, but we do not see any glyph in front of the li elements of ul's and ol's. We already tried to force it with css:

ol li { list-style-type: disc; }

But with no success. Also we tried other definitions (list-style: disc inside; list-style: disc outside; list-style: disc; or list-style-type: disc;) in ul, ol and/or li.

The css is parsed fine btw. we've changed the background-color of ul/ol which works.

We also tested several font files, but can not get the glyphs displayed.

Any suggenstions?


Solution

  • We created the font in the wrong way:

    this.font = PdfFontFactory.createFont(this.FONT, PdfEncodings.UTF8);
    this.fontProvider = new FontProvider();
    this.fontProvider.addFont(font.getFontProgram(), PdfEncodings.UTF8);
    

    This works correct:

    this.font = PdfFontFactory.createFont(this.FONT, PdfEncodings.UTF8);
    this.fontProvider = new FontProvider();
    this.fontProvider.addFont(font.getFontProgram());