0

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)

asked Sep 9, 2022 at 17:25
2
  • Please add your code and sample files to reproduce Commented 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. Commented Sep 19, 2022 at 7:42

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.