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.oscarehr.casemgmt.service.CaseManagementPrintPdf.java

License:Open Source License

public void printRx(String demoNo, List<CaseManagementNote> cpp) throws DocumentException {
    if (demoNo == null)
        return;//  w w w.j  a va 2  s  .  co  m

    if (newPage)
        document.newPage();
    else
        newPage = true;

    Paragraph p = new Paragraph();
    Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE);
    Phrase phrase = new Phrase(LEADING, "", obsfont);
    p.setAlignment(Paragraph.ALIGN_CENTER);
    phrase.add("Patient Rx History");
    p.add(phrase);
    document.add(p);

    Font normal = new Font(bf, FONTSIZE, Font.NORMAL);

    oscar.oscarRx.data.RxPrescriptionData prescriptData = new oscar.oscarRx.data.RxPrescriptionData();
    oscar.oscarRx.data.RxPrescriptionData.Prescription[] arr = {};
    arr = prescriptData.getUniquePrescriptionsByPatient(Integer.parseInt(demoNo));

    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.casemgmt.service.CaseManagementPrintPdf.java

License:Open Source License

public void printCPP(HashMap<String, List<CaseManagementNote>> cpp) throws DocumentException {
    if (cpp == null)
        return;//from   w w w.  j a va 2  s .  c  o m

    if (newPage)
        document.newPage();
    else
        newPage = true;

    Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE);

    Paragraph p = new Paragraph();
    p.setAlignment(Paragraph.ALIGN_CENTER);
    Phrase phrase = new Phrase(LEADING, "\n\n", font);
    p.add(phrase);
    phrase = new Phrase(LEADING, "Patient CPP", obsfont);
    p.add(phrase);
    document.add(p);
    //upperYcoord -= p.leading() * 2f;
    //lworkingYcoord = rworkingYcoord = upperYcoord;
    //ColumnText ct = new ColumnText(cb);
    String[] headings = { "Social History\n", "Other Meds\n", "Medical History\n", "Ongoing Concerns\n",
            "Reminders\n", "Family History\n", "Risk Factors\n" };
    String[] issueCodes = { "SocHistory", "OMeds", "MedHistory", "Concerns", "Reminders", "FamHistory",
            "RiskFactors" };
    //String[] content = {cpp.getSocialHistory(), cpp.getFamilyHistory(), cpp.getMedicalHistory(), cpp.getOngoingConcerns(), cpp.getReminders()};

    //init column to left side of page
    //ct.setSimpleColumn(document.left(), document.bottomMargin()+25f, document.right()/2f, lworkingYcoord);

    //int column = 1;
    //Chunk chunk;
    //float bottom = document.bottomMargin()+25f;
    //float middle;
    //bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    //cb.beginText();
    //String headerContd;
    //while there are cpp headings to process

    for (int idx = 0; idx < headings.length; ++idx) {
        p = new Paragraph();
        p.setAlignment(Paragraph.ALIGN_LEFT);
        phrase = new Phrase(LEADING, headings[idx], obsfont);
        p.add(phrase);
        document.add(p);
        newPage = false;
        this.printNotes(cpp.get(issueCodes[idx]));
    }
    //phrase.add(content[idx]);
    //ct.addText(phrase);

    //            //do we need a page break?  check if we're within a fudge factor of the bottom
    //            if( lworkingYcoord <= (bottom * 1.1) && rworkingYcoord <= (bottom*1.1) ) {
    //                document.newPage();
    //                rworkingYcoord = lworkingYcoord = document.top();
    //            }
    //
    //            //Are we in right column?  if so, flip over to left column if there is room
    //            if( column % 2 == 1 ) {
    //                if( lworkingYcoord > bottom ) {
    //                    ct.setSimpleColumn(document.left(), bottom, (document.right()/2f)-10f, lworkingYcoord);
    //                    ++column;
    //                }
    //            }
    //            //Are we in left column?  if so, flip over to right column only if text will fit
    //            else {
    //                ct.setSimpleColumn((document.right()/2f)+10f, bottom, document.right(), rworkingYcoord);
    //
    //                if( ct.go(true) == ColumnText.NO_MORE_COLUMN ) {
    //                    ct.setSimpleColumn(document.left(), bottom, (document.right()/2f)-10f, lworkingYcoord);
    //                }
    //                else {
    //                    ct.setYLine(rworkingYcoord);
    //                    ++column;
    //                }
    //
    //                //ct.go(true) consumes input so we reload
    //                phrase = new Phrase(LEADING, "", font);
    //                chunk = new Chunk(headings[idx], obsfont);
    //                phrase.add(chunk);
    //                phrase.add(content[idx]);
    //                ct.setText(phrase);
    //            }
    //
    //            //while there is text to write, fill columns/page break when page full
    //            while( ct.go() == ColumnText.NO_MORE_COLUMN ) {
    //                if( column % 2 == 0 ) {
    //                    lworkingYcoord = bottom;
    //                    middle = (document.right()/4f)*3f;
    //                    headerContd = headings[idx] + " cont'd";
    //                    cb.setFontAndSize(bf, FONTSIZE);
    //                    cb.showTextAligned(PdfContentByte.ALIGN_CENTER, headerContd, middle, rworkingYcoord-phrase.leading(), 0f);
    //                    //cb.showTextAligned(PdfContentByte.ALIGN_CENTER, headings[idx] + " cont'd", middle, rworkingYcoord, 0f);
    //                    rworkingYcoord -= phrase.leading();
    //                    ct.setSimpleColumn((document.right()/2f)+10f, bottom, document.right(), rworkingYcoord);
    //                }
    //                else {
    //                    document.newPage();
    //                    rworkingYcoord = lworkingYcoord = document.top();
    //                    middle = (document.right()/4f);
    //                    headerContd = headings[idx] + " cont'd";
    //                    cb.setFontAndSize(bf, FONTSIZE);
    //                    cb.showTextAligned(PdfContentByte.ALIGN_CENTER, headerContd, middle, lworkingYcoord-phrase.leading(), 0f);
    //                    lworkingYcoord -= phrase.leading();
    //                    ct.setSimpleColumn(document.left(), bottom, (document.right()/2f)-10f, lworkingYcoord);
    //                }
    //                ++column;
    //            }
    //
    //            if( column % 2 == 0 )
    //                lworkingYcoord -= (ct.getLinesWritten() * ct.getLeading() + (ct.getLeading() * 2f));
    //            else
    //                rworkingYcoord -= (ct.getLinesWritten() * ct.getLeading() + (ct.getLeading() * 2f));
    //        }
    //        cb.endText();
}

