List of usage examples for com.itextpdf.text.pdf PdfPCell setColspan
public void setColspan(int colspan)
From source file:nwk.com.br.documents.OrcamentoPdf.java
private PdfPTable dadosPagamento(Orcamento orcamento) throws Exception { Font fontTotal = new Font(Font.FontFamily.TIMES_ROMAN, 16); PdfPTable dPagamento = new PdfPTable(new float[] { 0.5f, 0.2f, 0.3f }); dPagamento.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento dPagamento.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); dPagamento.getDefaultCell().setBorder(0); //celula com espao em branco e com o Total PdfPCell spc = new PdfPCell(new Paragraph(" ")); PdfPCell total = new PdfPCell(new Paragraph("TOTAL: R$" + orcamento.getTotal(), fontTotal)); //alinha a celula total a esquerda total.setHorizontalAlignment(Element.ALIGN_RIGHT); spc.setColspan(3); total.setBorder(0);/*from w w w . ja va2s . c om*/ spc.setBorder(0); if (orcamento.getFormaPagamento().equals("0")) { dPagamento.addCell(new Paragraph("Forma de Pagamento: A vista - Dinheiro", f)); } else if (orcamento.getFormaPagamento().equals("1")) { dPagamento.addCell(new Paragraph("Forma de Pagamento: A vista - Carto", f)); } else if (orcamento.getFormaPagamento().equals("2")) { dPagamento.addCell(new Paragraph("Forma de Pagamento: Parcelado", f)); } dPagamento.addCell(new Paragraph("Desconto: R$" + orcamento.getDesconto(), f)); dPagamento.addCell(total); return dPagamento; }
From source file:nwk.com.br.documents.OrcamentoPdf.java
private PdfPTable dadosRodape(Orcamento orcamento) throws Exception { //tabela que pega com 100% do tamanho do arquivo, alinhada no centro com tres colunas e sem bordas PdfPTable rodape = new PdfPTable(new float[] { 0.5f, 0.2f, 0.3f }); rodape.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento rodape.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); rodape.getDefaultCell().setBorder(0); PdfPCell obs = new PdfPCell(new Paragraph("\n\n Observaes:\n" + orcamento.getObservacoes(), f)); PdfPCell ass = new PdfPCell(new Paragraph("\n\n_________________________\nAssinatura", f)); Font fonteAviso = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLDITALIC); PdfPCell spc = new PdfPCell(new Paragraph(" ")); PdfPCell aviso = new PdfPCell(new Paragraph( "AGRADEEMOS A PREFERNCIA\nORAMENTO VALIDO SOMENTE PARA O DIA DE SUA CRIAO!", fonteAviso)); aviso.setHorizontalAlignment(Element.ALIGN_CENTER); obs.setHorizontalAlignment(Element.ALIGN_LEFT); ass.setHorizontalAlignment(Element.ALIGN_CENTER); obs.setBorder(0);/*from ww w .j ava2 s . c o m*/ ass.setBorder(0); spc.setBorder(0); aviso.setBorder(0); spc.setColspan(3); aviso.setColspan(3); rodape.addCell(obs); rodape.addCell(new Paragraph(" ")); rodape.addCell(ass); rodape.addCell(spc); rodape.addCell(spc); rodape.addCell(spc); rodape.addCell(spc); rodape.addCell(aviso); //rodape.setExtendLastRow(true); //cria uma nova celula que recebe a tabela anterior PdfPCell otherCell = new PdfPCell(rodape); otherCell.setBorder(0); otherCell.setVerticalAlignment(Element.ALIGN_BOTTOM); otherCell.setHorizontalAlignment(Element.ALIGN_CENTER); //cria uma nova tabela que recebe a celula otherCell PdfPTable rodape2 = new PdfPTable(new float[] { 1.0f }); rodape2.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento rodape2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); rodape2.getDefaultCell().setBorder(0); //estende a tabela at o fim da pagina, como o alinhamento horizontal dela bottom, ela fica toda no rodape rodape2.addCell(otherCell); rodape2.setExtendLastRow(true); return rodape2; }
From source file:om.edu.squ.squportal.portlet.tsurvey.dao.pdf.TeachingSurveyPdfImpl.java
License:Open Source License
/** * /*from w w w .ja v a2 s . c o m*/ * method name : getPdfCell * @param content * @param rowSpan * @param colSpan * @return * TeachingSurveyPdfImpl * return type : PdfPCell * * purpose : * * Date : Feb 22, 2016 12:52:28 PM */ private PdfPCell getPdfCell(String content, int rowSpan, int colSpan, Font font, String txtAlign) { PdfPCell cell = new PdfPCell(new Phrase(content, font)); if (rowSpan == 0 && colSpan != 0) { cell.setColspan(colSpan); } if (rowSpan != 0 && colSpan == 0) { cell.setRowspan(rowSpan); } if (txtAlign.equals(Constants.CENTER)) cell.setHorizontalAlignment(Element.ALIGN_CENTER); if (null == txtAlign || txtAlign.equals(Constants.LEFT)) cell.setHorizontalAlignment(Element.ALIGN_LEFT); if (txtAlign.equals(Constants.RIGHT)) cell.setHorizontalAlignment(Element.ALIGN_RIGHT); return cell; }
From source file:org.agmip.ui.afsirs.util.AFSIRSUtils.java
private void designTableTitleCell(PdfPTable table, String str) { PdfPCell cell; // we add a c with colspan 3 cell = new PdfPCell(new Phrase(str, BLUE_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(14); table.addCell(cell);/* w w w.j a v a 2 s .co m*/ }
From source file:org.apache.jmeter.visualizers.CreateReport.java
License:Apache License
/** * Creates a table; widths are set with setWidths(). * @return a PdfPTable/*from www .ja v a 2 s .c o m*/ * @throws DocumentException */ public PdfPTable createTable1() throws DocumentException { PdfPTable table = new PdfPTable(7); table.setWidthPercentage(570 / 5.23f); table.setWidths(new int[] { 4, 4, 3, 3, 3, 3, 5 }); PdfPCell cell = null; for (int k = 0; k < 10; k++) { if (k != 5 && k != 8 && k != 9) { cell = new PdfPCell(new Phrase(JMeterUtils.getResString(COLUMNS[k]), headerFont)); BaseColor BC = new BaseColor(164, 188, 196); cell.setBackgroundColor(BC); cell.setColspan(1); table.addCell(cell); } } for (int l = 0; l < model.getRowCount(); l++) //row count does not include table headers for (int k = 0; k < 10; k++) { if (k != 5 && k != 8 && k != 9) { cell = new PdfPCell(new Phrase(model.getValueAt(l, k).toString(), rowFont)); cell.setGrayFill(2); table.addCell(cell); } } return table; /* original basic statements PdfPTable table = new PdfPTable(3); table.setWidthPercentage(288 / 5.23f); table.setWidths(new int[]{2, 1, 1}); PdfPCell cell; cell = new PdfPCell(new Phrase("Table 1")); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase("Cell with rowspan 2")); cell.setRowspan(2); table.addCell(cell); table.addCell("row 1; cell 1"); table.addCell("row 1; cell 2"); table.addCell("row 2; cell 1"); table.addCell("row 2; cell 2"); return table; */ }
From source file:org.apache.jmeter.visualizers.CreateReport.java
License:Apache License
public PdfPTable createTable2() throws DocumentException { PdfPTable table = new PdfPTable(4); table.setWidthPercentage(570 / 5.23f); table.setWidths(new int[] { 1, 2, 1, 3 }); PdfPCell cell = null; for (int k = 0; k < 4; k++) { {/* w ww. j av a2 s . c o m*/ cell = new PdfPCell(new Phrase(model2.getColumnName(k), headerFont)); BaseColor BC = new BaseColor(164, 188, 196); cell.setBackgroundColor(BC); cell.setColspan(1); table.addCell(cell); } } for (int l = 0; l < model2.getRowCount(); l++) //row count does not include table headers for (int k = 0; k < 4; k++) { cell = new PdfPCell(new Phrase(model2.getValueAt(l, k).toString(), rowFont)); cell.setGrayFill(2); table.addCell(cell); } return table; }
From source file:org.cejug.yougi.web.report.EventAttendeeReport.java
License:Open Source License
public void printReport(List<Attendee> attendees) throws DocumentException { float[] columnSizes = { 20, 220, 220, 60 }; PdfPTable table = new PdfPTable(columnSizes.length); table.setLockedWidth(true);//from w w w .j a v a 2 s. co m table.setTotalWidth(columnSizes); PdfPCell headerCell = new PdfPCell(new Phrase("Yougi")); headerCell.setColspan(4); headerCell.setBackgroundColor(BaseColor.ORANGE); headerCell.setPadding(3); table.addCell(headerCell); table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); PdfPCell checkCell = new PdfPCell(new Phrase(" ")); checkCell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(checkCell); PdfPCell productCell = new PdfPCell(new Phrase("Nome")); productCell.setBackgroundColor(BaseColor.LIGHT_GRAY); productCell.setVerticalAlignment(Element.ALIGN_BOTTOM); table.addCell(productCell); PdfPCell currentPurchaseCell = new PdfPCell(new Phrase("Email")); currentPurchaseCell.setPadding(3); currentPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER); currentPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(currentPurchaseCell); PdfPCell previousPurchaseCell = new PdfPCell(new Phrase("Presente")); previousPurchaseCell.setPadding(3); previousPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER); previousPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(previousPurchaseCell); table.getDefaultCell().setBackgroundColor(null); table.setHeaderRows(2); Font font = new Font(Font.FontFamily.HELVETICA, 9); int seq = 1; for (Attendee attendee : attendees) { table.addCell(new Phrase(String.valueOf(seq++), font)); table.addCell(new Phrase(attendee.getUserAccount().getFullName(), font)); table.addCell(new Phrase(attendee.getUserAccount().getEmail(), font)); table.addCell(" "); } document.add(table); }
From source file:org.cherchgk.actions.tournament.result.show.GetPDFTournamentResultAction.java
License:Apache License
public InputStream getDocument() throws DocumentException, IOException { Font normalFont = getNormalFont(); Font boldFont = getBoldFont(); ByteArrayOutputStream out = new ByteArrayOutputStream(); Document document = new Document(); PdfWriter.getInstance(document, out); document.open();// w w w.j av a 2 s.c o m Paragraph tournamentNameParagraph = new Paragraph(tournament.getTitle(), boldFont); tournamentNameParagraph.setAlignment(Element.ALIGN_CENTER); document.add(tournamentNameParagraph); Paragraph tournamentDateParagraph = new Paragraph(tournament.getDateAsString(), boldFont); tournamentDateParagraph.setAlignment(Element.ALIGN_CENTER); document.add(tournamentDateParagraph); if (teamCategory != null) { Paragraph teamCategoryParagraph = new Paragraph(teamCategory.getTitle(), boldFont); teamCategoryParagraph.setAlignment(Element.ALIGN_CENTER); document.add(teamCategoryParagraph); } int numColumns = 3 + tournamentResult.getRankingAlgorithms().size(); PdfPTable resultTable = new PdfPTable(numColumns); int[] widths = new int[numColumns]; widths[0] = 1; widths[1] = 3; for (int i = 2; i < numColumns; i++) { widths[i] = 1; } resultTable.setWidths(widths); resultTable.setSpacingBefore(10f); PdfPCell cell = new PdfPCell(new Phrase("", boldFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setColspan(2); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); resultTable.addCell(cell); for (RankingAlgorithm rankingAlgorithm : tournamentResult.getRankingAlgorithms()) { cell = new PdfPCell(new Phrase(rankingAlgorithm.getPointName(), boldFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); resultTable.addCell(cell); } cell = new PdfPCell(new Phrase("?", boldFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); resultTable.addCell(cell); boolean showTeamCategoryInTable = (teamCategory == null) && !tournament.getTeamCategories().isEmpty(); for (TournamentResult.TeamResult teamResult : tournamentResult.getTeamResultList()) { if (showTeamCategoryInTable) { if (teamResult.getTeam().getTeamCategory() != null) { cell = new PdfPCell(new Phrase(teamResult.getTeam().getTeamCategory().getTitle(), normalFont)); } else { cell = new PdfPCell(new Phrase("", normalFont)); } resultTable.addCell(cell); } cell = new PdfPCell(new Phrase(teamResult.getTeam().getName(), normalFont)); if (!showTeamCategoryInTable) { cell.setColspan(2); } resultTable.addCell(cell); for (Map<Team, RankingPoint> m : tournamentResult.getRankingPointsList()) { cell = new PdfPCell(new Phrase(m.get(teamResult.getTeam()).toString(), normalFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); resultTable.addCell(cell); } cell = new PdfPCell(new Phrase(teamResult.getPlace(), normalFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); resultTable.addCell(cell); } document.add(resultTable); document.close(); return new ByteArrayInputStream(out.toByteArray()); }
From source file:org.cidte.sii.negocio.PDFWriter.java
private void insertCell(PdfPTable table, String text, int align, int colspan, Font font) { // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font)); // set the cell alignment cell.setHorizontalAlignment(align);//w w w .jav a 2s .c o m // some padding cell.setPaddingLeft(10); // set the cell column span in case you want to merge two or more cells cell.setColspan(colspan); // in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } // add the call to the table table.addCell(cell); }
From source file:org.fossa.rolp.util.PdfFormatHelper.java
License:Open Source License
public static PdfPTable buildHeaderNameLine(String schuelername, Font headerFont) throws DocumentException { PdfPCell labelCell = new PdfPCell(new Phrase("Name", headerFont)); labelCell.setBorder(Rectangle.BOTTOM); labelCell.setBorderWidth(1f);//from w w w .j av a2 s . co m PdfPCell nameCell = new PdfPCell(new Phrase(schuelername, headerFont)); nameCell.setBorder(Rectangle.BOTTOM); nameCell.setBorderWidth(1f); nameCell.setColspan(5); PdfPTable table = prebuildHeaderTable(); table.addCell(labelCell); table.addCell(nameCell); return table; }