Example usage for com.lowagie.text.pdf PdfPCell setPhrase

List of usage examples for com.lowagie.text.pdf PdfPCell setPhrase

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPCell setPhrase.

Prototype

public void setPhrase(Phrase phrase) 

Source Link

Document

Sets the Phrase for this cell.

Usage

From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java

License:Open Source License

/**
 * Creates a table and populates it with the clinic information for the header.
 * @return the table produced/*from   w w  w  . j  a  va 2 s .co m*/
 */
private PdfPTable createClinicInfoHeader() {
    float[] tableWidths;
    PdfPCell cell;
    //tableWidths = new float[]{ 2, 2.5f };
    //PdfPTable infoTable = new PdfPTable(tableWidths);
    PdfPTable infoTable = new PdfPTable(1);
    infoTable.setWidthPercentage(100);
    //cell = new PdfPCell();

    String letterheadName = null;

    if (reqFrm.letterheadName != null && reqFrm.letterheadName.startsWith("prog_")) {
        ProgramDao programDao = (ProgramDao) SpringUtils.getBean("programDao");
        Integer programNo = Integer.parseInt(reqFrm.letterheadName.substring(5));
        letterheadName = programDao.getProgramName(programNo);
    } else if (!reqFrm.letterheadName.equals("-1")) {
        Provider letterheadNameProvider = (reqFrm.letterheadName != null
                ? new RxProviderData().getProvider(reqFrm.letterheadName)
                : null);
        if (letterheadNameProvider != null)
            letterheadName = letterheadNameProvider.getFirstName() + " " + letterheadNameProvider.getSurname();
    } else {
        letterheadName = clinic.getClinicName();
    }

    //PdfPCell cell;
    //PdfPTable infoTable = new PdfPTable(1);

    cell = new PdfPCell(new Phrase(letterheadName, headerFont));

    cell.setBorder(0);
    cell.setPaddingLeft(25);
    infoTable.addCell(cell);

    cell.setPhrase(new Phrase((reqFrm.letterheadAddress != null && reqFrm.letterheadAddress.trim().length() > 0
            ? String.format("%s", reqFrm.letterheadAddress)
            : String.format("%s, %s, %s %s", clinic.getClinicAddress(), clinic.getClinicCity(),
                    clinic.getClinicProvince(), clinic.getClinicPostal())),
            font));
    infoTable.addCell(cell);

    cell.setPhrase(new Phrase(String.format("Tel: %s Fax: %s",
            (reqFrm.letterheadPhone != null && reqFrm.letterheadPhone.trim().length() > 0
                    ? reqFrm.letterheadPhone
                    : clinic.getClinicPhone()),
            (reqFrm.letterheadFax != null && reqFrm.letterheadFax.trim().length() > 0 ? reqFrm.letterheadFax
                    : clinic.getClinicFax())),
            font));
    infoTable.addCell(cell);

    /*
    cell.setPhrase(new Phrase(getResource("msgConsReq"), font));
    cell.setPadding(0);
    cell.setBorder(0);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    infoTable.addCell(cell);
            
    if (reqFrm.pwb.equals("1")){
       cell.setPhrase(new Phrase(getResource("msgPleaseReplyPatient"), boldFont));
    }
            
    else if (org.oscarehr.common.IsPropertiesOn.isMultisitesEnable()) {
       cell.setPhrase(new Phrase("", boldFont));
    }
    else {
       cell.setPhrase(new Phrase(
       String.format("%s %s %s", getResource("msgPleaseReplyPart1"),
                           clinic.getClinicName(),
                           getResource("msgPleaseReplyPart2")), boldFont));
    }
    infoTable.addCell(cell);
    */
    // The last cell in the table is extended to the maximum available height;
    // inserting a blank cell here prevents the last border used to underline text from
    // being displaced to the bottom of this table.
    cell.setPhrase(new Phrase(" ", font));
    cell.setBorder(0);
    cell.setColspan(2);
    infoTable.addCell(cell);

    return infoTable;
}

From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java

License:Open Source License

/**
 * Creates the table containing information about the specialist.
 * @return the table produced//from  ww  w . j av a  2 s.co m
 */
