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

Free Support Forum - aspose.com

Page setup properties not preserved while merging

We ran into an issue while merging documents concerning header/footer settings. In our usecase, we have a source document that has different even and odd page headers, and the target document(to which the src is appended) has a default header. Each of these documents has only one section. On merging these documents (with link to previous for the src section set to false), we found a discrepancy for the getOddAndEvenPagesHeaderFooter() property of the PageSetup object. Namely, we found that in the merged document’s last section, this property was set to false and as a consequence, it was showing only the odd page header in the output. (setting this property to true however showed the expected result with odd and even page headers for the second section). Shouldn’t the page setup properties for a section be preserved even after merging?

Hi there,

Thanks for your inquiry. Could you please attach your input Word documents along with output document here for testing? I will investigate the issue on my side and provide you more information.

Hi Tahir,
Please find attached the source and target documents (the source is appended to the target) and the final output generated. In this case, the source has a different first page header, slightly different from the use case I mentioned, but even so, he page setup properties are not preserved. I have been using Aspose Words for Java (the latest release 13.5.0) on
my Windows 7 x64 machine and I have been using Java 7 (java version
Java™ SE Runtime Environment (build 1.7.0_21-b11) )

Hi there,

Thanks for sharing the document. Please note that Aspose.Words tries to mimic the same behaviour as MS Word do. If you do the same scenario by using MS Word, you will get the same output.

Please note that although OddAndEvenPagesHeaderFooter property is part of PageSetup class, but, the value of OddAndEvenPagesHeaderFooter is not actually stored in Section properties. It is a global attribute, affects all Sections and stored in DocPr object. That’s why Aspose.Words and Microsoft Word do not import this property during Section import.

Please set this value by using setOddAndEvenPagesHeaderFooter(true) as shown in following code snippet. Please let me know if I can be of any further assistance.

Document dstDoc = new
Document(MyDir + “target.docx”);<o:p></o:p>

Document srcDoc = new Document(MyDir + "src.docx");

dstDoc.appendDocument(srcDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);

for(Section section : (Iterable<Section>)dstDoc.getSections())




dstDoc.save(MyDir + "Out.docx");