Example usage for com.lowagie.text Paragraph setAlignment

List of usage examples for com.lowagie.text Paragraph setAlignment

Introduction

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

Prototype

public void setAlignment(String alignment) 

Source Link

Document

Sets the alignment of this paragraph.

Usage

From source file:org.mapfish.print.config.layout.TextBlock.java

License:Open Source License

public void render(PJsonObject params, PdfElement target, final RenderingContext context)
        throws DocumentException {
    Paragraph paragraph = new Paragraph();

    final Font pdfFont = getPdfFont();
    paragraph.setFont(pdfFont);//from   w w  w .j av a  2 s. c  om

    final Phrase text = PDFUtils.renderString(context, params, this.text, pdfFont);
    paragraph.add(text);

    if (getAlign() != null)
        paragraph.setAlignment(getAlign().getCode());
    paragraph.setSpacingAfter((float) spacingAfter);
    target.add(paragraph);
}

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 .j  a v a  2 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.ExportToPDF14.java

License:Open Source License

private void prepareGrid(PdfPTable parentTable, int parentTableCols, Document document,
        ExportOptions exportOptions, GridExportOptions opt) throws Throwable {
    // prepare vo getters methods...
    String methodName = null;//  w ww.j  a v  a 2 s . co m
    String attributeName = null;
    Hashtable gettersMethods = new Hashtable();
    Method[] voMethods = opt.getValueObjectType().getMethods();
    for (int i = 0; i < voMethods.length; i++) {
        methodName = voMethods[i].getName();
        if (methodName.startsWith("get")) {
            attributeName = methodName.substring(3, 4).toLowerCase() + methodName.substring(4);
            if (opt.getExportAttrColumns().contains(attributeName))
                gettersMethods.put(attributeName, voMethods[i]);
        }
    }

    Response response = null;
    int start = 0;
    int rownum = 0;
    Object value = null;
    Object vo = null;
    int type;

    SimpleDateFormat sdf = new SimpleDateFormat(exportOptions.getDateFormat());
    SimpleDateFormat sdatf = new SimpleDateFormat(exportOptions.getDateTimeFormat());
    SimpleDateFormat stf = new SimpleDateFormat(exportOptions.getTimeFormat());

    int headerwidths[] = new int[opt.getExportColumns().size()];
    int total = 0;
    for (int i = 0; i < opt.getExportColumns().size(); i++) {
        headerwidths[i] = Math.max(opt.getExportColumns().get(i).toString().length() * 10,
                ((Integer) opt.getColumnsWidth().get(opt.getExportAttrColumns().get(i))).intValue());
        total += headerwidths[i];
    }

    Paragraph line = null;
    if (opt.getTitle() != null && !opt.getTitle().equals("")) {
        line = new Paragraph(opt.getTitle(), (Font) exportOptions.getExportToPDFAdapter().getFontTitle());
        line.setAlignment(Element.ALIGN_CENTER);
        document.add(line);
        document.add(new Paragraph("\n"));
    }
    String[] filters = opt.getFilteringConditions();
    if (filters != null) {
        for (int i = 0; i < filters.length; i++) {
            line = new Paragraph(filters[i]);
            document.add(line);
        }
        document.add(new Paragraph("\n"));
    }

    PdfPTable table = new PdfPTable(opt.getExportColumns().size());
    table.setWidths(headerwidths);
    table.setWidthPercentage(90);
    table.getDefaultCell().setBorderWidth(2);
    table.getDefaultCell().setBorderColor(Color.black);
    table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getHeaderGrayFill());
    table.getDefaultCell().setPadding(3);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);

    for (int i = 0; i < opt.getExportColumns().size(); i++)
        table.addCell(new Phrase(opt.getExportColumns().get(i).toString(), (Font) exportOptions
                .getExportToPDFAdapter().getHeaderFont(opt.getExportAttrColumns().get(i).toString())));

    table.setHeaderRows(1);
    table.getDefaultCell().setBorderWidth(1);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);

    for (int j = 0; j < opt.getTopRows().size(); j++) {
        // create a row for each top rows...
        table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getTopRowsGrayFill(j));
        vo = opt.getTopRows().get(j);
        appendRow(document, exportOptions, table, vo, opt, gettersMethods, sdf, sdatf, stf, j, 0);
    }

    do {
        response = opt.getGridDataLocator().loadData(GridParams.NEXT_BLOCK_ACTION, start,
                opt.getFilteredColumns(), opt.getCurrentSortedColumns(), opt.getCurrentSortedVersusColumns(),
                opt.getValueObjectType(), opt.getOtherGridParams());
        if (response.isError())
            throw new Exception(response.getErrorMessage());

        boolean even = false;

        for (int j = 0; j < ((VOListResponse) response).getRows().size(); j++) {
            if (even) {
                table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getEvenRowsGrayFill());
                even = false;
            } else {
                table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getOddRowsGrayFill());
                even = true;
            }

            vo = ((VOListResponse) response).getRows().get(j);

            appendRow(document, exportOptions, table, vo, opt, gettersMethods, sdf, sdatf, stf, rownum, 1);

            rownum++;
        }

        start = start + ((VOListResponse) response).getRows().size();

        if (!((VOListResponse) response).isMoreRows())
            break;
    } while (rownum < opt.getMaxRows());

    for (int j = 0; j < opt.getBottomRows().size(); j++) {
        // create a row for each bottom rows...
        table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getBottomRowsGrayFill(j));
        vo = opt.getBottomRows().get(j);
        appendRow(document, exportOptions, table, vo, opt, gettersMethods, sdf, sdatf, stf, j, 2);
    }

    if (parentTable != null) {
        PdfPCell cell = new PdfPCell(table);
        cell.setColspan(parentTableCols);
        parentTable.addCell(cell);
    } else
        document.add(table);

}

