java类com.itextpdf.text.pdf.PdfPTableEvent的实例源码

TableNodeProcessor.java 文件源码 项目:gutenberg 阅读 18 收藏 0 点赞 0 评论 0
@Override
public void process(int level, Node node, InvocationContext context) {

    TableNode tableNode = (TableNode) node;
    List<TableColumnNode> tableNodeColumns = tableNode.getColumns();

    PdfPTable table = new PdfPTable(tableNodeColumns.size());
    for (PdfPTableEvent tableEvent : tableEvents) {
        table.setTableEvent(tableEvent);
    }
    context.pushTable(new TableInfos(table, tableNodeColumns));
    context.processChildren(level, node);
    context.popTable();


    KeyValues kvs = context.iTextContext().keyValues();

    Float spacingBefore = kvs.<Float>getNullable(TABLE_SPACING_BEFORE).or(5f);
    Float spacingAfter = kvs.<Float>getNullable(TABLE_SPACING_AFTER).or(5f);
    table.setSpacingBefore(spacingBefore);
    table.setSpacingAfter(spacingAfter);

    applyAttributes(context, table);
    context.append(table);
}
Printer.java 文件源码 项目:EnTax 阅读 28 收藏 0 点赞 0 评论 0
public static void createPdf(String filename, String dbTable) throws SQLException, DocumentException, IOException {
        // step 1
        Document document = new Document(PageSize.A4);
//        System.out.println(Tax.class.getResource("fonts/arial.ttf").getPath());
        BaseFont bf = BaseFont.createFont("etc/Arial.ttf", "Cp1253", BaseFont.EMBEDDED);
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        // step 3
        document.open();
        // step 4
        PdfPTableEvent event = new Printer();
        PdfPTable table = getTable(dbTable, bf);
        table.setTableEvent(event);
        document.add(table);
        document.newPage();
        // step 5
        document.close();
    }
TableNodeProcessor.java 文件源码 项目:gutenberg 阅读 16 收藏 0 点赞 0 评论 0
public TableNodeProcessor(PdfPTableEvent... tableEvents) {
    this.tableEvents = tableEvents;
}


问题


面经


文章

微信
公众号

扫码关注公众号