Add test case for empty cells
This commit is contained in:
parent
4c22b99df3
commit
d04832a82f
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -620,6 +620,7 @@
|
||||
!autoprint.pdf
|
||||
!bug1811694.pdf
|
||||
!bug1811510.pdf
|
||||
!issue20324.pdf
|
||||
!bug1815476.pdf
|
||||
!issue16021.pdf
|
||||
!bug1770750.pdf
|
||||
|
||||
BIN
test/pdfs/issue20324.pdf
Normal file
BIN
test/pdfs/issue20324.pdf
Normal file
Binary file not shown.
@ -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",
|
||||
|
||||
@ -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 () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user