如何使用itext5为以下内容生成pdf。
我能够使用itext获得简单的表格。但是对于上面的图像如何实现呢?
下面是我的代码。它没有在表格中显示图像。
Paragraph paragraph = new Paragraph();
PdfPCell cell = null;
// Main table
PdfPTable mainTable = new PdfPTable(2);
//mainTable.setWidthPercentage(100.0f);
// First table
PdfPCell firstTableCell = new PdfPCell();
firstTableCell.setBorder(PdfPCell.NO_BORDER);
PdfPTable firstTable = new PdfPTable(1);
mainTable.setHorizontalAlignment(Element.ALIGN_LEFT);
Image img = Image.getInstance(appIconNameWithPath);
//img.setWidthPercentage(10);
cell = new PdfPCell(img, true);
cell.setBorder(PdfPCell.NO_BORDER);
firstTable.addCell(cell);
mainTable.addCell(firstTableCell);
// Second table
PdfPCell secondTableCell = new PdfPCell();
secondTableCell.setBorder(PdfPCell.NO_BORDER);
PdfPTable secondTable = new PdfPTable(2);
secondTable.setHorizontalAlignment(Element.ALIGN_RIGHT);
secondTableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
cell = new PdfPCell(new Phrase(appName));
cell.setBorder(PdfPCell.NO_BORDER);
secondTable.addCell(cell);
cell = new PdfPCell(new Phrase(packageName));
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
cell.setBorder(PdfPCell.NO_BORDER);
secondTable.addCell(cell);