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

Free Support Forum - aspose.com

How to clear out all content in a document?

I am trying to find a way in Aspose.Words to clear out all "content" (text, tables, images, bookmarks, etc) from a document, and also preserve the styles at the same time? The idea is to copy a document, keep the basic document template, but blow away all of its content. My best stab at this so far has been the following:

Aspose.Words.Document newDocument = sourceDocument.Clone();

I know that Document.RemoveMacros() does the macro part of this, and Document.Range.Bookmarks.Clear() takes care of the bookmarks, but the remainder of the content is where I'm getting stuck.

Any ideas?


Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. If you just need to remove all content from the document, it is enough to use the following code:

Document doc = new Document(@"Test161\in.doc");




Hope this helps.

Best regards.

That did the trick. Thanks!!