Determining OLE values within a WOrd documents

We are running the latest Aspose.word and are having issues determining OLE print commands found within a document. Some of the pages are showing multiple print commands. It may be with our code to determine pages. Can you please look into this?
Attached are the neceesary files.

Hi John,

Thanks for your inquiry.

I have worked with your sample document and code and have found that there are 27 sections. The HeaderFooter is a section-level node and can only be a child of Section. The GetPrintCommands method call CopyLinkedHeadersFooters method which copy the HeaderFooter multiple times in the document that is the reason you are getting multiple Print Commands. Please test your application without calling CopyLinkedHeadersFooters method and check the output. You will get the three Print Commands.

Could you please share your expected output regarding Print Commands? I will investigate the issue in more detail provide you more information.

Hi John,

Thanks for your inquiry.

I have taken a look at your project and found yYou can fix this bug by adding the following condition to the loop in the GetPrintCommands method:

foreach(Section section in doc.Sections)
{
    if (section.PageSetup.SectionStart != SectionStart.Continuous && section.PageSetup.DifferentFirstPageHeaderFooter)
    {
        foreach(HeaderFooter node in section.HeadersFooters)
        {
            if (node.HeaderFooterType != HeaderFooterType.HeaderFirst ||
                node.FirstParagraph == null || !node.FirstParagraph.HasChildNodes)
                continue;
            foreach(Run run in node.FirstParagraph.Runs)
            {
                var oleMatch = olePattern.Match(run.Text);
                if (!oleMatch.Success) continue;
                printCommands.Add(pageStarts[section], oleMatch.Groups[1].Value);
                break;
            }
        }
    }
}

Thanks,