Java Programing laungage

iText Projects

iText Project 1

adplus-dvertising
Implement Underline in PDF
Previous Home Next

By the help of this program we can create the PDF page which left the Underline for text in the PDF file. For creating this 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

  • java.io.*;
  • 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.

Example:

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

public class Underlinetest
	{
public static void main(String[] args) throws Exception
	{
System.out.println("Underline.......................");

Document doc  = new Document();

PdfWriter.getInstance(doct, 
new FileOutputStream("underLinesPdf.pdf"));
doc.open();
Chunk ch = new Chunk("R4R Tutorials site");
ch.setUnderline(0.2f, -2f);
Paragraph par = new Paragraph
("following this........................");

par.add(chunk);
doc.add(paragraph);
Chunk ch1 = new Chunk
("This is ths free site of the tutorials...........");

ch1.setUnderline(0.5f, 3f); 
doc.add(ch1); 
doc.close();
}
}
Previous Home Next