mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Ignore null-chars when using structTree-data in the viewer
Testing the `tagged_stamp.pdf` document locally in the viewer, I noticed that e.g. the /Alt entry for the StampAnnotation contains "Secondary text for stamp\u0000". Elsewhere in the viewer we're skipping null-chars and it's easy enough to do that in the `StructTreeLayerBuilder` class as well. (Note that we generally let the API itself return the data as-is.)
This commit is contained in:
parent
14b2a31e78
commit
284f32f50b
2 changed files with 23 additions and 2 deletions
|
@ -13,6 +13,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { removeNullCharacters } from "./ui_utils.js";
|
||||
|
||||
const PDF_ROLE_TO_HTML_ROLE = {
|
||||
// Document level structure types
|
||||
Document: null, // There's a "document" role, but it doesn't make sense here.
|
||||
|
@ -102,13 +104,16 @@ class StructTreeLayerBuilder {
|
|||
#setAttributes(structElement, htmlElement) {
|
||||
const { alt, id, lang } = structElement;
|
||||
if (alt !== undefined) {
|
||||
htmlElement.setAttribute("aria-label", alt);
|
||||
htmlElement.setAttribute("aria-label", removeNullCharacters(alt));
|
||||
}
|
||||
if (id !== undefined) {
|
||||
htmlElement.setAttribute("aria-owns", id);
|
||||
}
|
||||
if (lang !== undefined) {
|
||||
htmlElement.setAttribute("lang", lang);
|
||||
htmlElement.setAttribute(
|
||||
"lang",
|
||||
removeNullCharacters(lang, /* replaceInvisible = */ true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue