List of usage examples for com.itextpdf.text Phrase Phrase
private Phrase(final boolean dummy)
From source file:br.com.docedesafio.pdfs.FirstPdf.java
private static void createTable(Section subCatPart) throws BadElementException { PdfPTable table = new PdfPTable(3); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPCell c1 = new PdfPCell(new Phrase("Table Header 1")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);/*from ww w . jav a 2 s . c o m*/ c1 = new PdfPCell(new Phrase("Table Header 2")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Table Header 3")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); table.addCell("1.0"); table.addCell("1.1"); table.addCell("1.2"); table.addCell("2.1"); table.addCell("2.2"); table.addCell("2.3"); subCatPart.add(table); }
From source file:BUS.ExportPDF.java
public boolean ExportPN(ArrayList<String[]> al) throws BadElementException, IOException, DocumentException { // To i tng ti liu Document document = new Document(PageSize.A4, 50, 50, 50, 50); File fontFile = new File("src\\Helper\\arialuni.ttf"); BaseFont unicode = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font f = new Font(unicode, 12); try {/*w w w. j a v a 2 s. c o m*/ // To i tng PdfWriter Date d = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String s = "PhieuNhap_" + ft.format(d) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(s)); // M file thc hin ghi document.open(); Paragraph title1 = new Paragraph("CO's BAKERY", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title1); //Logo Group Image image1 = Image.getInstance("src\\Library\\cao.png"); document.add(new Paragraph()); document.add(image1); //Data PdfPTable t = new PdfPTable(7); t.setSpacingBefore(25); t.setSpacingAfter(25); PdfPCell c1 = new PdfPCell(new Phrase("STT")); t.addCell(c1); PdfPCell c2 = new PdfPCell(new Phrase("M phiu nhp", f)); t.addCell(c2); PdfPCell c3 = new PdfPCell(new Phrase("M Nhn Vin", f)); t.addCell(c3); PdfPCell c4 = new PdfPCell(new Phrase("Tn Nhn Vin", f)); t.addCell(c4); PdfPCell c5 = new PdfPCell(new Phrase("Ngy lp", f)); t.addCell(c5); PdfPCell c6 = new PdfPCell(new Phrase("Nh cung cp", f)); t.addCell(c6); PdfPCell c7 = new PdfPCell(new Phrase("Tng ti?n", f)); t.addCell(c7); for (int i = 0; i < al.size(); i++) { Object ob = i + 1; t.addCell(ob.toString()); t.addCell(al.get(i)[0]); t.addCell(al.get(i)[1]); t.addCell(new Phrase(al.get(i)[2], f)); t.addCell(al.get(i)[3]); t.addCell(new Phrase(al.get(i)[4], f)); t.addCell(al.get(i)[5]); } document.add(t); // ?ng File document.close(); } catch (FileNotFoundException | DocumentException e) { return false; } return true; }
From source file:BUS.ExportPDF.java
public boolean ExportPX(ArrayList<String[]> al) throws BadElementException, IOException, DocumentException { // To i tng ti liu Document document = new Document(PageSize.A4, 50, 50, 50, 50); File fontFile = new File("src\\Helper\\arialuni.ttf"); BaseFont unicode = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font f = new Font(unicode, 12); try {/* w ww. ja va2s .c o m*/ // To i tng PdfWriter Date d = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String s = "PhieuXuat_" + ft.format(d) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(s)); // M file thc hin ghi document.open(); Paragraph title1 = new Paragraph("CO's BAKERY", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title1); //Logo Group Image image1 = Image.getInstance("src\\Library\\cao.png"); document.add(new Paragraph()); document.add(image1); //Data PdfPTable t = new PdfPTable(5); t.setSpacingBefore(25); t.setSpacingAfter(25); PdfPCell c1 = new PdfPCell(new Phrase("STT")); t.addCell(c1); PdfPCell c2 = new PdfPCell(new Phrase("M phiu xut", f)); t.addCell(c2); PdfPCell c3 = new PdfPCell(new Phrase("M Nhn Vin", f)); t.addCell(c3); PdfPCell c4 = new PdfPCell(new Phrase("Tn Nhn Vin", f)); t.addCell(c4); PdfPCell c5 = new PdfPCell(new Phrase("Ngy lp", f)); t.addCell(c5); for (int i = 0; i < al.size(); i++) { Object ob = i + 1; t.addCell(ob.toString()); t.addCell(al.get(i)[0]); t.addCell(al.get(i)[1]); t.addCell(new Phrase(al.get(i)[2], f)); t.addCell(al.get(i)[3]); } document.add(t); // ?ng File document.close(); } catch (FileNotFoundException | DocumentException e) { return false; } return true; }
From source file:BUS.ExportPDF.java
public boolean ExportHD(ArrayList<String[]> al) throws BadElementException, IOException, DocumentException { // To i tng ti liu Document document = new Document(PageSize.A4, 50, 50, 50, 50); File fontFile = new File("src\\Helper\\arialuni.ttf"); BaseFont unicode = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font f = new Font(unicode, 12); try {/*from ww w .j av a 2s. c o m*/ // To i tng PdfWriter Date d = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String s = "Hoadon_" + ft.format(d) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(s)); // M file thc hin ghi document.open(); Paragraph title1 = new Paragraph("CO's BAKERY", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title1); //Logo Group Image image1 = Image.getInstance("src\\Library\\cao.png"); document.add(new Paragraph()); document.add(image1); //Data PdfPTable t = new PdfPTable(6); t.setSpacingBefore(25); t.setSpacingAfter(25); PdfPCell c1 = new PdfPCell(new Phrase("STT")); t.addCell(c1); PdfPCell c2 = new PdfPCell(new Phrase("M ha n", f)); t.addCell(c2); PdfPCell c3 = new PdfPCell(new Phrase("Tn khch hng", f)); t.addCell(c3); PdfPCell c4 = new PdfPCell(new Phrase("Tn Nhn Vin", f)); t.addCell(c4); PdfPCell c5 = new PdfPCell(new Phrase("Ngy lp", f)); t.addCell(c5); PdfPCell c6 = new PdfPCell(new Phrase("Tng ti?n", f)); t.addCell(c6); for (int i = 0; i < al.size(); i++) { Object ob = i + 1; t.addCell(ob.toString()); t.addCell(al.get(i)[0]); t.addCell(new Phrase(al.get(i)[1], f)); t.addCell(new Phrase(al.get(i)[2], f)); t.addCell(al.get(i)[3]); t.addCell(al.get(i)[4]); } document.add(t); // ?ng File document.close(); System.out.println("Write file succes!"); } catch (FileNotFoundException | DocumentException e) { return false; } return true; }
From source file:BUS.ExportPDF.java
public boolean ExportTKSP(ArrayList<String[]> al, String year) throws BadElementException, IOException, DocumentException { // To i tng ti liu Document document = new Document(PageSize.A4, 50, 50, 50, 50); File fontFile = new File("src\\Helper\\arialuni.ttf"); BaseFont unicode = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font f = new Font(unicode, 12); try {/*from ww w. ja va 2s .co m*/ // To i tng PdfWriter Date d = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String s = "ThongKeSanPham_" + ft.format(d) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(s)); // M file thc hin ghi document.open(); Paragraph title1 = new Paragraph("CO's BAKERY", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title1); //Logo Group Image image1 = Image.getInstance("src\\Library\\cao.png"); document.add(new Paragraph()); document.add(image1); //Nm c bo co Paragraph title2 = new Paragraph(year, FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title2); //Chart Image image = Image.getInstance("src\\Library\\pie_Chart3D.jpeg"); image.scaleToFit(500, 400); document.add(new Paragraph()); document.add(image); //Data PdfPTable t = new PdfPTable(5); t.setSpacingBefore(25); t.setSpacingAfter(25); PdfPCell c1 = new PdfPCell(new Phrase("STT")); t.addCell(c1); PdfPCell c2 = new PdfPCell(new Phrase("M sn phm", f)); t.addCell(c2); PdfPCell c3 = new PdfPCell(new Phrase("Tn sn phm", f)); t.addCell(c3); PdfPCell c4 = new PdfPCell(new Phrase("Tng s lng", f)); t.addCell(c4); PdfPCell c5 = new PdfPCell(new Phrase("Tng ti?n", f)); t.addCell(c5); for (int i = 0; i < al.size(); i++) { Object ob = i + 1; t.addCell(ob.toString()); t.addCell(al.get(i)[0]); t.addCell(new Phrase(al.get(i)[1], f)); t.addCell(al.get(i)[2]); t.addCell(al.get(i)[3]); } document.add(t); // ?ng File document.close(); System.out.println("Write file succes!"); } catch (FileNotFoundException | DocumentException e) { return false; } return true; }
From source file:Business.PDFMaker.java
public PDFMaker(String filename, TicketMap tm, int pr1, int pr2, int pr3) { Document doc = new Document(); try {//from w ww .ja v a 2 s .co m PdfWriter.getInstance(doc, new FileOutputStream(filename)); doc.open(); doc.add(new Phrase("Cabaz de Natal, Cl Schindler")); doc.add(new Paragraph("As seguintes Rifas foram vendidas:")); doc.add(new Paragraph("\n")); PdfPTable table = new PdfPTable(5); for (Ticket t : tm.getFullTickets()) { PdfPCell cell = new PdfPCell(new Paragraph(t.getId() + "-" + t.getName())); table.addCell(cell); } doc.add(table); doc.add(new Chapter("Vencedores deste ano:", 1)); doc.add(new Paragraph("1 Prmio. " + tm.getTicket(pr1))); doc.add(new Paragraph("2 Prmio. " + tm.getTicket(pr2))); doc.add(new Paragraph("3 Prmio. " + tm.getTicket(pr3))); doc.close(); } catch (Exception e) { } }
From source file:cis_690_report.DynamicReporter.java
public PdfPCell getCell(String text, int alignment) { PdfPCell cell = new PdfPCell(new Phrase(text)); cell.setPadding(0);/*from w w w . ja v a 2 s. c o m*/ cell.setHorizontalAlignment(alignment); cell.setBorder(PdfPCell.NO_BORDER); return cell; }
From source file:clases.Funciones.java
private String GenerateReporte_pdf(JTable t, String title, int open) { Document documento = new Document(PageSize.LETTER.rotate(), 10, 10, 10, 10); FileOutputStream ficheroPdf;/*from w ww . j av a 2 s . c o m*/ File ruta = null; com.itextpdf.text.Image imagen = null; try { imagen = com.itextpdf.text.Image.getInstance(p.ReturnPropiedad(p.Ruta_logo)); char rt = p.ReturnPropiedad(p.Ruta_SaveReports) .charAt(p.ReturnPropiedad(p.Ruta_SaveReports).length() - 1); if ("/".equalsIgnoreCase(String.valueOf(rt))) { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } else { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + "/" + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } ficheroPdf = new FileOutputStream(ruta); PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); } catch (DocumentException | IOException ex) { Alert("Verifique las rutas de guardado de reportes y logo."); } try { documento.open(); title += "\nGENER: " + ReturnNombreUsuario(); Paragraph Title = new Paragraph(title.toUpperCase()); Title.setAlignment(1); documento.add(Title); imagen.setAlignment(Element.ALIGN_CENTER); imagen.scaleToFit(200, 100); String membrete = ReturnDatosFisicos(this.Datos_Nombre) + "\n"; membrete += "DIRECCION: " + ReturnDatosFisicos(this.Datos_Direccion) + "\n"; membrete += "RFC: " + ReturnDatosFisicos(this.Datos_Rfc) + "\n"; membrete += "TELEFONO: " + ReturnDatosFisicos(this.Datos_Telefono) + "\n"; membrete += "GENERO DOCUMENTO: " + ReturnNombreUsuario() + "\n"; membrete += "FECHA Y HORA DE GENERACION: " + GetFechaAndHourActual() + "\n"; ///////// PdfPTable HeaderDatos = new PdfPTable(2); HeaderDatos.setWidthPercentage(100); documento.add(new Paragraph("\n")); PdfPCell cell = new PdfPCell(new Phrase(membrete)); cell.setBorder(0); HeaderDatos.addCell(cell); cell = new PdfPCell(imagen); cell.setBorder(0); cell.setHorizontalAlignment(1); HeaderDatos.addCell(cell); documento.add(HeaderDatos); documento.add(new Paragraph("\n")); ///////// PdfPTable tabla = new PdfPTable(t.getColumnCount()); tabla.setWidthPercentage(100); for (int i = 0; i < t.getColumnCount(); i++) { Paragraph header = new Paragraph(t.getColumnName(i)); header.setAlignment(1); tabla.addCell(header); } for (int i = 0; i < t.getRowCount(); i++) { for (int a = 0; a < t.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t.getValueAt(i, a))); campo.setAlignment(1); tabla.addCell(campo); } } documento.add(tabla); documento.add(new Paragraph(" ")); Paragraph footer = new Paragraph("SOFTWARE Y MAS ! - WWW.CYBERCHOAPAS.COM"); footer.setAlignment(1); documento.add(footer); documento.close(); if (open > 0) { Desktop.getDesktop().open(ruta); } } catch (IOException | DocumentException ex) { Alert(ex.getMessage()); } return ruta.getAbsolutePath(); }
From source file:clases.Funciones.java
public boolean GenerateReporte_Service(JTable t_client, JTable t_vehiculos, int open, String S_solicitad, String S_realizado, JTable t_productos, String Total, String Prioridad, JComboBox client, JComboBox vehiculos, Double km) { boolean r = false; int Folio = GenerateFolioService(); if (AddService(client, vehiculos, S_solicitad, S_realizado, t_productos, Double.parseDouble(Total), "URGENTE".equals(Prioridad)) && vehiculos.getSelectedIndex() > 0) { UpdateKilometraje((String) ListVehiculos.get(vehiculos.getSelectedIndex()), km); Table_LoadClient(t_client, client); Table_LoadCar(t_vehiculos, vehiculos); Document documento = new Document(PageSize.LETTER, 10, 10, 10, 10); FileOutputStream ficheroPdf; File ruta = null;// w ww. jav a 2 s .co m com.itextpdf.text.Image imagen = null; try { imagen = com.itextpdf.text.Image.getInstance(p.ReturnPropiedad(p.Ruta_logo)); char rt = p.ReturnPropiedad(p.Ruta_SaveReports) .charAt(p.ReturnPropiedad(p.Ruta_SaveReports).length() - 1); if ("/".equalsIgnoreCase(String.valueOf(rt))) { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } else { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + "/" + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } ficheroPdf = new FileOutputStream(ruta); PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); } catch (DocumentException | IOException ex) { Alert("Verifique las rutas de guardado de reportes y logo."); } try { documento.open(); imagen.setAlignment(Element.ALIGN_CENTER); imagen.scaleToFit(200, 100); String membrete = "REPORTE DE SERVICIO NO: " + Folio + "\n\n"; membrete += ReturnDatosFisicos(this.Datos_Nombre) + "\n"; membrete += "DIRECCION: " + ReturnDatosFisicos(this.Datos_Direccion) + "\n"; membrete += "RFC: " + ReturnDatosFisicos(this.Datos_Rfc) + "\n"; membrete += "TELEFONO: " + ReturnDatosFisicos(this.Datos_Telefono) + "\n"; membrete += "GENERO DOCUMENTO: " + ReturnNombreUsuario() + "\n"; membrete += "GENERADO: " + GetFechaAndHourActual() + "\n"; PdfPTable HeaderDatos = new PdfPTable(2); HeaderDatos.setWidthPercentage(100); documento.add(new Paragraph("\n")); PdfPCell cell = new PdfPCell(new Phrase(membrete)); cell.setBorder(0); HeaderDatos.addCell(cell); cell = new PdfPCell(imagen); cell.setBorder(0); cell.setHorizontalAlignment(1); cell.setVerticalAlignment(1); HeaderDatos.addCell(cell); documento.add(HeaderDatos); documento.add(new Paragraph("\n")); ///////// //Tabla_Clientes String Client_header = "CLIENTE"; Paragraph Title = new Paragraph(Client_header.toUpperCase()); Title.setAlignment(1); documento.add(Title); documento.add(new Paragraph(" ")); PdfPTable tabla = new PdfPTable(t_client.getColumnCount()); tabla.setWidthPercentage(100); for (int i = 0; i < t_client.getColumnCount(); i++) { Paragraph header = new Paragraph(t_client.getColumnName(i)); header.setAlignment(1); tabla.addCell(header); } for (int i = 0; i < t_client.getRowCount(); i++) { for (int a = 0; a < t_client.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_client.getValueAt(i, a))); campo.setAlignment(1); tabla.addCell(campo); } } documento.add(tabla); documento.add(new Paragraph(" ")); //Tabla_Vehiculos String Vehiculos_header = "VEHICULO"; Paragraph Title1 = new Paragraph(Vehiculos_header.toUpperCase()); Title1.setAlignment(1); documento.add(Title1); documento.add(new Paragraph(" ")); PdfPTable tabla_vehiculos = new PdfPTable(t_vehiculos.getColumnCount()); tabla_vehiculos.setWidthPercentage(100); for (int i = 0; i < t_vehiculos.getColumnCount(); i++) { Paragraph header = new Paragraph(t_vehiculos.getColumnName(i)); header.setAlignment(1); tabla_vehiculos.addCell(header); } for (int i = 0; i < t_vehiculos.getRowCount(); i++) { for (int a = 0; a < t_vehiculos.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_vehiculos.getValueAt(i, a))); campo.setAlignment(1); tabla_vehiculos.addCell(campo); } } documento.add(tabla_vehiculos); documento.add(new Paragraph("SERVICIO SOLICITADO: " + S_solicitad.toUpperCase())); documento.add(new Paragraph("SERVICIO REALIZADO: " + S_realizado.toUpperCase())); documento.add(new Paragraph("PRIORIDAD: " + Prioridad)); //Tabla de servicios y productos String Service_header = "\nSERVICIOS Y PRODUCTOS UTILIZADOS"; Paragraph Title2 = new Paragraph(Service_header.toUpperCase()); Title2.setAlignment(1); documento.add(Title2); documento.add(new Paragraph(" ")); PdfPTable tabla_PRODUCTS = new PdfPTable(t_productos.getColumnCount()); tabla_PRODUCTS.setWidthPercentage(100); for (int i = 0; i < t_productos.getColumnCount(); i++) { Paragraph header = new Paragraph(t_productos.getColumnName(i)); header.setAlignment(1); tabla_PRODUCTS.addCell(header); } for (int i = 0; i < t_productos.getRowCount(); i++) { for (int a = 0; a < t_productos.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_productos.getValueAt(i, a))); campo.setAlignment(1); tabla_PRODUCTS.addCell(campo); } } documento.add(tabla_PRODUCTS); documento.add(new Paragraph("")); // documento.add(new Paragraph("COSTO TOTAL DE SERVICIO $ " + Total)); documento.add(new Paragraph( "FECHA Y HORA DE ENTREGA: ____________________________________________________")); documento.add(new Paragraph( "NOMBRE Y FIRMA DEL QUE REALIZA: _____________________________________________")); documento.add(new Paragraph( "CONFORMIDAD, NOMBRE Y FIRMA DE QUIEN RECIBE: _______________________________")); documento.add(new Paragraph( "PROXIMO SERVICIO: ___________________________________________________________")); Paragraph footer = new Paragraph("SOFTWARE Y MAS ! - WWW.CYBERCHOAPAS.COM"); footer.setAlignment(1); documento.add(footer); documento.close(); r = true; if (open > 0) { Desktop.getDesktop().open(ruta); } } catch (IOException | DocumentException ex) { Alert(ex.getMessage()); } } else { Alert("VERIFIQUE SU INFORMACION"); } return r; }
From source file:clases.Funciones.java
public void ReGenerateReporte_Service(JTable t) { int id = 0, id_cliente = 0; double total = 0; String id_vehiculo = "", s_solicitado = "", s_realizado = "", productos = ""; boolean p_urgente = false; try {//from www.ja va 2 s . c o m coneccion = new Conexion(); try (ResultSet rs = coneccion.Consulta( "SELECT id, id_cliente, id_vehiculo, s_solicitado, s_realizado, productos, total, p_urgente FROM services where id = " + Integer.parseInt((String) t.getValueAt(t.getSelectedRow(), 0)) + " ")) { if (rs.next()) { id = rs.getInt(1); id_cliente = rs.getInt(2); id_vehiculo = rs.getString(3); s_solicitado = rs.getString(4); s_realizado = rs.getString(5); productos = rs.getString(6); total = rs.getDouble(7); p_urgente = rs.getBoolean(8); } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException ex) { Alert(ex.getMessage()); } int Folio = id; JTable t_client = new JTable(); JTable t_vehiculos = new JTable(); Table_LoadClient(t_client, id_cliente); Table_LoadCar(t_vehiculos, id_vehiculo); Document documento = new Document(PageSize.LETTER, 10, 10, 10, 10); FileOutputStream ficheroPdf; File ruta = null; com.itextpdf.text.Image imagen = null; try { imagen = com.itextpdf.text.Image.getInstance(p.ReturnPropiedad(p.Ruta_logo)); char rt = p.ReturnPropiedad(p.Ruta_SaveReports) .charAt(p.ReturnPropiedad(p.Ruta_SaveReports).length() - 1); if ("/".equalsIgnoreCase(String.valueOf(rt))) { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } else { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + "/" + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } ficheroPdf = new FileOutputStream(ruta); PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); } catch (DocumentException | IOException ex) { Alert("Verifique las rutas de guardado de reportes y logo."); } try { documento.open(); imagen.setAlignment(Element.ALIGN_CENTER); imagen.scaleToFit(200, 100); String membrete = "REPORTE DE SERVICIO NO: " + Folio + "\n\n"; membrete += ReturnDatosFisicos(this.Datos_Nombre) + "\n"; membrete += "DIRECCION: " + ReturnDatosFisicos(this.Datos_Direccion) + "\n"; membrete += "RFC: " + ReturnDatosFisicos(this.Datos_Rfc) + "\n"; membrete += "TELEFONO: " + ReturnDatosFisicos(this.Datos_Telefono) + "\n"; membrete += "GENERO DOCUMENTO: " + ReturnNombreUsuario() + "\n"; membrete += "GENERADO: " + GetFechaAndHourActual() + "\n"; PdfPTable HeaderDatos = new PdfPTable(2); HeaderDatos.setWidthPercentage(100); documento.add(new Paragraph("\n")); PdfPCell cell = new PdfPCell(new Phrase(membrete)); cell.setBorder(0); HeaderDatos.addCell(cell); cell = new PdfPCell(imagen); cell.setBorder(0); cell.setHorizontalAlignment(1); cell.setVerticalAlignment(1); HeaderDatos.addCell(cell); documento.add(HeaderDatos); documento.add(new Paragraph("\n")); ///////// //Tabla_Clientes String Client_header = "CLIENTE"; Paragraph Title = new Paragraph(Client_header.toUpperCase()); Title.setAlignment(1); documento.add(Title); documento.add(new Paragraph(" ")); PdfPTable tabla = new PdfPTable(t_client.getColumnCount()); tabla.setWidthPercentage(100); for (int i = 0; i < t_client.getColumnCount(); i++) { Paragraph header = new Paragraph(t_client.getColumnName(i)); header.setAlignment(1); tabla.addCell(header); } for (int i = 0; i < t_client.getRowCount(); i++) { for (int a = 0; a < t_client.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_client.getValueAt(i, a))); campo.setAlignment(1); tabla.addCell(campo); } } documento.add(tabla); documento.add(new Paragraph(" ")); //Tabla_Vehiculos String Vehiculos_header = "VEHICULO"; Paragraph Title1 = new Paragraph(Vehiculos_header.toUpperCase()); Title1.setAlignment(1); documento.add(Title1); documento.add(new Paragraph(" ")); PdfPTable tabla_vehiculos = new PdfPTable(t_vehiculos.getColumnCount()); tabla_vehiculos.setWidthPercentage(100); for (int i = 0; i < t_vehiculos.getColumnCount(); i++) { Paragraph header = new Paragraph(t_vehiculos.getColumnName(i)); header.setAlignment(1); tabla_vehiculos.addCell(header); } for (int i = 0; i < t_vehiculos.getRowCount(); i++) { for (int a = 0; a < t_vehiculos.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_vehiculos.getValueAt(i, a))); campo.setAlignment(1); tabla_vehiculos.addCell(campo); } } documento.add(tabla_vehiculos); documento.add(new Paragraph("SERVICIO SOLICITADO: " + s_solicitado.toUpperCase())); documento.add(new Paragraph("SERVICIO REALIZADO: " + s_realizado.toUpperCase())); String var = ""; if (p_urgente) { var = "URGENTE"; } else { var = "PROGRAMAR"; } documento.add(new Paragraph("PRIORIDAD: " + var)); //Tabla de servicios y productos String Service_header = "\nSERVICIOS Y PRODUCTOS UTILIZADOS"; Paragraph Title2 = new Paragraph(Service_header.toUpperCase()); Title2.setAlignment(1); documento.add(Title2); documento.add(new Paragraph(" ")); JTable t_productos = new JTable(); Table_LoadProductsServicio(t_productos); String[] result = productos.replace("+", ",").split(","); if (result.length >= 1) { for (String r : result) { if (!r.equalsIgnoreCase("") || !r.isEmpty()) { if (ExistProduct(r)) { Table_AddProductsServicio(t_productos, r); } } } } PdfPTable tabla_PRODUCTS = new PdfPTable(t_productos.getColumnCount()); tabla_PRODUCTS.setWidthPercentage(100); for (int i = 0; i < t_productos.getColumnCount(); i++) { Paragraph header = new Paragraph(t_productos.getColumnName(i)); header.setAlignment(1); tabla_PRODUCTS.addCell(header); } for (int i = 0; i < t_productos.getRowCount(); i++) { for (int a = 0; a < t_productos.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_productos.getValueAt(i, a))); campo.setAlignment(1); tabla_PRODUCTS.addCell(campo); } } documento.add(tabla_PRODUCTS); documento.add(new Paragraph("")); // documento.add(new Paragraph("COSTO TOTAL DE SERVICIO $ " + total)); documento.add( new Paragraph("FECHA Y HORA DE ENTREGA: ____________________________________________________")); documento.add( new Paragraph("NOMBRE Y FIRMA DEL QUE REALIZA: _____________________________________________")); documento.add( new Paragraph("CONFORMIDAD, NOMBRE Y FIRMA DE QUIEN RECIBE: _______________________________")); documento.add( new Paragraph("PROXIMO SERVICIO: ___________________________________________________________")); Paragraph footer = new Paragraph("SOFTWARE Y MAS ! - WWW.CYBERCHOAPAS.COM"); footer.setAlignment(1); documento.add(footer); documento.close(); Desktop.getDesktop().open(ruta); } catch (IOException | DocumentException ex) { Alert(ex.getMessage()); } catch (ClassNotFoundException | SQLException | InstantiationException | IllegalAccessException ex) { Alert(ex.getMessage()); } }