Java Programing laungage

iText Projects

iText Project 1

adplus-dvertising
Set Subscript and Superscript in PDF file
Previous Home Next

By the help of this program I am trying to show you how we can set the Subscript and superscript in PDF file. This means that if we want to write the text under any heading so we can set the subscript. And if we want to superscript under the subscript then we can used to the superscript 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 the settextRise(float f) method for sub and superscript.

Example:

package r4r;
import java.util.*;
import java.io.FileOutputStream;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfWriter;

public class setsuperscripttest {
public static void main(String[] args)throws Exception 
	{
System.out.println("Superscript Examples"); 
Document doc = new Document();
PdfWriter.getInstance(doc,new FileOutputStream
("setsuperscripttest.pdf"));
doc.open(); 
Chunk ch1,ch2,ch3;
ch1 = new Chunk("Welcome");
ch1.setTextRise(8.0f);
doc.add(ch1);
ch2 = new Chunk("In");
ch2.setTextRise(4.0f);
doc.add(ch2);
ch3 = new Chunk("R4RTechSoft solution");
ch3.setTextRise(2.0f);
doc.add(ch3);
doc.close();
}
}
Previous Home Next