HtmlFormatProvider Bold formatting missing from generated PDF

1 Answer 107 Views
PdfProcessing
Jeff
Top achievements
Rank 1
Jeff asked on 09 Mar 2023, 03:20 PM

Hello! I am having an issue with missing bold font styling when using the HtmlFormatProvider to export an HTML string to a PDF byte array. All other CSS styles work as expected in the creation of some relatively complex forms, but the bold formatting is missing from the resultant PDF document (see attached image). 

Currently using version 2020.2.615 of Telerik.Documents & related NuGet packages (upgrade may not be possible due to some legacy restrictions, so would ideally like to resolve without)

Using the following code with an example string, we save the byte array as a database record and the document is downloaded on request by the user.

// sample string
var stringToConvert = "<div><span>Here is some text. And here is some <b>bold</b> text... maybe?</span></div><div><span>Here is some text. And here is some <strong>bold</strong> text... maybe?</span></div><div><span>Here is some text. And here is some <span style=\"font-weight:bold;\">bold</span> text... maybe?</span></div>";

HtmlFormatProvider provider = new HtmlFormatProvider();
RadFlowDocument document = provider.Import(stringToConvert);

// Export document
PdfFormatProvider byteProvider = new PdfFormatProvider();
return byteProvider.Export(document);

Thank you,

Jeff

 

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 14 Mar 2023, 09:27 AM

Hello Jeff,

I tested the provided code snippet in a project on my end and did not manage to reproduce the missing bold formatting (see attached 'boldFormatting.png'). I might be missing something in the process so for me to get a better context of this case, I am attaching the sample project along with the result output document for you to take a look at. Feel free to examine and modify them as you prefer and let me know if my approach is correct and if there is anything I can change or improve upon. Modifying the project, so that it reproduces the issue, and sending it back to us would also be of great help.

In addition, I wanted to ask you which version of NET you are using.

If you happen to have any feedback or questions in the meantime feel free to share.

Regards, Yoan Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
PdfProcessing
Asked by
Jeff
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or