I am converting html to pdf by using HtmlConverter.convertToElements and then adding the iElements to the document. And it works with every html element except a caption element directly inside a table.
<table>
<caption>Some text</caption>
... TRs with TDs here ...
</table>
The error is
java.lang.IllegalStateException: FontProvider and FontSet are empty.
Cannot resolve font family name (see ElementPropertyContainer#setFontFamily)
without initialized FontProvider (see RootElement#setFontProvider).
I have identified that the error occurs at com.itextpdf.layout.renderer.TextRenderer.resolveFonts when the FontProvider has no fonts. It does not help to explicitly define the font for caption in a style and all other elements use the same font just fine. If I hide the caption by using display: none; everything else (h3, p, div, th, td) renders correctly in the pdf and uses the fonts just fine. It feels like something is wrong in iText, but a work-around would be welcome in the meantime.
I am using Linux, Java and itext7-core 7.2.3 and html2pdf 4.0.3