Add Image in PDF using iText

iText has a variety of API support for image manipulation in PDF file. You can Rotate, Reverse, Scale and do many other operations on an image using the iText library. Lets see how to add image in PDF using iText.

Important class – com.itextpdf.text.Image

Following are the methods that can be used
a) setRotation(float r) Sets the rotation of the image in radians.
b) setRotationDegrees(float deg) Sets the rotation of the image in degrees.
c) scalePercent(float percent) Scale the image to a certain percentage.
d) scalePercent(float percentX, float percentY) Scale the width and height of an image to a certain percentage.
e) scaleToFit(float fitWidth, float fitHeight) Scales the image so that it fits a certain width and height.

Example

In the below example we have taken an image and displayed it in various ways.

Output
Add Image in PDF using iText

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn