Getting exception with builder.InsertDocument

Howdy,

We are using Aspose.words version 20.3.0 and are inserting a document into another document like

builder.InsertDocument(newDocument, UseDestinationStyles) and we get this exception

Exception thrown: 'System.InvalidOperationException' in Aspose.Words.dll: 'Empty name.'
   at    ..ctor(String )
   at Aspose.Words.Themes.Theme.(Theme ,     )
   at Aspose.Words.StyleCollection.(Style , Style )
   at Aspose.Words.StyleCollection.(Style , Style )
   at Aspose.Words.StyleCollection.(Style , Style )
   at Aspose.Words.StyleCollection.(    , Style )
   at Aspose.Words.StyleCollection.(    , Style )
   at Aspose.Words.StyleCollection.(    , Style )
   at Aspose.Words.NodeImporter.( ​  ,  ​  , Int32 )
   at Aspose.Words.NodeImporter.(Paragraph , Paragraph )
   at Aspose.Words.NodeImporter.(Node , Node )
   at Aspose.Words.NodeImporter.(Node , Boolean ,     )
   at Aspose.Words.NodeImporter.(CompositeNode , CompositeNode ,     )
   at Aspose.Words.NodeImporter.(Node , Boolean ,     )
   at Aspose.Words.NodeImporter.(CompositeNode , CompositeNode ,     )
   at Aspose.Words.NodeImporter.(Node , Boolean ,     )
   at Aspose.Words.NodeImporter.(Node , Boolean ,     )
   at    .(Document , ImportFormatMode )
   at    .(Document , ImportFormatMode , ImportFormatOptions )
   at    .(DocumentBuilder , Document , ImportFormatMode , ImportFormatOptions )
   at Aspose.Words.DocumentBuilder.InsertDocument(Document srcDoc, ImportFormatMode importFormatMode, ImportFormatOptions importFormatOptions)
   at Aspose.Words.DocumentBuilder.InsertDocument(Document srcDoc, ImportFormatMode importFormatMode)

@dmerkle1 can you please attach the source and destination documents and the value of the var UseDestinationStyles.

Howdy,

Thanks for the quick reply. Turns out, one of the styles in the Document being inserted was a character style that didn’t have a font selected. So I added some code to set the font to “Times New Roman” if it was null, and that fixed it.
image.png (11.5 KB)

@dmerkle1 It’s great that you figure out this for yourself. If you face any issue don’t doubt to contact us.