ImportFormatMode.KeepDifferentStyles cause AppendDocument crash

Hi, in our application, when call ‘AppendDocument’ with KeepDifferentStyles ImportFormaMode, in some document, Aspose.Words crash with error message:

System.NullReferenceException: Object reference not set to an instance of an object.
at Aspose.Words.NodeImporter.a(PR a, PR b, Int32 c)
at Aspose.Words.NodeImporter.a(Paragraph a, Paragraph b)
at Aspose.Words.NodeImporter.a(Node a, Node b)
at Aspose.Words.NodeImporter.b(Node a, Boolean b, ZS c)
at Aspose.Words.NodeImporter.a(CompositeNode a, CompositeNode b, ZS c)
at Aspose.Words.NodeImporter.b(Node a, Boolean b, ZS c)
at Aspose.Words.NodeImporter.a(CompositeNode a, CompositeNode b, ZS c)
at Aspose.Words.NodeImporter.b(Node a, Boolean b, ZS c)
at qT.b(Document a, ImportFormatMode b, ImportFormatOptions c)
at Aspose.Words.Document.AppendDocument(Document srcDoc, ImportFormatMode importFormatMode, ImportFormatOptions importFormatOptions)
at Aspose.Words.Document.AppendDocument(Document srcDoc, ImportFormatMode importFormatMode)

Please see my example application with minimum set of documents I used to reproduce the error.

What we are trying to achieve is to merge multiple different documents to a large singe document for batch print out, and it seems that the KeepDifferentStyles is the best option for us to keep the resulting merged document retains styles from each of the source documents. Otherwise, use other ImportFormatMode doesn’t seems cause crash.

ThanksAsposeMergeStyleError.zip (389.4 KB)

@DougT I have logged the issue as WORDSNET-24010. We will keep you informed and let you know once it has been resolved.

Thanks Vadim again for your help.

1 Like

The issues you have found earlier (filed as WORDSNET-24010) have been fixed in this Aspose.Words for .NET 22.7 update also available on NuGet.

Reporting back the case appears to be fixed for me.

1 Like