List of usage examples for com.lowagie.text FontFactory TIMES
String TIMES
To view the source code for com.lowagie.text FontFactory TIMES.
Click Source Link
From source file:com.bytecode.customexporter.PDFCustomExporter.java
@Override public void export(ActionEvent event, String tableId, FacesContext context, String filename, String tableTitle, boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor, MethodExpression postProcessor, boolean subTable) throws IOException { try {/*from w w w .j a va2 s . c o m*/ Document document = new Document(); if (orientation.equalsIgnoreCase("Landscape")) document.setPageSize(PageSize.A4.rotate()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); StringTokenizer st = new StringTokenizer(tableId, ","); while (st.hasMoreElements()) { String tableName = (String) st.nextElement(); UIComponent component = SearchExpressionFacade.resolveComponent(context, event.getComponent(), tableName); if (component == null) { throw new FacesException("Cannot find component \"" + tableName + "\" in view."); } if (!(component instanceof DataTable || component instanceof DataList)) { throw new FacesException("Unsupported datasource target:\"" + component.getClass().getName() + "\", exporter must target a PrimeFaces DataTable/DataList."); } if (preProcessor != null) { preProcessor.invoke(context.getELContext(), new Object[] { document }); } if (!document.isOpen()) { document.open(); } if (tableTitle != null && !tableTitle.isEmpty() && !tableId.contains("" + ",")) { Font tableTitleFont = FontFactory.getFont(FontFactory.TIMES, encodingType, Font.DEFAULTSIZE, Font.BOLD); Paragraph title = new Paragraph(tableTitle, tableTitleFont); document.add(title); Paragraph preface = new Paragraph(); addEmptyLine(preface, 3); document.add(preface); } PdfPTable pdf; DataList list = null; DataTable table = null; if (component instanceof DataList) { list = (DataList) component; pdf = exportPDFTable(context, list, pageOnly, encodingType); } else { table = (DataTable) component; pdf = exportPDFTable(context, table, pageOnly, selectionOnly, encodingType, subTable); } if (pdf != null) { document.add(pdf); } // add a couple of blank lines Paragraph preface = new Paragraph(); addEmptyLine(preface, datasetPadding); document.add(preface); if (postProcessor != null) { postProcessor.invoke(context.getELContext(), new Object[] { document }); } } document.close(); writePDFToResponse(context.getExternalContext(), baos, filename); } catch (DocumentException e) { throw new IOException(e.getMessage()); } }
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected void createCustomFonts(String encoding) { if (fontName != null && FontFactory.getFont(fontName).getBaseFont() != null) { this.cellFont = FontFactory.getFont(fontName, encoding); this.facetFont = FontFactory.getFont(fontName, encoding, Font.DEFAULTSIZE, Font.BOLD); } else {/*from ww w . ja v a 2 s. c om*/ this.cellFont = FontFactory.getFont(FontFactory.TIMES, encoding); this.facetFont = FontFactory.getFont(FontFactory.TIMES, encoding, Font.DEFAULTSIZE, Font.BOLD); } if (facetFontColor != null) { this.facetFont.setColor(facetFontColor); } if (facetFontSize != null) { this.facetFont.setSize(facetFontSize); } if (facetFontStyle != null) { this.facetFont.setStyle(facetFontStyle); } if (cellFontColor != null) { this.cellFont.setColor(cellFontColor); } if (cellFontSize != null) { this.cellFont.setSize(cellFontSize); } if (cellFontStyle != null) { this.cellFont.setStyle(cellFontStyle); } }
From source file:com.centurylink.mdw.designer.pages.ExportHelper.java
License:Apache License
private void initialize(boolean isUseCase) { chapterFont = FontFactory.getFont(FontFactory.TIMES, isUseCase ? 16 : 20, Font.BOLD, new Color(0, 0, 0)); sectionFont = FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLD, new Color(0, 0, 0)); subSectionFont = FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)); normalFont = FontFactory.getFont(FontFactory.TIMES, 12, Font.NORMAL, new Color(0, 0, 0)); boldFont = FontFactory.getFont(FontFactory.TIMES, 12, Font.BOLD, new Color(0, 0, 0)); fixedWidthFont = FontFactory.getFont(FontFactory.COURIER, 11, Font.NORMAL, new Color(0, 0, 0)); excludedAttributes = new HashSet<String>(); excludedAttributes.add(WorkAttributeConstant.LOGICAL_ID); excludedAttributes.add(WorkAttributeConstant.REFERENCE_ID); excludedAttributes.add(WorkAttributeConstant.WORK_DISPLAY_INFO); excludedAttributes.add(WorkAttributeConstant.REFERENCES); excludedAttributes.add(WorkAttributeConstant.DOCUMENTATION); excludedAttributes.add(WorkAttributeConstant.SIMULATION_STUB_MODE); excludedAttributes.add(WorkAttributeConstant.SIMULATION_RESPONSE); excludedAttributes.add(WorkAttributeConstant.DESCRIPTION); excludedAttributes.add(WorkAttributeConstant.BAM_START_MSGDEF); excludedAttributes.add(WorkAttributeConstant.BAM_FINISH_MSGDEF); excludedAttributesForSpecificValues = new HashMap<String, String>(); excludedAttributesForSpecificValues.put("DoNotNotifyCaller", "false"); excludedAttributesForSpecificValues.put("DO_LOGGING", "True"); tabularAttributes = new HashMap<String, List<String>>(); tabularAttributes.put("Notices", Arrays.asList(new String[] { "Outcome", "Template", "Notifier Class(es)" })); tabularAttributes.put("Variables", Arrays.asList(new String[] { "Variable", "ReferredAs", "Display", "Seq.", "Index" })); tabularAttributes.put("WAIT_EVENT_NAMES", Arrays.asList(new String[] { "Event Name", "Completion Code", "Recurring" })); tabularAttributes.put("variables", Arrays.asList(new String[] { "=", "SubProcess Variable", "Binding Expression" })); tabularAttributes.put("processmap", Arrays.asList(new String[] { "=", "Logical Name", "Process Name", "Process Version" })); tabularAttributes.put("Bindings", Arrays.asList(new String[] { "=", "Variable", "LDAP Attribute" })); tabularAttributes.put("Parameters", Arrays.asList(new String[] { "=", "Input Variable", "Binding Expression" })); textboxAttributes = new HashMap<String, String>(); textboxAttributes.put("Rule", "Code"); textboxAttributes.put("Java", "Java"); textboxAttributes.put("PreScript", "Pre-Script"); textboxAttributes.put("PostScript", "Post-Script"); }
From source file:com.centurylink.mdw.designer.pages.ExportHelper.java
License:Apache License
private void printNodePdf(Node node, Chapter chapter) throws Exception { Section section;//from w w w. j ava2s .c om String id = node.getDisplayId(nodeIdType); if (id == null || id.length() == 0) id = node.getId().toString(); String tmp = "Activity " + id + ": \"" + node.getName().replace('\n', ' ') + "\n"; Paragraph sTitle = new Paragraph(tmp, sectionFont); section = chapter.addSection(sTitle, options.contains(SECTION_NUMBER) ? 2 : 0); String summary = node.getAttribute(WorkAttributeConstant.DESCRIPTION); if (summary != null && summary.length() > 0) { printBoldParagraphsPdf(section, summary); } if (options.contains(DOCUMENTATION)) { String detail = node.getAttribute(WorkAttributeConstant.DOCUMENTATION); if (detail != null && detail.length() > 0) { printHtmlParagraphsPdf(section, detail, options.contains(SECTION_NUMBER) ? 2 : 0); section.add(new Paragraph("\n", FontFactory.getFont(FontFactory.TIMES, 4, Font.NORMAL, new Color(0, 0, 0)))); } } if (options.contains(ATTRIBUTES) && !node.getAttributes().isEmpty()) { printAttributesPdf(section, node.getAttributes(), options.contains(SECTION_NUMBER) ? 2 : 0); } section.add(new Paragraph("\n", normalFont)); }
From source file:com.crm.webapp.util.PDFCustomExporter.java
License:Apache License
@Override public void export(ActionEvent event, String tableId, FacesContext context, String filename, String tableTitle, boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor, MethodExpression postProcessor, boolean subTable) throws IOException { try {// w w w .j ava 2s .c om Document document = new Document(); if (orientation.equalsIgnoreCase("Landscape")) { document.setPageSize(PageSize.A4.rotate()); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); StringTokenizer st = new StringTokenizer(tableId, ","); while (st.hasMoreElements()) { String tableName = (String) st.nextElement(); UIComponent component = SearchExpressionFacade.resolveComponent(context, event.getComponent(), tableName); if (component == null) { throw new FacesException("Cannot find component \"" + tableName + "\" in view."); } if (!(component instanceof DataTable || component instanceof DataList)) { throw new FacesException("Unsupported datasource target:\"" + component.getClass().getName() + "\", exporter must target a PrimeFaces DataTable/DataList."); } if (preProcessor != null) { preProcessor.invoke(context.getELContext(), new Object[] { document }); } if (!document.isOpen()) { document.open(); } if (tableTitle != null && !tableTitle.isEmpty() && !tableId.contains("" + ",")) { Font tableTitleFont = FontFactory.getFont(FontFactory.TIMES, encodingType, Font.DEFAULTSIZE, Font.BOLD); Paragraph title = new Paragraph(tableTitle, tableTitleFont); document.add(title); Paragraph preface = new Paragraph(); addEmptyLine(preface, 3); document.add(preface); } PdfPTable pdf; DataList list = null; DataTable table = null; if (component instanceof DataList) { list = (DataList) component; pdf = exportPDFTable(context, list, pageOnly, encodingType); } else { table = (DataTable) component; pdf = exportPDFTable(context, table, pageOnly, selectionOnly, encodingType, subTable); } if (pdf != null) { document.add(pdf); } // add a couple of blank lines Paragraph preface = new Paragraph(); addEmptyLine(preface, datasetPadding); document.add(preface); if (postProcessor != null) { postProcessor.invoke(context.getELContext(), new Object[] { document }); } } document.close(); writePDFToResponse(context.getExternalContext(), baos, filename); } catch (DocumentException e) { throw new IOException(e.getMessage()); } }
From source file:com.crm.webapp.util.PDFCustomExporter.java
License:Apache License
protected void createCustomFonts(String encoding) { this.cellFont = FontFactory.getFont(FontFactory.TIMES, encoding); this.facetFont = FontFactory.getFont(FontFactory.TIMES, encoding, Font.DEFAULTSIZE, Font.BOLD); if (facetFontColor != null) { this.facetFont.setColor(facetFontColor); }/*from w w w.j a va 2s . co m*/ if (facetFontSize != null) { this.facetFont.setSize(facetFontSize); } if (facetFontStyle != null) { this.facetFont.setStyle(facetFontStyle); } if (cellFontColor != null) { this.cellFont.setColor(cellFontColor); } if (cellFontSize != null) { this.cellFont.setSize(cellFontSize); } if (cellFontStyle != null) { this.cellFont.setStyle(cellFontStyle); } if (fontName != null) { cellFont.setFamily(fontName); facetFont.setFamily(fontName); } }
From source file:de.maklerpoint.office.Schnittstellen.PDF.ExportListePDF.java
License:Open Source License
public void write() throws DocumentException, FileNotFoundException { SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Document doc = null;/* w w w . jav a2 s .c om*/ if (titles.length > 7) doc = new Document(PageSize.A4.rotate(), 20, 20, 20, 20); else doc = new Document(PageSize.A4, 20, 20, 20, 20); PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(filename)); doc.addAuthor("MaklerPoint - www.maklerpoint.de"); doc.addCreator("MaklerPoint - www.maklerpoint.de"); doc.addCreationDate(); doc.addTitle(title); doc.open(); doc.add(new Paragraph(title, FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, Color.BLACK))); Table t = new Table(titles.length, data.length + 1); t.setPadding(3); t.setSpacing(0); t.setBorderWidth(1); for (int i = 0; i < titles.length; i++) { Cell c1 = new Cell(titles[i]); c1.setHeader(true); t.addCell(c1); } t.endHeaders(); for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[i].length; j++) { Cell c1 = null; if (data[i][j] != null) c1 = new Cell(data[i][j].toString()); else c1 = new Cell(""); t.addCell(c1); } } doc.add(t); if (footer == null) { doc.add(new Paragraph( ("Export " + title + " - Genereriert am " + df.format(new Date(System.currentTimeMillis()))) + " von MaklerPoint", FontFactory.getFont(FontFactory.TIMES, 10, Font.NORMAL, Color.black))); } else { doc.add(new Paragraph(footer, FontFactory.getFont(FontFactory.TIMES, 10, Font.NORMAL, Color.black))); } doc.close(); }
From source file:ec.edu.chyc.manejopersonal.managebean.PDFCustomExporter.java
License:Apache License
@Override public void export(ActionEvent event, String tableId, FacesContext context, String filename, String tableTitle, boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor, MethodExpression postProcessor, boolean subTable) throws IOException { try {//from www . jav a2 s . c o m Document document = new Document(); if (orientation.equalsIgnoreCase("Landscape")) { document.setPageSize(PageSize.A4.rotate()); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); StringTokenizer st = new StringTokenizer(tableId, ","); while (st.hasMoreElements()) { String tableName = (String) st.nextElement(); UIComponent component = SearchExpressionFacade.resolveComponent(context, event.getComponent(), tableName); if (component == null) { throw new FacesException("Cannot find component \"" + tableName + "\" in view."); } if (!(component instanceof DataTable || component instanceof DataList)) { throw new FacesException("Unsupported datasource target:\"" + component.getClass().getName() + "\", exporter must target a PrimeFaces DataTable/DataList."); } if (preProcessor != null) { preProcessor.invoke(context.getELContext(), new Object[] { document }); } if (!document.isOpen()) { document.open(); } if (tableTitle != null && !tableTitle.isEmpty() && !tableId.contains("" + ",")) { Font tableTitleFont = FontFactory.getFont(FontFactory.TIMES, encodingType, Font.DEFAULTSIZE, Font.BOLD); Paragraph title = new Paragraph(tableTitle, tableTitleFont); document.add(title); Paragraph preface = new Paragraph(); addEmptyLine(preface, 3); document.add(preface); } PdfPTable pdf; DataList list = null; DataTable table = null; if (component instanceof DataList) { list = (DataList) component; pdf = exportPDFTable(context, list, pageOnly, encodingType); } else { table = (DataTable) component; pdf = exportPDFTable(context, table, pageOnly, selectionOnly, encodingType, subTable); } if (pdf != null) { document.add(pdf); } // add a couple of blank lines Paragraph preface = new Paragraph(); addEmptyLine(preface, datasetPadding); document.add(preface); if (postProcessor != null) { postProcessor.invoke(context.getELContext(), new Object[] { document }); } } document.close(); writePDFToResponse(context.getExternalContext(), baos, filename); } catch (DocumentException e) { throw new IOException(e.getMessage()); } }
From source file:ec.edu.uce.erp.web.common.util.CustomPDFExporter.java
@Override protected void addColumnFacets(DataTable table, PdfPTable pdfTable, ColumnType columnType) { for (UIColumn col : table.getColumns()) { if (!col.isRendered()) { continue; }//from ww w . ja v a 2 s.c o m if (col instanceof DynamicColumn) { ((DynamicColumn) col).applyModel(); } if (col.isExportable()) { addHeaderValue(pdfTable, col.getFacet(columnType.facet()), FontFactory.getFont(FontFactory.TIMES, "iso-8859-1", Font.DEFAULTSIZE, Font.BOLD)); } } }
From source file:mx.avanti.siract.ui.RACTBeanUI.java
public void postProcessPDF(Object document) throws IOException, DocumentException { final Document pdf = (Document) document; TreeNode[] selectedNodesPDF = selectedNodes; if (selectedNodes != null) { for (TreeNode nodo : selectedNodes) { System.out.println("*********************" + ((NodoMultiClass) nodo.getData()).getNombre()); }//from ww w . j av a2 s. c o m } pdf.setPageSize(PageSize.A4.rotate()); pdf.open(); String nombrep = profesor.getPronombre() + " " + profesor.getProapellidoPaterno() + " " + profesor.getProapellidoMaterno(); String numEmpPro = Integer.toString(profesor.getPronumeroEmpleado()); String porAv = Float.toString(porcentajeAvance); SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); //Obtener el nombre del programa educativo seleccionado String nombreProgEdu = ""; int programaEducativoSeleccionado2 = Integer.parseInt(programaEducativoSeleccionado); for (int x = 0; x < programasEducativos.size(); x++) { if (programasEducativos.get(x).getPedid() == programaEducativoSeleccionado2) { nombreProgEdu = programasEducativos.get(x).getPednombre(); } } //---------------------------------------------------------------------------------- //Obtener el nombre de la unidad de aprendizaje y clave seleccionada String nombreUniApr = ""; String nombreclave = ""; int uniAprselec2 = Integer.parseInt(unidadAprendizajeSeleccionada); for (int x = 0; x < unidadesaprendisaje.size(); x++) { if (unidadesaprendisaje.get(x).getUapclave() == uniAprselec2) { nombreUniApr = unidadesaprendisaje.get(x).getUapnombre(); nombreclave = Integer.toString(unidadesaprendisaje.get(x).getUapclave()); } } //---------------------------------------------------------------------- // rutaImagen es la ruta para acceder a la imagen guardada en el folder resources del proyecto try { // Image imagenLogo = Image.getInstance("C:\\Users\\Y\\Desktop\\RACT 22-01-2015\\RACT\\build\\web\\resources\\imagenes\\logo.jpg"); Image imagenLogo = Image.getInstance(RACTBeanUI.class.getResource("imagenes/logo.jpg")); //Posicion de imagen (Horizontal, Vertiacal) imagenLogo.setAbsolutePosition(120f, 460f); //Tamao de imagen (Ancho, largo) imagenLogo.scaleAbsolute(90, 120); //imagenLogo.scaleAbsoluteWidth(100f); //imagenLogo.scaleAbsoluteHeight(150f); //imagenLogo.scaleToFit(100f, 120f); Esta es la buena //Image imagenLogo = Image.getInstance("http://ed.uabc.mx/sed/images/logo.jpg"); //imagenLogo.scaleAbsolute(70f, 90f); pdf.add(imagenLogo); } catch (Exception exception) { System.out.println("****NO SE ENCONTRO LA RUTA DE IMAGEN ESPECIFICADA"); } //Tabla con UABC y Nombre del profesor(a) PdfPTable pdfTabletitulo = new PdfPTable(2); pdfTabletitulo.getDefaultCell().setBorder(PdfPCell.NO_BORDER); PdfPTable pdfTabletitulo2 = new PdfPTable(2); pdfTabletitulo2.getDefaultCell().setBorder(PdfPCell.NO_BORDER); Paragraph UABC = new Paragraph("Universidad Autnoma de Baja California", FontFactory.getFont(FontFactory.TIMES, 22, Font.BOLD, new Color(0, 113, 65))); UABC.setAlignment(Element.ALIGN_CENTER); Paragraph esp = new Paragraph(" "); pdf.add(UABC); pdf.add(esp); pdf.add(esp); pdf.add(esp); pdf.add(esp); pdfTabletitulo.addCell(new Paragraph("")); pdfTabletitulo.addCell(new Paragraph("")); pdfTabletitulo.addCell(new Paragraph("")); pdfTabletitulo.addCell(new Paragraph("")); pdfTabletitulo.addCell(new Paragraph("")); pdfTabletitulo.addCell(new Paragraph("")); pdfTabletitulo.addCell(new Paragraph("")); pdfTabletitulo.addCell(new Paragraph("")); pdfTabletitulo.addCell(new Paragraph("")); pdfTabletitulo.addCell(new Paragraph("")); pdfTabletitulo.addCell(new Paragraph("Profesor(a): ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdfTabletitulo.addCell(new Paragraph(nombrep)); pdfTabletitulo2.addCell(new Paragraph("Num. de Empleado: ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdfTabletitulo2.addCell(new Paragraph(numEmpPro)); pdfTabletitulo.setHorizontalAlignment(25); //pdfTabletitulo.setHorizontalAlignment(Element.ALIGN_CENTER); //document.add(table); float[] columnWidthsss = new float[] { 4f, 28 }; pdfTabletitulo.setWidths(columnWidthsss); pdf.add(pdfTabletitulo); float[] columnWidthss = new float[] { 10f, 38 }; pdfTabletitulo2.setWidths(columnWidthss); pdf.add(pdfTabletitulo2); pdf.add(new Phrase(" ")); //---------------------------------------------------------------------- //Tabla Cabezera PdfPTable pdftablecabezera = new PdfPTable(4); pdftablecabezera.getDefaultCell().setBorder(PdfPCell.NO_BORDER); PdfPTable pdftablecabezera2 = new PdfPTable(5); pdftablecabezera2.getDefaultCell().setBorder(PdfPCell.NO_BORDER); pdftablecabezera.addCell(new Paragraph("Programa educativo: ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdftablecabezera.addCell(new Paragraph("Fecha: ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdftablecabezera.addCell(new Paragraph("Ciclo Escolar: ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdftablecabezera.addCell(new Paragraph("Avance Global: ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdftablecabezera.addCell(new Paragraph(nombreProgEdu)); pdftablecabezera.addCell(new Paragraph(formato.format(new Date()))); pdftablecabezera.addCell(new Paragraph(" " + cicloEscolar)); pdftablecabezera.addCell(new Paragraph(" " + porAv)); pdftablecabezera.addCell(new Paragraph(" ")); pdftablecabezera.addCell(new Paragraph(" ")); pdftablecabezera.addCell(new Paragraph(" ")); pdftablecabezera.addCell(new Paragraph(" ")); pdftablecabezera2.addCell(new Paragraph("Unidad de Aprendizaje: ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdftablecabezera2.addCell(new Paragraph("Clave: ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdftablecabezera2.addCell(new Paragraph("Grupo: ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdftablecabezera2.addCell(new Paragraph("Subgrupo: ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdftablecabezera2.addCell(new Paragraph("Tipo Grupo: ", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)))); pdftablecabezera2.addCell(new Paragraph(nombreUnidadSeleccionado)); pdftablecabezera2.addCell(new Paragraph(claveUnidadAprendizajeSeleccionada)); pdftablecabezera2.addCell(new Paragraph(" " + grupo)); pdftablecabezera2.addCell(new Paragraph(" " + subGrupo)); String tipoGrupo = ""; switch (this.tipoUnidadAprendizaje) { case "C": tipoGrupo = "Clase"; break; case "L": tipoGrupo = "Laboratorio"; break; case "T": tipoGrupo = "Taller"; break; case "P": tipoGrupo = "Practica"; break; case "CL": tipoGrupo = "Practicas Clinica"; break; } pdftablecabezera2.addCell(new Paragraph(" " + tipoGrupo)); pdftablecabezera2.addCell(new Paragraph(" ")); pdftablecabezera.setHorizontalAlignment(25); float[] columnWidths = new float[] { 38f, 10f, 14f, 18f }; pdftablecabezera.setWidths(columnWidths); pdf.add(pdftablecabezera); pdftablecabezera2.setHorizontalAlignment(25); float[] columnWidthss2 = new float[] { 38f, 10f, 8f, 11f, 14f }; pdftablecabezera2.setWidths(columnWidthss2); pdf.add(pdftablecabezera2); pdf.add(new Phrase(" ")); //---------------------------------------------------------------------- Paragraph numrep = new Paragraph("Reporte # " + numeroReporte, FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLD, new Color(0, 0, 0))); numrep.setAlignment(Element.ALIGN_CENTER); pdf.add(numrep); pdf.add(new Paragraph(" ")); //Tabla con Datos PdfPTable pdfTable = new PdfPTable(3); pdfTable.addCell(new Phrase("Nombre", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(0, 0, 0)))); pdfTable.addCell(new Phrase("Porcentaje", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(0, 0, 0)))); pdfTable.addCell(new Phrase("Observaciones", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(0, 0, 0)))); //Evitar Null pointer exception por no tener nodoes en selectedNodes //Se utiliza un auxiliar de selectedNodes por que hay posibilidad de que selectedNodes se modifique durante el proceso de generacion del PDF if (selectedNodesPDF != null && selectedNodesPDF.length > 0) { //Regresar a lo basicoString int nns = selectedNodesPDF.length; String[] ns = new String[nns]; for (int x = 0; x < selectedNodesPDF.length; x++) { ns[x] = ((NodoMultiClass) selectedNodesPDF[x].getData()).getNumero() + "--" + ((NodoMultiClass) selectedNodes[x].getData()).getNombre() + "--" + ((NodoMultiClass) selectedNodes[x].getData()).getPorcentajeAvance() + "--" + ((NodoMultiClass) selectedNodes[x].getData()).getObservaciones() + " -- "; } String[] filas = new String[4]; String[] nstr = new String[3]; String[] filas2 = new String[4]; String[] nstr2 = new String[3]; for (int x = 1; x < ns.length; x++) { for (int y = 0; y < ns.length - x; y++) { //Obtengo los valores para hacer las comparaciones int[] n = new int[3]; int[] n2 = new int[3]; filas = ns[y].split("--"); nstr = filas[0].split("\\."); for (int z = 0; z < nstr.length; z++) { if (nstr == null) { n[z] = 0; } else { n[z] = Integer.parseInt(nstr[z]); } } filas2 = ns[y + 1].split("--"); nstr2 = filas2[0].split("\\."); for (int z = 0; z < nstr2.length; z++) { if (nstr2 == null) { n2[z] = 0; } else { n2[z] = Integer.parseInt(nstr2[z]); } } //-------------------------------------------------comparacion if (n[0] == n2[0]) { if (n[1] == n2[1]) { if (n[2] > n2[2]) { String aux = ns[y]; ns[y] = ns[y + 1]; ns[y + 1] = aux; } } else { if (n[1] > n2[1]) { String aux = ns[y]; ns[y] = ns[y + 1]; ns[y + 1] = aux; } } } else { if (n[0] > n2[0]) { String aux = ns[y]; ns[y] = ns[y + 1]; ns[y + 1] = aux; } } //------------------------------------------------------------- } } String[] auxNum = new String[4]; for (int x = 0; x < ns.length; x++) { filas = ns[x].split("--"); num = filas[0].split("\\."); //Auxiliar para agregar padre de tema/subtema int auxMargen = 1; //Agregar unidad a la que pertenece el tema/subtema String[] auxNum2 = auxNum; int tamanoArbol = root.getChildCount(); //AGREGAR A TEMA if (Integer.parseInt(num[0]) > tamanoArbol) { auxMargen = Integer.parseInt(num[0]) - tamanoArbol; } if (num.length >= 2 && auxNum2[0] != null && !auxNum2[0].equals(num[0])) { if (!num[1].equals("0")) { while (!num[0].equals(auxNum2[0]) && auxMargen > 0) { System.out.println("XXXXXXIteracion para encontrar padre XXXXXXX 0" + auxMargen); auxNum2 = (((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getData()).getNumero()).split("\\."); //if(auxNum[0]!=null&&Integer.parseInt(num[0])>Integer.parseInt(auxNum[0])){ if (num[0].equals(auxNum2[0])) { } else { auxMargen--; } } System.out.println("***Unidad Padre" + ((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getData()).getNombre()); NodoMultiClass auxNodo = ((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getData()); //UTIL PARA PONER TEXTO TACHADO // Chunk strikethrough = new Chunk("Strikethrough."); // strikethrough.setUnderline(0.1f, 3f); //0.1 thick, 2 y-location // document.add(strikethrough); pdfTable.addCell(new Phrase(auxNodo.getNumero() + ".- " + auxNodo.getNombre(), FontFactory .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151)))); pdfTable.addCell(new Phrase(auxNodo.getPorcentajeAvance(), FontFactory .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151)))); pdfTable.addCell(auxNodo.getObservaciones()); } } else { if (auxNum2[0] == null && num.length >= 2) { auxNum2 = (((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[0]) - auxMargen) .getData()).getNumero()).split("\\."); while (!num[0].equals(auxNum2[0]) && auxMargen > 0) { System.out.println("XXXXXXIteracion para encontrar padre XXXXXXX 0" + auxMargen); auxNum2 = (((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getData()).getNumero()).split("\\."); //if(auxNum[0]!=null&&Integer.parseInt(num[0])>Integer.parseInt(auxNum[0])){ if (num[0].equals(auxNum2[0])) { } else { auxMargen--; } } System.out.println("***Unidad Padre" + ((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getData()).getNombre()); NodoMultiClass auxNodo = ((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getData()); //UTIL PARA PONER TEXTO TACHADO // Chunk strikethrough = new Chunk("Strikethrough."); // strikethrough.setUnderline(0.1f, 3f); //0.1 thick, 2 y-location // document.add(strikethrough); pdfTable.addCell(new Phrase(auxNodo.getNumero() + ".- " + auxNodo.getNombre(), FontFactory .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151)))); pdfTable.addCell(new Phrase(auxNodo.getPorcentajeAvance(), FontFactory .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151)))); pdfTable.addCell(auxNodo.getObservaciones()); } } //AGREGAR A SUBTEMA String[] auxNumeroUnidad = new String[4]; int auxMargen2 = 1; if (num.length == 3 && auxNum[1] != null && !auxNum[1].equals(num[1])) { if (!num[2].equals("0")) { while (!num[0].equals(auxNum[0]) && auxMargen >= 0) { NodoMultiClass auxNodoUnidad = ((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getData()); auxNumeroUnidad = auxNodoUnidad.getNumero().split("\\."); tamanoArbol = root.getChildren().get(Integer.parseInt(num[0])).getChildCount(); if (Integer.parseInt(num[1]) > tamanoArbol) { auxMargen2 = Integer.parseInt(num[1]) - tamanoArbol; } while (auxNumeroUnidad[0].equals(num[0]) && !num[1].equals(auxNum[1]) && auxMargen > 0) { System.out.println("XXXXXXIteracion para encontrar padre XXXXXXX 0" + auxMargen); auxNum = (((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getChildren() .get(Integer.parseInt(num[1]) - auxMargen2).getData()).getNumero()) .split("\\."); //if(auxNum[0]!=null&&Integer.parseInt(num[0])>Integer.parseInt(auxNum[0])){ if (num[1].equals(auxNum[1])) { } else { auxMargen2--; } } // auxNum = (((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[1]) - auxMargen).getData()).getNumero()).split("\\."); if (num[0].equals(auxNum[0])) { } else { auxMargen--; } } System.out.println("*****Unidad Padre(SUBTEMA)" + ((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[0]) - auxMargen) .getChildren().get(Integer.parseInt(num[1]) - auxMargen2).getData()) .getNombre()); NodoMultiClass auxNodo = ((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getChildren() .get(Integer.parseInt(num[1]) - auxMargen2).getData()); //UTIL PARA PONER TEXTO TACHADO // Chunk strikethrough = new Chunk("Strikethrough."); // strikethrough.setUnderline(0.1f, 3f); //0.1 thick, 2 y-location // document.add(strikethrough); pdfTable.addCell( new Phrase(" " + auxNodo.getNumero() + ".- " + auxNodo.getNombre(), FontFactory .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151)))); pdfTable.addCell(new Phrase(auxNodo.getPorcentajeAvance(), FontFactory .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151)))); pdfTable.addCell(auxNodo.getObservaciones()); } } else { if (auxNum[0] == null && num.length == 3) { auxNum = (((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[0]) - auxMargen) .getData()).getNumero()).split("\\."); while (!num[0].equals(auxNum[0]) && auxMargen > 0) { NodoMultiClass auxNodoUnidad = ((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getData()); auxNumeroUnidad = auxNodoUnidad.getNumero().split("\\."); tamanoArbol = root.getChildren().get(Integer.parseInt(num[0])).getChildCount(); if (Integer.parseInt(num[1]) > tamanoArbol) { auxMargen2 = Integer.parseInt(num[1]) - tamanoArbol; } while (auxNumeroUnidad[0].equals(num[0]) && !num[1].equals(auxNum[1]) && auxMargen > 0) { System.out.println("Iteracion para encontrar padre XXXXXXX 0" + auxMargen); auxNum = (((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getChildren() .get(Integer.parseInt(num[1]) - auxMargen2).getData()).getNumero()) .split("\\."); //if(auxNum[0]!=null&&Integer.parseInt(num[0])>Integer.parseInt(auxNum[0])){ if (num[1].equals(auxNum[1])) { } else { auxMargen2--; } } // auxNum = (((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[1]) - auxMargen).getData()).getNumero()).split("\\."); if (num[0].equals(auxNum[0])) { } else { auxMargen--; } } System.out.println("***Unidad Padre(SUBTEMA)" + ((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[0]) - auxMargen) .getChildren().get(Integer.parseInt(num[1]) - auxMargen2).getData()) .getNombre()); NodoMultiClass auxNodo = ((NodoMultiClass) root.getChildren() .get(Integer.parseInt(num[0]) - auxMargen).getChildren() .get(Integer.parseInt(num[1]) - auxMargen2).getData()); //UTIL PARA PONER TEXTO TACHADO // Chunk strikethrough = new Chunk("Strikethrough."); // strikethrough.setUnderline(0.1f, 3f); //0.1 thick, 2 y-location // document.add(strikethrough); pdfTable.addCell( new Phrase(" " + auxNodo.getNumero() + ".- " + auxNodo.getNombre(), FontFactory .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151)))); pdfTable.addCell(new Phrase(auxNodo.getPorcentajeAvance(), FontFactory .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151)))); pdfTable.addCell(auxNodo.getObservaciones()); } } auxNum = num; //FIN AGREGAR PADRE DE TEMA/SUBTEMA boolean banpor = true; if (num.length == 1) { pdfTable.addCell(new Phrase(filas[0] + ".- " + filas[1], FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(0, 0, 0)))); pdfTable.addCell(new Phrase(String.valueOf(dosDecimales(Float.parseFloat(filas[2]))), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(0, 0, 0)))); banpor = false; } if (num.length == 2) { pdfTable.addCell(new Phrase(" " + filas[0] + ".- " + filas[1])); } if (num.length == 3) { pdfTable.addCell(new Phrase(" " + filas[0] + ".- " + filas[1], FontFactory.getFont(FontFactory.TIMES_ITALIC, 12))); pdfTable.addCell(new Phrase(String.valueOf(dosDecimales(Float.parseFloat(filas[2]))), FontFactory.getFont(FontFactory.TIMES_ITALIC, 12))); banpor = false; } if (banpor) { pdfTable.addCell(String.valueOf(dosDecimales(Float.parseFloat(filas[2])))); pdfTable.addCell(filas[3]); } else { pdfTable.addCell(filas[3]); } } } else { pdfTable.addCell("No hay nada seleccionado"); pdfTable.addCell(""); pdfTable.addCell(""); } pdfTable.setHorizontalAlignment(15); float[] columnWidths2 = new float[] { 32f, 8f, 14f }; pdfTable.setWidths(columnWidths2); pdf.add(pdfTable); //---------------------------------------------------------------------- }