Cannot add a style because a style with the same name already exists

Hi,

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

Hi

Thanks for your request. It seems to be a known issue # 3658. I will notify you as soon as it is fixed.

Best regards.

Hi Alexey,

when is the planed delivery date of this fix? We would need this quite urgently as we received a customer request.

Kind regards,
Werner

Hi

Thanks for your inquiry. Unfortunately I can’t provide you any reliable estimate. Please expect a reply before next hotfix (within 3-4 weeks).

Best regards.

The issues you have found earlier (filed as 3658) have been fixed in this update.

Issue #3658 - “Cannot add a style because a style with the same name already exists” exception occurs during inserting one document into another.

The problem occurs when destination document contains a user defined style with a name of a built in style.

Hi,

when will this hotfix be available for Java?

Regards,
Werner

Hi

Thanks for your inquiry. The next java release is scheduled on September. I think this release will include this fix.

Best regards.

Hi,

thanks for this announcement. Is the release date for the next java release fixed, yet? Will this release contain a fix for this issue?

Kind regards.

Hi

Thanks for your request. Yes the next java release will contain a fix for this issue. I think it will be published within week or two.

Best regards.

Hi,

may I ask for an update on this issue, as two weeks since the last announcement passed by?

Kind regards,
Werner

Hi

Thanks for your inquiry. We are still working on the next version. We are on the final stage. Release is coming soon.

Best regards.

Hi,

Aspose.Words 2.5.0 was released, but I cannot find bug 3658 in the release notes.

Could you please specify if it is included or not?

Kind Regards,
Werner

Hi

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.

Best regards.

Thanks for this confirmation.

Is there a date or a schedule for the next Aspose.Words for java release fixed, yet?
Regards,
Werner

Hi

Thanks for your inquiry. I think the next java release will be published within 2-3 months.

Best regards.

Hi!

Aspose.Words 2.6.1 for Java was released and does not contain a fix for this issue.

Could you please let me know when there is a fix planed for this?

Thanks

Hi

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.

Best regards.

Thank you for this confirmation.

When will this release be available?

Regards

Hi

Thanks for your request. Hopefully, the next version will be released in 2-3 months.

Best regards.

The issues you have found earlier (filed as 3658) have been fixed in the latest version of Aspose.Words for Java. You can download it from here: