diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 75b11be7d..ed64906db 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -620,6 +620,7 @@ !autoprint.pdf !bug1811694.pdf !bug1811510.pdf +!issue20324.pdf !bug1815476.pdf !issue16021.pdf !bug1770750.pdf diff --git a/test/pdfs/issue20324.pdf b/test/pdfs/issue20324.pdf new file mode 100644 index 000000000..c5f2a1d4f Binary files /dev/null and b/test/pdfs/issue20324.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 03d1f1d71..afc29a290 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1676,6 +1676,12 @@ "lastPage": 1, "type": "eq" }, + { "id": "issue20324", + "file": "pdfs/issue20324.pdf", + "md5": "13250232aa91444f983279581d9c02d6", + "rounds": 1, + "type": "eq" + }, { "id": "issue13561_reduced", "file": "pdfs/issue13561_reduced.pdf", diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index a8e0fbc07..9e975cb00 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -5076,6 +5076,41 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`) canvasFactory.destroy(canvasAndCtx); await loadingTask.destroy(); }); + + it("should collect all list and table items in StructTree", async function() { + const findNodes = (node, check) => { + const results = []; + if (check(node)) { + results.push(node); + } + if (node.children) { + for (const child of node.children) { + results.push(...findNodes(child, check)); + } + } + return results; + }; + const loadingTask = getDocument(buildGetDocumentParams("issue20324.pdf")); + + const pdfDoc = await loadingTask.promise; + const page = await pdfDoc.getPage(1); + const tree = await page.getStructTree({ + includeMarkedContent: true, + }); + const cells = findNodes( + tree, + node => node.role === "TD" + ); + expect(cells.length).toEqual(4); + + const listItems = findNodes( + tree, + node => node.role === "LI" + ); + expect(listItems.length).toEqual(4); + + await loadingTask.destroy(); + }); }); describe("Multiple `getDocument` instances", function () {