Example usage for com.lowagie.text Font NORMAL

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

Introduction

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

Prototype

int NORMAL

To view the source code for com.lowagie.text Font NORMAL.

Click Source Link

Document

this is a possible style.

Usage

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 a v a  2  s .co  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.netxilia.server.rest.pdf.SheetPdfProvider.java

License:Open Source License

@Override
public void writeTo(SheetFullName sheetName, Class<?> clazz, Type type, Annotation[] ann, MediaType mediaType,
        MultivaluedMap<String, Object> headers, OutputStream out) throws IOException, WebApplicationException {

    if (sheetName == null) {
        return;//from   w  w w.  ja  va2 s. c  o  m
    }

    /**
     * This is the table, added as an Element to the PDF document. It contains all the data, needed to represent the
     * visible table into the PDF
     */
    Table tablePDF;

    /**
     * The default font used in the document.
     */
    Font smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0, 0, 0));
    ISheet summarySheet = null;
    ISheet sheet = null;
    try {
        sheet = workbookProcessor.getWorkbook(sheetName.getWorkbookId()).getSheet(sheetName.getSheetName());
        try {
            // get the corresponding summary sheet
            SheetFullName summarySheetName = SheetFullName.summarySheetName(sheetName,
                    userService.getCurrentUser());
            summarySheet = workbookProcessor.getWorkbook(summarySheetName.getWorkbookId())
                    .getSheet(summarySheetName.getSheetName());

        } catch (Exception e) {
            // no summary sheet - go without one
        }

        // Initialize the Document and register it with PdfWriter listener and the OutputStream
        Document document = new Document(PageSize.A4.rotate(), 60, 60, 40, 40);
        document.addCreationDate();
        HeaderFooter footer = new HeaderFooter(new Phrase("", smallFont), true);
        footer.setBorder(Rectangle.NO_BORDER);
        footer.setAlignment(Element.ALIGN_CENTER);

        PdfWriter.getInstance(document, out);

        // Fill the virtual PDF table with the necessary data
        // Initialize the table with the appropriate number of columns
        tablePDF = initTable(sheet);
        // take tha maximum numbers of columns
        int columnCount = sheet.getDimensions().getNonBlocking().getColumnCount();
        if (summarySheet != null) {
            columnCount = Math.max(columnCount, summarySheet.getDimensions().getNonBlocking().getColumnCount());
        }
        generateHeaders(sheet, tablePDF, smallFont, columnCount);

        tablePDF.endHeaders();
        generateRows(sheet, false, tablePDF, smallFont, columnCount);
        if (summarySheet != null) {
            generateRows(summarySheet, true, tablePDF, smallFont, columnCount);
        }

        document.open();
        document.setFooter(footer);
        document.add(tablePDF);
        document.close();

        out.flush();
        out.close();

    } catch (Exception e) {
        throw new IOException(e);
    }
}

From source file:org.nuxeo.ecm.platform.signature.core.sign.SignatureServiceImpl.java

License:Open Source License

