List of usage examples for com.lowagie.text Element ALIGN_RIGHT
int ALIGN_RIGHT
To view the source code for com.lowagie.text Element ALIGN_RIGHT.
Click Source Link
From source file:jm.seg.frmGeneraPdf.java
License:GNU General Public License
public void GenerarFactura(String ruta_xml, String dir, String _archivoNombre) throws FileNotFoundException { File _archivo = null;/* w w w. j a v a2s . c o m*/ Xml xml = new Xml(ruta_xml + ".xml"); String numeroAutorizacion = xml.getValor("numeroAutorizacion"); String fechaAutorizacion = xml.getValor("fechaAutorizacion"); String doc = xml.getValor("comprobante"); try { _archivo = new File(dir, _archivoNombre + "xml.xml"); if (!_archivo.exists()) { //byte[] bytes = (res.getString(campoBytea)!=null) ? res.getBytes(campoBytea) : null; RandomAccessFile archivo = new RandomAccessFile(dir + _archivoNombre + "xml.xml", "rw"); archivo.writeBytes(doc); archivo.close(); } } catch (Exception e) { e.printStackTrace(); } //infoTributaria Xml xml2 = new Xml(ruta_xml + "xml.xml"); String ambiente = xml2.getValor("ambiente"); String tipoEmision = xml2.getValor("tipoEmision"); String razonSocial = xml2.getValor("razonSocial"); String nombreComercial = xml2.getValor("nombreComercial"); String ruc = xml2.getValor("ruc"); String claveAcceso = xml2.getValor("claveAcceso"); String codDoc = xml2.getValor("codDoc"); String numFac = xml2.getValor("estab") + "-" + xml2.getValor("ptoEmi") + "-" + xml2.getValor("secuencial"); String dirMatriz = xml2.getValor("dirMatriz"); String EMAIL = ""; String DIRECCION = ""; String ARCOTEL = ""; int limiteAdi = xml2.getNumNodos("campoAdicional"); try { //Campos Adicionales for (int i = 0; i < limiteAdi; i++) { if (xml2.getAtributo("campoAdicional", i, "nombre").toUpperCase().compareTo("EMAIL") == 0) { EMAIL = xml2.getValor("campoAdicional", i); } if (xml2.getAtributo("campoAdicional", i, "nombre").toUpperCase().compareTo("DIRECCION") == 0) { DIRECCION = xml2.getValor("campoAdicional", i); } if (xml2.getAtributo("campoAdicional", i, "nombre").toUpperCase().compareTo("ARCOTEL") == 0) { ARCOTEL = xml2.getValor("campoAdicional", i); } } } catch (Exception e) { e.printStackTrace(); } if (ambiente.compareTo("1") == 0) { ambiente = "Pruebas"; } if (ambiente.compareTo("2") == 0) { ambiente = "Produccin"; } if (tipoEmision.compareTo("1") == 0) { tipoEmision = "Normal"; } if (tipoEmision.compareTo("2") == 0) { tipoEmision = "Contingencia"; } if (codDoc.compareTo("01") == 0) { //infoFactura String fechaEmision = xml2.getValor("fechaEmision"); String dirEstablecimiento = xml2.getValor("dirEstablecimiento"); String contribuyenteEspecial = xml2.getValor("contribuyenteEspecial"); String obligadoContabilidad = xml2.getValor("obligadoContabilidad"); String razonSocialComprador = xml2.getValor("razonSocialComprador"); String identificacionComprador = xml2.getValor("identificacionComprador"); String totalSinImpuestos = xml2.getValor("totalSinImpuestos"); String totalDescuento = xml2.getValor("totalDescuento"); String codigoPorcentaje = xml2.getValor("codigoPorcentaje");//0% 0 >>12% 2>>mo objeto de impuesto 6>>Excento al iva 7 String baseImponible = xml2.getValor("baseImponible"); //Depende del codigo porcentaje String valor = xml2.getValor("valor");// va en el Iva 12% String importeTotal = xml2.getValor("importeTotal");//Sumatoria de todo //detalles int limite = xml2.getNumNodos("detalle"); String[][] array = new String[limite][6]; for (int i = 0; i < limite; i++) { array[i][0] = xml2.getValor("codigoPrincipal"); array[i][1] = xml2.getValor("descripcion"); array[i][2] = xml2.getValor("cantidad"); array[i][3] = xml2.getValor("precioUnitario"); array[i][4] = xml2.getValor("descuento"); array[i][5] = xml2.getValor("precioTotalSinImpuesto"); } /* inicio PDF */ Document pdf = new Document(PageSize.A4);// paso 1 pdf.setMargins(-35, -45, 40, 10); /*Izquierda, derecha, tope, pie */ try { PdfWriter writer = PdfWriter.getInstance(pdf, new FileOutputStream(dir + claveAcceso + ".pdf")); pdf.open(); //pdf.open(); // paso 3 // Para enviar a la impresora automticamente. //writer.addJavaScript("this.print(false);", false); /* todo el cuerpo del doc es el paso 4 */ //PdfPTable tbl_titulo = new PdfPTable(1); PdfPTable tbl_titulo = new PdfPTable(new float[] { 49f, 2f, 49f }); PdfPTable tbl_1 = new PdfPTable(new float[] { 37f, 63f }); PdfPTable tbl_2 = new PdfPTable(1); //titulos izquierda tbl_1.addCell(Addons.setLogo(dir + "logo.jpg", 250, 83, Element.ALIGN_CENTER));//ancho,alto tbl_1.addCell( Addons.setCeldaPDF(" ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_1.addCell(Addons.setCeldaPDF(razonSocial + " '" + nombreComercial + "' ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 2)); tbl_1.addCell(Addons.setCeldaPDF("Direccin Matriz: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF(dirMatriz, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF("Direccin Sucursal: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF(dirEstablecimiento, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF("Contribuyente Especial Nro. " + contribuyenteEspecial, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_1.addCell(Addons.setCeldaPDF("OBLIGADO A LLEVAR CONTABILIDAD: " + obligadoContabilidad, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); //Titulos derecha tbl_2.addCell(Addons.setCeldaPDF("R.U.C: " + ruc, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("F A C T U R A ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("No. " + numFac, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("NMERO DE AUTORIZACIN", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF(numeroAutorizacion, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("FECHA Y HORA DE AUTORIZACION", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF(fechaAutorizacion, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("AMBIENTE: " + ambiente, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("EMISIN: " + tipoEmision, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("CLAVE DE ACCESO", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setBarCode(this.getBarcode(writer, claveAcceso)));//ancho,alto tbl_titulo.addCell(Addons.setCeldaPDF(tbl_1, 0, 1)); tbl_titulo.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 1, Font.NORMAL, 0, 0)); tbl_titulo.addCell(Addons.setCeldaPDF(tbl_2, 0, 1)); tbl_titulo.addCell(Addons.setFilaBlanco(3, 20)); pdf.add(tbl_titulo); //Informacion Cliente PdfPTable tbl_info = new PdfPTable(1); PdfPTable tbl_info1 = new PdfPTable(new float[] { 32f, 43f, 25f }); tbl_info1.addCell(Addons.setCeldaPDF("Razn Social / Nombres y Apellidos: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8)); tbl_info1.addCell(Addons.setCeldaPDF(razonSocialComprador, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8)); tbl_info1.addCell(Addons.setCeldaPDF("RUC/CI: " + identificacionComprador, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8)); tbl_info1.addCell(Addons.setCeldaPDF("Fecha de emisin: " + fechaEmision, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 1)); tbl_info1.addCell(Addons.setCeldaPDF("DIRECCION: " + DIRECCION, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 2)); tbl_info.addCell(Addons.setCeldaPDF(tbl_info1, 0, 1)); tbl_info.addCell(Addons.setFilaBlanco(3, 20)); pdf.add(tbl_info); //Detalles PdfPTable tbl_det = new PdfPTable(1); PdfPTable tbl_det1 = new PdfPTable(new float[] { 10f, 10f, 50f, 10f, 10f, 10f }); tbl_det1.addCell(Addons.setCeldaPDF("Cod. Principal", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); tbl_det1.addCell( Addons.setCeldaPDF("Cant.", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF("Descripcin", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF("Precio Unitario", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); tbl_det1.addCell( Addons.setCeldaPDF("Desc.", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); tbl_det1.addCell( Addons.setCeldaPDF("Total", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); for (int i = 0; i < limite; i++) { tbl_det1.addCell(Addons.setCeldaPDF(array[i][0], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF(array[i][2], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF(array[i][1], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF(array[i][3], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF(array[i][4], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF(array[i][5], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); } tbl_det.addCell(Addons.setCeldaPDF(tbl_det1, 0, 1)); tbl_det.addCell(Addons.setFilaBlanco(6, 20)); pdf.add(tbl_det); //Informacion Adicional PdfPTable tbl_info_ad = new PdfPTable(new float[] { 40f, 10f, 50f }); PdfPTable tbl_info_ad1 = new PdfPTable(new float[] { 30f, 70f }); PdfPTable tbl_info_ad2 = new PdfPTable(new float[] { 70f, 30f }); //titulos izquierda tbl_info_ad1.addCell(Addons.setCeldaPDF("Informacin Adicional", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 5, 2)); tbl_info_ad1.addCell(Addons.setCeldaPDF("Contacto: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("062609177 / 062610330", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("Email: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell( Addons.setCeldaPDF(EMAIL, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("Sitio Web:", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("www.saitel.ec", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell( Addons.setCeldaPDF(ARCOTEL, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 2)); //Titulos derecha if (codigoPorcentaje.compareTo("0") == 0) { tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL 12% ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL 0% ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF(baseImponible, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL No objeto de IVA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL SIN IMPUESTOS", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF(totalSinImpuestos, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL Exento de IVA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF(valor, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("DESCUENTO", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF(totalDescuento, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("IVA 12%", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); } if (codigoPorcentaje.compareTo("2") == 0) { tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL 12% ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF(baseImponible, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL 0% ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL No objeto de IVA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL SIN IMPUESTOS", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF(totalSinImpuestos, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL Exento de IVA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("DESCUENTO", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF(totalDescuento, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("IVA 12%", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell( Addons.setCeldaPDF(valor, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); } tbl_info_ad2.addCell(Addons.setCeldaPDF("VALOR TOTAL", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF(Addons.redondear(importeTotal), Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad.addCell(Addons.setCeldaPDF(tbl_info_ad1, 0, 1)); tbl_info_ad.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 1, Font.NORMAL, 0, 0)); tbl_info_ad.addCell(Addons.setCeldaPDF(tbl_info_ad2, 0, 1)); pdf.add(tbl_info_ad); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } finally { } pdf.close(); // paso 5 /* fin PDF */ } //Nota de credito if (codDoc.compareTo("04") == 0) { //infoFactura String fechaEmision = xml2.getValor("fechaEmision"); String dirEstablecimiento = xml2.getValor("dirEstablecimiento"); String razonSocialComprador = xml2.getValor("razonSocialComprador"); String identificacionComprador = xml2.getValor("identificacionComprador"); String contribuyenteEspecial = xml2.getValor("contribuyenteEspecial"); String obligadoContabilidad = xml2.getValor("obligadoContabilidad"); String codDocModificado = xml2.getValor("codDocModificado"); String numDocModificado = xml2.getValor("numDocModificado"); String fechaEmisionDocSustento = xml2.getValor("fechaEmisionDocSustento"); String motivo = xml2.getValor("motivo"); String totalSinImpuestos = xml2.getValor("totalSinImpuestos"); if (codDocModificado.compareTo("01") == 0) { codDocModificado = "FACTURA"; } if (codDocModificado.compareTo("04") == 0) { codDocModificado = "NOTA DE CRDITO"; } if (codDocModificado.compareTo("05") == 0) { codDocModificado = "NOTA DE DBITO"; } if (codDocModificado.compareTo("06") == 0) { codDocModificado = "GU?A DE REMISION"; } if (codDocModificado.compareTo("07") == 0) { codDocModificado = "COMPROBANTE DE RETENCIN"; } String codigoPorcentaje = xml2.getValor("codigoPorcentaje");//0% 0 >>12% 2>>mo objeto de impuesto 6>>Excento al iva 7 String baseImponible = xml2.getValor("baseImponible"); //Depende del codigo porcentaje String valor = xml2.getValor("valor");// va en el Iva 12% //detalles int limite = xml2.getNumNodos("detalle"); String[][] array = new String[limite][6]; for (int i = 0; i < limite; i++) { array[i][0] = xml2.getValor("codigoPrincipal"); array[i][1] = xml2.getValor("descripcion"); array[i][2] = xml2.getValor("cantidad"); array[i][3] = xml2.getValor("precioUnitario"); array[i][4] = xml2.getValor("descuento"); array[i][5] = xml2.getValor("precioTotalSinImpuesto"); } /* inicio PDF */ Document pdf = new Document(PageSize.A4);// paso 1 pdf.setMargins(-35, -45, 40, 10); /*Izquierda, derecha, tope, pie */ try { PdfWriter writer = PdfWriter.getInstance(pdf, new FileOutputStream(dir + claveAcceso + ".pdf")); pdf.open(); //pdf.open(); // paso 3 // Para enviar a la impresora automticamente. //writer.addJavaScript("this.print(false);", false); /* todo el cuerpo del doc es el paso 4 */ //PdfPTable tbl_titulo = new PdfPTable(1); PdfPTable tbl_titulo = new PdfPTable(new float[] { 49f, 2f, 49f }); PdfPTable tbl_1 = new PdfPTable(new float[] { 37f, 63f }); PdfPTable tbl_2 = new PdfPTable(1); //titulos izquierda tbl_1.addCell(Addons.setLogo(dir + "logo.jpg", 250, 83, Element.ALIGN_CENTER));//ancho,alto tbl_1.addCell( Addons.setCeldaPDF(" ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_1.addCell(Addons.setCeldaPDF(razonSocial + " '" + nombreComercial + "' ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 2)); tbl_1.addCell(Addons.setCeldaPDF("Direccin Matriz: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF(dirMatriz, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF("Direccin Sucursal: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF(dirEstablecimiento, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF("Contribuyente Especial Nro. " + contribuyenteEspecial, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_1.addCell(Addons.setCeldaPDF("OBLIGADO A LLEVAR CONTABILIDAD: " + obligadoContabilidad, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); //Titulos derecha tbl_2.addCell(Addons.setCeldaPDF("R.U.C: " + ruc, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("F A C T U R A ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("No. " + numFac, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("NMERO DE AUTORIZACIN", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF(numeroAutorizacion, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("FECHA Y HORA DE AUTORIZACIN", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF(fechaAutorizacion, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("AMBIENTE: " + ambiente, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("EMISIN: " + tipoEmision, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("CLAVE DE ACCESO", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setBarCode(this.getBarcode(writer, claveAcceso)));//ancho,alto tbl_titulo.addCell(Addons.setCeldaPDF(tbl_1, 0, 1)); tbl_titulo.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 1, Font.NORMAL, 0, 0)); tbl_titulo.addCell(Addons.setCeldaPDF(tbl_2, 0, 1)); tbl_titulo.addCell(Addons.setFilaBlanco(3, 20)); pdf.add(tbl_titulo); //Informacion Cliente PdfPTable tbl_info = new PdfPTable(1); PdfPTable tbl_info1 = new PdfPTable(new float[] { 32f, 43f, 25f }); tbl_info1.addCell(Addons.setCeldaPDF("Razn Social / Nombres y Apellidos: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_info1.addCell(Addons.setCeldaPDF(razonSocialComprador, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_info1.addCell(Addons.setCeldaPDF("RUC/CI: " + identificacionComprador, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_info1.addCell(Addons.setCeldaPDF("Fecha de emisin:" + fechaEmision, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 3)); tbl_info1.addCell(Addons.setCeldaPDF( "-------------------------------------------------------------------------------------------------------------", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 5, 3)); tbl_info1.addCell(Addons.setCeldaPDF("Comprobante que se Modifica:", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_info1.addCell(Addons.setCeldaPDF(codDocModificado + ": " + numDocModificado, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_info1.addCell(Addons.setCeldaPDF("Fecha emisin (Comprobante a Modificar)", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_info1.addCell(Addons.setCeldaPDF(fechaEmisionDocSustento, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_info1.addCell(Addons.setCeldaPDF("Razn de Modificacin: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_info1.addCell( Addons.setCeldaPDF(motivo, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_info.addCell(Addons.setCeldaPDF(tbl_info1, 0, 1)); tbl_info.addCell(Addons.setFilaBlanco(3, 20)); pdf.add(tbl_info); //Detalles PdfPTable tbl_det = new PdfPTable(1); PdfPTable tbl_det1 = new PdfPTable(new float[] { 10f, 10f, 50f, 10f, 10f, 10f }); tbl_det1.addCell(Addons.setCeldaPDF("Cod. Principal", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); tbl_det1.addCell( Addons.setCeldaPDF("Cant.", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF("Descripcin", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF("Precio Unitario", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); tbl_det1.addCell( Addons.setCeldaPDF("Desc.", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); tbl_det1.addCell( Addons.setCeldaPDF("Total", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 1, 5)); for (int i = 0; i < limite; i++) { tbl_det1.addCell(Addons.setCeldaPDF(array[i][0], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF(array[i][2], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF(array[i][1], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF(array[i][3], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF(array[i][4], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF(array[i][5], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); } tbl_det.addCell(Addons.setCeldaPDF(tbl_det1, 0, 1)); tbl_det.addCell(Addons.setFilaBlanco(6, 20)); pdf.add(tbl_det); //Informacion Adicional PdfPTable tbl_info_ad = new PdfPTable(new float[] { 40f, 10f, 50f }); PdfPTable tbl_info_ad1 = new PdfPTable(new float[] { 30f, 70f }); PdfPTable tbl_info_ad2 = new PdfPTable(new float[] { 70f, 30f }); //titulos izquierda tbl_info_ad1.addCell(Addons.setCeldaPDF("Informacin Adicional", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 5, 2)); tbl_info_ad1.addCell(Addons.setCeldaPDF("Contacto: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("062609177 / 062610330", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("Email: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell( Addons.setCeldaPDF(EMAIL, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("Sitio Web:", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("www.saitel.ec", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell( Addons.setCeldaPDF(ARCOTEL, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 2)); //Titulos derecha if (codigoPorcentaje.compareTo("0") == 0) { tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL 12% ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL 0% ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF(baseImponible, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL No objeto de IVA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL SIN IMPUESTOS", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF(totalSinImpuestos, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL Exento de IVA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF(valor, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); tbl_info_ad2.addCell(Addons.setCeldaPDF("IVA 12%", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 0)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, 2)); } else { tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL 12% ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF(baseImponible, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL 0% ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL No objeto de IVA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL SIN IMPUESTOS", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF(totalSinImpuestos, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("SUBTOTAL Exento de IVA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("0.00", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); tbl_info_ad2.addCell(Addons.setCeldaPDF("IVA 12%", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_info_ad2.addCell( Addons.setCeldaPDF(valor, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5)); } tbl_info_ad.addCell(Addons.setCeldaPDF(tbl_info_ad1, 0, 1)); tbl_info_ad.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 1, Font.NORMAL, 0, 0)); tbl_info_ad.addCell(Addons.setCeldaPDF(tbl_info_ad2, 0, 1)); pdf.add(tbl_info_ad); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } finally { } pdf.close(); // paso 5 /* fin PDF */ } //Comprobante de retencion if (codDoc.compareTo("07") == 0) { //infoCompRetencion String fechaEmision = xml2.getValor("fechaEmision"); String dirEstablecimiento = xml2.getValor("dirEstablecimiento"); String contribuyenteEspecial = xml2.getValor("contribuyenteEspecial"); String obligadoContabilidad = xml2.getValor("obligadoContabilidad"); String tipoIdentificacionSujetoRetenido = xml2.getValor("tipoIdentificacionSujetoRetenido"); String razonSocialSujetoRetenido = xml2.getValor("razonSocialSujetoRetenido"); String identificacionSujetoRetenido = xml2.getValor("identificacionSujetoRetenido"); String periodoFiscal = xml2.getValor("periodoFiscal"); //detalles int limite = xml2.getNumNodos("impuesto"); String[][] array = new String[limite][7]; for (int i = 0; i < limite; i++) { array[i][0] = xml2.getValor("codigo", i); array[i][1] = xml2.getValor("codigoRetencion", i); array[i][2] = xml2.getValor("baseImponible", i); array[i][3] = xml2.getValor("porcentajeRetener", i); array[i][4] = xml2.getValor("valorRetenido", i); array[i][5] = xml2.getValor("codDocSustento", i); array[i][6] = xml2.getValor("numDocSustento", i); } /* inicio PDF */ Document pdf = new Document(PageSize.A4);// paso 1 pdf.setMargins(-35, -45, 40, 10); /*Izquierda, derecha, tope, pie */ try { PdfWriter writer = PdfWriter.getInstance(pdf, new FileOutputStream(dir + claveAcceso + ".pdf")); pdf.open(); //pdf.open(); // paso 3 // Para enviar a la impresora automticamente. //writer.addJavaScript("this.print(false);", false); /* todo el cuerpo del doc es el paso 4 */ //PdfPTable tbl_titulo = new PdfPTable(1); PdfPTable tbl_titulo = new PdfPTable(new float[] { 49f, 2f, 49f }); PdfPTable tbl_1 = new PdfPTable(new float[] { 37f, 63f }); PdfPTable tbl_2 = new PdfPTable(1); //titulos izquierda tbl_1.addCell(Addons.setLogo(dir + "logo.jpg", 250, 83, Element.ALIGN_CENTER));//ancho,alto tbl_1.addCell( Addons.setCeldaPDF(" ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_1.addCell(Addons.setCeldaPDF(razonSocial + " '" + nombreComercial + "' ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 8, 2)); tbl_1.addCell(Addons.setCeldaPDF("Direccin Matriz: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF(dirMatriz, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF("Direccin Sucursal: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF(dirEstablecimiento, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 0)); tbl_1.addCell(Addons.setCeldaPDF("Contribuyente Especial Nro. " + contribuyenteEspecial, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); tbl_1.addCell(Addons.setCeldaPDF("OBLIGADO A LLEVAR CONTABILIDAD: " + obligadoContabilidad, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5, 2)); //Titulos derecha tbl_2.addCell(Addons.setCeldaPDF("R.U.C: " + ruc, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("COMPROBANTE DE RETENCIN", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("No. " + numFac, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("NMERO DE AUTORIZACIN", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF(numeroAutorizacion, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("FECHA Y HORA DE AUTORIZACIN", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF(fechaAutorizacion, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("AMBIENTE: " + ambiente, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("EMISIN: " + tipoEmision, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setCeldaPDF("CLAVE DE ACCESO", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 5)); tbl_2.addCell(Addons.setBarCode(this.getBarcode(writer, claveAcceso)));//ancho,alto tbl_titulo.addCell(Addons.setCeldaPDF(tbl_1, 0, 1)); tbl_titulo.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 1, Font.NORMAL, 0, 0)); tbl_titulo.addCell(Addons.setCeldaPDF(tbl_2, 0, 1)); tbl_titulo.addCell(Addons.setFilaBlanco(3, 20)); pdf.add(tbl_titulo); //Informacion Cliente PdfPTable tbl_info = new PdfPTable(1); PdfPTable tbl_info1 = new PdfPTable(new float[] { 32f, 43f, 25f }); tbl_info1.addCell(Addons.setCeldaPDF("Razn Social / Nombres y Apellidos: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8)); tbl_info1.addCell(Addons.setCeldaPDF(razonSocialSujetoRetenido, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8)); tbl_info1.addCell(Addons.setCeldaPDF("RUC/CI: " + identificacionSujetoRetenido, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8)); tbl_info1.addCell(Addons.setCeldaPDF("Fecha de emisin: " + fechaEmision, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 3)); tbl_info.addCell(Addons.setCeldaPDF(tbl_info1, 0, 1)); tbl_info.addCell(Addons.setFilaBlanco(3, 20)); pdf.add(tbl_info); //Detalles PdfPTable tbl_det = new PdfPTable(1); PdfPTable tbl_det1 = new PdfPTable(new float[] { 14f, 18f, 12f, 10f, 13f, 10f, 13f, 10f }); tbl_det1.addCell(Addons.setCeldaPDF("Comprobante", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell( Addons.setCeldaPDF("Nmero", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF("Fecha Emisin", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF("Ejercicio Fiscal", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF("Base Imponible para la retencion", Font.STRIKETHRU, 8, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell( Addons.setCeldaPDF("Impuesto", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF("Porcentaje de Retencin", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); tbl_det1.addCell(Addons.setCeldaPDF("Valor Retenido", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); Double val_ret = 0.0; //detalles for (int i = 0; i < limite; i++) { //Comprobante if (array[i][5].compareTo("01") == 0) { tbl_det1.addCell(Addons.setCeldaPDF("FACTURA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); } if (array[i][5].compareTo("04") == 0) { tbl_det1.addCell(Addons.setCeldaPDF("NOTA DE CRDITO", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); } if (array[i][5].compareTo("05") == 0) { tbl_det1.addCell(Addons.setCeldaPDF("NOTA DE DBITO", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); } if (array[i][5].compareTo("06") == 0) { tbl_det1.addCell(Addons.setCeldaPDF("GU?A DE REMISION", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); } if (array[i][5].compareTo("07") == 0) { tbl_det1.addCell(Addons.setCeldaPDF("COMPROBANTE DE RETENCIN", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); } //Nmero tbl_det1.addCell(Addons.setCeldaPDF(array[i][6], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); //Fecha Emisin tbl_det1.addCell(Addons.setCeldaPDF(fechaEmision, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); //Ejercicio Fiscal tbl_det1.addCell(Addons.setCeldaPDF(periodoFiscal, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); //Base Imponible para la retencion tbl_det1.addCell(Addons.setCeldaPDF(array[i][2], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); //Impuesto if (array[i][0].compareTo("1") == 0) { tbl_det1.addCell(Addons.setCeldaPDF("RENTA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); } if (array[i][0].compareTo("2") == 0) { tbl_det1.addCell(Addons.setCeldaPDF("IVA", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); } if (array[i][0].compareTo("6") == 0) { tbl_det1.addCell(Addons.setCeldaPDF("ISD", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); } //Porcentaje de Retencin tbl_det1.addCell(Addons.setCeldaPDF(array[i][3], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); //Valor Retenido tbl_det1.addCell(Addons.setCeldaPDF(array[i][4], Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5)); val_ret += Double.parseDouble(array[i][4]); } tbl_det1.addCell(Addons.setCeldaPDF("Valor Retenido", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_RIGHT, 1, 5, 7)); tbl_det1.addCell(Addons.setCeldaPDF(Addons.redondear(val_ret) + "", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 1, 5, 1)); tbl_det.addCell(Addons.setCeldaPDF(tbl_det1, 0, 1)); tbl_det.addCell(Addons.setFilaBlanco(6, 20)); pdf.add(tbl_det); //Informacion Adicional PdfPTable tbl_info_ad = new PdfPTable(new float[] { 40f, 10f, 50f }); PdfPTable tbl_info_ad1 = new PdfPTable(new float[] { 30f, 70f }); //titulos izquierda tbl_info_ad1.addCell(Addons.setCeldaPDF("Informacin Adicional", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_CENTER, 0, 5, 2)); tbl_info_ad1.addCell(Addons.setCeldaPDF("Contacto: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("062609177 / 062610330", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("Email: ", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell( Addons.setCeldaPDF(EMAIL, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("Sitio Web:", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell(Addons.setCeldaPDF("www.saitel.ec", Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 0)); tbl_info_ad1.addCell( Addons.setCeldaPDF(ARCOTEL, Font.STRIKETHRU, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 8, 2)); tbl_info_ad.addCell(Addons.setCeldaPDF(tbl_info_ad1, 0, 1)); tbl_info_ad.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 1, Font.NORMAL, 0, 0)); tbl_info_ad.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 1, Font.NORMAL, 0, 0)); pdf.add(tbl_info_ad); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } finally { } pdf.close(); // paso 5 /* fin PDF */ } }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPTable setHistorial(ResultSet histo) { float bar[] = new float[103]; bar[0] = 20f;/*from w ww . j av a 2s .c o m*/ bar[1] = 2f; for (int i = 2; i <= 101; i++) { bar[i] = 1f; } bar[102] = 20f; PdfPTable tabla = new PdfPTable(bar); tabla.addCell(Addons.setFilaBlanco(103, 1)); String historial[][] = DatosDinamicos.ResultSetToMatriz(histo); float maximo = DatosDinamicos.valMaximo(historial, 1); /* es el valor mximo de los consumos */ int porcentaje = 100; if (maximo / 10000 >= 1) { porcentaje = 100000; } if (maximo / 1000 >= 1) { porcentaje = 10000; } if (maximo / 100 >= 1) { porcentaje = 1000; } for (int i = 0; i < historial.length; i++) { tabla.addCell(Addons.setCeldaPDF(historial[i][0], Font.HELVETICA, 5, Font.NORMAL, Element.ALIGN_RIGHT, 0, 0, 1)); tabla.addCell(Addons.setCeldaPDF(" ", Font.HELVETICA, 5, Font.NORMAL, Element.ALIGN_RIGHT, 0, 0, 1)); int ancho = Math.round(Float.parseFloat(historial[i][1]) * maximo / porcentaje); tabla.addCell(Addons.setBarra(ancho, 0f)); /* barra de consumo */ if (ancho == 0) { ancho = 1; } tabla.addCell(Addons.setBarra(100 - ancho, 10f)); /* barra complementaria blanca */ tabla.addCell(Addons.setCeldaPDF(" " + historial[i][1], Font.HELVETICA, 3, Font.NORMAL, Element.ALIGN_LEFT, 0, 0, 1)); tabla.addCell(Addons.setFilaBlanco(103, 2)); } return tabla; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static void setPie(PdfWriter writer, Document document, String rep_pie) { try {//from w ww . j a v a 2 s . co m PdfContentByte cb = writer.getDirectContent(); /*cb.setLineWidth(2); cb.moveTo(60, document.bottomMargin()-5); cb.lineTo(document.right() - document.left()-70, document.bottomMargin()-5); */ PdfPTable pie = new PdfPTable(1); pie.setTotalWidth(document.right() - document.left() - 120); pie.addCell(Addons.setCeldaPDF(rep_pie, Font.HELVETICA, 9, Font.BOLD, Element.ALIGN_CENTER, 0)); pie.addCell(Addons.setCeldaPDF("Pg " + String.valueOf(writer.getPageNumber()), Font.HELVETICA, 9, Font.BOLD, Element.ALIGN_RIGHT, 0)); pie.addCell(Addons.setCeldaPDF( "Reporte diseado por: Jorge Mueses Cevallos. Mvil: 095204832 mail:jorge_mueses@yahoo.com", Font.HELVETICA, 5, Font.BOLD, Element.ALIGN_LEFT, 0)); pie.writeSelectedRows(0, -1, 60, document.bottomMargin() - 10, cb); } catch (Exception e) { throw new ExceptionConverter(e); } }
From source file:lt.bsprendimai.ddesk.pdf.PDFTicket.java
License:Apache License
public byte[] writePage() throws Exception { ByteArrayOutputStream bout = new ByteArrayOutputStream(); try {// ww w . j a va 2 s .c o m logo = Image.getInstance(root.getAbsolutePath() + "/logo.gif"); logo.setAlignment(Image.ALIGN_LEFT); } catch (Exception exc) { exc.printStackTrace(); } baseArial = BaseFont.createFont(root.getAbsolutePath() + "/objects/arial.ttf", BaseFont.CP1257, BaseFont.EMBEDDED); Document doc = new Document(PageSize.A4, 56.5354331f, 22.6771654f, 28.3464567f, 25.0f); PdfWriter.getInstance(doc, bout); doc.open(); logo.setAbsolutePosition(28.3464567f, doc.getPageSize().height() - logo.height() - 25.0f); doc.add(logo); Paragraph pg = new Paragraph(sdf.format(new Date()), new Font(baseArial, 10)); pg.setAlignment(Element.ALIGN_RIGHT); doc.add(pg); doc.add(new Phrase("\n\n\n")); writeClientInfo(doc); writeTicketInfo(doc); writeJobInfo(doc); writeWorkerInfo(doc); doc.close(); return bout.toByteArray(); }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
public void buildPDF(MimeMessage message, String replyURL, OutputStream pdfStream) throws DocumentException, MessagingException, IOException { Document document = createDocument(); PdfWriter pdfWriter = createPdfWriter(document, pdfStream); document.open();//w w w . j ava2 s . c o m String[] froms = null; try { froms = EmailAddressUtils.addressesToStrings(message.getFrom(), true /* mime decode */); } catch (MessagingException e) { logger.warn("From address is not a valid email address."); } if (froms != null) { for (String from : froms) { document.addAuthor(from); } } String subject = null; try { subject = message.getSubject(); } catch (MessagingException e) { logger.error("Error getting subject.", e); } if (subject != null) { document.addSubject(subject); document.addTitle(subject); } String[] tos = null; try { tos = EmailAddressUtils.addressesToStrings(message.getRecipients(RecipientType.TO), true /* mime decode */); } catch (MessagingException e) { logger.warn("To is not a valid email address."); } String[] ccs = null; try { ccs = EmailAddressUtils.addressesToStrings(message.getRecipients(RecipientType.CC), true /* mime decode */); } catch (MessagingException e) { logger.warn("CC is not a valid email address."); } Date sentDate = null; try { sentDate = message.getSentDate(); } catch (MessagingException e) { logger.error("Error getting sent date.", e); } Collection<Part> attachments = new LinkedList<Part>(); String body = BodyPartUtils.getPlainBodyAndAttachments(message, attachments); attachments = preprocessAttachments(attachments); if (body == null) { body = MISSING_BODY; } /* * PDF does not have tab support so we convert tabs to spaces */ body = StringReplaceUtils.replaceTabsWithSpaces(body, tabWidth); PdfPTable headerTable = new PdfPTable(2); headerTable.setHorizontalAlignment(Element.ALIGN_LEFT); headerTable.setWidthPercentage(100); headerTable.setWidths(new int[] { 1, 6 }); headerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); Font headerFont = createHeaderFont(); FontSelector headerFontSelector = createHeaderFontSelector(); PdfPCell cell = new PdfPCell(new Paragraph("From:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); String decodedFroms = StringUtils.defaultString(StringUtils.join(froms, ", ")); headerTable.addCell(headerFontSelector.process(decodedFroms)); cell = new PdfPCell(new Paragraph("To:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(StringUtils.join(tos, ", ")))); cell = new PdfPCell(new Paragraph("CC:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(StringUtils.join(ccs, ", ")))); cell = new PdfPCell(new Paragraph("Subject:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(subject))); cell = new PdfPCell(new Paragraph("Date:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(ObjectUtils.toString(sentDate)); cell = new PdfPCell(new Paragraph("Attachments:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable .addCell(headerFontSelector.process(StringUtils.defaultString(getAttachmentHeader(attachments)))); document.add(headerTable); if (replyURL != null) { addReplyLink(document, replyURL); } /* * Body table will contain the body of the message */ PdfPTable bodyTable = new PdfPTable(1); bodyTable.setWidthPercentage(100f); bodyTable.setSplitLate(false); bodyTable.setSpacingBefore(15f); bodyTable.setHorizontalAlignment(Element.ALIGN_LEFT); addBodyAndAttachments(pdfWriter, document, bodyTable, body, attachments); Phrase footer = new Phrase(FOOTER_TEXT); PdfContentByte cb = pdfWriter.getDirectContent(); ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, footer, document.right(), document.bottom(), 0); document.close(); }
From source file:net.bull.javamelody.internal.web.pdf.PdfCacheInformationsReport.java
License:Apache License
@Override void toPdf() throws DocumentException { writeHeader();/*from w ww .j a v a2s . c o m*/ for (final CacheInformations cacheInformations : cacheInformationsList) { nextRow(); writeCacheInformations(cacheInformations); } addTableToDocument(); if (!hitsRatioEnabled) { final Paragraph statisticsEnabledParagraph = new Paragraph(getString("caches_statistics_enable"), cellFont); statisticsEnabledParagraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(statisticsEnabledParagraph); } addConfigurationReference(); }
From source file:net.bull.javamelody.internal.web.pdf.PdfCacheInformationsReport.java
License:Apache License
private void addConfigurationReference() throws DocumentException { final Anchor ehcacheAnchor = new Anchor("Configuration reference", PdfFonts.BLUE.getFont()); ehcacheAnchor.setName("Ehcache configuration reference"); ehcacheAnchor.setReference(//ww w.j ava2s .c o m "http://ehcache.sourceforge.net/apidocs/net/sf/ehcache/config/CacheConfiguration.html#field_summary"); ehcacheAnchor.setFont(PdfFonts.BLUE.getFont()); final Paragraph ehcacheParagraph = new Paragraph(); ehcacheParagraph.add(ehcacheAnchor); ehcacheParagraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(ehcacheParagraph); }
From source file:net.bull.javamelody.internal.web.pdf.PdfCacheInformationsReport.java
License:Apache License
private void writeCacheInformations(CacheInformations cacheInformations) { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(cacheInformations.getName()); defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); if (configurationEnabled) { addCell(integerFormat.format(cacheInformations.getInMemoryPercentUsed())); }//from w w w. ja va 2s . c o m addCell(integerFormat.format(cacheInformations.getInMemoryObjectCount())); addCell(integerFormat.format(cacheInformations.getOnDiskObjectCount())); if (hitsRatioEnabled) { addCell(integerFormat.format(cacheInformations.getInMemoryHitsRatio())); addCell(integerFormat.format(cacheInformations.getHitsRatio())); } if (configurationEnabled) { defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(cacheInformations.getConfiguration()); } }
From source file:net.bull.javamelody.internal.web.pdf.PdfCounterErrorReport.java
License:Apache License
private void writeError(CounterError error, boolean displayUser, boolean displayHttpRequest) { getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(dateTimeFormat.format(error.getDate())); getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); if (displayHttpRequest) { if (error.getHttpRequest() == null) { addCell(""); } else {//from w w w . j a v a 2s.co m addCell(error.getHttpRequest()); } } if (displayUser) { if (error.getRemoteUser() == null) { addCell(""); } else { addCell(error.getRemoteUser()); } } addCell(error.getMessage()); }
From source file:net.bull.javamelody.internal.web.pdf.PdfCounterReport.java
License:Apache License
private void writeFooter() throws DocumentException { final List<CounterRequest> requests = counterRequestAggregation.getRequests(); final CounterRequest globalRequest = counterRequestAggregation.getGlobalRequest(); // delta ni ngatif ni 0 final long deltaMillis = Math.max(System.currentTimeMillis() - counter.getStartDate().getTime(), 1); final long hitsParMinute = 60 * 1000 * globalRequest.getHits() / deltaMillis; final String key; if (isJobCounter()) { key = "nb_jobs"; } else if (isErrorCounter()) { key = "nb_erreurs"; } else {//from ww w . ja va 2s.c o m key = "nb_requetes"; } final Paragraph footer = new Paragraph( getFormattedString(key, integerFormat.format(hitsParMinute), integerFormat.format(requests.size())), normalFont); footer.setAlignment(Element.ALIGN_RIGHT); addToDocument(footer); }