Java tutorial
import java.io.FileOutputStream; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.Paragraph; 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(); Chunk c = new Chunk("this is a test"); float w = c.getWidthPoint(); Paragraph p = new Paragraph("The width of the chunk: '"); p.add(c); p.add("' is "); p.add(String.valueOf(w)); p.add(" points or "); p.add(String.valueOf(w / 72f)); p.add(" inches or "); p.add(String.valueOf(w / 72f * 2.54f)); p.add(" cm."); document.add(p); document.add(c); c.setHorizontalScaling(0.5f); document.add(c); document.close(); } }