List of usage examples for com.lowagie.text Font UNDERLINE
int UNDERLINE
To view the source code for com.lowagie.text Font UNDERLINE.
Click Source Link
From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.CaseStudieSummaryPDF.java
License:Open Source License
/** * This method is used for add the main information table of project summary */// w ww .j a v a2 s. co m private void addMainInformationTable() { String startDate, endDate; if (project.getStartDate() != null) { startDate = new SimpleDateFormat("dd-MM-yyyy").format(project.getStartDate()); } else { startDate = this.messageReturn(null); } if (project.getEndDate() != null) { endDate = new SimpleDateFormat("dd-MM-yyyy").format(project.getEndDate()); } else { endDate = this.messageReturn(null); } Paragraph cellContent; // Add content try { PdfPTable table = new PdfPTable(4); // Set table widths table.setLockedWidth(true); table.setTotalWidth(480); table.setWidths(new int[] { 3, 5, 3, 5 }); // First row cellContent = new Paragraph(this.getText("summaries.project.startDate") + "\n" + " (dd-MM-yyyy)", TABLE_BODY_BOLD_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 0); cellContent = new Paragraph(this.messageReturn(startDate), TABLE_BODY_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 0); cellContent = new Paragraph(this.getText("summaries.project.endDate") + "\n" + " (dd-MM-yyyy)", TABLE_BODY_BOLD_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 0); cellContent = new Paragraph(this.messageReturn(endDate), TABLE_BODY_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 0); // Second row cellContent = new Paragraph(this.getText("summaries.project.managementLiaison"), TABLE_BODY_BOLD_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 1); cellContent = new Paragraph(this.messageReturn(project.getLiaisonInstitution().getAcronym() + " - " + project.getLiaisonInstitution().getName()), TABLE_BODY_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 1); cellContent = new Paragraph(this.getText("summaries.project.contactPerson"), TABLE_BODY_BOLD_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 1); cellContent = new Paragraph(this.messageReturn(project.getOwner().getComposedName()), TABLE_BODY_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 1); // Third row cellContent = new Paragraph(this.getText("summaries.project.leadOrganization"), TABLE_BODY_BOLD_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 0); if (project.getLeader() == null || project.getLeader().getInstitution() == null) { cellContent = new Paragraph(this.getText("summaries.project.empty"), TABLE_BODY_FONT); } else { cellContent = new Paragraph( this.messageReturn( this.messageReturn(project.getLeader().getInstitution().getComposedName())), TABLE_BODY_FONT); } this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 0); cellContent = new Paragraph(this.getText("summaries.project.projectLeader"), TABLE_BODY_BOLD_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 0); if (project.getLeaderPerson() == null || project.getLeaderPerson().getUser() == null) { cellContent = new Paragraph(this.getText("summaries.project.empty"), TABLE_BODY_FONT); } else { cellContent = new Paragraph( this.messageReturn(project.getLeaderPerson().getUser().getComposedName()), TABLE_BODY_FONT); } this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 0); // Fourth row cellContent = (new Paragraph(this.getText("summaries.project.projectType"), TABLE_BODY_BOLD_FONT)); this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 1); cellContent = new Paragraph(this.messageReturn(project.getType().replaceAll("_", " ")), TABLE_BODY_FONT); this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 1); // Fiveth row Chunk imdb = null; Font hyperLink = new Font(FontFactory.getFont("openSans", 10, Color.BLUE)); hyperLink.setStyle(Font.UNDERLINE); // -- Not Bilateral if (!project.isBilateralProject()) { cellContent = (new Paragraph(this.getText("summaries.project.detailed"), TABLE_BODY_BOLD_FONT)); this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 1); if (project.getWorkplanName() != null && !project.getWorkplanName().equals("")) { imdb = new Chunk(project.getWorkplanName(), hyperLink); try { imdb.setAction(new PdfAction(new URL(this.messageReturn(project.getWorkplanURL())))); } catch (MalformedURLException exp) { imdb = new Chunk(project.getWorkplanName(), TABLE_BODY_FONT); LOG.error("There is an Malformed exception in " + project.getWorkplanName()); } } else { imdb = new Chunk(this.getText("summaries.project.empty"), TABLE_BODY_FONT); } } // -- Bilateral else { cellContent = (new Paragraph(this.getText("summaries.project.ipContributions.proposal.space"), TABLE_BODY_BOLD_FONT)); this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 1); if (project.getBilateralContractProposalName() != null && !project.getBilateralContractProposalName().equals("")) { imdb = new Chunk(project.getBilateralContractProposalName(), hyperLink); try { imdb.setAction(new PdfAction(new URL(this.messageReturn(project.getWorkplanURL())))); } catch (MalformedURLException exp) { imdb = new Chunk(project.getBilateralContractProposalName(), TABLE_BODY_FONT); LOG.error("There is an Malformed exception in bilateral contract: " + project.getBilateralContractProposalName()); } } else { imdb = new Chunk(this.getText("summaries.project.empty"), TABLE_BODY_FONT); } } cellContent = new Paragraph(); cellContent.add(imdb); this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 1); document.add(table); document.add(Chunk.NEWLINE); } catch (DocumentException e) { LOG.error( "-- generatePdf() > There was an error adding the table with content for case study summary. ", e); } }
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.egov.works.web.actions.contractorBill.ContractorBillPDFGenerator.java
License:Open Source License
protected PdfPTable createNetPayableTable() { final String resultAmt = getIntDecimalParts(netPayableAmount); final String[] resultAry = resultAmt.split(":"); final PdfPTable createNetPayableData = new PdfPTable(11); createNetPayableData.getDefaultCell().setBorderWidth(1); createNetPayableData.getDefaultCell().setColspan(9); createNetPayableData.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); createNetPayableData.addCell(makePara( pdfLabel.get("contractorbill.pdf.netamount") + ":\t" + getNetPayAmtInWords(), Font.UNDERLINE)); createNetPayableData.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); createNetPayableData.getDefaultCell().setColspan(1); createNetPayableData.addCell(resultAry[0]); createNetPayableData.addCell(resultAry[1]); return createNetPayableData; }
From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerInvoiceWriteoffBatchServiceImpl.java
License:Open Source License
protected void writeInvoiceSectionTitle(com.lowagie.text.Document pdfDoc, String customerNameLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT); paragraph.add(new Chunk(customerNameLine, font)); // blank line paragraph.add(new Chunk("", font)); try {//from w w w. ja v a 2 s.c o m pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerLoadServiceImpl.java
License:Open Source License
protected void writeCustomerSectionTitle(Document pdfDoc, String customerNameLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_LEFT); paragraph.add(new Chunk(customerNameLine, font)); // blank line paragraph.add(new Chunk("", font)); try {//from ww w .ja v a 2s.c o m pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
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();// w w w. j a va 2 s.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.odftoolkit.odfdom.converter.internal.itext.stylable.StylableParagraph.java
License:Open Source License
@SuppressWarnings("unchecked") public Element getElement() { if (!elementPostProcessed) { elementPostProcessed = true;//from www .j ava2 s . c o m // add space if this paragraph is empty // otherwise it's height will be zero boolean empty = true; ArrayList<Chunk> chunks = getChunks(); for (Chunk chunk : chunks) { if (chunk.getImage() == null && chunk.getContent() != null && chunk.getContent().length() > 0) { empty = false; break; } } if (empty) { super.add(new Chunk("\u00A0")); // non breaking space } // adjust line height and baseline if (font != null && font.getBaseFont() != null) { // iText and open office computes proportional line height differently // [iText] line height = coefficient * font size // [open office] line height = coefficient * (font ascender + font descender + font extra margin) // we have to increase paragraph line height to generate pdf similar to open office document // this algorithm may be inaccurate if fonts with different multipliers are used in this paragraph float size = font.getSize(); float ascender = font.getBaseFont().getFontDescriptor(BaseFont.AWT_ASCENT, size); float descender = -font.getBaseFont().getFontDescriptor(BaseFont.AWT_DESCENT, size); // negative value float margin = font.getBaseFont().getFontDescriptor(BaseFont.AWT_LEADING, size); float multiplier = (ascender + descender + margin) / size; if (multipliedLeading > 0.0f) { setMultipliedLeading(getMultipliedLeading() * multiplier); } // iText seems to output text with baseline lower than open office // we raise all paragraph text by some amount // again this may be inaccurate if fonts with different size are used in this paragraph float itextdescender = -font.getBaseFont().getFontDescriptor(BaseFont.DESCENT, size); // negative float textRise = itextdescender + getTotalLeading() - font.getSize() * multiplier; chunks = getChunks(); for (Chunk chunk : chunks) { Font f = chunk.getFont(); if (f != null) { // have to raise underline and strikethru as well float s = f.getSize(); if (f.isUnderlined()) { f.setStyle(f.getStyle() & ~Font.UNDERLINE); chunk.setUnderline(s * 1 / 17, s * -1 / 7 + textRise); } if (f.isStrikethru()) { f.setStyle(f.getStyle() & ~Font.STRIKETHRU); chunk.setUnderline(s * 1 / 17, s * 1 / 4 + textRise); } } chunk.setTextRise(chunk.getTextRise() + textRise); } } // wrap this paragraph into a table if necessary if (wrapperCell != null) { // background color or borders were set wrapperCell.addElement(this); wrapperTable = createTable(wrapperCell); if (getIndentationLeft() > 0.0f || getIndentationRight() > 0.0f || getSpacingBefore() > 0.0f || getSpacingAfter() > 0.0f) { // margins were set, have to wrap the cell again PdfPCell outerCell = createCell(); outerCell.setPaddingLeft(getIndentationLeft()); setIndentationLeft(0.0f); outerCell.setPaddingRight(getIndentationRight()); setIndentationRight(0.0f); outerCell.setPaddingTop(getSpacingBefore()); setSpacingBefore(0.0f); outerCell.setPaddingBottom(getSpacingAfter()); setSpacingAfter(0.0f); outerCell.addElement(wrapperTable); wrapperTable = createTable(outerCell); } } } return wrapperTable != null ? wrapperTable : this; }
From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java
License:Open Source License
public void printMasterRecord() throws DocumentException { if (newPage) { document.newPage();// ww w. ja v a2 s . co m newPage = false; } Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE); Paragraph p = null; Phrase phrase = null; p = new Paragraph(); p.setAlignment(Paragraph.ALIGN_LEFT); phrase = new Phrase(LEADING, "Patient Information", boldFont); phrase.add("\n"); p.add(phrase); document.add(p); p = new Paragraph(); phrase = new Phrase(LEADING, "", font); phrase.add("Title: " + demographic.getTitle() + "\n"); phrase.add("Last Name: " + demographic.getLastName() + "\n"); phrase.add("First Name: " + demographic.getFirstName() + "\n"); phrase.add("Gender: " + demographic.getSex() + "\n"); phrase.add("Date of Birth: " + demographic.getFormattedDob() + "\n"); phrase.add("Offical Language: " + demographic.getOfficialLanguage() + "\n"); phrase.add("Spoken Language: " + demographic.getSpokenLanguage() + "\n"); phrase.add("\n"); p.add(phrase); document.add(p); p = new Paragraph(); phrase = new Phrase(LEADING, "", font); phrase.add("Roster Status: " + demographic.getRosterStatus() + "\n"); phrase.add("Date Rostered: " + "\n"); phrase.add("Patient Status: " + demographic.getPatientStatus() + "\n"); phrase.add("Chart No (MRN): " + demographic.getChartNo() + "\n"); if (demographic.getDateJoined() != null) { phrase.add("Date Joined: " + formatter.format(demographic.getDateJoined()) + "\n"); } if (demographic.getEndDate() != null) { phrase.add("End Date: " + formatter.format(demographic.getEndDate()) + "\n"); } phrase.add("\n"); p.add(phrase); document.add(p); p = new Paragraph(); phrase = new Phrase(LEADING, "", font); phrase.add("Address: " + demographic.getAddress() + "\n"); phrase.add("City: " + demographic.getCity() + "\n"); phrase.add("Province: " + demographic.getProvince() + "\n"); phrase.add("Postal Code: " + demographic.getPostal() + "\n"); phrase.add("Email: " + demographic.getEmail() + "\n"); phrase.add("Phone: " + demographic.getPhone() + "\n"); List<DemographicExt> exts = demographicExtDao .getDemographicExtByDemographicNo(demographic.getDemographicNo()); String phoneExt = null; String cell = null; for (DemographicExt ext : exts) { if (ext.getKey().equals("wPhoneExt")) { phoneExt = ext.getValue(); } if (ext.getKey().equals("demo_cell")) { cell = ext.getValue(); } } phrase.add("Work Phone: " + demographic.getPhone2()); if (phoneExt != null) { phrase.add(" ext:" + phoneExt + "\n"); } else { phrase.add("\n"); } if (cell != null) { phrase.add("Cell Phone: " + cell + "\n"); } phrase.add("\n"); p.add(phrase); document.add(p); p = new Paragraph(); phrase = new Phrase(LEADING, "", font); phrase.add("Health Insurance #: " + demographic.getHin() + "\n"); phrase.add("HC Type: " + demographic.getHcType() + "\n"); if (demographic.getEffDate() != null) { phrase.add("Eff Date: " + formatter.format(demographic.getEffDate()) + "\n"); } phrase.add("\n"); p.add(phrase); document.add(p); DemographicCust demographicCust = demographicCustDao.find(demographic.getDemographicNo()); p = new Paragraph(); phrase = new Phrase(LEADING, "", font); phrase.add("Physician: " + getProviderName(demographic.getProviderNo()) + "\n"); if (demographicCust != null) { phrase.add("Nurse: " + getProviderName(demographicCust.getNurse()) + "\n"); phrase.add("Midwife: " + getProviderName(demographicCust.getMidwife()) + "\n"); phrase.add("Resident: " + getProviderName(demographicCust.getResident()) + "\n"); } phrase.add("Referral Doctor: " + getReferralDoctor(demographic.getFamilyDoctor()) + "\n"); phrase.add("\n"); p.add(phrase); document.add(p); p = new Paragraph(); phrase = new Phrase(LEADING, "", font); //alerts & notes if (demographicCust != null) { phrase.add("Alerts: " + demographicCust.getAlert() + "\n"); if (demographicCust.getNotes().length() > 0) { phrase.add("Notes: " + SxmlMisc.getXmlContent(demographicCust.getNotes(), "unotes") + "\n"); } } phrase.add("\n"); p.add(phrase); document.add(p); //relationships p = new Paragraph(); phrase = new Phrase(LEADING, "", font); DemographicRelationship demoRel = new DemographicRelationship(); @SuppressWarnings("unchecked") ArrayList<HashMap<String, String>> demoR = demoRel .getDemographicRelationships(String.valueOf(demographic.getDemographicNo())); for (int j = 0; j < demoR.size(); j++) { HashMap<String, String> r = demoR.get(j); String relationDemographicNo = r.get("demographic_no"); Demographic relationDemographic = demographicDao .getClientByDemographicNo(Integer.parseInt(relationDemographicNo)); String relation = r.get("relation"); String subDecisionMaker = r.get("sub_decision_maker"); String emergencyContact = r.get("emergency_contact"); String notes = r.get("notes"); phrase.add(relation + " - " + relationDemographic.getFormattedName() + " - " + subDecisionMaker + " - " + emergencyContact + " - " + notes + "\n"); } phrase.add("\n"); p.add(phrase); document.add(p); }
From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java
License:Open Source License
public void printCPPItem(String heading, Collection<CaseManagementNote> notes) throws DocumentException { if (newPage)//from ww w .j a v a 2 s. c om document.newPage(); // else // newPage = true; Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE); Paragraph p = null; Phrase phrase = null; p = new Paragraph(); p.setAlignment(Paragraph.ALIGN_LEFT); phrase = new Phrase(LEADING, heading, obsfont); p.add(phrase); document.add(p); newPage = false; this.printNotes(notes, true); cb.endText(); }
From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java
License:Open Source License
public void printNotes(Collection<CaseManagementNote> notes, boolean compact) throws DocumentException { CaseManagementNote note;/*from ww w .j av a 2 s. co m*/ Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE); Paragraph p; Phrase phrase; Chunk chunk; //if( newPage ) // document.newPage(); // else // newPage = true; //Print notes Iterator<CaseManagementNote> notesIter = notes.iterator(); while (notesIter.hasNext()) { note = notesIter.next(); p = new Paragraph(); //p.setSpacingBefore(font.leading(LINESPACING)*2f); phrase = new Phrase(LEADING, "", font); if (compact) { phrase.add(new Chunk(formatter.format(note.getObservation_date()) + ":")); } else { chunk = new Chunk("Impression/Plan: (" + formatter.format(note.getObservation_date()) + ")\n", obsfont); phrase.add(chunk); } if (compact) { phrase.add(note.getNote() + "\n"); } else { phrase.add(note.getNote() + "\n\n"); } p.add(phrase); document.add(p); } }