Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
- Add bbox and placement options to PDFStructureElement for PDF/UA compliance
- Extend `roundedRect` with `borderRadius` as number for all corners or per-corner array (CSS order)

### [v0.18.1] - 2026-05-29

- Fix accessibility: scope in TH element
-
### [v0.18.0] - 2026-03-14

- Fix garbled text copying in Chrome/Edge for PDFs with >256 unique characters (#1659)
Expand Down
8 changes: 8 additions & 0 deletions lib/structure_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ class PDFStructureElement {
data.A = attrs;
}

if (typeof options.scope !== 'undefined') {
data.A = {
...(data.A || {}),
O: 'Table',
Scope: options.scope,
};
}

this._children = [];

if (children) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"document",
"vector"
],
"version": "0.18.0",
"version": "0.18.1",
"homepage": "http://pdfkit.org/",
"author": {
"name": "Devon Govett",
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/structure_element.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,33 @@ describe('PDFStructureElement', () => {
`endobj`,
]);
});
test('should contain scope on TH tag', () => {
const docData = logData(document);

const table = document.struct('Table');

const thead = document.struct('THead');

table.add(thead);

const trHead = document.struct('TR');

thead.add(trHead);

const th1 = document.struct('TH', { scope: 'Column' });

th1.add(document.struct('P', () => document.text('Test')));

trHead.add(th1);

document.addStructure(table);

document.end();

expect(docData).toContainChunk([
'<<\n/S /TH\n/A <<\n/O /Table\n/Scope /Column\n>>\n/P 10 0 R\n/K [12 0 R]\n>>',
`endobj`,
]);
})
});
});