List of usage examples for com.lowagie.text FontFactory getFont
public static Font getFont(String fontname)
Font
-object. From source file:displayStructureAsPDFTable.java
License:Open Source License
private void addTitle(IAtomContainer mol, Phrase phrase) { if (mol.getProperty(CDKConstants.TITLE) == null || mol.getProperty(CDKConstants.TITLE).toString().trim().length() == 0) return;/*ww w . j ava2 s .co m*/ phrase.add(new Chunk(CDKConstants.TITLE + ": ", FontFactory.getFont(FontFactory.HELVETICA_BOLD))); phrase.add( new Chunk(mol.getProperty(CDKConstants.TITLE) + "\n", FontFactory.getFont(FontFactory.HELVETICA))); }
From source file:displayStructureAsPDFTable.java
License:Open Source License
private void addProperty(Object propertyLabel, IAtomContainer mol, Phrase phrase) { if (mol.getProperty(propertyLabel) == null || mol.getProperty(propertyLabel).toString().trim().length() == 0) return;//from w w w . j a v a2s. c o m phrase.add(new Chunk(propertyLabel + ": ", FontFactory.getFont(FontFactory.HELVETICA_BOLD))); String value; try { double tmp = Double.parseDouble(mol.getProperty(propertyLabel).toString()); value = decimalFormat.format(tmp); } catch (NumberFormatException nfe) { value = mol.getProperty(propertyLabel).toString(); } phrase.add(new Chunk(value + "\n", FontFactory.getFont(FontFactory.HELVETICA))); }
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 w w w .j av a 2s. co m 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.conecta.sat.utils.BuildAsignaSoftPDF.java
@Override protected void buildPdfDocument(Map<String, Object> map, Document document, PdfWriter writer, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. System.out.println("Into BuildImportTokensPDF"); hsr1.setContentType("application/pdf"); DateFormat name = new SimpleDateFormat("ddMMyyyyhhmmss"); hsr1.setHeader("Content-disposition", "attachment; filename=AsignaToken" + name.format(new Date()) + ".pdf"); AsignaSoftPDF list = (AsignaSoftPDF) map.get("list"); String nombreUsuario = (String) map.get("nombreUsuario"); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100);/*from ww w .java 2 s. c o m*/ table.setSpacingBefore(10); Font font = FontFactory.getFont(FontFactory.HELVETICA); try { font.setFamily(fontName); } catch (Exception e) { font.setFamily("Verdana"); } try { ServletContext servletContext = hsr.getSession().getServletContext(); String relativeWebPath = logoPath; String absoluteDiskPath = servletContext.getRealPath(relativeWebPath); Image logo = Image.getInstance(absoluteDiskPath); // Image logo = Image.getInstance("logo.png"); System.out.println("La imagen se cargo correctamente"); logo.scaleToFit(widthLogo, heightLogo); document.add(logo); } catch (Exception e) { System.err.println("ERROR" + Excepciones.getStackTrace(e)); document.add(new Paragraph("Sin imagen " + logoPath)); } font.setSize(fontSize + 3); Paragraph titulo = new Paragraph("Asignacin de Token a cliente", font); titulo.setAlignment(Element.ALIGN_RIGHT); document.add(titulo); Chunk CONNECT = new Chunk(new LineSeparator(0.5f, 100, java.awt.Color.BLACK, Element.ALIGN_CENTER, 3.5f)); document.add(CONNECT); DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm a"); font.setSize(fontSize + 2); Paragraph fecha = new Paragraph("Asignacin Correcta", font); fecha.setAlignment(Element.ALIGN_CENTER); document.add(fecha); // Paragraph pNombre = new Paragraph( nombreUsuario , font); // pNombre.setAlignment(Element.ALIGN_RIGHT); // document.add(pNombre); font.setSize(fontSize); font.setColor(java.awt.Color.white); // define table header cell PdfPCell cell = new PdfPCell(); java.awt.Color color = java.awt.Color.LIGHT_GRAY; cell.setBackgroundColor(color); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Nombre empleado", font)); table.addCell(cell); cell.setPhrase(new Phrase("Fecha y Hora", font)); table.addCell(cell); cell.setPhrase(new Phrase("Cliente", font)); table.addCell(cell); cell.setPhrase(new Phrase("Token", font)); table.addCell(cell); cell.setPhrase(new Phrase("Tipo de Token", font)); table.addCell(cell); // cell.setPhrase(new Phrase("Centro Financiero", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Tipo", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Cliente nico", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Fecha de ultima modificacin", font)); // table.addCell(cell); Font font2 = FontFactory.getFont(FontFactory.HELVETICA); try { font2.setFamily(fontName); } catch (Exception e) { font2.setFamily("Verdana"); } font2.setSize(fontSize); font2.setColor(java.awt.Color.black); // write table row data // for (ImportTokensPDF pdf : list) { // ImportTokensPDF pdf; cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getNombre(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(df.format(list.getFecha()), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getCliente(), font2)); table.addCell(cell); if (list.getToken().length() >= 14) { list.setTipo("SOFTTOKEN"); } else { list.setTipo("HARDTOKEN"); } cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getToken(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getTipo(), font2)); table.addCell(cell); // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getCentro(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getTipo(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getCliente(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getLastUpdate(),font2) ); // table.addCell(cell); // } document.add(table); }
From source file:com.conecta.sat.utils.BuildAsignaTokenCenFinPDF.java
@Override protected void buildPdfDocument(Map<String, Object> map, Document document, PdfWriter writer, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. System.out.println("Into BuildImportTokensPDF"); hsr1.setContentType("application/pdf"); DateFormat name = new SimpleDateFormat("ddMMyyyyhhmmss"); hsr1.setHeader("Content-disposition", "attachment; filename=AsignacionTokensCentroFinanciero" + name.format(new Date()) + ".pdf"); AsignaTokenCenFinPDF list = (AsignaTokenCenFinPDF) map.get("list"); String nombreUsuario = (String) map.get("nombreUsuario"); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100);/*from w ww .ja va2 s . c o m*/ table.setSpacingBefore(10); Font font = FontFactory.getFont(FontFactory.HELVETICA); try { font.setFamily(fontName); } catch (Exception e) { font.setFamily("Verdana"); } try { ServletContext servletContext = hsr.getSession().getServletContext(); String relativeWebPath = logoPath; String absoluteDiskPath = servletContext.getRealPath(relativeWebPath); Image logo = Image.getInstance(absoluteDiskPath); // Image logo = Image.getInstance("logo.png"); System.out.println("La imagen se cargo correctamente"); logo.scaleToFit(widthLogo, heightLogo); document.add(logo); } catch (Exception e) { System.err.println("ERROR" + Excepciones.getStackTrace(e)); document.add(new Paragraph("Sin imagen " + logoPath)); } font.setSize(fontSize + 3); Paragraph titulo = new Paragraph("Asignacin de Hard Token", font); titulo.setAlignment(Element.ALIGN_RIGHT); document.add(titulo); Chunk CONNECT = new Chunk(new LineSeparator(0.5f, 100, java.awt.Color.BLACK, Element.ALIGN_CENTER, 3.5f)); document.add(CONNECT); DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm a"); font.setSize(fontSize + 2); Paragraph fecha = new Paragraph("Asignacin de Tokens a Centro Financiero", font); fecha.setAlignment(Element.ALIGN_CENTER); document.add(fecha); // Paragraph pNombre = new Paragraph( nombreUsuario , font); // pNombre.setAlignment(Element.ALIGN_RIGHT); // document.add(pNombre); font.setSize(fontSize); font.setColor(java.awt.Color.white); // define table header cell PdfPCell cell = new PdfPCell(); java.awt.Color color = java.awt.Color.LIGHT_GRAY; cell.setBackgroundColor(color); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(5); // write table header // cell.setPhrase(new Phrase("Usuario que importo en token", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Fecha y Hora", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Tokens importados", font)); // table.addCell(cell); // cell.setPhrase(new Phrase("Centro Financiero", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Tipo", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Cliente nico", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Fecha de ultima modificacin", font)); // table.addCell(cell); Font font2 = FontFactory.getFont(FontFactory.HELVETICA); try { font2.setFamily(fontName); } catch (Exception e) { font2.setFamily("Verdana"); } font2.setSize(fontSize); font2.setColor(java.awt.Color.black); // write table row data // for (ImportTokensPDF pdf : list) { // ImportTokensPDF pdf; cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase("Nombre empleado", font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getNombre(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase("Fecha de Asignacin", font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(df.format(list.getFecha()), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase("Centro Financiero asignado", font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getCentroFinanciero(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase("Tokens asignados", font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getTokens(), font2)); table.addCell(cell); document.add(table); }
From source file:com.conecta.sat.utils.BuildBitacoraPDF.java
@Override protected void buildPdfDocument(Map<String, Object> map, Document document, PdfWriter writer, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. hsr1.setContentType("application/pdf"); DateFormat name = new SimpleDateFormat("ddMMyyyyhhmmss"); hsr1.setHeader("Content-disposition", "attachment; filename=Bitacora" + name.format(new Date()) + ".pdf"); List<BitacoraPDF> list = (List<BitacoraPDF>) map.get("listBitacora"); String nombreUsuario = (String) map.get("nombreUsuario"); PdfPTable table = new PdfPTable(columnas); table.setWidthPercentage(100);/* ww w. j av a 2s . c o m*/ table.setSpacingBefore(10); Font font = FontFactory.getFont(FontFactory.HELVETICA); try { font.setFamily(fontName); } catch (Exception e) { font.setFamily("Verdana"); } try { ServletContext servletContext = hsr.getSession().getServletContext(); String relativeWebPath = logoPath; String absoluteDiskPath = servletContext.getRealPath(relativeWebPath); Image logo = Image.getInstance(absoluteDiskPath); // Image logo = Image.getInstance("logo.png"); System.out.println("La imagen se cargo correctamente"); logo.scaleToFit(widthLogo, heightLogo); document.add(logo); } catch (Exception e) { System.err.println("ERROR" + Excepciones.getStackTrace(e)); document.add(new Paragraph("Sin imagen " + logoPath)); } font.setSize(fontSize + 3); Paragraph titulo = new Paragraph("Bitcora de Actividades", font); titulo.setAlignment(Element.ALIGN_RIGHT); document.add(titulo); Chunk CONNECT = new Chunk(new LineSeparator(0.5f, 100, java.awt.Color.BLACK, Element.ALIGN_CENTER, 3.5f)); document.add(CONNECT); DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm a"); font.setSize(fontSize + 2); Paragraph fecha = new Paragraph(df.format(new Date()), font); fecha.setAlignment(Element.ALIGN_RIGHT); document.add(fecha); Paragraph pNombre = new Paragraph(nombreUsuario, font); pNombre.setAlignment(Element.ALIGN_RIGHT); document.add(pNombre); font.setSize(fontSize); font.setColor(java.awt.Color.white); // define table header cell PdfPCell cell = new PdfPCell(); java.awt.Color color = java.awt.Color.LIGHT_GRAY; cell.setBackgroundColor(color); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Nombre de usuario", font)); table.addCell(cell); cell.setPhrase(new Phrase("Bitcora", font)); table.addCell(cell); cell.setPhrase(new Phrase("ltima fecha de Modificaciones", font)); table.addCell(cell); Font font2 = FontFactory.getFont(FontFactory.HELVETICA); try { font2.setFamily(fontName); } catch (Exception e) { font2.setFamily("Verdana"); } font2.setSize(fontSize); font2.setColor(java.awt.Color.black); // write table row data df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (BitacoraPDF bitacora : list) { cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(bitacora.getNombre(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(bitacora.getMensaje(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(bitacora.getFecha(), font2)); table.addCell(cell); cell = new PdfPCell(); } document.add(table); }
From source file:com.conecta.sat.utils.BuildDesactivarSoftPDF.java
@Override protected void buildPdfDocument(Map<String, Object> map, Document document, PdfWriter writer, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. System.out.println("Into BuildImportTokensPDF"); hsr1.setContentType("application/pdf"); DateFormat name = new SimpleDateFormat("ddMMyyyyhhmmss"); hsr1.setHeader("Content-disposition", "attachment; filename=DesactivarToken" + name.format(new Date()) + ".pdf"); AsignaSoftPDF list = (AsignaSoftPDF) map.get("list"); String nombreUsuario = (String) map.get("nombreUsuario"); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100);/*w ww . jav a 2s .c o m*/ table.setSpacingBefore(10); Font font = FontFactory.getFont(FontFactory.HELVETICA); try { font.setFamily(fontName); } catch (Exception e) { font.setFamily("Verdana"); } try { ServletContext servletContext = hsr.getSession().getServletContext(); String relativeWebPath = logoPath; String absoluteDiskPath = servletContext.getRealPath(relativeWebPath); Image logo = Image.getInstance(absoluteDiskPath); // Image logo = Image.getInstance("logo.png"); System.out.println("La imagen se cargo correctamente"); logo.scaleToFit(widthLogo, heightLogo); document.add(logo); } catch (Exception e) { System.err.println("ERROR" + Excepciones.getStackTrace(e)); document.add(new Paragraph("Sin imagen " + logoPath)); } font.setSize(fontSize + 3); Paragraph titulo = new Paragraph("Desactivacin de Token a cliente", font); titulo.setAlignment(Element.ALIGN_RIGHT); document.add(titulo); Chunk CONNECT = new Chunk(new LineSeparator(0.5f, 100, java.awt.Color.BLACK, Element.ALIGN_CENTER, 3.5f)); document.add(CONNECT); DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm a"); font.setSize(fontSize + 2); Paragraph fecha = new Paragraph("Cambio de Status Correcto", font); fecha.setAlignment(Element.ALIGN_CENTER); document.add(fecha); // Paragraph pNombre = new Paragraph( nombreUsuario , font); // pNombre.setAlignment(Element.ALIGN_RIGHT); // document.add(pNombre); font.setSize(fontSize); font.setColor(java.awt.Color.white); // define table header cell PdfPCell cell = new PdfPCell(); java.awt.Color color = java.awt.Color.LIGHT_GRAY; cell.setBackgroundColor(color); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Nombre empleado", font)); table.addCell(cell); cell.setPhrase(new Phrase("Fecha y Hora", font)); table.addCell(cell); cell.setPhrase(new Phrase("Cliente", font)); table.addCell(cell); cell.setPhrase(new Phrase("Token", font)); table.addCell(cell); cell.setPhrase(new Phrase("Tipo de Token", font)); table.addCell(cell); // cell.setPhrase(new Phrase("Centro Financiero", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Tipo", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Cliente nico", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Fecha de ultima modificacin", font)); // table.addCell(cell); if (list.getToken().length() < 8) { list.setTipo("SoftToken"); } else { list.setTipo("HardToken"); } Font font2 = FontFactory.getFont(FontFactory.HELVETICA); try { font2.setFamily(fontName); } catch (Exception e) { font2.setFamily("Verdana"); } font2.setSize(fontSize); font2.setColor(java.awt.Color.black); // write table row data // for (ImportTokensPDF pdf : list) { // ImportTokensPDF pdf; cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getNombre(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(df.format(list.getFecha()), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getCliente(), font2)); table.addCell(cell); if (list.getToken().length() > 8) { list.setTipo("SOFTTOKEN"); } else { list.setTipo("HARDTOKEN"); } cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getToken(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getTipo(), font2)); table.addCell(cell); // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getCentro(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getTipo(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getCliente(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getLastUpdate(),font2) ); // table.addCell(cell); // } document.add(table); }
From source file:com.conecta.sat.utils.BuildDesasignaSoftPDF.java
@Override protected void buildPdfDocument(Map<String, Object> map, Document document, PdfWriter writer, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. System.out.println("Into BuildImportTokensPDF"); hsr1.setContentType("application/pdf"); DateFormat name = new SimpleDateFormat("ddMMyyyyhhmmss"); hsr1.setHeader("Content-disposition", "attachment; filename=CancelarToken" + name.format(new Date()) + ".pdf"); AsignaSoftPDF list = (AsignaSoftPDF) map.get("list"); String nombreUsuario = (String) map.get("nombreUsuario"); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100);/*from w w w . ja v a 2 s . c o m*/ table.setSpacingBefore(10); Font font = FontFactory.getFont(FontFactory.HELVETICA); try { font.setFamily(fontName); } catch (Exception e) { font.setFamily("Verdana"); } try { ServletContext servletContext = hsr.getSession().getServletContext(); String relativeWebPath = logoPath; String absoluteDiskPath = servletContext.getRealPath(relativeWebPath); Image logo = Image.getInstance(absoluteDiskPath); // Image logo = Image.getInstance("logo.png"); System.out.println("La imagen se cargo correctamente"); logo.scaleToFit(widthLogo, heightLogo); document.add(logo); } catch (Exception e) { System.err.println("ERROR" + Excepciones.getStackTrace(e)); document.add(new Paragraph("Sin imagen " + logoPath)); } font.setSize(fontSize + 3); Paragraph titulo = new Paragraph("Cancelacin de Token a cliente", font); titulo.setAlignment(Element.ALIGN_RIGHT); document.add(titulo); Chunk CONNECT = new Chunk(new LineSeparator(0.5f, 100, java.awt.Color.BLACK, Element.ALIGN_CENTER, 3.5f)); document.add(CONNECT); DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm a"); font.setSize(fontSize + 2); Paragraph fecha = new Paragraph("Cancelacin Correcta", font); fecha.setAlignment(Element.ALIGN_CENTER); document.add(fecha); // Paragraph pNombre = new Paragraph( nombreUsuario , font); // pNombre.setAlignment(Element.ALIGN_RIGHT); // document.add(pNombre); font.setSize(fontSize); font.setColor(java.awt.Color.white); // define table header cell PdfPCell cell = new PdfPCell(); java.awt.Color color = java.awt.Color.LIGHT_GRAY; cell.setBackgroundColor(color); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Nombre empleado", font)); table.addCell(cell); cell.setPhrase(new Phrase("Fecha y Hora", font)); table.addCell(cell); cell.setPhrase(new Phrase("Cliente", font)); table.addCell(cell); cell.setPhrase(new Phrase("Token", font)); table.addCell(cell); cell.setPhrase(new Phrase("Tipo de Token", font)); table.addCell(cell); // cell.setPhrase(new Phrase("Centro Financiero", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Tipo", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Cliente nico", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Fecha de ultima modificacin", font)); // table.addCell(cell); if (list.getToken().length() < 8) { list.setTipo("SoftToken"); } else { list.setTipo("HardToken"); } Font font2 = FontFactory.getFont(FontFactory.HELVETICA); try { font2.setFamily(fontName); } catch (Exception e) { font2.setFamily("Verdana"); } font2.setSize(fontSize); font2.setColor(java.awt.Color.black); // write table row data // for (ImportTokensPDF pdf : list) { // ImportTokensPDF pdf; cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getNombre(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(df.format(list.getFecha()), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getCliente(), font2)); table.addCell(cell); if (list.getToken().length() == 14) { list.setTipo("SOFTTOKEN"); } else { list.setTipo("HARDTOKEN"); } cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getToken(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getTipo(), font2)); table.addCell(cell); // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getCentro(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getTipo(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getCliente(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getLastUpdate(),font2) ); // table.addCell(cell); // } document.add(table); }
From source file:com.conecta.sat.utils.BuildDesasignaTokenCenFinPDF.java
@Override protected void buildPdfDocument(Map<String, Object> map, Document document, PdfWriter writer, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. System.out.println("Into BuildImportTokensPDF"); hsr1.setContentType("application/pdf"); DateFormat name = new SimpleDateFormat("ddMMyyyyhhmmss"); hsr1.setHeader("Content-disposition", "attachment; filename=DesasignacionTokensCentroFinanciero" + name.format(new Date()) + ".pdf"); DesasignaTokenCenFinPDF list = (DesasignaTokenCenFinPDF) map.get("list"); String nombreUsuario = (String) map.get("nombreUsuario"); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100);/* w ww . ja va 2 s . c om*/ table.setSpacingBefore(10); Font font = FontFactory.getFont(FontFactory.HELVETICA); try { font.setFamily(fontName); } catch (Exception e) { font.setFamily("Verdana"); } try { ServletContext servletContext = hsr.getSession().getServletContext(); String relativeWebPath = logoPath; String absoluteDiskPath = servletContext.getRealPath(relativeWebPath); Image logo = Image.getInstance(absoluteDiskPath); // Image logo = Image.getInstance("logo.png"); System.out.println("La imagen se cargo correctamente"); logo.scaleToFit(widthLogo, heightLogo); document.add(logo); } catch (Exception e) { System.err.println("ERROR" + Excepciones.getStackTrace(e)); document.add(new Paragraph("Sin imagen " + logoPath)); } font.setSize(fontSize + 3); Paragraph titulo = new Paragraph("Desasignacin de Hard Token", font); titulo.setAlignment(Element.ALIGN_RIGHT); document.add(titulo); Chunk CONNECT = new Chunk(new LineSeparator(0.5f, 100, java.awt.Color.BLACK, Element.ALIGN_CENTER, 3.5f)); document.add(CONNECT); DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm a"); font.setSize(fontSize + 2); Paragraph fecha = new Paragraph("Desasignacin de Tokens a Centro Financiero", font); fecha.setAlignment(Element.ALIGN_CENTER); document.add(fecha); // Paragraph pNombre = new Paragraph( nombreUsuario , font); // pNombre.setAlignment(Element.ALIGN_RIGHT); // document.add(pNombre); font.setSize(fontSize); font.setColor(java.awt.Color.white); // define table header cell PdfPCell cell = new PdfPCell(); java.awt.Color color = java.awt.Color.LIGHT_GRAY; cell.setBackgroundColor(color); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(5); // write table header // cell.setPhrase(new Phrase("Usuario que importo en token", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Fecha y Hora", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Tokens importados", font)); // table.addCell(cell); // cell.setPhrase(new Phrase("Centro Financiero", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Tipo", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Cliente nico", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Fecha de ultima modificacin", font)); // table.addCell(cell); Font font2 = FontFactory.getFont(FontFactory.HELVETICA); try { font2.setFamily(fontName); } catch (Exception e) { font2.setFamily("Verdana"); } font2.setSize(fontSize); font2.setColor(java.awt.Color.black); // write table row data // for (ImportTokensPDF pdf : list) { // ImportTokensPDF pdf; cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase("Nombre empleado", font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getNombre(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase("Fecha de Desasignacin", font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(df.format(list.getFecha()), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase("Tokens desasignados", font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getTokens(), font2)); table.addCell(cell); document.add(table); }
From source file:com.conecta.sat.utils.BuildImportTokensPDF.java
@Override protected void buildPdfDocument(Map<String, Object> map, Document document, PdfWriter writer, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. System.out.println("Into BuildImportTokensPDF"); hsr1.setContentType("application/pdf"); DateFormat name = new SimpleDateFormat("ddMMyyyyhhmmss"); hsr1.setHeader("Content-disposition", "attachment; filename=ImportTokens" + name.format(new Date()) + ".pdf"); ImportTokensPDF list = (ImportTokensPDF) map.get("list"); String nombreUsuario = (String) map.get("nombreUsuario"); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100);//from www.j av a2 s . c om table.setSpacingBefore(10); Font font = FontFactory.getFont(FontFactory.HELVETICA); try { font.setFamily(fontName); } catch (Exception e) { font.setFamily("Verdana"); } try { ServletContext servletContext = hsr.getSession().getServletContext(); String relativeWebPath = logoPath; String absoluteDiskPath = servletContext.getRealPath(relativeWebPath); Image logo = Image.getInstance(absoluteDiskPath); // Image logo = Image.getInstance("logo.png"); System.out.println("La imagen se cargo correctamente"); logo.scaleToFit(widthLogo, heightLogo); document.add(logo); } catch (Exception e) { System.err.println("ERROR" + Excepciones.getStackTrace(e)); document.add(new Paragraph("Sin imagen " + logoPath)); } font.setSize(fontSize + 3); Paragraph titulo = new Paragraph("Reporte de Tokens", font); titulo.setAlignment(Element.ALIGN_RIGHT); document.add(titulo); Chunk CONNECT = new Chunk(new LineSeparator(0.5f, 100, java.awt.Color.BLACK, Element.ALIGN_CENTER, 3.5f)); document.add(CONNECT); DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm a"); font.setSize(fontSize + 2); Paragraph fecha = new Paragraph(df.format(new Date()), font); fecha.setAlignment(Element.ALIGN_RIGHT); document.add(fecha); Paragraph pNombre = new Paragraph(nombreUsuario, font); pNombre.setAlignment(Element.ALIGN_RIGHT); document.add(pNombre); font.setSize(fontSize); font.setColor(java.awt.Color.white); // define table header cell PdfPCell cell = new PdfPCell(); java.awt.Color color = java.awt.Color.LIGHT_GRAY; cell.setBackgroundColor(color); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Nmero de empleado que importo en token", font)); table.addCell(cell); cell.setPhrase(new Phrase("Fecha y Hora", font)); table.addCell(cell); cell.setPhrase(new Phrase("Tokens importados", font)); table.addCell(cell); // cell.setPhrase(new Phrase("Centro Financiero", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Tipo", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Cliente nico", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Fecha de ultima modificacin", font)); // table.addCell(cell); Font font2 = FontFactory.getFont(FontFactory.HELVETICA); try { font2.setFamily(fontName); } catch (Exception e) { font2.setFamily("Verdana"); } font2.setSize(fontSize); font2.setColor(java.awt.Color.black); // write table row data // for (ImportTokensPDF pdf : list) { // ImportTokensPDF pdf; cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getUsuario(), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(df.format(list.getFecha()), font2)); table.addCell(cell); cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.addElement(new Phrase(list.getTokens(), font2)); table.addCell(cell); // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getCentro(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getTipo(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getCliente(),font2) ); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment( Element.ALIGN_CENTER ); // cell.addElement( new Phrase(pdf.getLastUpdate(),font2) ); // table.addCell(cell); // } document.add(table); }