import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.ColumnText;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;
public class ColumnAlignmentPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream("ColumnAlignmentPDF.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER);
ct.addText(new Phrase("col \n"));
ct.addText(new Phrase("cool \n"));
ct.addText(new Phrase("coool\n"));
ct.addText(new Phrase("cooool\n"));
ct.go();
} catch (Exception e) {
System.err.println(e.getMessage());
}
document.close();
}
}
itext.zip( 1,748 k)