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

Free Support Forum - aspose.com

Text before revision

hello

I need get original text before revision apply, but when I call from revision navigation property parent as paragraph i see changed text. Is it possible?

foreach (Revision item in doc.Revisions)
{
Console.WriteLine(“");
var p = item.ParentNode.ParentNode as Paragraph;
if (p == null) continue;
var body = p.ParentNode as Body;
if (body == null) continue;
var originaltext = p.GetText();
var newtext = item.ParentNode.GetText();
Console.WriteLine(“Type {0}”, item.RevisionType);
Console.WriteLine(“Original : {0}”, originaltext);
Console.WriteLine(“Change : {0}”, newtext);
Console.WriteLine("”);
}
Hi Mike,

Thanks for your inquiry. Please use following code example to achieve your requirements. Hope this helps you. If you face any issue, please share your input document along with expected output here for our reference. We will then provide you more information about your query.

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

Document cloneDoc = (Document)doc.Clone(true);

ArrayList removerevision = new ArrayList();

foreach (Revision revision in cloneDoc.Revisions)

{

if (revision.ParentNode.NodeType == NodeType.Run && revision.RevisionType == RevisionType.Insertion)

removerevision.Add(revision);

}

foreach (Revision revision in removerevision)

{

revision.Reject();

}

foreach (Revision item in cloneDoc.Revisions)

{

Console.WriteLine("_______");

var p = item.ParentNode.ParentNode as Paragraph;

if (p == null) continue;

var body = p.ParentNode as Body;

if (body == null) continue;

var originaltext = p.ToString(SaveFormat.Text);

var newtext = item.ParentNode.ToString(SaveFormat.Text);

Console.WriteLine("Type {0}", item.RevisionType);

Console.WriteLine("Original : {0}", originaltext);

Console.WriteLine("Change : {0}", newtext);

Console.WriteLine("_______");

}