Example usage for com.lowagie.text Font Font

List of usage examples for com.lowagie.text Font Font

Introduction

In this page you can find the example usage for com.lowagie.text Font Font.

Prototype


public Font(int family, float size, int style) 

Source Link

Document

Constructs a Font.

Usage

From source file:org.jcryptool.visual.crt.export.FileExporter.java

License:Open Source License

/**
 * creates the PDF output-file using iText library
 *///www  .j  av a  2s.c  om
public void exportToPDF() {
    Font fontSupscript = new Font(Font.HELVETICA, 6, Font.NORMAL);
    Font fontSymbol = new Font(Font.SYMBOL, 12, Font.NORMAL);

    try {
        PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();

        document.add(new Paragraph("Chinese Remainder Theorem"));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("Equations:"));
        document.add(new Paragraph(" "));
        for (int i = 0; i < valueA.length; i++) {
            document.add(new Paragraph("x = " + valueA[i] + " mod " + valueModuli[i]));
        }
        document.add(new Paragraph(" "));
        document.add(new Paragraph("Compute"));
        document.add(new Paragraph(" "));

        Chunk space = new Chunk(" ");
        Chunk spaceBig = new Chunk("    ");
        Chunk index = new Chunk("i", fontSupscript);
        index.setTextRise(-3.0f);
        Chunk m = new Chunk("m");
        Chunk equal = new Chunk("=");
        Chunk openB = new Chunk("(");
        Chunk closeB = new Chunk(")");
        Chunk p = new Chunk("P", fontSymbol);
        Chunk comma = new Chunk(",");
        Chunk range = new Chunk("i=0 to n-1");
        Chunk bigM = new Chunk("M");
        Chunk div = new Chunk("/");

        document.add(m);
        document.add(space);
        document.add(equal);
        document.add(space);
        document.add(p);
        document.add(space);
        document.add(openB);
        document.add(space);
        document.add(m);
        document.add(index);
        document.add(space);
        document.add(closeB);
        document.add(comma);
        document.add(spaceBig);
        document.add(bigM);
        document.add(space);
        document.add(equal);
        document.add(space);
        document.add(m);
        document.add(space);
        document.add(div);
        document.add(space);
        document.add(m);
        document.add(index);
        document.add(comma);
        document.add(spaceBig);
        document.add(range);

        document.add(new Paragraph(" "));
        document.add(new Paragraph("m = " + crt.getModulus()));
        document.add(new Paragraph(" "));
        for (int i = 0; i < valueBigM.length; i++) {
            m = new Chunk("m");
            index = new Chunk(String.valueOf(i), fontSupscript);
            index.setTextRise(-3.0f);
            Chunk value = new Chunk(valueBigM[i].toString());

            document.add(m);
            document.add(index);
            document.add(new Chunk(" = "));
            document.add(value);
            document.add(new Paragraph());
        }
        document.add(new Paragraph(" "));
        document.add(new Paragraph("To get the inverse you can use the extended euclidean."));
        document.add(new Paragraph(" "));

        Chunk y = new Chunk("y");
        Chunk equiv = new Chunk("=");
        Chunk mod = new Chunk("mod");
        index = new Chunk("i", fontSupscript);
        index.setTextRise(-3.0f);

        document.add(y);
        document.add(index);
        document.add(bigM);
        document.add(index);
        document.add(space);
        document.add(equiv);
        document.add(space);
        document.add(new Chunk("1"));
        document.add(space);
        document.add(mod);
        document.add(space);
        document.add(m);
        document.add(index);
        document.add(comma);
        document.add(spaceBig);
        document.add(range);

        document.add(new Paragraph(" "));
        for (int i = 0; i < valueBigM.length; i++) {
            index = new Chunk(String.valueOf(i), fontSupscript);
            index.setTextRise(-3.0f);
            Chunk value = new Chunk(valueInverse[i].toString());

            document.add(new Chunk("y"));
            document.add(index);
            document.add(new Chunk(" = "));
            document.add(value);
            document.add(new Paragraph());
        }
        document.add(new Paragraph(" "));
        document.add(new Paragraph("To get one solution of the simultaneous congruences."));
        document.add(new Paragraph(" "));

        Chunk sum = new Chunk("S", fontSymbol);
        index = new Chunk("i", fontSupscript);
        index.setTextRise(-3.0f);

        document.add(new Chunk("x = "));
        document.add(sum);
        document.add(space);
        document.add(new Chunk());
        document.add(new Chunk("a"));
        document.add(index);
        document.add(new Chunk("y"));
        document.add(index);
        document.add(bigM);
        document.add(index);
        document.add(space);
        document.add(new Chunk("mod"));
        document.add(space);
        document.add(m);
        document.add(comma);
        document.add(spaceBig);
        document.add(range);
        document.add(new Chunk("."));

        document.add(new Paragraph(" "));
        document.add(new Paragraph("One solution is: " + crt.getFinalResult()));

        document.close();

    } catch (FileNotFoundException e) {
        LogUtil.logError(e);
    } catch (DocumentException e) {
        LogUtil.logError(e);
    }
}

From source file:org.kuali.ole.describe.controller.EditorController.java

License:Open Source License

