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

Free Support Forum - aspose.com

Ignore Revisions in Document

I want to be able to ignore revisions in a document opened with Aspose. I do not want to accept or reject any of them, simply ignore that they are there and replace them with whitespace. Is there a way to do this?

Hi Ashley,

Thanks for your inquiry. Could you please attach your input and expected output Word documents here for testing? We will then provide you more information about your query along with code.

I have added a sample input document and what should be an expected output document. Technically, we are not modifying the original document, we just want to ignore runs that are within revisions as we are parsing the document without actually modifying the document. So, the output document is more of what we expect the input document to look like when we parse it, if that makes sense.
Hi Ashley,

Thanks for sharing the detail. Please use following code example to achieve your requirements. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "sampleInputDocument.docx");

Boolean blnHasnodes = false;

foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true).ToArray())

{

foreach (Run run in para.Runs)

{

blnHasnodes = true;

if (run.IsDeleteRevision || run.IsInsertRevision)

run.Remove();

}

if (blnHasnodes && !para.HasChildNodes)

para.Remove();

blnHasnodes = false;

}

doc.Save(MyDir + "Out.docx");

I can see how that would work for Insertion and Deletion type revisions. But what about FormatChange, Moving, and StyleDefinitionChange revisions? I would like to remove those from my document as well without accepting or rejecting them.

Hi Ashley,

Thanks for your inquiry. Could you please share some detail about your Use Case why you do not want to accept or reject the revisions?

You may try following code example to achieve your requirements. Hope this helps you.

Document doc = new Document(MyDir + "sampleInputDocument.docx");

foreach (Revision revision in doc.Revisions)

{

revision.ParentNode.Remove();

}

doc.Save(MyDir + "Out.docx");