Hello.
I have some problems on using Aspose Words, inserting some specific HTML elements vía DocumentBuilder:
Issues:
1.- When a HTML contains tags like: , Empty tags with no ID and name: When exporting to PDF or creating a Table of Contents the process hangs for a very long time (about 30 minutes )
2.- When using
, this is, empty
tags, the document builder raises a null pointer exception:
java.lang.NullPointerException
at com.aspose.words.zzZWC.zzWF(Unknown Source)
at com.aspose.words.zzZWC.zzZLp(Unknown Source)
at com.aspose.words.zzZVV.zzT(Unknown Source)
at com.aspose.words.zzZVV.zzZ(Unknown Source)
at com.aspose.words.zzZVV.zzO(Unknown Source)
at com.aspose.words.zzZVV.zzP(Unknown Source)
at com.aspose.words.zzZVV.zzO(Unknown Source)
at com.aspose.words.zzZVV.zzP(Unknown Source)
at com.aspose.words.zzZVV.zzO(Unknown Source)
at com.aspose.words.zzZVV.zzP(Unknown Source)
at com.aspose.words.zzZVV.zzO(Unknown Source)
at com.aspose.words.zzZVV.zzP(Unknown Source)
at com.aspose.words.zzZVV.zzO(Unknown Source)
at com.aspose.words.zzZVV.zzP(Unknown Source)
at com.aspose.words.zzZVV.zzZ(Unknown Source)
at com.aspose.words.DocumentBuilder.zzZ(Unknown Source)
at com.aspose.words.DocumentBuilder.insertHtml(Unknown Source)
We have isolated the problem to a block of HTML and executing the code:
Document wordTest = new Document();
DocumentBuilder docBuilder = new DocumentBuilder(wordTest);
docBuilder.moveToDocumentEnd();
String content = new String(Files.readAllBytes(Paths.get("c:\temp\liproblem.html"))); //i attached this file to the post
docBuilder.insertHtml(content); //This line of code raises the exception
wordTest.save("c:\temp\temp.docx");
We are currently deleting these problematic specific tags with regular expressions, is there any alternative or solutions, what other tags can cause exceptions in a possibly bad formed html ?
Maybe we can try to add the node directly, not by using document builder, could this help ? what is the sample code for adding HTML node ?