Please choose a menu option
Visit the IDRsolutions WebSite

Convert PDF to grayscale or black and white

PDF files are usually displayed and printed in ARGB to provide the highest quality output. Sometimes, you may wish to change this functionality (for example to only print in grayscale or black and white). This tutorial explains how to use hooks in JPedal to achieve this.

JPedal Helper class

JPedal contains an interface org.jpedal.external.JPedalHelper and a static instance of this in PdfDecoder called Helper. Usually Helper is null, but if a static instance of it is created, it will be called at various points. These include controlling the setting of colour and rendering of images, so the ARGB data can be changed.

The interface includes 2 methods which can be used to control the color of the output

Setting it up

To activate this functionality, you just have to setup a static instance to PdfDecoder.Helper before you use JPedal. The instance should implement the interface org.jpedal.external.JPedalHelper. There is an example built in to convert all printed output to black and white. To use this you would just add this line to your code before using JPedal.

PdfDecoder.Helper=new org.jpedal. examples.ExampleHelper();

Click here to see the code in ExampleHelper

 

Return to main PDF support section

Click here for the main PDF support area with lots of java examples, PDF tutorials and useful information to get the most out of the JPedal PDF library

 


PDF viewer