List of usage examples for com.itextpdf.text BaseColor BaseColor
public BaseColor(final float red, final float green, final float blue)
From source file:com.miraflorescarwash.controller.PdfController.java
private void crearPdfCombos(Document doc, List<ComboPorModelo> combos) { Paragraph parrafo;// w w w.j a v a 2 s.c o m PdfPTable tabla; String txt; PdfPCell cell; Phrase frase; String fuente; int i; fuente = "arial"; if (combos.isEmpty()) { return; } try { // // Se abre el documento. doc.open(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = "Combos"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 30, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_CENTER); doc.add(parrafo); LineSeparator ls = new LineSeparator(); doc.add(new Chunk(ls)); doc.add(Chunk.NEWLINE); tabla = new PdfPTable(5); frase = new Phrase("Id", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Nombre", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Lavadas", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Modelo", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Precio", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); i = 1; for (ComboPorModelo combo : combos) { if (i % 2 == 0) { cell = new PdfPCell(); cell.setBackgroundColor(new BaseColor(244, 119, 119)); frase = new Phrase(combo.getId()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(combo.getCombo().getNombre()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(combo.getCombo().getNumeroLavadas()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(combo.getModelo().getNombre()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase("S/. " + combo.getPrecio() + "0"); cell.setPhrase(frase); tabla.addCell(cell); } else { tabla.addCell(combo.getId() + ""); tabla.addCell(combo.getCombo().getNombre()); tabla.addCell(combo.getCombo().getNumeroLavadas() + ""); tabla.addCell(combo.getModelo().getNombre()); tabla.addCell("S/. " + combo.getPrecio() + "0"); } i++; } doc.add(tabla); doc.close(); } catch (DocumentException ex) { } }
From source file:com.miraflorescarwash.controller.PdfController.java
private void crearPdfCombosReporte(Document doc, List<ComboReporte> combos, PdfWriter writer) { Paragraph parrafo;//from w ww . ja v a 2s .co m PdfPTable tabla; String txt; PdfPCell cell; Phrase frase; String fuente; int i; JFreeChart chart; int w, h; int pos; pos = 0; w = h = 500; fuente = "arial"; if (combos.isEmpty()) { return; } try { // // Se abre el documento. doc.open(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = "Reporte de Combos"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 30, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_CENTER); doc.add(parrafo); LineSeparator ls = new LineSeparator(); doc.add(new Chunk(ls)); tabla = new PdfPTable(3); frase = new Phrase("Id", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Nombre", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Dinero Recaudado", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); i = 1; for (ComboReporte combo : combos) { if (i % 2 == 0) { cell = new PdfPCell(); cell.setBackgroundColor(new BaseColor(244, 119, 119)); frase = new Phrase(combo.getId() + ""); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(combo.getNombre()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase("S/. " + combo.getCantidad() + "0"); cell.setPhrase(frase); tabla.addCell(cell); } else { tabla.addCell(combo.getId() + ""); tabla.addCell(combo.getNombre()); tabla.addCell("S/. " + combo.getCantidad() + "0"); } i++; } doc.add(tabla); doc.newPage(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); chart = comboService.generarChartReporte(combos); w = 500; h = 500; PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(w, h); Graphics2D g2d = tp.createGraphics(w, h, new DefaultFontMapper()); Rectangle2D r2d = new Rectangle2D.Double(0, 0, w, h); chart.draw(g2d, r2d); cb.addTemplate(tp, 50, 250); g2d.dispose(); doc.close(); } catch (DocumentException ex) { } }
From source file:com.miraflorescarwash.controller.PdfController.java
private void crearPdfClientesFreq(Document doc, List<ClienteReporte> reporteCompras, PdfWriter writer) { Paragraph parrafo;// w w w . java2s . c om PdfPTable tabla; String txt; PdfPCell cell; Phrase frase; String fuente; JFreeChart chart; int i, w, h; fuente = "arial"; if (reporteCompras.isEmpty()) { return; } try { // // Se abre el documento. doc.open(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = "Clientes Frecuentes"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 30, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_CENTER); doc.add(parrafo); LineSeparator ls = new LineSeparator(); doc.add(new Chunk(ls)); doc.add(Chunk.NEWLINE); tabla = new PdfPTable(3); frase = new Phrase("Id", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Nombre", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Dinero", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); i = 1; for (ClienteReporte clienteReporte : reporteCompras) { if (i % 2 == 0) { cell = new PdfPCell(); cell.setBackgroundColor(new BaseColor(244, 119, 119)); frase = new Phrase(clienteReporte.getId() + ""); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(clienteReporte.getApellido() + " " + clienteReporte.getNombre()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase("S/. " + clienteReporte.getTotal() + "0"); cell.setPhrase(frase); tabla.addCell(cell); } else { tabla.addCell(clienteReporte.getId() + ""); tabla.addCell(clienteReporte.getApellido() + " " + clienteReporte.getNombre()); tabla.addCell("S/. " + clienteReporte.getTotal() + "0"); } i++; } doc.add(tabla); doc.newPage(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); chart = clienteService.generarChartReporte(reporteCompras); w = 500; h = 500; PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(w, h); Graphics2D g2d = tp.createGraphics(w, h, new DefaultFontMapper()); Rectangle2D r2d = new Rectangle2D.Double(0, 0, w, h); chart.draw(g2d, r2d); cb.addTemplate(tp, 50, 250); g2d.dispose(); doc.close(); } catch (DocumentException ex) { } }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private Font getFont(String color, boolean bold) throws Exception { Font font = FontFactory.getFont(BscConstants.PDF_ITEXT_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); int rgb[] = SimpleUtils.getColorRGB2(color); BaseColor baseColor = new BaseColor(rgb[0], rgb[1], rgb[2]); font.setSize(9);/*from w w w . j a v a 2s. c o m*/ if (bold) { font.setSize(14); font.setStyle(Font.BOLD); } font.setColor(baseColor); return font; }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void setCellBackgroundColor(PdfPCell cell, String color) throws Exception { int rgb[] = SimpleUtils.getColorRGB2(color); cell.setBackgroundColor(new BaseColor(rgb[0], rgb[1], rgb[2])); }
From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportPdfCommand.java
License:Apache License
private Font getFont(String color, boolean bold) throws Exception { Font font = FontFactory.getFont(BscConstants.PDF_ITEXT_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); int rgb[] = SimpleUtils.getColorRGB2(color); BaseColor baseColor = new BaseColor(rgb[0], rgb[1], rgb[2]); font.setSize(9);/*from w ww .j ava 2s .co m*/ font.setColor(baseColor); return font; }
From source file:com.nlbhub.nlb.domain.export.hypertext.document.PDFFont.java
License:Open Source License
public PDFFont(float size, Style style, RGBColor color) throws HTDocumentException { try {//from ww w . j a v a 2 s .co m BaseFont baseFont = (BaseFont.createFont("fonts/ttf/dejavu/DejaVuSans.ttf", "cp1251", BaseFont.EMBEDDED)); int iStyle; switch (style) { case BOLD: iStyle = Font.BOLD; break; case ITALIC: iStyle = Font.ITALIC; break; case UNDERLINE: iStyle = Font.UNDERLINE; break; default: iStyle = Font.NORMAL; break; } m_font = new Font(baseFont, size, iStyle, new BaseColor(color.getRed(), color.getGreen(), color.getBlue())); } catch (DocumentException | IOException e) { throw new HTDocumentException("Error while creating PDF font", e); } }
From source file:com.photoshop.misc.Factuurgenerator.java
private void creatCell(String cellnaam, PdfPTable table, boolean header) { if (header == true) { Font font = new Font(FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.WHITE); PdfPCell c1 = new PdfPCell(new Phrase(cellnaam, font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(new BaseColor(0, 121, 182)); c1.setMinimumHeight(20);//from w w w.j a v a 2s. c om table.addCell(c1); } if (header == false) { PdfPCell c1 = new PdfPCell(new Phrase(cellnaam)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); } }
From source file:com.photoshop.misc.Indexkaartgenerator.java
private void creatCell(String cellnaam, PdfPTable table, boolean header) { if (header == true) { Font font = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.WHITE); PdfPCell c1 = new PdfPCell(new Phrase(cellnaam, font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(new BaseColor(0, 121, 182)); c1.setMinimumHeight(20);// w w w . j av a 2 s. c o m table.addCell(c1); } if (header == false) { PdfPCell c1 = new PdfPCell(new Phrase(cellnaam)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); } }
From source file:com.primeleaf.krystal.web.action.console.OpenDocumentClassAction.java
License:Open Source License
private File generatePdfFile(ArrayList<Hit> hits, ArrayList<IndexDefinition> indexes, User loggedInUser) throws Exception { File tempPdf = File.createTempFile("tempPdf", ".pdf"); FileOutputStream file = new FileOutputStream(tempPdf); Document document = new Document(PageSize.A3.rotate()); PdfWriter.getInstance(document, file); document.open();// w ww .j av a 2 s . c om Font boldFont12 = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Font normalFont10 = new Font(FontFamily.HELVETICA, 10, Font.NORMAL); int colCount = 9; //predefined columns count int colSize = indexes.size() + colCount; float[] columnWidths = new float[colSize]; for (int i = 0; i < columnWidths.length; i++) { columnWidths[i] = (100 / colSize); } PdfPTable table = new PdfPTable(columnWidths); table.setWidthPercentage(100f); if (hits.size() > 0) { BaseColor bgColor = new BaseColor(225, 240, 255); insertCellPDF(table, "Document ID", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Revision ID", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Created By", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Last Modified By", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "File Size", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Created On", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Last Modified On", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Expiry On", Element.ALIGN_CENTER, 1, boldFont12, bgColor); for (IndexDefinition index : indexes) { insertCellPDF(table, index.getIndexDisplayName(), Element.ALIGN_CENTER, 1, boldFont12, bgColor); } insertCellPDF(table, "Note", Element.ALIGN_CENTER, 1, boldFont12, bgColor); int count = 0; for (Hit hit : hits) { count++; if (count % 2 == 0) { bgColor = new BaseColor(240, 240, 240); } else { bgColor = new BaseColor(210, 210, 210); } insertCellPDF(table, hit.documentId + "", Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.revisionId, Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.createdBy, Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.modifiedBy + "", Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, StringHelper.formatSizeText(hit.fileLength), Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.created, Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.modified, Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.expiryOn, Element.ALIGN_CENTER, 1, normalFont10, bgColor); for (String index : hit.indexValues) { insertCellPDF(table, index, Element.ALIGN_LEFT, 1, normalFont10, bgColor); } ArrayList<DocumentNote> documentNotes = DocumentNoteDAO.getInstance() .readJournalNotes("DOCUMENTID=" + hit.documentId + " AND ACTIVE ='Y' ORDER BY 1 DESC"); String notesData = ""; if (documentNotes.size() > 0) { for (DocumentNote documentNote : documentNotes) { if (!"P".equalsIgnoreCase(documentNote.getNoteType())) { if (!loggedInUser.getUserName().equalsIgnoreCase(documentNote.getUserName())) { continue; } } User user = UserDAO.getInstance().readUserByName(documentNote.getUserName()); notesData += documentNote.getNoteData() + "\n"; notesData += "Posted By" + " : " + user.getRealName() + "\n"; notesData += "Posted On" + " : " + StringHelper.formatDate(documentNote.getCreated()); notesData += "\n"; } } insertCellPDF(table, notesData, Element.ALIGN_LEFT, 1, normalFont10, bgColor); } } try { document.add(table); document.close(); file.close(); } catch (Exception e) { e.printStackTrace(); } return tempPdf; }