Hope to see you there!
Hope to see you there!
This page describes theaccessibility features of Apache™ FOP.Section 508 defines accessibility in the context of electronic documents for the USA but other countries have similar requirements.
Accessibility features are available only for the PDF output format and there are some implementation limitations. Also, certain actions must be undertaken by the content creator to ensure that FOP can create a truly accessible document.
There are 3 ways to enable accessibility:
Command line: The command line option-a turns on accessibility:
fop -a -fo mydocument.fo -pdf mydocument.pdfEmbedding:
userAgent.setAccessibility(true);Optional setting in fop.xconf file:
<fopversion="1.0"><accessibility>true</accessibility> ...</fop>When accessibility is enabled, additional information relating to the logical structure of the document is added to the PDF. That information allows the PDF viewer (or a text-to-speech application) to retrieve the natural reading order of the document.
Apache FOP cannot automatically generate accessible PDFs. Some of the work can only be performed by the content provider. Following are some changes that may be necessary to your XSL-FO content in order to generate really accessible documents:
Table cells must have a table row as their parent.
Images must have an alternate text: use thefox:alt-text extension attribute (in thefox namespace) onfo:external-graphic andfo:instream-foreign-object to specify a short text describing the image. The alternate text can also be used onfo:basic-link.
Ensure that the order offo:block-container elements in a page corresponds to the reading order.
Specify the natural language of the document using the language and country properties (or via thexml:lang shorthand property).
To remove empty fo:blocks from the structure tree, you can set the keep-empty-tags to false.
<accessibilitykeep-empty-tags="false">true</accessibility>A screen reader may repeat page numbers for static content such as footers. So we can enable this option to duplicate these elements per page.
<accessibilitystatic-region-per-page="true">true</accessibility>ThePDF Reference defines a set of standard Structure Types to tag content. For example, ‘P’ is used for identifying paragraphs, ‘H1’ to ‘H6’ for headers, ‘L’ for lists, ‘Div’ for block-level groups of elements, etc. This standard set is aimed at improving interoperability between applications producing or consuming PDF.
FOP provides a default mapping of Formatting Objects to elements from that standard set. For example,fo:page-sequence is mapped to ‘Part’,fo:block is mapped to ‘P’,fo:list-block to ‘L’, etc.
You may want to customize that mapping to improve the accuracy of the tagging or deal with particular FO constructs. For example, you may want to make use of the ‘H1’ to ‘H6’ tags to make the hierarchical structure of the document appear in the PDF. This is achieved by using therole XSL-FO property:
...<fo:blockrole="H1"font-weight="bold">I. A Level 1 Heading</fo:block><fo:block>This is the first paragraph of the first section...</fo:block>...If a non-standard structure type is specified, FOP will issue a warning and fall back to the default tag associated to the Formatting Object.
If your document has content that is not meant to appear in the structure tree, you can wrap it in anfo:wrapper element whoserole property has been set to ‘artifact’. For example:
<fo:block>blah... blah...<fo:wrapperrole="artifact">Funny graphical thing without logical meaning</fo:wrapper> blah... blah...</fo:block>This special value for therole property can also be applied tofo:static-content elements; indeed such elements are often used to contain page header information, that is there purely as a reading aid for sighted people and is meaningless when read out loud by a screen reader.
<fo:static-contentflow-name="xsl-region-before"role="artifact"><fo:block>Page<fo:page-number/></fo:block></fo:static-content>This can be applied to table headers and footers also:
<fo:table-headerrole="artifact"><fo:table-footerrole="artifact">In XSL-FO, tables are inherently defined row by row. Thefo:table-header element can be used to define ‘header rows’, in which each cell is a header of the corresponding column (likeTH cells in HTML). The cell is said to have a columnscope.
There is no way, however, to define ‘row headers’: cells that have a row scope. Of course it is possible to style a cell to make it look like a header (for example, by using a bolder font), but that won’t be reflected in the structure of the document.
When creating accessible documents, it is desirable to have that information, as it can be used by a screen reader to help the user build a mental representation of the table.
For that purpose, FOP defines thefox:header extension property. If anfo:table-column element has this property set totrue, then the corresponding cells will receive theTH structure type, and theScope structure attribute will have one of the following value:
fo:table-header;fox:header | |
|---|---|
| Value: | true | false |
| Initial: | false |
| Inherited: | no |
| Applies to: | fo:table-column |
If for some reason a cell inside a header column is not meant to be a header cell, therole property can be used to override the default behavior and set the structure type toTD.
For example, the following table:
<fo:tablewidth="100%"table-layout="fixed"><fo:table-columnxmlns:fox="http://xmlgraphics.apache.org/fop/extensions"fox:header="true"column-width="proportional-column-width(1)"/><fo:table-columncolumn-width="proportional-column-width(1)"/><fo:table-columncolumn-width="proportional-column-width(1)"/><fo:table-headerfont-weight="bold"><fo:table-row><fo:table-cellborder="1pt solid black"padding-left="1pt"><fo:block>Header Scope = Both</fo:block></fo:table-cell><fo:table-cellborder="1pt solid black"padding-left="1pt"><fo:block>Header Scope = Column</fo:block></fo:table-cell><fo:table-cellborder="1pt solid black"padding-left="1pt"><fo:block>Header Scope = Column</fo:block></fo:table-cell></fo:table-row></fo:table-header><fo:table-body><fo:table-row><fo:table-cellborder="1pt solid black"padding-left="1pt"font-weight="bold"><fo:block>Header Scope = Row</fo:block></fo:table-cell><fo:table-cellborder="1pt solid black"padding-left="1pt"><fo:block>Cell 1.1</fo:block></fo:table-cell><fo:table-cellborder="1pt solid black"padding-left="1pt"><fo:block>Cell 1.2</fo:block></fo:table-cell></fo:table-row><fo:table-row><fo:table-cellborder="1pt solid black"padding-left="1pt"font-weight="bold"><fo:block>Header Scope = Row</fo:block></fo:table-cell><fo:table-cellborder="1pt solid black"padding-left="1pt"><fo:block>Cell 2.1</fo:block></fo:table-cell><fo:table-cellborder="1pt solid black"padding-left="1pt"><fo:block>Cell 2.2</fo:block></fo:table-cell></fo:table-row><fo:table-row><fo:table-cellborder="1pt solid black"padding-left="1pt"role="TD"><fo:block>Non-header</fo:block></fo:table-cell><fo:table-cellborder="1pt solid black"padding-left="1pt"><fo:block>Cell 3.1</fo:block></fo:table-cell><fo:table-cellborder="1pt solid black"padding-left="1pt"><fo:block>Cell 3.2</fo:block></fo:table-cell></fo:table-row></fo:table-body></fo:table>will be rendered into this:
| Header Scope = Both | Header Scope = Column | Header Scope = Column |
|---|---|---|
| Header Scope = Row | Cell 1.1 | Cell 1.2 |
| Header Scope = Row | Cell 2.1 | Cell 2.2 |
| Non-header | Cell 3.1 | Cell 3.2 |
Accessible PDFs can be tested, for example, using Adobe Acrobat Professional. Its Accessibility Check feature creates a report indicating any deficiencies with a PDF document. Alternatively, you can just let a screen reader read the document aloud.
Accessibility support in Apache FOP is relatively new, so there are certain limitations. Please help us identify and close any gaps.
The natural language can currently only be specified at the page-sequence level. The document language is derived from the language of the first page-sequence. It is currently not possible to override the language inside the content below the page-sequence level.
It's currently not possible to specify the expanded form of an abbreviation or acronym.
SVG graphics (or images in general) are treated as a single figure. Text contained in SVGs is not accessible. It's only possible to work withfox:alt-text.
The side regions (region-before, region-after etc.) are currently not specially identified. Screen readers may read their content at page changes.
PDF/UA (PDF/Universal Accessibility), the standard for accessible PDF technology.
Define document title in fo:
<fo:declarations><x:xmpmetaxmlns:x="adobe:ns:meta/"><rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Descriptionrdf:about=""xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:title>Document title</dc:title><dc:creator>Document author</dc:creator><dc:description>Document subject</dc:description></rdf:Description></rdf:RDF></x:xmpmeta></fo:declarations>Enable PDF/UA-1 in fop.xconf:
<fopversion="1.0"><accessibility>true</accessibility><renderers><renderermime="application/pdf"><pdf-ua-mode>PDF/UA-1</pdf-ua-mode></renderer></renderers></fop>Many resources providing guidance about creating accessible documents can be found on the web. Here are a few links, along with additional resources around the topic:
PDF Reference 1.4 (look up chapters 9.7 "Tagged PDF" and 9.8 "Accessibility Support")
Developer-oriented details on the accessibility features (on the Wiki)
Copyright © 2025 The Apache Software Foundation, Licensed undertheApache License, Version 2.0.
Apache, Apache XML Graphics, Apache FOP, Apache Batik, the Apache logo, and theApache XML Graphics logos are trademarks ofThe ApacheSoftware Foundation. All other marks mentioned may be trademarks or registeredtrademarks of their respective owners.