} ?>
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

PDF to HTML5 conversion – image manipulation

47 sec read

By default when we convert a PDF to HTML5 page, we down-sample the images to reduce the size. This setting does not suit everyone – some people want them smaller while others want then larger or want to do their own image down-sampling. So we we have added a custom interface so that you can alter the images yourself. If an instance of this is setup, we will leave the image control to you. Here is how it works…

You can create an instance of our interface and pass it into our PDF2HTML convertor. At the moment it only has 1 method (we may add more to gives users even more functionality).

/**
 * allow user to control image
 */OutputImageController imageController=new SampleHTMLImageController();
HTMLoutput.writeCustom(HTMLDisplay.IMAGE_CONTROLLER,imageController);

The actual interface is very simple. It takes the image and the GraphicsState (which tells you how big the final image will be) and you return the image. Our sample here just returns the exact image (so it will not be scaled down). You could do anything you need here (add a watermark, down-sample with bicubic algorithm, convert it to grayscale, etc).

/**
 * example code for image handler
 */private class SampleHTMLImageController 
       implements OutputImageController {
    public BufferedImage processImage(BufferedImage image, 
                          GraphicsState gs, String name) {

        return image; //just return full image in example
    }
}

What would you use it for?



Do you need to solve any of these problems in Java?

Convert PDF to HTML5
Convert PDF to HTML5
Convert PDF to SVG
Convert PDF to SVG
View Forms in the browser
View Forms in the browser
Java PDF Reader and Viewer
View PDF Documents
Convert PDF to image
Convert PDF to image
Extract Text from PDF
Extract Text from PDF
Read/Write images in Java
Read/Write images
Replace ImageIO
Replace ImageIO
Convert Image to PDF
Convert Image to PDF
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2020. All rights reserved.