When I convert html with in-line styles to pdf, the font-family works on every tag I have tried except from pre. It seems that when a pre is converted to IBlockElement and then added to the document, the specific font is ignored and either the default font (Times) or a default monospace font is used, but never the exact font I request. Since the font-family works fine with p and td and div, I guess there must be something special with pre. Also, the same fonts work fine when creating normal Paragraphs from strings and specifying fonts or styles with fonts. I have solved my specific problem by converting the pre to a string (with Jsoup) and then to a Paragraph with a style with a font. But I though I should write here so that someone can look into this a determine whether or not it is a bug that should be fixed.
Just in case it matters: I am using Java and itext7-core 7.2.3 and html2pdf 4.0.3 on linux (kubuntu)
-
Please add your code and sample files to reproduceAlexey Subach– Alexey Subach2022年09月17日 11:43:28 +00:00Commented Sep 17, 2022 at 11:43
-
I was trying to recreate this and I think I figured out what the problem is. When working with html2pdf, the DefaultFontProvider does not register system fonts. By creating a new DefaultFontProvider and using ConverterProperties as explained at kb.itextpdf.com/home/it7kb/ebooks/… I got the fonts to work.nikos– nikos2022年09月19日 07:42:09 +00:00Commented Sep 19, 2022 at 7:42