DynamicPDF Generator for Java has support for 6 image types and transparent images. It can read images from a file path or byte array object. This section explains how to use images in a document.
Images can be added to a page using the Image Page Element or the Background Image Page Element:
[Java]
// Adds a background image and image to a page.
page1.getElements().add(new BackgroundImage("[PhysicalPath]/MyBackground.gif"));
page1.getElements().add(new Image("[PhysicalPath]/MyLogo.gif", 0, 0, 0.24f));
NOTE: The examples in this topic show how to add an image when it is not going to be reused multiple times. For details on how to most efficiently handle images that will be used multiple times, see the Image Reuse topic.
Images can be created from a file as follows:
[Java]
// Adds an image to a page.
page1.getElements().add(new Image("[PhysicalPath]/MyLogo.gif", 0, 0, 0.24f));
Images can be created from a byte array object as follows:
[Java]
// Adds an image to a page.
page1.getElements().add(new Image(byteArray, 0, 0, 0.24f));
Images can be created from a database field as follows:
[Java]
// The "rs" variable is a ResultSet object.
// Create a byte array object out of the image data.
byte[] byteArray = rs.getBytes("field name/column number");
// Add the image to a page.
page1.getElements().add(new Image(byteArray, 0, 0, 0.24f));