We have 30 to 40 revisions in a word document which need to track the PageNo , LineNo , Header Text and Footer Text
Ex: 1st page contains 3 revisions and 4th page contains 5 revisions.
Expected Output: For 1st Revision in 1st page
Change Type: Insertion
Text: ABCDEF
PageNo: 1
Line No : 5
Header Text Changed: Summary to Summarize
Footer Text Changed: All Rights to All Rights Reserved
For 2nd Revision in 1st page
Change Type: Insertion
Text: GHIJKLM
PageNo: 1
Line No : 10
Header Text Changed: Summary to Summarize
Footer Text Changed: All Rights to All Rights Reserved
etc etc
How we can achieve this? Please provide a solution.
Thanks in advance.
Thank You for your quick response.
Extractpages method does not exist. Is it something changed in any of the version. As of now we are using Aspose.Words- 20.8.0 version
@sureshkap You can upgrade to the latest version of Aspose.Words or use LayoutCollector.GetStartPageIndex(rev.ParentNode) instead of ExtractPages to detect the page number.
LayoutCollector collector = new LayoutCollector(doc);
foreach (Revision rev in doc.Revisions)
{
if (rev.ParentNode.NodeType != NodeType.Run)
continue;
string text = (rev.ParentNode as Run).Text;
Console.WriteLine("Change Type: " + rev.RevisionType.ToString());
Console.WriteLine("Text: " + text);
int pageNum = collector.GetStartPageIndex(rev.ParentNode);
Console.WriteLine("PageNo: {0}", pageNum);
PageSetup ps = doc.FirstSection.PageSetup;
string headerText = doc.FirstSection.HeadersFooters[HeaderFooterType.HeaderPrimary].GetText().Trim();
string footerText = doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary].GetText().Trim();
if (ps.DifferentFirstPageHeaderFooter && (pageNum == 1))
{
headerText = doc.FirstSection.HeadersFooters[HeaderFooterType.HeaderFirst].GetText().Trim();
footerText = doc.FirstSection.HeadersFooters[HeaderFooterType.FooterFirst].GetText().Trim();
}
if (pageNum % 2 == 0)
{
headerText = doc.FirstSection.HeadersFooters[HeaderFooterType.HeaderEven].GetText().Trim();
footerText = doc.FirstSection.HeadersFooters[HeaderFooterType.FooterEven].GetText().Trim();
}
Console.WriteLine("Header Text Changed: " + headerText);
Console.WriteLine("Footer Text Changed: " + footerText);
Console.WriteLine();
}