Source Code : Sub and Super Script

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Sub and Super Script

Sub and Super Script

import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.StringTokenizer;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;

public class SubSupScriptPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter.getInstance(document, new FileOutputStream("SubSupScriptPDF.pdf"));
      document.open();
      String s = "Text Text Text Text Text Text Text Text Text Text Text Text Text Text ";
      StringTokenizer st = new StringTokenizer(s, " ");
      float textrise = 6.0f;
      Chunk c;
      while (st.hasMoreTokens()) {
        c = new Chunk(st.nextToken());
        c.setTextRise(textrise);
        c.setUnderline(new Color(0xC0, 0xC0, 0xC0), 0.2f, 0.0f, 0.0f, 0.0f, PdfContentByte.LINE_CAP_BUTT);
        document.add(c);
        textrise -= 2.0f;
      }
    } catch (Exception ioe) {
      System.err.println(ioe.getMessage());
    }
    document.close();
  }
}
           
       

Thank with us