Inspecting accessibility

edit

PdfAccessibilityInspector reports the accessibility issues of a document that can be found automatically, from the requirements of PDF/UA and Tagged PDF. It reads the document and does not change it:

var report = PdfAccessibilityInspector.Inspect(PdfDocument.Open(file));
foreach (var issue in report.Issues)
{
    Assert.Fail(issue.ToString()); // such as "MissingAlternateText (page 1): A Figure has no alternate text (/Alt)"
}
PdfAccessibilityIssueKindIssue
MissingStructureTreeThe document is not tagged: it has no structure tree
NotMarkedAsTaggedThe catalog does not declare the document as tagged (/MarkInfo)
MissingLanguage, MissingTitleThe document has no natural language, or no title
TitleNotDisplayedThe viewer shows the file name instead of the title
UntaggedContentContent of a page is neither tagged nor an artifact
MissingAlternateTextA figure or a formula has no alternate text
UntaggedAnnotation, MissingTabOrderAn annotation is not in the structure tree; a page with annotations does not order them by the structure
ReadingOrderThe structure reads the content of a page in another order than the content draws it
UnknownStructureTypeA structure type is neither standard nor mapped to a standard type by the role map
SkippedHeadingLevelA heading level is skipped, such as an H3 after an H1
  • Each PdfAccessibilityIssue has its page, or none for the issues of the document, and the structure type it concerns.
  • The content of an untagged document is not checked page by page: the whole document is untagged.
  • The reading order is a heuristic: a document may draw its content in another order than it should be read on purpose. Review the pages it reports.
  • The inspector checks what can be checked automatically: it does not judge whether an alternate text describes its figure. A document that must conform to PDF/UA should be validated with veraPDF too. To write tagged documents, see Tagged PDF and PDF/UA.