List of usage examples for com.itextpdf.text.pdf PdfPTable setWidthPercentage
public void setWidthPercentage(final float widthPercentage)
From source file:org.fossa.rolp.util.PdfFormatHelper.java
License:Open Source License
public static PdfPTable buildFooterUnterschriftenLine(Font footerFont) throws DocumentException { PdfPCell leftCell = new PdfPCell(new Phrase("Schulleiter(in)", footerFont)); leftCell.setBorder(Rectangle.TOP); leftCell.setBorderWidth(1f);//from w ww . jav a2 s.co m leftCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont)); centerCell.setBorder(Rectangle.TOP); centerCell.setBorderWidth(1f); centerCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell rightCell = new PdfPCell(new Phrase("Klassenleiter(in)", footerFont)); rightCell.setBorder(Rectangle.TOP); rightCell.setBorderWidth(1f); rightCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100f); table.addCell(leftCell); table.addCell(centerCell); table.addCell(rightCell); table.setWidths(new float[] { 0.3f, 0.3f, 0.3f }); return table; }
From source file:org.fossa.rolp.util.PdfFormatHelper.java
License:Open Source License
public static PdfPTable buildFooterKenntnisLine(Font footerFont) { PdfPCell cell = new PdfPCell(new Phrase("Kenntnis genommen: Erziehungsberechtigte", footerFont)); cell.setBorder(Rectangle.TOP); cell.setBorderWidth(1f);//from w w w .j a va 2 s.c o m cell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setWidthPercentage(100f); table.addCell(cell); return table; }
From source file:org.fossa.rolp.util.PdfFormatHelper.java
License:Open Source License
public static PdfPTable buildFooterHalbjahrDatumLine(String datumString, Font footerFont) throws DocumentException { PdfPCell leftCell = new PdfPCell(new Phrase(datumString, footerFont)); leftCell.setBorder(Rectangle.NO_BORDER); leftCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont)); centerCell.setBorder(Rectangle.NO_BORDER); centerCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont)); rightCell.setBorder(Rectangle.NO_BORDER); rightCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100f); table.addCell(leftCell);/*from w w w.j av a 2 s. c o m*/ table.addCell(centerCell); table.addCell(rightCell); table.setWidths(new float[] { 0.3f, 0.3f, 0.3f }); return table; }
From source file:org.fossa.rolp.util.PdfFormatHelper.java
License:Open Source License
public static PdfPTable buildFooterHalbjahrDatumKlassenleiterLine(Font footerFont) throws DocumentException { PdfPCell leftCell = new PdfPCell(new Phrase("Datum", footerFont)); leftCell.setBorder(Rectangle.TOP); leftCell.setBorderWidth(1f);//from w ww.j a va2 s . c o m leftCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont)); centerCell.setBorder(Rectangle.TOP); centerCell.setBorderWidth(1f); centerCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell rightCell = new PdfPCell(new Phrase("Klassenleiter(in)", footerFont)); rightCell.setBorder(Rectangle.TOP); rightCell.setBorderWidth(1f); rightCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100f); table.addCell(leftCell); table.addCell(centerCell); table.addCell(rightCell); table.setWidths(new float[] { 0.3f, 0.3f, 0.3f }); return table; }
From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java
License:GNU General Public License
private PdfPTable createTableHeader(ColumnList tableHeader, ArrayList<Column> orderedColumns) { for (int i = 0; i < tableHeader.getSize(); i++) { Column c = tableHeader.getField(i); if (c.isVisible()) { orderedColumns.add(c);/*from www. j a v a2 s. c om*/ } } Collections.sort(orderedColumns, new Comparator<Column>() { @Override public int compare(Column lhs, Column rhs) { if (lhs == null || rhs == null) { return 0; } return lhs.getOrder() - rhs.getOrder(); } }); float[] widths = new float[orderedColumns.size()]; for (int i = 0; i < orderedColumns.size(); i++) { Column column = orderedColumns.get(i); widths[i] = column.getWidth(); } PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(95); for (Column field : orderedColumns) { if (field.isVisible()) { PdfPCell cell = new PdfPCell(new Paragraph(field.getName(), getSansRegularBold(12f))); cell.setPaddingTop(4); cell.setPaddingBottom(4); cell.setPaddingLeft(5); cell.setPaddingRight(5); cell.setBorderWidth(0); cell.setBorder(PdfPCell.BOTTOM); cell.setBorderWidthBottom(1); cell.setBorderColor(SORTAVALA_GREEN); table.addCell(cell); } } table.setHeaderRows(1); return table; }
From source file:org.inspira.condominio.pdf.DocumentoEgresos.java
public void exportarPdf(String destino) throws IOException, DocumentException { File file = new File(destino); file.getParentFile().mkdirs();/*from ww w . j av a 2s. c o m*/ PdfWriter.getInstance(documento, new FileOutputStream(file)); documento.open(); documento.add(new Paragraph( "Periodo: ".concat( DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()).format(new Date())), F_NORMAL)); documento.add(new Paragraph(admin, F_NORMAL)); Paragraph heading = new Paragraph("Gastos ".concat(tipoDeGasto), new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD, new BaseColor(0x000000))); heading.setSpacingBefore(16f); heading.setSpacingAfter(16f); Paragraph heading2 = new Paragraph("Autoriz", new Font(Font.FontFamily.HELVETICA, 12, Font.NORMAL, new BaseColor(0x000000))); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); Paragraph heading3 = new Paragraph("Vo. Bo.", new Font(Font.FontFamily.HELVETICA, 12, Font.NORMAL, new BaseColor(0x000000))); PdfPCell cell1 = new PdfPCell(heading2); cell1.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell1.setColspan(1); cell1.setFixedHeight(20f); cell1.setBorder(Rectangle.NO_BORDER); PdfPCell cell2 = new PdfPCell(heading3); cell2.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell2.setColspan(1); cell2.setFixedHeight(20f); cell2.setBorder(Rectangle.NO_BORDER); table.addCell(cell1); table.addCell(cell2); table.setSpacingBefore(16f); table.setSpacingAfter(32f); documento.add(heading); agregarTablaEgresos(egresos); documento.add(table); agregarZonaVistoBueno(); documento.close(); }
From source file:org.inspira.condominio.pdf.DocumentoEgresos.java
private void agregarZonaVistoBueno() throws DocumentException { PdfPCell cell1 = new PdfPCell(new Phrase("", F_NORMAL)); cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell1.setColspan(5);/*from ww w . j a v a 2 s . com*/ cell1.setFixedHeight(20f); cell1.setBorder(Rectangle.BOTTOM); PdfPCell cell2 = new PdfPCell(new Phrase("", F_NORMAL)); cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell2.setColspan(1); cell2.setFixedHeight(20f); cell2.setBorder(Rectangle.NO_BORDER); PdfPCell cell3 = new PdfPCell(new Phrase("", F_NORMAL)); cell3.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell3.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell3.setColspan(5); cell3.setFixedHeight(20f); cell3.setBorder(Rectangle.BOTTOM); PdfPCell cell4 = new PdfPCell(new Phrase(presidente, F_NORMAL)); cell4.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell4.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell4.setColspan(5); cell4.setFixedHeight(20f); cell4.setBorder(Rectangle.NO_BORDER); PdfPCell cell5 = new PdfPCell(new Phrase("", F_NORMAL)); cell5.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell5.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell5.setColspan(1); cell5.setFixedHeight(20f); cell5.setBorder(Rectangle.NO_BORDER); PdfPCell cell6 = new PdfPCell(new Phrase("", F_NORMAL)); cell6.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell6.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell6.setColspan(5); cell6.setFixedHeight(20f); cell6.setBorder(Rectangle.NO_BORDER); PdfPCell cell7 = new PdfPCell(new Phrase(("(Administrador)"), F_NORMAL)); cell7.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell7.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell7.setColspan(5); cell7.setFixedHeight(20f); cell7.setBorder(Rectangle.NO_BORDER); PdfPCell cell8 = new PdfPCell(new Phrase("", F_NORMAL)); cell8.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell8.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell8.setColspan(1); cell8.setFixedHeight(20f); cell8.setBorder(Rectangle.NO_BORDER); PdfPCell cell9 = new PdfPCell(new Phrase(("(Presidente comit de vigilancia)"), F_NORMAL)); cell9.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell9.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell9.setColspan(5); cell9.setFixedHeight(20f); cell9.setBorder(Rectangle.NO_BORDER); PdfPTable table = new PdfPTable(11); table.setWidthPercentage(100); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); table.addCell(cell5); table.addCell(cell6); table.addCell(cell7); table.addCell(cell8); table.addCell(cell9); documento.add(table); }
From source file:org.inspira.condominio.pdf.DocumentoEgresos.java
private void agregarTablaEgresos(InformacionEgreso[] egresos) throws DocumentException { PdfPCell cell1 = new PdfPCell(new Phrase("Fecha", F_CELL_HEADER_TEXT)); cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell1.setColspan(2);//from www.j a v a 2 s.co m cell1.setFixedHeight(20f); cell1.setBackgroundColor(new BaseColor(0xff009846)); PdfPCell cell2 = new PdfPCell(new Phrase("Descripcin", F_CELL_HEADER_TEXT)); cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell2.setColspan(6); cell2.setBackgroundColor(new BaseColor(0xff009846)); cell2.setFixedHeight(20f); PdfPCell cell3 = new PdfPCell(new Phrase("Monto", F_CELL_HEADER_TEXT)); cell3.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell3.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell3.setColspan(2); cell3.setBackgroundColor(new BaseColor(0xff009846)); cell3.setFixedHeight(20f); PdfPCell cell4 = new PdfPCell(new Phrase("Pagado con", F_CELL_HEADER_TEXT)); cell4.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell4.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell4.setColspan(2); cell4.setBackgroundColor(new BaseColor(0xff009846)); cell4.setFixedHeight(20f); PdfPCell cell5 = new PdfPCell(new Phrase("Total", F_NORMAL)); cell5.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); cell5.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell5.setColspan(8); cell5.setFixedHeight(20f); PdfPCell cell6 = new PdfPCell(); cell6.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell6.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell6.setColspan(4); cell6.setFixedHeight(20f); PdfPTable table = new PdfPTable(12); table.setWidthPercentage(100); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); float total = agregarEgresos(table, egresos); cell5.setBorder(Rectangle.RIGHT); table.addCell(cell5); cell6.setPhrase(new Phrase(String.format("%.2f pesos", total), F_NORMAL)); table.addCell(cell6); documento.add(table); }
From source file:org.inspira.condominio.pdf.DocumentoIngreso.java
private float addTablaFormatoIngresos(InformacionIngresos infoIngresos) throws DocumentException { PdfPCell cellHeader1 = new PdfPCell(new Phrase("Ingresos Ordinarios", F_CELL_HEADER_TEXT)); cellHeader1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellHeader1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellHeader1.setColspan(5);//from ww w .java2 s . c o m cellHeader1.setFixedHeight(20f); cellHeader1.setBackgroundColor(new BaseColor(0xff009846)); PdfPCell cellHeader2 = new PdfPCell(new Phrase("Monto", F_CELL_HEADER_TEXT)); cellHeader2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellHeader2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellHeader2.setColspan(5); cellHeader2.setBackgroundColor(new BaseColor(0xff009846)); cellHeader2.setFixedHeight(20f); PdfPCell cellHeader3 = new PdfPCell(new Phrase("En cuenta bancaria", F_NORMAL)); cellHeader3.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); cellHeader3.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellHeader3.setColspan(5); cellHeader3.setFixedHeight(20f); PdfPCell cellHeader4 = new PdfPCell( new Phrase(String.format("%.2f pesos", infoIngresos.getMontoCuentaBancaria()), F_NORMAL)); cellHeader4.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellHeader4.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellHeader4.setColspan(5); cellHeader4.setFixedHeight(20f); PdfPCell cellHeader5 = new PdfPCell(new Phrase("En caja de administracin", F_NORMAL)); cellHeader5.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); cellHeader5.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellHeader5.setColspan(5); cellHeader5.setFixedHeight(20f); PdfPCell cellHeader6 = new PdfPCell( new Phrase(String.format("%.2f pesos", infoIngresos.getMontoEnCajaDeAdministracion()), F_NORMAL)); cellHeader6.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellHeader6.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellHeader6.setColspan(5); cellHeader6.setFixedHeight(20f); PdfPCell cellHeader7 = new PdfPCell(new Phrase("Total", F_NORMAL)); cellHeader7.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); cellHeader7.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellHeader7.setColspan(5); cellHeader7.setFixedHeight(20f); PdfPCell cellHeader8 = new PdfPCell(new Phrase( String.format("%.2f pesos", infoIngresos.getMontoCuentaBancaria() + infoIngresos.getMontoEnCajaDeAdministracion()), F_NORMAL)); cellHeader8.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellHeader8.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellHeader8.setColspan(5); cellHeader8.setFixedHeight(20f); PdfPTable table = new PdfPTable(10); table.setWidthPercentage(100); table.addCell(cellHeader1); table.addCell(cellHeader2); table.addCell(cellHeader3); table.addCell(cellHeader4); table.addCell(cellHeader5); table.addCell(cellHeader6); table.addCell(cellHeader7); table.addCell(cellHeader8); table.setSpacingBefore(3f); documento.add(table); return infoIngresos.getMontoCuentaBancaria() + infoIngresos.getMontoEnCajaDeAdministracion(); }
From source file:org.inspira.condominio.pdf.DocumentoIngreso.java
private void addTablaCobranza(InformacionIngresos infoIngresos) throws DocumentException { PdfPCell cell1 = new PdfPCell(new Phrase("Tipo de condminos", F_CELL_HEADER_TEXT)); cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell1.setColspan(6);/*from w ww . j a v a 2s.com*/ cell1.setFixedHeight(20f); cell1.setBackgroundColor(new BaseColor(0xff009846)); PdfPCell cell2 = new PdfPCell(new Phrase("Nmero", F_CELL_HEADER_TEXT)); cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell2.setColspan(2); cell2.setBackgroundColor(new BaseColor(0xff009846)); cell2.setFixedHeight(20f); PdfPCell cell3 = new PdfPCell(new Phrase("Porcentaje", F_CELL_HEADER_TEXT)); cell3.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell3.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell3.setColspan(2); cell3.setBackgroundColor(new BaseColor(0xff009846)); cell3.setFixedHeight(20f); PdfPCell cell4 = new PdfPCell(new Phrase("Condminos que efectuaron su pago", F_NORMAL)); cell4.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); cell4.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell4.setColspan(6); cell4.setFixedHeight(20f); PdfPCell cell5 = new PdfPCell(new Phrase(String.valueOf(infoIngresos.getTotalRegulares()), F_NORMAL)); cell5.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell5.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell5.setColspan(2); cell5.setFixedHeight(20f); PdfPCell cell6 = new PdfPCell(new Phrase(String.format("%.2f%%", ((float) infoIngresos.getTotalRegulares() / (float) infoIngresos.getTotalhabitantes()) * 100), F_NORMAL)); cell6.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell6.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell6.setColspan(2); cell6.setFixedHeight(20f); PdfPCell cell7 = new PdfPCell(new Phrase("Condminos morosos", F_NORMAL)); cell7.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); cell7.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell7.setColspan(6); cell7.setFixedHeight(20f); PdfPCell cell8 = new PdfPCell(new Phrase( String.valueOf(infoIngresos.getTotalhabitantes() - infoIngresos.getTotalRegulares()), F_NORMAL)); cell8.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell8.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell8.setColspan(2); cell8.setFixedHeight(20f); PdfPCell cell9 = new PdfPCell(new Phrase(String.format("%.2f%%", (((float) infoIngresos.getTotalhabitantes() - (float) infoIngresos.getTotalRegulares()) / (float) infoIngresos.getTotalhabitantes()) * 100), F_NORMAL)); cell9.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell9.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell9.setColspan(2); cell9.setFixedHeight(20f); PdfPCell cell10 = new PdfPCell(new Phrase("Total", F_NORMAL)); cell10.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); cell10.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell10.setColspan(6); cell10.setFixedHeight(20f); PdfPCell cell11 = new PdfPCell(new Phrase(String.valueOf(infoIngresos.getTotalhabitantes()), F_NORMAL)); cell11.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell11.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell11.setColspan(2); cell11.setFixedHeight(20f); PdfPCell cell12 = new PdfPCell(new Phrase("100%", F_NORMAL)); cell12.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell12.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell12.setColspan(2); cell12.setFixedHeight(20f); PdfPTable table = new PdfPTable(10); table.setWidthPercentage(100); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); table.addCell(cell5); table.addCell(cell6); table.addCell(cell7); table.addCell(cell8); table.addCell(cell9); table.addCell(cell10); table.addCell(cell11); table.addCell(cell12); documento.add(table); }