From source file:org.oscarehr.casemgmt.service.CaseManagementPrintPdf.java

License:Open Source License

public void printNotes(List<CaseManagementNote> notes) throws DocumentException {

    CaseManagementNote note;/*from  w  ww.j a va2 s  .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
    for (int idx = 0; idx < notes.size(); ++idx) {
        note = notes.get(idx);
        p = new Paragraph();
        //p.setSpacingBefore(font.leading(LINESPACING)*2f);
        phrase = new Phrase(LEADING, "", font);
        chunk = new Chunk("Documentation Date: " + formatter.format(note.getObservation_date()) + "\n",
                obsfont);
        phrase.add(chunk);
        phrase.add(note.getNote() + "\n\n");
        p.add(phrase);
        document.add(p);
    }
}

From source file:org.oscarehr.casemgmt.service.MeasurementPrint.java

License:Open Source License

@Override
public void printExt(CaseManagementPrintPdf engine, HttpServletRequest request)
        throws IOException, DocumentException {
    logger.info("measurement print!!!!");
    MeasurementsDao measurementsDao = (MeasurementsDao) SpringUtils.getBean("measurementsDao");
    String startDate = request.getParameter("pStartDate");
    String endDate = request.getParameter("pEndDate");
    String demographicNo = request.getParameter("demographicNo");

    logger.info("startDate = " + startDate);
    logger.info("endDate = " + endDate);
    logger.info("demographicNo = " + demographicNo);

    List<Measurements> measurements = null;

    if (startDate.equals("") && endDate.equals("")) {
        measurements = measurementsDao.getMeasurements(demographicNo);
    } else {//www.ja v  a2  s  . com
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
            Date dStartDate = formatter.parse(startDate);
            Date dEndDate = formatter.parse(endDate);
            measurements = measurementsDao.getMeasurements(demographicNo, dStartDate, dEndDate);
        } catch (Exception e) {
            logger.error(e);
        }

    }

    if (engine.getNewPage())
        engine.getDocument().newPage();
    else
        engine.setNewPage(true);

    Font obsfont = new Font(engine.getBaseFont(), engine.FONTSIZE, Font.UNDERLINE);

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

    //go through each appt in reverge chronological order, and print the measurements
    String lastDate = null;
    PdfPTable table = null;
    for (Measurements measurement : measurements) {
        boolean newDate = false;
        String date = engine.getFormatter().format(measurement.getDateObserved());
        if (lastDate == null) {
            lastDate = date;
            newDate = true;
        } else {
            if (!lastDate.equals(date)) {
                newDate = true;
                lastDate = date;
            }
        }
        if (newDate) {
            p = new Paragraph();
            phrase = new Phrase(engine.LEADING, "", engine.getFont());
            Chunk chunk = new Chunk("Documentation Date: "
                    + engine.getFormatter().format(measurement.getDateObserved()) + "\n\n", obsfont);
            phrase.add(chunk);
            p.add(phrase);
            table = new PdfPTable(2);
            printMeasurementEntries(date, measurements, table);
            engine.getDocument().add(p);
            engine.getDocument().add(table);
        }

        //
        // engine.getDocument().add(table);                              
    }
    //engine.getDocument().add(p);
}

From source file:org.oscarehr.common.service.PdfRecordPrinter.java

License:Open Source License

public PdfRecordPrinter(HttpServletRequest request, OutputStream os) throws DocumentException, IOException {
    this.request = request;
    this.os = os;
    formatter = new SimpleDateFormat("dd-MMM-yyyy");

    //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);

    //Create the document we are going to write to
    document = new Document();
    writer = PdfWriter.getInstance(document, os);
    writer.setPageEvent(new EndPage());
    writer.setStrictImageSequence(true);

    document.setPageSize(PageSize.LETTER);

    /*//from ww w  .  ja  v a  2  s .c o m
    HeaderFooter footer = new HeaderFooter(new Phrase("-",font),new Phrase("-",font));
    footer.setAlignment(HeaderFooter.ALIGN_CENTER);
    footer.setBorder(0);
            
    document.setFooter(footer);
    */
    document.open();

}

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;//from   ww  w .ja  v a  2 s.  com
    /*
    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.common.service.PdfRecordPrinter.java

License:Open Source License

public void printCPPItem(String heading, Collection<CaseManagementNote> notes) throws DocumentException {
    if (newPage)/*  ww w.  j a  v a  2  s.com*/
        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.common.service.PdfRecordPrinter.java

