List of usage examples for com.itextpdf.text.pdf PdfPTable setExtendLastRow
public void setExtendLastRow(final boolean extendLastRows, final boolean extendFinalRow)
From source file:com.masscustsoft.service.ToPdf.java
License:Open Source License
private PdfPTable getTable(Map it) throws Exception { String ss = MapUtil.getStr(it, "widthList", "100"); List<String> st = MapUtil.getSelectList(ss); float[] widths = new float[st.size()]; for (int i = 0; i < st.size(); i++) widths[i] = LightUtil.decodeFloat(st.get(i)); PdfPTable table = new PdfPTable(widths); table.setExtendLastRow(false, false); MapUtil.setIfFloat(it, "spacingAfter", table); MapUtil.setIfFloat(it, "spacingBefore", table); MapUtil.setIfInt(it, "headerRows", table); MapUtil.setIfInt(it, "footerRows", table); MapUtil.setIfBool(it, "skipFirstHeader", table); MapUtil.setIfBool(it, "skipLastFooter", table); MapUtil.setIfFloat(it, "widthPercentage", table); MapUtil.setIfBool(it, "splitRows", table); MapUtil.setIfBool(it, "splitLate", table); MapUtil.setIfBool(it, "extendLastRow", table); MapUtil.setIfBool(it, "keepTogether", table); List<Map> items = (List) it.get("items"); if (items != null) { for (Map cell : items) { Element el = getElement(cell); PdfPCell pc = new PdfPCell(); if (el != null) if (el instanceof Phrase) pc = new PdfPCell((Phrase) el); else if (el instanceof Image) pc = new PdfPCell((Image) el); else { pc.addElement(el);/*from w w w . java 2 s . co m*/ } pc.setHorizontalAlignment(getAlignment(cell, "align")); pc.setVerticalAlignment(getVAlign(cell, "valign")); pc.setUseBorderPadding(true); MapUtil.setIfInt(cell, "rowspan", pc); MapUtil.setIfInt(cell, "colspan", pc); MapUtil.setIfInt(cell, "border", pc); MapUtil.setIfInt(cell, "rotation", pc); MapUtil.setIfFloat(cell, "borderWidth", pc); BaseColor color = getColor(cell, "bgColor"); if (color != null) pc.setBackgroundColor(color); table.addCell(pc); } } return table; }