Java Programing laungage

iText Projects

iText Project 1

Set the PDF Page margin
Previous Home Next

By the help of this program we can create the PDF page which left the margin in the PDF file. For creating Margin page we firstly create the PDF file by utilizing the two package, which is help to create the PDF file and manipulation in it. These package are

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

For doing this, firstly import the some package. Before this we are going to add the iText jar file in our project. then we can start the code.


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

public class marginetest 
public static void main(String[] arg)throws Exception
Paragraph paragraph=new Paragraph(); 
Document doc = new Document(PageSize.A4, 36, 72, 108, 180);
PdfWriter.getInstance(doc,new FileOutputStream
doc.add(new Paragraph(
"Margin Test"));

doc.add(new Paragraph
("This is the R4R tutorials Visit it Please"));

for (int k = 0; k < 20; k++) { 
("Welcome friends in the R4R Tutotrials\n");

doc.add(new Paragraph("Done"));
Previous Home Next