Java Programing laungage

iText Projects

iText Project 1

adplus-dvertising
Set the page size of PDF file
Previous Home Next

The iText library is very useful tool by help of this jar file we can set the page size of PDF file. If it is exist then PDF file automatically set the size of page otherwise PDF file  will be created. for making the program for set the size of page firstly import the iText jar file, in which two interface is too important that support to the creation of PDF file and manipulation it.

These interfaces are:

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

Example:

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

public class pagesize 
	{
public static void main(String[] args)throws Exception
	{
Document doc=new Document(PageSize.A4,40,40,40,40);
PdfWriter.getInstance(doc,new FileOutputStream("pagesize.pdf"));
doc.open();
doc.add(new Paragraph("hello bhai"));
doc.close();
}
}
Previous Home Next