ceTe Software Help Library for Java August - 2020
DynamicPDF Generator for Java / Programming with Generator for Java / Images
In This Topic
    Images
    In This Topic

    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.

    Adding Images From A File

    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));
    

    Adding Images From A byte array Object

    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));
    

    Adding Images From A Database

    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));
    

    In This Section

    Image Formats
         Lists and Explains the different image formats that are supported.
    Image Resolution
         Explains how to set and adjust the resolution and size of images.
    Tiff Images
         Explains the different options for Tiff images that are supported.
    Image Reuse
         Explains how to most efficiently use reuse images.
    See Also