DocumentBuilder.InsertHtml error when string contains anchor tag

EDIT: This issue was fixed by upgrading from 14.3 to 14.8 version of the DLL.


When an anchor is included in the html string, and InsertHtml is used, the following error always occurs:

[NullReferenceException: Object reference not set to an instance of an object.]
 .(String ) +129
 .( ) +147
 .( ) +449
 .( ) +54
 .( ) +304
 .( ) +54
 .( ) +304
 .( ) +54
 .( ) +304
 .( ) +54
 .(String , DocumentBuilder ) +154
Aspose.Words.DocumentBuilder.InsertHtml(String html) +266

Code to generate this error (C#):

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

string html = “Text [1]

[1] Footnote text.”;
builder.InsertHtml(html); //always causes error with above html string

MemoryStream stream = new MemoryStream();
doc.Save(stream, SaveFormat.Docx);

I’ve been able to track the error down to the InsertHtml method incorrectly parsing the element. The tags are being generated as footnote links from Microsoft Word, then copied and pasted into a CKEditor, and being saved to our database. Then, the html string is extracted from the database and inserted into the DocumentBuilder via InsertHtml.

I’m looking at this as a bug in InsertHtml, since you should be able to use anchor tags with or without fully qualified domain names.

Currently using Aspose.Words version 14.3.0.0, with the Developer Small Business license.

The following HTML string does not cause an error in .NET and does output a Word Document, however if you open the document you can see that the contents do not match the simple HTML. (Although, this doesn’t help my case, I simply tested adding a domain name to the anchor and while the code doesn’t break, it still doesn’t generate properly.)

Something odd is going on with tags.

string html = “Text [1]

[1] Footnote text.”;
builder.InsertHtml(html); //doesn’t cause error with above html string, but does not generate correctly in word doc.

Hi Blaise,


Thanks for your inquiry. It is great that the latest version of Aspose.Words resolves your issue. Please let us know any time you have any further queries.

Best regards,