Free Support Forum - aspose.com

IsHtmlTagSupported Font Sizing

Hello. I’m trying to output some html to a pdf and am having problems formatting the font size. I have tried both approaches bellow (using Aspose’s functions and using html), but in either case the text in the pdf just shows up at its default size. I’m using Aspose pdf 10.5.0.0. Am I missing something obvious? Thanks for any help you can give me!


Aspose.Pdf.Generator.Pdf pdf1 = new Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();

string htmlString = " test string ";

Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, htmlString);
Aspose.Pdf.Generator.TextInfo textInfo1 = new Aspose.Pdf.Generator.TextInfo();
textInfo1.FontSize = 4;
text1.TextInfo = textInfo1;

text1.IsHtmlTagSupported = true;
sec1.Paragraphs.Add(text1);

-------------------------------------------------------------------------

Aspose.Pdf.Generator.Pdf pdf1 = new Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();

string htmlString = " <font size = “4”>test string ";

text1.IsHtmlTagSupported = true;
sec1.Paragraphs.Add(text1);

Hi Jackie,


Thanks for contacting support.

I have observed that you are using legacy Aspose.Pdf.Generator approach for converting HTML file to PDF format and during my testing with latest release of Aspose.Pdf for .NET 10.5.0, where I have used following code snippet (based on new Document Object Model) of Aspose.Pdf namespace, I am unable to notice any problem. For your reference, I have also attached the resultant file generated over my end.

For further details, you may consider visiting


[C#]

Document doc = new Document();<o:p></o:p>

HtmlFragment html = new HtmlFragment(" test string ");

doc.Pages.Add().Paragraphs.Add(html);

doc.Save("c:/pdftest/HTMLTextSizeIssue.pdf");