Free Support Forum -

Isuue while creating PDF from HTML file with Specific font


I am trying to create a PDF file from HTML file attached and in the HTML file I have used font-family: MS UI Gothic. I am getting an exception as The Font ’ MS UI Gothic’ is not found. This
font is not supported.

Following is the piece of code which I have used

Pdf pdfObject = new Pdf();
// add the section to PDF document sections collection
Aspose.Pdf.Generator.Section section = pdfObject.Sections.Add();

// Read the contents of HTML file into StreamReader object
StreamReader r = File.OpenText(source);

//Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());

// enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;
//Add the text paragraphs containing HTML text to the section

// Set the Font of Section as “Arial Unicode MS”, modified to support Unicode support
text2.TextInfo.FontName = “Arial Unicode MS”;

// Set the font size of the section as 9
text2.TextInfo.FontSize = 9;

// If you need to display all the text in Olive Color
text2.TextInfo.Color = new Aspose.Pdf.Generator.Color(“Olive”);
// Add the text object containing HTML contents to PD Sections

// Specify the URL which serves as images database

pdfObject.HtmlInfo.ImgUrl = source.Substring(0, source.LastIndexOf(’\’));

//Setting the unicode support.

//Save the pdf document

Also, If I change the font-family to Arial , its generating the PDF but the layout of the PDF is not proper.

Please guide me.

Hi Sandeep,

Thanks for using our products and reporting this issue to us. I managed to reproduce this issue on my side. For the sake of correction, I have logged this issue as PDFNEWNET-33451 in our bug tracking system. Your request has also linked to the appropriate issue and you will be notified as soon as it is resolved.

We apologize for your inconvenience.

Thanks & Regards,

The issues you have found earlier (filed as PDFNEWNET-33451) have been fixed in Aspose.Pdf for .NET 10.7.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.