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

Free Support Forum - aspose.com

Header footer Lost when page orientation change

Hi Team,

I am inserting documents(aspose word doc) dynamically to one main document(aspose word doc) using
DocumentBuilder.insertDocument() method. I have also dynamic configuration for document orientation in my DB which I can set as Landscape or Portrait. Earlier when there was no landscape orientation, I was able to insert Header in the document, but as I change orientation to Landscape, header goes from several pages and on last few pages header appears.

I have also created Header.docx file in which I have created header and inserting Header.doc file into main document after collating all word documents.
Inserting headerDoc using below code
builder.insertDocument(headerDoc, ImportFormatMode.USE_DESTINATION_STYLES);

Code to change page orientation and inserting doc

if (section.isLandscape()) {

} else {

Please help, how to set header and footer when we change page orientation.


Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word documents.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.