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

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

Introduction

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

Prototype

public PdfPCell(PdfPCell cell) 

Source Link

Document

Constructs a deep copy of a PdfPCell.

Usage

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

License:Open Source License

public void printDocHeaderFooter() throws DocumentException {
    String headerTitle = demographic.getFormattedName() + " " + demographic.getAge() + " "
            + demographic.getSex() + " DOB:" + demographic.getFormattedDob();

    //set up document title and header
    ResourceBundle propResource = ResourceBundle.getBundle("oscarResources");
    String title = propResource.getString("oscarEncounter.pdfPrint.title") + " "
            + (String) request.getAttribute("demoName") + "\n";
    String gender = propResource.getString("oscarEncounter.pdfPrint.gender") + " "
            + (String) request.getAttribute("demoSex") + "\n";
    String dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " "
            + (String) request.getAttribute("demoDOB") + "\n";
    String age = propResource.getString("oscarEncounter.pdfPrint.age") + " "
            + (String) request.getAttribute("demoAge") + "\n";
    String mrp = propResource.getString("oscarEncounter.pdfPrint.mrp") + " "
            + (String) request.getAttribute("mrp") + "\n";
    String[] info = new String[] { title, gender, dob, age, mrp };

    ClinicData clinicData = new ClinicData();
    clinicData.refreshClinicData();/*from   w  w w .j a v a2  s  .com*/
    String[] clinic = new String[] { clinicData.getClinicName(), clinicData.getClinicAddress(),
            clinicData.getClinicCity() + ", " + clinicData.getClinicProvince(), clinicData.getClinicPostal(),
            clinicData.getClinicPhone() };

    if (newPage) {
        document.newPage();
        newPage = false;
    }

    //Header will be printed at top of every page beginning with p2
    Phrase headerPhrase = new Phrase(LEADING, headerTitle, boldFont);
    HeaderFooter header = new HeaderFooter(headerPhrase, false);
    header.setAlignment(HeaderFooter.ALIGN_CENTER);
    document.setHeader(header);

    getDocument().add(headerPhrase);
    getDocument().add(new Phrase("\n"));

    Paragraph p = new Paragraph("Tel:" + demographic.getPhone(), getFont());
    p.setAlignment(Paragraph.ALIGN_LEFT);
    // getDocument().add(p);

    Paragraph p2 = new Paragraph("Date of Visit: ", getFont());
    p2.setAlignment(Paragraph.ALIGN_RIGHT);
    // getDocument().add(p);

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    PdfPCell cell1 = new PdfPCell(p);
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    PdfPCell cell2 = new PdfPCell(p2);
    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell2.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);

    getDocument().add(table);

    table = new PdfPTable(3);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    cell1 = new PdfPCell(getParagraph("Signed Provider:" + ((signingProvider != null) ? signingProvider : "")));
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2 = new PdfPCell(getParagraph("RFR:"));
    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell2.setBorder(PdfPCell.NO_BORDER);
    PdfPCell cell3 = new PdfPCell(getParagraph("Ref:"));
    cell3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell3.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);
    table.addCell(cell3);

    getDocument().add(table);

    //Write title with top and bottom borders on p1
    cb = writer.getDirectContent();
    cb.setColorStroke(new Color(0, 0, 0));
    cb.setLineWidth(0.5f);

    cb.moveTo(document.left(), document.top() - (font.getCalculatedLeading(LINESPACING) * 5f));
    cb.lineTo(document.right(), document.top() - (font.getCalculatedLeading(LINESPACING) * 5f));
    cb.stroke();
}

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

License:Open Source License

private PdfPCell generalCellForApptHistory(String text) {
    Paragraph p = new Paragraph(text, getFont());
    p.setAlignment(Paragraph.ALIGN_LEFT);
    PdfPCell cell1 = new PdfPCell(p);
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    return cell1;

}

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

License:Open Source License

