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

    Because PDF is predominately vector based, most elements will print well at any resolution. Images are an exception to this. Care must be taken to ensure that Images are output to the desired resolution.

    DynamicPDF Generator for Java does not resample or change the pixels of an image. If an image is 300 pixels wide and 300 pixels tall, it will be the same when it is output to the PDF. The size of the image in points, inches or centimeters will depend on its scale. If the scale is set to 1, it will have 1 pixel per point and output at 72 pixels per inch (also known as dots per inch or dpi). If the scale is set to 0.24, then the image will have 1 pixel for every 0.24 points and output at 300 dpi.

    Setting an Images DPI or Pixels Per Inch

    Many image formats contain a target resolution within the file. If this information is present it is read from the file and used as the default resolution when a scale is not specified. If this information is not present, the default scale is 0.24 or 300 dpi.

    To set an Image Page Element to a specified DPI, you can use the HorizontalDpi and VerticalDpi properties or the setDpi method.

    [Java]
        // Create an Image Page Element.
        Image image = new Image("[PhysicalPath]/MyLogo.gif", 0, 0);
        // Set the dpi of the image
        image.setDpi(300);
        // Add the image to a page.
        page1.getElements().add(image);
    
    See Also