Mega Code Archive

 
Categories / Java Tutorial / PDF
 

Set table cell minimun height

import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfWriter; public class MainClass {   public static void main(String[] args) throws Exception {     Document document = new Document(PageSize.A5.rotate());       PdfWriter.getInstance(           document,           new FileOutputStream("2.pdf"));       document.open();       PdfPTable table = new PdfPTable(2);       table.setExtendLastRow(true);       PdfPCell cell;       cell = new PdfPCell(new Paragraph("blah"));       table.addCell("wrap");       cell.setNoWrap(false);       table.addCell(cell);       table.addCell("no wrap");       cell.setNoWrap(true);       table.addCell(cell);       table.addCell("fixed height (not sufficient)");       cell.setMinimumHeight(36f);       table.addCell(cell);       document.add(table);     document.close();   } }