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

Free Support Forum - aspose.com

Best Way to remove a specific page from Word


I done some research to find a way to remove a page from docx document. I didn’t find many results on the subject.

So, what is for you the best way to do that.

Thanks for your answers.

Hi Olivier,

Thanks for your inquiry. You can use PageSplitter code to achieve your requirements. It splits each page as a section and you can create a new document with your required page numbers. Please check following code snippet, it excludes page number 5 in the resultant document.

Please check “PageSplitter” example project in Aspose.Words for .NET examples repository at GitHub.

Document doc = new Document("input.doc");
LayoutCollector layoutCollector = new LayoutCollector(doc);
DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);
Document doc1 = splitter.GetDocumentOfPageRange(1,4);
Document doc2 = splitter.GetDocumentOfPage(6);
doc1.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);

Best Regards,

Thanks for answer.

the github project was helpful