We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Getting Blank pages in word document when append document from one document to another document

Hello team,
I am trying to append document from secDoc document to another document then mainDoc document in added some extra blank pages.
How can i fix this issue ?

Snippet :

Aspose.Words.Document mainDoc = new Aspose.Words.Document();   
bool isContentFound = false;  
byte[] sectionData;
Aspose.Words.Document secDoc = (Aspose.Words.Document)mainDoc.Clone(false);
sectionData= Encoding.UTF8.GetBytes(@"C:\\secDoc.docx");
secDoc = new Aspose.Words.Document(new MemoryStream(sectionData));  
mainDoc.AppendDocument(secDoc, ImportFormatMode.KeepSourceFormatting);

secDoc.docx (285.7 KB)
mainDoc.docx (98.1 KB)

@AlpeshChaudhari12345 The problem occurs because the newly created document and your document have different set of compatibility options. When you concatenate the documents compatibility options of the main document are applied and the content is reflowed appropriately. This might lead to difference in layout of the appended documents.
You can use CompatibilityOptions.OptimizeFor method to optimize your main document to concrete version of MS Word. For example the following code fixes the issue.

Document doc = new Document();

Document secDoc = new Document(@"C:\Temp\secDoc.docx");
doc.AppendDocument(secDoc, ImportFormatMode.KeepSourceFormatting);


@alexey.noskov thanks for response…