Sub and Super Script : Super Subscript « PDF RTF « Java






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();
  }
}
           
       








itext.zip( 1,748 k)

Related examples in the same category