We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unexpected font parsing exception in HTML conversion

Hello, Aspose,

I have a problem with Html conversion with some files (examples attached). When I try to convert file an exception occurs such as “Unexpected font parsing”. I use following code:

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

using (var streamReader = File.OpenText(inputFilePath))
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(section, streamReader.ReadToEnd());

text.IsHtmlTagSupported = true;


using (var outputDocument = new Aspose.Pdf.Document(pdf))

I also have tried this code from your samples:

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

Aspose.Pdf.Generator.Section section = pdf.Sections.Add();

StreamReader r = File.OpenText(inputFilePath);

Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());

text2.IsHtmlTagSupported = true;



Could you please help me with this issue.
Thanks in advance.

Best Regards,

Hi Mikhail,

Thanks for contacting support.

I have tested the scenario using Document Object Model (DOM) of Aspose.Pdf namespace and as per my observations, the index.html is being converted to PDF format (see attached index_Converted.pdf). However when using test.html, an ArgumentNullException is being generated. For
the sake of correction, I have logged it in our issue tracking system as
PDFNEWNET-37123. We will
investigate this issue in details and will keep you updated on the status of a
apologize for your inconvenience.


load source HTML

Aspose.Pdf.Document pdf = new Document("c:/pdftest/test.html", new HtmlLoadOptions());

// save output in PDF format


Thanks, Nayyer,

But I have tried your code sample and I have got an exception on this line:
Aspose.Pdf.Document pdf = new Document(“c:/pdftest/test.html”, new HtmlLoadOptions());
Exception: "Object reference not set to an instance of an object."

I use Aspose.Pdf version

Could you help me please how to perform conversion from html format to pdf format correctly?

Thanks in advance.
Best Regards,

Hi Mikhail,

Thanks for sharing the details.

In my earlier attempt, I have used Aspose.Pdf for .NET 9.3.0 to test and scenario and I am afraid we might not be able to fix the issue in older release. Can you please try using the latest release and in case you still encounter the same exception, please share some details regarding your working environment i.e. Operating System, VisualStudio version, .NET Framework version etc.

Thank you for your help.

Latest Aspose.Pdf.dll version resolves this issue.

Best Regards,

Hi Mikhail,

Thanks for your feedback. It is good to know that you have managed to resolve the issue with one of the problematic documents. However we will keep you updated about above logged issue( PDFNEWNET-37123 ) resolution progress via this forum thread.

We are sorry for the inconvenience caused.

Best Regards,

The issues you have found earlier (filed as PDFNET-37123) have been fixed in Aspose.PDF for .NET 20.1.