private PdfPTable createSpecialistTable() {
    float[] tableWidths;
    PdfPCell cell = new PdfPCell();
    tableWidths = new float[] { 1.5f, 2.5f };
    PdfPTable infoTable = new PdfPTable(tableWidths);

    infoTable.addCell(setInfoCell(cell, getResource("msgDate")));
    infoTable.addCell(setDataCell(cell, reqFrm.pwb.equals("1") ? getResource("pwb") : reqFrm.referalDate));

    infoTable.addCell(setInfoCell(cell, getResource("msgStatus")));
    infoTable.addCell(setDataCell(cell,
            (reqFrm.urgency.equals("1") ? getResource("msgUrgent")
                    : (reqFrm.urgency.equals("2") ? getResource("msgNUrgent")
                            : (reqFrm.urgency.equals("3")) ? getResource("msgReturn") : "  "))));

    infoTable.addCell(setInfoCell(cell, getResource("msgService")));
    infoTable.addCell(setDataCell(cell, reqFrm.getServiceName(reqFrm.service)));

    infoTable.addCell(setInfoCell(cell, getResource("msgConsultant")));
    infoTable.addCell(setDataCell(cell, reqFrm.getSpecailistsName(reqFrm.specialist)));

    infoTable.addCell(setInfoCell(cell, getResource("msgPhone")));
    if ((reqFrm.getSpecailistsName(reqFrm.specialist).equals("-1"))
            || (reqFrm.getSpecailistsName(reqFrm.specialist).equals(null))
            || (reqFrm.getSpecailistsName(reqFrm.specialist).equals(""))) {
        infoTable.addCell(setDataCell(cell, ""));
    } else {
        infoTable.addCell(setDataCell(cell, reqFrm.specPhone));
    }

    infoTable.addCell(setInfoCell(cell, getResource("msgFax")));
    if ((reqFrm.getSpecailistsName(reqFrm.specialist).equals("-1"))
            || (reqFrm.getSpecailistsName(reqFrm.specialist).equals(null))
            || (reqFrm.getSpecailistsName(reqFrm.specialist).equals(""))) {
        infoTable.addCell(setDataCell(cell, ""));
    } else {
        infoTable.addCell(setDataCell(cell, reqFrm.specFax));
    }

    infoTable.addCell(setInfoCell(cell, getResource("msgAddr")));
    if ((reqFrm.getSpecailistsName(reqFrm.specialist).equals("-1"))
            || (reqFrm.getSpecailistsName(reqFrm.specialist).equals(null))
            || (reqFrm.getSpecailistsName(reqFrm.specialist).equals(""))) {
        infoTable.addCell(setDataCell(cell, ""));
    } else {
        infoTable.addCell(setDataCell(cell, divy(reqFrm.specAddr)));
    }

    // The last cell in the table is extended to the maximum available height;
    // inserting a blank cell here prevents the last border used to underline text from
    // being displaced to the bottom of this table.
    cell.setPhrase(new Phrase(" ", font));
    cell.setBorder(0);
    cell.setColspan(2);
    infoTable.addCell(cell);

    return infoTable;
}

From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java

License:Open Source License

/**
 * Creates the table containing information about the patient.
 * @return the table produced/*from  w ww.j  av a  2 s  .co  m*/
 */
private PdfPTable createPatientTable() {
    float[] tableWidths;
    PdfPCell cell;
    tableWidths = new float[] { 2, 2.5f };
    PdfPTable infoTable = new PdfPTable(tableWidths);
    cell = new PdfPCell();
    infoTable.addCell(setInfoCell(cell, getResource("msgPat")));
    infoTable.addCell(setDataCell(cell, reqFrm.patientName));

    infoTable.addCell(setInfoCell(cell, getResource("msgAddr")));
    infoTable.addCell(setDataCell(cell, divy(reqFrm.patientAddress)));

    infoTable.addCell(setInfoCell(cell, getResource("msgPhone")));
    infoTable.addCell(setDataCell(cell, reqFrm.patientPhone));

    infoTable.addCell(setInfoCell(cell, getResource("msgWPhone")));
    infoTable.addCell(setDataCell(cell, reqFrm.patientWPhone));

    infoTable.addCell(setInfoCell(cell, getResource("msgBirth")));
    infoTable.addCell(setDataCell(cell, reqFrm.patientDOB + " (y/m/d)"));

    infoTable.addCell(setInfoCell(cell, getResource("msgCard")));
    infoTable.addCell(setDataCell(cell, String.format("(%s) %s %s", reqFrm.patientHealthCardType,
            reqFrm.patientHealthNum, reqFrm.patientHealthCardVersionCode)));

    if (!reqFrm.pwb.equals("1")) {
        infoTable.addCell(setInfoCell(cell, getResource("msgappDate")));
        if (!StringUtils.isBlank(reqFrm.appointmentYear)) {
            infoTable.addCell(setDataCell(cell,
                    reqFrm.pwb.equals("1") ? getResource("pwb")
                            : String.format("%s/%s/%s (y/m/d)", reqFrm.appointmentYear, reqFrm.appointmentMonth,
                                    reqFrm.appointmentDay)));
        } else {
            infoTable.addCell(setDataCell(cell, reqFrm.pwb.equals("1") ? getResource("pwb") : ""));
        }
        infoTable.addCell(setInfoCell(cell, getResource("msgTime")));
        if (!StringUtils.isBlank(reqFrm.appointmentHour)) {
            infoTable.addCell(setDataCell(cell, String.format("%s:%s %s", reqFrm.appointmentHour,
                    reqFrm.appointmentMinute, reqFrm.appointmentPm)));
        } else {
            infoTable.addCell(setDataCell(cell, ""));
        }

    }

    infoTable.addCell(setInfoCell(cell, getResource("msgChart")));
    infoTable.addCell(setDataCell(cell, reqFrm.patientChartNo));

    // The last cell in the table is extended to the maximum available height;
    // inserting a blank cell here prevents the last border used to underline text from
    // being displaced to the bottom of this table.
    cell.setPhrase(new Phrase(" ", font));
    cell.setBorder(0);
    cell.setColspan(2);
    infoTable.addCell(cell);

    return infoTable;
}

