Automatic numbering

Hello everyone,

I have a Word document in which I have a footer with automatic numbering.

Displayed on screen : Pages 1

My aim is to check the page displayed to the user, to verify its value. I run my document like this:

DocumentAspose doc = new DocumentAspose(memoryStream);
for (int i = 0; i < doc.PageCount; i++) {
            
        DocumentAspose pageDoc = doc.ExtractPages(pageIndex, 1);
        foreach (Paragraph paragraph in pageDoc.GetChildNodes(NodeType.Paragraph, true)) {
               var text = paragraph.GetText();
        }
}

I then analyze the contents of my “text” variable. My problem is that this variable doesn’t actually contain “Pages 1” but :

Pages PAGE * MERGEFORMAT9

Is there a way to define in the options that we want to have the calculated value actually displayed on the screen, instead of the MERGEFORMAT?

Thank you very much !
Best regards,

@BlackSea PAGE field in the document’s header/footer are updated by the consumer application. Since the header/footer can be displayed on several pages it’s value might vary.

Also in your code you are using paragraph.GetText(); to get the displayed content use paragraph.ToString(SaveFormat.Text).

1 Like