TPTruPDF

@trupdf/a11y

Accessibility helpers targeting WCAG 2.2 AA. Live region announcements, skip links, structural reading order (secure mode), roving focus utilities.

AccessibilityManager

Owns an off-screen role="status" live region that screen readers read aloud whenever it updates — page changes, search hits, status messages.

import { AccessibilityManager } from '@trupdf/viewer';
 
const a11y = new AccessibilityManager({
  host: viewerRoot, // default document.body
  politeness: 'polite', // or 'assertive' for license / error events
});
a11y.announce('Page 4 of 12'); // repeats re-fire (aria-atomic)
a11y.destroy();

Announcements auto-clear after 5 s so they don't re-read when the screen reader re-focuses the region.

Secure-mode reading order

In secure mode the text layer DOM is never mounted (canvas-only DRM rendering), so the live region carries the accessibility burden:

a11y.secureModeAnnounce(page, total, extras);
// "Page 4 of 12. <extras…>"

Pass structural context (e.g. headings from the structure tree via ViewerEngine.getStructureTree(page)) through extras.

Roving focus

AccessibilityManager.nextFocusable(toolbarRoot, currentEl, 'next');

Static helper returning the next/previous focusable element inside a root — used for arrow-key roving focus inside toolbars. Skips disabled, aria-hidden, and detached elements; wraps around.

import { createSkipLink } from '@trupdf/viewer';
 
const link = createSkipLink('trupdf-main', 'Skip to document');
host.prepend(link);

Builds a WCAG 2.4.1 (Bypass Blocks) anchor — visually hidden until focused.

Visible focus

Focus indicators use the --trupdf-focus-ring token. Override via Theming.

Audit

Run the automated accessibility suite:

pnpm --filter @trupdf/a11y test