List of usage examples for com.lowagie.text Font BOLD
int BOLD
To view the source code for com.lowagie.text Font BOLD.
Click Source Link
From source file:org.lucee.extension.pdf.tag.PDF.java
License:Open Source License
private Font toFont(Struct sct) throws PageException { Cast caster = engine.getCastUtil();/*from w ww. j a v a 2s.c o m*/ Font f = getDefaultFont(); // size float size = caster.toFloatValue(sct.get("size", null), 0); if (size > 0) f.setSize(size); // family Set fonts = FontFactory.getRegisteredFonts(); String family = caster.toString(sct.get("family", null), null); if (!Util.isEmpty(family)) { String lc = family.toLowerCase(); if (!fonts.contains(lc)) { StringBuilder sb = new StringBuilder(); Iterator it = fonts.iterator(); while (it.hasNext()) { if (sb.length() > 0) sb.append(", "); sb.append(it.next()); } throw engine.getExceptionUtil().createApplicationException( "font family [" + family + "] is not available, available font families are [" + sb + "]"); } f.setFamily(lc); } int style = 0; // bold boolean bold = caster.toBooleanValue(sct.get("bold", null), false); if (bold) style |= Font.BOLD; // italic boolean italic = caster.toBooleanValue(sct.get("italic", null), false); if (italic) style |= Font.ITALIC; // underline boolean underline = caster.toBooleanValue(sct.get("underline", null), false); if (underline) style |= Font.UNDERLINE; // strike boolean strike = caster.toBooleanValue(sct.get("strike", null), false); if (strike) style |= Font.STRIKETHRU; if (style != 0) f.setStyle(style); return f; }
From source file:org.mapfish.print.PDFUtils.java
License:Open Source License
public static BaseFont getBaseFont(String fontFamily, String fontSize, String fontWeight) { int myFontValue; float myFontSize; int myFontWeight; if (fontFamily.toUpperCase().contains("COURIER")) { myFontValue = Font.COURIER; } else if (fontFamily.toUpperCase().contains("HELVETICA")) { myFontValue = Font.HELVETICA; } else if (fontFamily.toUpperCase().contains("ROMAN")) { myFontValue = Font.TIMES_ROMAN; } else {//from w ww .j a va 2s. co m myFontValue = Font.HELVETICA; } myFontSize = (float) Double.parseDouble(fontSize.toLowerCase().replaceAll("px", "")); if (fontWeight.toUpperCase().contains("NORMAL")) { myFontWeight = Font.NORMAL; } else if (fontWeight.toUpperCase().contains("BOLD")) { myFontWeight = Font.BOLD; } else if (fontWeight.toUpperCase().contains("ITALIC")) { myFontWeight = Font.ITALIC; } else { myFontWeight = Font.NORMAL; } Font pdfFont = new Font(myFontValue, myFontSize, myFontWeight); BaseFont bf = pdfFont.getCalculatedBaseFont(false); return bf; }
From source file:org.nuxeo.dam.pdf.export.PDFCreator.java
License:Open Source License
public boolean createPDF(String title, OutputStream out) throws ClientException { try {/*ww w . j av a 2 s. c o m*/ Document document = new Document(); PdfWriter.getInstance(document, out); document.addTitle(title); document.addAuthor(Functions.principalFullName(currentUser)); document.addCreator(Functions.principalFullName(currentUser)); document.open(); document.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n")); Font titleFont = new Font(Font.HELVETICA, 36, Font.BOLD); Paragraph titleParagraph = new Paragraph(title, titleFont); titleParagraph.setAlignment(Element.ALIGN_CENTER); document.add(titleParagraph); Font authorFont = new Font(Font.HELVETICA, 20); Paragraph authorParagraph = new Paragraph("By " + Functions.principalFullName(currentUser), authorFont); authorParagraph.setAlignment(Element.ALIGN_CENTER); document.add(authorParagraph); document.newPage(); boolean foundOnePicture = false; for (DocumentModel doc : docs) { if (!doc.hasSchema(PICTURE_SCHEMA)) { continue; } foundOnePicture = true; PictureResourceAdapter picture = doc.getAdapter(PictureResourceAdapter.class); Blob blob = picture.getPictureFromTitle(ORIGINAL_JPEG_VIEW); Rectangle pageSize = document.getPageSize(); if (blob != null) { Paragraph imageTitle = new Paragraph(doc.getTitle(), font); imageTitle.setAlignment(Paragraph.ALIGN_CENTER); document.add(imageTitle); Image image = Image.getInstance(blob.getByteArray()); image.scaleToFit(pageSize.getWidth() - 20, pageSize.getHeight() - 100); image.setAlignment(Image.MIDDLE); Paragraph imageParagraph = new Paragraph(); imageParagraph.add(image); imageParagraph.setAlignment(Paragraph.ALIGN_MIDDLE); document.add(imageParagraph); document.newPage(); } } if (foundOnePicture) { document.close(); return true; } } catch (Exception e) { throw ClientException.wrap(e); } return false; }
From source file:org.opensixen.swing.OCellRenderer.java
License:GNU General Public License
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { // TODO Auto-generated method stub Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); // Setup Background Color //component.setOpaque(true); int r = row % 2; if (r == 0) { component.setBackground(colorA); } else {//w w w . j av a2 s . co m component.setBackground(colorB); } TableModel tableModel = table.getModel(); if (tableModel instanceof POTableModel) { POTableModel potm = (POTableModel) tableModel; // If group variable, set bold if (potm.isGroupVariableRow(row)) { component.setFont(component.getFont().deriveFont(Font.BOLD)); } } return component; }
From source file:org.openswing.swing.export.java.ExportToPDFCallbacks14Impl.java
License:Open Source License
/** * @param attributeName attribute name that identify column header * @return Font to set for the specified column header *//* w w w.ja v a 2s. c om*/ public Object getHeaderFont(String attributeName) { return new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLD); }
From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java
License:Open Source License
public OscarChartPrinter(HttpServletRequest request, OutputStream os) throws DocumentException, IOException { this.request = request; this.os = os; document = new Document(); writer = PdfWriter.getInstance(document, os); writer.setPageEvent(new EndPage()); document.setPageSize(PageSize.LETTER); document.open();//from ww w.j a v a 2 s . com //Create the font we are going to print to bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); font = new Font(bf, FONTSIZE, Font.NORMAL); boldFont = new Font(bf, FONTSIZE, Font.BOLD); }
From source file:org.oscarehr.common.service.PdfRecordPrinter.java
License:Open Source License
public PdfRecordPrinter(HttpServletRequest request, OutputStream os) throws DocumentException, IOException { this.request = request; this.os = os; formatter = new SimpleDateFormat("dd-MMM-yyyy"); //Create the font we are going to print to bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); font = new Font(bf, FONTSIZE, Font.NORMAL); boldFont = new Font(bf, FONTSIZE, Font.BOLD); //Create the document we are going to write to document = new Document(); writer = PdfWriter.getInstance(document, os); writer.setPageEvent(new EndPage()); writer.setStrictImageSequence(true); document.setPageSize(PageSize.LETTER); /*// w ww . ja v a 2 s . c om HeaderFooter footer = new HeaderFooter(new Phrase("-",font),new Phrase("-",font)); footer.setAlignment(HeaderFooter.ALIGN_CENTER); footer.setBorder(0); document.setFooter(footer); */ document.open(); }
From source file:org.oscarehr.phr.web.PHRUserManagementAction.java
License:Open Source License
public ByteArrayOutputStream generateUserRegistrationLetter(String demographicNo, String username, String password) throws Exception { log.debug("Demographic " + demographicNo + " username " + username + " password " + password); DemographicDao demographicDao = (DemographicDao) SpringUtils.getBean("demographicDao"); Demographic demographic = demographicDao.getDemographic(demographicNo); final String PAGESIZE = "printPageSize"; Document document = new Document(); ByteArrayOutputStream baosPDF = new ByteArrayOutputStream(); PdfWriter writer = null;//from ww w . j a va 2 s . c o m try { writer = PdfWriter.getInstance(document, baosPDF); String title = "TITLE"; String template = "MyOscarLetterHead.pdf"; Properties printCfg = getCfgProp(); String[] cfgVal = null; StringBuilder tempName = null; // get the print prop values Properties props = new Properties(); props.setProperty("letterDate", UtilDateUtilities.getToday("yyyy-MM-dd")); props.setProperty("name", demographic.getFirstName() + " " + demographic.getLastName()); props.setProperty("dearname", demographic.getFirstName() + " " + demographic.getLastName()); props.setProperty("address", demographic.getAddress()); props.setProperty("city", demographic.getCity() + ", " + demographic.getProvince()); props.setProperty("postalCode", demographic.getPostal()); props.setProperty("credHeading", "MyOscar User Account Details"); props.setProperty("username", "Username: " + username); props.setProperty("password", "Password: " + password); //Temporary - the intro will change to be dynamic props.setProperty("intro", "We are pleased to provide you with a log in and password for your new MyOSCAR Personal Health Record. This account will allow you to connect electronically with our clinic. Please take a few minutes to review the accompanying literature for further information.We look forward to you benefiting from this service."); document.addTitle(title); document.addSubject(""); document.addKeywords("pdf, itext"); document.addCreator("OSCAR"); document.addAuthor(""); document.addHeader("Expires", "0"); Rectangle pageSize = PageSize.LETTER; document.setPageSize(pageSize); document.open(); // create a reader for a certain document String propFilename = oscar.OscarProperties.getInstance().getProperty("pdfFORMDIR", "") + "/" + template; PdfReader reader = null; try { reader = new PdfReader(propFilename); log.debug("Found template at " + propFilename); } catch (Exception dex) { log.debug("change path to inside oscar from :" + propFilename); reader = new PdfReader("/oscar/form/prop/" + template); log.debug("Found template at /oscar/form/prop/" + template); } // retrieve the total number of pages int n = reader.getNumberOfPages(); // retrieve the size of the first page Rectangle pSize = reader.getPageSize(1); float width = pSize.getWidth(); float height = pSize.getHeight(); log.debug("Width :" + width + " Height: " + height); PdfContentByte cb = writer.getDirectContent(); ColumnText ct = new ColumnText(cb); int fontFlags = 0; document.newPage(); PdfImportedPage page1 = writer.getImportedPage(reader, 1); cb.addTemplate(page1, 1, 0, 0, 1, 0, 0); BaseFont bf; // = normFont; String encoding; cb.setRGBColorStroke(0, 0, 255); String[] fontType; for (Enumeration e = printCfg.propertyNames(); e.hasMoreElements();) { tempName = new StringBuilder(e.nextElement().toString()); cfgVal = printCfg.getProperty(tempName.toString()).split(" *, *"); if (cfgVal[4].indexOf(";") > -1) { fontType = cfgVal[4].split(";"); if (fontType[1].trim().equals("italic")) fontFlags = Font.ITALIC; else if (fontType[1].trim().equals("bold")) fontFlags = Font.BOLD; else if (fontType[1].trim().equals("bolditalic")) fontFlags = Font.BOLDITALIC; else fontFlags = Font.NORMAL; } else { fontFlags = Font.NORMAL; fontType = new String[] { cfgVal[4].trim() }; } if (fontType[0].trim().equals("BaseFont.HELVETICA")) { fontType[0] = BaseFont.HELVETICA; encoding = BaseFont.CP1252; //latin1 encoding } else if (fontType[0].trim().equals("BaseFont.HELVETICA_OBLIQUE")) { fontType[0] = BaseFont.HELVETICA_OBLIQUE; encoding = BaseFont.CP1252; } else if (fontType[0].trim().equals("BaseFont.ZAPFDINGBATS")) { fontType[0] = BaseFont.ZAPFDINGBATS; encoding = BaseFont.ZAPFDINGBATS; } else { fontType[0] = BaseFont.COURIER; encoding = BaseFont.CP1252; } bf = BaseFont.createFont(fontType[0], encoding, BaseFont.NOT_EMBEDDED); // write in a rectangle area if (cfgVal.length >= 9) { Font font = new Font(bf, Integer.parseInt(cfgVal[5].trim()), fontFlags); ct.setSimpleColumn(Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), Integer.parseInt(cfgVal[7].trim()), (height - Integer.parseInt(cfgVal[8].trim())), Integer.parseInt(cfgVal[9].trim()), (cfgVal[0].trim().equals("left") ? Element.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? Element.ALIGN_RIGHT : Element.ALIGN_CENTER))); ct.setText(new Phrase(12, props.getProperty(tempName.toString(), ""), font)); ct.go(); continue; } // draw line directly if (tempName.toString().startsWith("__$line")) { cb.setRGBColorStrokeF(0f, 0f, 0f); cb.setLineWidth(Float.parseFloat(cfgVal[4].trim())); cb.moveTo(Float.parseFloat(cfgVal[0].trim()), Float.parseFloat(cfgVal[1].trim())); cb.lineTo(Float.parseFloat(cfgVal[2].trim()), Float.parseFloat(cfgVal[3].trim())); // stroke the lines cb.stroke(); // write text directly } else if (tempName.toString().startsWith("__")) { cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), (cfgVal.length >= 7 ? (cfgVal[6].trim()) : props.getProperty(tempName.toString(), "")), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } else if (tempName.toString().equals("forms_promotext")) { if (OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT") != null) { cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT"), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } } else { // write prop text cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), (cfgVal.length >= 7 ? ((props.getProperty(tempName.toString(), "").equals("") ? "" : cfgVal[6].trim())) : props.getProperty(tempName.toString(), "")), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } } } catch (DocumentException dex) { baosPDF.reset(); throw dex; } finally { if (document != null) document.close(); if (writer != null) writer.close(); } return baosPDF; }
From source file:org.oscarehr.web.reports.ocan.NeedRatingOverTimeReportGenerator.java
License:Open Source License
private void addSummaryOfNeedsHeader(PdfPTable summaryOfNeedsTable, List<OcanNeedRatingOverTimeSummaryOfNeedsBean> currentBeanList, int loopNo) { PdfPCell headerCell = new PdfPCell(); headerCell.setPhrase(new Phrase("Summary of Needs" + (loopNo > 1 ? " (Contd.)" : ""), new Font(Font.HELVETICA, 20, Font.BOLD))); headerCell.setColspan(currentBeanList.size() * 3); headerCell.setVerticalAlignment(Element.ALIGN_TOP); headerCell.setBorder(0);//from ww w . j av a 2s . c om headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(headerCell); Font f = new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE); //row1 PdfPCell c2 = null; c2 = new PdfPCell(); c2.setBorder(0); summaryOfNeedsTable.addCell(c2); if (currentBeanList.size() > 0) { c2 = new PdfPCell(); c2.setColspan(2); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase(currentBeanList.get(0).getOcanName() + "\n" + dateFormatter.format(currentBeanList.get(0).getOcanDate()), f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 1) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setColspan(2); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase(currentBeanList.get(1).getOcanName() + "\n" + dateFormatter.format(currentBeanList.get(1).getOcanDate()), f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 2) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setColspan(2); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase(currentBeanList.get(2).getOcanName() + "\n" + dateFormatter.format(currentBeanList.get(2).getOcanDate()), f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } //row2 c2 = new PdfPCell(); c2.setBorder(0); summaryOfNeedsTable.addCell(c2); if (currentBeanList.size() > 0) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Consumer", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Staff", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 1) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Consumer", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Staff", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 2) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Consumer", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Staff", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } }
From source file:org.oscarehr.web.reports.ocan.NeedRatingOverTimeReportGenerator.java
License:Open Source License
private void addSummaryOfNeedsDomainHeader(PdfPTable summaryOfNeedsTable, List<OcanNeedRatingOverTimeNeedBreakdownBean> currentBeanList, int loopNo) { Font f = new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE); //row1//from ww w. jav a 2s . c om PdfPCell c2 = null; c2 = new PdfPCell(); c2.setBorder(0); summaryOfNeedsTable.addCell(c2); if (loopNo > 1) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 0) { c2 = new PdfPCell(); c2.setColspan(2); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase(currentBeanList.get(0).getOcanName() + "\n" + dateFormatter.format(currentBeanList.get(0).getOcanDate()), f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 1) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setColspan(2); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase(currentBeanList.get(1).getOcanName() + "\n" + dateFormatter.format(currentBeanList.get(1).getOcanDate()), f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 2) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setColspan(2); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase(currentBeanList.get(2).getOcanName() + "\n" + dateFormatter.format(currentBeanList.get(2).getOcanDate()), f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } //row2 c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Domains", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); if (loopNo > 1) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 0) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Consumer", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Staff", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 1) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Consumer", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Staff", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 2) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Consumer", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase("Staff", f)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } }