Java Programing laungage

iText Projects

iText Project 1

Rotate the Images
Previous Home Next

By help of this program we are trying to rotate the image in any direction in a pdf file. If the images is exists, then fine otherwise we are going to insert the image into the PDF file. For creating this program we are firstly need to import some packages. For make this program the first is to place the iText.jar into the WEB-INF/lib of our web application. Without iText.jar the application will not run. These packages will help us to make and use pdf file in our program. The packages we were talking about are

  • com.lowagie.text.pdf.*; and
  • com.lowagie.text.*;

Now firstly we are creating a file name imagesRotate. what the program is going to perform. Inside the class declare a main method inside which we are going to write the logic of our program. Firstly make a object of Document class. This class describes a document's margins,page size,and other attributes.


package r4r;
import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

public class rotateimagetest 
public static void main(String[]args)throws Exception
Document doc=new Document();
PdfWriter.getInstance(doc,new FileOutputStream
Image img = Image.getInstance

doc.add(new Paragraph("Original Images of Bag:"));
img.scalePercent (10.0f);
img.setRotationDegrees (60.0f); 
doc.add(new Paragraph("After Rotation"));
Previous Home Next