// step 3: we open the document
document.open();
// step 4: we add content to the document
BaseFont bfComic = BaseFont.createFont("c:\\windows\\fonts\\comic.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED);
LwgFont font = new LwgFont(bfComic, 12);
String text1 = "quick brown fox jumps";
String text2 = " over ";
String text3 = "the lazy dog";
document.add(new Paragraph(text1, font));
document.add(new Paragraph("width: " + bfComic.getWidthPoint(text1, 12)));
document.add(new Paragraph("ascent: " + bfComic.getAscentPoint(text1, 12)));
document.add(new Paragraph("descent: " + bfComic.getDescentPoint(text1, 12)));
document.add(new Paragraph("height: " + (bfComic.getAscentPoint(text1, 12) - bfComic.getDescentPoint(text1, 12))));
document.add(new Paragraph(text2, font));
document.add(new Paragraph("width: " + bfComic.getWidthPoint(text2, 12)));
document.add(new Paragraph("ascent: " + bfComic.getAscentPoint(text2, 12)));
document.add(new Paragraph("descent: " + bfComic.getDescentPoint(text2, 12)));
document.add(new Paragraph("height: " + (bfComic.getAscentPoint(text2, 12) - bfComic.getDescentPoint(text2, 12))));
document.add(new Paragraph(text3, font));
document.add(new Paragraph("width: " + bfComic.getWidthPoint(text3, 12)));
document.add(new Paragraph("ascent: " + bfComic.getAscentPoint(text3, 12)));
document.add(new Paragraph("descent: " + bfComic.getDescentPoint(text3, 12)));
document.add(new Paragraph("height: " + (bfComic.getAscentPoint(text3, 12) - bfComic.getDescentPoint(text3, 12))));
document.add(new Paragraph(text1 + text2 + text3, font));
document.add(new Paragraph("width: " + bfComic.getWidthPoint(text1 + text2 + text3, 12)));
document.add(new Paragraph("ascent: " + bfComic.getAscentPoint(text1 + text2 + text3, 12)));
document.add(new Paragraph("descent: " + bfComic.getDescentPoint(text1 + text2 + text3, 12)));
document.add(new Paragraph("height: " + (bfComic.getAscentPoint(text1 + text2 + text3, 12) - bfComic.getDescentPoint(text1 + text2 + text3, 12))));
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {