Free Support Forum - aspose.com

Merge documents with numbered lists & WordArt

Hello,

I have to merge two documents which contain numbered lists. I want source document to continue numbering of the first document. To achieve it, I use the following code:
var dstDoc = new Document(DestinationDocumentPath);
var srcDoc = new Document(SourceDocumentPath);

srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
dstDoc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles);

var opt = new OoxmlSaveOptions(SaveFormat.Docx) { Compliance = OoxmlCompliance.

Iso29500_2008_Transitional
dstDoc.Save(ResultDocumentpath, opt);
The problem is, that these documents may contain text styles (WordArt). In the generated document I don’t have these styles. Also, AFAIK, these lists must have the same linked style, but my documents are not guaranteed to have them. Is there a way to create this style and apply it for both lists to make numbering continue? Or is there another solution to make numbering continue and use WordArt?
Thanks in advance

Hi Aliaksei,


Thanks for your inquiry. First of all, I would suggest you please read the following article on how to control Lists during appending documents:
http://www.aspose.com/docs/display/wordsnet/Controlling+How+Lists+are+Handled

When two documents are joined using ImportFormatMode.UseDestinationStyles then the lists having the same linked styles in the combined document continue on instead of being restarted as separate lists. Therefore, the easiest way you can achieve this is by coping all linked styles applied to lists in source document to destination document. Here is the code that demonstrates how to copy style from one document into a different document.

// This is the style in the source
document to copy to the destination document.

Style srcStyle = srcDoc.Styles[StyleIdentifier.Heading1];

// Change the font of the heading style to red.

srcStyle.Font.Color = Color.Red;

// The AddCopy method can be used to copy a style from a different document.

Style newStyle = dstDoc.Styles.AddCopy(srcStyle);


I hope, this helps.

Best regards,