import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
Font font = new Font(Font.HELVETICA, 12);
BaseFont bf = font.getCalculatedBaseFont(false);
String numbers = "0123456789";
String letters = "abcdefghijklmnopqrstuvwxyz";
document.add(new Paragraph(numbers, font));
System.out.println("width: " + bf.getWidth(numbers) + " (" + bf.getWidthPoint(numbers, 12)
+ "pt)");
System.out.println("ascent: " + bf.getAscent(numbers) + "; descent: " + bf.getDescent(numbers)
+ "; height: " + (bf.getAscentPoint(numbers, 12) - bf.getDescentPoint(numbers, 12) + "pt"));
document.add(new Paragraph(letters, font));
System.out.println("width: " + bf.getWidth(letters) + " (" + bf.getWidthPoint(letters, 12)
+ "pt)");
System.out.println("ascent: " + bf.getAscent(letters) + "; descent: " + bf.getDescent(letters)
+ "; height: " + (bf.getAscentPoint(letters, 12) - bf.getDescentPoint(letters, 12)) + "pt");
document.close();
}
}