From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java

License:Open Source License

/**
 * Creates the table containing additional information
 * about the reason for the consultation request.
 * @return the table produced//from ww w.  j a va2s .  c  om
 */
private PdfPTable createConsultDetailTable() {
    PdfPTable infoTable;
    PdfPCell cell;
    infoTable = new PdfPTable(1);
    cell = new PdfPCell();

    infoTable.addCell(setInfoCell2(cell, getResource("msgReason")));
    infoTable.addCell(setDataCell2(cell, reqFrm.reasonForConsultation));

    if (getlen(reqFrm.clinicalInformation) > 1) {
        infoTable.addCell(setInfoCell(cell, getResource("msgClinicalInfom")));
        infoTable.addCell(setDataCell(cell, divy(reqFrm.clinicalInformation)));
    }

    if (getlen(reqFrm.concurrentProblems) > 1) {
        if (props.getProperty("significantConcurrentProblemsTitle", "").length() > 1) {
            infoTable.addCell(setInfoCell(cell, props.getProperty("significantConcurrentProblemsTitle", "")));
        } else {
            infoTable.addCell(setInfoCell(cell, getResource("msgSigProb")));
        }
        infoTable.addCell(setDataCell(cell, divy(reqFrm.concurrentProblems)));
    }

    if (getlen(reqFrm.currentMedications) > 1) {
        if (props.getProperty("currentMedicationsTitle", "").length() > 1) {
            infoTable.addCell(setInfoCell(cell, props.getProperty("currentMedicationsTitle", "")));
        } else {
            infoTable.addCell(setInfoCell(cell, getResource("msgCurrMed")));
        }
        infoTable.addCell(setDataCell(cell, divy(reqFrm.currentMedications)));
    }

    if (getlen(reqFrm.allergies) > 1) {
        infoTable.addCell(setInfoCell(cell, getResource("msgAllergies")));
        infoTable.addCell(setDataCell(cell, divy(reqFrm.allergies)));
    }

    if (getlen(reqFrm.ocularExamination) > 1) {
        infoTable.addCell(setInfoCell(cell, getResource("msgOcularExamination")));
        infoTable.addCell(setDataCell(cell, divy(reqFrm.ocularExamination)));
    }

    ProviderDao proDAO = (ProviderDao) SpringUtils.getBean("providerDao");
    org.oscarehr.common.model.Provider pro = proDAO.getProvider(reqFrm.providerNo);
    String billingNo = pro.getBillingNo();
    DemographicDao demoDAO = (DemographicDao) SpringUtils.getBean("demographicDao");
    Demographic demo = demoDAO.getDemographic(reqFrm.demoNo);
    pro = proDAO.getProvider(demo.getProviderNo());
    String famDocBillingNo = pro.getBillingNo();
    //infoTable.addCell(setFooterCell(cell, getResource("msgAssociated2"), reqFrm.getProviderName(reqFrm.providerNo) + ((getlen(billingNo) > 0) ? " (" + billingNo + ")" : "")));
    //infoTable.addCell(setFooterCell(cell, getResource("msgFamilyDoc2"), reqFrm.getFamilyDoctor() + ((getlen(famDocBillingNo) > 0) ? " (" + famDocBillingNo + ")" : "")));
    if (props.getProperty("CONSULTATION_SIGNATURE_LINE1") != null) {
        cell.setPadding(0);
        cell.setBorder(0);
        cell.setPhrase(new Phrase(props.getProperty("CONSULTATION_SIGNATURE_LINE1")));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        infoTable.addCell(cell);

        if (props.getProperty("CONSULTATION_SIGNATURE_LINE2") != null) {
            cell.setPadding(0);
            cell.setBorder(0);
            cell.setPhrase(new Phrase(props.getProperty("CONSULTATION_SIGNATURE_LINE2")));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            infoTable.addCell(cell);
        }
        if (props.getProperty("CONSULTATION_SIGNATURE_LINE3") != null) {
            cell.setPadding(0);
            cell.setBorder(0);
            cell.setPhrase(new Phrase(props.getProperty("CONSULTATION_SIGNATURE_LINE3")));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            infoTable.addCell(cell);
        }
    } else {
        infoTable.addCell(setFooterCell(cell, getResource("msgAssociated2"), reqFrm.getFamilyDoctor()
                + ((getlen(famDocBillingNo) > 0) ? " (" + famDocBillingNo + ")" : "")));
        infoTable.addCell(
                setFooterCell(cell, getResource("msgCreatedBy"), reqFrm.getProviderName(reqFrm.providerNo)
                        + ((getlen(billingNo) > 0) ? " (" + billingNo + ")" : "")));
    }

    if (getlen(reqFrm.signatureImg) > 0) {
        addSignature(infoTable);
    }
    return infoTable;
}

