List of usage examples for com.itextpdf.text Paragraph add
@Override public boolean add(Element o)
Element
to the Paragraph
. From source file:gov.nih.nci.firebird.service.registration.AbstractPdfWriterGenerator.java
License:Open Source License
PdfPCell createHeaderCell(String value) { Paragraph contents = new Paragraph(); Chunk chunk = getValueChunk(value);// ww w .j ava 2 s .c om chunk.setFont(TABLE_HEADER_FONT); contents.add(chunk); PdfPCell cell = createCell(contents); cell.setBackgroundColor(TABLE_HEADER_COLOR); return cell; }
From source file:gov.nih.nci.firebird.service.registration.AbstractPdfWriterGenerator.java
License:Open Source License
private PdfPCell createTableCell(String value) { Paragraph contents = new Paragraph(); contents.add(getValueChunk(value)); PdfPCell cell = createTableCell(contents); cell.setPaddingLeft(VALUE_CELL_INDENTATION); return cell;//from www . j av a 2s . c o m }
From source file:gov.nih.nci.firebird.service.registration.AbstractPdfWriterGenerator.java
License:Open Source License
private void addColumnHeadingCell(PdfPTable table, String columnHeadingKey) { Paragraph contents = new Paragraph(); contents.setAlignment(Element.ALIGN_BOTTOM); PdfPCell cell = createCell();//w ww. j a v a 2 s .c o m cell.setBackgroundColor(TABLE_CELL_COLOR); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setPhrase(contents); contents.add(getColumnHeaderChunk(columnHeadingKey)); addToTable(table, cell); }
From source file:gov.nih.nci.firebird.service.registration.AbstractPdfWriterGenerator.java
License:Open Source License
void addValues(PdfPTable table, String... values) { for (String value : values) { Paragraph contents = new Paragraph(); contents.add(getValueChunk(value)); addToTable(table, contents);/*from w w w . j ava2 s. co m*/ } }
From source file:gov.nih.nci.firebird.service.registration.ProfileContentPdfHelper.java
License:Open Source License
private void addAddress(Address address, PdfPTable table, int index) { PdfPTable addressTable = pdfGenerator.createTable(AbstractPdfWriterGenerator.ONE_COLUMN); addressTable.addCell(//from www . j a va 2s . com pdfGenerator.createHeaderCell(index + ". " + pdfGenerator.getFromResources(ADDRESS_TITLE_KEY))); Paragraph contents = new Paragraph(); if (getOrganization() != null) { contents.add(pdfGenerator.getValueChunk(getOrganization().getName())); contents.add(Chunk.NEWLINE); } if (address != null) { addAddressContent(contents, address); } PdfPCell addressCell = pdfGenerator.createTableCell(contents); addressCell.setPaddingLeft(VALUE_CELL_INDENTATION); addressTable.addCell(addressCell); PdfPCell addressTableCell = pdfGenerator.createCell(addressTable); addressTableCell.setPaddingRight(PADDING_RIGHT); table.addCell(addressTableCell); }
From source file:gov.nih.nci.firebird.service.registration.ProfileContentPdfHelper.java
License:Open Source License
private void addAddressContent(Paragraph contents, Address address) { contents.add(pdfGenerator.getValueChunk(address.getStreetAddress())); if (StringUtils.isNotBlank(address.getDeliveryAddress())) { contents.add(Chunk.NEWLINE);/*from ww w . j av a 2 s . c o m*/ contents.add(pdfGenerator.getValueChunk(address.getDeliveryAddress())); } contents.add(Chunk.NEWLINE); contents.add(pdfGenerator.getValueChunk(address.getCity())); if (StringUtils.isNotBlank(address.getStateOrProvince())) { contents.add(pdfGenerator.getValueChunk(", " + address.getStateOrProvince())); } if (StringUtils.isNotBlank(address.getPostalCode())) { contents.add(pdfGenerator.getValueChunk(SPACE_CHARACTER)); contents.add(pdfGenerator.getValueChunk(address.getPostalCode())); } if (!FirebirdConstants.US_COUNTRY_CODE.equals(address.getCountry())) { contents.add(Chunk.NEWLINE); contents.add(pdfGenerator.getValueChunk(address.getCountry())); } }
From source file:gov.utah.dts.det.ccl.actions.facility.information.license.reports.LicenseLetter.java
private static void writePdf(License license, ByteArrayOutputStream ba, HttpServletRequest request) throws DocumentException, BadElementException, IOException { Document document = null;//from w w w . j a v a2 s. com Paragraph paragraph = null; document = new Document(PageSize.LETTER, 50, 50, 190, 75); PdfWriter writer = PdfWriter.getInstance(document, ba); SimpleDateFormat df = new SimpleDateFormat("MMMM d, yyyy"); SimpleDateFormat df2 = new SimpleDateFormat("MM/dd/yyyy"); Date today = new Date(); StringBuilder sb; document.open(); LetterheadStamper.stampLetter(writer, request); // Add report date paragraph = getParagraph(); paragraph.add(new Phrase(df.format(today), mediumfont)); paragraph.setIndentationLeft(rightindent); document.add(paragraph); // Add facility name and address information paragraph = getParagraph(); paragraph.add(new Phrase(license.getFacility().getName().toUpperCase(), mediumfont)); paragraph.setSpacingBefore(20); document.add(paragraph); if (StringUtils.isNotBlank(license.getFacility().getSiteName())) { paragraph = getParagraph(); paragraph.add(new Phrase(license.getFacility().getSiteName().toUpperCase(), mediumfont)); document.add(paragraph); } paragraph = getParagraph(); try { paragraph.add(new Phrase(license.getFacility().getMailingAddress().getAddressOne().toUpperCase(), mediumfont)); } catch (Exception e) { paragraph.add(new Phrase("Mailing Address", mediumfont)); } document.add(paragraph); try { if (StringUtils.isNotBlank(license.getFacility().getMailingAddress().getAddressTwo())) { // Add facility location address two paragraph = getParagraph(); paragraph.add(new Phrase(license.getFacility().getMailingAddress().getAddressTwo().toUpperCase(), mediumfont)); document.add(paragraph); } } catch (Exception e) { // Skip if no address found } paragraph = getParagraph(); try { paragraph.add(new Phrase(license.getFacility().getMailingAddress().getCityStateZip().toUpperCase(), mediumfont)); } catch (Exception e) { paragraph.add(new Phrase("City, State Zipcode", mediumfont)); } document.add(paragraph); // Add subject information paragraph = getParagraph(); sb = new StringBuilder(); sb.append("SUBJECT: LICENSE APPROVAL"); if (license.getSubtype() != null && StringUtils.isNotBlank(license.getSubtype().getValue())) { sb.append(" - " + license.getSubtype().getValue().toUpperCase()); } paragraph.add(new Phrase(sb.toString(), mediumfont)); paragraph.setSpacingBefore(paragraphSpacing); document.add(paragraph); // Add salutation paragraph = getParagraph(); paragraph.add(new Phrase("Dear Director:", mediumfont)); paragraph.setSpacingBefore(paragraphSpacing); document.add(paragraph); // Start letter detail paragraph = getParagraph(); sb = new StringBuilder(); sb.append("Your application to provide "); // Get the Service Code Definition String service = ""; if (license.getSpecificServiceCode() != null && StringUtils.isNotBlank(license.getSpecificServiceCode().getValue()) && DV_TREATMENT.equalsIgnoreCase(license.getSpecificServiceCode().getValue())) { service = DOMESTIC_VIOLENCE; } if (!license.getProgramCodeIds().isEmpty()) { // redmine 25410 mentalHealthLoop: for (PickListValue pkv : license.getProgramCodeIds()) { String program = pkv.getValue(); int idx = program.indexOf(" "); if (idx >= 0) { String code = program.substring(0, idx); if (MENTAL_HEALTH_CODES.indexOf(code + ":") >= 0) { if (service.length() > 0) { service += "/"; } service += MENTAL_HEALTH; break mentalHealthLoop; } } } substanceAbuseLoop: for (PickListValue pkv : license.getProgramCodeIds()) { String program = pkv.getValue(); int idx = program.indexOf(" "); if (idx >= 0) { String code = program.substring(0, idx); if (SUBSTANCE_ABUSE_CODES.indexOf(code + ":") >= 0) { if (service.length() > 0) { service += "/"; } service += SUBSTANCE_ABUSE; break substanceAbuseLoop; } } } } if (license.getServiceCode() != null && StringUtils.isNotBlank(license.getServiceCode().getValue())) { if (service.length() > 0) { service += "/"; } String code = license.getServiceCode().getValue(); int idx = code.indexOf("-"); if (idx > -1) { idx++; code = code.substring(idx).trim(); } service += code; } sb.append(service); sb.append(" for "); if (license.getAgeGroup() == null || license.getAgeGroup().getValue().equalsIgnoreCase("Adult & Youth")) { // Adult & Youth if (license.getAdultTotalSlots() != null) { sb.append(license.getAdultTotalSlots().toString()); } sb.append(" adult and youth clients"); } else if (license.getAgeGroup().getValue().equalsIgnoreCase("Adult")) { // Adult if (license.getAdultTotalSlots() != null) { // Are male or female counts specified? sb.append(license.getAdultTotalSlots().toString()); sb.append(" adult"); if (license.getAdultFemaleCount() != null || license.getAdultMaleCount() != null) { // Does either the male or female count equal the total slot count? if ((license.getAdultFemaleCount() != null && license.getAdultFemaleCount().equals(license.getAdultTotalSlots()))) { sb.append(" female clients"); } else if (license.getAdultMaleCount() != null && license.getAdultMaleCount().equals(license.getAdultTotalSlots())) { sb.append(" male clients"); } else { sb.append(" clients, "); if (license.getAdultMaleCount() != null) { sb.append(license.getAdultMaleCount().toString() + " male"); } if (license.getAdultFemaleCount() != null) { if (license.getAdultMaleCount() != null) { sb.append(" and "); } sb.append(license.getAdultFemaleCount().toString() + " female"); } if (license.getFromAge() != null || license.getToAge() != null) { sb.append(","); } } } else { sb.append(" clients"); } } else { sb.append(" adult clients"); } } else { // Youth if (license.getYouthTotalSlots() != null) { // Are male or female counts specified? sb.append(license.getYouthTotalSlots().toString()); sb.append(" youth"); if (license.getYouthFemaleCount() != null || license.getYouthMaleCount() != null) { // Does either the male or female count equal the total slot count? if ((license.getYouthFemaleCount() != null && license.getYouthFemaleCount().equals(license.getYouthTotalSlots()))) { sb.append(" female clients"); } else if (license.getYouthMaleCount() != null && license.getYouthMaleCount().equals(license.getYouthTotalSlots())) { sb.append(" male clients"); } else { sb.append(" clients, "); if (license.getYouthMaleCount() != null) { sb.append(license.getYouthMaleCount().toString() + " male"); } if (license.getYouthFemaleCount() != null) { if (license.getYouthMaleCount() != null) { sb.append(" and "); } sb.append(license.getYouthFemaleCount().toString() + " female"); } if (license.getFromAge() != null || license.getToAge() != null) { sb.append(","); } } } else { sb.append(" clients"); } } else { sb.append(" youth clients"); } } if (license.getFromAge() != null || license.getToAge() != null) { sb.append(" ages "); if (license.getFromAge() != null) { sb.append(license.getFromAge().toString()); if (license.getToAge() != null) { sb.append(" to " + license.getToAge().toString()); } else { sb.append(" and older"); } } else { sb.append("to " + license.getToAge().toString()); } } if (StringUtils.isNotBlank(license.getCertificateComment())) { sb.append(" "); sb.append(license.getCertificateComment()); } sb.append(" has been approved."); paragraph.add(new Phrase(sb.toString(), mediumfont)); paragraph.setSpacingBefore(paragraphSpacing); document.add(paragraph); paragraph = getParagraph(); sb = new StringBuilder(); sb.append("The license is issued for the period from "); sb.append(df2.format(license.getStartDate())); sb.append(" to "); sb.append(df2.format(license.getEndDate())); sb.append( ". The enclosed license is subject to revocation for cause; or if there should be any change in the management, ownership, or address of the facility, "); sb.append( "the license is automatically void and should be returned to our office. The enclosed license must be posted in the facility."); paragraph.add(new Phrase(sb.toString(), mediumfont)); paragraph.setSpacingBefore(paragraphSpacing); document.add(paragraph); paragraph = getParagraph(); sb = new StringBuilder(); sb.append( "The approval of your license is based upon reports submitted to this office by our staff and by the "); sb.append( "collaberative agencies which show that reasonable standards of care are maintained and the services "); sb.append("provided meet the requirements established by our State Standards."); paragraph.add(new Phrase(sb.toString(), mediumfont)); paragraph.setSpacingBefore(paragraphSpacing); document.add(paragraph); paragraph = getParagraph(); sb = new StringBuilder(); sb.append( "During the period for which the license is granted, representatives from this office and other collaborative "); sb.append( "agencies may make periodic supervisory visits and will be available for consultation. Please feel free to "); sb.append("request assistance at any time."); paragraph.add(new Phrase(sb.toString(), mediumfont)); paragraph.setSpacingBefore(paragraphSpacing); document.add(paragraph); paragraph = getParagraph(); paragraph.add(new Phrase(license.getFacility().getLicensingSpecialist().getFirstAndLastName(), mediumfont)); paragraph.setSpacingBefore(paragraphSpacing); document.add(paragraph); paragraph = getParagraph(); paragraph.add(new Phrase("Licensing Specialist", mediumfont)); document.add(paragraph); paragraph = getParagraph(); sb = new StringBuilder(); sb.append("Enclosure: License #"); if (license.getLicenseNumber() != null) { sb.append(license.getLicenseNumber().toString()); } paragraph.add(new Phrase(sb.toString(), mediumfont)); paragraph.setSpacingBefore(paragraphSpacing); document.add(paragraph); // Check to see if Program Code starts with 'D' if (!license.getProgramCodeIds().isEmpty()) { // redmine 25410 multiple program codes sb = new StringBuilder(); for (PickListValue pkv : license.getProgramCodeIds()) { if (pkv.getValue() != null && pkv.getValue().length() >= 4) { String code = pkv.getValue().substring(0, 4).toUpperCase(); if (CC_PROGRAM_CODES.contains(code)) { if (sb.length() > 0) { sb.append(", "); } sb.append(code); } } } if (sb.length() > 0) { paragraph = getParagraph(); paragraph.add(new Phrase("cc: " + sb.toString(), mediumfont)); document.add(paragraph); } } document.close(); }
From source file:gov.utah.dts.det.ccl.actions.reports.generators.ExpiredLicensesReport.java
private static void writePdf(Person specialist, List<FacilityLicenseView> licenses, OutputStream ba) throws DocumentException, BadElementException { Document document = null;//w w w. j av a2s .co m PdfPTable doctable; PdfPTable datatable; PdfPTable factable; Paragraph paragraph; Facility facility; document = new Document(PageSize.A4); @SuppressWarnings("unused") PdfWriter writer = PdfWriter.getInstance(document, ba); document.open(); doctable = getDocumentTable(specialist); if (licenses != null && licenses.size() > 0) { doctable.getDefaultCell().setPaddingBottom(4); doctable.getDefaultCell().setBorderWidthBottom(.5f); for (FacilityLicenseView license : licenses) { facility = license.getFacility(); datatable = getDetailTable(); datatable.getDefaultCell().setPaddingLeft(4); datatable.getDefaultCell().setPaddingRight(2); datatable.getDefaultCell().setColspan(1); // Add Facility Name information if (StringUtils.isNotBlank(license.getFacilityName())) { datatable.addCell(new Phrase(license.getFacilityName().toUpperCase(), smallfont)); } else { datatable.addCell(BLANK); } // Add License Number information datatable.getDefaultCell().setPaddingLeft(2); if (license.getLicenseNumber() != null) { datatable.addCell(new Phrase(license.getLicenseNumber().toString(), smallfont)); } else { datatable.addCell(BLANK); } // Add Service Code information if (StringUtils.isNotBlank(license.getServiceCodeCode())) { datatable.addCell(new Phrase(license.getServiceCodeCode(), smallfont)); } else { datatable.addCell(BLANK); } // Add License Type information if (StringUtils.isNotBlank(license.getSubtype())) { datatable.addCell(new Phrase(license.getSubtype(), smallfont)); } else { datatable.addCell(BLANK); } // Add License Expiration date information datatable.getDefaultCell().setPaddingRight(4); if (StringUtils.isNotBlank(license.getExpirationDateFormatted())) { datatable.addCell(new Phrase(license.getExpirationDateFormatted(), smallfont)); } else { datatable.addCell(BLANK); } // Add Mailing Location information sb = new StringBuilder(); if (facility != null && facility.getMailingAddress() != null && StringUtils.isNotBlank(facility.getMailingAddress().getAddressOne())) { sb.append(facility.getMailingAddress().getAddressOne()); // add address two if (StringUtils.isNotBlank(facility.getMailingAddress().getAddressTwo())) { if (sb.length() > 0) { sb.append(" "); } sb.append(facility.getMailingAddress().getAddressTwo()); } // Add city, state, zip if (StringUtils.isNotBlank(facility.getMailingAddress().getCityStateZip())) { if (sb.length() > 0) { sb.append(", "); } sb.append(facility.getMailingAddress().getCityStateZip()); } } datatable.getDefaultCell().setColspan(5); datatable.getDefaultCell().setPaddingLeft(4); datatable.getDefaultCell().setPaddingRight(4); if (sb.length() > 0) { datatable.addCell(new Phrase(sb.toString().toUpperCase(), smallfont)); } else { datatable.addCell(BLANK); } // // Add Facility details information // factable = getFacilityDetailsTable(); // Add primary phone information paragraph = new Paragraph(fixedLeading); paragraph.add(new Phrase("Primary Phone: ", smallfontB)); if (facility != null && facility.getPrimaryPhone() != null && StringUtils.isNotBlank(facility.getPrimaryPhone().getFormattedPhoneNumber())) { paragraph.add(new Phrase(facility.getPrimaryPhone().getFormattedPhoneNumber(), smallfont)); } factable.getDefaultCell().setPaddingLeft(4); factable.getDefaultCell().setPaddingRight(2); factable.addCell(paragraph); // Add SAFE Provider ID number paragraph = new Paragraph(fixedLeading); paragraph.add(new Phrase("SAFE: ", smallfontB)); if (facility != null && facility.getSafeProviderId() != null) { paragraph.add(new Phrase(facility.getSafeProviderId().toString(), smallfontB)); } factable.getDefaultCell().setColspan(2); factable.addCell(paragraph); // Add the facility information table to the details table datatable.getDefaultCell().setPadding(0); datatable.addCell(factable); // Add the detail to the document table doctable.addCell(datatable); } } else { // No open applications datatable = getDetailTable(); datatable.getDefaultCell().setPaddingTop(10); datatable.getDefaultCell().setColspan(3); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_CENTER); datatable.addCell(new Phrase("No expired licenses found to display.", smallfont)); doctable.getDefaultCell().setPaddingBottom(0); doctable.getDefaultCell().setBorderWidthBottom(0); doctable.addCell(datatable); } // Add the document table to the document document.add(doctable); document.close(); }
From source file:gov.utah.dts.det.ccl.actions.reports.generators.FacilityLicenseDetailReport.java
private static void writePdf(Person specialist, Date endDate, List<FacilityLicenseView> licenses, OutputStream ba) throws DocumentException, BadElementException { Document document = null;//from ww w .j av a 2 s . c o m PdfPTable doctable; Paragraph paragraph; Facility facility; document = new Document(PageSize.LETTER, 40, 40, 50, 50); PdfWriter writer = PdfWriter.getInstance(document, ba); PageNumberEventLeft pageNumber = new PageNumberEventLeft(); writer.setPageEvent(pageNumber); document.open(); doctable = getDocumentTable(specialist, endDate); if (licenses != null && licenses.size() > 0) { boolean moreLicenses = true; boolean facilityIsChanging = true; int idx = 0; FacilityLicenseView license = licenses.get(idx); while (moreLicenses) { facility = license.getFacility(); doctable.getDefaultCell().setPaddingBottom(4); doctable.getDefaultCell().setBorderWidthBottom(.5f); if (facilityIsChanging) { doctable.addCell(populateFacilityInformation(facility)); facilityIsChanging = false; } // Check to see if the next record will change the facility so we can put the // proper bottom border. idx++; if (idx >= licenses.size()) { // this is the last license moreLicenses = false; } else { FacilityLicenseView next = licenses.get(idx); if (!next.getFacilityId().equals(license.getFacilityId())) { facilityIsChanging = true; } } // Set the bottom border based on the previous check findings if (facilityIsChanging || !moreLicenses) { // Add a large bottom border doctable.getDefaultCell().setBorderWidthBottom(1.0f); } doctable.addCell(populateLicenseInformation(license)); // Get the next license if (moreLicenses) { license = licenses.get(idx); } } } else { // No open applications paragraph = new Paragraph(fixedLeading); paragraph.setSpacingBefore(10); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.add(new Phrase("No active facility licenses found to display.", smallfont)); doctable.addCell(paragraph); } // Add the document table to the document document.add(doctable); document.close(); }
From source file:gov.utah.dts.det.ccl.actions.reports.generators.FacilityLicenseDetailReport.java
private static PdfPTable populateFacilityInformation(Facility facility) throws DocumentException { Paragraph paragraph; PdfPTable datatable = getFacilityDetailTable(); // Add Facility Name information datatable.getDefaultCell().setColspan(4); datatable.getDefaultCell().setPaddingLeft(4); datatable.getDefaultCell().setPaddingRight(4); if (StringUtils.isNotBlank(facility.getName())) { datatable.addCell(new Phrase(facility.getName().toUpperCase(), smallfont)); } else {/* w w w .ja va 2 s. c o m*/ datatable.addCell(BLANK); } // Add First Director(s) information datatable.getDefaultCell().setColspan(1); datatable.getDefaultCell().setPaddingLeft(4); datatable.getDefaultCell().setPaddingRight(2); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_RIGHT); datatable.addCell(new Phrase("Director(s):", smallfontB)); datatable.getDefaultCell().setPaddingLeft(2); datatable.getDefaultCell().setPaddingRight(4); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_LEFT); datatable.getDefaultCell().setColspan(3); sb = new StringBuilder(); List<FacilityPerson> directors = facility.getPeopleOfType(FIRST_DIRECTOR, true); if (directors != null && directors.size() > 0) { for (FacilityPerson fp : directors) { if (fp.getPerson() != null && StringUtils.isNotBlank(fp.getPerson().getFirstAndLastName())) { if (sb.length() > 0) { sb.append(", "); } sb.append(fp.getPerson().getFirstAndLastName().toUpperCase()); } } } if (sb.length() > 0) { datatable.addCell(new Phrase(sb.toString(), mediumfont)); } else { datatable.addCell(BLANK); } // Add Site information datatable.getDefaultCell().setColspan(1); datatable.getDefaultCell().setPaddingLeft(4); datatable.getDefaultCell().setPaddingRight(2); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_RIGHT); datatable.addCell(new Phrase("Site:", smallfontB)); datatable.getDefaultCell().setPaddingLeft(2); datatable.getDefaultCell().setPaddingRight(4); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_LEFT); datatable.getDefaultCell().setColspan(3); if (StringUtils.isNotBlank(facility.getSiteName())) { datatable.addCell(new Phrase(facility.getSiteName())); } else { datatable.addCell(BLANK); } // Add Mailing address information datatable.getDefaultCell().setColspan(1); datatable.getDefaultCell().setPaddingLeft(4); datatable.getDefaultCell().setPaddingRight(2); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_RIGHT); datatable.addCell(new Phrase("Mailing:", smallfontB)); datatable.getDefaultCell().setPaddingLeft(2); datatable.getDefaultCell().setPaddingRight(4); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_LEFT); datatable.getDefaultCell().setColspan(3); if (facility.getMailingAddress() != null && StringUtils.isNotBlank(facility.getMailingAddress().getAddressOne())) { sb = new StringBuilder(); sb.append(facility.getMailingAddress().getAddressOne()); if (StringUtils.isNotBlank(facility.getMailingAddress().getAddressTwo())) { sb.append(" " + facility.getMailingAddress().getAddressTwo()); } if (StringUtils.isNotBlank(facility.getMailingAddress().getCityStateZip())) { sb.append(", " + facility.getMailingAddress().getCityStateZip()); } paragraph = new Paragraph(fixedLeading); paragraph.add(new Phrase(sb.toString().toUpperCase(), smallfont)); datatable.addCell(paragraph); } else { datatable.addCell(BLANK); } // Add Location address information datatable.getDefaultCell().setColspan(1); datatable.getDefaultCell().setPaddingLeft(4); datatable.getDefaultCell().setPaddingRight(2); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_RIGHT); datatable.addCell(new Phrase("Location:", smallfontB)); datatable.getDefaultCell().setPaddingLeft(2); datatable.getDefaultCell().setPaddingRight(4); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_LEFT); datatable.getDefaultCell().setColspan(3); if (facility.getLocationAddress() != null && StringUtils.isNotBlank(facility.getLocationAddress().getAddressOne())) { sb = new StringBuilder(); sb.append(facility.getLocationAddress().getAddressOne()); if (StringUtils.isNotBlank(facility.getLocationAddress().getAddressTwo())) { sb.append(" " + facility.getLocationAddress().getAddressTwo()); } if (StringUtils.isNotBlank(facility.getLocationAddress().getCityStateZip())) { sb.append(", " + facility.getLocationAddress().getCityStateZip()); } paragraph = new Paragraph(fixedLeading); paragraph.add(new Phrase(sb.toString().toUpperCase(), smallfont)); datatable.addCell(paragraph); } else { datatable.addCell(BLANK); } // Add Phone information // Primary Phone datatable.getDefaultCell().setColspan(1); datatable.getDefaultCell().setPaddingLeft(4); datatable.getDefaultCell().setPaddingRight(2); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_RIGHT); datatable.addCell(new Phrase("Phone:", smallfontB)); datatable.getDefaultCell().setPaddingLeft(2); datatable.getDefaultCell().setPaddingRight(2); datatable.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_LEFT); if (facility.getPrimaryPhone() != null && StringUtils.isNotBlank(facility.getPrimaryPhone().getFormattedPhoneNumber())) { datatable.addCell(new Phrase(facility.getPrimaryPhone().getFormattedPhoneNumber(), smallfont)); } else { datatable.addCell(BLANK); } // Site Phone paragraph = new Paragraph(fixedLeading); paragraph.add(new Phrase("Site Phone: ", smallfontB)); if (facility.getAlternatePhone() != null && StringUtils.isNotBlank(facility.getAlternatePhone().getFormattedPhoneNumber())) { paragraph.add(new Phrase(facility.getAlternatePhone().getFormattedPhoneNumber(), smallfont)); } datatable.getDefaultCell().setPaddingLeft(2); datatable.getDefaultCell().setPaddingRight(2); datatable.addCell(paragraph); // Fax paragraph = new Paragraph(fixedLeading); paragraph.add(new Phrase("Fax: ", smallfontB)); if (facility.getFax() != null && StringUtils.isNotBlank(facility.getFax().getFormattedPhoneNumber())) { paragraph.add(new Phrase(facility.getFax().getFormattedPhoneNumber(), smallfont)); } datatable.getDefaultCell().setPaddingRight(4); datatable.addCell(paragraph); return datatable; }