This tutorial explains how you can use various options to make the viewer more accessible to those with more specific needs.
Override PDF Colors
JPedal has options to allow you to specify a set of colors to be used when displaying a PDF in place of those colors specified within the PDF. This can prove useful in several situations such as dark environments where a black page and white text would be seen clearer or altering the page color to an off white color to avoid straining the eyes.
Please note that the follow instruction discuss changing the PDF text and page colors. This is only changed in the display, the PDF document remains untouched and will appear as it was when these options are turned off or if the file is viewed in another viewer.
The first and by far the easiest way to change the colors of the displayed PDF pages is to use the preferences window to alter them.
The page color option is always active with the default white value and can be changed as any point.
Below this is the optional text color options. Once you select the Replace Document Text Colors check box all the text within the PDF displayed is changed to the selected text color.
The Change Color of Text and Line art check box will use the text color on all text and shapes with the PDF.
All options selected within the preferences window above are saved into the properties files to be used every time the Viewer is opened. The second way to use these options to to alter the values within the propertied file manually.
For example this is the value that controls the page color. The integer value is an integer representation of the RGB values. The value here will turn the page black:
This value specifies if the text color should also be changed:
This is the value that controls the text color. The integer value is an integer representation of the RGB values. The value here will turn the text white:
This values specified if shapes and line art should also have it's color changed like the text:
The third option is code based. The advantage of using this method over those listed before is that it also works when converting a PDF page to an image. In order to achieve this you need only add the values you wish to use to a map and pass them to the PdfDecoder instance you are using.
Here is an example of the code to handle this.
//Create a map to hold the values
Map mapValues = new HashMap();
//This sets the page color, the int value here will make the page black. mapValues.put(JPedalSettings.PAGE_COLOR, 0);
//This sets the text color, the int value here will make the text white. mapValues.put(JPedalSettings.TEXT_COLOR, -1);
//This sets a flag to specify if shape and line art
//should also be made the same color as the text.
//This actually sets the values so they will be used from this point on.
//decoder here is an instance of PdfDecoder
The Viewer example has a feature that will prove useful for those who have difficultly reading PDF content on screen. When you have highlighted a section of the text you can have the Viewer read the highlighted text back to you. All of this is handled by an external speech library you will need to add manually, we have a tutorial for this which can be found here.
Once you have added your speech library and handling class you can have the Viewer read highlighted text back to you by following these steps.
First you must start by highlighting the text you wish to have read back to you. Next you need to right click on the page (hold down ctrl and click if using a Mac).
If you have added your speech handler correctly, the bottom most option on this menu should be "Speak Highlight Text". Clicking this will have the text read to you.
As mentioned before you can set your own voice for the text to speech functionality to use. These voices are any that you have added to the name list in your speech handler.
The first method is to set the file voice variable in the properties file with one from your voice list. The example below sets the voice to one of the default options supported by Freetts in the tutorials example:
<voice value="kevin16(general domain)"/>
The second method is achieved via the preferences window. Once you have the Viewer example open, go to the preferences window. Once the window is open, select the Interface tab and go to the speech tab to the right. Here you will find a drop down box containing all the available default voices.