List of usage examples for com.itextpdf.text.pdf PdfPCell setBackgroundColor
public void setBackgroundColor(final BaseColor backgroundColor)
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private void insertHeaderCell(PdfPTable table, String text, Integer colSpan) { if (text == null) { text = ""; }/* w w w . j a v a 2 s . c om*/ // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER)); // set the cell alignment // in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(colSpan); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorderWidth(2); cell.setPadding(3f); // add the call to the table table.addCell(cell); }
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);//ww w . j av a 2 s .c o m //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:com.wabacus.system.component.application.report.abstractreport.AbsReportType.java
License:Open Source License
protected void addDataHeaderCell(Object configbean, String value, int rowspan, int colspan, int align) { if (dataheadFont == null) { int dataheaderfontsize = 0; if (this.pdfbean != null) dataheaderfontsize = this.pdfbean.getDataheaderfontsize(); if (dataheaderfontsize <= 0) dataheaderfontsize = 6;/* ww w . ja va 2 s.c o m*/ dataheadFont = new Font(PdfAssistant.getInstance().getBfChinese(), dataheaderfontsize, Font.BOLD);//?? } PdfPCell cell = new PdfPCell(new Paragraph(value, dataheadFont)); cell.setColspan(colspan); cell.setRowspan(rowspan); // cell.setImage(img); // cell.addElement(new Paragraph(value+"2222",dataheadFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(align); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); if (pdfbean != null && pdfbean.getInterceptorObj() != null) { pdfbean.getInterceptorObj().displayPerColDataWithoutTemplate(this, configbean, -1, value, cell); } pdfDataTable.addCell(cell); }
From source file:control.ReportHandler.java
public void writeTotalEnrolledReport() throws DocumentException, FileNotFoundException { Document doc = new Document(); Calendar c = Calendar.getInstance(); String file = "" + c.get(Calendar.DAY_OF_MONTH) + "_" + (c.get(Calendar.MONTH) + 1) + "_" + c.get(Calendar.YEAR) + "_T_" + c.get(Calendar.HOUR_OF_DAY) + "_" + c.get(Calendar.MINUTE) + ".pdf"; PdfWriter.getInstance(doc, new FileOutputStream(new File(his.His.reportEnrolledDir + "/" + file))); doc.open();/*from w ww . j av a 2s . com*/ PdfPTable totalTable = new PdfPTable(1); totalTable.setSpacingAfter(10f); PdfPTable tableP = new PdfPTable(4); PdfPTable tableGs = new PdfPTable(3); PdfPCell tableGsnameCell = new PdfPCell(new Phrase("Navn", columnFont)); tableGsnameCell.setBackgroundColor(BaseColor.BLACK); PdfPCell tableGsbirthCell = new PdfPCell(new Phrase("Fdselsdag", columnFont)); tableGsbirthCell.setBackgroundColor(BaseColor.BLACK); PdfPCell tableGsPersonCell = new PdfPCell(new Phrase("Person navn", columnFont)); tableGsPersonCell.setBackgroundColor(BaseColor.BLACK); tableGs.addCell(tableGsnameCell); tableGs.addCell(tableGsbirthCell); tableGs.addCell(tableGsPersonCell); PdfPCell tablePnameCell = new PdfPCell(new Phrase("Navn", columnFont)); tablePnameCell.setBackgroundColor(BaseColor.BLACK); PdfPCell tablePaddressCell = new PdfPCell(new Phrase("Adresse", columnFont)); tablePaddressCell.setBackgroundColor(BaseColor.BLACK); PdfPCell tablePenrollerCell = new PdfPCell(new Phrase("Indskriver", columnFont)); tablePenrollerCell.setBackgroundColor(BaseColor.BLACK); PdfPCell tablePtotalGuestsCell = new PdfPCell(new Phrase("Total gster", columnFont)); tablePtotalGuestsCell.setBackgroundColor(BaseColor.BLACK); tableP.addCell(tablePnameCell); tableP.addCell(tablePaddressCell); tableP.addCell(tablePenrollerCell); tableP.addCell(tablePtotalGuestsCell); HashSet<Enrollment> enA = enR.getEnrollments(); int totalCounter = 0; int totalCounter_NoHoene = 0; Iterator<Enrollment> enI = enA.iterator(); while (enI.hasNext()) { totalCounter++; Enrollment en = enI.next(); Person enP = en.getEnrolledPerson(); if (!enP.isHoene()) { totalCounter_NoHoene++; } String nameP = enP.getFirstname() + " " + enP.getMiddlename() + " " + enP.getLastname(); String addressP = enP.getAddress(); User enU = en.getEnrolledByUser(); String nameU = enU.getFirstname() + " " + enU.getMiddlename() + " " + enU.getLastname(); Set<Guest> enGs = en.getGuests(); String totalGs = String.valueOf(enGs.size()); totalCounter += enGs.size(); totalCounter_NoHoene += enGs.size(); PdfPCell namePCell = new PdfPCell(new Phrase(nameP)); PdfPCell birthPCell = new PdfPCell(new Phrase(addressP)); PdfPCell nameUCell = new PdfPCell(new Phrase(nameU)); PdfPCell totalGsCell = new PdfPCell(new Phrase(totalGs)); tableP.addCell(namePCell); tableP.addCell(birthPCell); tableP.addCell(nameUCell); tableP.addCell(totalGsCell); Iterator<Guest> enGsI = enGs.iterator(); while (enGsI.hasNext()) { Guest g = enGsI.next(); String nameG = g.getFirstname() + " " + g.getMiddlename() + " " + g.getLastname(); PdfPCell nameGCell = new PdfPCell(new Phrase(nameG)); PdfPCell birthGCell = new PdfPCell(new Phrase(g.getBirthdayDate())); PdfPCell personGCell = new PdfPCell(new Phrase(nameP)); tableGs.addCell(nameGCell); tableGs.addCell(birthGCell); tableGs.addCell(personGCell); } } PdfPCell totalCell = new PdfPCell(new Phrase("Total indskrevne: " + totalCounter)); totalTable.addCell(totalCell); PdfPCell totalNoHoeneCell = new PdfPCell( new Phrase("Total indskrevne uden hner: " + totalCounter_NoHoene)); totalTable.addCell(totalNoHoeneCell); doc.add(new Phrase("Personer")); doc.add(tableP); doc.add(totalTable); doc.add(new Phrase("Gster")); doc.add(tableGs); doc.close(); }
From source file:control.ReportHandler.java
public void writeTotalPersonReport() throws DocumentException, FileNotFoundException { Document doc = new Document(PageSize.A4.rotate()); Calendar c = Calendar.getInstance(); String file = "" + c.get(Calendar.DAY_OF_MONTH) + "_" + (c.get(Calendar.MONTH) + 1) + "_" + c.get(Calendar.YEAR) + "_T_" + c.get(Calendar.HOUR_OF_DAY) + "_" + c.get(Calendar.MINUTE) + ".pdf"; PdfWriter.getInstance(doc, new FileOutputStream(new File(his.His.reportPersonsDir + "/" + file))); doc.open();//from w w w. j av a 2 s . com PdfPTable table = new PdfPTable(7); table.setWidths(new float[] { 10f, 10f, 10f, 10f, 5f, 5f, 5f }); PdfPTable totalTable = new PdfPTable(1); PdfPCell nameCell = new PdfPCell(new Phrase("Navn", columnFont)); nameCell.setBackgroundColor(BaseColor.BLACK); PdfPCell addressCell = new PdfPCell(new Phrase("Adresse", columnFont)); addressCell.setBackgroundColor(BaseColor.BLACK); PdfPCell birthCell = new PdfPCell(new Phrase("Fdselsdag", columnFont)); birthCell.setBackgroundColor(BaseColor.BLACK); PdfPCell createdCell = new PdfPCell(new Phrase("Oprettelsesdato", columnFont)); createdCell.setBackgroundColor(BaseColor.BLACK); PdfPCell hoeneCell = new PdfPCell(new Phrase("Hne", columnFont)); hoeneCell.setBackgroundColor(BaseColor.BLACK); PdfPCell reserveCell = new PdfPCell(new Phrase("Reserve", columnFont)); reserveCell.setBackgroundColor(BaseColor.BLACK); PdfPCell oneOneCell = new PdfPCell(new Phrase("1-1", columnFont)); oneOneCell.setBackgroundColor(BaseColor.BLACK); table.addCell(nameCell); table.addCell(addressCell); table.addCell(birthCell); table.addCell(createdCell); table.addCell(hoeneCell); table.addCell(reserveCell); table.addCell(oneOneCell); HashSet<Person> persons = peR.getPersons(); Iterator<Person> personsI = persons.iterator(); PdfPCell totalCell = new PdfPCell(new Phrase("Total: " + persons.size())); totalTable.addCell(totalCell); while (personsI.hasNext()) { Person p = personsI.next(); String name = p.getFirstname() + " " + p.getMiddlename() + " " + p.getLastname(); String hoene = "Nej"; if (p.isHoene()) { hoene = "Ja"; } String reserve = "Nej"; if (p.isReserve()) { reserve = "Ja"; } String oneOne = "Nej"; if (p.isOneOne()) { oneOne = "Ja"; } PdfPCell nameC = new PdfPCell(new Phrase(name)); PdfPCell addressC = new PdfPCell(new Phrase(p.getAddress())); PdfPCell birthC = new PdfPCell(new Phrase(p.getBirthdayDate())); PdfPCell createdC = new PdfPCell(new Phrase(p.getCreationDate())); PdfPCell hoeneC = new PdfPCell(new Phrase(hoene)); PdfPCell reserveC = new PdfPCell(new Phrase(reserve)); PdfPCell oneOneC = new PdfPCell(new Phrase(oneOne)); table.addCell(nameC); table.addCell(addressC); table.addCell(birthC); table.addCell(createdC); table.addCell(hoeneC); table.addCell(reserveC); table.addCell(oneOneC); } doc.add(new Phrase("Personer")); doc.add(table); doc.add(totalTable); doc.close(); }
From source file:control.ReportHandler.java
public void writeTotalUserReport() throws DocumentException, FileNotFoundException { Document doc = new Document(PageSize.A4.rotate()); Calendar c = Calendar.getInstance(); String file = "" + c.get(Calendar.DAY_OF_MONTH) + "_" + (c.get(Calendar.MONTH) + 1) + "_" + c.get(Calendar.YEAR) + "_T_" + c.get(Calendar.HOUR_OF_DAY) + "_" + c.get(Calendar.MINUTE) + ".pdf"; PdfWriter.getInstance(doc, new FileOutputStream(new File(his.His.reportUsersDir + "/" + file))); doc.open();// w w w . j a va2s . c o m PdfPTable table = new PdfPTable(5); PdfPTable totalTable = new PdfPTable(1); PdfPCell colName = new PdfPCell(new Phrase("Navn", columnFont)); colName.setBackgroundColor(BaseColor.BLACK); PdfPCell colBrugernavn = new PdfPCell(new Phrase("Brugernavn", columnFont)); colBrugernavn.setBackgroundColor(BaseColor.BLACK); PdfPCell colCreated = new PdfPCell(new Phrase("Oprettelsesdato", columnFont)); colCreated.setBackgroundColor(BaseColor.BLACK); PdfPCell colReserve = new PdfPCell(new Phrase("Reserve", columnFont)); colReserve.setBackgroundColor(BaseColor.BLACK); PdfPCell colAdmin = new PdfPCell(new Phrase("Administrator", columnFont)); colAdmin.setBackgroundColor(BaseColor.BLACK); table.addCell(colName); table.addCell(colBrugernavn); table.addCell(colCreated); table.addCell(colReserve); table.addCell(colAdmin); HashSet<User> users = usR.getUsers(); Iterator<User> usI = users.iterator(); PdfPCell totalCell = new PdfPCell(new Phrase("Total: " + users.size())); totalTable.addCell(totalCell); while (usI.hasNext()) { User u = usI.next(); String name = u.getFirstname() + " " + u.getMiddlename() + " " + u.getLastname(); String reserve = "Nej"; if (u.isReserve()) { reserve = "Ja"; } String admin = "Nej"; if (u.isAdministrator()) { admin = "Ja"; } PdfPCell nameC = new PdfPCell(new Phrase(name)); PdfPCell usernameC = new PdfPCell(new Phrase(u.getUsername())); PdfPCell creationC = new PdfPCell(new Phrase(u.getCreationDate())); PdfPCell reserveC = new PdfPCell(new Phrase(reserve)); PdfPCell adminC = new PdfPCell(new Phrase(admin)); table.addCell(nameC); table.addCell(usernameC); table.addCell(creationC); table.addCell(reserveC); table.addCell(adminC); } doc.add(new Phrase("Brugere")); doc.add(table); doc.add(totalTable); doc.close(); }
From source file:control.ReportHandler.java
public void writeTotalQuarantineReport() throws DocumentException, FileNotFoundException { Document doc = new Document(PageSize.A4.rotate()); Calendar c = Calendar.getInstance(); String file = "" + c.get(Calendar.DAY_OF_MONTH) + "_" + (c.get(Calendar.MONTH) + 1) + "_" + c.get(Calendar.YEAR) + "_T_" + c.get(Calendar.HOUR_OF_DAY) + "_" + c.get(Calendar.MINUTE) + ".pdf"; PdfWriter.getInstance(doc, new FileOutputStream(new File(his.His.reportQuarantinesDir + "/" + file))); doc.open();/*from w w w . j a v a2 s .com*/ PdfPTable table = new PdfPTable(2); PdfPTable totalTable = new PdfPTable(1); PdfPCell colName = new PdfPCell(new Phrase("Navn", columnFont)); colName.setBackgroundColor(BaseColor.BLACK); PdfPCell colBirth = new PdfPCell(new Phrase("Fdselsdag", columnFont)); colBirth.setBackgroundColor(BaseColor.BLACK); table.addCell(colName); table.addCell(colBirth); ; HashSet<Quarantine> quarantines = quR.getQuarantines(); Iterator<Quarantine> quI = quarantines.iterator(); PdfPCell totalCell = new PdfPCell(new Phrase("Total: " + quarantines.size())); totalTable.addCell(totalCell); while (quI.hasNext()) { Quarantine qu = quI.next(); Person p = qu.getPerson(); String name = p.getFirstname() + " " + p.getMiddlename() + " " + p.getLastname(); PdfPCell nameCell = new PdfPCell(new Phrase(name)); PdfPCell birthCell = new PdfPCell(new Phrase(p.getBirthdayDate())); table.addCell(nameCell); table.addCell(birthCell); } doc.add(new Phrase("Karantner")); doc.add(table); doc.add(totalTable); doc.close(); }
From source file:dbms_prj.Display.java
public void create_pdf() throws Exception { Document doc = new Document(); PdfWriter.getInstance(doc, new FileOutputStream(S1 + ".pdf")); Image image = Image.getInstance("src/Travel partners.png"); image.scaleAbsolute(500f, 200f);/*from www. ja v a 2 s . c o m*/ Image ima = Image.getInstance("src/images.jpg"); ima.scaleAbsolute(100f, 100f); ima.setAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(9); PdfPCell cell = new PdfPCell(new Paragraph("Ticket")); cell.setColspan(9); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(10.0f); cell.setBackgroundColor(new BaseColor(140, 221, 8)); table.addCell(cell); table.addCell("PNR"); table.addCell("BOOK_ID"); table.addCell("FLIGHT_NO"); table.addCell("NAME"); table.addCell("SOURCE"); table.addCell("DESTINATION"); table.addCell("STATUS"); table.addCell("FARE"); table.addCell("Date"); table.addCell(S1); table.addCell(S11); table.addCell(S4); table.addCell(S6 + " " + S7); table.addCell(S8); table.addCell(S9); table.addCell(S5); table.addCell(S10); table.addCell(S12); table.setSpacingBefore(30.0f); // Space Before table starts, like margin-top in CSS table.setSpacingAfter(30.0f); doc.open(); //doc.add(new Paragraph("Hello!! Yo this is my first pdf!")); doc.add(image); doc.add(new Paragraph("Ticket created on " + new Date().toString())); doc.add(table); //doc.add(list); doc.add(ima); doc.close(); }
From source file:dbms_prj.Status.java
public void create_pdf() throws Exception { Document doc = new Document(); PdfWriter.getInstance(doc, new FileOutputStream(S1 + ".pdf")); Image image = Image.getInstance("src/Travel partners.png"); image.scaleAbsolute(500f, 200f);// w w w .j a v a2s .c o m Image ima = Image.getInstance("src/images.jpg"); ima.scaleAbsolute(100f, 100f); ima.setAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(9); PdfPCell cell = new PdfPCell(new Paragraph("Ticket")); cell.setColspan(9); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(10.0f); table.setTotalWidth(300.0f); cell.setBackgroundColor(new BaseColor(140, 221, 8)); table.addCell(cell); table.addCell("PNR"); table.addCell("BOOK_ID"); table.addCell("FLIGHT_NO"); table.addCell("NAME"); table.addCell("SOURCE"); table.addCell("DESTINATION"); table.addCell("STATUS"); table.addCell("FARE"); table.addCell("Date"); table.addCell(S1); table.addCell(S11); table.addCell(S4); table.addCell(S6 + S7); table.addCell(S8); table.addCell(S9); table.addCell(S5); table.addCell(S10); table.addCell(S2); table.setSpacingBefore(50.0f); // Space Before table starts, like margin-top in CSS table.setSpacingAfter(50.0f); doc.open(); //doc.add(new Paragraph("Hello!! Yo this is my first pdf!")); doc.add(image); //doc.add(new Paragraph("Ticket created on " + new Date().toString())); doc.add(table); //doc.add(list); doc.add(ima); doc.close(); }
From source file:de.aidger.utils.pdf.BudgetReportConverter.java
License:Open Source License
/** * Adds a row, containing a course budget, to the table. * //w ww. j a v a 2 s . c o m * @param objectArray * The course budget. * @return The table containing the row. */ private PdfPTable addRow(Object[] objectArray) { try { Font tableContentFont = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 9); PdfPTable tableContent = new PdfPTable(new float[] { 0.3f, 0.15f, 0.15f, 0.15f, 0.15f, 0.10f }); Color cellColor = new Color(255, 255, 255); if (Double.parseDouble(objectArray[4].toString()) == 0) { cellColor = new Color(252, 200, 150); } for (int i = 0; i < objectArray.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(objectArray[i].toString(), tableContentFont)); cell.setBackgroundColor(new BaseColor(cellColor)); cell.setPaddingBottom(5); tableContent.addCell(cell); } return tableContent; } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }