Hi,
We have a requirement where in we have to merge n number of docx files, with varied formatting and styling, in to a single docx file.
For this purpose I am evaluating latest Aspose.Words.
Following is the code I used to merge all docs in to one but the generated file is not preserving the source styles.
ImportFormatOptions importFormatOptions = new ImportFormatOptions();
importFormatOptions.SmartStyleBehavior = true;
importFormatOptions.KeepSourceNumbering = true;
Document doc = new Document(sourcefiles[0]);
for (int i = 1; i < sourcefiles.Length; i++)
{
Document doc1 = new Document(sourcefiles[i]);
doc1.ExpandTableStylesToDirectFormatting();
doc1.FirstSection.HeadersFooters.LinkToPrevious(false);
doc.AppendDocument(doc1, ImportFormatMode.KeepSourceFormatting, importFormatOptions);
}
doc.Save(destfile,SaveFormat.Docx);
For security reasons, I can’t send you my source files.
Following are the differences I could see:
- Some paragraph styles are not applied: Source contains a bullet list whose style is set to ‘List Paragraph’ and in the merged document it is bullet list with out the style
- Font issues: For some sources font is specified as Calibri (Body) in source and it is set to Calibri in destination or vice versa.
- Font color is getting changed for some docs.
- Extra line (empty line) is inserted after few headings.
Is there any way to merge multiple documents with different styles, margins, headers and footers be merged in to one with out disturbing any of the styles?
Thanks,
Anupama