private void generateCallSlip(EditorForm editorForm, HttpServletResponse response) {
    LOG.debug("Creating pdf");
    String title = "", author = "", callNumber = "", location = "", copyNumber = "", enumeration = "",
            chronology = "", barcode = "";
    SearchResponse searchResponse = null;
    SearchParams searchParams = new SearchParams();
    SearchField searchField1 = searchParams.buildSearchField("item", "ItemIdentifier_search",
            editorForm.getDocId());/*from   w w w.j  a v  a  2  s.c o m*/
    searchParams.getSearchConditions().add(searchParams.buildSearchCondition("OR", searchField1, "AND"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("bibliographic", "Title"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("bibliographic", "Author"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "CallNumber"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "LocationName"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "CopyNumber"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "enumeration"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "chronology"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "ItemBarcode"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("holdings", "CallNumber"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("holdings", "LocationName"));
    try {
        searchResponse = getDocstoreClientLocator().getDocstoreClient().search(searchParams);
    } catch (Exception e) {
        LOG.error(e, e);
    }
    if (CollectionUtils.isNotEmpty(searchResponse.getSearchResults())) {
        for (SearchResultField searchResultField : searchResponse.getSearchResults().get(0)
                .getSearchResultFields()) {
            if (searchResultField.getDocType().equalsIgnoreCase(DocType.BIB.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("Title")) {
                if (StringUtils.isBlank(title)) {
                    title = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
                }
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.BIB.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("Author")) {
                if (StringUtils.isBlank(author)) {
                    author = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
                }
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("CallNumber")) {
                callNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("LocationName")) {
                location = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("CopyNumber")) {
                copyNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("enumeration")) {
                enumeration = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue()
                        : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("chronology")) {
                chronology = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("ItemBarcode")) {
                barcode = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.HOLDINGS.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("CallNumber")) {
                if (StringUtils.isBlank(callNumber)) {
                    callNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue()
                            : "";
                }
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.HOLDINGS.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("LocationName")) {
                if (StringUtils.isBlank(location)) {
                    location = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue()
                            : "";
                }
            }
        }
    }
    String fileName = "Call/Paging Slip" + "_" + (editorForm.getTitle() != null ? editorForm.getTitle() : "")
            + "_" + new Date(System.currentTimeMillis()) + ".pdf";
    if (LOG.isInfoEnabled()) {
        LOG.info("File Created :" + title + "file name ::" + fileName + "::");
    }
    try {
        Document document = this.getDocument(0, 0, 5, 5);
        OutputStream outputStream = null;
        response.setContentType("application/pdf");
        //response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
        outputStream = response.getOutputStream();
        PdfWriter.getInstance(document, outputStream);
        Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
        document.open();
        document.newPage();
        PdfPTable pdfTable = new PdfPTable(3);
        pdfTable.setWidths(new int[] { 20, 2, 30 });
        Paragraph paraGraph = new Paragraph();
        paraGraph.setAlignment(Element.ALIGN_CENTER);
        paraGraph.add(new Chunk("Call/Paging Slip", boldFont));
        paraGraph.add(Chunk.NEWLINE);
        paraGraph.add(Chunk.NEWLINE);
        paraGraph.add(Chunk.NEWLINE);
        document.add(paraGraph);

        pdfTable.addCell(getPdfPCellInJustified("Title"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(title));

        pdfTable.addCell(getPdfPCellInJustified("Author"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(author));

        pdfTable.addCell(getPdfPCellInJustified("Call Number"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(callNumber));

        pdfTable.addCell(getPdfPCellInJustified("Location"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(location));

        pdfTable.addCell(getPdfPCellInJustified("Copy Number"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(copyNumber));

        pdfTable.addCell(getPdfPCellInJustified("Enumeration"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(enumeration));

        pdfTable.addCell(getPdfPCellInJustified("Chronology"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(chronology));

        pdfTable.addCell(getPdfPCellInJustified("Barcode"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(barcode));

        document.add(pdfTable);
        document.close();
        outputStream.flush();
        outputStream.close();
    } catch (Exception e) {
        LOG.error(e, e);
    }
}

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 w w  . j av  a  2s. c o 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 {//  w  w w  .  ja  v a2  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.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
 *//*from   w  w w.  java 2s .co  m*/
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();//w w  w  .jav  a 2s.c  o m
    //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.casemgmt.print.OscarChartPrinter.java

License:Open Source License

public void printMasterRecord() throws DocumentException {
    if (newPage) {
        document.newPage();/*from ww w  .  j  a v  a 2  s .  c  o 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)//w w  w .j  a  v a2  s .  c o m
        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   w  w w .j  a  va 2s. c  om
    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);
    }
}

From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java

License:Open Source License

public void printAllergies(List<Allergy> allergies) throws DocumentException {
    ProviderDao providerDao = (ProviderDao) SpringUtils.getBean("providerDao");

    /*/*from ww w .j  av a2  s .  co m*/
         if( getNewPage() )
    getDocument().newPage();
           else
    setNewPage(true);
    */
    Font obsfont = new Font(getBaseFont(), FONTSIZE, Font.UNDERLINE);

    Paragraph p = new Paragraph();
    p.setAlignment(Paragraph.ALIGN_LEFT);
    Phrase phrase = new Phrase(LEADING, "\n", getFont());
    p.add(phrase);
    phrase = new Phrase(LEADING, "Allergies", obsfont);
    p.add(phrase);
    getDocument().add(p);

    for (Allergy allergy : allergies) {
        p = new Paragraph();
        phrase = new Phrase(LEADING, "", getFont());
        Chunk chunk = new Chunk(allergy.getDescription());
        phrase.add(chunk);
        p.add(phrase);
        getDocument().add(p);
    }
    getDocument().add(new Phrase("\n", getFont()));
}