2

我使用 iText 在我的 Android 应用程序中生成 PDF。我需要在 pdf 中添加一个 LIST。这个列表需要来自我已经在适配器中拥有的数据。我的适配器已经填充了正确的数据,所以我只需要知道如何将适配器中的数据以 LIST 形式添加到我的 PDF 文件中。PS:填写应用程序另一部分的动态数据。所以这个数据只需要在 PDF 中显示。

4

1 回答 1

2

这是在 PDF 表中添加数据的方法..

private static void descriptionTable(Document p,ArrayList<String> list) throws BadElementException 
      {
            PdfPTable table = new PdfPTable(3);

            table.setWidthPercentage(100);

            PdfPCell c1 = new PdfPCell(new Phrase("Site Address",ele_noraml_black));
            c1.setHorizontalAlignment(Element.ALIGN_LEFT);
            c1.setColspan(1);
            c1.setBorderWidth(1);
            c1.setPaddingBottom(10);
            c1.setBorderColor(celalBorderColor);
            table.addCell(c1);



            c1 = new PdfPCell(new Phrase(list_tree_tree.get(0),ele_noraml_black));
            c1.setHorizontalAlignment(Element.ALIGN_LEFT);
            c1.setBorderWidth(1);
            c1.setColspan(2);
            c1.setPaddingBottom(10);
            c1.setBorderColor(celalBorderColor);
            table.addCell(c1);
 try {
                p.add(table);
            } catch (DocumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
}
于 2012-11-29T11:51:52.437 回答