i’m trying to merge two documents together.
this is my code:
foreach (byte[] d in data)
{
using (MemoryStream ms = new MemoryStream(d))
{
Aspose.Words.Document doc = new Aspose.Words.Document(ms);
if (result == null)
{
result = doc;
}
else
{
doc.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;
foreach (Section s in doc)
{
Section sec = (Section)result.ImportNode(s, true, ImportFormatMode.KeepSourceFormatting);
result.AppendChild(sec);
}
}
}
}
data is an array of byte arrays.
Despite using ImportFormatMode.KeepSourceFormatting i get the following exception:
System.ArgumentException: Cannot add a style because a style with the same name already exists.
at Aspose.Words.StyleCollection.?(Style ?)
at Aspose.Words.StyleCollection.?(? ?, Style ?)
at Aspose.Words.NodeImporter.?(? ?, ? ?)
at Aspose.Words.NodeImporter.ImportNode(Node srcNode, Boolean isImportChildren)
at Aspose.Words.NodeImporter.?(CompositeNode ?, CompositeNode ?, Boolean ?)
at Aspose.Words.NodeImporter.ImportNode(Node srcNode, Boolean isImportChildren)
at Aspose.Words.NodeImporter.?(CompositeNode ?, CompositeNode ?, Boolean ?)
at Aspose.Words.NodeImporter.ImportNode(Node srcNode, Boolean isImportChildren)
at Aspose.Words.Document.ImportNode(Node srcNode, Boolean isImportChildren, ImportFormatMode importFormatMode)
Is this a bug or am i doing something wrong?
You can find the documents that produce this error attached.
Thank you
Robert
Thanks for your inquiry. Unfortunately Aspose.Words for java v2.5.0 does not include fix for issue #3658. This release includes all changes and fixes we’ve made earlier on Aspose.Words for .NET versions 4.4.0 to 5.2.0.
But issue was fixed in Aspose.Words v5.2.1. So this fix will be included in the next Aspose.Words for java release. Sorry for inconvenience.
Thanks for your request. Aspose.Words for java 2.6.1 is maintain release and contains only java fixes. The fix of this issue will be ported to java version in the next release. Sorry for inconvenience.