List of usage examples for com.itextpdf.text.pdf PdfPTable setTotalWidth
public void setTotalWidth(final float columnWidth[]) throws DocumentException
From source file:org.fossa.rolp.util.LebPageHelper.java
License:Open Source License
@Override public void onEndPage(PdfWriter writer, Document document) { PdfPTable table = new PdfPTable(2); table.setTotalWidth(527); table.setWidthPercentage(100);// w w w . j a va 2 s . com table.setLockedWidth(true); table.getDefaultCell().setFixedHeight(105f); table.getDefaultCell().setBorderWidth(0); table.addCell(""); table.addCell(csmLogoImage); table.writeSelectedRows(0, -1, 100, 840, writer.getDirectContent()); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase( lebData.getSchuelername() + " " + lebData.getSchuljahr() + " " + lebData.getSchulhalbjahr().getId() + " Seite " + document.getPageNumber(), fusszeilenFont), 100, 75, 0); }
From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java
License:GNU General Public License
private void writeTitlePage() throws DocumentException { Rectangle page = myDoc.getPageSize(); PdfPTable head = new PdfPTable(1); PdfPTable colontitleTable = createColontitleTable(getProject().getProjectName(), GanttLanguage.getInstance().getMediumDateFormat().format(new Date()), getProject().getOrganization(), getProject().getWebLink()); head.setTotalWidth(page.getWidth() - myDoc.leftMargin() - myDoc.rightMargin()); {//w w w. j av a 2 s . com PdfPCell cell = new PdfPCell(colontitleTable); cell.setBorder(PdfPCell.NO_BORDER); head.addCell(cell); } addEmptyRow(head, 20); LinkedHashMap<String, String> attrs = new LinkedHashMap<>(); attrs.put(i18n("label.project_manager"), buildManagerString()); attrs.put(i18n("label.dates"), buildProjectDatesString()); attrs.put(" ", " "); attrs.put(i18n("label.completion"), buildProjectCompletionString()); attrs.put(i18n("label.tasks"), String.valueOf(getProject().getTaskManager().getTaskCount())); attrs.put(i18n("label.resources"), String.valueOf(getProject().getHumanResourceManager().getResources().size())); PdfPTable attrsTable = new PdfPTable(2); writeAttributes(attrsTable, attrs); PdfPCell attrsCell = new PdfPCell(attrsTable); attrsCell.setBorder(PdfPCell.NO_BORDER); head.addCell(attrsCell); addEmptyRow(head, 20); if (getProject().getDescription().length() > 0) { Paragraph p = new Paragraph(getProject().getDescription(), getSansRegular(12)); PdfPCell cell = new PdfPCell(p); cell.setBorder(PdfPCell.TOP | PdfPCell.BOTTOM); cell.setBorderColor(SORTAVALA_GREEN); cell.setBorderWidth(1); cell.setPadding(5); cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER); head.addCell(cell); } myDoc.add(head); }
From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java
License:GNU General Public License
private PdfPTable createColontitleTable(String topLeft, String topRight, String bottomLeft, String bottomRight) {/*from w ww .j a v a 2 s . co m*/ PdfPTable head = new PdfPTable(2); { PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); Paragraph p = new Paragraph(topLeft, getSansRegularBold(18)); p.setAlignment(Paragraph.ALIGN_LEFT); // colontitle.setLeading(0); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); // cell.setPaddingLeft(2); cell.setPaddingBottom(6); cell.setPhrase(p); head.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); Paragraph p = new Paragraph(topRight, getSansRegularBold(10)); p.setAlignment(Paragraph.ALIGN_RIGHT); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setPaddingBottom(6); cell.setPhrase(p); head.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setPaddingLeft(3); cell.setPaddingTop(2); cell.setPaddingBottom(6); cell.setBorder(Rectangle.TOP); cell.setBorderWidthTop(2); cell.setBorderColor(SORTAVALA_GREEN); Paragraph p = new Paragraph(bottomLeft, getSansRegularBold(18)); p.setAlignment(Paragraph.ALIGN_LEFT); p.setExtraParagraphSpace(0); p.setIndentationLeft(0); p.setSpacingBefore(0); cell.setPhrase(p); // cell.addElement(p); head.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingTop(2); cell.setPaddingBottom(6); cell.setBorder(Rectangle.TOP); cell.setBorderWidthTop(2); cell.setBorderColor(SORTAVALA_GREEN); Paragraph p = new Paragraph(bottomRight, getSansRegularBold(10)); p.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPhrase(p); head.addCell(cell); } final Document document = myDoc; Rectangle page = document.getPageSize(); head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin()); return head; }
From source file:org.inspira.condominio.pdf.DocumentoEstadoDeCuenta.java
private void bakeContent(String path, String imgResString) throws IOException, DocumentException { File outFile = new File(path); outFile.getParentFile().mkdirs();// w w w . j a v a 2s. com PdfWriter.getInstance(documento, new FileOutputStream(outFile)); documento.open(); documento.add(new Paragraph( "Ciudad de Mxico, " + DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.getDefault()).format(new Date()), new Font(FontFamily.HELVETICA, 18, Font.NORMAL, new BaseColor(0x000000)))); Paragraph intro = new Paragraph(new Phrase("Comprobante de estado de cuenta", F_NORMAL)); intro.setAlignment(Paragraph.ALIGN_RIGHT); intro.setSpacingBefore(10f); documento.add(intro); Image image = Image.getInstance(imgResString); PdfPTable table = new PdfPTable(1); table.setTotalWidth(image.getScaledWidth()); table.setLockedWidth(true); PdfPCell cell = new PdfPCell(); cell.setBorder(0); //cell.setCellEvent(new ImageBackgroundEvent(image)); cell.setFixedHeight(image.getScaledHeight()); table.addCell(cell); documento.add(table); Paragraph p1 = new Paragraph("Estado de cuenta: ".concat(idEdoCta), F_NORMAL); p1.setSpacingBefore(5f); p1.setSpacingAfter(25f); p1.setAlignment(Paragraph.ALIGN_CENTER); documento.add(p1); documento.add(new Paragraph("Pagos", F_NORMAL)); agregaTablaDePagos(); Paragraph pNotas = new Paragraph("Notas: ".concat(notas), F_NORMAL); pNotas.setSpacingAfter(12f); pNotas.setSpacingAfter(2f); documento.add(pNotas); Paragraph pAdeudos = new Paragraph("Adeudos", F_NORMAL); pAdeudos.setSpacingBefore(25f); documento.add(pAdeudos); agregaTablaDeAdeudos(); documento.add(new Paragraph( "Recuerde que puede consultar su estado de pagos y adeudos desde la aplicacin mvil o directamente con su administrador.", F_NORMAL)); Paragraph hechoPor = new Paragraph("Elabor:", F_NORMAL); hechoPor.setSpacingBefore(30f); hechoPor.setSpacingAfter(15f); documento.add(hechoPor); Paragraph nombreDelAdmin = new Paragraph(admin, F_NORMAL); nombreDelAdmin.setAlignment(Paragraph.ALIGN_CENTER); documento.add(nombreDelAdmin); Paragraph nombreDeCondominio = new Paragraph(condominio, F_NORMAL); nombreDeCondominio.setAlignment(Paragraph.ALIGN_CENTER); documento.add(nombreDeCondominio); }
From source file:org.inspira.condominio.pdf.DocumentoIngreso.java
private void addHousePicture(String imgResStr) throws BadElementException, IOException, DocumentException { Image image = Image.getInstance(imgResStr); PdfPTable table = new PdfPTable(1); table.setTotalWidth(image.getScaledWidth()); table.setLockedWidth(true);//from w ww .j a v a 2s .c o m PdfPCell cell = new PdfPCell(); cell.setBorder(0); //cell.setCellEvent(new ImageBackgroundEvent(image)); cell.setFixedHeight(image.getScaledHeight()); table.addCell(cell); table.setHorizontalAlignment(PdfPTable.ALIGN_RIGHT); documento.add(table); }
From source file:org.openmrs.module.mohtracportal.util.FileExporter.java
License:Open Source License
/** * @param request/*from w w w .jav a 2 s . c om*/ * @param response * @param res * @param filename * @param title * @param from * @param to * @param selectedUsers * @throws Exception */ public void exportToPDF(HttpServletRequest request, HttpServletResponse response, List<Object> res, String filename, String title, String from, String to, List<Integer> selectedUsers) throws Exception { SimpleDateFormat sdf = Context.getDateFormat(); Document document = new Document(); response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); // file name PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); writer.setBoxSize("art", new Rectangle(36, 54, 559, 788)); HeaderFooter event = new HeaderFooter(); writer.setPageEvent(event); document.open(); document.setPageSize(PageSize.A4); document.addAuthor(Context.getAuthenticatedUser().getPersonName().getFamilyName() + " " + Context.getAuthenticatedUser().getPersonName().getGivenName());// the name of the author PersonService ps = Context.getPersonService(); String users = ""; for (Integer usrId : selectedUsers) { users += ps.getPerson(usrId).getPersonName() + "; "; } FontSelector fontTitle = new FontSelector(); fontTitle.addFont(new Font(FontFamily.COURIER, 10.0f, Font.BOLD)); title = MohTracUtil.getMessage("mohtracportal.report.title", null) + " : " + title; String underLine = ""; int count = 0; while (count < title.length()) { count += 1; underLine += "_"; } document.add(fontTitle.process(title));// Report title if (from.trim().compareTo("") != 0) document.add(fontTitle .process("\n" + MohTracUtil.getMessage("mohtracportal.from", null) + " : " + from));// from if (to.trim().compareTo("") != 0) document.add( fontTitle.process("\n" + MohTracUtil.getMessage("mohtracportal.to", null) + " : " + to));// to document.add(fontTitle.process("\n" + MohTracUtil.getMessage("mohtracportal.report.created.on", null) + " : " + sdf.format(new Date())));// Report date document.add(fontTitle.process("\n" + MohTracUtil.getMessage("mohtracportal.report.created.by", null) + " : " + Context.getAuthenticatedUser().getPersonName()));// Report // author Integer numberOfPatients = res.size(); document.add(fontTitle.process("\n" + MohTracUtil.getMessage("mohtracportal.numberOfPatients", null) + " : " + numberOfPatients.toString()));// Number of patients if (users.trim().compareTo("") != 0) document.add(fontTitle.process( "\n" + MohTracUtil.getMessage("mohtracportal.patient.enterers", null) + " : " + users));// enterer(s) document.add(fontTitle.process("\n" + underLine));// Report title document.add(new Paragraph("\n\n")); boolean hasPrivToViewPatientNames = Context.getAuthenticatedUser().hasPrivilege("View Patient Names"); // PdfLine line; PdfPTable table = null; if (hasPrivToViewPatientNames == true) { float[] colsWidth = { 1.2f, 5f, 2.7f, 2.7f, 4.2f, 2.7f }; table = new PdfPTable(colsWidth); } else { float[] colsWidth = { 1.2f, 2.7f, 2.7f, 4.2f, 2.7f }; table = new PdfPTable(colsWidth); } // column number table.setTotalWidth(540f); // title row FontSelector fontTitleSelector = new FontSelector(); fontTitleSelector.addFont(new Font(FontFamily.COURIER, 9, Font.BOLD)); BaseColor bckGroundTitle = new BaseColor(170, 170, 170); // table Header PdfPCell cell = new PdfPCell( fontTitleSelector.process(MohTracUtil.getMessage("mohtracportal.report.list.no", null))); cell.setBackgroundColor(bckGroundTitle); table.addCell(cell); if (hasPrivToViewPatientNames) { cell = new PdfPCell( fontTitleSelector.process(MohTracUtil.getMessage("mohtracportal.patient.names", null))); cell.setBackgroundColor(bckGroundTitle); table.addCell(cell); } cell = new PdfPCell(fontTitleSelector.process(MohTracPortalTag .getIdentifierTypeNameByIdAsString("" + MohTracConfigurationUtil.getTracNetIdentifierTypeId()))); cell.setBackgroundColor(bckGroundTitle); table.addCell(cell); cell = new PdfPCell(fontTitleSelector.process(MohTracPortalTag.getIdentifierTypeNameByIdAsString( "" + MohTracConfigurationUtil.getLocalHealthCenterIdentifierTypeId()))); cell.setBackgroundColor(bckGroundTitle); table.addCell(cell); cell = new PdfPCell( fontTitleSelector.process(MohTracUtil.getMessage("mohtracportal.patient.date.created", null) + "(" + Context.getDateFormat().toPattern() + ")")); cell.setBackgroundColor(bckGroundTitle); table.addCell(cell); cell = new PdfPCell( fontTitleSelector.process(MohTracUtil.getMessage("mohtracportal.numberOfEncounters", null))); cell.setBackgroundColor(bckGroundTitle); table.addCell(cell); // normal row FontSelector fontselector = new FontSelector(); fontselector.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL)); // empty row FontSelector fontEmptyCell = new FontSelector(); fontEmptyCell.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL)); int ids = 0; for (Object patient : res) { Object[] o = (Object[]) patient; ids += 1; cell = new PdfPCell(fontselector.process(ids + "")); if (o[2].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(238, 238, 238)); if (o[3].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(224, 0, 0)); table.addCell(cell); if (hasPrivToViewPatientNames) { String names = MohTracPortalTag.getPersonNames(Integer.valueOf(o[0].toString())); cell = new PdfPCell(fontselector.process(names + "")); if (names.compareTo("-") == 0) cell.setBackgroundColor(new BaseColor(224, 224, 240)); if (o[2].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(238, 238, 238)); if (o[3].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(224, 0, 0)); table.addCell(cell); } String tracnetId = MohTracPortalTag.personIdentifierByPatientIdAndIdentifierTypeId( Integer.valueOf(o[0].toString()), MohTracConfigurationUtil.getTracNetIdentifierTypeId()); cell = new PdfPCell(fontselector.process(tracnetId + "")); if (tracnetId.compareTo("-") == 0) cell.setBackgroundColor(new BaseColor(224, 224, 240)); if (o[2].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(238, 238, 238)); if (o[3].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(224, 0, 0)); table.addCell(cell); String cohortId = MohTracPortalTag.personIdentifierByPatientIdAndIdentifierTypeId( Integer.valueOf(o[0].toString()), MohTracConfigurationUtil.getLocalHealthCenterIdentifierTypeId()); cell = new PdfPCell(fontselector.process(cohortId + "")); if (cohortId.compareTo("-") == 0) cell.setBackgroundColor(new BaseColor(224, 224, 240)); if (o[2].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(238, 238, 238)); if (o[3].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(224, 0, 0)); table.addCell(cell); cell = new PdfPCell(fontselector.process(sdf.format(o[1]) + "")); if (o[2].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(238, 238, 238)); if (o[3].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(224, 0, 0)); table.addCell(cell); String numberOfEncounters = MohTracPortalTag .getNumberOfEncounterByPatient(Integer.valueOf(o[0].toString())); cell = new PdfPCell(fontselector.process(numberOfEncounters + "")); if (numberOfEncounters.compareTo("-") == 0) cell.setBackgroundColor(new BaseColor(224, 224, 240)); if (o[2].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(238, 238, 238)); if (o[3].toString().compareTo("1") == 0) cell.setBackgroundColor(new BaseColor(224, 0, 0)); table.addCell(cell); } document.add(table); document.close(); log.info("pdf file created"); }
From source file:org.opensrp.web.utils.PdfUtil.java
License:Open Source License
public static ByteArrayOutputStream generatePdf(List<String> data, int width, int height, int copiesImage, int columnLimit) { try {// ww w . ja v a 2 s .c o m ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); Document document = new Document(); document.setMargins(MARGINS[0], MARGINS[1], MARGINS[2], MARGINS[3]); PdfWriter.getInstance(document, byteArrayOutputStream); document.open(); PdfPTable table = new PdfPTable(columnLimit); table.setTotalWidth(TABLE_WIDTH); table.setHorizontalAlignment(Element.ALIGN_LEFT); int length = 0; int count = 0; for (String str : data) { if (str.length() > 0 && str.length() <= 5) { length = 54; } else if (str.length() >= 6 && str.length() <= 9) { length = 44; } else if (str.length() >= 10 && str.length() <= 11) { length = 36; } else if (str.length() >= 12 && str.length() <= 14) { length = 27; } else if (str.length() >= 15 && str.length() <= 17) { length = 22; } else { length = 15; } Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>(); hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); QRCodeWriter qrCodeWriter = new QRCodeWriter(); BitMatrix byteMatrix = null; byteMatrix = qrCodeWriter.encode(str, BarcodeFormat.QR_CODE, width, height, hintMap); int matrixWidth = byteMatrix.getWidth(); int matrixHeight = byteMatrix.getHeight(); BufferedImage image = new BufferedImage(matrixWidth, matrixHeight, BufferedImage.TYPE_INT_RGB); image.createGraphics(); Graphics2D graphics = (Graphics2D) image.getGraphics(); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, matrixWidth + 5, matrixHeight + 5); graphics.setFont(graphics.getFont().deriveFont(13f)); graphics.setColor(Color.BLACK); graphics.drawString(str, length, height - 10); for (int i = 0; i < matrixHeight; i++) { for (int j = 0; j < matrixHeight; j++) { if (byteMatrix.get(i, j)) { graphics.fillRect((i), j, 1, 1); } } } Image itextImage = null; itextImage = Image.getInstance(Toolkit.getDefaultToolkit().createImage(image.getSource()), null); for (int i = 0; i < copiesImage; i++) { PdfPCell cell = new PdfPCell(itextImage); cell.setBorder(Rectangle.NO_BORDER); count++; table.addCell(cell); } } for (int i = 0; i < 6; i++) { if (count % columnLimit != 0) { PdfPCell cell = new PdfPCell(new Phrase()); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); count++; } } document.add(table); document.close(); return byteArrayOutputStream; } catch (Exception e) { return null; } }
From source file:org.qnot.passtab.PDFOutput.java
License:Open Source License
private void createPDF(OutputStream out, String[][] array) throws IOException, DocumentException { Document document = new Document(PageSize.LETTER.rotate()); PdfWriter.getInstance(document, out); document.open();/*from ww w . j ava 2 s . c om*/ PdfPTable table = new PdfPTable(array[0].length); table.setTotalWidth((float) array.length * PDFOutput.CELL_WIDTH); table.setLockedWidth(true); table.setHorizontalAlignment(Element.ALIGN_CENTER); for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[0].length; j++) { addCell(table, array[i][j], (j % 2) != 0, (i % 2) != 0, j == 0, i == 0); } } document.add(table); document.close(); }
From source file:pdf.FooterHeader.java
License:Open Source License
@Override public void onEndPage(PdfWriter writer, Document document) { PdfPTable table = new PdfPTable(3); try {/*from w ww.j a v a 2 s .c o m*/ if (document.getPageNumber() > 1) { table.setWidths(new int[] { 24, 24, 2 }); table.setTotalWidth(527); table.setLockedWidth(true); table.getDefaultCell().setFixedHeight(20); table.getDefaultCell().setBorder(Rectangle.BOTTOM); table.addCell(header); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(String.format("Seite %d von", writer.getPageNumber())); PdfPCell cell = new PdfPCell(Image.getInstance(total)); cell.setBorder(Rectangle.BOTTOM); table.addCell(cell); table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent()); } } catch (DocumentException de) { throw new ExceptionConverter(de); } PdfContentByte cb = writer.getDirectContent(); if (document.getPageNumber() > 1) { footer = new Phrase(document.getPageNumber() - 2); ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, footer, (document.right() - document.left() - 30) / 2 + document.leftMargin(), document.bottom() + 10, 0); } }
From source file:PDF.Reportes.java
public static ArrayList<PdfPTable> tablaAspAula(String usuario, String contra, String horario, int opc) throws DocumentException { ArrayList<PdfPTable> tablas = new ArrayList(); // IngresoAbd bd = new IngresoAbd(usuario, contra); List<Beans.Reportes> reportes = ReportesDAO.AspPAula(usuario, contra, horario, opc); PdfPTable table = new PdfPTable(2); // reportes = bd.AspPAula(horario, opc); PdfPCell cell;/* w w w . ja v a2 s. c o m*/ String carrera = "", fecha = ""; if (reportes.isEmpty()) { cell = new PdfPCell( new Phrase("Lo sentimos, por el momento an no existe informacin para este reporte.")); cell.setColspan(5); table.addCell(cell); tablas.add(table); } else if (reportes.get(0).getCodError() != 0) { if (reportes.get(0).getCodError() == -1) { cell = new PdfPCell(new Phrase(Constants.ERROR1)); cell.setColspan(5); table.addCell(cell); } if (reportes.get(0).getCodError() == -2) { cell = new PdfPCell(new Phrase(Constants.ERROR3)); cell.setColspan(5); table.addCell(cell); } if (reportes.get(0).getCodError() == -3) { cell = new PdfPCell(new Phrase(Constants.ERROR2)); cell.setColspan(5); table.addCell(cell); } tablas.add(table); } else { table = new PdfPTable(5); BaseColor color = new BaseColor(217, 217, 217); BaseColor colorB = new BaseColor(0, 0, 0); cell = new PdfPCell(new Phrase("Ficha(5)", FontFactory.getFont("arial", 12, colorB))); cell.setMinimumHeight(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(color); cell.setBorderColor(colorB); table.addCell(cell); cell = new PdfPCell(new Phrase("Folio Ceneval(6)", FontFactory.getFont("arial", 12, colorB))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(color); cell.setBorderColor(colorB); table.addCell(cell); cell = new PdfPCell(new Phrase("Nombre(7)", FontFactory.getFont("arial", 12, colorB))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(color); cell.setBorderColor(colorB); table.addCell(cell); // cell = new PdfPCell(new Phrase("Nombre carrera", FontFactory.getFont("arial", 12, colorB))); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setBackgroundColor(color); // cell.setBorderColor(colorB); // table.addCell(cell); cell = new PdfPCell(new Phrase("Asistencia(8)", FontFactory.getFont("arial", 12, colorB))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(color); cell.setBorderColor(colorB); cell.setColspan(2); table.addCell(cell); // cell = new PdfPCell(new Phrase("Firma", FontFactory.getFont("arial", 12, colorB))); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setBackgroundColor(color); // cell.setBorderColor(colorB); // table.addCell(cell); for (int i = 0; i < reportes.size(); i++) { cell = new PdfPCell(new Phrase(reportes.get(i).getFicha())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase(reportes.get(i).getFolio())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase(reportes.get(i).getNombre(), FontFactory.getFont("arial", 10))); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); carrera = reportes.get(i).getNom_carrera(); // cell = new PdfPCell(new Phrase(reportes.get(i).getAsist())); table.addCell(cell); cell = new PdfPCell(new Phrase(reportes.get(i).getFirma())); table.addCell(cell); fecha = reportes.get(i).getFecha(); if ((i % 34 == 0 || (i + 1) == reportes.size()) && i != 0) { table.setWidthPercentage(110); table.setWidths(new int[] { 25, 30, 120, 15, 15 }); tablas.add(table); table = new PdfPTable(5); } } String datos[] = horario.split(" "); String edificio = datos[0]; String aula = ""; if (edificio.length() == 2) { edificio = datos[0].charAt(0) + ""; aula = datos[0].charAt(1) + ""; } if (edificio.length() == 4) { edificio = datos[0].charAt(0) + "" + datos[0].charAt(1); aula = "" + datos[0].charAt(3); } if (edificio.length() == 5) { edificio = datos[0].charAt(0) + "" + datos[0].charAt(1); aula = "" + datos[0].charAt(3) + datos[0].charAt(4); } PdfPTable tableH = new PdfPTable(7); tableH.setTotalWidth(500); cell.setMinimumHeight(20); cell = new PdfPCell(new Phrase("CARRERA:(1)", FontFactory.getFont("arial", 11))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); tableH.addCell(cell); cell = new PdfPCell(new Phrase(carrera)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); tableH.addCell(cell); cell = new PdfPCell(new Phrase("FECHA DE EXAMEN:(2)", FontFactory.getFont("arial", 11))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); tableH.addCell(cell); cell = new PdfPCell(new Phrase(fecha)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableH.addCell(cell); cell = new PdfPCell(new Phrase("EDIFICIO:(3)", FontFactory.getFont("arial", 11))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableH.addCell(cell); cell = new PdfPCell(new Phrase(edificio)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableH.addCell(cell); cell = new PdfPCell(new Phrase("AULA:(4)", FontFactory.getFont("arial", 11))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableH.addCell(cell); cell = new PdfPCell(new Phrase(aula)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableH.addCell(cell); tablas.add(tableH); } return tablas; }