Home Java Itext adding Under Lines



adding Under Lines
Posted on: April 17, 2007 at 12:00 AM
This section provides an example that adds under lines in java.

adding Under Lines

     

In this program we are going to tell you how you can add underlines. You can  any number of lines. This example gives you an idea ,how to make a java program to add a underline and you can also make program for making line on the text.
In this example we create chunk and then we  use the setUnderLine(
0.2f, -2f) method to add the line. There are an other chunk  object on which we use setUnderLine(0.5f, 3f).So you can create any number of chunk object and set line as your requirements. 

Code Description:


You can create line for chunk object to any position of the text .

To make a program you need to import some packages one more package:
 import java.awt.Color;

setUnderLine(float f,float f):We use the setUnderLine(float f,float f) method. Float values may be negative or positive depending on  where you want to fix the line for the text.

You can create line on small text .For this Chunk class is provided by iText API,s.

 The code of the program is given below:

import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class addUnderLines{
 public static void main(String[] argsthrows Exception{
 System.out.println("Underline, Strike through,...");
 Document document = new Document();
 PdfWriter.getInstance(document,  
 new 
FileOutputStream("underLinesPdf.pdf"));
 document.open();
 Chunk chunk = new Chunk("RoseIndia.net");
 chunk.setUnderline(0.2f, -2f);
 Paragraph paragraph = 
 
new Paragraph("The following chunk is ");
 paragraph.add(chunk);
 document.add(paragraph);
 Chunk chunk1 = new Chunk("roseindia.net");
 chunk1.setUnderline(0.5f3f);  
 document.add(chunk1);  
 document.close();
  }
}

The output of the program is given below:

Download this example.

 

Related Tags for adding Under Lines:
javacidetextmakenumberlinethisidtexforexampleaddprogramtoramexamlinesunderlineextelscanliinmcaddjadeshowproxaxampssoanykideaisllivmplerlerlgoeaandarxtvassthavlsopleplprndonogro


More Tutorials from this section

Ask Questions?    Discuss: adding Under Lines  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.