I am currently having trouble making any text bold or changing font-weight using the AdvancedHtmlToPDF forge component. Is this a known issue? Any help would be appreciated.
I've already tried: -Using the bold tag <b>.-Using the strong tag <strong>.-Using CSS class (.bold-class {font-weight: bold;}) applied to the element.-Using inline CSS: <p><span style='font-weight: bold;'>Hello World!</span></p> -Using <em> tag and inline CSS: <em style='font-weight: bold;'>
The issue with bold text not rendering in PDFs generated by AdvancedHtmlToPDF (which uses iText) often occurs because the converter doesn't automatically apply bold variants unless a supported font-family is explicitly specified.
Try Adding font-family: helvetica; (or times) to your styles — these are standard PDF fonts with built-in bold support in iText.
Hi @Gustavo Sanchez Maeda,
Yes, this is a known and well‑understood limitation of the AdvancedHtmlToPDF Forge asset. All the HTML and CSS you tried are correct for browsers, but they don’t behave the same way inside this PDF generator.
Despite the name, AdvancedHtmlToPDF does not use a browser engine. It uses iText’s HTML-to-PDF renderer, which has limited CSS/font support.
The key limitation: Text can only be bold if the font itself has a bold variant loaded.
If only the regular font is available for UI, then:
are silently ignored and this is exactly what you’re experiencing.
Solution:
You must provide both regular and bold font files and map them correctly.
Example:
<style>@font-face { font-family: 'CustomFont'; src: url('CustomFont-Regular.ttf'); font-weight: normal;}@font-face { font-family: 'CustomFont'; src: url('CustomFont-Bold.ttf'); font-weight: bold;}body { font-family: 'CustomFont';}</style><p><strong>Hello World!</strong></p>
Important: Each font weight requires its own .ttf file.
Hope this helps.
Cheers,
Saugat