List of usage examples for com.itextpdf.text Image getInstance
public static Image getInstance(final Image image)
From source file:Modelo.DAO.RecetasDAO.java
public void generaPDF(String Indicaciones, String Medicamentos, Paciente paciente, Integer idPaciente) throws FileNotFoundException, DocumentException, IOException { Calendar cal = Calendar.getInstance(); String time = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(cal.getTime()); String timename = new SimpleDateFormat("yyyyMMddHHmm").format(cal.getTime()); File file = new File("Receta" + timename + ".pdf"); FileOutputStream fileout = new FileOutputStream(file); Document document = new Document(); PdfWriter writer;/*from w w w .j a v a 2 s . c o m*/ writer = PdfWriter.getInstance(document, fileout); Font fuente = new Font(); Font fuente2 = new Font(); // fuente.setColor(BaseColor.BLUE); fuente.setStyle(Font.BOLD | Font.UNDERLINE); fuente2.setStyle(Font.BOLD); fuente2.setSize(20); document.open(); document.add(new Paragraph("\n \n \n \n \n")); document.add(new Paragraph("Clinica Mdica INFTEL", fuente2)); String imageUrl = "src/Imagen/logo.png"; Image image = Image.getInstance(imageUrl); image.setAbsolutePosition(300, 750); image.scalePercent(80f); document.add(image); document.add(new Paragraph(" ")); document.add(new Paragraph("---------------------")); document.add(new Paragraph("DATOS DEL PACIENTE", fuente)); document.add(new Paragraph(" ")); document.add( new Paragraph("Apellidos y Nombre : " + paciente.getApellidos() + ", " + paciente.getNombre())); document.add(new Paragraph("NIF : " + paciente.getNif())); document.add(new Paragraph("NSS : " + paciente.getNumSS())); document.add(new Paragraph("Direccion : " + paciente.getDireccion())); document.add(new Paragraph("Telefono : " + paciente.getTelefono())); document.add(new Paragraph("Email : " + paciente.getEmail())); document.add(new Paragraph("ID Paciente : " + idPaciente)); document.add(new Paragraph(" ")); document.add(new Paragraph("---------------------")); document.add(new Paragraph(" ")); document.add(new Paragraph("DATOS CL?NICOS", fuente)); document.add(new Paragraph(" ")); document.add(new Paragraph("Diagnstico : ")); document.add(new Paragraph(Indicaciones)); document.add(new Paragraph(" ")); document.add(new Paragraph("Tratamiento : ")); document.add(new Paragraph(Medicamentos)); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); absText(writer, time, 450, 50); document.close(); }
From source file:modelo.DTO.PDF_Registro2.java
public static void generar() throws DocumentException, FileNotFoundException, BadElementException, IOException { Rectangle pageSize = new Rectangle(816f, 1056f); //ancho y alto miPDF = new Document(pageSize, 0, 0, 0, 0); PdfWriter.getInstance(miPDF, new FileOutputStream(PDF_Registro2.rutaDestino + ".pdf")); miPDF.open();//from www . jav a 2 s.c o m miPDF.addTitle("Registro"); miPDF.addAuthor("Universidad Tecnolgica de Len"); miPDF.addSubject("Constancia de Registro"); miPDF.addKeywords("1"); //Inicio //Image foto = Image.getInstance("src/imagens/Registro.png"); String thisIp = InetAddress.getLocalHost().getHostAddress(); Image foto = Image.getInstance("http://" + thisIp + ":8084/ExamenParcial2Web/imagenes/Registro.png"); foto.setAlignment(Chunk.ALIGN_MIDDLE); foto.scaleToFit(816, 754); miPDF.add(foto); PdfPTable ta = new PdfPTable(2); PdfPCell celda; celda = new PdfPCell(new Paragraph("\nClave:\n\n", FontFactory.getFont("arial", 12, Font.BOLD))); celda.setBorderColor(BaseColor.WHITE); ta.addCell(celda); celda = new PdfPCell(new Paragraph("\n" + clave + "\n\n")); celda.setBorderColor(BaseColor.WHITE); ta.addCell(celda); celda = new PdfPCell(new Paragraph("\nNombre:\n\n", FontFactory.getFont("arial", 12, Font.BOLD))); celda.setBorderColor(BaseColor.WHITE); ta.addCell(celda); celda = new PdfPCell(new Paragraph("\n" + nombre + "\n\n")); celda.setBorderColor(BaseColor.WHITE); ta.addCell(celda); celda = new PdfPCell(new Paragraph("\nE-mail:\n\n", FontFactory.getFont("arial", 12, Font.BOLD))); celda.setBorderColor(BaseColor.WHITE); ta.addCell(celda); celda = new PdfPCell(new Paragraph("\n" + email + "\n\n")); celda.setBorderColor(BaseColor.WHITE); ta.addCell(celda); celda = new PdfPCell(new Paragraph("\nUT:\n\n", FontFactory.getFont("arial", 12, Font.BOLD))); celda.setBorderColor(BaseColor.WHITE); ta.addCell(celda); celda = new PdfPCell(new Paragraph("\n" + procedencia + "\n\n")); celda.setBorderColor(BaseColor.WHITE); ta.addCell(celda); miPDF.add(ta); miPDF.close(); //Fin miPDF.close(); }
From source file:modelo.GenerarPDF.java
public void nuevoReporteClientes(ArrayList<Cliente> Datos) throws IOException { // Se crea el documento Document documento = new Document(); // Se crea el OutputStream para el fichero donde queremos dejar el pdf. Document documento = null;/*from w w w.j av a2s. c o m*/ try { FileOutputStream ficheroPdf = new FileOutputStream("C:\\Users\\panle\\Documents\\ReporteClientes.pdf"); documento = new Document(); // Se asocia el documento al OutputStream y se indica que el espaciado entre // lineas sera de 20. Esta llamada debe hacerse antes de abrir el documento PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); // Se abre el documento. documento.open(); documento.add(new Paragraph("REPORTE CLIENTES", FontFactory.getFont("ARIAL", // fuente 16, // tamao Font.ITALIC, // estilo BaseColor.BLACK))); // color PdfPTable tabla = new PdfPTable(9); Font font = new Font(FontFamily.COURIER, 6, Font.BOLD, BaseColor.BLACK); PdfPCell cell = new PdfPCell(new Phrase("algo", font)); documento.add(new Paragraph("\n")); Image img = Image.getInstance("C:\\Users\\panle\\Documents\\logo.png"); documento.add(img); documento.add(new Paragraph("\n")); int conta = 0; cell.setBorder(Rectangle.TITLE); tabla.addCell("NOMBRE COMLETO"); tabla.addCell("USUARIO"); tabla.addCell("NIT"); tabla.addCell("NO DOCUMENTO"); tabla.addCell("PROFESION"); tabla.addCell("TELFONO CELULAR"); tabla.addCell("TELFONO RESIDENCIA"); tabla.addCell("DIRECCIN"); tabla.addCell("CIUDAD"); while (conta < Datos.size()) { cell.setBorder(Rectangle.NO_BORDER); tabla.addCell(Datos.get(conta).getNOMBRE() + " " + Datos.get(conta).getAPELLIDO()); tabla.addCell(Datos.get(conta).getUSUARIO()); tabla.addCell(Datos.get(conta).getNIT()); tabla.addCell(Datos.get(conta).getNUMERO_DOC()); tabla.addCell(Datos.get(conta).getPROFESION()); tabla.addCell(Datos.get(conta).getTEL_CEL()); tabla.addCell(Datos.get(conta).getTEL_RESIDENCIA()); tabla.addCell(Datos.get(conta).getDIRECCION()); tabla.addCell(Datos.get(conta).getCIUDAD()); conta++; } documento.add(tabla); documento.close(); } catch (FileNotFoundException | DocumentException e) { System.out.println("Error al generar Reporte Clientes, por:"); e.printStackTrace(); } }
From source file:modelo.GenerarPDF.java
public void nuevoReporteProductos(ArrayList<Producto> Datos) throws IOException { // Se crea el documento Document // Se crea el OutputStream para el fichero donde queremos dejar el pdf. Document documento = null;//from w w w .ja v a 2 s. c om try { //Direccion root FileOutputStream ficheroPdf = new FileOutputStream("C:\\Users\\panle\\Documents\\ReporteProductos.pdf"); //FileOutputStream ficheroPdf = new FileOutputStream("user.dir/tmp", "ReporteProductos.pdf"); //File tempfile = new File("user.dir/tmp", "tempfile.txt"); documento = new Document(); // Se asocia el documento al OutputStream y se indica que el espaciado entre // lineas sera de 20. Esta llamada debe hacerse antes de abrir el documento PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); // Se abre el documento documento.open(); documento.add(new Paragraph("REPORTE PRODUCTOS", FontFactory.getFont("ARIAL", // fuente 16, // tamao Font.ITALIC, // estilo BaseColor.BLACK))); // color PdfPTable tabla = new PdfPTable(3);//#campos(columnas) para la tabla Font font = new Font(FontFamily.COURIER, 6, Font.BOLD, BaseColor.BLACK); PdfPCell cell = new PdfPCell(new Phrase("Celdas", font)); documento.add(new Paragraph("\n")); Image img = Image.getInstance("C:\\Users\\logo.png"); documento.add(img); documento.add(new Paragraph("\n")); int conta = 0; cell.setBorder(Rectangle.TITLE); tabla.addCell("DESCRIPCION"); tabla.addCell("REFERENCIA"); tabla.addCell("TIPO"); while (conta < Datos.size()) { cell.setBorder(Rectangle.NO_BORDER); tabla.addCell(Datos.get(conta).getDESCRIPCION()); tabla.addCell(Datos.get(conta).getREFERENCIA()); tabla.addCell(Datos.get(conta).getTIPO()); conta++; } documento.add(tabla); documento.close(); } catch (FileNotFoundException | DocumentException e) { System.out.println("Error al generar Reporte Productos, por:"); e.printStackTrace(); } }
From source file:modelo.GenerarPDF.java
public void nuevoReporteVentasFecha(ArrayList<Producto> Datos) throws IOException { // Se crea el documento Document // Se crea el OutputStream para el fichero donde queremos dejar el pdf. Document documento = null;/*w w w. ja va2 s .c o m*/ try { //Direccion root FileOutputStream ficheroPdf = new FileOutputStream( "C:\\Users\\panle\\Documents\\ReporteVentasFecha.pdf"); //FileOutputStream ficheroPdf = new FileOutputStream("user.dir/tmp", "ReporteProductos.pdf"); //File tempfile = new File("user.dir/tmp", "tempfile.txt"); documento = new Document(); // Se asocia el documento al OutputStream y se indica que el espaciado entre // lineas sera de 20. Esta llamada debe hacerse antes de abrir el documento PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); // Se abre el documento documento.open(); documento.add(new Paragraph("REPORTE VENTAS POR FECHA", FontFactory.getFont("ARIAL", // fuente 16, // tamao Font.ITALIC, // estilo BaseColor.BLACK))); // color PdfPTable tabla = new PdfPTable(3);//#campos(columnas) para la tabla Font font = new Font(FontFamily.COURIER, 6, Font.BOLD, BaseColor.BLACK); PdfPCell cell = new PdfPCell(new Phrase("Celdas", font)); documento.add(new Paragraph("\n")); Image img = Image.getInstance("C:\\Users\\logo.png"); documento.add(img); documento.add(new Paragraph("\n")); int conta = 0; cell.setBorder(Rectangle.TITLE); tabla.addCell("DESCRIPCION"); tabla.addCell("REFERENCIA"); tabla.addCell("TIPO"); while (conta < Datos.size()) { cell.setBorder(Rectangle.NO_BORDER); tabla.addCell(Datos.get(conta).getDESCRIPCION()); tabla.addCell(Datos.get(conta).getREFERENCIA()); tabla.addCell(Datos.get(conta).getTIPO()); conta++; } documento.add(tabla); documento.close(); } catch (FileNotFoundException | DocumentException e) { System.out.println("Error al generar Reporte Productos, por:"); e.printStackTrace(); } }
From source file:modelo.GenerarPDF.java
public void nuevoReporteVentasCiudad(ArrayList<Producto> Datos) throws IOException { // Se crea el documento Document // Se crea el OutputStream para el fichero donde queremos dejar el pdf. Document documento = null;/*from w w w. j a v a 2s . c om*/ try { //Direccion root FileOutputStream ficheroPdf = new FileOutputStream( "C:\\Users\\panle\\Documents\\ReporteVentasCiudad.pdf"); //FileOutputStream ficheroPdf = new FileOutputStream("user.dir/tmp", "ReporteProductos.pdf"); //File tempfile = new File("user.dir/tmp", "tempfile.txt"); documento = new Document(); // Se asocia el documento al OutputStream y se indica que el espaciado entre // lineas sera de 20. Esta llamada debe hacerse antes de abrir el documento PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); // Se abre el documento documento.open(); documento.add(new Paragraph("REPORTE VENTAS POR CIUDAD", FontFactory.getFont("ARIAL", // fuente 16, // tamao Font.ITALIC, // estilo BaseColor.BLACK))); // color PdfPTable tabla = new PdfPTable(3);//#campos(columnas) para la tabla Font font = new Font(FontFamily.COURIER, 6, Font.BOLD, BaseColor.BLACK); PdfPCell cell = new PdfPCell(new Phrase("Celdas", font)); documento.add(new Paragraph("\n")); Image img = Image.getInstance("C:\\Users\\logo.png"); documento.add(img); documento.add(new Paragraph("\n")); int conta = 0; cell.setBorder(Rectangle.TITLE); tabla.addCell("DESCRIPCION"); tabla.addCell("REFERENCIA"); tabla.addCell("TIPO"); while (conta < Datos.size()) { cell.setBorder(Rectangle.NO_BORDER); tabla.addCell(Datos.get(conta).getDESCRIPCION()); tabla.addCell(Datos.get(conta).getREFERENCIA()); tabla.addCell(Datos.get(conta).getTIPO()); conta++; } documento.add(tabla); documento.close(); } catch (FileNotFoundException | DocumentException e) { System.out.println("Error al generar Reporte Productos, por:"); e.printStackTrace(); } }
From source file:modelo.GenerarPDF.java
public void nuevoReporteVentasMueble(ArrayList<Producto> Datos) throws IOException { // Se crea el documento Document // Se crea el OutputStream para el fichero donde queremos dejar el pdf. Document documento = null;// w ww . j a v a 2 s . c o m try { //Direccion root FileOutputStream ficheroPdf = new FileOutputStream( "C:\\Users\\panle\\Documents\\ReporteVentasMueble.pdf"); //FileOutputStream ficheroPdf = new FileOutputStream("user.dir/tmp", "ReporteProductos.pdf"); //File tempfile = new File("user.dir/tmp", "tempfile.txt"); documento = new Document(); // Se asocia el documento al OutputStream y se indica que el espaciado entre // lineas sera de 20. Esta llamada debe hacerse antes de abrir el documento PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); // Se abre el documento documento.open(); documento.add(new Paragraph("REPORTE VENTAS POR MUEBLE", FontFactory.getFont("ARIAL", // fuente 16, // tamao Font.ITALIC, // estilo BaseColor.BLACK))); // color PdfPTable tabla = new PdfPTable(3);//#campos(columnas) para la tabla Font font = new Font(FontFamily.COURIER, 6, Font.BOLD, BaseColor.BLACK); PdfPCell cell = new PdfPCell(new Phrase("Celdas", font)); documento.add(new Paragraph("\n")); Image img = Image.getInstance("C:\\Users\\logo.png"); documento.add(img); documento.add(new Paragraph("\n")); int conta = 0; cell.setBorder(Rectangle.TITLE); tabla.addCell("DESCRIPCION"); tabla.addCell("REFERENCIA"); tabla.addCell("TIPO"); while (conta < Datos.size()) { cell.setBorder(Rectangle.NO_BORDER); tabla.addCell(Datos.get(conta).getDESCRIPCION()); tabla.addCell(Datos.get(conta).getREFERENCIA()); tabla.addCell(Datos.get(conta).getTIPO()); conta++; } documento.add(tabla); documento.close(); } catch (FileNotFoundException | DocumentException e) { System.out.println("Error al generar Reporte Productos, por:"); e.printStackTrace(); } }
From source file:modelo.impOrdenCarta.java
public boolean impOrden(int idOrden, String codOrden, int numRegTiq) { try {//from w ww.j a v a2s .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; } }
From source file:modelo.impOrdenLegal.java
public boolean impOrden(int idOrden, String codOrden, int numRegTiq) { try {/*from w w w .jav a2s .co m*/ 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 Cor = new Chunk("CORT", FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK)); Chunk Guar = new Chunk("GUAR", FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK)); Chunk Mon = new Chunk("MONT", FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK)); Chunk Emp = new Chunk("EMP", 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_Legal_" + codOrden + ".pdf"; // El archivo pdf que vamos a generar FileOutputStream fileOutputStream = new FileOutputStream(dir); Rectangle pageSize = new Rectangle(1008f, 612f); Document document = new Document(pageSize, 1, 1, 1, 1); PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream); document.open(); PdfPTable table = new PdfPTable(50); 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(43); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Tel)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(43); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Correo)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(43); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(43); 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(12); 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("ETAPA DEL PROCESO")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(8); 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(8); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cor)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Guar)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Mon)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Emp)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); 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(8); 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(" ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); 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(" ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); 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(35); 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; } }
From source file:modelo.plantillaPDF.java
public void pdf(int tiquet, int idOrden, String codOrden) { try {/*from www. jav a 2 s . com*/ 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; //rs.last(); int cuantos = rs.getRow(); //System.out.print("puestos:" + cuantos+ "orden: " + codOrden + "tiquet: " + tiquet); //Fecha actual en formato completo: //Tue Sep 23 01:18:48 CEST 2014 Date fechaActual = new Date(); // System.out.println(fechaActual); // System.out.println("---------------------------------------------"); //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)); //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(); String fe = Fecha.format(fechaActual); 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); //Creacion del documento con un tamao y unos margenes predeterminados Document document = new Document(PageSize.LETTER, 10, 10, 10, 1); //A DocWriter class for PDF con Java. //When this PdfWriter is added to a certain PdfDocument, //the <strong>PDF</strong> representation of every Element added to this Document will be written to the outputstream. //PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); // Obtener la instancia del PdfWriter PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream); //LEADING = separacion entre lineas del documento writer.setInitialLeading(16); Rectangle rct = new Rectangle(36, 54, 559, 788); //Definimos un nombre y un tamao para el PageBox los nombres posibles son: crop?, trim?, art? and bleed?. writer.setBoxSize("art", rct); //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 //Aadir tabla 15 columnas PdfPTable table = new PdfPTable(15); // PdfPTable tabla = new PdfPTable(15); PdfPCell celda; //Aadir CABECERA PdfPCell cell; Image image = Image.getInstance("logo/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("Calle 12 # 6-68 Nia Ceci")); 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); c6 = rs.getInt(8); c7 = rs.getInt(9); c8 = rs.getInt(10); c9 = rs.getInt(11); c10 = rs.getInt(12); c11 = rs.getInt(13); c12 = rs.getInt(14); c13 = rs.getInt(15); c14 = rs.getInt(16); c15 = rs.getInt(17); c16 = rs.getInt(18); c17 = rs.getInt(19); c18 = rs.getInt(21); c19 = rs.getInt(22); c20 = rs.getInt(23); c21 = rs.getInt(24); c22 = rs.getInt(25); c23 = rs.getInt(26); c24 = rs.getInt(28); c25 = rs.getInt(29); c26 = rs.getInt(30); c27 = rs.getInt(31); c28 = rs.getInt(32); colorUno = verColor.consultarNombreColorUno(c4); colorDos = verColor.consultarNombreColorDos(c5); ob = verTiquet.ConsultaObservacion(tiquet); System.out.print("Color Uno: " + colorUno); //cell.setBackgroundColor(BaseColor.BLUE); table.addCell(cell); cell = new PdfPCell(new Phrase("TIKET #:")); cell.setColspan(2); cell.setRowspan(2); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); cell = new PdfPCell(new Phrase("" + tiquet)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(2); table.addCell(cell); //Aadir dos filas de celdas sin formato cell = new PdfPCell(new Phrase("Tel: 5783364")); 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("" + c6)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("calzadoseiya@gmail.com")); 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("PARES:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("" + c7)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("FECHA"));//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("CORTADA")); 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("GUARNICION")); 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("MONTADA")); 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("EMPLANTILLADA")); 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("COLOR 1:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase(colorUno)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("COLOR 2:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase(colorDos)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); table.addCell(cell); cell = new PdfPCell(new Phrase("OBSERVACION")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(ob)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); cell.setRowspan(2); table.addCell(cell); table.addCell("21"); table.addCell("22"); table.addCell("23"); table.addCell("24"); table.addCell("25"); table.addCell("26"); table.addCell("27"); table.addCell("28"); table.addCell("29"); table.addCell("30"); table.addCell("31"); table.addCell("32"); table.addCell("33"); table.addCell("34"); table.addCell("35"); table.addCell(" " + c8); table.addCell(" " + c9); table.addCell(" " + c10); table.addCell(" " + c11); table.addCell(" " + c12); table.addCell(" " + c13); table.addCell(" " + c14); table.addCell(" " + c15); table.addCell(" " + c16); table.addCell(" " + c17); table.addCell(" " + c18); table.addCell(" " + c19); table.addCell(" " + c20); table.addCell(" " + c21); table.addCell(" " + c22); table.addCell("36"); table.addCell("37"); table.addCell("38"); table.addCell("39"); table.addCell("40"); table.addCell("41"); table.addCell("42"); table.addCell("43"); table.addCell("44"); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" " + c23); table.addCell(" " + c24); table.addCell(" " + c25); table.addCell(" " + c26); table.addCell(" " + c27); table.addCell(" " + c28); table.addCell(" " + c29); table.addCell(" " + c30); table.addCell(" " + c31); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); document.add(table); String cadena = ""; 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 = "EMPLANTILLADA"; if (i == 2) cadena = "MONTADA"; if (i == 3) { cadena = "GUARNICION"; } if (i == 4) cadena = "CORTADA"; cell = new PdfPCell( new Phrase("------------------------------------------------------------------------")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(15); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("CALZADO SEIYA")); 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("TIQUET #")); 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("PARES:")); cell.setHorizontalAlignment(Font.BOLD); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("" + c7)); 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("" + c6)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("COLOR 1:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); tabla.addCell(cell); cell = new PdfPCell(new Phrase(colorUno)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); tabla.addCell(cell); cell = new PdfPCell(new Phrase("COLOR 2:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); tabla.addCell(cell); cell = new PdfPCell(new Phrase(colorDos)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); tabla.addCell(cell); tabla.addCell("21"); tabla.addCell("22"); tabla.addCell("23"); tabla.addCell("24"); tabla.addCell("25"); tabla.addCell("26"); tabla.addCell("27"); tabla.addCell("28"); tabla.addCell("29"); tabla.addCell("30"); tabla.addCell("31"); tabla.addCell("32"); tabla.addCell("33"); tabla.addCell("34"); tabla.addCell("35"); tabla.addCell(" " + c8); tabla.addCell(" " + c9); tabla.addCell(" " + c10); tabla.addCell(" " + c11); tabla.addCell(" " + c12); tabla.addCell(" " + c13); tabla.addCell(" " + c14); tabla.addCell(" " + c15); tabla.addCell(" " + c16); tabla.addCell(" " + c17); tabla.addCell(" "); tabla.addCell(" " + c20); tabla.addCell(" " + c21); tabla.addCell(" " + c22); tabla.addCell(" " + c23); tabla.addCell("36"); tabla.addCell("37"); tabla.addCell("38"); tabla.addCell("39"); tabla.addCell("40"); tabla.addCell("41"); tabla.addCell("42"); tabla.addCell("43"); tabla.addCell("44"); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" " + c24); tabla.addCell(" " + c25); tabla.addCell(" " + c26); tabla.addCell(" " + c27); tabla.addCell(" " + c28); tabla.addCell(" " + c29); tabla.addCell(" " + c30); tabla.addCell(" " + c31); tabla.addCell(" " + c32); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); document.add(tabla); } //document.add(new Paragraph(new Date().toString())); //FIN Ejemplos de TABLE //************************************************************** //************************************************************** // Cierre del documento document.close(); } } catch (Exception ex) { System.out.println(ex.getMessage()); } }