Aspose.Words Append document adds extra dashed line and number for bullets

Hi, I am doing a simple document append using Aspose.words v18.8, It seems to be working fine but for some bullets in source document I see that it adds a dashed line and number after appending. This only happens for some bullets and not all. See the resultant Append.docx file and there is a dashed line for bullets. Please let me know how to fix it and if you cna find why this happens only for few bullets.

v18.8 Code for appendingAppended.docx (20.4 KB)
doc1.docx (13.1 KB)
doc2.docx (10.9 KB)

var finalDocument = new Aspose.Words.Document();
finalDocument.FirstSection.Remove();

var doc1 = new Aspose.Words.Document("C:\\Temp\\Aspose\\doc1.docx");
var doc2 = new Aspose.Words.Document("C:\\Temp\\Aspose\\doc2.docx");

finalDocument.AppendDocument(doc1, ImportFormatMode.KeepSourceFormatting);
finalDocument.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting);

finalDocument.Save("C:\\Temp\\Aspose\\Appended.docx", Aspose.Words.SaveFormat.Docx);

Thanks,
Swamy

@thippeswamy.kn This is not a bug. The problem is causes by the fact that newly created document is optimized for MS Word 2003 by default and have CompatibilityOptions.DoNotUseIndentAsNumberingTabStop set. If you disable this option the output document will look fine:

var finalDocument = new Aspose.Words.Document();
finalDocument.FirstSection.Remove();
finalDocument.CompatibilityOptions.DoNotUseIndentAsNumberingTabStop = false;

But I would suggest you better use CompatibilityOptions.OptimizeFor method to optimize the document to MS Word version you use. For example:

var finalDocument = new Aspose.Words.Document();
finalDocument.FirstSection.Remove();
finalDocument.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2019);

Or even better use clone one of source document as a final document, in this case the same set of CompatibilityOptions will be used:

var doc1 = new Aspose.Words.Document("C:\\Temp\\doc1.docx");
var doc2 = new Aspose.Words.Document("C:\\Temp\\doc2.docx");

Document finalDocument = (Document)doc1.Clone(false);

finalDocument.AppendDocument(doc1, ImportFormatMode.KeepSourceFormatting);
finalDocument.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting);

finalDocument.Save("C:\\Temp\\out.docx", Aspose.Words.SaveFormat.Docx);

And finally, the list items in your source document have this abnormally big tab stop, that causes the problem.

Thank you so much for informing about the root cause and providing multiple option to fix it so quickly, OptimizeFor works fine for us as we will not know what is the version of all of the source documents.
Thanks again.

1 Like