LayoutEnumerator API is not able to detect PAGE nodes when the document contains Footnote element after "Section Break" element

Hi,
We are currently using Aspose Words Java version in our application.

The LayoutEnumerator API is not able to detect PAGE nodes when the document contains FOOTNOTE element after “Section Break” element.

We ran the below code with the latest Aspose Words Java version 23.9.0.
Use the attached “TestData.docx” file when running below code.

The attached test document has total 5 pages, but the below code traverses thru and detects only first 2 pages (BUG).

What we observed is, when there is a “Footnote” element after the “Section Break” element in a particular page, then the LayoutEnumerator API fails to detect the PAGE node in that page, and it does NOT advance the layout entity traversal to the subsequent pages. Thus, the traversal get stuck and it doesn’t proceed on to the subsequent pages in the document.

Run the below code:

public static void main(String[] args) throws Exception {
    Document doc = new Document("TestData.docx");
    int numberOfPages = doc.getPageCount();
    LayoutEnumerator enumerator = new LayoutEnumerator(doc);
    List<Integer> pageNumbersFound = new ArrayList<>();
    for (int pageIndex = 0; pageIndex < numberOfPages; pageIndex++) {
        pageNumbersFound.add(traverseLayoutEntities(enumerator));
    }
    System.out.println("Page numbers found: " + pageNumbersFound);
}
 
// Traverses the layout elements in the current page.
// Returns the current page number if the PAGE node is found. Otherwise returns -1.
private static int traverseLayoutEntities(LayoutEnumerator enumerator) throws Exception {
    do {
        if (enumerator.moveLastChild()) {
            traverseLayoutEntities(enumerator);
            enumerator.moveParent();
        }
        if (enumerator.getType() == LayoutEntityType.PAGE) {
            int pagerNumberFound = enumerator.getPageIndex();
            enumerator.moveNext();
            return pagerNumberFound; // Page node found.
        }
    } while (enumerator.movePrevious());
    return -1; // Page node not found.
}

When we run the above code, it prints

Page numbers found: [1, 2, -1, -1, -1]

But we expect the following to be printed

Page numbers found: [1, 2, 3, 4, 5]

Can you please check this.
Let us know if we miss something in the above code or if there any workaround code for this issue.
TestData.docx (16.1 KB)

Thanks,
-Satya

@oraspose
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26023

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

TestData2.docx (16.1 KB)
We have observed this same issue with “Endnote” element as well. When there is a “Endnote” element reference is used in a particular page and if there is a “Section Break” element at the end that particular page, then the LayoutEnumerator API fails to detect the PAGE entity in that page, and it does NOT advance the layout entity traversal to the subsequent pages. Thus, the traversal get stuck and it doesn’t proceed on to the subsequent pages in the document.

Use the attached “TestData2.docx” to reproducible this issue with “Endnote” element by running the same code provided in the original issue logged for Footnote element.

The attached test document “TestData2.docx” has total 5 pages, but the above code traverses thru and detects only first 2 pages (BUG).

@oraspose Thank you for additional information. Looks like the same problem as described above. Endnotes and footnotes are the same by their nature in Aspose.Words DOM. We will let you know once the problem is resolved or we have more information for you.

The issues you have found earlier (filed as WORDSNET-26023) have been fixed in this Aspose.Words for Java 23.11 update.