From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java

License:Open Source License

/**
 * Formats a cell to display information provided in a regular font with an underline.
 * @param cell the cell to format/*  w w w  .j a  va  2 s.  c  om*/
 * @param phrase the information to display
 * @return the formatted cell
 */
private PdfPCell setDataCell(PdfPCell cell, String phrase) {
    cell.setPhrase(new Phrase(phrase, font));
    cell.setBorderWidthBottom(0.75f);
    return cell;
}

From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java

License:Open Source License

private PdfPCell setDataCell2(PdfPCell cell, String phrase) {
    cell.setPhrase(new Phrase(phrase, boldFont));
    cell.setBorderWidthBottom(0.75f);/*from   ww w  .  j av  a 2s.  co m*/
    return cell;
}

From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java

License:Open Source License

/**
 * Formats a cell to display information provided in a slightly larger font and followed by a colon.
 * @param cell the cell to format/*www.ja v a 2 s.  co  m*/
 * @param phrase the information to display
 * @return the formatted cell
 */
private PdfPCell setInfoCell(PdfPCell cell, String phrase) {
    cell.setPhrase(new Phrase(phrase + ":", infoFont));
    cell.setBorder(0);
    return cell;
}

From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java

License:Open Source License

private PdfPCell setInfoCell2(PdfPCell cell, String phrase) {
    cell.setPhrase(new Phrase(phrase + ":", boldFont));
    cell.setBorder(0);//from   w  w w .  ja v a 2s .c  o  m
    return cell;
}

From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java

License:Open Source License

/**
 * Formats a cell to display on the same line both the information style (larger text followed by colon) and
 * the data in a normal font on the same line.
 * @param cell the cell to format//from  w  w  w  .  j a  v  a  2s .  com
 * @param info the information heading
 * @param data the data value
 * @return the formatted cell
 */
private PdfPCell setFooterCell(PdfPCell cell, String info, String data) {
    cell.setPhrase(new Phrase(String.format("%s %s %s", info, getlen(data) > 0 ? ":" : "", data)));
    cell.setBorder(0);
    return cell;
}

From source file:oscar.oscarLab.ca.all.pageUtil.LabPDFCreator.java

License:Open Source License

public void printPdf() throws IOException, DocumentException {

    // check that we have data to print
    if (handler == null)
        throw new DocumentException();

    //response.setContentType("application/pdf");  //octet-stream
    //response.setHeader("Content-Disposition", "attachment; filename=\""+handler.getPatientName().replaceAll("\\s", "_")+"_LabReport.pdf\"");

    //Create the document we are going to write to
    document = new Document();
    //PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
    PdfWriter writer = PdfWriter.getInstance(document, os);

    //Set page event, function onEndPage will execute each time a page is finished being created
    writer.setPageEvent(this);

    document.setPageSize(PageSize.LETTER);
    document.addTitle("Title of the Document");
    document.addCreator("OSCAR");
    document.open();// w w w .  j ava 2s . co m

    //Create the fonts that we are going to use
    bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    font = new Font(bf, 9, Font.NORMAL);
    boldFont = new Font(bf, 10, Font.BOLD);
    redFont = new Font(bf, 9, Font.NORMAL, Color.RED);

    // add the header table containing the patient and lab info to the document
    createInfoTable();

    // add the tests and test info for each header
    ArrayList<String> headers = handler.getHeaders();
    for (int i = 0; i < headers.size(); i++)
        addLabCategory(headers.get(i));

    // add end of report table
    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100);
    PdfPCell cell = new PdfPCell();
    cell.setBorder(0);
    cell.setPhrase(new Phrase("  "));
    table.addCell(cell);
    cell.setBorder(15);
    cell.setBackgroundColor(new Color(210, 212, 255));
    cell.setPhrase(new Phrase("END OF REPORT", boldFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);
    document.add(table);

    document.close();

    os.flush();
}