DEIMS-2024: Fully Accessible PDF/UA documents

Accessibility

The PDF's tagging tree is analogous to the Accessibility tree for an HTML document, structured in accordance with WCAG/ARIA guidelines. This includes specifying ‘landmarks’ and ‘regions’ with headings, and a ‘Skip to Main’ link by-passing the top-matter information, as shown in the following image. This link facilitates keyboard navigation (using the Tab key) in the PDF, as well as in derived HTML.

Tagging tree indicating top-matter, with abstract as target of Skip-to-Main link.

Being the 1st hyperlink on the page, it is most easily accessed (in Adobe Reader or Acrobat Pro) using the tab key; then return to activate the link. The target of this ‘Skip-to-Main’ link is the ‘Abstract’ title text.

The image below shows this and other links using FireFox's ‘Accessibility Tree’ view in HTML, with tab-order shown.

Accessibility Tree in Firefox, with tab-order shown
    for the links at the top of the HTML page.

Also shown is the navigation structure having links to the places within the content where pages start within the PDF file. This is permanently fixed to the top of the HTML page and allows sense to be made of phrases such as ‘top of page x’ or ‘Figure x on page y’ which might otherwise be meaningless or confusing in the HTML context. There is no corresponding structure in the PDF file, as the PDF reader software provides easy page selection. This <nav> structure is within the ‘banner’ landmark, which also contains the visual Title (i.e, ‘heading’ structure) and other top-matter Metadata elements. The link with anchor ‘Main’ skips past this ‘banner’ landmark to where the real content begins within the <div> defining the ‘main’ landmark having accessible name ‘Article Body’ as value of an aria-label attribute. Successive hits of the Tab key pass through the links until reaching the email address, as an external hyperlink.

PDF 2.0 features: References, internal links, structure destinations, and back-references

The following images, based on screen shots using Acrobat Pro, illustrate how an internal hyperlink is implemented in PDF 2.0, using Reference and Link structure elements, as well as the Link Annotation and named destination for compatibility with previous PDF specifications.

PDF structure around an internal hyperlink

The image above shows the Tag tree (at right) around a hyperlink anchor text (visual view in middle) with StructElem dictionaries expanded (at left). Red arrows denote the correspondence between structure element views, while blue arrows indicate correspondences between the actual content pieces and marked content identification (MCID) numbers, occurring sequentially as Kids (K) within the parent structures. Both the Link (id 170) and its parent Reference (id 169) StructElem dictionaries have a Ref key whose value is an indirect reference to the structure target (id 190). These are indicated with rectangles colored magenta, and similarly colored text. This id value of 190 also occurs with the ‘structure destination’ (SD) key of the Link Annotation object (Link-OBJR) which targets the destination named as ‘figure.1’. Thus a PDF consumer application (such as a viewer, screen-reader, or translation software) can determine the link target without processing the Link annotation or the named destination; starting from either object 169 or 170, one references directly object 190.

The image below similarly shows the structure and content around the target destination, which occurs at the Caption of the figure, numbered as ‘Figure 1’. It shows primarily the StructElem dictionary (id 190) of the FloatFig custom structure, which has children of an image and following Caption (with its own content). Here the Ref key has value an array of indirect references, to objects 169 and 170. That is, there are ‘back-references’ to those structures that link to this target.

PDF structures around the link target

When exporting to other formats, the object numbers have little intrinsic meaning. Names are usually better. These can be supplied through attribute values, as in the next image. Here ‘FltFig.1’ refers to the StructElem by name, which is used to identify the figure structure in both HTML and XML. Also ‘Caption.1’ refers to the caption which provides a textual description; useful particularly for screen-readers to locate an ‘Accessible Description’.

Specialised attributes for the link structure, used with various comsumer applications

It is worth noting that although the FloatFig structure is tagged between two paragraphs (id 167 and id 198) it appears visually in the middle of the latter paragraph, between the words ‘For’ and ‘each’ where the page-break occurs. (This can be seen in the 2nd image.) In LaTeX parlance, Figure 1 has ‘floated’ to the top of the page following the one being built when its coding was encountered. That LaTeX coding was as follows.

\begin{figure}
... coding for the image, fully tagged ...
\caption{... descriptive text ...}\label{PDF-enc}%
\end{figure}

It is the \caption that internally defines the named destination ‘figure.1’, which semantically refers to the whole figure environment even though it actually specifies the start of the caption label. Having the structure destination to be object 190, rather than object 197, is chosen to respect the semantics. That is, a human reader will be interested in the Figure, more so than just its caption.

The cross-reference, implemented as a hyperlink, was specified using ‘as in Figure~\ref{PDF-enc}.’. In this case it occurs before the figure itself; though in similar instances of cross-referencing it could well be coming afterwards. To cope with both possibilities, information must be saved from one LaTeX run, to be used in the next run. Such information, in this case, was as follows.

  • written to the .aux (auxiliary) file:
    \@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces ... caption text ...}}{2}{figure.1}\protected@file@percent }
    \newlabel{PDF-enc}{{1}{2}{... caption text ...}{figure.1}{}}
  • written to the .tgx (tagging history) file:
    \TPDFmakeSD{cap::figure.1}{197}{Caption.1}%
    \TPDFmakeSD{figure.1}{190}{FltFig.1}%
    \TPDFmakeSD{PDF-enc}{190}{}%
    \TPDFaliasSD{PDF-enc}{figure.1}%
    \TPDFrecordrefs{PDF-enc}{169}% aliased
    \TPDFrecordrefs{figure.1}{169,170}% combined
    \TPDFrecordrefs{figure.1}{169,170}% used

Where the \newlabel establishes the connection between the user-defined label ‘PDF-enc’ and the internally-defined destination name ‘figure.1’, it is the \TPDFalias command that allows the object numbers referring to these to be combined for \TPDFrecordrefs and used as back-references. The \TPDFmakeSD commands associate object ID numbers with the destination and/or label names, or other identifying string. Where appropriate, the name of the StructElem object is provided as well. By reading and storing information from the .aux and .tgx files, read near the beginning of LaTeX processing, all objects in the structure tree can be recorded in a fully consistent way provided there are no changes from one run to the next. Checks on whether there have been any changes are built-in to the processing and recording, so that it can be determined whether another run is needed before the results will indeed be fully consistent.