import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.PageSize;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class TableCellWithFontPDF {
public static void main(String[] args) {
Document document = new Document(PageSize.A4);
try {
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TableCellWithFontPDF.pdf"));
document.open();
PdfPTable table = new PdfPTable(1);
PdfPCell cell = new PdfPCell(new Phrase("phrase without font"));
table.addCell(cell);
table.addCell(new Phrase("A", FontFactory.getFont(FontFactory.HELVETICA, 8)));
table.addCell("no font");
document.add(table);
} catch (Exception e) {
System.err.println(e.getMessage());
}
document.close();
}
}
|