git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Accessibility@828039 13f79535-47bb-0310-9956-ffa450edef68tags/fop-1_0
<code>fop -a -fo mydocument.fo -pdf mydocument.pdf</code> | <code>fop -a -fo mydocument.fo -pdf mydocument.pdf</code> | ||||
</li> | </li> | ||||
<li> | <li> | ||||
<strong>Embedding:</strong> <code>userAgent.getRendererOptions().put("accessibility", Boolean.TRUE);</code> | |||||
<strong>Embedding:</strong> <code>userAgent.setAccessibility(true);</code> | |||||
</li> | </li> | ||||
<li> | <li> | ||||
<strong>Optional setting in fop.xconf file:</strong> | <strong>Optional setting in fop.xconf file:</strong> |
this.factory = factory; | this.factory = factory; | ||||
setBaseURL(factory.getBaseURL()); | setBaseURL(factory.getBaseURL()); | ||||
setTargetResolution(factory.getTargetResolution()); | setTargetResolution(factory.getTargetResolution()); | ||||
if (this.getRendererOptions().get(AccessibilityUtil.ACCESSIBILITY) == null) { | |||||
this.rendererOptions.put(AccessibilityUtil.ACCESSIBILITY, Boolean.FALSE); | |||||
} | |||||
setAccessibility(factory.isAccessibilityEnabled()); | |||||
} | } | ||||
/** @return the associated FopFactory instance */ | /** @return the associated FopFactory instance */ | ||||
getFactory().getFontManager().setFontBaseURL(fontBaseUrl); | getFactory().getFontManager().setFontBaseURL(fontBaseUrl); | ||||
} catch (MalformedURLException e) { | } catch (MalformedURLException e) { | ||||
throw new IllegalArgumentException(e.getMessage()); | throw new IllegalArgumentException(e.getMessage()); | ||||
} | |||||
} | |||||
} | } | ||||
/** | /** | ||||
this.conserveMemoryPolicy = conserveMemoryPolicy; | this.conserveMemoryPolicy = conserveMemoryPolicy; | ||||
} | } | ||||
/** | |||||
* Activates accessibility (for output formats that support it). | |||||
* | |||||
* @param accessibility <code>true</code> to enable accessibility support | |||||
*/ | |||||
public void setAccessibility(boolean accessibility) { | |||||
if (accessibility) { | |||||
getRendererOptions().put(AccessibilityUtil.ACCESSIBILITY, Boolean.TRUE); | |||||
} | |||||
} | |||||
/** | /** | ||||
* Check if accessibility is enabled. | * Check if accessibility is enabled. | ||||
* @return true if accessibility is enabled | * @return true if accessibility is enabled |
import org.apache.xmlgraphics.image.loader.ImageContext; | import org.apache.xmlgraphics.image.loader.ImageContext; | ||||
import org.apache.xmlgraphics.image.loader.ImageManager; | import org.apache.xmlgraphics.image.loader.ImageManager; | ||||
import org.apache.fop.accessibility.AccessibilityUtil; | |||||
import org.apache.fop.fo.ElementMapping; | import org.apache.fop.fo.ElementMapping; | ||||
import org.apache.fop.fo.ElementMappingRegistry; | import org.apache.fop.fo.ElementMappingRegistry; | ||||
import org.apache.fop.fonts.FontCache; | import org.apache.fop.fonts.FontCache; | ||||
*/ | */ | ||||
public FOUserAgent newFOUserAgent() { | public FOUserAgent newFOUserAgent() { | ||||
FOUserAgent userAgent = new FOUserAgent(this); | FOUserAgent userAgent = new FOUserAgent(this); | ||||
userAgent.getRendererOptions().put(AccessibilityUtil.ACCESSIBILITY, | |||||
Boolean.valueOf(this.accessibility)); | |||||
return userAgent; | return userAgent; | ||||
} | } | ||||
/** | /** | ||||
* Used for accessibility to pass value to newFOUserAgent | |||||
* @param value set through xconf file | |||||
* Sets accessibility support. | |||||
* | |||||
* @param value <code>true</code> to enable accessibility, <code>false</code> otherwise | |||||
*/ | */ | ||||
void setAccessibility(boolean value) { | void setAccessibility(boolean value) { | ||||
this.accessibility = value; | this.accessibility = value; | ||||
} | } | ||||
boolean isAccessibilityEnabled() { | |||||
return accessibility; | |||||
} | |||||
/** | /** | ||||
* Returns a new {@link Fop} instance. FOP will be configured with a default user agent | * Returns a new {@link Fop} instance. FOP will be configured with a default user agent | ||||
* instance. | * instance. |