concept java.awt in category itext

appears as: java.awt, java.awt
iText in Action, Second Edition

This is an excerpt from Manning's book iText in Action, Second Edition.

This isn’t a definitive overview of what you can do with images. You’ve learned enough to change the properties of an image, but there’s more to learn about the bits and bytes of specific image types (TIFF, animated GIF, and so on), about using java.awt.Image, and about using image masks. All of this will be covered in chapter 10; now it’s time to round up what we’ve covered in chapter 2.

You can also create a java.awt.Image of the barcode using the createAwtImage() method. This method expects two colors of type java.awt.Color (as opposed to com.itextpdf.text.BaseColor). The first one represents the color of the bars; the second one defines the background color. No text is added to these barcodes.

Figure 10.10. Transparency with java.awt.Image

For this example, you’ll use a java.awt.Image object and create four different instances of com.itextpdf.Image with it.

The second parameter in the getInstance() method is null in this example. In section 10.3.1, you’ll learn that you can pass a java.awt.Color object. This color will replace the transparent color when the com.itextpdf.text.Image is added to the document. One of the possible reasons why you’d prefer using java.awt.Image is to reduce the quality of an image so that the resulting file size is significantly lower.