Working with a Renderer <<
Table of Contents
>> Creating PDF Documents
|
|---|
Creating Images
The ImageRenderer creates java.awt.image.BufferedImage's.
This is particularly useful because it means that you can easily save the
rendered image in a variety of formats, such as PNG and JPEG. For example
the following code renders the first slide of a presentation to a 640x480
PNG image.
// Set up the presentation, output file and image File presentation = new File(...); File output = new File("out.png"); BufferedImage image = new BufferedImage(640, 480, BufferedImage.TYPE_INT_RGB); // Perform the rendering ImageRenderer renderer = new ImageRenderer(); renderer.setPresentation(presentation); renderer.setImage(image); renderer.render(0); ImageIO.write(image, "PNG", output);
To create a JPEG image, you simply need to change "PNG" to "JPEG" in the last line.
The code snippet above uses the javax.imageio package. This package
is included in JDK 1.4 and later. If you are using JDK 1.3, then you can add this
library by installing the
Java Advanced Imaging (JAI) API v1.1.2.
The image renderer does not have any renderer specific properties.
Working with a Renderer <<
Table of Contents
>> Creating PDF Documents
|
|---|
©2007 Google - Terms of Service - Privacy Policy - Google Home
