I am using a upload document and then will change some special words with values using IReplace interface. For certain case I have to remove all the content after replacing it, but should show the exact empty pages(page number should be same after removing the content). Also after emptying the page page boarder, header and footer shouldn’t remove. So can you please help me to figure out a solution for this problem.
@Gptrnt MS Word document consist of Sections. Each section has Headers/Footers and the main body. So if the document contains only one section and it is required to remove everything except Header/Footer, you should simply remove all content from the section’s body. For example see the following code:
Document doc = new Document("C:\\Temp\\in.docx");
doc.getFirstSection().getBody().removeAllChildren();
doc.save("C:\\Temp\\out.docx");
Sometimes my document contains more than one section in the content, So in that case I need to find the section which has header and footer. Is there any property to find it ?