List of usage examples for com.itextpdf.text Font NORMAL
int NORMAL
To view the source code for com.itextpdf.text Font NORMAL.
Click Source Link
From source file:itext_result.Main.java
private int developScreeningSheet() { new SwingWorker<Object, Object>() { String filename;// w w w. j av a2 s . c o m @Override protected void done() { // ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. "); } public PdfPCell createBarcode(PdfWriter writer, String code) throws DocumentException, IOException { BarcodeEAN barcode = new BarcodeEAN(); barcode.setCodeType(Barcode.EAN8); barcode.setCode(code); PdfPCell cell = new PdfPCell( barcode.createImageWithBarcode(writer.getDirectContent(), BaseColor.BLACK, BaseColor.GRAY), true); cell.setPadding(10); return cell; } class ImageContent implements PdfPTableEvent { protected com.itextpdf.text.Image content; public ImageContent(com.itextpdf.text.Image content) { this.content = content; } public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) { try { PdfContentByte canvas = canvases[PdfPTable.TEXTCANVAS]; float x = widths[3][1] + 10; float y = heights[3] - 10 - content.getScaledHeight(); content.setAbsolutePosition(x, y); canvas.addImage(content); } catch (DocumentException e) { throw new ExceptionConverter(e); } } } @Override protected Object doInBackground() throws Exception { // System.err.println(" Roll No Received ....." + rollno); Document doc = new Document(); try { PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("12345" + ".pdf")); doc.open(); doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : "); doc.addSubject("Confidential Report Eyes Only"); doc.addKeywords(""); doc.addAuthor("SOS"); doc.addCreator("SOS"); // A4 = 210mm x 297mm ~ 605points x 855points doc.setPageSize(PageSize.A5); doc.setMargins(15f, 15f, 15f, 15f); ///////////////////////////////////////////////////////////// int pageno = 1; for (int i = 0; i == pageno; i++) { // doc.add(imageRight); } PdfContentByte cb = writer.getDirectContent(); //DONE BarcodeEAN codeEAN = new BarcodeEAN(); codeEAN.setCodeType(Barcode.EAN8); Barcode128 code128 = new Barcode128(); code128.setCode(String.valueOf("123456")); Barcode128 code128_jacket = new Barcode128(); code128_jacket.setCode(String.valueOf("10345")); codeEAN.setCode(String.valueOf("123456")); com.itextpdf.text.Image imageEAN = code128.createImageWithBarcode(cb, null, null); // imageEAN.scalePercent(10f); //464f, 725f // imageEAN.setAbsolutePosition(474f, 662f); int i = 1; while (i <= pageno) { doc.newPage(); // cb.addImage(imageRight); // cb.addImage(imageEAN); i++; } com.itextpdf.text.Image carcode = code128_jacket.createImageWithBarcode(cb, null, null); carcode.scaleAbsolute(100f, 35f); carcode.setAbsolutePosition(500f, 600f); writer.addDirectImageSimple(carcode); // cb.addImage(carcode); com.itextpdf.text.Image carcode2 = code128.createImageWithBarcode(cb, null, null); carcode2.scaleAbsolute(100f, 35f); carcode2.setAbsolutePosition(450f, 760f); writer.addDirectImageSimple(carcode2); // cb.addImage(carcode2); Image image1 = Image.getInstance("jklogo.gif"); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(99); table.addCell(image1); doc.add(table); table = new PdfPTable(4); table.setWidthPercentage(99); float[] columnWidths = { 6, 2 }; PdfPTable CandidateTable = new PdfPTable(columnWidths); Font f = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK); Font fsmall = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK); PdfPCell rollno = new PdfPCell(new Phrase("Roll No# " + String.valueOf("123456"), fsmall)); PdfPCell cname = new PdfPCell(new Phrase("Name #" + String.valueOf("John Doe"), fsmall)); // DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); // String today = formatter.format(cInfo.getDob()); PdfPCell dob = new PdfPCell(new Phrase("DOB#" + String.valueOf("12-03-1989"), fsmall)); PdfPCell fname = new PdfPCell(new Phrase("F/H Name #" + String.valueOf("Big John"), fsmall)); PdfPCell type = new PdfPCell(new Phrase("Total Time #" + String.valueOf("350.00"), fsmall)); // String scrtoday = formatter.format(cInfo.getScreeningdate()); // System.out.println("Today : " + today); PdfPCell scrdate = new PdfPCell(new Phrase("Laps #" + String.valueOf("4"), fsmall)); PdfPCell cell = new PdfPCell(new Phrase(" ", fsmall)); rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); dob.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); fname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); type.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); scrdate.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cell.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); CandidateTable.addCell(rollno); CandidateTable.addCell(cell); CandidateTable.addCell(cname); CandidateTable.addCell(cell); CandidateTable.addCell(dob); CandidateTable.addCell(cell); PdfPTable CandidateOtherTable = new PdfPTable(columnWidths); CandidateOtherTable.addCell(fname); CandidateOtherTable.addCell(cell); CandidateOtherTable.addCell(scrdate); CandidateOtherTable.addCell(cell); CandidateOtherTable.addCell(type); CandidateOtherTable.addCell(cell); PdfPCell race_start_time = new PdfPCell(new Phrase("Start Time :XX-XX-XX ", fsmall)); PdfPCell race_end_time = new PdfPCell(new Phrase("End Time :XX-XX-XX", fsmall)); PdfPCell race_total_time = new PdfPCell(new Phrase("Total Time : 350.00 ", fsmall)); race_start_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); race_end_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); race_total_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); PdfPTable CandidateRaceDetails = new PdfPTable(columnWidths); CandidateRaceDetails.addCell(race_start_time); CandidateRaceDetails.addCell(cell); CandidateRaceDetails.addCell(race_end_time); CandidateRaceDetails.addCell(cell); CandidateRaceDetails.addCell(race_total_time); CandidateRaceDetails.addCell(cell); PdfPTable tablewith3cells = new PdfPTable(3); //1 St Col for Roll No Name and DOB tablewith3cells.addCell(CandidateTable); //2 nd Col for Father Name sCREEning Date Gurkha tablewith3cells.addCell(CandidateOtherTable); //3rd Col for Barcode to be Printed tablewith3cells.addCell(CandidateRaceDetails); // Setting the Width here to 101 tablewith3cells.setWidthPercentage(99); doc.add(tablewith3cells); PdfPTable userArea = new PdfPTable(1); userArea.setWidthPercentage(99); userArea.addCell(" \n \n Congratulations \n \n "); doc.add(userArea); PdfPTable footerCSBC = new PdfPTable(2); footerCSBC.setWidthPercentage(99); PdfPCell height_box = new PdfPCell(new Phrase("Height \n\n\n", f)); height_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell chest_box = new PdfPCell(new Phrase("Chest \n\n\n", f)); chest_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell chest_exp_box = new PdfPCell(new Phrase("Chest Exp \n\n\n", f)); chest_exp_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell pushup_box = new PdfPCell(new Phrase("Pushup \n\n\n", f)); pushup_box.setBorder(com.itextpdf.text.Rectangle.BOX); //CSignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX); // ASignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX); footerCSBC.addCell(height_box); footerCSBC.addCell(chest_box); footerCSBC.addCell(chest_exp_box); footerCSBC.addCell(pushup_box); doc.add(footerCSBC); float[] columnWidths_ForBarcode = { 6, 3 }; PdfPTable terminalinfo = new PdfPTable(columnWidths_ForBarcode); // terminalinfo.setWidthPercentage(99); String computername = InetAddress.getLocalHost().getHostName(); System.out.println(computername); PdfPCell pcname = new PdfPCell(new Phrase("\t Jacket \n\n ", f)); String UserMatchScore = "\t Barcode\n\n"; PdfPCell score = new PdfPCell(new Phrase(UserMatchScore, f)); PdfPCell barcode = new PdfPCell(carcode2); PdfPCell jacketnumber = new PdfPCell(carcode); pcname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); score.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); barcode.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); jacketnumber.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); terminalinfo.addCell(score); terminalinfo.addCell(pcname); terminalinfo.addCell(barcode); terminalinfo.addCell(jacketnumber); doc.add(terminalinfo); PdfPCell eula_notice = new PdfPCell(new Phrase(" ", f)); eula_notice.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable eula_notice_table = new PdfPTable(1); eula_notice_table.setWidthPercentage(25); eula_notice_table.addCell(eula_notice); doc.add(eula_notice_table); } catch (Exception e) { System.err.println(e.getMessage()); // ConsoleMsg(e.getMessage()); } finally { doc.close(); doc.close(); doc.close(); } //ConsoleMsg("PDF... GENERATED"); return null; // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }.execute(); return 0; }
From source file:library.Report.java
public void createPdf(String filename) throws DocumentException, IOException { // step 1//from w w w . j ava2 s . c o m Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(filename)); document.addAuthor("Admin"); document.addTitle("Library report"); document.setPageSize(PageSize.A4); document.setMargins(36, 72, 108, 180); document.setMarginMirroring(true); document.open(); Font normal = new Font(Font.FontFamily.HELVETICA, 36f, Font.NORMAL, BaseColor.DARK_GRAY); Font normal1 = new Font(Font.FontFamily.HELVETICA, 18f, Font.NORMAL); Font normal2 = new Font(Font.FontFamily.HELVETICA, 12f, Font.NORMAL); document.add(new Paragraph("KNOWLEDGICA LIBRARY REPORT", normal)); document.add(new Phrase("\n")); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime()); document.add(new Paragraph(timeStamp, normal1)); document.add(new Paragraph("Amount of books " + DF.getText() + "\nAmount of Amount of checked in books " + jTextField1.getText() + "\nAmount of checked out books " + jTextField3.getText() + "" + "\nNunber of users " + jTextField4.getText() + "\nNumber of admins " + jTextField5.getText() + "\nNumber of librarians " + jTextField6.getText() + "\nNumber of guest " + jTextField7.getText() + "\nMost logged user " + jTextField8.getText() + "\nAmount of males " + jTextField9.getText() + "\nAmount of female " + jTextField10.getText() + "", normal2)); document.close(); }
From source file:logica.Generar_pdf.java
public void ConvertirPDF(int num, String nombre, String nombre2, String cedula, String cedula2, String direccion, String direccion2, String telefono, String telefono2, String sede, String tipo, String observacion, int peso, int declaracion_precio, int precio_neto, int precio_seguro, int precio_impuesto, int total_envio, String forma_pago, String fecha) throws FileNotFoundException { String nombre_pdf = "Factura No " + num + ".pdf"; System.out.println(nombre_pdf); try {//from ww w.j a v a 2 s. com //Creamos documento indicando el tamao y margenes Document documento = new Document(PageSize.LETTER, 20, 20, 20, 20); //Creamos el PDF y lo instanceamos para poder escribir sobre el PdfWriter.getInstance(documento, new FileOutputStream(nombre_pdf)).setInitialLeading(20); //Abrimos el documento documento.open(); System.out.println("Documento Abierto"); //Anexamos el texto a un objeto Pharagraph Paragraph parametro = new Paragraph("Factura Envio de Paquete No. " + num, FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLD, BaseColor.BLACK)); parametro.setAlignment(1); Paragraph parametro17 = new Paragraph("Fecha: " + fecha, FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLD, BaseColor.BLACK)); parametro17.setAlignment(1); Paragraph parametro2 = new Paragraph("Datos Remitente", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK)); Paragraph parametro3 = new Paragraph("Nombre: " + nombre + " Telefono: " + telefono, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); Paragraph parametro4 = new Paragraph("Cedula: " + cedula + " Direccin: " + direccion, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); Paragraph parametro5 = new Paragraph("Datos Destinatario", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK)); Paragraph parametro6 = new Paragraph("Nombre: " + nombre2 + " Telefono: " + telefono2, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); Paragraph parametro7 = new Paragraph("Cedula: " + cedula2 + " Direccin: " + direccion2, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); Paragraph parametro8 = new Paragraph("Datos Envio", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK)); Paragraph parametro9 = new Paragraph("Tipo de Envio: " + tipo + " Observacin: " + observacion, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); Paragraph parametro10 = new Paragraph( "Peso: " + peso + " Declaracin precio Envio: " + declaracion_precio, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); Paragraph parametro11 = new Paragraph("Datos Pago", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK)); Paragraph parametro12 = new Paragraph("Precio de Envio Neto: " + precio_neto, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); Paragraph parametro13 = new Paragraph("Precio Seguro: " + precio_seguro, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); Paragraph parametro14 = new Paragraph("Excedente Impuesto: " + precio_impuesto, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); Paragraph parametro15 = new Paragraph("Total Envio: " + total_envio, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); Paragraph parametro16 = new Paragraph("Forma de Pago: " + forma_pago, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)); //Escribimos sobre el documento.add(parametro); documento.add(parametro17); documento.add(parametro2); documento.add(parametro3); documento.add(parametro4); documento.add(parametro5); documento.add(parametro6); documento.add(parametro7); documento.add(parametro8); documento.add(parametro9); documento.add(parametro10); documento.add(parametro11); documento.add(parametro12); documento.add(parametro13); documento.add(parametro14); documento.add(parametro15); documento.add(parametro16); //Cerrar documento documento.close(); //Mensaje de Exito JOptionPane.showMessageDialog(null, "PDF Creado con exito."); } catch (DocumentException de) { System.out.println("Error..."); } }
From source file:Login.ventas.fproyectos.java
/** * Creates new form cliente// w w w .j a v a 2s . c o m * @param user */ public fproyectos(Login user) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); @SuppressWarnings("MismatchedReadAndWriteOfArray") String[] fecha = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }; initComponents(); Calendar rightNow = Calendar.getInstance(); int ccyy = rightNow.get(Calendar.YEAR); int month = rightNow.get(Calendar.MONTH); setSize(d.width, d.height - 95); this.usuario = user; add(f); f.setLocation(jPanel1.getX(), jPanel1.getY()); add(f3); f3.setLocation(jPanel1.getX(), jPanel1.getY()); add(f4); f4.setLocation(jPanel1.getX(), jPanel1.getY()); add(f5); f5.setLocation(jPanel1.getX(), jPanel1.getY()); add(f2); f2.setLocation(jPanel1.getX(), jPanel1.getY()); f2.getjButton1().addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { ServiceHb helper = new ServiceHb(); helper.iniciarTransaccion(); Fcomisiones fc = helper.getFcomisiones(idcliente, idinstalacion); if (helper.getFcomisiones(idcliente, idinstalacion) == null) { fc = new Fcomisiones(); Calendar d = Calendar.getInstance(); fc.setFecha(new java.sql.Date(d.getTime().getTime())); fc.setClientes( (Clientes) helper.obtenerObjeto(Clientes.class, Integer.parseInt(idcliente))); fc.setInstalacion((Instalacion) helper.obtenerObjeto(Instalacion.class, Integer.parseInt(idinstalacion))); fc.setRentabilidad(f2.getjLabel20().getText()); fc.setValor1(f2.getjLabel11().getText().substring(2, f2.getjLabel11().getText().length())); fc.setValor2(f2.getjLabel2().getText().substring(3, f2.getjLabel2().getText().length())); fc.setDiferido(f2.getjLabel4().getText()); fc.setDias(numeroinstala); helper.crearObjeto(fc); helper.confirmarTransaccion(); helper.cerrarSesion(); JOptionPane.showMessageDialog(null, "Comision prepara con fecha " + Funcion.DateFormatSql(d.getTime())); } else { Calendar d = Calendar.getInstance(); fc.setFecha(new java.sql.Date(d.getTime().getTime())); fc.setRentabilidad(f2.getjLabel20().getText()); fc.setValor1(f2.getjLabel11().getText().substring(2, f2.getjLabel11().getText().length())); fc.setValor2(f2.getjLabel2().getText().substring(3, f2.getjLabel2().getText().length())); fc.setDiferido(f2.getjLabel4().getText()); fc.setDias(numeroinstala); helper.actualizarObjeto(fc); helper.confirmarTransaccion(); helper.cerrarSesion(); JOptionPane.showMessageDialog(null, "Actualizado / Comision prepara con fecha " + Funcion.DateFormatSql(d.getTime())); } } catch (Exception io) { System.out.println(io); } } }); f2.getjButton2().addMouseListener(new java.awt.event.MouseAdapter() { @Override @SuppressWarnings("UseSpecificCatch") public void mouseClicked(MouseEvent e) { float ancho = 0; try { Document documento = new Document(PageSize.A4, 0, 0, 0, 0); ancho = documento.getPageSize().getWidth() - 100; FileOutputStream ficheroPdf; PdfWriter writer = null; PdfWriter writer2 = null; String direccion = ""; Calendar now2 = Calendar.getInstance(); try { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); //Mostrar la ventana para abrir archivo y recoger la respuesta //En el parmetro del showOpenDialog se indica la ventana // al que estar asociado. Con el valor this se asocia a la // ventana que la abre. int respuesta = chooser.showOpenDialog(null); String cadena = ""; if (respuesta == JFileChooser.APPROVE_OPTION) { direccion = chooser.getSelectedFile().getAbsolutePath(); } Calendar d = Calendar.getInstance(); ficheroPdf = new FileOutputStream(direccion + "/" + idcliente + idinstalacion + ".pdf"); writer = PdfWriter.getInstance(documento, ficheroPdf); } catch (IOException ex) { System.out.println(ex.toString()); } ServiceHb helper = null; try { List<Productos> lt = null; helper = new ServiceHb(); helper.iniciarTransaccion(); PdfPTable tabla; PdfPCell casilla; PdfPTable salto = null; PdfPCell celda; Font fontpersonalizado = FontFactory.getFont("ARIAL", 7, Font.BOLD); Font fontpersonalizado2 = FontFactory.getFont("ARIAL", 7, Font.NORMAL); documento.open(); PdfContentByte canvas = writer.getDirectContent(); fondos(documento, canvas); //Materiales double total = 0; double total2 = 0; double total3 = 0; double total4 = 0; double total5 = 0; tabla = new PdfPTable(6); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); celda = new PdfPCell(new Paragraph("ADQUISICION DE MATERIALES")); celda.setColspan(6); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); float pagina = documento.getPageSize().getHeight() - 140; final float max = pagina; pagina = pagina - tabla.getRow(0).calculateHeights(); if (ltart != null) { Object nuevo2[] = { "FECHA", "DETALLE", "CANT.", "PRECIO", "SUBTOTAL", "TOTAL DIARIO" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; double diario = 0; int turno = 0; for (int i = 0; i < ltart.size(); i++) { turno = 0; fact = helper.getFacturafecha(ltart.get(i).getIdfactura()); String fecha = ""; if (fact != null) { fecha = Funcion.DateFormatSql(fact.getFecha()); } if ((i + 1) == ltart.size()) { diario = diario + Double.parseDouble(ltart.get(i).getTotal()); turno = 1; } else { fact2 = helper.getFacturafecha(ltart.get(i + 1).getIdfactura()); String fecha2 = ""; if (fact2 != null) { fecha2 = Funcion.DateFormatSql(fact2.getFecha()); if (fecha.equalsIgnoreCase(fecha2)) { diario = diario + Double.parseDouble(ltart.get(i).getTotal()); } else { diario = diario + Double.parseDouble(ltart.get(i).getTotal()); turno = 1; } } } String uni = "$ " + df.format(Double.parseDouble(ltart.get(i).getUnitario())) .replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(ltart.get(i).getTotal())).replace(",", "."); total = total + Double.parseDouble(ltart.get(i).getTotal()); if (turno == 0) { Object nuevo[] = { fecha, ltart.get(i).getDescripcion(), ltart.get(i).getCantidad(), uni, tot, "" }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); if (((String) obj).equalsIgnoreCase("")) { celda.setBorder(Rectangle.RIGHT); } celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } } else { Object nuevo[] = { fecha, ltart.get(i).getDescripcion(), ltart.get(i).getCantidad(), uni, tot, "$ " + df.format(diario).replace(",", ".") }; int va = 0; for (Object obj : nuevo) { va++; celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); if (va == 5) { celda.setBorder(Rectangle.BOTTOM); } celda.setColspan(1); celda.setBorderColor(new Color(195, 195, 195)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } diario = 0; } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 11) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(6); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); pagina = max; tam = 0; } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell( new Paragraph("Adquisicin de Materiales", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(4); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); /*Parte 2*/ tabla = new PdfPTable(4); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1, 1 }); celda = new PdfPCell(new Paragraph("MANO DE OBRA TECNICOS")); celda.setColspan(4); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "CANT.", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; double diario = 0; int turno = 0; for (Ctepagar list1 : list) { if (list1.getDetalle().contains("ci:")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String[] cadena = desc.split(" "); String result = ""; int contador = 0; for (String n : cadena) { if (n.contains("ci:")) { result = result + ", "; contador++; } else { result = result + n + " "; } } result = result.substring(0, result.length() - 2); String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total2 = total2 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, result, "" + contador, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 90) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado2))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(4); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Mano de Obra Tcnicos", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(2); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total2).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph("TRANSPORTE")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; for (Ctepagar list1 : list) { if (list1.getDetalle().contains("Transporte")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String result = ""; String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total3 = total3 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, desc, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 50) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado2))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Transporte", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total3).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph("COMBUSTIBLE")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; for (Ctepagar list1 : list) { if (list1.getDetalle().contains("Combustible")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String result = ""; String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total4 = total4 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, desc, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 50) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Combustible", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total4).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); //Extras tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph("EXTRAS")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; for (Ctepagar list1 : list) { if (!list1.getDetalle().contains("Combustible") && !list1.getDetalle().contains("ci:") && !list1.getDetalle().contains("Transporte")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String result = ""; String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total5 = total5 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, desc, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 50) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Extra", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total5).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); //Final Vendedor tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph(nombrecliente)); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Venta")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_LEFT); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); Object nuevo2[] = { "FECHA", "DETALLE", "TOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo3[] = { "", nombreinstalacion, totalinstalacion }; for (Object obj : nuevo3) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("INVERSION", new Font(fontpersonalizado))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); Object nuevo4[] = { "Uso de Materiales", "", "$ " + df.format(total).replace(",", ".") }; for (Object obj : nuevo4) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo5[] = { "Mano de obra tcnicos", "", "$ " + df.format(total2).replace(",", ".") }; for (Object obj : nuevo5) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo6[] = { "Transporte", "", "$ " + df.format(total3).replace(",", ".") }; for (Object obj : nuevo6) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo7[] = { "Combustible", "", "$ " + df.format(total4).replace(",", ".") }; for (Object obj : nuevo7) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo71[] = { "Extras", "", "$ " + df.format(total5).replace(",", ".") }; for (Object obj : nuevo71) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo8[] = { "Total Inversin", "", "$ " + df.format(total + total2 + total3 + total4).replace(",", ".") }; for (Object obj : nuevo8) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_LEFT); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); Object nuevo9[] = { "Utilidad del proyecto", "", "$ " + df.format(proyectoval - total - total2 - total3 - total4).replace(",", ".") }; for (Object obj : nuevo9) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setColspan(1); celda.setBorder(PdfPCell.NO_BORDER); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo10[] = { "Rentabilidad ", "", df.format(porcent).replace(",", ".") + " %" }; for (Object obj : nuevo10) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); /*Fin Parte 3*/ documento.close(); helper.cerrarSesion(); } catch (Exception ex) { documento.close(); } JOptionPane.showMessageDialog(null, "PDF Generado"); } catch (Exception io) { System.out.println(io); } } }); f.getjTable1().addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = f.getjTable1().getSelectedRow(); int col = f.getjTable1().getSelectedColumn(); if (col == 4) { f2.setVisible(true); f.setVisible(false); idcliente = f.getjTable1().getValueAt(row, 5).toString(); idinstalacion = f.getjTable1().getValueAt(row, 6).toString(); f2.getjLabel15().setText(f.getjTable1().getValueAt(row, 0).toString()); f2.getjLabel8().setText(f.getjTable1().getValueAt(row, 2).toString()); nombrecliente = f.getjTable1().getValueAt(row, 0).toString(); nombreinstalacion = f.getjTable1().getValueAt(row, 2).toString(); updateTablas up = new updateTablas(1); up.start(); } } }); f5.getjComboBox1().addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { DefaultTableModel temp2 = (DefaultTableModel) f5.getjTable2().getModel(); for (int i = temp2.getRowCount() - 1; i >= 0; i--) { temp2.removeRow(i); } f5.setComi(null); f5.setNinstalacion(""); f5.setNcliente(""); f5.setList(null); f5.setId(""); updateTablas up = new updateTablas(4); up.start(); } }); f3.getjTable1().addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = f3.getjTable1().getSelectedRow(); int col = f3.getjTable1().getSelectedColumn(); if (col == 6) { visible(f4); fcomisiones = f3.getjTable1().getValueAt(row, 6).toString(); try { ServiceHb helper = new ServiceHb(); helper.iniciarTransaccion(); Fcomisiones ft = (Fcomisiones) helper.obtenerObjeto(Fcomisiones.class, Integer.parseInt(fcomisiones)); numeroinstala = ft.getDias(); f4.setIdcliente("" + ft.getClientes().getId()); f4.setIdinstalacion("" + ft.getInstalacion().getId()); f4.getDiasint().setText(numeroinstala); helper.cerrarSesion(); } catch (Exception io) { } f4.getjLabel1().setText(fcomisiones); f4.getC1().setText(f3.getjTable1().getValueAt(row, 0).toString()); f4.getC2().setText(f3.getjTable1().getValueAt(row, 1).toString()); double campo1 = Double .parseDouble(f3.getjTable1().getValueAt(row, 3).toString().replace("$ ", "")); double campo2 = Double .parseDouble(f3.getjTable1().getValueAt(row, 4).toString().replace("-$ ", "")); f4.getC3().setText(f3.getjTable1().getValueAt(row, 3).toString()); f4.getC4().setText(f3.getjTable1().getValueAt(row, 4).toString()); f4.getC5().setText(f3.getjTable1().getValueAt(row, 5).toString()); f4.getC6().setText("$ " + df.format((campo1 - campo2)).replace(",", ".")); updateTablas up = new updateTablas(3); up.start(); } } }); setVisible(false); }
From source file:Model.GerarRelatorio.java
public void init() { /*JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory()); System.out.println("getSelectedFile() : " + chooser.getSelectedFile()); } else {/* w w w. j ava2 s . c om*/ System.out.println("No Selection "); } String saida = "\\RelatorioDiarioExecucao.pdf"; System.out.println(chooser.getSelectedFile() + saida); file = new File(chooser.getSelectedFile() + saida);*/ file = new File("C:\\Windows\\Temp\\" + relatorio.getNmRelatorio() + ".pdf"); file.delete(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { if (file.exists()) { file = new File("C:\\Windows\\Temp\\" + relatorio.getNmRelatorio() + "2.pdf"); } if (relatorio.getOrientacao().equalsIgnoreCase("Retrato")) { d = new Document(PageSize.A4); } else { d = new Document(PageSize.A4.rotate()); } paragrafos = new ArrayList<>(); tableHeader = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK); tableContent = new Font(FontFamily.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK); dateHeader(); preencheVariaveis(); preencheNomeColuna(); preenche(); printPdf(); } catch (Exception e) { } } }); }
From source file:Model.MyFontSelector.java
License:Open Source License
/** * Inicializa as fontes//from ww w . j a v a2 s . c o m * Initialize the fonts * @param baseFontList A List with the BaseFonts */ private void initFonts(ArrayList<BaseFont> baseFontList) { FontSelector fontSelectorTitle = new FontSelector(); FontSelector fontSelectorBlue = new FontSelector(); FontSelector fontSelectorGreen = new FontSelector(); FontSelector fontSelectorRed = new FontSelector(); FontSelector fontSelectorBlack = new FontSelector(); for (BaseFont bf : baseFontList) { Font TITLE = new Font(bf, 16, Font.BOLD, BaseColor.BLACK); Font BLUE = new Font(bf, 14, Font.NORMAL, BaseColor.BLUE); Font GREEN = new Font(bf, 14, Font.NORMAL, new BaseColor(8, 138, 75)); Font RED = new Font(bf, 14, Font.NORMAL, BaseColor.RED); Font BLACK = new Font(bf, 14, Font.NORMAL, BaseColor.BLACK); fontSelectorTitle.addFont(TITLE); fontSelectorBlue.addFont(BLUE); fontSelectorGreen.addFont(GREEN); fontSelectorRed.addFont(RED); fontSelectorBlack.addFont(BLACK); } fontSelectors.put("TITLE", fontSelectorTitle); fontSelectors.put("BLUE", fontSelectorBlue); fontSelectors.put("GREEN", fontSelectorGreen); fontSelectors.put("RED", fontSelectorRed); fontSelectors.put("BLACK", fontSelectorBlack); }
From source file:model.PDFModel.java
License:Open Source License
public PdfPTable createTablePDFTable(int counter, String raportDate) { JTable resultTable = query.getProductsInTablePDFTable(raportDate, counter); PdfPTable[] tableTable = new PdfPTable[11]; PdfPCell cell, productNameCell, paymentCell, countCell, priceCell; tableTable[counter] = new PdfPTable(4); tableTable[counter].setSpacingBefore(5f); tableTable[counter].setSpacingAfter(5f); totalTablePayment[counter] = 0.00;//w w w . jav a 2 s. c o m if (resultTable != null) { DefaultTableModel resultTableModel = (DefaultTableModel) resultTable.getModel(); if (resultTableModel.getRowCount() > 0) { cell = new PdfPCell(new Phrase("Stolik " + (counter))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 255, 50)); tableTable[counter].addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); tableTable[counter].addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); tableTable[counter].addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase("Produkt")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase("Ilosc")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase("Cena jednostkowa")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase("Zaplata")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); tableTable[counter].addCell(cell); for (int i = 0; i < resultTableModel.getRowCount(); i++) { productNameCell = new PdfPCell(new Phrase(resultTableModel.getValueAt(i, 0).toString(), FontFactory.getFont(FontFactory.defaultEncoding, 10, Font.NORMAL, BaseColor.BLACK))); productNameCell.setHorizontalAlignment(Element.ALIGN_CENTER); productNameCell.setBackgroundColor(new BaseColor(80, 135, 8)); tableTable[counter].addCell(productNameCell); countCell = new PdfPCell(new Phrase(String.valueOf(resultTableModel.getValueAt(i, 2)))); countCell.setHorizontalAlignment(Element.ALIGN_CENTER); tableTable[counter].addCell(countCell); double payment = Double.parseDouble(resultTableModel.getValueAt(i, 1).toString()) * Double.parseDouble(resultTableModel.getValueAt(i, 2).toString()); totalTablePayment[counter] += payment; paymentCell = new PdfPCell(new Phrase(String.valueOf(resultTableModel.getValueAt(i, 1)))); paymentCell.setHorizontalAlignment(Element.ALIGN_CENTER); tableTable[counter].addCell(paymentCell); priceCell = new PdfPCell(new Phrase(String.valueOf(payment))); priceCell.setHorizontalAlignment(Element.ALIGN_CENTER); priceCell.setBackgroundColor(new BaseColor(255, 160, 160)); tableTable[counter].addCell(priceCell); } } } if (totalTablePayment[counter] > 0.00) { cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); tableTable[counter].addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase("SUMA:", FontFactory.getFont(FontFactory.defaultEncoding, 12, Font.NORMAL, BaseColor.BLACK))); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(totalTablePayment[counter]), FontFactory.getFont(FontFactory.defaultEncoding, 12, Font.BOLD, BaseColor.BLACK))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(255, 50, 50)); tableTable[counter].addCell(cell); } return tableTable[counter]; }
From source file:modelo.crearPdf.java
public String pdf(int tiquet, int idOrden, String codOrden) { try {//ww w .j av a 2 s . co m String sql = "Select * from tiquet where idorden = '" + idOrden + "' and tiquet='" + tiquet + "'"; rs = Consultar(sql); int id = 0; int numTiquet = 0; String ob = ""; tiquet verTiquet = new tiquet(); colores verColor = new colores(); String colorUno = ""; String colorDos = ""; System.out.print("id de la orden en el tiquet:" + idOrden); ArrayList<String> lista = new ArrayList<String>(); int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0, c13 = 0, c14 = 0, c15 = 0; int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0, c27 = 0, c28 = 0, c29 = 0; int c30 = 0, c31 = 0, c32 = 0, c33 = 0; String observacion = ""; String verificacion = ""; //rs.last(); int cuantos = rs.getRow(); //System.out.print("puestos:" + cuantos+ "orden: " + codOrden + "tiquet: " + tiquet); //Creamos el CHUNK definiendo su tipo de letra, tamao Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Tiq = new Chunk("Tiquet #", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValTiq = new Chunk("" + tiquet, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Tel = new Chunk("Tel: 5783364", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Ref = new Chunk("Ref", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValRef = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Correo = new Chunk("calzadoseiya@gmail.com", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Par = new Chunk("Pares", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValPar = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FechaTiq = new Chunk("Fecha", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FechaTiq2 = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Orden = new Chunk("Orden", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValOrd = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Cor = new Chunk("CORTADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Guar = new Chunk("GUARNICION", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Mon = new Chunk("MONTADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Emp = new Chunk("EMPLANTILLADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk OBSER = new Chunk("OBSERVACION", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Col1 = new Chunk("Color 1", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Col2 = new Chunk("Color 2", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Encabezado = new Chunk("SEIYA", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK)); Chunk num21 = new Chunk("21", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num22 = new Chunk("22", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num23 = new Chunk("23", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num24 = new Chunk("24", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num25 = new Chunk("25", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num26 = new Chunk("26", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num27 = new Chunk("27", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num28 = new Chunk("28", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num29 = new Chunk("29", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num30 = new Chunk("30", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num31 = new Chunk("31", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num32 = new Chunk("32", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num33 = new Chunk("33", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num34 = new Chunk("34", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num35 = new Chunk("35", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num36 = new Chunk("36", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num37 = new Chunk("37", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num38 = new Chunk("38", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num39 = new Chunk("39", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num40 = new Chunk("40", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num41 = new Chunk("41", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num42 = new Chunk("42", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num43 = new Chunk("43", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num44 = new Chunk("44", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); //Fecha actual en formato completo: //Tue Sep 23 01:18:48 CEST 2014 Date fechaActual = new Date(); //Formateando la fecha: DateFormat formatoHora = new SimpleDateFormat("HH-mm-ss"); DateFormat formatoFecha = new SimpleDateFormat("yyyy-MM-dd"); DateFormat Fecha = new SimpleDateFormat("dd/MM/yyyy"); // System.out.println("Fecha: "+formatoFecha.format(fechaActual)+" Son las: "+formatoHora.format(fechaActual)); String fe = Fecha.format(fechaActual); //Directorio destino para las descargas File folder = new File("c:\\seiya\\tiquets"); //Crea el directorio de destino en caso de que no exista folder.mkdirs(); int numeroAleatorio = (int) (Math.random() * 2500 + 1); //Nombre del fichero <strong>PDF</strong> Resultante de la ejecucion String dir = "C:\\seiya\\tiquets\\Tiquet_" + tiquet + ".pdf"; // El archivo pdf que vamos a generar FileOutputStream fileOutputStream = new FileOutputStream(dir); Rectangle pageSize = new Rectangle(300f, 792f); //ancho y alto //Creacion del documento con un tamao y unos margenes predeterminados Document document = new Document(pageSize, 1, 1, 1, 1); // Obtener la instancia del PdfWriter PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream); //Opens the document. //You have to open the document before you can begin to add content to the body of the document. document.open(); //************************************************************** //Ejemplos de TABLE titulo = new Chunk("", FontFactory.getFont(FontFactory.COURIER, 20, Font.UNDERLINE, BaseColor.BLACK)); document.add(titulo); //Aadir tabla 5 columnas PdfPTable table = new PdfPTable(15); //Aadir CABECERA PdfPCell cell = new PdfPCell(); cell.setColspan(15); table.addCell(cell); Image image = Image.getInstance("logo.png"); // String col = "jhon"; cell = new PdfPCell(image); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(7); table.addCell(cell); /* cell = new PdfPCell(new Phrase("imagen:")); cell.setColspan(4); cell.setRowspan(7); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); /*table.addCell(createImageCell(IMG1));*/ cell = new PdfPCell(new Phrase(direccion)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(6); cell.setRowspan(2); table.addCell(cell); while (rs.next()) { c1 = rs.getInt(1); c2 = rs.getInt(2); c3 = rs.getInt(3); c4 = rs.getInt(4); c5 = rs.getInt(5); observacion = rs.getString(6); verificacion = rs.getString(7); c8 = rs.getInt(8); c9 = rs.getInt(9); c10 = rs.getInt(10); c11 = rs.getInt(11); c12 = rs.getInt(12); c13 = rs.getInt(13); c14 = rs.getInt(14); c15 = rs.getInt(15); c16 = rs.getInt(16); c17 = rs.getInt(17); c18 = rs.getInt(18); c19 = rs.getInt(19); c20 = rs.getInt(20); c21 = rs.getInt(21); c22 = rs.getInt(22); c23 = rs.getInt(23); c24 = rs.getInt(24); c25 = rs.getInt(25); c26 = rs.getInt(26); c27 = rs.getInt(27); c28 = rs.getInt(28); c29 = rs.getInt(29); c30 = rs.getInt(30); c31 = rs.getInt(31); c32 = rs.getInt(32); c33 = rs.getInt(33); String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ", c09 = " ", c010 = " ", c011 = " ", c012 = " "; String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ", c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " "; String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ", c032 = " ", c033 = " ", c034 = " "; if (c1 != 0) c01 = String.valueOf(c1); if (c2 != 0) c02 = String.valueOf(c2); if (c3 != 0) c03 = String.valueOf(c3); if (c4 != 0) c04 = String.valueOf(c4); if (c5 != 0) c05 = String.valueOf(c5); if (c8 != 0) c08 = String.valueOf(c8); if (c9 != 0) c09 = String.valueOf(c9); if (c10 != 0) c010 = String.valueOf(c10); if (c11 != 0) c011 = String.valueOf(c11); if (c12 != 0) c012 = String.valueOf(c12); if (c13 != 0) c013 = String.valueOf(c13); if (c14 != 0) c014 = String.valueOf(c14); if (c15 != 0) c015 = String.valueOf(c15); if (c16 != 0) c016 = String.valueOf(c16); if (c17 != 0) c017 = String.valueOf(c17); if (c18 != 0) c018 = String.valueOf(c18); if (c19 != 0) c019 = String.valueOf(c19); if (c20 != 0) c020 = String.valueOf(c20); if (c21 != 0) c021 = String.valueOf(c21); if (c22 != 0) c022 = String.valueOf(c22); if (c23 != 0) c023 = String.valueOf(c23); if (c24 != 0) c024 = String.valueOf(c24); if (c25 != 0) c025 = String.valueOf(c25); if (c26 != 0) c026 = String.valueOf(c26); if (c27 != 0) c027 = String.valueOf(c27); if (c28 != 0) c028 = String.valueOf(c28); if (c29 != 0) c029 = String.valueOf(c29); if (c30 != 0) c030 = String.valueOf(c30); if (c31 != 0) c031 = String.valueOf(c31); if (c32 != 0) c032 = String.valueOf(c32); if (c33 != 0) c033 = String.valueOf(c33); colorUno = verColor.consultarNombreColorUno(c4); colorDos = verColor.consultarNombreColorDos(c5); ob = verTiquet.ConsultaObservacion(tiquet); Chunk ValCol1 = new Chunk(colorUno, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValCol2 = new Chunk(colorDos, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValObserv = new Chunk(ob, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); System.out.print("Color Uno: " + colorUno); cell = new PdfPCell(new Phrase(Tiq)); cell.setColspan(3); cell.setRowspan(2); cell.setVerticalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); cell = new PdfPCell(new Phrase("" + tiquet)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Tel)); cell.setColspan(6); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase(Ref)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("" + c8)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Correo)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(6); cell.setRowspan(2);//para eliminar espacio cabecera reemplazo el 2 por 3 table.addCell(cell); cell = new PdfPCell(new Phrase(Par)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("" + c9)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(FechaTiq));//espacio intermedio cabecera cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(fe));//espacio intermedio cabecera cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase(Orden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("" + codOrden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cor)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Guar)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); table.addCell(cell); cell = new PdfPCell(new Phrase(Mon)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); table.addCell(cell); cell = new PdfPCell(new Phrase(Emp)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); table.addCell(cell); cell = new PdfPCell(new Phrase(OBSER)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(ValObserv)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Col1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase(ValCol1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase(Col2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase(ValCol2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); table.addCell(cell); table.addCell(new Phrase(num21)); table.addCell(new Phrase(num22)); table.addCell(new Phrase(num23)); table.addCell(new Phrase(num24)); table.addCell(new Phrase(num25)); table.addCell(new Phrase(num26)); table.addCell(new Phrase(num27)); table.addCell(new Phrase(num28)); table.addCell(new Phrase(num29)); table.addCell(new Phrase(num30)); table.addCell(new Phrase(num31)); table.addCell(new Phrase(num32)); table.addCell(new Phrase(num33)); table.addCell(new Phrase(num34)); table.addCell(new Phrase(num35)); table.addCell("" + c010); table.addCell("" + c011); table.addCell("" + c012); table.addCell("" + c013); table.addCell("" + c014); table.addCell("" + c015); table.addCell("" + c016); table.addCell("" + c017); table.addCell("" + c018); table.addCell("" + c019); table.addCell("" + c020); table.addCell("" + c021); table.addCell("" + c022); table.addCell("" + c023); table.addCell("" + c024); table.addCell(new Phrase(num36)); table.addCell(new Phrase(num37)); table.addCell(new Phrase(num38)); table.addCell(new Phrase(num39)); table.addCell(new Phrase(num40)); table.addCell(new Phrase(num41)); table.addCell(new Phrase(num42)); table.addCell(new Phrase(num43)); table.addCell(new Phrase(num44)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell("" + c025); table.addCell("" + c026); table.addCell("" + c027); table.addCell("" + c028); table.addCell("" + c029); table.addCell("" + c030); table.addCell("" + c031); table.addCell("" + c032); table.addCell("" + c033); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.setWidthPercentage(100f); table.setHorizontalAlignment(Element.ALIGN_RIGHT); document.add(table); // String cadena=""; Chunk cadena = null; for (int i = 1; i <= 4; i++) { //Chunk chunkSeparador = new Chunk(SEPARADOR); // document.add(chunkSeparador); // document.add(Chunk.NEWLINE); PdfPTable tabla = new PdfPTable(15); if (i == 1) cadena = Emp; if (i == 2) cadena = Mon; if (i == 3) { cadena = Guar; } if (i == 4) cadena = Cor; cell = new PdfPCell( new Phrase("-----------------------------------------------------------------")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(15); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Encabezado)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(cadena)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Tiq)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("" + tiquet)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Par)); cell.setHorizontalAlignment(Font.BOLD); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("" + c9)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Ref)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("" + c8)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Col1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); tabla.addCell(cell); cell = new PdfPCell(new Phrase(ValCol1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Col2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); tabla.addCell(cell); cell = new PdfPCell(new Phrase(ValCol2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); tabla.addCell(cell); tabla.addCell(new Phrase(num21)); tabla.addCell(new Phrase(num22)); tabla.addCell(new Phrase(num23)); tabla.addCell(new Phrase(num24)); tabla.addCell(new Phrase(num25)); tabla.addCell(new Phrase(num26)); tabla.addCell(new Phrase(num27)); tabla.addCell(new Phrase(num28)); tabla.addCell(new Phrase(num29)); tabla.addCell(new Phrase(num30)); tabla.addCell(new Phrase(num31)); tabla.addCell(new Phrase(num32)); tabla.addCell(new Phrase(num33)); tabla.addCell(new Phrase(num34)); tabla.addCell(new Phrase(num35)); tabla.addCell("" + c010); tabla.addCell("" + c011); tabla.addCell("" + c012); tabla.addCell("" + c013); tabla.addCell("" + c014); tabla.addCell("" + c015); tabla.addCell("" + c016); tabla.addCell("" + c017); tabla.addCell("" + c018); tabla.addCell("" + c019); tabla.addCell("" + c020); tabla.addCell("" + c021); tabla.addCell("" + c022); tabla.addCell("" + c023); tabla.addCell("" + c024); tabla.addCell(new Phrase(num36)); tabla.addCell(new Phrase(num37)); tabla.addCell(new Phrase(num38)); tabla.addCell(new Phrase(num39)); tabla.addCell(new Phrase(num40)); tabla.addCell(new Phrase(num41)); tabla.addCell(new Phrase(num42)); tabla.addCell(new Phrase(num43)); tabla.addCell(new Phrase(num44)); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell("" + c025); tabla.addCell("" + c026); tabla.addCell("" + c027); tabla.addCell("" + c028); tabla.addCell("" + c029); tabla.addCell("" + c030); tabla.addCell("" + c031); tabla.addCell("" + c032); tabla.addCell("" + c033); tabla.addCell(""); tabla.addCell(""); tabla.addCell(""); tabla.addCell(""); tabla.addCell(""); tabla.addCell(""); tabla.setWidthPercentage(100f); tabla.setHorizontalAlignment(Element.ALIGN_RIGHT); document.add(tabla); } //FIN Ejemplos de TABLE } document.close(); return "exito"; } catch (Exception ex) { System.out.println(ex.getMessage()); return "Error al Generar el PDF"; } }
From source file:Modelo.generatePDF.java
public void generatePDFFactura(String url, Object cliente_proveedor, ArrayList<ArticuloPedido> articulos, double suma) { try {//from www .jav a 2 s .c om Document documento = new Document();//Creamos el documento FileOutputStream ficheroPdf = new FileOutputStream(url + "_factura.pdf");//Abrimos el flujo y le asignamos nombre al pdf y su direccion PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20);//Instanciamos el documento con el fichero documento.open();//Abrimos el documento Cliente c = (Cliente) cliente_proveedor; documento.add(new Paragraph("FACTURA", FontFactory.getFont("arial", 30, Font.BOLD, BaseColor.BLACK)));//Le indicamos el tipo de letra, el tamanio, el estilo y el color de la letra documento.add(new Paragraph(" "));//Realiza un salto de linea documento.add(new Paragraph("---DATOS--- "));//Crea un parrafo con el String que le introduzcamos //Le decimos que nos imprima el Dni, Nombre y Apellidos del cliente, contenidos en el objeto Cliente y le indicamos el tipo de letra, tamanio, estilo y color de la letra documento.add(new Paragraph("DNI: " + c.getDni(), FontFactory.getFont("arial", 25, Font.BOLD, BaseColor.BLACK))); documento.add(new Paragraph("NOMBRE: " + c.getNombre(), FontFactory.getFont("arial", 25, Font.BOLD, BaseColor.BLACK))); documento.add(new Paragraph("APELLIDOS: " + c.getApellidos(), FontFactory.getFont("arial", 25, Font.BOLD, BaseColor.BLACK))); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); int cont = 0;//Este contador se usara para que cuando sea la primera vez que inserta datos en la tabla inserte los nombres de las columnas en vez de datos PdfPTable tabla = new PdfPTable(3);//Creamos una tabla de tres columnas //Insertaremos todos los articulos del pedido Iterator it = articulos.iterator(); while (it.hasNext()) { if (cont == 0) { tabla.addCell("NOMBRE"); tabla.addCell("PRECIO"); tabla.addCell("CANTIDAD"); } //Imprimimos en el PDF los nombres de los articulos del pedido, su precio y la cantidad comprada ArticuloPedido artPed = (ArticuloPedido) it.next(); tabla.addCell(artPed.getArticulo().getNombre()); tabla.addCell(Double.toString(artPed.getArticulo().getPrecio())); tabla.addCell(Integer.toString(artPed.getCantidad())); suma = suma + artPed.getArticulo().getPrecio() * artPed.getArticulo().getCantidad();//Imprimimos el coste de cada articulo en relacion a su cantidad cont++; } documento.add(tabla);//Aadimos la tabla al documento documento.add(new Paragraph("")); documento.add(new Paragraph("TOTAL: " + suma + " ", FontFactory.getFont("arial", 25, Font.NORMAL, BaseColor.RED)));//Imprimimos el coste total del pedido documento.close();//Cerramos el flujo con el documento } catch (DocumentException ex) { Logger.getLogger(generatePDF.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(generatePDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:modelo.impOrdenCarta.java
public boolean impOrden(int idOrden, String codOrden, int numRegTiq) { try {//ww w.j av a2 s .c om int id = 0; int numTiquet = 0; String ob = ""; colores verColor = new colores(); String colorUno = ""; String colorDos = ""; ArrayList<String> lista = new ArrayList<String>(); int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0, c13 = 0, c14 = 0, c15 = 0; int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0, c27 = 0, c28 = 0, c29 = 0; int c30 = 0, c31 = 0, c32 = 0, c33 = 0; String observacion = ""; int CanTotal = 0; int idCliente = 0; String ciu = ""; String fecped = ""; String fecent = ""; for (orden ord : new orden().CargarDatosOrden(codOrden)) { idCliente = ord.getCliente(); ciu = ord.getCiudad(); fecped = ord.getPedido(); fecent = ord.getEntrega(); } String nomCliente = nuevaOrden.ConsultarNombreCliente(idCliente); Chunk idClient = new Chunk(nomCliente, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci", FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK)); Chunk Tiq = new Chunk("TK", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValTiq = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Tel = new Chunk("Tel: 5783364", FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK)); Chunk Ref = new Chunk("REF", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValRef = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Correo = new Chunk("calzadoseiya@gmail.com", FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK)); Chunk Cliente = new Chunk("CLIENTE", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FecEnt = new Chunk("FECHA ENTREGA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValFecEnt = new Chunk(fecent, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FecPed = new Chunk("FECHA PEDIDO", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValFecPed = new Chunk(fecped, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FechaTiq2 = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Orden = new Chunk("ORDEN", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValOrd = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Ciudad = new Chunk("CIUDAD", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValCiudad = new Chunk(ciu, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Cant = new Chunk("CANT.", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Mon = new Chunk("MONTADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Emp = new Chunk("EMPLANTILLADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk OBSER = new Chunk("OBSERVACION", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Col1 = new Chunk("Color 1", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Col2 = new Chunk("Color 2", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Encabezado = new Chunk("SEIYA", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK)); Chunk num21 = new Chunk("21", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num22 = new Chunk("22", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num23 = new Chunk("23", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num24 = new Chunk("24", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num25 = new Chunk("25", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num26 = new Chunk("26", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num27 = new Chunk("27", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num28 = new Chunk("28", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num29 = new Chunk("29", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num30 = new Chunk("30", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num31 = new Chunk("31", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num32 = new Chunk("32", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num33 = new Chunk("33", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num34 = new Chunk("34", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num35 = new Chunk("35", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num36 = new Chunk("36", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num37 = new Chunk("37", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num38 = new Chunk("38", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num39 = new Chunk("39", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num40 = new Chunk("40", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num41 = new Chunk("41", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num42 = new Chunk("42", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num43 = new Chunk("43", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num44 = new Chunk("44", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); File folder = new File("c:\\seiya\\ordenes"); folder.mkdirs(); String dir = "C:\\seiya\\ordenes\\Orden_" + codOrden + ".pdf"; // El archivo pdf que vamos a generar FileOutputStream fileOutputStream = new FileOutputStream(dir); Rectangle pageSize = new Rectangle(792f, 612f); Document document = new Document(pageSize, 1, 1, 1, 1); PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream); document.open(); PdfPTable table = new PdfPTable(40); PdfPCell cell = new PdfPCell(); Image image = Image.getInstance("logo.png"); // String col = "jhon"; cell = new PdfPCell(image); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(7); cell.setRowspan(7); table.addCell(cell); cell = new PdfPCell(new Phrase(direccion)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(33); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Tel)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(33); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Correo)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(33); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(33); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Tiq)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Orden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(codOrden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cliente)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(idClient)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(9); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Ciudad)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValCiudad)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(FecPed)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValFecPed)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(FecEnt)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValFecEnt)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Ref)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cant)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); table.addCell(new Phrase(num21)); table.addCell(new Phrase(num22)); table.addCell(new Phrase(num23)); table.addCell(new Phrase(num24)); table.addCell(new Phrase(num25)); table.addCell(new Phrase(num26)); table.addCell(new Phrase(num27)); table.addCell(new Phrase(num28)); table.addCell(new Phrase(num29)); table.addCell(new Phrase(num30)); table.addCell(new Phrase(num31)); table.addCell(new Phrase(num32)); table.addCell(new Phrase(num33)); table.addCell(new Phrase(num34)); table.addCell(new Phrase(num35)); table.addCell(new Phrase(num36)); table.addCell(new Phrase(num37)); table.addCell(new Phrase(num38)); table.addCell(new Phrase(num39)); table.addCell(new Phrase(num40)); table.addCell(new Phrase(num41)); table.addCell(new Phrase(num42)); table.addCell(new Phrase(num43)); cell = new PdfPCell(new Phrase(Col1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Col2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(OBSER)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); cell.setRowspan(1); table.addCell(cell); ArrayList<String> resultat; resultat = nuevoTiquet.consultarTiquetporOrden(idOrden); Iterator<String> tiquetIterator = resultat.iterator(); while (tiquetIterator.hasNext()) { String valorTiquet = tiquetIterator.next(); System.out.print(valorTiquet + " ------ "); int tiq = Integer.parseInt(valorTiquet); ArrayList<tiquet> listaDatosTiquet; listaDatosTiquet = nuevoTiquet.conten(idOrden, tiq);//La consulta tiene que retornar un ArrayList for (tiquet ord : new tiquet().conten(idOrden, tiq)) { System.out.print("Referencia: " + nuevoTiquet.ConsultarReferencia(tiq, idOrden)); c1 = ord.getTiquet(); c2 = ord.getIdorden(); observacion = ord.getObservacion(); c4 = nuevoTiquet.ConsultarReferencia(tiq, idOrden); c5 = nuevoTiquet.ConsultarCantidad(tiq, idOrden); c8 = ord.getN21(); c9 = ord.getN22(); c10 = ord.getN23(); c11 = ord.getN24(); c12 = ord.getN25(); c13 = ord.getN26(); c14 = ord.getN27(); c15 = ord.getN28(); c16 = ord.getN29(); c17 = ord.getN30(); c18 = ord.getN31(); c19 = ord.getN32(); c20 = ord.getN33(); c21 = ord.getN34(); c22 = ord.getN35(); c23 = ord.getN36(); c24 = ord.getN37(); c25 = ord.getN38(); c26 = ord.getN39(); c27 = ord.getN40(); c28 = ord.getN41(); c29 = ord.getN42(); c30 = ord.getN43(); String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ", c09 = " ", c010 = " ", c011 = " ", c012 = " "; String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ", c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " "; String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ", c032 = " ", c033 = " ", c034 = " "; if (c1 != 0) c01 = String.valueOf(c1); if (c2 != 0) c02 = String.valueOf(c2); // if(c3!=0) c03 = String.valueOf(c3); if (c4 != 0) c04 = String.valueOf(c4); if (c5 != 0) { c05 = String.valueOf(c5); CanTotal += c5; } if (c8 != 0) c08 = String.valueOf(c8); if (c9 != 0) c09 = String.valueOf(c9); if (c10 != 0) c010 = String.valueOf(c10); if (c11 != 0) c011 = String.valueOf(c11); if (c12 != 0) c012 = String.valueOf(c12); if (c13 != 0) c013 = String.valueOf(c13); if (c14 != 0) c014 = String.valueOf(c14); if (c15 != 0) c015 = String.valueOf(c15); if (c16 != 0) c016 = String.valueOf(c16); if (c17 != 0) c017 = String.valueOf(c17); if (c18 != 0) c018 = String.valueOf(c18); if (c19 != 0) c019 = String.valueOf(c19); if (c20 != 0) c020 = String.valueOf(c20); if (c21 != 0) c021 = String.valueOf(c21); if (c22 != 0) c022 = String.valueOf(c22); if (c23 != 0) c023 = String.valueOf(c23); if (c24 != 0) c024 = String.valueOf(c24); if (c25 != 0) c025 = String.valueOf(c25); if (c26 != 0) c026 = String.valueOf(c26); if (c27 != 0) c027 = String.valueOf(c27); if (c28 != 0) c028 = String.valueOf(c28); if (c29 != 0) c029 = String.valueOf(c29); if (c30 != 0) c030 = String.valueOf(c30); cell = new PdfPCell(new Phrase(String.valueOf(tiq))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c04)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c05)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c08)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c09)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c010)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c011)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c012)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c013)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c014)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c015)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c016)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c017)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c018)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c019)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c020)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c021)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c022)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c023)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c024)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c025)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c026)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c027)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c028)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c029)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c030)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); colorUno = verColor.consultarNombreColorUno(ord.getIdcoloruno()); colorDos = verColor.consultarNombreColorDos(ord.getIdcolordos()); // ob = verTiquet.ConsultaObservacion(tiquet); Chunk ValCol1 = new Chunk(colorUno, FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValCol2 = new Chunk(colorDos, FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValObserv = new Chunk(ord.getObservacion(), FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)); cell = new PdfPCell(new Phrase(ValCol1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValCol2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValObserv)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); cell.setRowspan(1); table.addCell(cell); } } cell = new PdfPCell(new Phrase("Cantidad Total de Pares Producidos ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(15); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(CanTotal))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(25); cell.setRowspan(1); table.addCell(cell); table.setWidthPercentage(95f); table.setHorizontalAlignment(Element.ALIGN_CENTER); document.add(table); document.close(); return true; } catch (Exception x) { return false; } }