List of usage examples for com.itextpdf.text BaseColor GRAY
BaseColor GRAY
To view the source code for com.itextpdf.text BaseColor GRAY.
Click Source Link
From source file:Compras.Formatos.java
private void cabeceraFac(PDF reporte, BaseFont bf, PdfPTable tabla, Factura fac) { reporte.contenido.setLineWidth(0.5f); reporte.contenido.setColorFill(new GrayColor(0.9f)); reporte.contenido.roundRectangle(35, 660, 543, 40, 5);//cuadro cliente reporte.contenido.roundRectangle(35, 618, 543, 40, 5);//cuadro unidad reporte.contenido.roundRectangle(353, 738, 223, 10, 0);//cuadro fecha reporte.contenido.roundRectangle(353, 728, 223, 10, 0);//cuadro F.Fiscal reporte.contenido.roundRectangle(353, 718, 223, 10, 0);//cuadro C. SAT reporte.contenido.roundRectangle(353, 708, 223, 10, 0);//cuadro C. Emisor Configuracion con = (Configuracion) session.get(Configuracion.class, 1); reporte.inicioTexto();// w ww. j a va 2 s . c o m reporte.agregaObjeto(reporte.crearImagen("imagenes/factura300115.jpg", 00, -32, 40)); reporte.contenido.setFontAndSize(bf, 10); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "FACTURA", 520, 765, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, fac.getFolio(), 520, 755, 0); reporte.contenido.setFontAndSize(bf, 8); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:", 425, 740, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, fac.getFechaFiscal()/*new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())*/, 430, 740, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Folio Fiscal:", 425, 730, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, fac.getFFiscal(), 430, 730, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Certificado SAT:", 425, 720, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Certificado Emisor:", 425, 710, 0); reporte.contenido.setFontAndSize(bf, 6); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "2a. DE LA CADENA S/N COL. SAN PEDRO TOTOLTEPEC MEXICO CP 50200", 40, 702, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Tel. (01 722) 199-24- 04", 570, 702, 0); reporte.contenido.setFontAndSize(bf, 8); //************************datos del cliente**************************** DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");//YYYY-MM-DD HH:MM:SS reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Cliente: " + fac.getNombreReceptor(), 80, 692, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, fac.getNombreReceptor(), 85, 692, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Direccion: ", 80, 682, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, fac.getCalleReceptor() + " " + fac.getNumeroExteriorReceptor() + " Col:" + fac.getColoniaReceptor(), 85, 682, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Ciudad: ", 80, 672, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, fac.getMunicipioReceptor() + " " + fac.getMunicipioReceptor(), 85, 672, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "R.F.C.: ", 80, 662, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, fac.getRfcReceptor(), 85, 662, 0); //**********************datos de la unidad***************************** reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Marca: ", 80, 650, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Tipo: ", 80, 640, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "No. Serie: ", 80, 630, 0); //reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "asegurado: ", 80, 620, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Modelo: ", 350, 650, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Placas: ", 350, 640, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Poliza: ", 350, 630, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Km: ", 350, 620, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Sinisestro: ", 490, 650, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "INC: ", 490, 640, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Reporte: ", 490, 630, 0); /*if(factura==null) { reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getMarca().getMarcaNombre(), 80, 650, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getTipo().getTipoNombre(), 80, 640, 0); if(ord.getNoSerie()!=null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getNoSerie(), 80, 630, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ""+ord.getModelo(), 350, 650, 0); if(ord.getNoPlacas()!=null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getNoPlacas(), 350, 640, 0); if(ord.getPoliza()!=null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getPoliza(), 350, 630, 0); if(ord.getTipoCliente().compareTo("2")==0 || ord.getTipoCliente().compareTo("3")==0) { reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Tercero: ", 80, 620, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getClientes().getNombre(), 80, 620, 0); } else { reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Asegurado: ", 80, 620, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getClientes().getNombre(), 80, 620, 0); } if(ord.getKm()!=null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, ord.getKm(), 365, 620, 0); if(ord.getSiniestro()!=null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getSiniestro(), 490, 650, 0); if(ord.getInciso()!=null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getInciso(), 490, 640, 0); if(ord.getNoReporte()!=null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getNoReporte(), 490, 630, 0); }*/ reporte.finTexto(); //agregamos renglones vacios para dejar un espacio reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); Font font_mini = new Font(Font.FontFamily.HELVETICA, 1, Font.BOLD); BaseColor cabecera = BaseColor.GRAY; BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; tabla.addCell(reporte.celda("Cant", font, contenido, centro, 0, 1, Rectangle.RECTANGLE + Rectangle.TOP)); tabla.addCell(reporte.celda("U/Med", font, contenido, centro, 0, 1, Rectangle.RECTANGLE + Rectangle.TOP)); tabla.addCell(reporte.celda("D E S C R I P C I O N", font, contenido, centro, 0, 1, Rectangle.RECTANGLE + Rectangle.TOP)); tabla.addCell( reporte.celda("Precio c/u", font, contenido, centro, 0, 1, Rectangle.RECTANGLE + Rectangle.TOP)); tabla.addCell( reporte.celda("T O T A L", font, contenido, centro, 0, 1, Rectangle.RECTANGLE + Rectangle.TOP)); tabla.addCell(reporte.celda(" ", font_mini, null, centro, 5, 1, Rectangle.BOTTOM)); }
From source file:Compras.reportePedidos.java
public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla) { reporte.contenido.setLineWidth(0.5f); reporte.contenido.setColorStroke(new GrayColor(0.2f)); reporte.contenido.setColorFill(new GrayColor(0.9f)); reporte.contenido.roundRectangle(30, 700, 210, 45, 5); reporte.contenido.roundRectangle(250, 700, 325, 45, 5); Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction().begin();/*from w w w . j ava2 s . c om*/ Configuracion con = (Configuracion) session.get(Configuracion.class, 1); reporte.inicioTexto(); reporte.contenido.setFontAndSize(bf, 14); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 30, 585, 0); reporte.contenido.setFontAndSize(bf, 8); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Reporte de pedidos", 30, 575, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 750, 585, 0); reporte.finTexto(); if (session != null) if (session.isOpen()) session.close(); //agregamos renglones vacios para dejar un espacio reporte.agregaObjeto(new Paragraph(" ")); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); BaseColor cabecera = BaseColor.GRAY; BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; tabla.addCell(reporte.celda("Pedido", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Fecha", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("O. Taller", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Usuario", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Prov.", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Nombre de Proveedor", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Facturar a", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Observaciones", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Autorizo1", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Autorizo2", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Monto Tot", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); }
From source file:Compras.reportePedidos.java
public void cabeceraReporte(PDF reporte, BaseFont bf, PdfPTable tabla) { reporte.contenido.setLineWidth(0.5f); reporte.contenido.setColorStroke(new GrayColor(0.2f)); reporte.contenido.setColorFill(new GrayColor(0.9f)); reporte.contenido.roundRectangle(30, 700, 210, 45, 5); reporte.contenido.roundRectangle(250, 700, 325, 45, 5); Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction().begin();// ww w .j a v a 2 s .co m Configuracion con = (Configuracion) session.get(Configuracion.class, 1); reporte.inicioTexto(); reporte.contenido.setFontAndSize(bf, 14); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 30, 585, 0); reporte.contenido.setFontAndSize(bf, 8); reporte.contenido.setColorFill(BaseColor.BLACK); String cabeza = "Reporte"; if (l_id_cliente.getText().compareTo("") != 0 && t_datos.getRowCount() > 0) { cabeza += " Proveedor: " + t_datos.getValueAt(0, 5).toString(); } if (t_fecha1.getText().compareTo("AAAA-MM-DD") != 0) cabeza += " del: " + t_fecha1.getText(); if (t_fecha2.getText().compareTo("AAAA-MM-DD") != 0) cabeza += " al: " + t_fecha2.getText(); if (t_orden.getText().compareTo("") != 0) cabeza += " Orden: " + t_orden.getText(); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, cabeza, 30, 575, 0); String texto = ""; int[] lista = t_datos.getSelectedRows(); if (t_datos.getSelectedRows().length > 0) { for (int x = 0; x < t_datos.getSelectedRows().length; x++) { texto += t_datos.getValueAt(lista[x], 0) + ", "; } } else { if (t_datos.getRowCount() > 0) { for (int x = 0; x < t_datos.getRowCount(); x++) { texto += t_datos.getValueAt(x, 0) + ", "; } } } reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 750, 585, 0); reporte.finTexto(); if (session != null) if (session.isOpen()) session.close(); //agregamos renglones vacios para dejar un espacio reporte.agregaObjeto(new Paragraph(" ")); Font font = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD); BaseColor cabecera = BaseColor.GRAY; BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; tabla.addCell( reporte.celda("MATERIAL PEDIDOS:" + texto, font, cabecera, centro, 8, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("PEDIDO", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("NP", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("DESCRIPCIN", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("CANT", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("MED", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("PRECIO", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("ORDEN", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("PARTIDA", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); }
From source file:Contabilidad.RCuentas.java
public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla, String titulo1, int op) { Session session = HibernateUtil.getSessionFactory().openSession(); try {//ww w. jav a2s .co m reporte.contenido.setLineWidth(0.5f); reporte.contenido.setColorStroke(new GrayColor(0.2f)); reporte.contenido.setColorFill(new GrayColor(0.9f)); Configuracion con = (Configuracion) session.get(Configuracion.class, 1); reporte.inicioTexto(); reporte.contenido.setFontAndSize(bf, 14); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 35, 570, 0); reporte.contenido.setFontAndSize(bf, 8); reporte.contenido.setColorFill(BaseColor.BLACK); String titulo = titulo1; if (op == 1) { if (t_fecha3.getText().compareTo("AAAA-MM-DD") != 0) titulo += " apartir del " + t_fecha3.getText(); if (t_fecha4.getText().compareTo("AAAA-MM-DD") != 0) titulo += " al " + t_fecha4.getText(); } reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, titulo, 35, 560, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 750, 570, 0); if (op == 1) { if (valores != null) { String val = "Estatus: "; if (lista.getSelectedValues().length > 0) { for (int m = 0; m < valores.length; m++) { val += valores[m].toString() + ", "; } reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, val, 750, 560, 0); } else { for (int mm = 0; mm < lista.getModel().getSize(); mm++) { val += lista.getModel().getElementAt(mm).toString() + ", "; } reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, val, 750, 560, 0); } } } reporte.finTexto(); //agregamos renglones vacios para dejar un espacio reporte.agregaObjeto(new Paragraph(" ")); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); BaseColor cabecera = BaseColor.GRAY; BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; if (op == 1) { for (int a = 0; a < tabla.getNumberOfColumns(); a++) { tabla.addCell(reporte.celda(t_datos.getColumnName(a), font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); } } } catch (Exception e) { System.out.println(e); } if (session != null) if (session.isOpen()) session.close(); }
From source file:de.domjos.schooltools.helper.ApiHelper.java
License:Open Source License
public PDFBuilder exportMarkListToPDF(PDFBuilder pdfBuilder, MarkListSettings settings) throws Exception { String pointsOrErrors;/*from w ww. ja va2 s . co m*/ if (settings.isDictatMode()) { pointsOrErrors = this.context.getString(R.string.marklist_failures); } else { pointsOrErrors = this.context.getString(R.string.marklist_points); } StringBuilder builder = new StringBuilder(); builder.append(this.context.getString(R.string.marklist_type)).append(": ") .append(this.context.getResources().getStringArray(R.array.marklist_type)[settings.getType()]) .append(",\n"); builder.append(this.context.getString(R.string.marklist_view)).append(": ") .append(this.context.getResources().getStringArray(R.array.marklist_view)[settings.getViewMode()]) .append(",\n"); builder.append(this.context.getString(R.string.marklist_markMode)).append(": ").append( this.context.getResources().getStringArray(R.array.marklist_markMode)[settings.getMarMode()]) .append(",\n"); builder.append(this.context.getString(R.string.marklist_maxPoints)).append(": ") .append(settings.getMaxPoints()).append(" ").append(pointsOrErrors).append(",\n"); if (settings.isDictatMode()) { builder.append(this.context.getString(R.string.marklist_dictatMode)).append(",\n"); } if (settings.getType() != 0) { builder.append(this.context.getString(R.string.marklist_bestMarkAt)).append(": ") .append(settings.getBestMarkAt()).append(" ").append(pointsOrErrors).append(", "); builder.append(this.context.getString(R.string.marklist_worstMarkTo)).append(": ") .append(settings.getWorstMarkTo()).append(" ").append(pointsOrErrors).append(",\n"); builder.append(pointsOrErrors).append(": ").append(settings.getCustomPoints()).append(" ") .append(pointsOrErrors).append(", "); builder.append(this.context.getString(R.string.marklist_mark)).append(": ") .append(settings.getCustomMark()); } String content = builder.toString(); if (content.endsWith(",\n")) { content = content.substring(0, content.length() - 2); } pdfBuilder.addTitle(settings.getTitle(), "subHeader", Paragraph.ALIGN_CENTER); pdfBuilder.addEmptyLine(3); pdfBuilder.addParagraph(this.context.getString(R.string.main_menu_settings), content, "subHeader", "CONTENT_PARAM"); List<List<Map.Entry<String, BaseColor>>> lsBuilders = new LinkedList<>(); Map<Double, Double> mp = null; switch (settings.getType()) { case 0: GermanLinearList markListLinear = new GermanLinearList(this.context, settings.getMaxPoints()); markListLinear.setDictatMode(settings.isDictatMode()); markListLinear.setMarkMode(MarkListWithMarkMode.MarkMode.values()[settings.getMarMode()]); markListLinear.setViewMode(MarkListInterface.ViewMode.values()[settings.getViewMode()]); if (settings.getTenthMarks() == 1) { markListLinear.setMarkMultiplier(0.1); } else { markListLinear.setMarkMultiplier(1); } if (settings.getHalfPoints() == 1) { markListLinear.setPointsMultiplier(0.5); } else { markListLinear.setPointsMultiplier(1); } mp = markListLinear.calculate(); break; case 1: GermanListWithCrease markListCrease = new GermanListWithCrease(this.context, settings.getMaxPoints()); markListCrease.setDictatMode(settings.isDictatMode()); markListCrease.setMarkMode(MarkListWithMarkMode.MarkMode.values()[settings.getMarMode()]); markListCrease.setViewMode(MarkListInterface.ViewMode.values()[settings.getViewMode()]); if (settings.getTenthMarks() == 1) { markListCrease.setMarkMultiplier(0.1); } else { markListCrease.setMarkMultiplier(1); } if (settings.getHalfPoints() == 1) { markListCrease.setPointsMultiplier(0.5); } else { markListCrease.setPointsMultiplier(1); } markListCrease.setCustomMark(settings.getCustomMark()); markListCrease.setCustomPoints(settings.getCustomPoints()); markListCrease.setBestMarkAt(settings.getBestMarkAt()); markListCrease.setWorstMarkTo(settings.getWorstMarkTo()); mp = markListCrease.calculate(); break; default: } if (mp != null) { for (Map.Entry<Double, Double> entry : mp.entrySet()) { List<Map.Entry<String, BaseColor>> ls = new LinkedList<>(); ls.add(new AbstractMap.SimpleEntry<>(String.valueOf(entry.getKey()), BaseColor.GRAY)); ls.add(new AbstractMap.SimpleEntry<>(String.valueOf(entry.getValue()), BaseColor.GRAY)); lsBuilders.add(ls); } pdfBuilder.addEmptyLine(2); pdfBuilder.addTable(Arrays.asList(this.context.getString(R.string.marklist_mark), this.context.getString(R.string.marklist_points)), null, lsBuilders); } pdfBuilder.newPage(); return pdfBuilder; }
From source file:de.domjos.schooltools.helper.ApiHelper.java
License:Open Source License
public PDFBuilder exportMarkToPDF(PDFBuilder pdfBuilder, SchoolYear schoolYear) throws Exception { pdfBuilder.addTitle(schoolYear.getSubject().getTitle(), "header", Paragraph.ALIGN_CENTER); pdfBuilder.addEmptyLine(2);// www . j a va2 s. c o m List<Test> tests = schoolYear.getTests(); for (Test test : tests) { pdfBuilder.addTitle(test.getTitle(), "subHeader", Paragraph.ALIGN_CENTER); pdfBuilder.addEmptyLine(3); List<List<Map.Entry<String, BaseColor>>> lsBuilders = new LinkedList<>(); List<Map.Entry<String, BaseColor>> ls = new LinkedList<>(); ls.add(new AbstractMap.SimpleEntry<>(this.context.getString(R.string.mark_date), BaseColor.GRAY)); ls.add(new AbstractMap.SimpleEntry<>(Converter.convertDateToString(test.getTestDate()), BaseColor.GRAY)); lsBuilders.add(ls); ls = new LinkedList<>(); ls.add(new AbstractMap.SimpleEntry<>(this.context.getString(R.string.sys_memory), BaseColor.GRAY)); ls.add(new AbstractMap.SimpleEntry<>(Converter.convertDateToString(test.getMemoryDate()), BaseColor.GRAY)); lsBuilders.add(ls); ls = new LinkedList<>(); ls.add(new AbstractMap.SimpleEntry<>(this.context.getString(R.string.mark_weight), BaseColor.GRAY)); ls.add(new AbstractMap.SimpleEntry<>(String.valueOf(test.getWeight()), BaseColor.GRAY)); lsBuilders.add(ls); ls = new LinkedList<>(); ls.add(new AbstractMap.SimpleEntry<>(this.context.getString(R.string.mark_average), BaseColor.GRAY)); ls.add(new AbstractMap.SimpleEntry<>(String.valueOf(test.getAverage()), BaseColor.GRAY)); lsBuilders.add(ls); ls = new LinkedList<>(); ls.add(new AbstractMap.SimpleEntry<>(this.context.getString(R.string.mark_mark), BaseColor.GRAY)); ls.add(new AbstractMap.SimpleEntry<>(String.valueOf(test.getMark()), BaseColor.GRAY)); lsBuilders.add(ls); pdfBuilder.addTable(Arrays.asList(this.context.getString(R.string.sys_description), ""), null, lsBuilders); pdfBuilder.addEmptyLine(2); pdfBuilder.addParagraph(this.context.getString(R.string.sys_description), test.getDescription(), "subHeader", "CONTENT_PARAM"); pdfBuilder.addEmptyLine(2); pdfBuilder.addParagraph(this.context.getString(R.string.mark_themes), test.getThemes(), "subHeader", "CONTENT_PARAM"); pdfBuilder.newPage(); } return pdfBuilder; }
From source file:de.domjos.schooltools.helper.ApiHelper.java
License:Open Source License
public PDFBuilder exportTimeTableToPDF(PDFBuilder pdfBuilder, TimeTable timeTable, List<String> headers, SQLite sqLite) throws Exception { pdfBuilder.addTitle(timeTable.getTitle(), "header", Paragraph.ALIGN_CENTER); pdfBuilder.addEmptyLine(3);//w w w . ja va 2 s . c o m String content = "%s%n%s%n%s"; String classTitle = ""; if (timeTable.getSchoolClass() != null) { classTitle = this.context.getString(R.string.timetable_class) + ": " + timeTable.getSchoolClass().getTitle(); } String yearTitle = ""; if (timeTable.getYear() != null) { yearTitle = this.context.getString(R.string.mark_year) + ": " + timeTable.getYear().getTitle(); } String description = ""; if (!timeTable.getDescription().isEmpty()) { description = this.context.getString(R.string.sys_description) + "\n" + timeTable.getDescription(); } content = String.format(content, yearTitle, classTitle, description); pdfBuilder.addParagraph("", content, "header", "CONTENT_PARAM"); pdfBuilder.addEmptyLine(2); List<List<Map.Entry<String, BaseColor>>> tblCells = new LinkedList<>(); List<Hour> hours = sqLite.getHours(""); for (Hour hour : hours) { if (hour.isBreak()) { List<Map.Entry<String, BaseColor>> tblRows = new LinkedList<>(); tblRows.add(new AbstractMap.SimpleEntry<>(hour.getStart() + " - " + hour.getEnd(), BaseColor.GRAY)); for (int i = 0; i <= 6; i++) { tblRows.add(new AbstractMap.SimpleEntry<>("", BaseColor.GRAY)); } tblCells.add(tblRows); } else { List<Map.Entry<String, BaseColor>> tblRows = new LinkedList<>(); tblRows.add( new AbstractMap.SimpleEntry<>(hour.getStart() + " - " + hour.getEnd(), BaseColor.WHITE)); for (int i = 0; i <= 6; i++) { tblRows.add(new AbstractMap.SimpleEntry<>("", BaseColor.WHITE)); } tblCells.add(tblRows); } } for (int column = 0; column <= timeTable.getDays().length - 1; column++) { Day day = timeTable.getDays()[column]; int tmp = 0; if (day != null) { if (MainActivity.globals.getUserSettings().isTimeTableMode()) { Object[] objArray = day.getTeacherHour().values().toArray(); int row = 0; for (Hour hour : hours) { if (objArray.length < tmp + 1) { break; } if (objArray[tmp] instanceof TeacherHour) { for (Map.Entry<Hour, TeacherHour> entry : day.getTeacherHour().entrySet()) { if (entry.getKey().getID() == hour.getID()) { Subject subject = entry.getValue().getSubject(); String roomNumber = entry.getValue().getRoomNumber(); if (tblCells.get(row).get(0).getValue() != BaseColor.GRAY) { tblCells.get(row).set(column + 1, new AbstractMap.SimpleEntry<>( subject.getAlias() + "\n" + roomNumber, new BaseColor(Integer.parseInt(subject.getBackgroundColor())))); tmp++; } break; } } } row++; } } else { Object[] objArray = day.getPupilHour().values().toArray(); int row = 0; for (Hour hour : hours) { if (objArray.length < tmp + 1) { break; } if (objArray[tmp] instanceof PupilHour) { for (Map.Entry<Hour, PupilHour> entry : day.getPupilHour().entrySet()) { if (entry.getKey().getID() == hour.getID()) { Subject subject = entry.getValue().getSubject(); String roomNumber = entry.getValue().getRoomNumber(); if (tblCells.get(row).get(0).getValue() != BaseColor.GRAY) { tblCells.get(row).set(column + 1, new AbstractMap.SimpleEntry<>( subject.getAlias() + "\n" + roomNumber, new BaseColor(Integer.parseInt(subject.getBackgroundColor())))); tmp++; } break; } } } row++; } } } } pdfBuilder.addTable(headers, new float[] { 20.0f, 15.0f, 15.0f, 15.0f, 15.0f, 15.0f, 15.0f, 15.0f }, tblCells); pdfBuilder.newPage(); return pdfBuilder; }
From source file:fll.web.report.FinalComputedScores.java
License:Open Source License
@SuppressFBWarnings(value = { "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" }, justification = "Category name determines table name") private void writeScores(final Connection connection, final ScoreCategory[] subjectiveCategories, final double[] weights, final float[] relativeWidths, final String awardGroup, final WinnerType winnerCriteria, final Tournament tournament, final PdfPTable divTable, final Set<Integer> bestTeams) throws SQLException { final Map<ScoreCategory, Map<String, Map<Integer, Integer>>> teamSubjectiveRanks = gatherRankedSubjectiveTeams( connection, subjectiveCategories, winnerCriteria, tournament, awardGroup); final Map<Integer, Integer> teamPerformanceRanks = gatherRankedPerformanceTeams(connection, winnerCriteria, tournament, awardGroup);//from w w w.j a va2 s. co m ResultSet rawScoreRS = null; PreparedStatement teamPrep = null; ResultSet teamsRS = null; PreparedStatement scorePrep = null; try { final StringBuilder query = new StringBuilder(); query.append( "SELECT Teams.Organization,Teams.TeamName,Teams.TeamNumber,FinalScores.OverallScore,FinalScores.performance,current_tournament_teams.judging_station"); for (int cat = 0; cat < subjectiveCategories.length; cat++) { if (weights[cat] > 0.0) { final String catName = subjectiveCategories[cat].getName(); query.append(",FinalScores." + catName); } } query.append(" FROM Teams,FinalScores,current_tournament_teams"); query.append(" WHERE FinalScores.TeamNumber = Teams.TeamNumber"); query.append(" AND FinalScores.Tournament = ?"); query.append(" AND current_tournament_teams.event_division = ?"); query.append(" AND current_tournament_teams.TeamNumber = Teams.TeamNumber"); query.append( " ORDER BY FinalScores.OverallScore " + winnerCriteria.getSortString() + ", Teams.TeamNumber"); teamPrep = connection.prepareStatement(query.toString()); teamPrep.setInt(1, tournament.getTournamentID()); teamPrep.setString(2, awardGroup); teamsRS = teamPrep.executeQuery(); scorePrep = connection .prepareStatement("SELECT score FROM performance_seeding_max" + " WHERE TeamNumber = ?"); while (teamsRS.next()) { final int teamNumber = teamsRS.getInt(3); final String organization = teamsRS.getString(1); final String teamName = teamsRS.getString(2); final String judgingGroup = teamsRS.getString(6); final double totalScore; final double ts = teamsRS.getDouble(4); if (teamsRS.wasNull()) { totalScore = Double.NaN; } else { totalScore = ts; } // /////////////////////////////////////////////////////////////////// // Build a table of data for this team // /////////////////////////////////////////////////////////////////// final PdfPTable curteam = new PdfPTable(relativeWidths); curteam.getDefaultCell().setBorder(0); // The first row of the team table... // First column is organization name final PdfPCell teamCol = new PdfPCell(new Phrase(organization, ARIAL_8PT_NORMAL)); teamCol.setBorder(0); teamCol.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_LEFT); curteam.addCell(teamCol); curteam.getDefaultCell().setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_RIGHT); final PdfPCell judgeGroupCell = new PdfPCell(new Phrase(judgingGroup, ARIAL_8PT_NORMAL)); judgeGroupCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); judgeGroupCell.setBorder(0); curteam.addCell(judgeGroupCell); // Second column is "Raw:" final PdfPCell rawLabel = new PdfPCell(new Phrase("Raw:", ARIAL_8PT_NORMAL)); rawLabel.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_RIGHT); rawLabel.setBorder(0); curteam.addCell(rawLabel); insertRawScoreColumns(connection, tournament, winnerCriteria.getSortString(), subjectiveCategories, weights, teamNumber, curteam); // Column for the highest performance score of the seeding rounds scorePrep.setInt(1, teamNumber); rawScoreRS = scorePrep.executeQuery(); final double rawScore; if (rawScoreRS.next()) { final double v = rawScoreRS.getDouble(1); if (rawScoreRS.wasNull()) { rawScore = Double.NaN; } else { rawScore = v; } } else { rawScore = Double.NaN; } PdfPCell pCell = new PdfPCell((Double.isNaN(rawScore) ? new Phrase("No Score", ARIAL_8PT_NORMAL_RED) : new Phrase(Utilities.NUMBER_FORMAT_INSTANCE.format(rawScore), ARIAL_8PT_NORMAL))); pCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); pCell.setBorder(0); curteam.addCell(pCell); rawScoreRS.close(); // The "Overall score" column is not filled in for raw scores curteam.addCell(""); // The second row of the team table... // First column contains the team # and name final PdfPCell teamNameCol = new PdfPCell( new Phrase(Integer.toString(teamNumber) + " " + teamName, ARIAL_8PT_NORMAL)); teamNameCol.setBorder(0); teamNameCol.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_LEFT); curteam.addCell(teamNameCol); // Second column contains "Scaled:" final PdfPCell scaledCell = new PdfPCell(new Phrase("Scaled:", ARIAL_8PT_NORMAL)); scaledCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_RIGHT); scaledCell.setBorder(0); scaledCell.setColspan(2); curteam.addCell(scaledCell); // Next, one column containing the scaled score for each subjective // category with weight > 0 for (int cat = 0; cat < subjectiveCategories.length; cat++) { final Map<String, Map<Integer, Integer>> catRanks = teamSubjectiveRanks .get(subjectiveCategories[cat]); final double catWeight = weights[cat]; if (catWeight > 0.0) { final double scaledScore; final double v = teamsRS.getDouble(6 + cat + 1); if (teamsRS.wasNull()) { scaledScore = Double.NaN; } else { scaledScore = v; } final Map<Integer, Integer> judgingRanks = catRanks.get(judgingGroup); Font scoreFont; final String rankText; if (judgingRanks.containsKey(teamNumber)) { final int rank = judgingRanks.get(teamNumber); rankText = String.format("%1$s(%2$d)", Utilities.NON_BREAKING_SPACE, rank); if (1 == rank) { scoreFont = ARIAL_8PT_BOLD; } else { scoreFont = ARIAL_8PT_NORMAL; } } else { rankText = String.format("%1$s%1$s%1$s%1$s%1$s", Utilities.NON_BREAKING_SPACE); scoreFont = ARIAL_8PT_NORMAL; } final String scoreText; if (Double.isNaN(scaledScore)) { scoreText = "No Score" + rankText; scoreFont = ARIAL_8PT_NORMAL_RED; } else { scoreText = Utilities.NUMBER_FORMAT_INSTANCE.format(scaledScore) + rankText; } final PdfPCell subjCell = new PdfPCell(new Phrase(scoreText, scoreFont)); subjCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); subjCell.setBorder(0); curteam.addCell(subjCell); } } // foreach category // 2nd to last column has the scaled performance score { Font scoreFont; final String rankText; if (teamPerformanceRanks.containsKey(teamNumber)) { final int rank = teamPerformanceRanks.get(teamNumber); rankText = String.format("%1$s(%2$d)", Utilities.NON_BREAKING_SPACE, rank); if (1 == rank) { scoreFont = ARIAL_8PT_BOLD; } else { scoreFont = ARIAL_8PT_NORMAL; } } else { rankText = String.format("%1$s%1$s%1$s%1$s%1$s", Utilities.NON_BREAKING_SPACE); scoreFont = ARIAL_8PT_NORMAL; } final double scaledScore; final double v = teamsRS.getDouble(5); if (teamsRS.wasNull()) { scaledScore = Double.NaN; } else { scaledScore = v; } final String scaledScoreStr; if (Double.isNaN(scaledScore)) { scoreFont = ARIAL_8PT_NORMAL_RED; scaledScoreStr = "No Score" + rankText; } else { scaledScoreStr = Utilities.NUMBER_FORMAT_INSTANCE.format(scaledScore) + rankText; } pCell = new PdfPCell(new Phrase(scaledScoreStr, scoreFont)); pCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); pCell.setBorder(0); curteam.addCell(pCell); } // performance score // Last column contains the overall scaled score final String overallScoreSuffix; if (bestTeams.contains(teamNumber)) { overallScoreSuffix = String.format("%1$s*", Utilities.NON_BREAKING_SPACE); } else { overallScoreSuffix = String.format("%1$s%1$s", Utilities.NON_BREAKING_SPACE); } pCell = new PdfPCell((Double.isNaN(totalScore) ? new Phrase("No Score" + overallScoreSuffix, ARIAL_8PT_NORMAL_RED) : new Phrase(Utilities.NUMBER_FORMAT_INSTANCE.format(totalScore) + overallScoreSuffix, ARIAL_8PT_NORMAL))); pCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); pCell.setBorder(0); curteam.addCell(pCell); // This is an empty row in the team table that is added to put a // horizontal rule under the team's score in the display final PdfPCell blankCell = new PdfPCell(); blankCell.setBorder(0); blankCell.setBorderWidthBottom(0.5f); blankCell.setBorderColorBottom(BaseColor.GRAY); blankCell.setColspan(relativeWidths.length); curteam.addCell(blankCell); // Create a new cell and add it to the division table - this cell will // contain the entire team table we just built above final PdfPCell curteamCell = new PdfPCell(curteam); curteamCell.setBorder(0); curteamCell.setColspan(relativeWidths.length); divTable.addCell(curteamCell); } teamsRS.close(); } finally { SQLFunctions.close(teamsRS); SQLFunctions.close(teamPrep); SQLFunctions.close(rawScoreRS); SQLFunctions.close(scorePrep); } }
From source file:Forms.AddCustomers.java
private void cardBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cardBtnActionPerformed String name = fNameTxt.getText() + " " + lNameTxt.getText(); String cid = cusIdTxt.getText(); Document document = new Document(); Rectangle test = new Rectangle(350, 200); BaseColor color = new BaseColor(63, 72, 204); test.setBackgroundColor(color);/*from w w w. j a v a 2 s . co m*/ document.setPageSize(test); File theDir = new File("E:\\CustomerCard"); // if the directory does not exist, create it if (!theDir.exists()) { //System.out.println("creating directory: " + directoryName); boolean result = false; try { theDir.mkdir(); result = true; } catch (SecurityException se) { System.out.println(se.getMessage()); } } try { PdfWriter.getInstance(document, new FileOutputStream("E:\\CustomerCard\\card(" + cid + ").pdf")); document.open(); //Image image; //image = Image.getInstance("api.png"); //document.add(image); document.add(new Paragraph(" Customer Discount Card", FontFactory.getFont(FontFactory.TIMES_BOLD, 16, Font.BOLD, BaseColor.GRAY))); document.add(new Paragraph(" ")); document.add(new Paragraph(" Name : " + name, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph(" Card ID: " + cid, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.close(); try { //Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+"E:\\CustomerCard\\card("+cid+").pdf"); Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "C:\\Users\\Vidu\\Desktop\\CustomerIDCard\\card(" + cid + ").pdf"); } catch (Exception ex) { Logger.getLogger(SellPage.class.getName()).log(Level.SEVERE, null, ex); } //document.add(new Paragraph(date,FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL,BaseColor.BLACK))); fNameTxt.setText(""); lNameTxt.setText(""); cusIdTxt.setText(""); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private PdfPCell createHeaderCell(String content) { Paragraph paragraph = new Paragraph(); Font font = new Font(); font.setColor(BaseColor.WHITE);/*w ww . ja v a2s .c om*/ paragraph.setFont(font); paragraph.add(new Phrase(content)); PdfPCell cell = new PdfPCell(paragraph); cell.setPaddingBottom(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.GRAY); return cell; }