List of usage examples for com.lowagie.text Font Font
public Font(BaseFont bf, float size, int style, Color color)
From source file:org.activityinfo.server.report.renderer.itext.ThemeHelper.java
License:Open Source License
private static Font bodyFont() { return new Font(Font.HELVETICA, BODY_FONT_SIZE, Font.NORMAL, Color.BLACK); }
From source file:org.apache.maven.doxia.module.itext.ITextFont.java
License:Apache License
/** * Convenience method to get a defined MonoSpaced font depending the wanted style and size. * * @param style the font style./*from w ww .j a v a 2s.c o m*/ * @param size the font size. * @param color the font color. * @return a font the font. */ public static Font getMonoSpacedFont(int style, float size, Color color) { try { return new Font(BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, false), size, style, color); } catch (Exception e) { throw new ExceptionConverter(e); } }
From source file:org.areasy.common.doclet.document.Fonts.java
License:Open Source License
public static Font getFont(int faceType, int style, int size) { Font font = null;/*from w ww . j a va2s.c om*/ String lookup = String.valueOf(faceType); String fontFile = fontTable.getProperty(lookup); int fontStyle = Font.NORMAL; Color color = COLOR_BLACK; if ((style & LINK) != 0) { fontStyle += Font.UNDERLINE; color = COLOR_LINK; } else if ((style & UNDERLINE) != 0) fontStyle += Font.UNDERLINE; if ((style & STRIKETHROUGH) != 0) fontStyle += Font.STRIKETHRU; if (fontFile != null) { File file = new File(DefaultConfiguration.getWorkDir(), fontFile); if (file.exists() && file.isFile()) { try { String encoding = encTable.getProperty(lookup, BaseFont.CP1252); BaseFont bfComic = BaseFont.createFont(file.getAbsolutePath(), encoding, BaseFont.EMBEDDED); if ((style & AbstractConfiguration.ITALIC) > 0) { if ((style & AbstractConfiguration.BOLD) > 0) fontStyle += Font.BOLDITALIC; else fontStyle += Font.ITALIC; } else if ((style & AbstractConfiguration.BOLD) > 0) fontStyle += Font.BOLD; if (fontStyle != Font.NORMAL) font = new Font(bfComic, size, fontStyle, color); else font = new Font(bfComic, size); if (font == null) throw new IllegalArgumentException("Font null: " + fontFile); } catch (Exception e) { e.printStackTrace(); throw new IllegalArgumentException("Font unusable"); } } else DocletUtility.error("Font file not found: " + fontFile); } else { // Use predefined font String face = ""; if (faceType == TEXT_FONT) { face = FontFactory.HELVETICA; if ((style & AbstractConfiguration.ITALIC) > 0) { if ((style & AbstractConfiguration.BOLD) > 0) face = FontFactory.HELVETICA_BOLDOBLIQUE; else face = FontFactory.HELVETICA_OBLIQUE; } else if ((style & AbstractConfiguration.BOLD) > 0) face = FontFactory.HELVETICA_BOLD; } else { face = FontFactory.COURIER; if ((style & ITALIC) > 0) { if ((style & BOLD) > 0) face = FontFactory.COURIER_BOLDOBLIQUE; else face = FontFactory.COURIER_OBLIQUE; } else if ((style & BOLD) > 0) face = FontFactory.COURIER_BOLD; } if (fontStyle != Font.NORMAL) font = FontFactory.getFont(face, size, fontStyle, color); else font = FontFactory.getFont(face, size); } return font; }
From source file:org.cocktail.superplan.server.gestionimpression.TabularEdtReport.java
License:CeCILL license
public NSData genererPdf(NSArray creneaux, NSTimestamp debutSemaine, String semaine, String libelleFormation) throws DocumentException { ByteArrayOutputStream os = new ByteArrayOutputStream(); Document document = new Document(); PdfWriter.getInstance(document, os); document.open();/*from w ww . j a v a2 s. c om*/ document.setMargins(0, 0, 0, 0); Font font = new Font(Font.TIMES_ROMAN, 12, Font.BOLD, Color.DARK_GRAY); PdfPTable headerTable = new PdfPTable(1); PdfPCell cell = new PdfPCell(); Phrase ph = new Phrase(); ph.add(new Chunk(libelleFormation, font)); cell.setPhrase(ph); cell.setHorizontalAlignment(Element.ALIGN_CENTER); headerTable.addCell(cell); font = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, Color.DARK_GRAY); cell = new PdfPCell(); ph = new Phrase(); ph.add(new Chunk(semaine, font)); cell.setPhrase(ph); cell.setHorizontalAlignment(Element.ALIGN_CENTER); headerTable.addCell(cell); headerTable.setWidthPercentage(100); headerTable.setSpacingAfter(5.0f); document.add(headerTable); PdfPTable pdfTable = creerCreneauxTable(creneaux, debutSemaine); pdfTable.setWidthPercentage(100); document.add(pdfTable); document.close(); return new NSData(os.toByteArray()); }
From source file:org.egov.works.utils.AbstractPDFGenerator.java
License:Open Source License
protected Font getUnderlinedFont() { return new Font(Font.UNDEFINED, Font.UNDEFINED, Font.UNDERLINE, null); }
From source file:org.jmesa.view.pdfp.PdfPView.java
License:Apache License
private Font getFontWithColor(Color color) { String fontName = getCoreContext().getPreference(PDF_FONT_NAME); String fontEncoding = getCoreContext().getPreference(PDF_FONT_ENCODING); if (isNotBlank(fontName) && isNotBlank(fontEncoding)) { try {/* w w w . j a va 2 s . c o m*/ BaseFont baseFont = createFont(fontName, fontEncoding, NOT_EMBEDDED); if (color != null) { return new Font(baseFont, 12, 0, color); } return new Font(baseFont, 12, 0); } catch (Exception e) { logger.warn("Not able to create the requested font for the PDF export...will use the export."); } } if (color != null) { return getFont(HELVETICA, 12, NORMAL, color); } return getFont(HELVETICA, 12, NORMAL); }
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 www . j a va 2 s .c o m 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); } }
From source file:org.oscarehr.web.reports.ocan.NeedRatingOverTimeReportGenerator.java
License:Open Source License
private void addSummaryOfNeedsRow(PdfPTable summaryOfNeedsTable, String needType, String needTypeKey, List<OcanNeedRatingOverTimeSummaryOfNeedsBean> currentBeanList) { //row3//from ww w .j a va 2s .c om PdfPCell c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase(needType, new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE))); summaryOfNeedsTable.addCell(c2); if (currentBeanList.size() > 0) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.GREEN); c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(0).getConsumerNeedMap().get(needTypeKey)), new Font(Font.HELVETICA, 14, Font.BOLD))); c2.setHorizontalAlignment(Element.ALIGN_RIGHT); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.LIGHT_GRAY); c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(0).getStaffNeedMap().get(needTypeKey)), new Font(Font.HELVETICA, 14, Font.BOLD))); c2.setHorizontalAlignment(Element.ALIGN_RIGHT); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 1) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.GREEN); c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(1).getConsumerNeedMap().get(needTypeKey)), new Font(Font.HELVETICA, 14, Font.BOLD))); c2.setHorizontalAlignment(Element.ALIGN_RIGHT); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.LIGHT_GRAY); c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(1).getStaffNeedMap().get(needTypeKey)), new Font(Font.HELVETICA, 14, Font.BOLD))); c2.setHorizontalAlignment(Element.ALIGN_RIGHT); summaryOfNeedsTable.addCell(c2); } if (currentBeanList.size() > 2) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.GREEN); c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(2).getConsumerNeedMap().get(needTypeKey)), new Font(Font.HELVETICA, 14, Font.BOLD))); c2.setHorizontalAlignment(Element.ALIGN_RIGHT); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.LIGHT_GRAY); c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(2).getStaffNeedMap().get(needTypeKey)), new Font(Font.HELVETICA, 14, Font.BOLD))); c2.setHorizontalAlignment(Element.ALIGN_RIGHT); summaryOfNeedsTable.addCell(c2); } }
From source file:org.oscarehr.web.reports.ocan.NeedRatingOverTimeReportGenerator.java
License:Open Source License
private void addSummaryOfNeedsDomainRow(PdfPTable summaryOfNeedsTable, int rowNum, List<String> domains, List<OcanNeedRatingOverTimeNeedBreakdownBean> ocans, OcanNeedRatingOverTimeNeedBreakdownBean lastBreakDownBean) { PdfPCell c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLUE); c2.setPhrase(new Phrase(domains.get(rowNum), new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE))); summaryOfNeedsTable.addCell(c2);//from www . ja va2 s . c o m if (lastBreakDownBean != null) { boolean checkmark = false; if (!ocans.get(0).getNeeds().get(rowNum).getConsumerNeed() .equals(lastBreakDownBean.getNeeds().get(rowNum).getConsumerNeed())) { checkmark = true; } if (!ocans.get(0).getNeeds().get(rowNum).getStaffNeed() .equals(lastBreakDownBean.getNeeds().get(rowNum).getStaffNeed())) { checkmark = true; } c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); c2.setHorizontalAlignment(Element.ALIGN_CENTER); if (checkmark) { c2.setPhrase(new Phrase("X", new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE))); } summaryOfNeedsTable.addCell(c2); } if (ocans.size() > 0) { c2 = new PdfPCell(); c2.setBackgroundColor(Color.GREEN); c2.setPhrase(new Phrase(ocans.get(0).getNeeds().get(rowNum).getConsumerNeed(), new Font(Font.HELVETICA, 14, (ocans.get(0).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Font.BOLD : Font.NORMAL), (ocans.get(0).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Color.RED : Color.BLACK)))); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.LIGHT_GRAY); c2.setPhrase(new Phrase(ocans.get(0).getNeeds().get(rowNum).getStaffNeed(), new Font(Font.HELVETICA, 14, (ocans.get(0).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Font.BOLD : Font.NORMAL), (ocans.get(0).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Color.RED : Color.BLACK)))); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } if (ocans.size() > 1) { boolean checkmark = false; if (!ocans.get(1).getNeeds().get(rowNum).getConsumerNeed() .equals((ocans.get(0).getNeeds().get(rowNum).getConsumerNeed()))) { checkmark = true; } if (!ocans.get(1).getNeeds().get(rowNum).getStaffNeed() .equals((ocans.get(0).getNeeds().get(rowNum).getStaffNeed()))) { checkmark = true; } c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); c2.setHorizontalAlignment(Element.ALIGN_CENTER); if (checkmark) { c2.setPhrase(new Phrase("X", new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE))); } summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.GREEN); c2.setPhrase(new Phrase(ocans.get(1).getNeeds().get(rowNum).getConsumerNeed(), new Font(Font.HELVETICA, 14, (ocans.get(1).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Font.BOLD : Font.NORMAL), (ocans.get(1).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Color.RED : Color.BLACK)))); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.LIGHT_GRAY); c2.setPhrase(new Phrase(ocans.get(1).getNeeds().get(rowNum).getStaffNeed(), new Font(Font.HELVETICA, 14, (ocans.get(1).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Font.BOLD : Font.NORMAL), (ocans.get(1).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Color.RED : Color.BLACK)))); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } if (ocans.size() > 2) { boolean checkmark = false; if (!ocans.get(2).getNeeds().get(rowNum).getConsumerNeed() .equals((ocans.get(1).getNeeds().get(rowNum).getConsumerNeed()))) { checkmark = true; } if (!ocans.get(2).getNeeds().get(rowNum).getStaffNeed() .equals((ocans.get(1).getNeeds().get(rowNum).getStaffNeed()))) { checkmark = true; } c2 = new PdfPCell(); c2.setBackgroundColor(Color.BLACK); c2.setHorizontalAlignment(Element.ALIGN_CENTER); if (checkmark) { c2.setPhrase(new Phrase("X", new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE))); } summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.GREEN); c2.setPhrase(new Phrase(ocans.get(2).getNeeds().get(rowNum).getConsumerNeed(), new Font(Font.HELVETICA, 14, (ocans.get(2).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Font.BOLD : Font.NORMAL), (ocans.get(2).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Color.RED : Color.BLACK)))); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); c2 = new PdfPCell(); c2.setBackgroundColor(Color.LIGHT_GRAY); c2.setPhrase(new Phrase(ocans.get(2).getNeeds().get(rowNum).getStaffNeed(), new Font(Font.HELVETICA, 14, (ocans.get(2).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Font.BOLD : Font.NORMAL), (ocans.get(2).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Color.RED : Color.BLACK)))); c2.setHorizontalAlignment(Element.ALIGN_CENTER); summaryOfNeedsTable.addCell(c2); } }
From source file:org.oscarehr.web.reports.ocan.SummaryOfActionsAndCommentsReportGenerator.java
License:Open Source License
private void createOcanEntry(PdfPTable table, SummaryOfActionsAndCommentsOCANBean ocanBean) { Font f = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK); //header// www .j a va 2 s . c o m PdfPCell c1 = new PdfPCell(); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setPhrase(new Phrase("Rating", f)); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(2); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setPhrase(new Phrase(ocanBean.getOcanName() + " - " + dateFormatter.format(ocanBean.getOcanDate()), f)); table.addCell(c1); //actions c1 = new PdfPCell(); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setBorderWidthBottom(0); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(1); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setPhrase(new Phrase("Actions", f)); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(1); c1.setPhrase(new Phrase(ocanBean.getActions(), normalText)); table.addCell(c1); //By Whom c1 = new PdfPCell(); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setBorderWidthBottom(0); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(1); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setPhrase(new Phrase("By Whom", f)); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(1); c1.setPhrase(new Phrase(ocanBean.getByWhom(), normalText)); table.addCell(c1); //review date c1 = new PdfPCell(); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setBorderWidthBottom(0); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(1); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setPhrase(new Phrase("Review Date", f)); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(1); c1.setPhrase(new Phrase(ocanBean.getReviewDate(), normalText)); table.addCell(c1); //consumer c1 = new PdfPCell(); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setPhrase(new Phrase(convertNeedToWord(ocanBean.getConsumerNeedRating()), boldText)); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(1); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setPhrase(new Phrase("Consumer Comments", f)); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(1); c1.setPhrase(new Phrase(includeComments ? ocanBean.getConsumerComments() : "", normalText)); table.addCell(c1); //staff c1 = new PdfPCell(); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setPhrase(new Phrase(convertNeedToWord(ocanBean.getStaffNeedRating()), boldText)); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(1); c1.setBackgroundColor(Color.LIGHT_GRAY); c1.setPhrase(new Phrase("Staff Comments", f)); table.addCell(c1); c1 = new PdfPCell(); c1.setColspan(1); c1.setPhrase(new Phrase(includeComments ? ocanBean.getStaffComments() : "", normalText)); table.addCell(c1); }