Mega Code Archive

 
Categories / Java Tutorial / PDF
 

Set table cell no wrap

import java.io.FileOutputStream; import com.lowagie.text.Document; 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);     document.add(table);     document.close();   } }