From source file:org.openswing.swing.export.java.ExportToRTF14.java

License:Open Source License

private void prepareGrid(Table parentTable, int parentTableCols, Document document, ExportOptions exportOptions,
        GridExportOptions opt) throws Throwable {
    // prepare vo getters methods...
    String methodName = null;/*from w  w  w.  j a  va 2 s.  co  m*/
    String attributeName = null;
    Hashtable gettersMethods = new Hashtable();
    Method[] voMethods = opt.getValueObjectType().getMethods();
    for (int i = 0; i < voMethods.length; i++) {
        methodName = voMethods[i].getName();
        if (methodName.startsWith("get")) {
            attributeName = methodName.substring(3, 4).toLowerCase() + methodName.substring(4);
            if (opt.getExportAttrColumns().contains(attributeName))
                gettersMethods.put(attributeName, voMethods[i]);
        }
    }

    Response response = null;
    int start = 0;
    int rownum = 0;
    Object value = null;
    Object vo = null;
    int type;

    SimpleDateFormat sdf = new SimpleDateFormat(exportOptions.getDateFormat());
    SimpleDateFormat sdatf = new SimpleDateFormat(exportOptions.getDateTimeFormat());
    SimpleDateFormat stf = new SimpleDateFormat(exportOptions.getTimeFormat());

    int headerwidths[] = new int[opt.getExportColumns().size()];
    int total = 0;
    for (int i = 0; i < opt.getExportColumns().size(); i++) {
        headerwidths[i] = Math.max(opt.getExportColumns().get(i).toString().length() * 10,
                ((Integer) opt.getColumnsWidth().get(opt.getExportAttrColumns().get(i))).intValue());
        total += headerwidths[i];
    }

    //    Document document = new Document();
    //    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    //    RtfWriter2 w = RtfWriter2.getInstance(document,baos);
    //    document.open();

    Paragraph line = null;
    if (opt.getTitle() != null && !opt.getTitle().equals("")) {
        line = new Paragraph(opt.getTitle(), (Font) exportOptions.getExportToRTFAdapter().getFontTitle());
        line.setAlignment(Element.ALIGN_CENTER);
        document.add(line);
        document.add(new Paragraph(""));
    }
    String[] filters = opt.getFilteringConditions();
    if (filters != null) {
        for (int i = 0; i < filters.length; i++) {
            line = new Paragraph(filters[i]);
            document.add(line);
        }
        document.add(new Paragraph(""));
    }

    Table table = new Table(opt.getExportColumns().size());
    table.setWidths(headerwidths);
    table.setBorderWidth(2);
    table.setBorderColor(Color.black);
    table.setGrayFill(exportOptions.getExportToRTFAdapter().getHeaderGrayFill());
    table.setPadding(3);

    Phrase cell = null;
    for (int i = 0; i < opt.getExportColumns().size(); i++) {
        cell = new Phrase(opt.getExportColumns().get(i).toString(), (Font) exportOptions.getExportToRTFAdapter()
                .getHeaderFont(opt.getExportAttrColumns().get(i).toString()));
        table.addCell(cell);
    }
    //    table.setHeaderRows(1);
    //    table.getDefaultCell().setBorderWidth(1);
    //    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    //    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);

    for (int j = 0; j < opt.getTopRows().size(); j++) {
        // create a row for each top rows...
        vo = opt.getTopRows().get(j);
        appendRow(document, exportOptions, table, vo, opt, gettersMethods, sdf, sdatf, stf, j, 0);
    }

    do {
        response = opt.getGridDataLocator().loadData(GridParams.NEXT_BLOCK_ACTION, start,
                opt.getFilteredColumns(), opt.getCurrentSortedColumns(), opt.getCurrentSortedVersusColumns(),
                opt.getValueObjectType(), opt.getOtherGridParams());
        if (response.isError())
            throw new Exception(response.getErrorMessage());

        boolean even = false;

        for (int j = 0; j < ((VOListResponse) response).getRows().size(); j++) {
            if (even) {
                even = false;
            } else {
                even = true;
            }

            vo = ((VOListResponse) response).getRows().get(j);

            appendRow(document, exportOptions, table, vo, opt, gettersMethods, sdf, sdatf, stf, rownum, 1);

            rownum++;
        }

        start = start + ((VOListResponse) response).getRows().size();

        if (!((VOListResponse) response).isMoreRows())
            break;
    } while (rownum < opt.getMaxRows());

    for (int j = 0; j < opt.getBottomRows().size(); j++) {
        // create a row for each bottom rows...
        table.setGrayFill(exportOptions.getExportToRTFAdapter().getBottomRowsGrayFill(j));
        vo = opt.getBottomRows().get(j);
        appendRow(document, exportOptions, table, vo, opt, gettersMethods, sdf, sdatf, stf, j, 2);
    }

    //    rtfTable.importTable(table,total);
    if (parentTable != null) {
        Cell c = new Cell(table);
        //      c.setColspan(parentTableCols);
        parentTable.addCell(c);
        //      table.setCellsFitPage(true);
        //      parentTable.insertTable(table,new Point(parentTable.getNextRow()+1,0));

    } else
        document.add(table);

    //    document.add(table);
}

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  a  2  s.c o  m
    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

public void printMasterRecord() throws DocumentException {
    if (newPage) {
        document.newPage();/*from w  ww .  j  a  va 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)/*from 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.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.casemgmt.print.OscarChartPrinter.java

License:Open Source License

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

    /*//ww w.j a  v a  2 s  .  c om
         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()));
}

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

License:Open Source License

public void printRx(String demoNo, List<CaseManagementNote> cpp) throws DocumentException {
    if (demoNo == null)
        return;/*from   w w  w  . j a v a 2  s  .  c  o m*/
    /*
    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);
        }
    }

}