Skip to content

Commit d04832a

Browse files
Add test case for empty cells
1 parent 4c22b99 commit d04832a

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@
620620
!autoprint.pdf
621621
!bug1811694.pdf
622622
!bug1811510.pdf
623+
!issue20324.pdf
623624
!bug1815476.pdf
624625
!issue16021.pdf
625626
!bug1770750.pdf

test/pdfs/issue20324.pdf

10.9 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,12 @@
16761676
"lastPage": 1,
16771677
"type": "eq"
16781678
},
1679+
{ "id": "issue20324",
1680+
"file": "pdfs/issue20324.pdf",
1681+
"md5": "13250232aa91444f983279581d9c02d6",
1682+
"rounds": 1,
1683+
"type": "eq"
1684+
},
16791685
{
16801686
"id": "issue13561_reduced",
16811687
"file": "pdfs/issue13561_reduced.pdf",

test/unit/api_spec.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5076,6 +5076,41 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
50765076
canvasFactory.destroy(canvasAndCtx);
50775077
await loadingTask.destroy();
50785078
});
5079+
5080+
it("should collect all list and table items in StructTree", async function() {
5081+
const findNodes = (node, check) => {
5082+
const results = [];
5083+
if (check(node)) {
5084+
results.push(node);
5085+
}
5086+
if (node.children) {
5087+
for (const child of node.children) {
5088+
results.push(...findNodes(child, check));
5089+
}
5090+
}
5091+
return results;
5092+
};
5093+
const loadingTask = getDocument(buildGetDocumentParams("issue20324.pdf"));
5094+
5095+
const pdfDoc = await loadingTask.promise;
5096+
const page = await pdfDoc.getPage(1);
5097+
const tree = await page.getStructTree({
5098+
includeMarkedContent: true,
5099+
});
5100+
const cells = findNodes(
5101+
tree,
5102+
node => node.role === "TD"
5103+
);
5104+
expect(cells.length).toEqual(4);
5105+
5106+
const listItems = findNodes(
5107+
tree,
5108+
node => node.role === "LI"
5109+
);
5110+
expect(listItems.length).toEqual(4);
5111+
5112+
await loadingTask.destroy();
5113+
});
50795114
});
50805115

50815116
describe("Multiple `getDocument` instances", function () {

0 commit comments

Comments
 (0)