Java Programing laungage

iText Projects

iText Project 1

adplus-dvertising
Insert Picture In PDF File
Previous Home Next

By help of this program we are trying to insert to the picture or image into the PDF file. for this operation firstly import the some package.

The most important thing is that firstly we are download the iText jar file and place it into the WEB-INFO/lib of your web application. because without this file we can not run the program. In the iText there are two package, which is play an important role to create and manipulate to the PDF file that is java.io.* for input output, com.lowagie.text.pdf.* and com.lowgie.text.*.

Now we are going to insert the image into the InsertpicturePDF file. for this firstly we are creating the file which name is InsertpicturePDF in our work space.

Example:-

package r4r;
import java.io.*;
import com.lowagie.text.pdf.*;
import com.lowagie.text.*;

public class InsertpicturePDF
{

public static void main(String[] args)throws Exception
  {
	Document doc=new Document();
    PdfWriter.getInstance(doc,new FileOutputStream(
		"InsertpicturePDF.pdf"));
    doc.open();
    Image img=Image.getInstance("D:/r4r/pdf file/bag.jpg");
    doc.add(new Paragrapg("R4R Bags"));
    doc.add(img);
    doc.close();
  }
}
Previous Home Next