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

Free Support Forum - aspose.com

Copy Document page styles :

Dear Team ,

I am using Aspose latest version for doc conversion . I need to copy only the document properties like pagination styles ( page border, page background color, etc … ) to another document. I tried using ’ deepClone() ’ method as below .

Document oldDoc = new Document(“oldDocument.doc”);
Document newDoc = oldDoc.deepClone();

after conversion whole styles are lost . I need to preserve document page styles alone. Am i doing anything wrong ? is there any other method to take page styles .


Hi Anbu,

Thanks for your request. As you know page setups are stored in sections. But if you remove all children from the document, you also removes all sections. So Aspose.Words creates one empty section before saving such document – just to keep the output document valid. Since all original sections are removed, all page setups of these sections are lost.

So to achieve what you need, you should remove everything except one section. For instance, see the following code:

Document oldDoc = new Document("C:\\Temp\\in.doc");

Document newDoc = oldDoc.deepClone();

// Remove everything except the first section.

while (newDoc.getSections().getCount() > 1)



// Save output.


Hope this helps.

Best regards,