Java Programing laungage

iText Projects

iText Project 1

adplus-dvertising
Set Page Type in PDF File
Previous Home Next

By the help of this program I am trying to show you how we can set the page type in PDF file. This means that we can set the page type like landscape or portrait in PDF file. For performing this task firstly we are import to the iText.jar file and some packages like com.lowagie.text.pdf.*, com.lowagie.text.*.

After import of the package we are going to initialized to the document into the PDF file. then apply for page type.

Example:

package r4r;
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

public class pagetypetest 
	{
public static void main(String arg[])throws Exception
	{
Document doc = new Document(PageSize.A4.rotate());
PdfWriter.getInstance(doc,new 
FileOutputStream("pagetypetest.pdf"));
doc.open();
doc.add(new Paragraph("landscape format"));
doc.setPageSize(PageSize.A4);
doc.newPage();
doc.add(new Paragraph("portrait format"));
doc.close();
}
}
Previous Home Next