Extra styles are added when one document is imported into another using C#

The style "CD_CV_body" in the attached document has a zero "After" spacing and a Single "Line spacing". When importing into another document both of these properties get changed to the default Normal properties. This occurs even when the style name doesn't exist in the target document.

Code:

When looping through sections of the source

targetDocument.ImportNode(sourceDocument.Sections(sectionIndex), True, ImportFormatMode.UseDestinationStyles)
Same thing happens when KeepSourceFormatting is used.

Hi Bruce,

Thanks for your query. I have tested the scenario and have not found any issue by using latest version of Aspose.Words for .NET. Please use the latest version of Aspose.Words for .NET 11.1.0. I have attached the source and output document with this post.

If you still face problem, please share some more detail about your issue and also share output document for investigation purposes.

Added the source, destination and result document. You can see in the result document that the CD_CV_body style picks up "After" rules where in the source document it has none.

Using Aspose.Words version 11.1

Sample code:

            Aspose.Words.Paragraph parentPara;
            Aspose.Words.Document sourceDocument;
            Aspose.Words.Document targetDocument;
 
            sourceDocument = new Aspose.Words.Document("c:\\temp\\TestUpload2.doc");
            targetDocument = new Aspose.Words.Document("c:\\temp\\Dest.docx");
 
            parentPara = (Aspose.Words.Paragraph)targetDocument.Range.Bookmarks["AAA"].BookmarkStart.ParentNode;
 
            for (int sectionIndex = sourceDocument.Sections.Count - 1; sectionIndex >= 0; sectionIndex--)
            {
                Aspose.Words.Section s = (Aspose.Words.Section)(targetDocument.ImportNode(sourceDocument.Sections[sectionIndex], true, Aspose.Words.ImportFormatMode.UseDestinationStyles));
            <span style="color: blue;">while</span> (s.Body.HasChildNodes)
            {
                parentPara.ParentNode.InsertAfter(s.Body.LastChild, parentPara);
            }
        }


targetDocument.Save(“c:\temp\results.docx”);

Hi Bruce,

Thanks for sharing the information. This is a know issue, we already had logged this issue in our issue tracking system. I have linked this thread to the appropriate issue and you will be notified via this forum thread once this issue is resolved. Please read following documentation link for your kind reference.

http://docs.aspose.com/display/wordsnet/Common+Issues+When+Appending+Documents

We apology for your inconvenience.

The issues you have found earlier (filed as WORDSNET-2098) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(6)