Section 508 defines accessibility in the context of electronic documents for the US but it impacts also other countries.
The first implementation of accessibility for Apache FOP was done for the PDF output generator. However, it is based on the new intermediate format, thus the effort to add other output formats should be much smaller than the initial work for PDF.
The current implementation uses 2 XSLT transforms as a preprocess in Fop.getDefaultHandler.
The first addPtr.xsl
adds a pointer attribute with an unique value to each FO that appears in the structure tree.
The second transform reduceFOTree.xsl
removes all elements, attributes and text from the input FO, that are not required in the structure tree.
The result from this second transform can be seen in the new IF, where it is split per page-sequence. See the element structure-tree
below:
<?xml version="1.0" encoding="UTF-8"?> <document xmlns="http://xmlgraphics.apache.org/fop/intermediate" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:nav="http://xmlgraphics.apache.org/fop/intermediate/document-navigation"> <header> <x:xmpmeta xmlns:x="adobe:ns:meta/"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/" rdf:about="> <xmp:CreateDate>2009-01-20T22:27:23-08:00</xmp:CreateDate> <xmp:CreatorTool>Apache FOP Version SVN branches/Temp_AreaTreeNewDesign</xmp:CreatorTool> <xmp:MetadataDate>2009-01-20T22:27:23-08:00</xmp:MetadataDate> </rdf:Description> </rdf:RDF> </x:xmpmeta> </header> <page-sequence> <structure-tree> <fo:flow xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:block xmlns:foi="http://xmlgraphics.apache.org/fop/internal" foi:ptr="N10014"/> </fo:flow> </structure-tree> <page index="0" name="1" page-master-name="1" width="594720" height="792000"> <page-header/> <content> <viewport width="594720" height="792000"> <font family="sans-serif" style="normal" weight="400" variant="normal" size="12000" color="#000000"/> <text x="0" y="10266" ptr="N10014">hello</text> </viewport> </content> <page-trailer/> </page> </page-sequence> <trailer/> </document>
There are 3 ways to enable accessibility:
fop -a -fo testcases/tc1/tc1.fo -pdf testcases/tc1/tc1.pdf
userAgent.getRendererOptions().put("accessibility", Boolean.TRUE);
<fop version="1.0"> <accessibility>true</accessibility> ... </fop>
fo:block-container
in a page corresponds to the reading order.fox:alt-text
has been added for fo:external-graphic
and fo:instream-foreign-object
.
Screen readers require additional information in tagged PDF files in order to read documents aloud. To enable proper vocalization PDF supports the following features:
Make sure to call the new PDF code when you embed FOP in your Java code: MimeConstants.MIME_PDF + ";mode=painter"
Adjust the Java heap size in order to process larger files.