List of usage examples for com.itextpdf.text BaseColor CYAN
BaseColor CYAN
To view the source code for com.itextpdf.text BaseColor CYAN.
Click Source Link
From source file:br.com.ifrn.panfleto.gui.PainelCadastrar.java
public BaseColor corPagina() { if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Branco")) { return BaseColor.WHITE; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Preto")) { return BaseColor.BLACK; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Azul")) { return BaseColor.BLUE; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cinza Escuro")) { return BaseColor.DARK_GRAY; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cinza")) { return BaseColor.GRAY; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cinza Claro")) { return BaseColor.LIGHT_GRAY; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Magenta")) { return BaseColor.MAGENTA; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Laranja")) { return BaseColor.ORANGE; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Rosa")) { return BaseColor.PINK; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Vermlho")) { return BaseColor.RED; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Amarero")) { return BaseColor.YELLOW; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cyan")) { return BaseColor.CYAN; }/* www . j ava 2s . co m*/ return BaseColor.WHITE; }
From source file:com.ainfosec.macresponse.report.PdfGenerator.java
License:Open Source License
private static void createDataSection(Paragraph paragraph, DisplayObject displayObject) { if (displayObject == null || displayObject.getObjects() == null) { return;//from w w w. j a va 2 s . co m } // See if the DisplayObject has a list or a single object if (displayObject.getObjects().size() == 1) { TreeObject treeObject = displayObject.getObjects().get(0); // There's only 1 item // For each column, create/add a label with the title and the data int i = 0; for (String columnName : displayObject.getColumnNames()) { StringBuffer sb = new StringBuffer(); // Add the column title sb.append(displayObject.getColumnTitles()[i]); sb.append(": "); // Get the value of the field try { Field field = treeObject.getClass().getDeclaredField(columnName); String val = (String) field.get(treeObject); if (val == null) { val = ""; } // Add the value sb.append(val); sb.append("\n"); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Put the string into the paragraph paragraph.add(sb.toString()); i++; } } else { PdfPTable table = new PdfPTable(displayObject.getColumnTitles().length); table.setWidthPercentage(100); table.setHorizontalAlignment(Element.ALIGN_CENTER); for (String columnName : displayObject.getColumnTitles()) { table.getDefaultCell().setBackgroundColor(BaseColor.CYAN); table.addCell(columnName); table.getDefaultCell().setBackgroundColor(BaseColor.WHITE); } for (TreeObject to1 : displayObject.getObjects()) { for (String columnName : displayObject.getColumnNames()) { try { Field field = to1.getClass().getDeclaredField(columnName); String val = (String) field.get(to1); if (val == null) { val = ""; } table.addCell(val); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } table.getDefaultCell().setColspan(displayObject.getColumnTitles().length); table.getDefaultCell().setBorder(SWT.NONE); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // TODO Paul number the tables table.addCell("Table: " + displayObject.getTitle()); paragraph.add(table); } }
From source file:com.systemevent.jsfclass.util.PdfEvento.java
public PdfPTable Tabla_compleja() { //creamos una tabla con 3 columnas PdfPTable mitablacompleja = new PdfPTable(3); //aadimos texto con formato a la primera celda PdfPCell celda = new PdfPCell(new Paragraph("Historial de Observaciones", FontFactory.getFont("arial", // fuente 22, // tamao Font.BOLD, // estilo BaseColor.RED))); // color //unimos esta celda con otras 2 celda.setColspan(3);//from w ww. j a v a2 s . c om //alineamos el contenido al centro celda.setHorizontalAlignment(Element.ALIGN_CENTER); // aadimos un espaciado celda.setPadding(12.0f); //colocamos un color de fondo celda.setBackgroundColor(BaseColor.GRAY); //se aade a la tabla mitablacompleja.addCell(celda); //fila 2 celda = new PdfPCell(new Paragraph("AUDITORIA DE SISTEMAS")); celda.setColspan(2); celda.setBackgroundColor(BaseColor.GREEN); mitablacompleja.addCell(celda); celda = new PdfPCell(new Paragraph("Aprobado")); celda.setBackgroundColor(BaseColor.LIGHT_GRAY); mitablacompleja.addCell(celda); //fila 3 celda = new PdfPCell(new Paragraph("COMPILADORES")); celda.setColspan(2); celda.setBackgroundColor(BaseColor.YELLOW); mitablacompleja.addCell(celda); celda = new PdfPCell(new Paragraph("Reprobado")); celda.setBackgroundColor(BaseColor.LIGHT_GRAY); mitablacompleja.addCell(celda); //fila 4 celda = new PdfPCell(new Paragraph("Prog. Bajo Nivel")); celda.setColspan(2); celda.setBackgroundColor(BaseColor.CYAN); mitablacompleja.addCell(celda); celda = new PdfPCell(new Paragraph("Eximido")); celda.setBackgroundColor(BaseColor.LIGHT_GRAY); mitablacompleja.addCell(celda); //fila 5 mitablacompleja.addCell("Conclusion"); celda = new PdfPCell(new Paragraph("GET A LIFE!!!")); celda.setHorizontalAlignment(Element.ALIGN_RIGHT); celda.setColspan(2); celda.setBackgroundColor(BaseColor.ORANGE); mitablacompleja.addCell(celda); // se retorna la tabla return mitablacompleja; }
From source file:controlador.PDFServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w w w . j a va 2 s. com*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, BadElementException, DocumentException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { this.cliente = new ClienteDAO(); ArrayList c = cliente.listarTodo(); FileOutputStream archivo = new FileOutputStream( "C:\\Users\\ayoro\\OneDrive\\Documents\\NetBeansProjects\\Proyecto2\\ExpoturismoDriver\\archivo.pdf"); Document documento = new Document(); PdfWriter.getInstance(documento, archivo); documento.open(); documento.add(new Paragraph("Clientes!")); documento.add(new Paragraph("Pruebita del primer pdf", FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.CYAN))); // color documento.add( new Paragraph("Nueva tablita", FontFactory.getFont("arial", 28, Font.BOLD, BaseColor.BLUE))); documento.add(Chunk.NEWLINE); PdfPTable tabla = new PdfPTable(4); Paragraph ced = new Paragraph("Cdula", FontFactory.getFont("arial", 12, Font.BOLD, BaseColor.BLACK)); Paragraph nom = new Paragraph("Nombre", FontFactory.getFont("arial", 12, Font.BOLD, BaseColor.BLACK)); Paragraph cor = new Paragraph("Correo", FontFactory.getFont("arial", 12, Font.BOLD, BaseColor.BLACK)); Paragraph tel = new Paragraph("Telfono", FontFactory.getFont("arial", 12, Font.BOLD, BaseColor.BLACK)); tabla.addCell(ced); tabla.addCell(nom); tabla.addCell(cor); tabla.addCell(tel); for (int i = 0; i < c.size(); i += 4) { tabla.addCell("" + c.get(i)); tabla.addCell((String) c.get(i + 1)); tabla.addCell((String) c.get(i + 2)); tabla.addCell("" + c.get(i + 3)); } documento.add(tabla); documento.add(new Paragraph("Finito")); documento.add(new Paragraph("Prueba 2")); documento.close(); response.sendRedirect("opciones.jsp"); } }
From source file:itextpdf.GeneratePdf.java
License:Minecraft Mod Public
public void addElements() throws DocumentException { document.add(new Paragraph("Ejemplo primer prrafo, Ejemplos del mundo")); document.add(new Paragraph("Segundo titulo del mundo", FontFactory.getFont("arial", 22, Font.ITALIC, BaseColor.CYAN))); }
From source file:org.agmip.ui.afsirs.util.AFSIRSUtils.java
private void designDataCell(PdfPTable table, String str) { PdfPCell cell;/* w ww .j a v a2 s . com*/ // we add a c with colspan 3 cell = new PdfPCell(new Phrase(str, BLACK_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.CYAN); //cell.setColspan(14); table.addCell(cell); }
From source file:org.com.controller.ProductController.java
@RequestMapping(value = "/repProduct", method = RequestMethod.GET) public void productReport(Model m, HttpServletResponse response, HttpServletRequest request, OutputStream outputStream) throws Exception { String name = "ProductReport-"; Date d = new Date(); name = name + d.toString() + ".pdf"; response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=" + name); Rectangle pagesize = new Rectangle(216f, 720f); Document document = new Document(PageSize.A4); PdfWriter.getInstance(document, outputStream); document.open();//from w w w .j av a 2 s . c o m document.addTitle("PRODUCT DETAILSA REPORT"); document.add(new Paragraph("PRODUCT DETAILSA REPORT ", FontFactory.getFont(FontFactory.HELVETICA, 28, BaseColor.CYAN))); document.add(new Paragraph("DATE: " + new Date())); document.add(new Paragraph("-------------------------------------------------------- ")); document.add(new Paragraph(" ")); ProductDaoImpl pdi = new ProductDaoImpl(); PdfPTable table = new PdfPTable(4); table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell("ID"); table.addCell("TITLE"); table.addCell("PUBLISHER"); table.addCell("PRICE"); ArrayList<ProductTable> list = pdi.getAllProduct(); for (ProductTable u : list) { table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(u.getPid().toString()); table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.addCell(u.getPname()); table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(u.getPublisher()); table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.addCell(u.getSprice().toString()); } document.add(table); document.close(); }
From source file:proyectopdf.Pleno.java
public static void main(String a[]) throws FileNotFoundException, DocumentException, IOException { String ae;/*from ww w . j a v a2s .c om*/ JFileChooser jfc = new JFileChooser(); jfc.showOpenDialog(null); BufferedReader archivo = new BufferedReader(new FileReader(jfc.getSelectedFile().getPath())); FileOutputStream nuevo = new FileOutputStream("hola.pdf"); Document documento = new Document(); PdfWriter.getInstance(documento, nuevo); documento.open(); String w; while (archivo.ready()) { ae = archivo.readLine(); StringTokenizer tituloI = new StringTokenizer(ae, "{T}{#T}{C}{#C}{P}{#P}{S}{#S}"); while (tituloI.hasMoreTokens()) { String a1 = tituloI.nextToken(); w = a1; documento.add(new Paragraph(a1, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.BLUE))); } String a2 = ""; while (tituloI.hasMoreTokens()) { a2 = tituloI.nextToken(); documento.add(new Paragraph(a2, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.RED))); } String a3 = ""; while (tituloI.hasMoreTokens()) { a3 = tituloI.nextToken(); documento.add(new Paragraph(a3, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.CYAN))); } String a4 = ""; while (tituloI.hasMoreTokens()) { a4 = tituloI.nextToken(); documento.add(new Paragraph(a4, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.YELLOW))); } System.out.println(archivo.readLine()); } documento.close(); }
From source file:servlet.SalesReportPDF.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w w w . j a va 2s . c om*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Document document = new Document(); List<ArrayList> data = productSession.getEventList(); List<ArrayList> sessions = getAllProductDetailsLocal.getAllSessions(); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); //get current date time with Date() Date date = new Date(); //System.out.println(dateFormat.format(date)); @SuppressWarnings("unused") PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream("C:/Users/Yong Jing Ying/Desktop/EventRecords.pdf")); document.open(); document.add(new Paragraph("Management Report", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLUE))); document.add(new Paragraph("PDF created on " + dateFormat.format(date).toString() + "\n", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph( "------------------------------------------------------------------------------------", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); for (int i = 0; i < data.size(); i++) { document.add(new Paragraph(data.get(i).get(1).toString() + " Event Details ", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph("Event Type : " + data.get(i).get(4).toString() + "\nStart Date : " + data.get(i).get(2).toString() + "\nEnd Date : " + data.get(i).get(3).toString() + "\nProperty Name : " + data.get(i).get(5).toString() + "\nNo of Category : " + data.get(i).get(6).toString() + "\nPromotions : " + data.get(i).get(7).toString() + "\n\n")); document.add(new Paragraph("Session", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); PdfPTable table = new PdfPTable(6); //table.addCell("item1"); table.setSpacingBefore(5); table.setSpacingAfter(5); table.setWidths(new int[] { 1, 2, 3, 3, 3, 3 }); table.setWidthPercentage(100); PdfPCell cell; cell = new PdfPCell(new Phrase("No:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("Name:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("Description:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("Start:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("End:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("TicketPrices:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); for (int j = 0; j < sessions.size(); j++) { if (sessions.get(j).get(1).toString().equals(data.get(i).get(4).toString()) && sessions.get(j).get(0).toString().equals(data.get(i).get(0).toString())) { cell = new PdfPCell(new Phrase(sessions.get(j).get(8).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(4).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(5).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(6).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(7).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(9).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); } } document.add(table); document.add(new Paragraph("\n")); document.add(new Paragraph("Alert", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); table = new PdfPTable(6); //table.addCell("item1"); table.setSpacingBefore(5); table.setSpacingAfter(5); table.setWidths(new int[] { 1, 2, 2, 3, 3, 3 }); table.setWidthPercentage(100); cell = new PdfPCell(new Phrase("No:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("Alert Type:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("Below Sales:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("In-Charged Email:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("Start:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("End:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); for (int j = 0; j < sessions.size(); j++) { if (sessions.get(j).get(1).toString().equals(data.get(i).get(4).toString()) && sessions.get(j).get(0).toString().equals(data.get(i).get(0).toString()) && sessions.get(j).size() == 15) { cell = new PdfPCell(new Phrase(sessions.get(j).get(8).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(10).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(11).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(12).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(13).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(14).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); } } document.add(table); document.add(new Paragraph("\n\n")); } document.close(); Thread.sleep(1000); PrintWriter out = response.getWriter(); String fileName = "EventRecords.pdf"; String filePath = "C:/Users/Yong Jing Ying/Desktop/"; response.setContentType("APPLICATION/OCTET-STREAM"); response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\""); FileInputStream fi = new FileInputStream("C:/Users/Yong Jing Ying/Desktop/EventRecords.pdf"); int i; while ((i = fi.read()) != -1) { out.write(i); } out.close(); fi.close(); } catch (Exception ex) { Logger.getLogger(SalesReportPDF.class.getName()).log(Level.SEVERE, null, ex); } }