Bold tag does not work when using HTML

Hello,


I am having a difficult time getting the bold tag to work as expected. Here is a code snippet that should reproduce the problem. I am taking an HTML string and passing it as a new segment. From there, I am setting the Text class object to use Courier and font size 10. The fonts are working as expected, but the html text inside the bold tags does not end up bold as expected.

var document = new Pdf();

var section = new Section();

document.Sections.Add(section);

var html = “This text should be bold. This text is not bold.”;

var text = new Text();

text.Segments.Add(new Segment(html));

text.TextInfo.FontSize = 10;
text.TextInfo.FontName = “Courier”;

text.IsHtmlTagSupported = true;
text.UseTextInfoStyle = true;
text.IfHtmlTagSupportedOverwriteHtmlFontNames = true;
text.IfHtmlTagSupportedOverwriteHtmlFontSizes = true;

section.Paragraphs.Add(text);

document.Save(@“C:\test.pdf”);

Hi Chris,


Thanks for your inquiry. Please use new DOM approach to add HTML string to PDF document. It will help you to resolve the issue.

Please feel free to contact us for any further assistance.

Best Regards,

Thank you for your response. I did look into HtmlFragment before reverting back to the Text object approach in my original post. However, I was having Courier font issues when using the code below. For some reason, the PDF ends up with CourierNew and CourierNewBold instead of Courier when the code below is run:


var document = new Document();

var page = document.Pages.Add();

var html = "<font style="font-family:courier; font-size:10pt; “>This text should be bold.This text is not bold.”;
var fragment = new HtmlFragment(html);

page.Paragraphs.Add(fragment);

document.Save(@“C:\test.pdf”);

Do you have any idea why Aspose is using the wrong font in the PDF? Somehow, it finds Courier without any issues when using the Text object, but it wants to use CourierNew with HtmlFragment.
pscmj84:
Thank you for your response. I did look into HtmlFragment before reverting back to the Text object approach in my original post. However, I was having Courier font issues when using the code below. For some reason, the PDF ends up with CourierNew and CourierNewBold instead of Courier when the code below is run:
Hi Chris,

Thanks for sharing the code snippet.

I have tested the scenario and I am able to notice the same problem. For the sake of correction, I have logged this problem as PDFNEWNET-37467 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Great, thanks for looking into this.

Hello, is there any update on this open bug?

Hi there,


Thank you for your inquiry. Just to let you know our support team have a short break early this week but rest assured your issue will be look into as soon as they return.

Thanks,
Hi Chris,

pscmj84:
Hello, is there any update on this open bug?

Thanks for your inquiry. I am afraid your reported issue is still pending for investigation due to other priority tasks. However, we have requested our development team to complete the investigation and share an ETA at their earliest. We will update you as soon as we get a feedback.

We are sorry for the inconvenience caused.

Best Regards

Hi Chris,


Thanks for your patience.

We have further investigated the issue PDFNEWNET-37467 reported earlier and it does not seem to be a bug in our API. The ‘Courier New’ is the newest version of the ‘Courier’ font that extends it by adding additional font styles: bold, italic etc. In most cases name ‘courier’ is used only as alias for ‘Courier New’ font.

You can verify this font-substitution behavior in the Google Chrome as example. The related screenshot is added ‘CourierNewRenderedFont.jpg’

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan