mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Add support for basic structure tree for accessibility.
When a PDF is "marked" we now generate a separate DOM that represents the structure tree from the PDF. This DOM is inserted into the <canvas> element and allows screen readers to walk the tree and have more information about headings, images, links, etc. To link the structure tree DOM (which is empty) to the text layer aria-owns is used. This required modifying the text layer creation so that marked items are now tracked.
This commit is contained in:
parent
6429ccc002
commit
fc9501a637
22 changed files with 911 additions and 14 deletions
|
@ -717,6 +717,7 @@ class WorkerMessageHandler {
|
|||
task,
|
||||
sink,
|
||||
normalizeWhitespace: data.normalizeWhitespace,
|
||||
includeMarkedContent: data.includeMarkedContent,
|
||||
combineTextItems: data.combineTextItems,
|
||||
})
|
||||
.then(
|
||||
|
@ -745,6 +746,18 @@ class WorkerMessageHandler {
|
|||
});
|
||||
});
|
||||
|
||||
handler.on("GetStructTree", function wphGetStructTree(data) {
|
||||
const pageIndex = data.pageIndex;
|
||||
return pdfManager
|
||||
.getPage(pageIndex)
|
||||
.then(function (page) {
|
||||
return pdfManager.ensure(page, "getStructTree");
|
||||
})
|
||||
.then(function (structTree) {
|
||||
return structTree.serializable;
|
||||
});
|
||||
});
|
||||
|
||||
handler.on("FontFallback", function (data) {
|
||||
return pdfManager.fontFallback(data.id, handler);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue