List of usage examples for com.itextpdf.text Font setSize
public void setSize(final float size)
From source file:Controlador.ControladorCrearPase.java
public void generaPDF(String Prueba, String Causa, Integer idCita, Integer idPaciente, Integer idPersona) throws FileNotFoundException, DocumentException, IOException { Calendar cal = Calendar.getInstance(); String time = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(cal.getTime()); String timename = new SimpleDateFormat("yyyyMMddHHmm").format(cal.getTime()); File file = new File("PaseServicio" + timename + ".pdf"); FileOutputStream fileout = new FileOutputStream(file); Document document = new Document(); PdfWriter writer;/*from ww w .ja v a2 s . c om*/ writer = PdfWriter.getInstance(document, fileout); Font fuente = new Font(); Font fuente2 = new Font(); Font fuente3 = new Font(); // fuente.setColor(BaseColor.BLUE); fuente.setStyle(Font.UNDERLINE | Font.BOLDITALIC); fuente2.setStyle(Font.BOLD); fuente2.setSize(12); fuente3.setSize(20); fuente3.setStyle(Font.BOLD); document.open(); document.add(new Paragraph("\n \n \n \n \n")); document.add(new Paragraph("Clinica Mdica INFTEL", fuente3)); String imageUrl = "src/Imagen/logo.png"; // String imagen="src\Imagen\logo.png"; Image image = Image.getInstance(imageUrl); image.setAbsolutePosition(300, 750); image.scalePercent(80f); document.add(image); document.add(new Paragraph(" ")); document.add(new Paragraph("---------------------")); document.add(new Paragraph("DATOS DEL PACIENTE", fuente)); document.add(new Paragraph(" ")); document.add( new Paragraph("Apellidos y Nombre : " + paciente.getApellidos() + ", " + paciente.getNombre())); document.add(new Paragraph("NIF : " + paciente.getNif())); document.add(new Paragraph("NSS : " + paciente.getNumSS())); document.add(new Paragraph("Direccion : " + paciente.getDireccion())); document.add(new Paragraph("Telefono : " + paciente.getTelefono())); document.add(new Paragraph("Email : " + paciente.getEmail())); document.add(new Paragraph("ID Paciente : " + idPaciente)); document.add(new Paragraph(" ")); document.add(new Paragraph("---------------------")); document.add(new Paragraph(" ")); document.add(new Paragraph("DATOS ", fuente)); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Prueba : ", fuente2)); document.add(new Paragraph(Prueba)); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Causa : ", fuente2)); document.add(new Paragraph(Causa)); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); absText(writer, time, 450, 50); document.close(); File myfile = new File("PaseServicio" + timename + ".pdf"); Desktop.getDesktop().open(myfile); }
From source file:es.baudlord.pcpartpicker.model.Build.java
License:Open Source License
public PdfPTable createPdfPTable(Font font) throws DocumentException { List<PdfPCell> cellList = new ArrayList<>(); cellList.addAll(Arrays.asList(new PdfPCell(new Phrase(GENERAL_BUNDLE.getString("column.Name"), font)), new PdfPCell(new Phrase(GENERAL_BUNDLE.getString("column.UnitPrice"), font)), new PdfPCell(new Phrase(GENERAL_BUNDLE.getString("column.Amount"), font)), new PdfPCell(new Phrase(GENERAL_BUNDLE.getString("column.Price"), font)))); for (Product.Category c : Product.Category.values()) { ArrayList<Part> parts = getParts(c); if (parts.isEmpty()) continue; parts.forEach(product -> cellList .addAll(Arrays.asList(new PdfPCell(new Phrase(product.getDescription(), font)), new PdfPCell(new Phrase(Coin.formatNet(product.getPrice()), font)), new PdfPCell(new Phrase(String.valueOf(product.getAmount()), font)), new PdfPCell(new Phrase(Coin.formatNet(product.getTotalPrice()), font))))); }/*from w ww. j a va 2 s . co m*/ PdfPCell line = new PdfPCell(new Phrase("")); line.setColspan(4); cellList.add(line); double totalPrice = this.getTotalPrice(); font.setSize(font.getSize() + 2); PdfPCell total = new PdfPCell(new Phrase(GENERAL_BUNDLE.getString("total.price").toUpperCase(), font)); total.setColspan(3); cellList.addAll(Arrays.asList(total, new PdfPCell(new Phrase(Coin.formatNet(totalPrice), font)))); PdfPCell totalTax = new PdfPCell(new Phrase(GENERAL_BUNDLE.getString("total.tax").toUpperCase(), font)); totalTax.setColspan(3); cellList.addAll(Arrays.asList(totalTax, new PdfPCell(new Phrase(Coin.formatTax(totalPrice), font)))); PdfPCell totalPvp = new PdfPCell(new Phrase(GENERAL_BUNDLE.getString("total.pvp").toUpperCase(), font)); totalPvp.setColspan(3); cellList.addAll(Arrays.asList(totalPvp, new PdfPCell(new Phrase(Coin.formatGross(totalPrice), font)))); PdfPTable table = new PdfPTable(4); table.setWidths(new int[] { 50, 10, 5, 10 }); table.setHeaderRows(1); for (int i = 0; i < table.getNumberOfColumns(); i++) { cellList.get(i).setBorder(Rectangle.BOTTOM); table.addCell(cellList.get(i)); } for (int i = table.getNumberOfColumns(); i < cellList.size() - 6; i++) { cellList.get(i).setBorder(0); table.addCell(cellList.get(i)); } for (int i = cellList.size() - 6; i < cellList.size() - 4; i++) { cellList.get(i).setBorder(Rectangle.TOP); table.addCell(cellList.get(i)); } for (int i = cellList.size() - 4; i < cellList.size(); i++) { cellList.get(i).setBorder(0); table.addCell(cellList.get(i)); } return table; }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private List<Talk> createProgrammePages() throws DocumentException, IOException { List<Talk> talksToExplain = new ArrayList<>(); document.setPageSize(PageSize.A4.rotate()); Font font = new Font(); font.setStyle(Font.BOLD);/* w w w . j a v a2s. c o m*/ font.setSize(14); for (String date : service.getDates()) { Set<String> tracksInPage = new HashSet<>(); Map<String, Talk> precedentTalk = new HashMap<>(); PdfPTable table = createBeginningOfPage(font, date); for (String creneau : service.getCreneaux().get(date)) { // Nouvelle page 14h if (creneau.startsWith("14:00") && !tracksInPage.isEmpty()) { document.add(table); addLegend(tracksInPage); table = createBeginningOfPage(font, date); } PdfPCell cellCreneau = new PdfPCell(); cellCreneau.setPaddingBottom(10); Paragraph startTime = new Paragraph(creneau); startTime.setAlignment(Element.ALIGN_CENTER); cellCreneau.addElement(startTime); Paragraph endTime = new Paragraph(getEndTime(date, creneau)); endTime.setAlignment(Element.ALIGN_CENTER); cellCreneau.addElement(endTime); table.addCell(cellCreneau); for (String room : service.getRooms(date)) { PdfPCell cell = new PdfPCell(); cell.setPaddingBottom(10); cell.setHorizontalAlignment(Element.ALIGN_LEFT); Talk talk = service.getTalkByDateAndCreneauxAndRoom(date, creneau, room); if (talk != null) { talksToExplain.add(talk); remplirCellWithTalk(cell, talk); cell.setRowspan(getRowSpan(date, talk)); precedentTalk.put(room, talk); tracksInPage.add(talk.getTrack()); table.addCell(cell); } else { talk = precedentTalk.get(room); if (!(talk != null && talk.getEnd().compareTo(creneau) > 0)) { table.addCell(cell); } } } } document.add(table); addLegend(tracksInPage); } return talksToExplain; }
From source file:fr.ybonnel.breizhcamppdf.RoomPdfRenderer.java
License:Apache License
private List<Talk> createProgrammePages() throws DocumentException, IOException { List<Talk> talksToExplain = new ArrayList<>(); document.setPageSize(PageSize.A4);/*from w ww .j ava 2s . com*/ Font font = new Font(); font.setStyle(Font.BOLD); font.setSize(14); for (String date : service.getDates()) { for (String room : service.getRooms(date)) { Set<String> tracksInPage = new HashSet<>(); Map<String, Talk> precedentTalk = new HashMap<>(); PdfPTable table = createBeginningOfPage(font, date, room); for (String creneau : service.getCreneaux().get(date)) { PdfPCell cellCreneau = new PdfPCell(); cellCreneau.setPaddingBottom(10); Paragraph startTime = new Paragraph(creneau); startTime.setAlignment(Element.ALIGN_CENTER); cellCreneau.addElement(startTime); Paragraph endTime = new Paragraph(getEndTime(date, creneau)); endTime.setAlignment(Element.ALIGN_CENTER); cellCreneau.addElement(endTime); table.addCell(cellCreneau); PdfPCell cell = new PdfPCell(); cell.setPaddingBottom(10); cell.setHorizontalAlignment(Element.ALIGN_LEFT); Talk talk = service.getTalkByDateAndCreneauxAndRoom(date, creneau, room); if (talk != null) { talksToExplain.add(talk); remplirCellWithTalk(cell, talk); cell.setRowspan(getRowSpan(date, talk)); precedentTalk.put(room, talk); tracksInPage.add(talk.getTrack()); table.addCell(cell); } else { talk = precedentTalk.get(room); if (!(talk != null && talk.getEnd().compareTo(creneau) > 0)) { table.addCell(cell); } } } document.add(table); addLegend(tracksInPage); } } return talksToExplain; }
From source file:GUI.Framenewventa.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed if (jLabel17.getText().toString().equals("-")) { JOptionPane.showMessageDialog(rootPane, "DEBE SELECCIONAR UN CLIENTE"); } else {/*from w w w . ja v a 2s. com*/ try { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); funciones f = new funciones(); String dia = (Calendar.getInstance().getTime().getDate() < 10) ? "0" + Calendar.getInstance().getTime().getDate() : Calendar.getInstance().getTime().getDate() + ""; String mes = f.get_mesMay((Calendar.getInstance().getTime().getMonth() + 1)); String anio = (Calendar.getInstance().getTime().getYear() + 1900) + ""; String nombre = "COTIZACION TIENDA ULTIMO ROUND"; String rut_socio = ""; int mon = 0; String arch = Calendar.getInstance().getTimeInMillis() + "_" + nombre + ".pdf"; DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); Date date = new Date(); String stringToEncrypt = nombre.trim() + dateFormat.format(date); int encryptedString = stringToEncrypt.trim().hashCode(); String aRemplazar = Integer.toString(encryptedString); String remplazado = aRemplazar.replace("-", ""); String url = f.getRutaCotizacion() + arch; FileOutputStream archivo = new FileOutputStream(url); int deuda = Integer.parseInt("1"); String palabra = f.Convertir(deuda + "", false); palabra = palabra.substring(0, palabra.length() - 2); if (palabra.split(" ")[palabra.split(" ").length - 1].equals("millones") | palabra.split(" ")[palabra.split(" ").length - 1].equals("milln")) { palabra = palabra + "de pesos"; } else { palabra = palabra + "pesos"; } Document documento = new Document(PageSize.LETTER); PdfWriter.getInstance(documento, archivo); documento.open(); try { Image im = Image.getInstance(f.getRutaCotizacion() + "headerword.png"); im.setAlignment(Image.ALIGN_CENTER); im.scaleToFit(600, 400); documento.add(im); } catch (Exception e) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL ENCABEZADO.", "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } int linea = 0; Font fuente = new Font(); fuente.setStyle(Font.UNDERLINE | Font.BOLD); fuente.setSize(11); fuente.setColor(BaseColor.BLACK); documento.add(new Paragraph(" ")); Paragraph fecha = new Paragraph(dia + " de " + mes.toLowerCase() + " de " + anio + "\n", FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); fecha.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(fecha); Paragraph obp = new Paragraph("ULTIMO ROUND\n", FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); obp.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(obp); Paragraph codigo = new Paragraph("COD." + remplazado, FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); codigo.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(codigo); Paragraph space = new Paragraph("\n", FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK)); space.setAlignment(Paragraph.ALIGN_LEFT); documento.add(space); Paragraph origen = new Paragraph("ESTIMADO CLIENTE: " + jLabel13.getText() + "\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); origen.setAlignment(Paragraph.ALIGN_LEFT); documento.add(origen); Paragraph origen2 = new Paragraph("EMAIL: " + jLabel15.getText() + "\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); origen2.setAlignment(Paragraph.ALIGN_LEFT); documento.add(origen2); Paragraph a = new Paragraph(nombre, FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); a.setAlignment(Paragraph.ALIGN_LEFT); documento.add(a); Paragraph rut = new Paragraph(rut_socio, FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); rut.setAlignment(Paragraph.ALIGN_LEFT); documento.add(rut); Paragraph ref = new Paragraph("REF:COTIZACION POR PRODUCTOS TIENDA ULTIMO ROUND\n", FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK)); ref.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(ref); documento.add(space); int numerocheque = 0; int montofinal = 0; String montostring = ""; String detalle = ""; String monto = jLabel22.getText(); String montoaux = monto.replace(".", ""); deuda = Integer.parseInt(montoaux); palabra = f.Convertir(deuda + "", false); System.out.println(palabra); palabra = palabra.replaceAll("0", ""); System.out.println(palabra); Paragraph e = new Paragraph( "Junto con saludarlo, adjunto la cotizacin detallada de los siguientes productos" + " por el monto de $" + monto + ".- ( " + palabra + "pesos IVA INCLUIDO) ,segn detalle:\n\n", FontFactory.getFont("times new roman", 11, Font.NORMAL, BaseColor.BLACK)); e.setAlignment(Paragraph.ALIGN_LEFT); documento.add(e); documento.add(new Paragraph(" ")); // ACA DEBE IR LA TABLA //special font sizes Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font bf10 = new Font(Font.FontFamily.TIMES_ROMAN, 10); //specify column widths //create PDF table with the given widths documento.add(new Paragraph(" ")); float[] colsWidth = { 1.5f, 1.5f, 1.5f, 1.5f, 1.5f }; PdfPTable tabla = new PdfPTable(5); tabla.setWidths(colsWidth); String[] titulos = { "PRODUCTO", "VALOR PRODUCTO", "TIPO", "MARCA", "TALLA" }; tabla.setWidthPercentage(100); PdfPCell celda; for (int k = 0; k < titulos.length; k++) { celda = new PdfPCell(new Paragraph(titulos[k], FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } int var = 0; int w = 0; for (w = 0; w < jTable1.getRowCount(); w++) { celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 1).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 7).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 4).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 3).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 2).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("MONTO NETO", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(monto, FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("IVA TOTAL", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); double iva2 = Float.parseFloat(monto) * (0.19); iva2 = Math.round(iva2); celda = new PdfPCell(new Paragraph(Double.toString(iva2), FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("VALOR TOTAL", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); int valortotal = Integer.parseInt(monto); ; celda = new PdfPCell(new Paragraph(Integer.toString(valortotal), FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); //FOOOTER documento.add(space); Paragraph despido = new Paragraph("Quedando a vuestra disposicin, saluda atentamente a Ud.,\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); despido.setAlignment(Paragraph.ALIGN_LEFT); documento.add(despido); documento.add(space); Paragraph firma2 = new Paragraph("TIENDA ULTIMO ROUND\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); firma2.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(firma2); documento.add(space); documento.add(space); documento.add(space); Paragraph firma3 = new Paragraph("Cotizacin vlida por siete das\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); firma3.setAlignment(Paragraph.ALIGN_CENTER); documento.add(firma3); documento.add(space); documento.add(space); try { Image im = Image.getInstance(f.getRutaCotizacion() + "footerword.png"); im.setAlignment(Image.ALIGN_CENTER); im.scaleToFit(600, 500); documento.add(im); } catch (Exception ex) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL PIE DE PAGINA.", "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } documento.close(); setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "REALIZADO CORRECTAMENTE", "INFORMACIN", JOptionPane.PLAIN_MESSAGE, JOptionPane.INFORMATION_MESSAGE); } catch (Exception ex) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "ERROR" + ex.getMessage(), "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } } }
From source file:GUI.frameNewVentaKit.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed if (jLabel17.getText().toString().equals("-")) { JOptionPane.showMessageDialog(rootPane, "DEBE SELECCIONAR UN CLIENTE"); } else {//ww w . ja v a 2 s . c o m try { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); funciones f = new funciones(); String dia = (Calendar.getInstance().getTime().getDate() < 10) ? "0" + Calendar.getInstance().getTime().getDate() : Calendar.getInstance().getTime().getDate() + ""; String mes = f.get_mesMay((Calendar.getInstance().getTime().getMonth() + 1)); String anio = (Calendar.getInstance().getTime().getYear() + 1900) + ""; String nombre = "COTIZACION TIENDA ULTIMO ROUND"; String rut_socio = ""; int mon = 0; String arch = Calendar.getInstance().getTimeInMillis() + "_" + nombre + ".pdf"; DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); Date date = new Date(); String stringToEncrypt = nombre.trim() + dateFormat.format(date); int encryptedString = stringToEncrypt.trim().hashCode(); String aRemplazar = Integer.toString(encryptedString); String remplazado = aRemplazar.replace("-", ""); String url = f.getRutaCotizacion() + arch; FileOutputStream archivo = new FileOutputStream(url); int deuda = Integer.parseInt("1"); String palabra = f.Convertir(deuda + "", false); palabra = palabra.substring(0, palabra.length() - 2); if (palabra.split(" ")[palabra.split(" ").length - 1].equals("millones") | palabra.split(" ")[palabra.split(" ").length - 1].equals("milln")) { palabra = palabra + "de pesos"; } else { palabra = palabra + "pesos"; } Document documento = new Document(PageSize.LETTER); PdfWriter.getInstance(documento, archivo); documento.open(); try { Image im = Image.getInstance(f.getRutaCotizacion() + "headerword.png"); im.setAlignment(Image.ALIGN_CENTER); im.scaleToFit(600, 400); documento.add(im); } catch (Exception e) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL ENCABEZADO.", "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } int linea = 0; Font fuente = new Font(); fuente.setStyle(Font.UNDERLINE | Font.BOLD); fuente.setSize(11); fuente.setColor(BaseColor.BLACK); documento.add(new Paragraph(" ")); Paragraph fecha = new Paragraph(dia + " de " + mes.toLowerCase() + " de " + anio + "\n", FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); fecha.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(fecha); Paragraph obp = new Paragraph("ULTIMO ROUND\n", FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); obp.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(obp); Paragraph codigo = new Paragraph("COD." + remplazado, FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); codigo.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(codigo); Paragraph space = new Paragraph("\n", FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK)); space.setAlignment(Paragraph.ALIGN_LEFT); documento.add(space); Paragraph origen = new Paragraph("ESTIMADO CLIENTE: " + jLabel13.getText() + "\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); origen.setAlignment(Paragraph.ALIGN_LEFT); documento.add(origen); Paragraph origen2 = new Paragraph("EMAIL: " + jLabel15.getText() + "\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); origen2.setAlignment(Paragraph.ALIGN_LEFT); documento.add(origen2); Paragraph a = new Paragraph(nombre, FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); a.setAlignment(Paragraph.ALIGN_LEFT); documento.add(a); Paragraph rut = new Paragraph(rut_socio, FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); rut.setAlignment(Paragraph.ALIGN_LEFT); documento.add(rut); Paragraph ref = new Paragraph("REF:COTIZACION POR PRODUCTOS TIENDA ULTIMO ROUND\n", FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK)); ref.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(ref); documento.add(space); int numerocheque = 0; int montofinal = 0; String montostring = ""; String detalle = ""; String monto = jLabel22.getText(); String montoaux = monto.replace(".", ""); deuda = Integer.parseInt(montoaux); palabra = f.Convertir(deuda + "", false); System.out.println(palabra); palabra = palabra.replaceAll("0", ""); System.out.println(palabra); Paragraph e = new Paragraph( "Junto con saludarlo, adjunto la cotizacin detallada de los siguientes productos" + " por el monto de $" + monto + ".- ( " + palabra + "pesos IVA INCLUIDO) ,segn detalle:\n\n", FontFactory.getFont("times new roman", 11, Font.NORMAL, BaseColor.BLACK)); e.setAlignment(Paragraph.ALIGN_LEFT); documento.add(e); documento.add(new Paragraph(" ")); // ACA DEBE IR LA TABLA //special font sizes Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font bf10 = new Font(Font.FontFamily.TIMES_ROMAN, 10); //specify column widths //create PDF table with the given widths documento.add(new Paragraph(" ")); float[] colsWidth = { 1.5f, 1.5f, 1.5f, 1.5f, 1.5f }; PdfPTable tabla = new PdfPTable(5); tabla.setWidths(colsWidth); String[] titulos = { "PRODUCTO", "VALOR PRODUCTO", "TIPO", "MARCA", "TALLA" }; tabla.setWidthPercentage(100); PdfPCell celda; for (int k = 0; k < titulos.length; k++) { celda = new PdfPCell(new Paragraph(titulos[k], FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } int var = 0; int w = 0; for (w = 0; w < jTable1.getRowCount(); w++) { celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 1).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 7).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 4).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 3).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 2).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("MONTO NETO", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(monto, FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("IVA TOTAL", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); double iva2 = Float.parseFloat(monto) * (0.19); iva2 = Math.round(iva2); celda = new PdfPCell(new Paragraph(Double.toString(iva2), FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("VALOR TOTAL", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); int valortotal = Integer.parseInt(monto); celda = new PdfPCell(new Paragraph(Integer.toString(valortotal), FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); //FOOOTER documento.add(space); Paragraph despido = new Paragraph("Quedando a vuestra disposicin, saluda atentamente a Ud.,\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); despido.setAlignment(Paragraph.ALIGN_LEFT); documento.add(despido); documento.add(space); Paragraph firma2 = new Paragraph("TIENDA ULTIMO ROUND\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); firma2.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(firma2); documento.add(space); documento.add(space); documento.add(space); Paragraph firma3 = new Paragraph("Cotizacin vlida por siete das\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); firma3.setAlignment(Paragraph.ALIGN_CENTER); documento.add(firma3); documento.add(space); documento.add(space); try { Image im = Image.getInstance(f.getRutaCotizacion() + "footerword.png"); im.setAlignment(Image.ALIGN_CENTER); im.scaleToFit(600, 500); documento.add(im); } catch (Exception ex) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL PIE DE PAGINA.", "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } documento.close(); setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "REALIZADO CORRECTAMENTE", "INFORMACIN", JOptionPane.PLAIN_MESSAGE, JOptionPane.INFORMATION_MESSAGE); } catch (Exception ex) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "ERROR" + ex.getMessage(), "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } } }
From source file:htmlparser.pdf.PDFFile.java
public void createScoreTable(Color oddrow_color, Color title_bg_color, Color title_font_color, int highlight) { if (this.opened) { int columnNumber = 0; for (String s : this.parser.getTeams().get(0).getData()) { columnNumber++;//from w ww.ja v a 2 s . c om } PdfPTable table = new PdfPTable(columnNumber + 1); Font f = new Font(this.fonttype, 13); int row = 1; Font headline = new Font(f); headline.setStyle("bold"); headline.setSize(16); headline.setColor(new BaseColor(title_bg_color.getRGB())); PdfPCell headcell = new PdfPCell(new Paragraph(this.parser.getCompetitionName(), headline)); headcell.setColspan(columnNumber + 1); headcell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(headcell); Font title = new Font(f); title.setStyle("bold"); title.setColor(new BaseColor(title_font_color.getRGB())); for (String s : this.shColNms) { PdfPCell cell = new PdfPCell(new Paragraph(s, title)); cell.setBackgroundColor(new BaseColor(title_bg_color.getRGB())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } row++; int order = 1; Font tfont = f; Font bold = new Font(f); bold.setStyle("bold"); for (Team t : this.parser.getTeams()) { if (highlight >= 0) { if (order == highlight + 1) { tfont = bold; } else { tfont = f; } } PdfPCell ordercell = new PdfPCell(new Paragraph(Integer.toString(order), tfont)); ordercell.setHorizontalAlignment(Element.ALIGN_CENTER); if (row % 2 == 0) { ordercell.setBackgroundColor(new BaseColor(oddrow_color.getRGB())); } table.addCell(ordercell); for (String s : t.getData()) { PdfPCell cell = new PdfPCell(new Paragraph(s, tfont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); if (row % 2 == 0) { cell.setBackgroundColor(new BaseColor(oddrow_color.getRGB())); } table.addCell(cell); } order++; row++; } try { float[] widths = { 12f, 40f, 13f, 5f, 5f, 5f, 10f, 10f }; table.setWidths(widths); this.document.add(table); } catch (DocumentException ex) { System.out.println("Content exception"); } } }
From source file:htmlparser.pdf.PDFFile.java
public void createMatchTable(Color oddrow_color, Color title_bg_color, Color title_font_color) { if (this.opened) { this.document.newPage(); int columnNumber = 0; for (String s : this.parser.getMatches().get(0).getData()) { columnNumber++;//from www . j a v a 2 s .co m } PdfPTable table = new PdfPTable(columnNumber); Font f = new Font(this.fonttype, 13); int row = 1; Font headline = new Font(f); headline.setStyle("bold"); headline.setSize(16); headline.setColor(new BaseColor(title_bg_color.getRGB())); PdfPCell headcell = new PdfPCell(new Paragraph(this.parser.getTeamName(), headline)); headcell.setColspan(columnNumber); headcell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(headcell); Font title = new Font(f); title.setStyle("bold"); title.setColor(new BaseColor(title_font_color.getRGB())); for (String s : this.mhColNms) { PdfPCell cell = new PdfPCell(new Paragraph(s, title)); cell.setBackgroundColor(new BaseColor(title_bg_color.getRGB())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } row++; for (Match t : this.parser.getMatches()) { for (String s : t.getData()) { PdfPCell cell = new PdfPCell(new Paragraph(s, f)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); if (row % 2 == 0) { cell.setBackgroundColor(new BaseColor(oddrow_color.getRGB())); } table.addCell(cell); } row++; } try { float[] widths = { 26f, 26f, 20f, 8f, 20f }; table.setWidths(widths); this.document.add(table); } catch (DocumentException ex) { } } }
From source file:informes.InformeActividad.java
public void generarInforme() { try {//from ww w .j av a 2s. c o m Document document = new Document(); Paragraph ParrafoHoja = new Paragraph(); String parrafo = this.getDescripsion(); String ruta = ec.getRealPath("img"); PdfWriter.getInstance(document, new FileOutputStream(ruta + "\\" + "actividades.pdf")); Font fuente = new Font(); fuente.setColor(255, 0, 0); fuente.setSize(30); Font fuente3 = new Font(); fuente3.setColor(255, 255, 255); fuente3.setSize(30); PdfPTable tabla2 = new PdfPTable(1); tabla2.getDefaultCell().setBackgroundColor(BaseColor.BLUE); tabla2.setWidthPercentage(110f); tabla2.addCell(new Paragraph("UNIDAD EDUCATIVA", fuente3)); tabla2.addCell(new Paragraph("'MISIONEROS OBLATOS'", fuente3)); Paragraph p = new Paragraph(parrafo, fuente); agregarLineasEnBlanco(ParrafoHoja, 3); document.open(); document.add(tabla2); document.add(p); document.add(ParrafoHoja); Font fuente1 = new Font(); fuente1.setColor(0, 0, 0); fuente1.setSize(5); Font fuente2 = new Font(); fuente2.setColor(255, 0, 0); fuente2.setSize(5); PdfPTable tabla = new PdfPTable(5); tabla.setWidthPercentage(107f); Font fuente4 = new Font(); fuente4.setColor(0, 0, 0); fuente4.setSize(8); // Paragraph p4 = new Paragraph(parrafo, fuente4); //tabla.addCell(new Paragraph("OBJESTRATEGICO",fuente2)); tabla.addCell(new Paragraph("RESPONSABLE", fuente2)); tabla.addCell(new Paragraph("CONTROL", fuente2)); tabla.addCell(new Paragraph("FECHA INICIO", fuente2)); tabla.addCell(new Paragraph("FECHA FIN", fuente2)); tabla.addCell(new Paragraph("AVANCE", fuente2)); int cont = 0; tabla.getDefaultCell().setBackgroundColor(BaseColor.WHITE); for (int i = 0; i < this.getItems().size(); i++) { // Paragraph p1 =new Paragraph(parrafo,fuente); String num = String.valueOf(i); Paragraph p4 = new Paragraph("Objetivo: " + num + " --> " + this.getItems().get(i).getNombre(), fuente4); document.add(p4); Paragraph p8 = new Paragraph(); agregarLineasEnBlanco(p8, 1); document.add(p8); for (Actividad a : this.getItems().get(i).getActividadCollection()) { System.out.println(""); if (a.getIdObjetivoEstrategico() .getIdObjetivoEstrategico() == (this.getItems().get(i).getIdObjetivoEstrategico())) { cont = 1; tabla.addCell(new Paragraph(a.getIdObjetivoEstrategico().getNombre(), fuente1)); tabla.addCell(new Paragraph(a.getIdPersonaResponsable().getNombre(), fuente1)); tabla.addCell(new Paragraph(a.getControl(), fuente1)); tabla.addCell(new Paragraph(a.getFechaInicio().toString(), fuente1)); tabla.addCell(new Paragraph(a.getFechaFin().toString(), fuente1)); tabla.addCell(new Paragraph(a.getAvance().toString(), fuente1)); } } Paragraph p7 = new Paragraph(); if (cont == 1) { document.add(tabla); cont = 0; agregarLineasEnBlanco(p7, 2); document.add(p7); } else { Font fuente5 = new Font(); fuente5.setColor(0, 0, 255); fuente5.setSize(10); document.add(new Paragraph("No contiene actividades registradas", fuente5)); agregarLineasEnBlanco(p7, 2); document.add(p7); } } document.add(new Paragraph(new Date().toString())); document.close(); System.out.println("aquiiiiii"); } catch (FileNotFoundException ex) { Logger.getLogger(InformeActividad.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(InformeActividad.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(InformeActividad.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:informes.InformeObjEs.java
public void generarInforme() { try {//from www . j av a 2 s .c o m Document document = new Document(); Paragraph ParrafoHoja = new Paragraph(); String parrafo = this.getDescripsion(); String ruta = ec.getRealPath("img"); PdfWriter.getInstance(document, new FileOutputStream(ruta + "\\" + "objEstra.pdf")); Font fuente = new Font(); fuente.setColor(255, 0, 0); fuente.setSize(30); Font fuente3 = new Font(); fuente3.setColor(255, 255, 255); fuente3.setSize(30); PdfPTable tabla2 = new PdfPTable(1); tabla2.getDefaultCell().setBackgroundColor(BaseColor.BLUE); tabla2.setWidthPercentage(110f); tabla2.addCell(new Paragraph("UNIDAD EDUCATIVA", fuente3)); tabla2.addCell(new Paragraph("'MISIONEROS OBLATOS'", fuente3)); Paragraph p = new Paragraph(parrafo, fuente); agregarLineasEnBlanco(ParrafoHoja, 3); document.open(); document.add(tabla2); document.add(p); document.add(ParrafoHoja); Font fuente1 = new Font(); fuente1.setColor(0, 0, 0); fuente1.setSize(5); Font fuente2 = new Font(); fuente2.setColor(255, 0, 0); fuente2.setSize(5); PdfPTable tabla = new PdfPTable(8); tabla.setWidthPercentage(107f); tabla.addCell(new Paragraph("OBJETIVO", fuente2)); tabla.addCell(new Paragraph("META", fuente2)); tabla.addCell(new Paragraph("DEFINICION", fuente2)); tabla.addCell(new Paragraph("ACLARACION", fuente2)); tabla.addCell(new Paragraph("CONCEPTUALIZACION", fuente2)); tabla.addCell(new Paragraph("INDICADOR", fuente2)); tabla.addCell(new Paragraph("FORMULA", fuente2)); tabla.addCell(new Paragraph("UNIDADES", fuente2)); tabla.getDefaultCell().setBackgroundColor(BaseColor.WHITE); for (int i = 0; i < this.getItems().size(); i++) { // Paragraph p1 =new Paragraph(parrafo,fuente); System.out.println("aquiiiiiiiiiiii" + this.getItems().get(i).getSemaforo()); tabla.addCell(new Paragraph(this.getItems().get(i).getObjetivoestrategico().getNombre(), fuente1)); tabla.addCell(new Paragraph(this.getItems().get(i).getMeta(), fuente1)); tabla.addCell(new Paragraph(this.getItems().get(i).getDefinicion(), fuente1)); tabla.addCell(new Paragraph(this.getItems().get(i).getAclaracion(), fuente1)); tabla.addCell(new Paragraph(this.getItems().get(i).getConceptualizacion(), fuente1)); tabla.addCell(new Paragraph(this.getItems().get(i).getIndicador().getNombre(), fuente1)); tabla.addCell(new Paragraph(this.getItems().get(i).getIndicador().getFormula(), fuente1)); tabla.addCell(new Paragraph(String.valueOf(this.getItems().get(i).getIndicador().getUnidades()), fuente1)); } document.add(tabla); document.add(new Paragraph(new Date().toString())); document.close(); System.out.println("aquiiiiii"); } catch (FileNotFoundException ex) { Logger.getLogger(InformeObjEs.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(InformeObjEs.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(InformeObjEs.class.getName()).log(Level.SEVERE, null, ex); } }