List of usage examples for com.itextpdf.text BaseColor BaseColor
public BaseColor(final float red, final float green, final float blue)
From source file:org.opentox.ontology.components.User.java
License:Open Source License
@Override public PDFObject getPDF() { PDFObject pdf = new PDFObject(); pdf.setPdfTitle(getUserName());/* ww w .j a v a 2 s . c o m*/ pdf.setPdfKeywords("User, " + getUserName() + ", Account"); pdf.setSubject("User Account Information for user " + getUserName()); Paragraph p1 = new Paragraph( new Chunk("OpenTox - User Report\n\n", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14))); pdf.addElement(p1); try { PdfPTable table = new PdfPTable(2); table.setWidths(new int[] { 30, 50 }); PdfPCell cell = new PdfPCell(new Paragraph("User Account Information")); cell.setColspan(2); cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0)); table.addCell(cell); table.addCell("UserName"); table.addCell(getUserName()); table.addCell("First Name"); table.addCell(getFirstName()); table.addCell("Last Name"); table.addCell(getLastName()); table.addCell("e-mail"); table.addCell(getEmail()); table.addCell("UserGroup"); table.addCell(getUserGroup().getName()); table.addCell("Authorization Level"); table.addCell(Integer.toString(getUserGroup().getLevel())); table.addCell("Organization"); table.addCell(getOrganization()); table.addCell("Country"); table.addCell(getCountry()); table.addCell("City"); table.addCell(getCity()); table.addCell("Address"); table.addCell(getAddress()); table.addCell("Web Page"); table.addCell(getWebpage()); table.addCell("Created on"); table.addCell(getTimeStamp()); pdf.addElement(table); } catch (DocumentException ex) { YaqpLogger.LOG.log( new Warning(getClass(), "XEI909 - Error while generating " + "PDF representation for User")); } return pdf; }
From source file:org.opentox.ontology.components.UserGroup.java
License:Open Source License
@Override public PDFObject getPDF() { PDFObject pdf = new PDFObject(); Paragraph p1 = new Paragraph( new Chunk("OpenTox - UserGroup Report\n\n", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14))); pdf.addElement(p1);// ww w . ja v a 2s . co m try { PdfPTable table = new PdfPTable(2); table.setWidths(new int[] { 30, 50 }); PdfPCell cell = new PdfPCell(new Paragraph("UserGroup General Information")); cell.setColspan(2); cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0)); table.addCell(cell); table.addCell("Name"); table.addCell(getName()); table.addCell("Authorization Level"); table.addCell(Integer.toString(getLevel())); pdf.addElement(table); } catch (DocumentException ex) { YaqpLogger.LOG.log(new Warning(getClass(), "XPI908 - Error while generating " + "PDF representation for User Group ")); } return pdf; }
From source file:org.patientview.radar.service.impl.PdfDocumentDataBuilder.java
License:Open Source License
private PdfPCell createHeadingCell(String text) { PdfPCell cell = createBaseCell(text, new Font(BASE_FONT, BASE_FONT_SIZE, Font.BOLD)); cell.setBackgroundColor(new BaseColor(0xDE, 0xDE, 0xDE)); return cell;//from ww w. j a va 2s . co m }
From source file:org.primaresearch.pdf.PageToPdfConverter.java
License:Apache License
/** * Returns the correct stroke colour for the given layout object type (e.g. blue for text region). *//* w w w .j av a 2 s. c o m*/ private BaseColor getOutlineColor(ContentType type) { if (type == LowLevelTextType.TextLine) return new BaseColor(50, 205, 50); else if (type == LowLevelTextType.Word) return new BaseColor(178, 34, 34); else if (type == LowLevelTextType.Glyph) return new BaseColor(46, 139, 8); else if (type == RegionType.TextRegion) return new BaseColor(0, 0, 255); else if (type == RegionType.ChartRegion) return new BaseColor(128, 0, 128); else if (type == RegionType.GraphicRegion) return new BaseColor(0, 128, 0); else if (type == RegionType.ImageRegion) return new BaseColor(0, 206, 209); else if (type == RegionType.LineDrawingRegion) return new BaseColor(184, 134, 11); else if (type == RegionType.MathsRegion) return new BaseColor(0, 191, 255); else if (type == RegionType.NoiseRegion) return new BaseColor(255, 0, 0); else if (type == RegionType.SeparatorRegion) return new BaseColor(255, 0, 255); else if (type == RegionType.TableRegion) return new BaseColor(139, 69, 19); else if (type == RegionType.AdvertRegion) return new BaseColor(70, 130, 180); else if (type == RegionType.ChemRegion) return new BaseColor(255, 140, 0); else if (type == RegionType.MusicRegion) return new BaseColor(148, 0, 211); return BaseColor.BLUE; }
From source file:org.restate.project.controller.PaymentReceiptController.java
License:Open Source License
@RequestMapping(method = RequestMethod.GET, value = "receipt.print") public void downloadDocument(HttpServletResponse response, @RequestParam(value = "id", required = false) Integer id) throws Exception { if (id == null) { return;/*from w ww .j a v a 2 s . c o m*/ } // creation of the document with a certain size and certain margins // may want to use PageSize.LETTER instead // Document document = new Document(PageSize.A4, 50, 50, 50, 50); Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); File tmpFile = File.createTempFile("paymentReceipt", ".pdf"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 12); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(tmpFile)); //document header attributes doc.addAuthor("betterThanZero"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("MySampleCode.com"); doc.addTitle("Report with Column Headings"); doc.setPageSize(PageSize.LETTER); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("iText is a library that allows you to create and " + "manipulate PDF documents. It enables developers looking to enhance web and other " + "applications with dynamic PDF document generation and/or manipulation."); //specify column widths float[] columnWidths = { 1.5f, 2f, 5f, 2f }; //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); //insert column headings insertCell(table, "Order No", Element.ALIGN_RIGHT, 1, bfBold12); insertCell(table, "Account No", Element.ALIGN_LEFT, 1, bfBold12); insertCell(table, "Account Name", Element.ALIGN_LEFT, 1, bfBold12); insertCell(table, "Order Total", Element.ALIGN_RIGHT, 1, bfBold12); table.setHeaderRows(1); //insert an empty row insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12); //create section heading by cell merging insertCell(table, "New York Orders ...", Element.ALIGN_LEFT, 4, bfBold12); double orderTotal, total = 0; //just some random data to fill for (int x = 1; x < 5; x++) { insertCell(table, "10010" + x, Element.ALIGN_RIGHT, 1, bf12); insertCell(table, "ABC00" + x, Element.ALIGN_LEFT, 1, bf12); insertCell(table, "This is Customer Number ABC00" + x, Element.ALIGN_LEFT, 1, bf12); orderTotal = Double.valueOf(df.format(Math.random() * 1000)); total = total + orderTotal; insertCell(table, df.format(orderTotal), Element.ALIGN_RIGHT, 1, bf12); } //merge the cells to create a footer for that section insertCell(table, "New York Total...", Element.ALIGN_RIGHT, 3, bfBold12); insertCell(table, df.format(total), Element.ALIGN_RIGHT, 1, bfBold12); //repeat the same as above to display another location insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12); insertCell(table, "California Orders ...", Element.ALIGN_LEFT, 4, bfBold12); orderTotal = 0; for (int x = 1; x < 7; x++) { insertCell(table, "20020" + x, Element.ALIGN_RIGHT, 1, bf12); insertCell(table, "XYZ00" + x, Element.ALIGN_LEFT, 1, bf12); insertCell(table, "This is Customer Number XYZ00" + x, Element.ALIGN_LEFT, 1, bf12); orderTotal = Double.valueOf(df.format(Math.random() * 1000)); total = total + orderTotal; insertCell(table, df.format(orderTotal), Element.ALIGN_RIGHT, 1, bf12); } insertCell(table, "California Total...", Element.ALIGN_RIGHT, 3, bfBold12); insertCell(table, df.format(total), Element.ALIGN_RIGHT, 1, bfBold12); //add the PDF table to the paragraph paragraph.add(table); // add the paragraph to the document doc.add(paragraph); } catch (DocumentException dex) { dex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } response.setHeader("Content-disposition", "attachment; filename=" + "sampleDoc" + ".pdf"); response.setContentType("application/pdf"); OutputStream outputStream = response.getOutputStream(); FileInputStream fileInputStream = new FileInputStream(tmpFile); IOUtils.copy(fileInputStream, outputStream); fileInputStream.close(); outputStream.flush(); tmpFile.delete(); } }
From source file:org.smap.sdal.managers.PDFSurveyManager.java
License:Open Source License
void setColor(String aValue, DisplayItem di, boolean isLabel) { BaseColor color = null;/*from w ww . j a v a 2 s .c om*/ String[] parts = aValue.split("_"); if (parts.length >= 4) { if (parts[1].startsWith("0x")) { color = new BaseColor(Integer.decode(parts[1]), Integer.decode(parts[2]), Integer.decode(parts[3])); } else { color = new BaseColor(Integer.decode("0x" + parts[1]), Integer.decode("0x" + parts[2]), Integer.decode("0x" + parts[3])); } } if (isLabel) { di.labelbg = color; } else { di.valuebg = color; } }
From source file:org.techytax.report.helper.PdfReportHelper.java
License:Open Source License
public byte[] createVatReportBytes(VatReportData vatReportData) { Document document = new Document(); document.setMargins(0, 0, 40, 40);/* w w w . j ava2 s .c om*/ ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); try { PdfWriter.getInstance(document, byteOutputStream); document.open(); PdfPTable subTable = new PdfPTable(1); PdfPCell cell = new PdfPCell(new Paragraph("")); subTable.addCell(cell); PdfPTable table = new PdfPTable(1); addSpace(table); Paragraph chunk = new Paragraph("btw declaratie aangever gegevens", headerFont); cell = new PdfPCell(chunk); cell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); subTable = new PdfPTable(2); addVatDeclarationData(subTable, vatReportData.getVatDeclarationData()); cell = new PdfPCell(subTable); cell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); addSpace(table); addVatData(table, vatReportData.getVatDeclarationData()); addSpace(table); addTotalsIn(vatReportData, table); addSpace(table); addTotalsOut(vatReportData, table); addSpace(table); addSpace(table); addJournalsIn(vatReportData, table); addJournalsOut(vatReportData, table); document.add(table); LineSeparator horizontalLine = new LineSeparator(); BaseColor lineColor = new BaseColor(141, 141, 141); horizontalLine.setLineWidth(1f); horizontalLine.setLineColor(lineColor); document.add(horizontalLine); } catch (Exception de) { de.printStackTrace(); } document.close(); return byteOutputStream.toByteArray(); }
From source file:PDF.GenerateReportActivities.java
private PdfPTable TablaDatos() throws Exception { PdfPTable Datos_prof = new PdfPTable(5); Datos_prof.setWidths(new int[] { 2, 3, 2, 2, 2 }); PdfPCell Titulo_tabla = new PdfPCell(new Phrase("Datos generales del Profesor", encabezadost)); PdfPCell Nombre = new PdfPCell(new Phrase("Nombre del Profesor")); PdfPCell Matricula = new PdfPCell(new Phrase("No. de Empleado")); PdfPCell UA = new PdfPCell(new Phrase("Unidad Acadmica")); PdfPCell Puntos = new PdfPCell(new Phrase("Puntos obtenidos")); PdfPCell Nivel = new PdfPCell(new Phrase("Nivel de Beca")); Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER); Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE); Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76)); Titulo_tabla.setColspan(5);/*from w w w. jav a 2 s . c o m*/ Titulo_tabla.setExtraParagraphSpace(15f); Datos_prof.addCell(Titulo_tabla); Nombre.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Nombre); Matricula.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Matricula); UA.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(UA); Puntos.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Puntos); Nivel.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Nivel); /*Aqui van las consultas de los datos del profesor*/ ResultSet rn, rt; String nom_usuario = null, id_usuario = null, u_a = null, puntaje_final = null, nivel = null; //Datos_prof.addCell("Hola"); ResultSet rp = lb.executeQuery("SELECT * FROM usuario WHERE id_usuario = " + username); while (rp.next()) { nom_usuario = rp.getString("nom_usuario"); id_usuario = rp.getString("id_usuario"); u_a = rp.getString("u_a"); } System.out.println(getUsername()); rn = lb.executeQuery( "SELECT * FROM evaluador_evalua_profesor WHERE id_usuario_prof = '" + getUsername() + "'"); while (rn.next()) { puntaje_final = rn.getString("puntaje_final"); //Datos_prof.addCell(rn.getString("puntaje_final")); } rt = lb.executeQuery("SELECT * FROM profesor WHERE id_usuario = '" + getUsername() + "'"); while (rt.next()) { nivel = rt.getString("nivel"); } Datos_prof.addCell(nom_usuario); Datos_prof.addCell(id_usuario); Datos_prof.addCell(u_a); Datos_prof.addCell(puntaje_final); Datos_prof.addCell(nivel); return Datos_prof; }
From source file:PDF.GenerateReportActivities.java
private PdfPTable dospuntouno() throws Exception { PdfPTable Dos_uno = new PdfPTable(6); Dos_uno.setWidths(new int[] { 2, 2, 3, 2, 2, 2 }); PdfPCell Titulo_tabla = new PdfPCell(new Phrase( "Actividad 2.1" + " - Formacin de Recursos Humanos para la Investigacin", encabezadost)); PdfPCell Nom_Proyecto = new PdfPCell(new Phrase("Nmero de proyecto SIP")); PdfPCell Num_Actividad = new PdfPCell(new Phrase("Nmero de Actividad")); PdfPCell Tipo_Actividad = new PdfPCell(new Phrase("Tipo de Actividad")); PdfPCell Ruta_alm = new PdfPCell(new Phrase("Evidencia")); PdfPCell Puntos = new PdfPCell(new Phrase("Puntos obtenidos")); PdfPCell Observaciones = new PdfPCell(new Phrase("Observaciones")); //PdfPCell celda=new PdfPCell(); Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER); Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE); Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76)); Titulo_tabla.setColspan(6);/*www . j a v a 2 s .co m*/ Titulo_tabla.setExtraParagraphSpace(15f); Dos_uno.addCell(Titulo_tabla); Nom_Proyecto.setHorizontalAlignment(Element.ALIGN_CENTER); Nom_Proyecto.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Nom_Proyecto); Num_Actividad.setHorizontalAlignment(Element.ALIGN_CENTER); Num_Actividad.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Num_Actividad); Tipo_Actividad.setHorizontalAlignment(Element.ALIGN_CENTER); Tipo_Actividad.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Tipo_Actividad); Ruta_alm.setHorizontalAlignment(Element.ALIGN_CENTER); Ruta_alm.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Ruta_alm); Puntos.setHorizontalAlignment(Element.ALIGN_CENTER); Puntos.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Puntos); Observaciones.setHorizontalAlignment(Element.ALIGN_CENTER); Observaciones.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Observaciones); /*Aqui van las consultas de las Actividades del profesor*/ /**Get actual period***/ int periodo = 0; ResultSet rperiodo = lb.executeQuery("SELECT * FROM profesor WHERE id_usuario = " + getUsername()); if (rperiodo.next()) periodo = rperiodo.getInt("periodo"); /**Get actual period***/ String id_al = null, tipo_alumno = null, puntaje = null, comen = null, nom_proyecto = null; ResultSet rb = lb .executeQuery("SELECT * FROM profesor_tiene_proyecto WHERE " + "id_usuario = " + getUsername() + " AND (validado_alumno = 1 OR validado_alumno = 0) AND " + "periodo = " + periodo); while (rb.next()) { nom_proyecto = rb.getString("id_proyecto"); Dos_uno.addCell(nom_proyecto); id_al = rb.getString("id_alumno"); Dos_uno.addCell(id_al); tipo_alumno = rb.getString("tipo_alumno"); Dos_uno.addCell(tipo_alumno); Anchor anchor = new Anchor("Constancia"); //anchor.setReference("file:///"+rb.getString("ruta_alm")); anchor.setReference(rb.getString("ruta_alumno")); Dos_uno.addCell(anchor); puntaje = rb.getString("puntaje_alumno"); Dos_uno.addCell(puntaje); comen = rb.getString("comentarios"); Dos_uno.addCell(comen); } return Dos_uno; }
From source file:PDF.GenerateReportActivities.java
private PdfPTable dospuntodos() throws Exception { PdfPTable Dos_dos = new PdfPTable(5); Dos_dos.setWidths(new int[] { 2, 2, 3, 2, 3 }); PdfPCell Titulo_tabla = new PdfPCell( new Phrase("Actividad 2.2" + " - Publicaciones Cientficas y/o de Divulgacin", encabezadost)); PdfPCell Num_Actividad = new PdfPCell(new Phrase("Nmero de Actividad")); PdfPCell Tipo_Actividad = new PdfPCell(new Phrase("Tipo de Actividad* (Consultar parte de abajo)")); PdfPCell Ruta_alm = new PdfPCell(new Phrase("Evidencia")); PdfPCell Puntos = new PdfPCell(new Phrase("Puntos obtenidos")); PdfPCell Observaciones = new PdfPCell(new Phrase("Observaciones")); PdfPCell celda = new PdfPCell(); Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER); Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE); Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76)); Titulo_tabla.setColspan(5);/*from w ww . ja v a 2 s. c om*/ Titulo_tabla.setExtraParagraphSpace(15f); Dos_dos.addCell(Titulo_tabla); Num_Actividad.setHorizontalAlignment(Element.ALIGN_CENTER); Num_Actividad.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_dos.addCell(Num_Actividad); Tipo_Actividad.setHorizontalAlignment(Element.ALIGN_CENTER); Tipo_Actividad.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_dos.addCell(Tipo_Actividad); Ruta_alm.setHorizontalAlignment(Element.ALIGN_CENTER); Ruta_alm.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_dos.addCell(Ruta_alm); Puntos.setHorizontalAlignment(Element.ALIGN_CENTER); Puntos.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_dos.addCell(Puntos); Observaciones.setHorizontalAlignment(Element.ALIGN_CENTER); Observaciones.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_dos.addCell(Observaciones); /*Aqui van las consultas de las Actividades del profesor*/ int periodo = 0; ResultSet rperiodo = lb.executeQuery("SELECT * FROM profesor WHERE id_usuario = " + getUsername()); if (rperiodo.next()) periodo = rperiodo.getInt("periodo"); /**Get actual period***/ String id_pub = null, id_tipo = null, puntaje = null, coment = null; ResultSet rb = lb.executeQuery("SELECT * FROM profesor_tiene_pub WHERE " + "id_usuario = '" + getUsername() + "' AND (validado = 1 OR validado = 0) AND (id_tipo_pub = 1 " + "OR id_tipo_pub = 2 OR id_tipo_pub = 3 OR id_tipo_pub = 4 OR id_tipo_pub = 5) AND " + "periodo = " + periodo); while (rb.next()) { id_pub = rb.getString("id_publicacion"); Dos_dos.addCell(id_pub); id_tipo = rb.getString("id_tipo_pub"); Dos_dos.addCell(id_tipo);//Add the type of every type pub Anchor anchor = new Anchor("Constancia"); anchor.setReference(rb.getString("ruta_alm")); //anchor.setReference("file:///"+rb.getString("ruta_alm")); Dos_dos.addCell(anchor); puntaje = rb.getString("puntaje"); Dos_dos.addCell(puntaje); coment = rb.getString("comentarios"); Dos_dos.addCell(coment); } return Dos_dos; }