List of usage examples for com.itextpdf.text.pdf PdfPTable setHorizontalAlignment
public void setHorizontalAlignment(final int horizontalAlignment)
From source file:be.rheynaerde.poolsheets.AbstractPoolSheet.java
License:Open Source License
protected void buildTitle(Document document) throws DocumentException { //the title is placed in a one-column table of width 100% PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.setWidthPercentage(100f);/* ww w .ja v a2 s . com*/ //one row for the title PdfPCell cell = new PdfPCell(new Phrase(configuration.getTitle(), configuration.getTitleFont())); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingBottom(10f); table.addCell(cell); //one row for the subtitle cell = new PdfPCell(new Phrase(configuration.getSubtitle(), configuration.getSubtitleFont())); cell.setBorder(Rectangle.NO_BORDER); cell.setBorder(Rectangle.TOP); table.addCell(cell); //make sure that there is some spacing between the title and the scores //20f just seems to work allright, but maybe something more configurable //would be better. table.setSpacingAfter(20f); document.add(table); }
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 w w w.j a v a 2 s. c om*/ (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 w w w . ja v a2 s . 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 w ww .j av a 2s . 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())); 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 2s. c om 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 a v a 2 s . c om 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:BusinessLogic.Controller.HandleCertificate.java
public void downloadCertificate(ContractDAO contrDAO, CertificateDAO certificateDAO, UserDAO usDAO, HttpServletResponse response, int idUser, int option) throws DocumentException, IOException { User user = usDAO.searchByPkID(idUser); List<Certificate> certificateObject = certificateDAO.searchUserAproved(); List<Certificate> certificateReturn = new ArrayList<Certificate>(); if (certificateObject != null) { certificateReturn.clear();/*from ww w . j av a 2 s . c om*/ for (int i = 0; i < certificateObject.size(); i++) { if (certificateObject.get(i).getFkuserID().getPkID().equals(user.getPkID())) { certificateReturn.add(certificateObject.get(i)); } } } Contract contractObject = contrDAO.getUserContract(new User(user.getPkID())); Certificate cert = certificateReturn.get(option); Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open(); Font fuente = new Font(); fuente.setStyle(Font.BOLD); fuente.setColor(BaseColor.BLACK); fuente.setFamily(Font.FontFamily.TIMES_ROMAN.toString()); fuente.setSize(15); Paragraph header = new Paragraph("\n\n\n\n\nEL DEPARTAMENTO DE GESTION HUMANA\n" + "DE TALENTO-HUMANO LTDA\n\n\n\n\n" + "CERTIFICA QUE:\n\n\n\n\n", fuente); header.setAlignment(Element.ALIGN_CENTER); Calendar fecha = new GregorianCalendar(); int annio = fecha.get(Calendar.YEAR); int mes = fecha.get(Calendar.MONTH) + 1; int dia = fecha.get(Calendar.DAY_OF_MONTH); Paragraph endtext = new Paragraph("\n\nSe expide la presente certificacion a solicitud" + " del interesado a la fecha de : " + dia + "/" + mes + "/" + annio + "\n\n\nCordialmente\n\n\nEdwin Alexander Bohorquez\nGERENTE GENERAL DE TALENTO-HUMANO LTDA"); endtext.setAlignment(Element.ALIGN_LEFT); String typeCertificate = ""; if (cert.getType().toLowerCase().equals("laboral")) { typeCertificate = "Laboral"; document.add(header); List<String> positionlist = new ArrayList<String>(); for (Position cargo : contractObject.getPositionSet()) { positionlist.add(cargo.getName()); } Paragraph body = new Paragraph(user.getName().toUpperCase() + " " + user.getLastname().toUpperCase() + " con cedula de ciudadania No." + user.getIdentifyCard() + ", trabaja en esta empresa" + " desde " + contractObject.getStartDate() + ", desempeandose actualmente como " + positionlist + " con una asignacion mensual de $" + contractObject.getSalary() + ".Su contrato de trabajo es a termino " + contractObject.getType() + "."); body.setAlignment(Element.ALIGN_JUSTIFIED_ALL); document.add(body); document.add(endtext); } else if (cert.getType().toLowerCase().equals("nmina")) { typeCertificate = "Nomina"; Paragraph Payroll_header = new Paragraph("DEPARTAMENTO DE CONTABILIDAD\n" + "TALENTO-HUMANO LTDA\n\n" + "LIQUIDACION DE NOMINA:\n" + "Nombre del empleado : " + user.getName() + " " + user.getLastname() + "\n" + "Cedula : " + user.getIdentifyCard() + "\n\n", fuente); Payroll_header.setAlignment(Element.ALIGN_CENTER); document.add(Payroll_header); double commissions = 10000; double extra_hours = 50000; double transportation_aid = 63600; double totalAccrued = contractObject.getSalary() + commissions + extra_hours + transportation_aid; PdfPTable basetable = new PdfPTable(2); PdfPCell headertable = new PdfPCell(new Paragraph("Tabla Base", fuente)); headertable.setColspan(2); basetable.addCell(headertable); PdfPCell cell1 = new PdfPCell(new Paragraph("Salario Basico : ")); PdfPCell cell2 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary()))); PdfPCell cell3 = new PdfPCell(new Paragraph("Comisiones : ")); PdfPCell cell4 = new PdfPCell(new Paragraph(String.valueOf(commissions))); PdfPCell cell5 = new PdfPCell(new Paragraph("Horas Extras : ")); PdfPCell cell6 = new PdfPCell(new Paragraph(String.valueOf(extra_hours))); PdfPCell cell7 = new PdfPCell(new Paragraph("Auxilio de transporte : ")); PdfPCell cell8 = new PdfPCell(new Paragraph(String.valueOf(transportation_aid))); PdfPCell ce9 = new PdfPCell(new Paragraph("Total Devengado : ")); PdfPCell ce10 = new PdfPCell(new Paragraph(" $ " + String.valueOf(totalAccrued))); basetable.setWidthPercentage(100F); basetable.setHorizontalAlignment(Element.ALIGN_CENTER); basetable.addCell(cell1); basetable.addCell(cell2); basetable.addCell(cell3); basetable.addCell(cell4); basetable.addCell(cell5); basetable.addCell(cell6); basetable.addCell(cell7); basetable.addCell(cell8); basetable.addCell(ce9); basetable.addCell(ce10); document.add(basetable); PdfPTable tableliquidation = new PdfPTable(2); PdfPCell title = new PdfPCell( new Paragraph("Liquidacion. Deducciones de nomina(Conceptos a cargo del empleado) ", fuente)); title.setColspan(2); tableliquidation.addCell(title); PdfPCell cell9 = new PdfPCell(new Paragraph("Salud (4%) : ")); PdfPCell cell10 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.04))); PdfPCell cell11 = new PdfPCell(new Paragraph("Pension (4%) : ")); PdfPCell cell12 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.04))); tableliquidation.setWidthPercentage(100F); tableliquidation.setHorizontalAlignment(Element.ALIGN_CENTER); tableliquidation.addCell(cell9); tableliquidation.addCell(cell10); tableliquidation.addCell(cell11); tableliquidation.addCell(cell12); document.add(tableliquidation); PdfPTable tablesocialSecurity = new PdfPTable(2); PdfPCell title2 = new PdfPCell(new Paragraph("Seguridad Social a cargo del empleador", fuente)); title2.setColspan(2); tablesocialSecurity.addCell(title2); PdfPCell cell13 = new PdfPCell(new Paragraph("Salud (8.5%) : ")); PdfPCell cell14 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.085))); PdfPCell cell15 = new PdfPCell(new Paragraph("Pension (12%) : ")); PdfPCell cell16 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.12))); PdfPCell cell17 = new PdfPCell(new Paragraph("A.R.P : ")); PdfPCell cell18 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.00522))); tablesocialSecurity.setWidthPercentage(100F); tablesocialSecurity.setHorizontalAlignment(Element.ALIGN_CENTER); tablesocialSecurity.addCell(cell13); tablesocialSecurity.addCell(cell14); tablesocialSecurity.addCell(cell15); tablesocialSecurity.addCell(cell16); tablesocialSecurity.addCell(cell17); tablesocialSecurity.addCell(cell18); document.add(tablesocialSecurity); PdfPTable social_benefits = new PdfPTable(2); PdfPCell title3 = new PdfPCell(new Paragraph("Prestaciones Sociales", fuente)); title3.setColspan(2); social_benefits.addCell(title3); PdfPCell cell19 = new PdfPCell(new Paragraph("Prima de servicios : ")); PdfPCell cell20 = new PdfPCell(new Paragraph(String.valueOf(totalAccrued * 0.0833))); PdfPCell cell21 = new PdfPCell(new Paragraph("Cesantias : ")); PdfPCell cell22 = new PdfPCell(new Paragraph(String.valueOf(totalAccrued * 0.0833))); PdfPCell cell23 = new PdfPCell(new Paragraph("Intereses sobre las cesantias : ")); PdfPCell cell24 = new PdfPCell(new Paragraph(String.valueOf(totalAccrued * 0.0833 * 0.12))); PdfPCell cell25 = new PdfPCell(new Paragraph("Vacaciones : ")); PdfPCell cell26 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.0417))); social_benefits.setWidthPercentage(100F); social_benefits.setHorizontalAlignment(Element.ALIGN_CENTER); social_benefits.addCell(cell19); social_benefits.addCell(cell20); social_benefits.addCell(cell21); social_benefits.addCell(cell22); social_benefits.addCell(cell23); social_benefits.addCell(cell24); social_benefits.addCell(cell25); social_benefits.addCell(cell26); document.add(social_benefits); PdfPTable fiscal_contributions = new PdfPTable(2); PdfPCell title4 = new PdfPCell(new Paragraph("Aportes Parafiscales", fuente)); title4.setColspan(2); fiscal_contributions.addCell(title4); PdfPCell cell27 = new PdfPCell(new Paragraph("Cajas de compensacion familiar (4%) : ")); PdfPCell cell28 = new PdfPCell( new Paragraph(String.valueOf((contractObject.getSalary() + extra_hours + commissions) * 0.04))); PdfPCell cell29 = new PdfPCell(new Paragraph("I.CB.F (3%) : ")); PdfPCell cell30 = new PdfPCell( new Paragraph(String.valueOf((contractObject.getSalary() + extra_hours + commissions) * 0.03))); PdfPCell cell31 = new PdfPCell(new Paragraph("Sena (2%) : ")); PdfPCell cell32 = new PdfPCell( new Paragraph(String.valueOf((contractObject.getSalary() + extra_hours + commissions) * 0.02))); fiscal_contributions.setWidthPercentage(100F); fiscal_contributions.setHorizontalAlignment(Element.ALIGN_CENTER); fiscal_contributions.addCell(cell27); fiscal_contributions.addCell(cell28); fiscal_contributions.addCell(cell29); fiscal_contributions.addCell(cell30); fiscal_contributions.addCell(cell31); fiscal_contributions.addCell(cell32); document.add(fiscal_contributions); PdfPTable totalValue = new PdfPTable(2); PdfPCell title5 = new PdfPCell(new Paragraph("Neto a pagar al empleado", fuente)); title5.setColspan(2); totalValue.addCell(title5); PdfPCell cell33 = new PdfPCell(new Paragraph(" Total devengado - salud - pension")); cell33.setColspan(2); PdfPCell cell34 = new PdfPCell(new Paragraph( " $ " + String.valueOf(totalAccrued - contractObject.getSalary() * 0.08), fuente)); cell34.setColspan(2); totalValue.setWidthPercentage(100F); totalValue.setHorizontalAlignment(Element.ALIGN_CENTER); totalValue.addCell(cell33); totalValue.addCell(cell34); document.add(totalValue); document.add(endtext); } else if (cert.getType().toLowerCase().equals("salud")) { typeCertificate = "Salud"; document.add(header); Paragraph body = new Paragraph(user.getName().toUpperCase() + " " + user.getLastname().toUpperCase() + " con cedula de ciudadania No." + user.getIdentifyCard() + ", esta afiliado desde " + contractObject.getStartHealthDate() + " a la empresa de salud " + contractObject.getHealthEnterprise() + "."); body.setAlignment(Element.ALIGN_JUSTIFIED_ALL); document.add(body); document.add(endtext); } else if (cert.getType().toLowerCase().equals("pensin")) { typeCertificate = "Pension"; document.add(header); Paragraph body = new Paragraph(user.getName().toUpperCase() + " " + user.getLastname().toUpperCase() + " con cedula de ciudadania No." + user.getIdentifyCard() + ", esta afiliado a la empresa de pension " + contractObject.getPensionEnterprise() + ".La fecha de inicio de pension es " + contractObject.getStartPensionDate() + "."); body.setAlignment(Element.ALIGN_JUSTIFIED_ALL); document.add(body); document.add(endtext); } document.close(); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setContentType("application/octet-strem"); File f = new File("Certificado" + typeCertificate + ".pdf"); response.setHeader("Content-Disposition", "attachment;filename=" + f.getName()); response.setContentLength(baos.size()); System.out.println("Hasta aca crea el pdf bien"); OutputStream os = response.getOutputStream(); System.out.println("Ac'a ya deberia haber descargado"); baos.writeTo(os); os.flush(); os.close(); }
From source file:climbingcompranking.model.ranking.RankingGenerator.java
License:Open Source License
public void createRankingPDF(String competitionName, CompetitionType compType) { doTheRanking(compType);// w w w .ja v a 2 s. c o m try { Document document = new Document(PageSize.A4.rotate()); // Landscape Date date = new Date(); String dateStr = ""; if (Locale.getDefault().equals(Locale.FRANCE)) { dateStr = new SimpleDateFormat("dd-MM-yyyy").format(date); } else { dateStr = new SimpleDateFormat("yyyy-MM-dd").format(date); } PdfWriter.getInstance(document, new FileOutputStream("data/pdf/" + competitionName + '-' + dateStr + ".pdf")); document.open(); // Meta data document.addTitle(competitionName); document.addSubject(competitionName + " ranking."); document.addKeywords(competitionName + ", ranking, climbingcompetition, climbcompranking"); document.addAuthor("ClimbingCompRanking - https://github.com/Yaty/ClimbingCompRanking"); document.addCreator("ClimbingCompRanking - https://github.com/Yaty/ClimbingCompRanking"); document.addCreationDate(); document.setMargins(0, 0, 0, 0); PdfPCell club = new PdfPCell(new Phrase(I18n.MODEL.getString("Club"))); PdfPCell climberName = new PdfPCell(new Phrase(I18n.MODEL.getString("ClimberName"))); PdfPCell ranking = new PdfPCell(new Phrase(I18n.MODEL.getString("Ranking"))); for (Map.Entry<Category, ArrayList<Climber>> climbersCategory : climbersMap.entrySet()) { if (climbersCategory.getValue().isEmpty()) continue; document.newPage(); // Title Paragraph title = new Paragraph( competitionName + " : " + climbersCategory.getKey().getCategoryName()); title.setAlignment(Element.ALIGN_CENTER); title.setFont(new Font(Font.FontFamily.HELVETICA, 36)); title.setSpacingAfter(20); // Table PdfPTable table = null; switch (compType) { case BOULDERING: case LEAD: case SPEED: table = new PdfPTable(3); // Club | Full name | Ranking table.addCell(club); table.addCell(climberName); table.addCell(ranking); for (Climber climber : climbersCategory.getValue()) { table.addCell(new PdfPCell(new Phrase(climber.getClubName()))); table.addCell(new PdfPCell(new Phrase(climber.getFullName()))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank())))); } break; case LEAD_AND_BOULDERING: table = new PdfPTable(6); // Club | Full name | Ranking table.addCell(club); table.addCell(climberName); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("LeadRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("BoulderingRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum")))); table.addCell(ranking); for (Climber climber : climbersCategory.getValue()) { table.addCell(new PdfPCell(new Phrase(climber.getClubName()))); table.addCell(new PdfPCell(new Phrase(climber.getFullName()))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getLeadRank())))); table.addCell( new PdfPCell(new Phrase(String.valueOf(climber.getRank().getBoulderingRank())))); table.addCell(new PdfPCell( new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType))))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank())))); } break; case SPEED_AND_BOULDERING: table = new PdfPTable(6); // Club | Full name | Ranking table.addCell(club); table.addCell(climberName); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("SpeedRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("BoulderingRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum")))); table.addCell(ranking); for (Climber climber : climbersCategory.getValue()) { table.addCell(new PdfPCell(new Phrase(climber.getClubName()))); table.addCell(new PdfPCell(new Phrase(climber.getFullName()))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getSpeedRank())))); table.addCell( new PdfPCell(new Phrase(String.valueOf(climber.getRank().getBoulderingRank())))); table.addCell(new PdfPCell( new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType))))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank())))); } break; case SPEED_AND_LEAD: table = new PdfPTable(6); // Club | Full name | Ranking table.addCell(club); table.addCell(climberName); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("SpeedRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("LeadRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum")))); table.addCell(ranking); for (Climber climber : climbersCategory.getValue()) { table.addCell(new PdfPCell(new Phrase(climber.getClubName()))); table.addCell(new PdfPCell(new Phrase(climber.getFullName()))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getSpeedRank())))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getLeadRank())))); table.addCell(new PdfPCell( new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType))))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank())))); } break; case COMBINED: table = new PdfPTable(7); // Club | Full name | Ranking table.addCell(club); table.addCell(climberName); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("LeadRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("BoulderingRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("SpeedRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum")))); table.addCell(ranking); for (Climber climber : climbersCategory.getValue()) { table.addCell(new PdfPCell(new Phrase(climber.getClubName()))); table.addCell(new PdfPCell(new Phrase(climber.getFullName()))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getLeadRank())))); table.addCell( new PdfPCell(new Phrase(String.valueOf(climber.getRank().getBoulderingRank())))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getSpeedRank())))); table.addCell(new PdfPCell( new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType))))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank())))); } break; } // Alignment for (PdfPRow row : table.getRows()) { PdfPCell[] cells = row.getCells(); for (PdfPCell cellToAlign : cells) { cellToAlign.setHorizontalAlignment(Element.ALIGN_CENTER); cellToAlign.setVerticalAlignment(Element.ALIGN_CENTER); } } table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setHeaderRows(1); document.add(title); document.add(table); } document.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(RankingGenerator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.ainfosec.macresponse.report.PdfGenerator.java
License:Open Source License
private static void createDataSection(Paragraph paragraph, DisplayObject displayObject) { if (displayObject == null || displayObject.getObjects() == null) { return;/*from w ww.j a v a 2 s . co m*/ } // See if the DisplayObject has a list or a single object if (displayObject.getObjects().size() == 1) { TreeObject treeObject = displayObject.getObjects().get(0); // There's only 1 item // For each column, create/add a label with the title and the data int i = 0; for (String columnName : displayObject.getColumnNames()) { StringBuffer sb = new StringBuffer(); // Add the column title sb.append(displayObject.getColumnTitles()[i]); sb.append(": "); // Get the value of the field try { Field field = treeObject.getClass().getDeclaredField(columnName); String val = (String) field.get(treeObject); if (val == null) { val = ""; } // Add the value sb.append(val); sb.append("\n"); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Put the string into the paragraph paragraph.add(sb.toString()); i++; } } else { PdfPTable table = new PdfPTable(displayObject.getColumnTitles().length); table.setWidthPercentage(100); table.setHorizontalAlignment(Element.ALIGN_CENTER); for (String columnName : displayObject.getColumnTitles()) { table.getDefaultCell().setBackgroundColor(BaseColor.CYAN); table.addCell(columnName); table.getDefaultCell().setBackgroundColor(BaseColor.WHITE); } for (TreeObject to1 : displayObject.getObjects()) { for (String columnName : displayObject.getColumnNames()) { try { Field field = to1.getClass().getDeclaredField(columnName); String val = (String) field.get(to1); if (val == null) { val = ""; } table.addCell(val); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } table.getDefaultCell().setColspan(displayObject.getColumnTitles().length); table.getDefaultCell().setBorder(SWT.NONE); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // TODO Paul number the tables table.addCell("Table: " + displayObject.getTitle()); paragraph.add(table); } }
From source file:com.asae.controllers.BeanGestionRutinas.java
public void generarPdf() { Document document = new Document(); try {//w ww. j av a2 s.co m File file = File.createTempFile("rutina-", ".pdf", new File("/var/webapp/pdf")); pdfFileName = file.getName(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); Font bold = new Font(Font.FontFamily.HELVETICA, 12f, Font.BOLD); URL url = FacesContext.getCurrentInstance().getExternalContext() .getResource("/resources/img/logo-unicauca-negro.png"); Image imgLogoUnicauca = Image.getInstance(url); imgLogoUnicauca.scaleAbsolute(118f, 131f); PdfPTable tableEncabezado = new PdfPTable(2); tableEncabezado.getDefaultCell().setBorder(Rectangle.NO_BORDER); tableEncabezado.setWidthPercentage(100); tableEncabezado.setSpacingAfter(5); PdfPCell cell1 = new PdfPCell(imgLogoUnicauca); cell1.setBorder(Rectangle.NO_BORDER); PdfPCell cell2 = new PdfPCell(new Paragraph("Vicerrectoria Administrativa")); cell2.setBorder(Rectangle.NO_BORDER); cell2.setVerticalAlignment(Element.ALIGN_BOTTOM); cell2.setHorizontalAlignment(Element.ALIGN_RIGHT); PdfPCell cell3 = new PdfPCell(new Paragraph("Universidad del Cauca", bold)); cell3.setBorder(Rectangle.NO_BORDER); PdfPCell cell4 = new PdfPCell(new Paragraph("Gimnasio y Actividad Fsica", bold)); cell4.setBorder(Rectangle.NO_BORDER); cell4.setHorizontalAlignment(Element.ALIGN_RIGHT); tableEncabezado.addCell(cell1); tableEncabezado.addCell(cell2); tableEncabezado.addCell(cell3); tableEncabezado.addCell(cell4); PdfPTable tableDatosUsuario = new PdfPTable(3); tableDatosUsuario.getDefaultCell().setBorder(Rectangle.NO_BORDER); tableDatosUsuario.setWidthPercentage(100); tableDatosUsuario.setSpacingBefore(20); PdfPCell cell5 = new PdfPCell(new Paragraph("Nombre: " + rutinaVisualizar.getIdusuario().getFisrtname() + " " + rutinaVisualizar.getIdusuario().getSecondname() + " " + rutinaVisualizar.getIdusuario().getFirstlastname() + " " + rutinaVisualizar.getIdusuario().getSecondlastname())); cell5.setBorder(Rectangle.NO_BORDER); PdfPCell cell6 = new PdfPCell(); cell6.setBorder(Rectangle.NO_BORDER); PdfPCell cell7 = new PdfPCell(); cell7.setBorder(Rectangle.NO_BORDER); tableDatosUsuario.addCell(cell5); tableDatosUsuario.addCell(cell6); tableDatosUsuario.addCell(cell7); PdfPTable tableFechas = new PdfPTable(3); tableFechas.getDefaultCell().setBorder(Rectangle.NO_BORDER); tableFechas.setWidthPercentage(100); tableFechas.setSpacingBefore(10); PdfPCell cell8 = new PdfPCell( new Paragraph("Fecha de inicio: " + getMyFormattedDate(rutinaVisualizar.getFechaInicio()))); cell8.setBorder(Rectangle.NO_BORDER); PdfPCell cell9 = new PdfPCell( new Paragraph("Fecha de fin: " + getMyFormattedDate(rutinaVisualizar.getFechaFin()))); cell9.setBorder(Rectangle.NO_BORDER); PdfPCell cell10 = new PdfPCell(); cell10.setBorder(Rectangle.NO_BORDER); tableFechas.addCell(cell8); tableFechas.addCell(cell9); tableFechas.addCell(cell10); PdfPTable tableMedidas = new PdfPTable(4); tableMedidas.getDefaultCell().setBorder(Rectangle.NO_BORDER); tableMedidas.setWidthPercentage(100); tableMedidas.setSpacingBefore(10); Usuario usuAux = rutinaVisualizar.getIdusuario(); List<Evaluacion> lstEvalAux = usuAux.getEvaluacionList(); Evaluacion evalAux; double peso = 0; if (lstEvalAux.size() > 0) { evalAux = lstEvalAux.get(lstEvalAux.size() - 1); peso = evalAux.getPeso().doubleValue(); } double estatura = 0; MedidasGenerales medGenAux = usuAux.getMedidasGenerales(); if (medGenAux != null) { estatura = medGenAux.getEstatura().doubleValue(); } PdfPCell cell11 = new PdfPCell(new Paragraph("Peso: " + peso)); cell11.setBorder(Rectangle.NO_BORDER); PdfPCell cell12 = new PdfPCell(new Paragraph("Talla: " + estatura)); cell12.setBorder(Rectangle.NO_BORDER); double imc = 0; if (peso != 0 && estatura != 0) { imc = peso / Math.pow(estatura, 2); } PdfPCell cell13 = new PdfPCell(new Paragraph("I.M.C: " + imc)); cell13.setBorder(Rectangle.NO_BORDER); PdfPCell cell14 = new PdfPCell(new Paragraph("Rutina: " + rutinaVisualizar.getCodigoRutina())); cell14.setBorder(Rectangle.NO_BORDER); tableMedidas.addCell(cell11); tableMedidas.addCell(cell12); tableMedidas.addCell(cell13); tableMedidas.addCell(cell14); PdfPTable tableDias = new PdfPTable(2); tableDias.getDefaultCell().setBorder(Rectangle.NO_BORDER); tableDias.setWidthPercentage(100); tableDias.setSpacingBefore(20); tableDias.setHorizontalAlignment(Element.ALIGN_LEFT); tableDias.setWidths(new int[] { 1, 9 }); List<Dia> lstDiasPDF = rutinaVisualizar.getDiaList(); PdfPCell cellCabezeraDia = new PdfPCell(new Paragraph("Da", bold)); PdfPCell cellCabezeraDia2 = new PdfPCell(); cellCabezeraDia2.setBorder(Rectangle.NO_BORDER); tableDias.addCell(cellCabezeraDia); tableDias.addCell(cellCabezeraDia2); for (Dia dia : lstDiasPDF) { PdfPCell cellDia = new PdfPCell(new Paragraph(dia.getNumDia().toString())); PdfPCell cellDia2 = new PdfPCell(); cellDia2.setBorder(Rectangle.NO_BORDER); List<GrupoMuscular> lstGMuscularPDF = dia.getGrupoMuscularList(); if (lstGMuscularPDF.size() > 0) { PdfPTable tableGMuscular = new PdfPTable(2); tableGMuscular.getDefaultCell().setBorder(Rectangle.NO_BORDER); tableGMuscular.setWidthPercentage(100); tableGMuscular.setHorizontalAlignment(Element.ALIGN_LEFT); tableGMuscular.setWidths(new int[] { 1, 6 }); PdfPCell cellCabezeraGMuscular = new PdfPCell(new Paragraph("Grupo Muscular", bold)); cellCabezeraGMuscular.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP); PdfPCell cellCabezeraGMuscular2 = new PdfPCell(); cellCabezeraGMuscular2.setBorder(Rectangle.NO_BORDER); tableGMuscular.addCell(cellCabezeraGMuscular); tableGMuscular.addCell(cellCabezeraGMuscular2); int aux = 1; for (GrupoMuscular gMuscularFor : lstGMuscularPDF) { PdfPCell cellGMuscular = new PdfPCell( new Paragraph(gMuscularFor.getIdgrupoMuscularGeneral().getNombre())); cellGMuscular.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT); PdfPCell cellGMuscular2 = new PdfPCell(); cellGMuscular2.setBorder(Rectangle.NO_BORDER); List<EjercicioGm> lstEjerciciosGMuscularPDF = gMuscularFor.getEjercicioGmList(); BaseColor myColor = WebColors.getRGBColor("#CCEEFF"); if (lstEjerciciosGMuscularPDF.size() > 0) { PdfPTable tableEjercicioGMsucular = new PdfPTable(5); tableEjercicioGMsucular.getDefaultCell().setBorder(Rectangle.NO_BORDER); tableEjercicioGMsucular.setWidthPercentage(100); tableEjercicioGMsucular.setHorizontalAlignment(Element.ALIGN_LEFT); PdfPCell cellCabezeraEjercicioGM = new PdfPCell(new Paragraph("Ejercicio", bold)); cellCabezeraEjercicioGM.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP); cellCabezeraEjercicioGM.setLeading(20f, 0f); cellCabezeraEjercicioGM.setBackgroundColor(myColor); tableEjercicioGMsucular.addCell(cellCabezeraEjercicioGM); PdfPCell cellCabezeraEjercicioGM2 = new PdfPCell(new Paragraph("Series", bold)); cellCabezeraEjercicioGM2.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP); cellCabezeraEjercicioGM2.setLeading(20f, 0f); cellCabezeraEjercicioGM2.setBackgroundColor(myColor); tableEjercicioGMsucular.addCell(cellCabezeraEjercicioGM2); PdfPCell cellCabezeraEjercicioGM3 = new PdfPCell(new Paragraph("Repeticiones", bold)); cellCabezeraEjercicioGM3.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP); cellCabezeraEjercicioGM3.setLeading(20f, 0f); cellCabezeraEjercicioGM3.setBackgroundColor(myColor); tableEjercicioGMsucular.addCell(cellCabezeraEjercicioGM3); PdfPCell cellCabezeraEjercicioGM4 = new PdfPCell(new Paragraph("Receso", bold)); cellCabezeraEjercicioGM4.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP); cellCabezeraEjercicioGM4.setLeading(20f, 0f); cellCabezeraEjercicioGM4.setBackgroundColor(myColor); tableEjercicioGMsucular.addCell(cellCabezeraEjercicioGM4); PdfPCell cellCabezeraEjercicioGM5 = new PdfPCell(new Paragraph("Peso", bold)); cellCabezeraEjercicioGM5.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP); cellCabezeraEjercicioGM5.setLeading(20f, 0f); cellCabezeraEjercicioGM5.setBackgroundColor(myColor); tableEjercicioGMsucular.addCell(cellCabezeraEjercicioGM5); int aux2 = 1; for (EjercicioGm ejercicioGm : lstEjerciciosGMuscularPDF) { PdfPCell cellEjercicioGM = new PdfPCell( new Paragraph(ejercicioGm.getEjercicio().getNombre())); cellEjercicioGM.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT); cellEjercicioGM.setLeading(20f, 0f); PdfPCell cellEjercicioGM2 = new PdfPCell( new Paragraph(ejercicioGm.getNumeroSeries().toString())); cellEjercicioGM2.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT); cellEjercicioGM2.setLeading(20f, 0f); PdfPCell cellEjercicioGM3 = new PdfPCell( new Paragraph(ejercicioGm.getRepeticiones().toString())); cellEjercicioGM3.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT); cellEjercicioGM3.setLeading(20f, 0f); PdfPCell cellEjercicioGM4 = new PdfPCell( new Paragraph(ejercicioGm.getReceso().toString())); cellEjercicioGM4.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT); cellEjercicioGM4.setLeading(20f, 0f); PdfPCell cellEjercicioGM5 = new PdfPCell( new Paragraph(ejercicioGm.getPeso().toString())); cellEjercicioGM5.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT); cellEjercicioGM5.setLeading(20f, 0f); if (aux2 % 2 == 0) { cellEjercicioGM.setBackgroundColor(myColor); cellEjercicioGM2.setBackgroundColor(myColor); cellEjercicioGM3.setBackgroundColor(myColor); cellEjercicioGM4.setBackgroundColor(myColor); cellEjercicioGM5.setBackgroundColor(myColor); } tableEjercicioGMsucular.addCell(cellEjercicioGM); tableEjercicioGMsucular.addCell(cellEjercicioGM2); tableEjercicioGMsucular.addCell(cellEjercicioGM3); tableEjercicioGMsucular.addCell(cellEjercicioGM4); tableEjercicioGMsucular.addCell(cellEjercicioGM5); aux2++; } cellGMuscular2.addElement(tableEjercicioGMsucular); } tableGMuscular.addCell(cellGMuscular); tableGMuscular.addCell(cellGMuscular2); aux++; } cellDia2.addElement(tableGMuscular); } tableDias.addCell(cellDia); tableDias.addCell(cellDia2); } LineSeparator ls = new LineSeparator(); document.add(tableEncabezado); document.add(ls); document.add(tableDatosUsuario); document.add(tableFechas); document.add(tableMedidas); document.add(tableDias); document.close(); } catch (DocumentException | FileNotFoundException e) { e.printStackTrace(); } catch (IOException ex) { Logger.getLogger(BeanGestionRutinas.class.getName()).log(Level.SEVERE, null, ex); } }