List of usage examples for com.itextpdf.text.pdf PdfPTable PdfPTable
public PdfPTable(final PdfPTable table)
PdfPTable
. From source file:be.rheynaerde.poolsheets.AbstractPufPoolSheet.java
License:Open Source License
@Override protected void buildTable(Document document) throws DocumentException { //large table to take care of the layout PdfPTable largeTable = new PdfPTable(3); largeTable.setWidths(new int[] { 19, 1, 20 }); final float largeTableHeight = configuration.getSquareCellSize() * (getNumberOfRows() + 1); PdfPCell cell1 = getEmptyCell();/*from w ww . j av a2 s . c om*/ cell1.setFixedHeight(largeTableHeight); cell1.addElement(getNameTable()); largeTable.addCell(cell1); PdfPCell cellSpacer = getEmptyCell(); cellSpacer.setFixedHeight(largeTableHeight); largeTable.addCell(cellSpacer); PdfPCell cell2 = getEmptyCell(); cell2.setFixedHeight(largeTableHeight); cell2.addElement(getScoreTable()); largeTable.addCell(cell2); document.add(largeTable); }
From source file:be.rheynaerde.poolsheets.AbstractPufPoolSheet.java
License:Open Source License
protected PdfPTable getNameTable() { //table with names PdfPTable nameTable = new PdfPTable(1); nameTable.setWidthPercentage(100.0F); nameTable.addCell(getEmptyCell());//from w w w.j av a 2s. c o m nameTable.addCell(getEmptyCell()); for (int i = 1; i <= getNumberOfPlayers(); i++) { nameTable.addCell(getNameCell(getPlayerName(i))); } return nameTable; }
From source file:be.rheynaerde.poolsheets.ClubPoolSheet.java
License:Open Source License
@Override protected void buildTable(Document document) throws DocumentException { int columnCount = configuration.getNrOfPlayers() + configuration.getSummaryColumnCount() + 3; int nameCellWidth = 5; PdfPTable table = new PdfPTable(columnCount); table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.setTotalWidth(/*from www . j av a2s . co m*/ (configuration.getNrOfPlayers() + 1 + nameCellWidth + 0.1f + configuration.getSummaryColumnCount()) * configuration.getSquareCellSize()); table.setLockedWidth(true); float[] widths = new float[columnCount]; widths[0] = 1f * nameCellWidth; for (int i = 1; i < widths.length; i++) { widths[i] = 1f; } widths[widths.length - 1 - configuration.getSummaryColumnCount()] = 0.1f; table.setWidths(widths); PdfPCell cell = new PdfPCell(new Paragraph(configuration.getTitle(), configuration.getTitleFont())); cell.setColspan(columnCount); cell.setPaddingBottom(configuration.getSquareCellSize() / 2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); { table.addCell(getHeaderCell(bundle.getString("name"))); table.addCell(getSolidCell()); for (int i = 0; i < configuration.getNrOfPlayers(); i++) { table.addCell(getHeaderCell(Integer.toString(i + 1))); } table.addCell(new PdfPCell()); //spacer column for (int i = 0; i < configuration.getSummaryColumnCount(); i++) { table.addCell(getHeaderCell(configuration.getSummaryColumnName(i))); } } for (int i = 0; i < configuration.getNrOfPlayers(); i++) { table.addCell(configuration.getNamePlayer(i + 1) == null ? "" : configuration.getNamePlayer(i + 1)); table.addCell(getHeaderCell(Integer.toString(i + 1))); for (int j = 0; j < i; j++) { String result = configuration.getResult(i + 1, j + 1); PdfPCell resultCell = new PdfPCell(new Phrase(result == null ? "" : result)); resultCell.setHorizontalAlignment(Element.ALIGN_CENTER); resultCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(resultCell); } table.addCell(getSolidCell()); for (int j = i + 1; j < configuration.getNrOfPlayers(); j++) { String result = configuration.getResult(i + 1, j + 1); PdfPCell resultCell = new PdfPCell(new Phrase(result == null ? "" : result)); resultCell.setHorizontalAlignment(Element.ALIGN_CENTER); resultCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(resultCell); } table.addCell(new PdfPCell()); //spacer column for (int j = 0; j < configuration.getSummaryColumnCount(); j++) { String result = configuration.getSummaryColumnValue(i + 1, j); PdfPCell summaryCell = new PdfPCell(new Phrase(result == null ? "" : result)); summaryCell.setHorizontalAlignment(Element.ALIGN_CENTER); summaryCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(summaryCell); } } document.add(table); }
From source file:be.rheynaerde.poolsheets.PufCompletePoolSheet.java
License:Open Source License
@Override protected PdfPTable getScoreTable() throws DocumentException { final int columnCount = configuration.getNrOfPlayers(1) + configuration.getNrOfPlayers(2) + 2; //one column for each player, an extra column for the numbers and a column for the team marks PdfPTable table = new PdfPTable(columnCount); table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.setTotalWidth((columnCount) * configuration.getSquareCellSize()); table.setLockedWidth(true);/*from www . j a v a2s .c o m*/ float[] widths = new float[columnCount]; for (int i = 0; i < widths.length; i++) { widths[i] = 1f; } table.setWidths(widths); PdfPCell topCell = getCellWithBorder(table.getDefaultCell(), Rectangle.RIGHT, 1, 2); topCell.setFixedHeight(configuration.getSquareCellSize()); table.addCell(topCell); table.addCell( getCellWithBorder(table.getDefaultCell(), Rectangle.RIGHT, 1, configuration.getNrOfPlayers(1))); table.addCell( getCellWithBorder(table.getDefaultCell(), Rectangle.RIGHT, 1, configuration.getNrOfPlayers(2))); table.addCell(getCellWithBorder(table.getDefaultCell(), Rectangle.BOTTOM, 1, 1)); { table.addCell(getSolidCell()); for (int i = 0; i < configuration.getNrOfPlayers(1) + configuration.getNrOfPlayers(2); i++) { table.addCell(getHeaderCell(Integer.toString(i + 1))); } } table.addCell( getCellWithBorder(table.getDefaultCell(), Rectangle.BOTTOM, configuration.getNrOfPlayers(1), 1)); for (int i = 0; i < configuration.getNrOfPlayers(1) + configuration.getNrOfPlayers(2); i++) { if (i == configuration.getNrOfPlayers(1)) table.addCell(getCellWithBorder(table.getDefaultCell(), Rectangle.BOTTOM, configuration.getNrOfPlayers(2), 1)); table.addCell(getHeaderCell(Integer.toString(i + 1))); for (int j = 0; j < configuration.getNrOfPlayers(1) + configuration.getNrOfPlayers(2); j++) { if (i == j) { PdfPCell blackCell = getSolidCell(); table.addCell(blackCell); } else { table.addCell(configuration.getResult(i, j)); } } } table.setHorizontalAlignment(Element.ALIGN_RIGHT); return table; }
From source file:be.rheynaerde.poolsheets.PufSingleTeamPoolSheet.java
License:Open Source License
@Override protected PdfPTable getScoreTable() throws DocumentException { final int columnCount = configuration.getNrOfPlayers() + 2; PdfPTable table = new PdfPTable(columnCount); table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.setTotalWidth((columnCount) * configuration.getSquareCellSize()); table.setLockedWidth(true);/*from ww w . j av a 2 s . co m*/ float[] widths = new float[columnCount]; for (int i = 0; i < widths.length; i++) { widths[i] = 1f; } table.setWidths(widths); PdfPCell topCell = getCellWithBorder(table.getDefaultCell(), Rectangle.RIGHT, 1, 2); topCell.setFixedHeight(configuration.getSquareCellSize()); table.addCell(topCell); table.addCell( getCellWithBorder(table.getDefaultCell(), Rectangle.RIGHT, 1, configuration.getNrOfPlayers())); table.addCell(getCellWithBorder(table.getDefaultCell(), Rectangle.BOTTOM, 1, 1)); { table.addCell(getSolidCell()); for (int i = 0; i < configuration.getNrOfPlayers(); i++) { table.addCell(getHeaderCell(Integer.toString(i + 1))); } } table.addCell( getCellWithBorder(table.getDefaultCell(), Rectangle.BOTTOM, configuration.getNrOfPlayers(), 1)); for (int i = 0; i < configuration.getNrOfPlayers(); i++) { table.addCell(getHeaderCell(Integer.toString(i + 1))); for (int j = 0; j < configuration.getNrOfPlayers(); j++) { if (i == j) { PdfPCell blackCell = getSolidCell(); table.addCell(blackCell); } else { table.addCell(configuration.getResult(i, j)); } } } table.setHorizontalAlignment(Element.ALIGN_RIGHT); return table; }
From source file:be.rheynaerde.poolsheets.PufTeamPoolSheet.java
License:Open Source License
protected PdfPTable getScoreTable() throws DocumentException { //table for scores final int columnCount = configuration.getNrOfPlayers(1) + configuration.getNrOfPlayers(2) + 2; //one column for each player, an extra column for the numbers and a column for the team marks PdfPTable table = new PdfPTable(columnCount); table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT); table.setTotalWidth((columnCount) * configuration.getSquareCellSize()); table.setLockedWidth(true);//from w w w. ja v a 2 s .co m float[] widths = new float[columnCount]; for (int i = 0; i < widths.length; i++) { widths[i] = 1f; } table.setWidths(widths); PdfPCell topCell = getCellWithBorder(table.getDefaultCell(), Rectangle.RIGHT, 1, 2); topCell.setFixedHeight(configuration.getSquareCellSize()); table.addCell(topCell); table.addCell( getCellWithBorder(table.getDefaultCell(), Rectangle.RIGHT, 1, configuration.getNrOfPlayers(1))); table.addCell( getCellWithBorder(table.getDefaultCell(), Rectangle.RIGHT, 1, configuration.getNrOfPlayers(2))); table.addCell(getCellWithBorder(table.getDefaultCell(), Rectangle.BOTTOM, 1, 1)); { table.addCell(getSolidCell()); for (int i = 0; i < configuration.getNrOfPlayers(1) + configuration.getNrOfPlayers(2); i++) { table.addCell(getHeaderCell(Integer.toString(i + 1))); } } table.addCell( getCellWithBorder(table.getDefaultCell(), Rectangle.BOTTOM, configuration.getNrOfPlayers(1), 1)); for (int i = 0; i < configuration.getNrOfPlayers(1); i++) { table.addCell(getHeaderCell(Integer.toString(i + 1))); if (i == 0) { PdfPCell blackCell = getSolidCell(); blackCell.setColspan(configuration.getNrOfPlayers(1)); blackCell.setRowspan(configuration.getNrOfPlayers(1)); table.addCell(blackCell); } for (int j = 0; j < configuration.getNrOfPlayers(2); j++) { table.addCell(configuration.getResult(0, i, 1, j)); } } table.addCell( getCellWithBorder(table.getDefaultCell(), Rectangle.BOTTOM, configuration.getNrOfPlayers(2), 1)); for (int i = 0; i < configuration.getNrOfPlayers(2); i++) { table.addCell(getHeaderCell(Integer.toString(configuration.getNrOfPlayers(1) + i + 1))); for (int j = 0; j < configuration.getNrOfPlayers(1); j++) { table.addCell(configuration.getResult(1, i, 0, j)); } if (i == 0) { PdfPCell blackCell = getSolidCell(); blackCell.setColspan(configuration.getNrOfPlayers(2)); blackCell.setRowspan(configuration.getNrOfPlayers(2)); table.addCell(blackCell); } } table.setHorizontalAlignment(Element.ALIGN_RIGHT); return table; }
From source file:be.rheynaerde.poolsheets.StandardPoolSheet.java
License:Open Source License
protected void buildTable(Document document) throws DocumentException { int columnCount = 1 + 1 + configuration.getNrOfPlayers() + 1 + configuration.getSummaryColumnCount(); // name + number + scores + spacer // + summary PdfPTable table = new PdfPTable(columnCount); table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.setTotalWidth((configuration.getNrOfPlayers() + 7 //the name column + extra space between grid and summary //currently the name column just gets a width that is //a multiple of the width of the other cells. Better //would be to let this cell take up the remaining space. + configuration.getSummaryColumnCount()) * configuration.getSquareCellSize()); table.setLockedWidth(true);/*from w w w . j ava2s . co m*/ float[] widths = new float[columnCount]; widths[0] = 5f; for (int i = 1; i < widths.length; i++) { widths[i] = 1f; } widths[widths.length - 1 - configuration.getSummaryColumnCount()] = 0.1f; table.setWidths(widths); { table.addCell(getHeaderCell(bundle.getString("name"))); table.addCell(getSolidCell()); for (int i = 0; i < configuration.getNrOfPlayers(); i++) { table.addCell(getHeaderCell(Integer.toString(i + 1))); } table.addCell(new PdfPCell()); //spacer column for (int i = 0; i < configuration.getSummaryColumnCount(); i++) { table.addCell(getHeaderCell(configuration.getSummaryColumnName(i))); } } for (int i = 0; i < configuration.getNrOfPlayers(); i++) { table.addCell(configuration.getNamePlayer(i + 1) == null ? "" : configuration.getNamePlayer(i + 1)); table.addCell(getHeaderCell(Integer.toString(i + 1))); for (int j = 0; j < i; j++) { String result = configuration.getResult(i + 1, j + 1); PdfPCell cell = new PdfPCell(new Phrase(result == null ? "" : result)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } table.addCell(getSolidCell()); for (int j = i + 1; j < configuration.getNrOfPlayers(); j++) { String result = configuration.getResult(i + 1, j + 1); PdfPCell cell = new PdfPCell(new Phrase(result == null ? "" : result)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } table.addCell(new PdfPCell()); //spacer column for (int j = 0; j < configuration.getSummaryColumnCount(); j++) { String result = configuration.getSummaryColumnValue(i + 1, j); PdfPCell cell = new PdfPCell(new Phrase(result == null ? "" : result)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } } document.add(table); }
From source file:be.roots.taconic.pricingguide.service.PDFServiceImpl.java
License:Open Source License
private PdfPTable createModelPage(Contact contact, Model model, PdfWriter pdfWriter) throws IOException, DocumentException { final PdfPTable pdfPTable = new PdfPTable(new float[] { 40f, 1f, 59f }); pdfPTable.setTotalWidth(iTextUtil.PAGE_SIZE.getWidth()); pdfPTable.addCell(cell(buildModelDetailSection(model, pdfWriter))); pdfPTable.addCell(cell(new Paragraph())); pdfPTable.addCell(cell(buildModelPricingTables(contact, model))); return pdfPTable; }
From source file:be.roots.taconic.pricingguide.service.PDFServiceImpl.java
License:Open Source License
private PdfPTable buildModelPricingTables(Contact contact, Model model) { final PdfPTable table = new PdfPTable(1); final List<Pricing> validPricings = model.validPricings(contact); if (CollectionUtils.isEmpty(validPricings)) { final Chunk chunk = new Chunk("Contact us for pricing on this model", iTextUtil.getFontContactUs()); chunk.setAction(new PdfAction(contactUsUrl)); table.addCell(cell(new Phrase(chunk))); } else {/*from w ww . j av a 2 s . c o m*/ for (Pricing pricing : validPricings) { table.addCell(cell(buildModelPricingTable(pricing))); } } return table; }
From source file:be.roots.taconic.pricingguide.service.PDFServiceImpl.java
License:Open Source License
private PdfPTable buildModelPricingTable(Pricing pricing) { final PdfPTable pricingTable = new PdfPTable(pricing.getNumberOfHeaderItems()); pricingTable.addCell(cell(new Paragraph(pricing.getCategory(), iTextUtil.getFontModelCategory()), pricing.getNumberOfHeaderItems())); pricingTable.addCell(cell(new Paragraph(" "), pricing.getNumberOfHeaderItems())); if (pricing.isQuantities()) { pricingTable.addCell(cellH(new Paragraph("Quantity", iTextUtil.getFontModelPricingTitle()))); }/*from ww w.j av a 2 s .c om*/ if (pricing.isAge()) { pricingTable.addCell(cellH(new Paragraph("Age (weeks)", iTextUtil.getFontModelPricingTitle()))); } if (pricing.isMale()) { pricingTable.addCell(cellH(new Paragraph("Male", iTextUtil.getFontModelPricingTitle()))); } if (pricing.isFemale()) { pricingTable.addCell(cellH(new Paragraph("Female", iTextUtil.getFontModelPricingTitle()))); } boolean invert = false; for (Line line : pricing.getLines()) { if (pricing.isQuantities()) { pricingTable.addCell( cellD(new Paragraph(line.getQuantity(), iTextUtil.getFontModelPricingData()), invert)); } if (pricing.isAge()) { pricingTable .addCell(cellD(new Paragraph(line.getAge(), iTextUtil.getFontModelPricingData()), invert)); } if (pricing.isMale()) { pricingTable .addCell(cellD(new Paragraph(line.getMale(), iTextUtil.getFontModelPricingData()), invert)); } if (pricing.isFemale()) { pricingTable.addCell( cellD(new Paragraph(line.getFemale(), iTextUtil.getFontModelPricingData()), invert)); } invert = !invert; } if (!StringUtils.isEmpty(pricing.getMessage())) { pricingTable.addCell(cell(new Paragraph(pricing.getMessage(), iTextUtil.getFontModelPricingMessage()), pricing.getNumberOfHeaderItems())); } pricingTable.addCell(cell(new Paragraph(" "), pricing.getNumberOfHeaderItems())); return pricingTable; }