License:Open Source License

public void printCPPItem(String heading, Measurements measurement) throws DocumentException {
    if (newPage)//from  w  ww.ja  v  a2s  .  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;

    p = new Paragraph();
    phrase = new Phrase(LEADING, "", font);
    //phrase.add(new Chunk(formatter.format(measurement.getDateObserved()) + ":"));
    phrase.add(measurement.getDataField() + "\n");
    p.add(phrase);
    document.add(p);

    // cb.endText();

}

From source file:org.oscarehr.common.service.PdfRecordPrinter.java

License:Open Source License

public void printNotes(Collection<CaseManagementNote> notes, boolean compact) throws DocumentException {

    CaseManagementNote note;//  w w  w . ja  v  a 2  s. 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.getUpdate_date()) + ":"));
        } else {
            chunk = new Chunk("Impression/Plan: (" + formatter.format(note.getUpdate_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.common.service.PdfRecordPrinter.java

License:Open Source License

public void printOcularProcedures(List<EyeformOcularProcedure> ocularProcedures) throws DocumentException {
    ProviderDao providerDao = (ProviderDao) SpringUtils.getBean("providerDao");

    /*/*from   ww  w .ja v  a2  s.  c  o  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, "Ocular Procedures", obsfont);
    p.add(phrase);
    getDocument().add(p);

    for (EyeformOcularProcedure proc : ocularProcedures) {
        p = new Paragraph();
        phrase = new Phrase(LEADING, "", getFont());
        //Chunk chunk = new Chunk("Documentation Date: " + getFormatter().format(proc.getDate()) + "\n", obsfont);
        Chunk chunk = new Chunk(getFormatter().format(proc.getDate()) + " " + proc.getEye() + " "
                + proc.getProcedureName() + " at " + proc.getLocation() + " by "
                + providerDao.getProviderName(proc.getDoctor()) + " " + proc.getProcedureNote() + "\n",
                getFont());
        phrase.add(chunk);
        p.add(phrase);
        getDocument().add(p);
    }
}