List of usage examples for com.lowagie.text Font NORMAL
int NORMAL
To view the source code for com.lowagie.text Font NORMAL.
Click Source Link
From source file:org.oscarehr.common.service.PdfRecordPrinter.java
License:Open Source License
public void printRx(String demoNo, List<CaseManagementNote> cpp) throws DocumentException { if (demoNo == null) return;/*w w w. j ava 2 s . c o m*/ /* if( newPage ) document.newPage(); else newPage = true; */ oscar.oscarRx.data.RxPrescriptionData prescriptData = new oscar.oscarRx.data.RxPrescriptionData(); oscar.oscarRx.data.RxPrescriptionData.Prescription[] arr = {}; arr = prescriptData.getUniquePrescriptionsByPatient(Integer.parseInt(demoNo)); if (arr.length == 0) { return; } Paragraph p = new Paragraph(); Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE); Phrase phrase = new Phrase(LEADING, "", obsfont); p.setAlignment(Paragraph.ALIGN_LEFT); phrase.add("Prescriptions"); p.add(phrase); document.add(p); Font normal = new Font(bf, FONTSIZE, Font.NORMAL); Font curFont; for (int idx = 0; idx < arr.length; ++idx) { oscar.oscarRx.data.RxPrescriptionData.Prescription drug = arr[idx]; p = new Paragraph(); p.setAlignment(Paragraph.ALIGN_LEFT); if (drug.isCurrent() && !drug.isArchived()) { curFont = normal; phrase = new Phrase(LEADING, "", curFont); phrase.add(formatter.format(drug.getRxDate()) + " - "); phrase.add(drug.getFullOutLine().replaceAll(";", " ")); p.add(phrase); document.add(p); } } if (cpp != null) { List<CaseManagementNote> notes = cpp; if (notes != null && notes.size() > 0) { p = new Paragraph(); p.setAlignment(Paragraph.ALIGN_LEFT); phrase = new Phrase(LEADING, "\nOther Meds\n", obsfont); //TODO:Needs to be i18n p.add(phrase); document.add(p); newPage = false; this.printNotes(notes); } } }
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 w w w . j av a2s. 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 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 w ww . j a va 2s . com 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.primefaces.component.export.PDFExporter.java
License:Open Source License
protected void applyFacetOptions(ExporterOptions options) { String facetBackground = options.getFacetBgColor(); if (facetBackground != null) { facetBgColor = Color.decode(facetBackground); }// w w w .j a v a2s .c o m String facetFontColor = options.getFacetFontColor(); if (facetFontColor != null) { facetFont.setColor(Color.decode(facetFontColor)); } String facetFontSize = options.getFacetFontSize(); if (facetFontSize != null) { facetFont.setSize(Integer.valueOf(facetFontSize)); } String facetFontStyle = options.getFacetFontStyle(); if (facetFontStyle != null) { if (facetFontStyle.equalsIgnoreCase("NORMAL")) { facetFontStyle = "" + Font.NORMAL; } if (facetFontStyle.equalsIgnoreCase("BOLD")) { facetFontStyle = "" + Font.BOLD; } if (facetFontStyle.equalsIgnoreCase("ITALIC")) { facetFontStyle = "" + Font.ITALIC; } facetFont.setStyle(facetFontStyle); } }
From source file:org.primefaces.component.export.PDFExporter.java
License:Open Source License
protected void applyCellOptions(ExporterOptions options) { String cellFontColor = options.getCellFontColor(); if (cellFontColor != null) { cellFont.setColor(Color.decode(cellFontColor)); }/*from w w w. j a v a 2 s. co m*/ String cellFontSize = options.getCellFontSize(); if (cellFontSize != null) { cellFont.setSize(Integer.valueOf(cellFontSize)); } String cellFontStyle = options.getCellFontStyle(); if (cellFontStyle != null) { if (cellFontStyle.equalsIgnoreCase("NORMAL")) { cellFontStyle = "" + Font.NORMAL; } if (cellFontStyle.equalsIgnoreCase("BOLD")) { cellFontStyle = "" + Font.BOLD; } if (cellFontStyle.equalsIgnoreCase("ITALIC")) { cellFontStyle = "" + Font.ITALIC; } cellFont.setStyle(cellFontStyle); } }
From source file:org.primefaces.extensions.showcase.util.PDFCustomExporter.java
License:Apache License
@Override public void customFormat(String facetBackground, String facetFontSize, String facetFontColor, String facetFontStyle, String fontName, String cellFontSize, String cellFontColor, String cellFontStyle, String datasetPadding, String orientation) { this.facetFontSize = new Float(facetFontSize); this.cellFontSize = new Float(cellFontSize); this.datasetPadding = Integer.parseInt(datasetPadding); this.orientation = orientation; if (facetBackground != null) { this.facetBackground = Color.decode(facetBackground); }/*from w ww . jav a 2s. c o m*/ if (facetFontColor != null) { this.facetFontColor = Color.decode(facetFontColor); } if (cellFontColor != null) { this.cellFontColor = Color.decode(cellFontColor); } if (fontName != null) { this.fontName = fontName; } if (facetFontStyle.equalsIgnoreCase("NORMAL")) { this.facetFontStyle = "" + Font.NORMAL; } if (facetFontStyle.equalsIgnoreCase("BOLD")) { this.facetFontStyle = "" + Font.BOLD; } if (facetFontStyle.equalsIgnoreCase("ITALIC")) { this.facetFontStyle = "" + Font.ITALIC; } if (cellFontStyle.equalsIgnoreCase("NORMAL")) { this.cellFontStyle = "" + Font.NORMAL; } if (cellFontStyle.equalsIgnoreCase("BOLD")) { this.cellFontStyle = "" + Font.BOLD; } if (cellFontStyle.equalsIgnoreCase("ITALIC")) { this.cellFontStyle = "" + Font.ITALIC; } }
From source file:org.revager.export.ProtocolPDFExporter.java
License:Open Source License
/** * Write the findings to the protocol.//from www .ja v a 2 s . com * * @param protocol * the protocol * @param attachExtRefs * true if the external references should be part of the protocol * * @throws ExportException * If an error occurs while writing the findings to the protocol */ protected void writeFindings(Protocol protocol, boolean attachExtRefs) throws ExportException { try { /* * Define fonts */ Font plainFontTitle = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 9, Font.NORMAL, Color.WHITE); Font boldFontTitle = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 10, Font.NORMAL, Color.WHITE); Font plainFont = new Font(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 10); Font boldFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 10); Font italicFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_OBLIQUE, BaseFont.CP1252, BaseFont.EMBEDDED), 10); Font boldItalicFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLDOBLIQUE, BaseFont.CP1252, BaseFont.EMBEDDED), 10); /* * Write findings */ PdfPTable tableBase = new PdfPTable(1); tableBase.setWidthPercentage(100); tableBase.setSplitRows(false); tableBase.getDefaultCell().setBorderWidth(0); tableBase.getDefaultCell().setPadding(0); for (Finding f : protocol.getFindings()) { tableBase.addCell(createVerticalStrut(PDFTools.cmToPt(0.7f), 1)); PdfPCell cellFinding = new PdfPCell(); cellFinding.setBorderColor(Color.GRAY); cellFinding.setBorderWidth(0.5f); PdfPTable tableTitle = new PdfPTable(3); tableTitle.setWidthPercentage(100); /* * Print title of the finding */ Phrase phraseTitle = new Phrase(translate("Finding") + " " + f.getId(), boldFontTitle); PdfPCell cellTitle = new PdfPCell(phraseTitle); cellTitle.setBackgroundColor(bgColorTitle); cellTitle.setBorderWidth(0); cellTitle.setPadding(padding); cellTitle.setPaddingBottom(padding * 1.5f); cellTitle.setHorizontalAlignment(Element.ALIGN_LEFT); tableTitle.addCell(cellTitle); /* * Print severity of the finding */ Phrase phraseSeverity = new Phrase(findMgmt.getLocalizedSeverity(f), plainFontTitle); PdfPCell cellSeverity = new PdfPCell(phraseSeverity); cellSeverity.setBackgroundColor(bgColorTitle); cellSeverity.setBorderWidth(0); cellSeverity.setPadding(padding); cellSeverity.setPaddingTop(padding * 1.1f); cellSeverity.setHorizontalAlignment(Element.ALIGN_CENTER); tableTitle.addCell(cellSeverity); /* * Print the meeting date and time of the finding */ String meetingDate = sdfDate.format(protocol.getDate().getTime()); PdfPCell cellMeeting = new PdfPCell(new Phrase(meetingDate, plainFontTitle)); cellMeeting.setBackgroundColor(bgColorTitle); cellMeeting.setBorderWidth(0); cellMeeting.setPadding(padding); cellMeeting.setPaddingTop(padding * 1.1f); cellMeeting.setHorizontalAlignment(Element.ALIGN_RIGHT); tableTitle.addCell(cellMeeting); /* * Description */ Phrase phraseDesc = new Phrase(f.getDescription(), plainFont); phraseDesc.setLeading(leading); PdfPCell cellDesc = new PdfPCell(); cellDesc.addElement(phraseDesc); cellDesc.setBorderWidth(0); cellDesc.setPadding(padding); cellDesc.setColspan(3); tableTitle.addCell(cellDesc); cellFinding.addElement(tableTitle); /* * List point used for lists */ Phrase phraseListPoint = new Phrase("", boldFont); phraseListPoint.setLeading(leading * 0.93f); PdfPCell cellListPoint = new PdfPCell(); cellListPoint.addElement(phraseListPoint); cellListPoint.setBorderWidth(0); cellListPoint.setPadding(padding); cellListPoint.setPaddingLeft(padding * 2); /* * Table of references */ if (f.getReferences().size() > 0 || (f.getExternalReferences().size() > 0 && attachExtRefs == true)) { PdfPTable tableRefs = new PdfPTable(new float[] { 0.04f, 0.96f }); tableRefs.setWidthPercentage(100); PdfPCell cellRefTitle = new PdfPCell(new Phrase(translate("References:"), boldItalicFont)); cellRefTitle.setBorderWidth(0); cellRefTitle.setPadding(padding); cellRefTitle.setPaddingTop(padding * 3); cellRefTitle.setPaddingBottom(0); cellRefTitle.setColspan(2); tableRefs.addCell(cellRefTitle); /* * Textual references */ for (String ref : f.getReferences()) { Phrase phraseRef = new Phrase(ref, plainFont); phraseRef.setLeading(leading); PdfPCell cellRef = new PdfPCell(); cellRef.addElement(phraseRef); cellRef.setBorderWidth(0); cellRef.setPadding(padding); tableRefs.addCell(cellListPoint); tableRefs.addCell(cellRef); } /* * External file references */ if (attachExtRefs == true) { for (File ref : findMgmt.getExtReferences(f)) { Phrase phraseRef = new Phrase(); phraseRef.add(new Chunk(ref.getName(), plainFont)); phraseRef.add(new Chunk(" (" + translate("File Attachment") + ")", italicFont)); phraseRef.setFont(plainFont); phraseRef.setLeading(leading); PdfPCell cellRef = new PdfPCell(); cellRef.addElement(phraseRef); cellRef.setBorderWidth(0); cellRef.setPadding(padding); tableRefs.addCell(cellListPoint); cellRef.setCellEvent(new PDFCellEventExtRef(pdfWriter, ref)); tableRefs.addCell(cellRef); } } cellFinding.addElement(tableRefs); } /* * Table of aspects */ if (f.getAspects().size() > 0) { PdfPTable tableAspects = new PdfPTable(new float[] { 0.04f, 0.96f }); tableAspects.setWidthPercentage(100); PdfPCell cellAspTitle = new PdfPCell(new Phrase(translate("Aspects:"), boldItalicFont)); cellAspTitle.setBorderWidth(0); cellAspTitle.setPadding(padding); cellAspTitle.setPaddingTop(padding * 3); cellAspTitle.setPaddingBottom(0); cellAspTitle.setColspan(2); tableAspects.addCell(cellAspTitle); for (String asp : f.getAspects()) { Phrase phraseAsp = new Phrase(asp, plainFont); phraseAsp.setLeading(leading); PdfPCell cellAsp = new PdfPCell(); cellAsp.addElement(phraseAsp); cellAsp.setBorderWidth(0); cellAsp.setPadding(padding); tableAspects.addCell(cellListPoint); tableAspects.addCell(cellAsp); } cellFinding.addElement(tableAspects); } /* * Vertical strut at the end of the table */ PdfPTable tableStrut = new PdfPTable(1); tableStrut.setWidthPercentage(100); tableStrut.addCell(createVerticalStrut(padding, 1)); cellFinding.addElement(tableStrut); tableBase.addCell(cellFinding); } pdfDoc.add(tableBase); } catch (Exception e) { /* * Not part of unit testing because this exception is only thrown if * an internal error occurs. */ throw new ExportException(translate("Cannot put findings into the PDF document.")); } }
From source file:org.sakaiproject.evaluation.tool.reporting.EvalPDFReportBuilder.java
License:Educational Community License
public EvalPDFReportBuilder(OutputStream outputStream) { document = new Document(); try {//from w w w .jav a 2 s . c o m pdfWriter = PdfWriter.getInstance(document, outputStream); pdfWriter.setStrictImageSequence(true); document.open(); // attempting to handle i18n chars better // BaseFont evalBF = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.IDENTITY_H, // BaseFont.EMBEDDED); // paragraphFont = new Font(evalBF, 9, Font.NORMAL); // paragraphFont = new Font(Font.TIMES_ROMAN, 9, Font.NORMAL); titleTextFont = new Font(Font.TIMES_ROMAN, 22, Font.BOLD); boldTextFont = new Font(Font.TIMES_ROMAN, 10, Font.BOLD); questionTextFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.BOLD); paragraphFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.NORMAL); paragraphFontBold = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD); frontTitleFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, frontTitleSize, Font.NORMAL); frontAuthorFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 18, Font.NORMAL); frontInfoFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.NORMAL); } catch (Exception e) { throw UniversalRuntimeException.accumulate(e, "Unable to start PDF Report"); } }
From source file:org.sigmah.server.report.renderer.itext.ThemeHelper.java
License:Open Source License
public static Paragraph reportTitle(String title) { Paragraph para = new Paragraph(title); para.setFont(new Font(Font.TIMES_ROMAN, 26, Font.NORMAL, new Color(23, 54, 93))); para.setSpacingAfter(15);/*from ww w . ja v a 2 s. c om*/ return para; }
From source file:org.sigmah.server.report.renderer.itext.ThemeHelper.java
License:Open Source License
public static Paragraph filterDescription(String text) { Paragraph para = new Paragraph(text); para.setFont(new Font(Font.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 0))); return para;/* w w w .j av a2s.c om*/ }