Link

Use JPedals Accessibility Options

This tutorial explains how you can use various options to make the viewer more accessible to those with more specific needs.

Alter Page and Text Colors

The Viewer includes options to override the color used for the page, text, and shapes on a PDF page.

Doing so can have many benefits such as displaying the page as white text on black for viewing in dark environments, setting the page color to an off-white color to reduce eye strain, or alter the text to page contrast ratio to improve readability.

These values can be set in 3 different ways.

Using the Viewer Preferences window

Using the preferences window (Edit → Preferences) is an approach that your users can also use if you want to allow them to modify these options.

1

Once the Preference window is open, select the color option in the left hand panel to display the options shown below.

2

There are 4 options that control the color options for the page.

  1. The “Change Page Color” button will alter the color used for the pages background, the default is white.
  2. If you want to alter the color used for text, select the checkbox “Replace Document Text Colors”, the text on the page will have its color overrode with the color shown in the area below.
  3. The “Change Text Color” button will let you specify the color used for the pages text content, the default is black.
  4. The “Change Color of text and Line Art” will allow shapes on the page to also have colors overrode with the same color used for the text.

All options selected within the preferences window above are saved (if the properties is not read only) into the properties file to be used every time the Viewer is opened.

Using the Viewer Properties file

The properties file is an approach that can easily allow you to set these values and then lock down the properties to prevent users changing it later.

There are 4 properties that control the color options for the page.

  1. vbgColor - This property controls the page color. It takes an Integer representing an RGB color obtained by using Color.getRGB()
       <vbgColor value="16777215"/>
    
  2. replaceDocumentTextColors - This property to specify if the pages text should have its colors changed. It takes a boolean value.
       <replaceDocumentTextColors value="false"/>
    
  3. vbgColor - This property controls the text color. It takes an Integer representing an RGB color obtained by using Color.getRGB()
       <vfgColor value="0"/>
    
  4. changeTextAndLineart - This property to specify if the pages shapes should also have its colors changed. It takes a boolean value.
       <changeTextAndLineart value="false"/>
    

Using your application

You can slo trigger these changes from within your own application. This will allow you to control the color values from your own user interface and will also work with JPedals PDF to Image Conversion should you need.

The below example demonstrates how this can be achieved.

//Create a map to hold the values 
Map mapValues = new HashMap();

//This sets the page colour, the int value here will make the page black.
mapValues.put(JPedalSettings.PAGE_COLOR, Color.WHITE.getRGB());

//This sets the text colour, the int value here will make the text white.
mapValues.put(JPedalSettings.TEXT_COLOR, Color.BLACK.getRGB());

//This sets a flag to specify if shape and line art 
//should also be made the same colour as the text. 
mapValues.put(JPedalSettings.CHANGE_LINEART, true);

//This actually sets the values, so they will be used from this point on. 
//decoder here is an instance of PdfDecoder 
decoder.modifyNonstaticJPedalParameters(mapValues);  

Text To Speech

The Viewer has a facility to add text to speech functionality. Once implemented you need only highlight text, right-click the page and select the “Speak Highlight Text” option.

There are many text to speech services available, instead of providing an implementation for each we provide a simple interface and a tutorial to implement and connect to your service of choice.

The Viewer can allow you to modify the text to speech voice if multiple voices are available. This can be done in 2 ways.

  1. The properties file contains a setting to allow you to specify a voice you wish to use (if your service has multiple options). This is a simple string that is passed into Speech.setVoice(String).
       <voice value="kevin16(general domain)"/>
    
  2. The Viewer Preferences window (Edit → Preferences) contains an Interface option on the left hand side.
    On this page there will be a Speech tab if the Text to Speech has been set up. From here you can change the voice to any of those returned by Speech.listVoices().