public void printDocHeaderFooter() throws DocumentException {
    document.resetHeader();//from   ww w  .  ja  va  2  s  .  c o  m
    document.resetFooter();
    //document.resetPageCount();
    String headerTitle = demographic.getFormattedName() + " " + demographic.getAge() + " "
            + demographic.getSex() + " DOB:" + demographic.getFormattedDob();

    //set up document title and header
    ResourceBundle propResource = ResourceBundle.getBundle("oscarResources");
    String title = propResource.getString("oscarEncounter.pdfPrint.title") + " "
            + (String) request.getAttribute("demoName") + "\n";
    String gender = propResource.getString("oscarEncounter.pdfPrint.gender") + " "
            + (String) request.getAttribute("demoSex") + "\n";
    String dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " "
            + (String) request.getAttribute("demoDOB") + "\n";
    String age = propResource.getString("oscarEncounter.pdfPrint.age") + " "
            + (String) request.getAttribute("demoAge") + "\n";
    String mrp = propResource.getString("oscarEncounter.pdfPrint.mrp") + " "
            + (String) request.getAttribute("mrp") + "\n";
    String[] info = new String[] { title, gender, dob, age, mrp };

    ClinicData clinicData = new ClinicData();
    clinicData.refreshClinicData();
    String[] clinic = new String[] { clinicData.getClinicName(), clinicData.getClinicAddress(),
            clinicData.getClinicCity() + ", " + clinicData.getClinicProvince(), clinicData.getClinicPostal(),
            clinicData.getClinicPhone() };

    if (newPage) {
        document.newPage();
        newPage = false;
    }

    //Header will be printed at top of every page beginning with p2

    Phrase headerPhrase = new Phrase(LEADING, headerTitle, boldFont);
    /*
            HeaderFooter header = new HeaderFooter(headerPhrase,false);
            header.setAlignment(HeaderFooter.ALIGN_CENTER);
            document.setHeader(header);
    */
    getDocument().add(headerPhrase);
    getDocument().add(new Phrase("\n"));

    Paragraph p = new Paragraph("Tel:" + demographic.getPhone(), getFont());
    p.setAlignment(Paragraph.ALIGN_LEFT);
    // getDocument().add(p);

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Paragraph p2 = new Paragraph("Date of Visit: " + sdf.format(appointment.getAppointmentDate()), getFont());
    p2.setAlignment(Paragraph.ALIGN_RIGHT);
    // getDocument().add(p);

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    PdfPCell cell1 = new PdfPCell(p);
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    PdfPCell cell2 = new PdfPCell(p2);
    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell2.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);

    getDocument().add(table);

    table = new PdfPTable(3);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    cell1 = new PdfPCell(getParagraph("Signed Provider:" + ((signingProvider != null) ? signingProvider : "")));
    cell1.setBorder(PdfPCell.BOTTOM);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2 = new PdfPCell(getParagraph("RFR:" + this.appointment.getReason()));
    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell2.setBorder(PdfPCell.BOTTOM);
    PdfPCell cell3 = new PdfPCell(getParagraph("Ref:" + this.getRefName(this.demographic)));
    cell3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell3.setBorder(PdfPCell.BOTTOM);
    table.addCell(cell1);
    table.addCell(cell2);
    table.addCell(cell3);
    getDocument().add(table);

    /*
    HeaderFooter footer = new HeaderFooter(new Phrase("-",font),new Phrase("-",font));
    footer.setAlignment(HeaderFooter.ALIGN_CENTER);
    footer.setBorder(0);
            
    document.setFooter(footer);
    */

    //Write title with top and bottom borders on p1

    // cb = writer.getDirectContent();
    /*
    cb.setColorStroke(new Color(0,0,0));
    cb.setLineWidth(0.5f);
    * 
    cb.moveTo(document.left(), document.top() - (font.getCalculatedLeading(LINESPACING)*5f));
    cb.lineTo(document.right(), document.top() - (font.getCalculatedLeading(LINESPACING)*5f));
    cb.stroke();     
    */
}

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

License:Open Source License

public void printSpecsHistory(List<EyeformSpecsHistory> specsHistory) throws DocumentException {
    ProviderDao providerDao = (ProviderDao) SpringUtils.getBean("providerDao");

    /*//from   ww w  . ja va 2  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, "Specs History", obsfont);
    p.add(phrase);
    getDocument().add(p);

    PdfPTable table = new PdfPTable(2);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    table.setSpacingBefore(10f);
    table.setSpacingAfter(10f);
    table.setTotalWidth(new float[] { 10f, 60f });
    table.setTotalWidth(5f);
    table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

    for (EyeformSpecsHistory specs : specsHistory) {
        PdfPCell cell1 = new PdfPCell(new Phrase(getFormatter().format(specs.getDate()), getFont()));
        cell1.setBorder(PdfPCell.NO_BORDER);
        cell1.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        table.addCell(cell1);

        PdfPCell cell2 = new PdfPCell(new Phrase(specs.toString2(), getFont()));
        cell2.setBorder(PdfPCell.NO_BORDER);
        cell2.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        table.addCell(cell2);
    }

    getDocument().add(table);
}