@Override
public Blob signPDF(Blob pdfBlob, DocumentModel user, String keyPassword, String reason)
        throws ClientException {
    CertService certService = Framework.getLocalService(CertService.class);
    CUserService cUserService = Framework.getLocalService(CUserService.class);
    try {/*w  w  w.  j a  v  a  2 s.co  m*/
        File outputFile = File.createTempFile("signed-", ".pdf");
        Blob blob = Blobs.createBlob(outputFile, MIME_TYPE_PDF);
        Framework.trackFile(outputFile, blob);

        PdfReader pdfReader = new PdfReader(pdfBlob.getStream());
        List<X509Certificate> pdfCertificates = getCertificates(pdfReader);

        // allows for multiple signatures
        PdfStamper pdfStamper = PdfStamper.createSignature(pdfReader, new FileOutputStream(outputFile), '\0',
                null, true);

        PdfSignatureAppearance pdfSignatureAppearance = pdfStamper.getSignatureAppearance();
        String userID = (String) user.getPropertyValue("user:username");
        AliasWrapper alias = new AliasWrapper(userID);
        KeyStore keystore = cUserService.getUserKeystore(userID, keyPassword);
        Certificate certificate = certService.getCertificate(keystore, alias.getId(AliasType.CERT));
        KeyPair keyPair = certService.getKeyPair(keystore, alias.getId(AliasType.KEY),
                alias.getId(AliasType.CERT), keyPassword);

        if (certificatePresentInPDF(certificate, pdfCertificates)) {
            X509Certificate userX509Certificate = (X509Certificate) certificate;
            String message = ALREADY_SIGNED_BY + userX509Certificate.getSubjectDN();
            log.debug(message);
            throw new AlreadySignedException(message);
        }

        List<Certificate> certificates = new ArrayList<Certificate>();
        certificates.add(certificate);

        Certificate[] certChain = certificates.toArray(new Certificate[0]);
        pdfSignatureAppearance.setCrypto(keyPair.getPrivate(), certChain, null,
                PdfSignatureAppearance.SELF_SIGNED);
        if (StringUtils.isBlank(reason)) {
            reason = getSigningReason();
        }
        pdfSignatureAppearance.setReason(reason);
        pdfSignatureAppearance.setAcro6Layers(true);
        Font layer2Font = FontFactory.getFont(FontFactory.TIMES, getSignatureLayout().getTextSize(),
                Font.NORMAL, new Color(0x00, 0x00, 0x00));
        pdfSignatureAppearance.setLayer2Font(layer2Font);
        pdfSignatureAppearance.setRender(PdfSignatureAppearance.SignatureRenderDescription);

        pdfSignatureAppearance.setVisibleSignature(getNextCertificatePosition(pdfReader, pdfCertificates), 1,
                null);

        pdfStamper.close(); // closes the file

        log.debug("File " + outputFile.getAbsolutePath() + " created and signed with " + reason);

        return blob;
    } catch (IOException e) {
        throw new SignException(e);
    } catch (DocumentException e) {
        // iText PDF stamping
        throw new SignException(e);
    } catch (IllegalArgumentException e) {
        if (String.valueOf(e.getMessage()).contains("PdfReader not opened with owner password")) {
            // iText PDF reading
            throw new SignException("PDF is password-protected");
        }
        throw new SignException(e);
    }
}

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();/*  www  . j  a  va 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 printRx(String demoNo, List<CaseManagementNote> cpp) throws DocumentException {
    if (demoNo == null)
        return;//w  ww .j  a  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);
        }
    }

}

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

License:Open Source License

public void printDocHeaderFooter() throws IOException, DocumentException {
    //Create the document we are going to write to
    document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, os);
    writer.setPageEvent(new EndPage());
    document.setPageSize(PageSize.LETTER);
    document.open();/* w w  w  . ja  v a2s. 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);

    String title = "", gender = "", dob = "", age = "", mrp = "";
    if (this.demoDtl != null) {
        //set up document title and header
        ResourceBundle propResource = ResourceBundle.getBundle("oscarResources");
        title = propResource.getString("oscarEncounter.pdfPrint.title") + " " + (String) demoDtl.get("demoName")
                + "\n";
        gender = propResource.getString("oscarEncounter.pdfPrint.gender") + " "
                + (String) demoDtl.get("demoSex") + "\n";
        dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " " + (String) demoDtl.get("demoDOB")
                + "\n";
        age = propResource.getString("oscarEncounter.pdfPrint.age") + " " + (String) demoDtl.get("demoAge")
                + "\n";
        mrp = propResource.getString("oscarEncounter.pdfPrint.mrp") + " " + (String) demoDtl.get("mrp") + "\n";
    } else {
        //set up document title and header
        ResourceBundle propResource = ResourceBundle.getBundle("oscarResources");
        title = propResource.getString("oscarEncounter.pdfPrint.title") + " "
                + (String) request.getAttribute("demoName") + "\n";
        gender = propResource.getString("oscarEncounter.pdfPrint.gender") + " "
                + (String) request.getAttribute("demoSex") + "\n";
        dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " "
                + (String) request.getAttribute("demoDOB") + "\n";
        age = propResource.getString("oscarEncounter.pdfPrint.age") + " "
                + (String) request.getAttribute("demoAge") + "\n";
        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(), "Fax: " + clinicData.getClinicFax() };

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

    //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());
    cb.lineTo(document.right(), document.top());
    cb.stroke();
    //cb.setFontAndSize(bf, FONTSIZE);

    upperYcoord = document.top() - (font.getCalculatedLeading(LINESPACING) * 2f);

    ColumnText ct = new ColumnText(cb);
    Paragraph p = new Paragraph();
    p.setAlignment(Paragraph.ALIGN_LEFT);
    Phrase phrase = new Phrase();
    Phrase dummy = new Phrase();
    for (int idx = 0; idx < clinic.length; ++idx) {
        phrase.add(clinic[idx] + "\n");
        dummy.add("\n");
        upperYcoord -= phrase.getLeading();
    }

    dummy.add("\n");
    ct.setSimpleColumn(document.left(), upperYcoord, document.right() / 2f, document.top());
    ct.addElement(phrase);
    ct.go();

    p.add(dummy);
    document.add(p);

    //add patient info
    phrase = new Phrase();
    p = new Paragraph();
    p.setAlignment(Paragraph.ALIGN_RIGHT);
    for (int idx = 0; idx < info.length; ++idx) {
        phrase.add(info[idx]);
    }

    ct.setSimpleColumn(document.right() / 2f, upperYcoord, document.right(), document.top());
    p.add(phrase);
    ct.addElement(p);
    ct.go();

    cb.moveTo(document.left(), upperYcoord);
    cb.lineTo(document.right(), upperYcoord);
    cb.stroke();
    upperYcoord -= phrase.getLeading();

    if (Boolean.parseBoolean(OscarProperties.getInstance().getProperty("ICFHT_CONVERT_TO_PDF", "false"))) {
        printPersonalInfo();
    }
}

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

License:Open Source License

public void printPersonalInfo() throws DocumentException {
    if (demoDtl != null && demoDtl.get("DEMO_ID") != null) {
        String demoId = demoDtl.get("DEMO_ID").toString();
        DemographicDao demographicDao = (DemographicDao) SpringUtils.getBean("demographicDao");
        Demographic demographic = demographicDao.getDemographic(demoId);
        if (demographic != null) {
            ResourceBundle propResource = ResourceBundle.getBundle("oscarResources");

            List<String> demoFields = new ArrayList<String>();

            //demographic section
            demoFields.add("##DEMOGRAPHIC");

            String name = "Name: " + demographic.getLastName() + ", " + demographic.getFirstName();
            demoFields.add(name);//from ww  w.ja v  a2s . c o  m

            String gender = "Gender: " + demographic.getSex();
            demoFields.add(gender);

            String dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " " + demoDtl.get("demoDOB");
            if (dob != null && dob.trim().length() > 0)
                demoFields.add(dob);

            String age = propResource.getString("oscarEncounter.pdfPrint.age") + " " + demographic.getAge();
            demoFields.add(age);

            String language = propResource.getString("oscarEncounter.pdfPrint.language") + " "
                    + demographic.getOfficialLanguage();
            demoFields.add(language);

            DemographicCustDao demographicCustDao = (DemographicCustDao) SpringUtils
                    .getBean("demographicCustDao");
            DemographicCust demographicCust = demographicCustDao.find(Integer.parseInt(demoId));

            //other contacts
            demoFields.add("##OTHER CONTACTS");

            DemographicRelationship demoRelation = new DemographicRelationship();
            ArrayList<Hashtable<String, Object>> relList = demoRelation
                    .getDemographicRelationshipsWithNamePhone(demographic.getDemographicNo().toString());

            for (int reCounter = 0; reCounter < relList.size(); reCounter++) {
                Hashtable<String, Object> relHash = (Hashtable<String, Object>) relList.get(reCounter);
                String sdb = relHash.get("subDecisionMaker") == null ? ""
                        : ((Boolean) relHash.get("subDecisionMaker")).booleanValue() ? "/SDM" : "";
                String ec = relHash.get("emergencyContact") == null ? ""
                        : ((Boolean) relHash.get("emergencyContact")).booleanValue() ? "/EC" : "";
                String relation = relHash.get("relation") + sdb + ec + ": " + relHash.get("lastName") + ", "
                        + relHash.get("firstName") + ", " + relHash.get("phone");
                demoFields.add(relation);
            }

            //Contact Information
            demoFields.add("##CONTACT INFORMATION");

            DemographicExtDao demographicExtDao = SpringUtils.getBean(DemographicExtDao.class);
            Map<String, String> demoExt = demographicExtDao.getAllValuesForDemo(demoId);

            String phone = "";
            if (demographic.getPhone() != null && demographic.getPhone().trim().length() > 0)
                phone = demographic.getPhone() + " "
                        + (demoExt.get("hPhoneExt") != null ? demoExt.get("hPhoneExt") : "");
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.phoneh") + " " + phone);

            String phoneW = "";
            if (demographic.getPhone2() != null && demographic.getPhone2().trim().length() > 0)
                phoneW = demographic.getPhone2() + " " + demoExt.get("wPhoneExt") != null
                        ? demoExt.get("wPhoneExt")
                        : "";
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.phonew") + " " + phoneW);

            String cellPhone = "";
            if (demoExt.get("demo_cell") != null && demoExt.get("demo_cell").trim().length() > 0)
                cellPhone = demoExt.get("demo_cell").trim();
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.cellphone") + " " + cellPhone);

            String address = "";
            if (demographic.getAddress() != null && demographic.getAddress().trim().length() > 0)
                address = demographic.getAddress().trim();
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.address") + " " + address);

            String city = "";
            if (demographic.getCity() != null && demographic.getCity().trim().length() > 0)
                city = demographic.getCity().trim();
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.city") + " " + city);

            String province = "";
            if (demographic.getProvince() != null && demographic.getProvince().trim().length() > 0)
                province = demographic.getProvince().trim();
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.province") + " " + province);

            String postal = "";
            if (demographic.getPostal() != null && demographic.getPostal().trim().length() > 0)
                postal = demographic.getPostal().trim();
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.postal") + " " + postal);

            String email = "";
            if (demographic.getEmail() != null && demographic.getEmail().trim().length() > 0)
                email = demographic.getEmail().trim();
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.email") + " " + email);

            String newsletter = "";
            if (demographic.getNewsletter() != null && demographic.getNewsletter().trim().length() > 0)
                newsletter = demographic.getNewsletter().trim();
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.newsletter") + " " + newsletter);

            //health insurance
            demoFields.add("##HEALTH INSURANCE");

            String hin = demographic.getHin() != null ? demographic.getHin() : "";
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.health_ins") + " " + hin);

            String hcType = demographic.getHcType() != null ? demographic.getHcType() : "";
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.hc_type") + " " + hcType);

            String EFFData = demographic.getEffDate() != null ? demographic.getEffDate().toString() : "";
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.eff_date") + " " + EFFData);

            //clinic status
            demoFields.add("##CLINIC STATUS");

            String dateJoined = demographic.getDateJoined() != null ? demographic.getDateJoined().toString()
                    : "";
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.date_joined") + " " + dateJoined);

            //Patient Clinic Status
            demoFields.add("##PATIENT CLINIC STATUS");

            String doctorName = "";
            ProviderDao providerDao = SpringUtils.getBean(ProviderDao.class);

            if (demographic.getProviderNo() != null && demographic.getProviderNo().trim().length() > 0) {
                doctorName = providerDao.getProviderName(demographic.getProviderNo());
            }
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.doctor") + " " + doctorName);

            String nurseName = "";
            if (demographicCust.getResident() != null && demographicCust.getResident().trim().length() > 0) {
                nurseName = providerDao.getProviderName(demographicCust.getResident());
            }
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.nurse") + " " + nurseName);

            String midwifeName = "";
            if (demographicCust.getMidwife() != null && demographicCust.getMidwife().trim().length() > 0) {
                midwifeName = providerDao.getProviderName(demographicCust.getMidwife());
            }
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.midwife") + " " + midwifeName);

            String residentName = "";
            if (demographicCust.getNurse() != null && demographicCust.getNurse().trim().length() > 0) {
                residentName = providerDao.getProviderName(demographicCust.getNurse());
            }
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.resident") + " " + residentName);

            String rd = "";
            String rdohip = "";
            String fd = demographic.getFamilyDoctor();
            if (fd != null) {
                rd = SxmlMisc.getXmlContent(StringUtils.trimToEmpty(demographic.getFamilyDoctor()), "rd");
                rd = rd != null ? rd : "";
                rdohip = SxmlMisc.getXmlContent(StringUtils.trimToEmpty(demographic.getFamilyDoctor()),
                        "rdohip");
                rdohip = rdohip != null ? rdohip : "";
            }

            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.referral_doctor") + " " + rd);
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.referral_doctor_no") + " " + rdohip);

            //RX INTERACTION WARNING LEVEL
            demoFields.add("##");
            String warningLevel = demoExt.get("rxInteractionWarningLevel");
            if (warningLevel == null)
                warningLevel = "0";
            String warningLevelStr = "Not Specified";
            if (warningLevel.equals("1")) {
                warningLevelStr = "Low";
            }
            if (warningLevel.equals("2")) {
                warningLevelStr = "Medium";
            }
            if (warningLevel.equals("3")) {
                warningLevelStr = "High";
            }
            if (warningLevel.equals("4")) {
                warningLevelStr = "None";
            }
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.rx_int_warning_level") + " "
                    + warningLevelStr);

            String alert = demographicCust.getAlert() != null ? demographicCust.getAlert() : " ";
            demoFields.add(propResource.getString("oscarEncounter.pdfPrint.alert") + " " + alert);

            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, "Personal Information", obsfont);
            p.add(phrase);
            document.add(p);

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

            int index = 0;
            int size = demoFields.size();
            for (String personalInfoField : demoFields) {
                p = new Paragraph();
                p.setAlignment(Paragraph.ALIGN_LEFT);
                if (personalInfoField.startsWith("##")) {
                    phrase = new Phrase(LEADING, "", obsfont2);
                    personalInfoField = personalInfoField.replaceFirst("##", "").trim();
                } else {
                    phrase = new Phrase(LEADING, "", normal);
                }

                if (personalInfoField.trim().length() > 0)
                    phrase.add(personalInfoField);
                if ((index + 1) < size && demoFields.get(index + 1).startsWith("##"))
                    phrase.add("\n\n");

                p.add(phrase);
                document.add(p);

                index++;
            }

            newPage = true;
        }
    }
}

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

License:Open Source License

public void printAllergies(String demoNo) throws DocumentException {
    List<String> allergyList = getAllergyData(demoNo);

    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);//from   w ww  .  ja  v  a 2s. c  om
    phrase = new Phrase(LEADING, "Allergies", obsfont);
    p.add(phrase);
    document.add(p);

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

    if (allergyList != null && allergyList.size() > 0) {
        p = new Paragraph();
        p.setAlignment(Paragraph.ALIGN_LEFT);
        phrase = new Phrase(LEADING, "", obsfont2);
        phrase.add("DESCRIPTION - SEVERIY - REACTION - DATE\n");
        p.add(phrase);
        document.add(p);

        for (String allergy : allergyList) {
            p = new Paragraph();
            p.setAlignment(Paragraph.ALIGN_LEFT);
            phrase = new Phrase(LEADING, "", normal);
            phrase.add(allergy + "\n");
            p.add(phrase);
            document.add(p);
        }

        newPage = true;
    }
}

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;//from  w  ww  .  ja va 2s  .  c om

    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.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  .j  a  v  a 2s. 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();

}