本文整理匯總了Java中com.itextpdf.text.pdf.PdfPTable.setTableEvent方法的典型用法代碼示例。如果您正苦於以下問題:Java PdfPTable.setTableEvent方法的具體用法?Java PdfPTable.setTableEvent怎麽用?Java PdfPTable.setTableEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.itextpdf.text.pdf.PdfPTable
的用法示例。
在下文中一共展示了PdfPTable.setTableEvent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: process
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
@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);
}
示例2: createPdf
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
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();
}
示例3: process
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public List<Element> process(SourceCode sourceCode) {
String lang = sourceCode.lang();
String content = sourceCode.content();
boolean linenos = sourceCode.showLineNumbers();
Tokens tokens = pygments.tokenize(lang, content);
Paragraph p = new Paragraph();
for (TokenWithValue token : tokens) {
Style style = styleSheet.styleOf(token.token);
BaseColor color = toColor(style.fg());
int s = calculateStyle(style);
Font font = styles.getFont(Styles.CODE_FONT, s, color).get();
Chunk o = new Chunk(token.value, font);
RGB bg = style.bg();
if (bg != null)
o.setBackground(toColor(bg));
p.add(o);
}
PdfPCell cell = new PdfPCell(p);
cell.setPaddingBottom(5.0f);
cell.setBorder(Rectangle.NO_BORDER);
PdfPTable table = new PdfPTable(1);
table.addCell(cell);
table.setSpacingBefore(5.0f);
table.setSpacingAfter(5.0f);
table.setTableEvent(new TableBackground(toColor(styleSheet.backgroundColor())));
return Arrays.<Element>asList(table);
}