Example usage for com.itextpdf.text.pdf PdfPTable PdfPTable

List of usage examples for com.itextpdf.text.pdf PdfPTable PdfPTable

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable PdfPTable.

Prototype

public PdfPTable(final PdfPTable table) 

Source Link

Document

Constructs a copy of a PdfPTable.

Usage

From source file:at.jps.sanction.core.io.file.PDFFileOutputWorker.java

License:Open Source License

@Override
public void handleMessage(final AnalysisResult message) {

    super.handleMessage(message);

    try {/*from   ww  w .ja v a  2 s.c o m*/

        logger.info("write Message: " + message.getMessage().getId());

        final Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(getFilename()));
        document.open();

        final Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD);
        final Font paragraphFont = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.NORMAL);

        Chunk chunk = new Chunk("Message", chapterFont);
        Chapter chapter = new Chapter(new Paragraph(chunk), 1);
        chapter.setNumberDepth(0);
        chapter.add(new Paragraph(message.getMessage().toString(), paragraphFont));
        document.add(chapter);

        getWriter().write(message.getMessage().toString());

        if (message.getHitList() != null) {

            chapter.add(new Paragraph("Hits", paragraphFont));

            for (final HitResult hit : message.getHitList()) {
                final PdfPTable table = new PdfPTable(2);

                table.addCell("Description");
                table.addCell(hit.getHitDescripton());
                table.addCell("Field");
                table.addCell(hit.getHitDescripton());
                table.addCell("Absolute Value");
                table.addCell(hit.getAbsolutHit() + "");
                table.addCell("Relative Value");
                table.addCell(hit.getRelativeHit() + "");
                table.addCell("Phrase Value");
                table.addCell(hit.getPhraseHit() + "");
                table.addCell("HitType");
                table.addCell(hit.getHitType());

                document.add(table);
            }
        } else {
            final String exception = message.getException();
            if (exception != null) {
                chunk = new Chunk("Error:", chapterFont);
                chapter = new Chapter(new Paragraph(chunk), 1);
                chapter.add(new Paragraph(message.getException().toString(), paragraphFont));
                document.add(chapter);
            }
        }
        document.close();
    } catch (final Exception e) {
        logger.error("Error writing to file:" + getFilename());
        logger.debug("Exception: ", e);
    }
}

From source file:basiclayout.ReportFrame.java

public ReportFrame(DefaultTableModel subtotal_model, String st1_date, String e1_date)
        throws DocumentException, IOException {

    this();/* ww  w .  j a  v a 2 s .  c o  m*/
    report_model = (DefaultTableModel) reportTable.getModel();
    reportTable.setRowSelectionAllowed(true);
    reportTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    document = new Document();

    try {

        initialize_connection();

        PdfWriter.getInstance((com.itextpdf.text.Document) document,
                new FileOutputStream("C:\\Users\\jaina_000\\Desktop\\test.pdf"));
        document.open();

        table = new PdfPTable(5);
        table.setWidthPercentage(300 / 3f);
        table.setWidths(new int[] { 3, 3, 3, 3, 3 });

        PdfPCell cell;
        cell = new PdfPCell(new Phrase("Category"));
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Title"));
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Date"));
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Amount"));
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Details"));
        table.addCell(cell);

        cell.setRowspan(5);

        final_total = 0;

        for (int i = 0; i < subtotal_model.getRowCount(); i++) {

            String subt_cat = subtotal_model.getValueAt(i, 0).toString();

            resultset1 = statement1
                    .executeQuery("Select * from " + tableC + " WHERE CategoryName='" + subt_cat + "'");
            resultset1.next();

            resultset2 = statement2
                    .executeQuery("Select * from " + tableE + " WHERE CategoryId= '" + resultset1.getString(1)
                            + "' " + "AND (Date BETWEEN '" + st1_date + "' AND '" + e1_date + "')");

            sub_amt = 0;

            System.out.print("\n\nCategory: " + resultset1.getString(2));
            rep_row[0] = resultset1.getString(2);

            for (int z = 1; z < 5; z++) {
                rep_row[z] = null;
            }

            report_model.addRow(rep_row);

            table.addCell(new PdfPCell(new Phrase((String) rep_row[0])));
            table.addCell(new PdfPCell(new Phrase("")));
            table.addCell(new PdfPCell(new Phrase("")));
            table.addCell(new PdfPCell(new Phrase("")));
            table.addCell(new PdfPCell(new Phrase("")));

            cell.setRowspan(5);

            while (resultset2.next()) {

                rep_row[0] = null;
                System.out.print("\nTitle : " + resultset2.getString(5)); // Title
                rep_row[1] = resultset2.getString(5);

                System.out.print("\tDate : " + resultset2.getString(2)); // Date
                rep_row[2] = resultset2.getString(2);

                System.out.print("\tAmount: " + Math.abs(Integer.parseInt(resultset2.getString(4))));
                rep_row[3] = Math.abs(Integer.parseInt(resultset2.getString(4)));

                System.out.print("\tDescription : " + resultset2.getString(6)); // Description
                rep_row[4] = resultset2.getString(6);

                table.addCell(new PdfPCell(new Phrase((String) rep_row[0])));
                table.addCell(new PdfPCell(new Phrase((String) rep_row[1])));
                table.addCell(new PdfPCell(new Phrase((String) rep_row[2])));
                table.addCell(new PdfPCell(new Phrase(String.valueOf(rep_row[3]))));
                table.addCell(new PdfPCell(new Phrase((String) rep_row[4])));

                sub_amt += Integer.parseInt(resultset2.getString(4));

                report_model.addRow(rep_row);

                cell.setRowspan(5);
            }

            final_total += sub_amt;
            for (int z = 0; z < 5; z++) {
                rep_row[z] = null;
            }

            rep_row[2] = "Subtotal";
            rep_row[3] = Math.abs(sub_amt);
            System.out.println("\nCategory Subtotal : " + Math.abs(sub_amt));

            table.addCell(new PdfPCell(new Phrase((String) rep_row[0])));
            table.addCell(new PdfPCell(new Phrase((String) rep_row[1])));
            table.addCell(new PdfPCell(new Phrase((String) rep_row[2])));
            table.addCell(new PdfPCell(new Phrase(String.valueOf(rep_row[3]))));
            table.addCell(new PdfPCell(new Phrase((String) rep_row[4])));

            report_model.addRow(rep_row);

            cell.setRowspan(5);
        }

        for (int z = 0; z < 5; z++) {
            rep_row[z] = null;
        }
        report_model.addRow(rep_row);
        report_model.addRow(rep_row);

        System.out.print("\n\nFinal total: " + Math.abs(final_total));
        rep_row[2] = "Final Total";
        rep_row[3] = Math.abs(final_total);

        if (final_total < 0) {
            System.out.println("  (Expense)");
            rep_row[4] = "(Expense)";
        }

        else {
            System.out.println("  (Income)");
            rep_row[4] = "(Income)";
        }

        table.addCell(new PdfPCell(new Phrase((String) rep_row[0])));
        table.addCell(new PdfPCell(new Phrase((String) rep_row[1])));
        table.addCell(new PdfPCell(new Phrase((String) rep_row[2])));
        table.addCell(new PdfPCell(new Phrase(String.valueOf(rep_row[3]))));
        table.addCell(new PdfPCell(new Phrase((String) rep_row[4])));

        report_model.addRow(rep_row);

        cell.setRowspan(5);

    } catch (ClassNotFoundException | SQLException e) {

    } catch (FileNotFoundException ex) {
        Logger.getLogger(ReportFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    finally {

        close_connection();

    }

}

From source file:bd.gov.forms.web.FormBuilder.java

License:Open Source License

@RequestMapping(value = "/individualpdf", method = RequestMethod.GET)
public String individualpdf(@RequestParam(value = "formId", required = true) String formId,
        @RequestParam(value = "entryId", required = true) String entryId, ModelMap model,
        HttpServletResponse response) throws IOException {

    byte[] fileContent = formDao.getTemplateContent(formId);
    Form form = formDao.getFormWithFields(formId);
    form.setEntryId(entryId);/*from   w  w  w  . j  ava  2  s.c  om*/

    form = formDao.getEntry(form);
    String report = "";

    Document document = new Document();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    if (fileContent != null) {
        report = new String(fileContent, "UTF8");

        for (Field field : form.getFields()) {
            if (fieldTypeIsNotOfFileOrNoteOrSection(field)) {
                report = report.replaceAll("#" + field.getColName() + ":label#", field.getLabel());
                report = report.replaceAll("#" + field.getColName() + ":value#", field.getStrVal());
            }
        }
    }

    else {
        // step 2
        try {
            response.reset();
            response.setContentType("application/pdf");
            response.setHeader("Content-disposition", "inline; filename=test.pdf");

            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expires", 0);
            response.setHeader("Pragma", "No-cache");

            PdfWriter writer = PdfWriter.getInstance(document, baos);
            // step 3
            document.open();

            PdfPCell space;
            space = new PdfPCell();
            space.setBorder(Rectangle.NO_BORDER);
            space.setColspan(2);
            space.setFixedHeight(8);

            PdfPTable table = new PdfPTable(2);
            PdfPCell cell;

            report += "<table cellspacing='0' cellpadding='0' style='border:1px solid #aaa;width:98%;'>";

            for (Field field : form.getFields()) {
                if (fieldTypeIsNotOfFileOrNoteOrSection(field)) {

                    report += field.getLabel();

                    report += field.getStrVal();

                    table.setWidths(new int[] { 1, 2 });
                    table.addCell(field.getLabel());
                    //cell = new PdfPCell();
                    //cell.setCellEvent(new TextFields(1));
                    table.addCell(field.getStrVal());

                }
            }

            document.add(table);
            document.close();
            ServletOutputStream out = response.getOutputStream();
            baos.writeTo(out);
            out.flush();

        }

        catch (Exception ex) {
            System.out.println("Could not print reasone::" + ex.toString());

        }

    }

    return null;

}

From source file:bd.gov.forms.web.FormBuilder.java

License:Open Source License

@RequestMapping(value = "/pdfExport", method = RequestMethod.GET)
public String pdfExport(@RequestParam(value = "formId", required = true) String formId,
        @RequestParam(value = "page", required = false) Integer page,
        @RequestParam(value = "colName", required = false) String colName,
        @RequestParam(value = "colVal", required = false) String colVal,
        @RequestParam(value = "sortCol", required = false) String sortCol,
        @RequestParam(value = "sortDir", required = false) String sortDir, ModelMap model,
        HttpServletResponse response, HttpServletRequest request) throws IOException {

    Document document = new Document();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    // step 2/*  w  ww.  j a  va 2 s .  co  m*/
    try {
        response.reset();
        response.setContentType("application/pdf");
        response.setHeader("Content-disposition", "inline; filename=test.pdf");

        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        response.setHeader("Pragma", "No-cache");

        PdfWriter writer = PdfWriter.getInstance(document, baos);
        // step 3
        document.open();

        Form form = null;
        //System.out.println("The form id is 1:"+formId);
        if (formId != null) {
            form = formDao.getFormWithFields(formId);
        }

        if (form != null) {
            if (form.getStatus() != 2) {//2-active, 3-deactive
                model.put("doneMessage", "msg.access.denied");
                model.put("doneMsgType", "failed");

                return "redirect:done.htm";
            }
            initForm(form);
        }

        List<Field> fieldList = form.getFields();

        if (fieldList.isEmpty()) {
            System.out.println("The list size is zero");
        }

        PdfPCell space;
        space = new PdfPCell();
        space.setBorder(Rectangle.NO_BORDER);
        space.setColspan(2);
        space.setFixedHeight(8);

        PdfPTable table = new PdfPTable(2);
        PdfPCell cell;

        //PdfPCell cell;                
        table.setWidths(new int[] { 1, 2 });

        int i = 0;
        for (Field f : fieldList) {
            if ("text".equals(f.getType())) {

                table.addCell(f.getLabel());
                cell = new PdfPCell();
                cell.setCellEvent(new TextFields(1, i));
                table.addCell(cell);

            } else if ("textarea".equals(f.getType())) {
                table.addCell(f.getLabel());
                cell = new PdfPCell();
                cell.setCellEvent(new TextFields(1, i));
                cell.setFixedHeight(60);
                table.addCell(cell);

            } else if ("select".equals(f.getType())) {
                table.addCell(f.getType());
                cell = new PdfPCell();
                cell.setCellEvent(new ChoiceFields(3, f.getList().toArray()));
                table.addCell(cell);
                //table.addCell(space);
                System.out.println("ajsdhd");
            }
            i++;
        }

        /*
          for(Field f : fieldList)
          {  
                
        if( "radio".equals(f.getType()) )
        {    
            System.out.println("List "+f.getList()+"  Oppt"+f.getOptions()+ "    df"+f.getColName());
                    
            writer = PdfWriter.getInstance(document, new FileOutputStream("TextFieldForm.pdf"));
                 
            //writer.addJavaScript(Utilities.readFileToString(""));
            // add the radio buttons
            PdfContentByte canvas = writer.getDirectContent();
            Font font = new Font(FontFamily.HELVETICA, 14);
            Rectangle rect;
            PdfFormField field;
            PdfFormField radiogroup = PdfFormField.createRadioButton(writer, true);
            radiogroup.setFieldName("language");
            RadioCheckField radio;
            for (int i = 0; i < 2; i++) 
            {
                rect = new Rectangle(40, 806 - i * 40, 60, 788 - i * 40);
                radio = new RadioCheckField(writer, rect, null, f.getLabel());
                radio.setBorderColor(GrayColor.GRAYBLACK);
                radio.setBackgroundColor(GrayColor.GRAYWHITE);
                radio.setCheckType(RadioCheckField.TYPE_CIRCLE);
                field = radio.getRadioField();
                radiogroup.addKid(field);
                        
                writer.addAnnotation(field);
                       
                ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                    new Phrase(f.getLabel(), font), 70, 790 - i * 40, 0);
            }
            //table.addCell(f.getLabel());
            //cell = new PdfPCell();
                    
            //document.add(radiogroup);
            //writer.addAnnotation(radiogroup);
                    
                
        }
                
          }       */

        // Add submit button   
        PushbuttonField submitBtn = new PushbuttonField(writer, new Rectangle(400, 700, 370, 670),
                "submitPOST");
        //submitBtn.setBackgroundColor(Color.GRAY);
        submitBtn.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
        submitBtn.setText("Submit");
        submitBtn.setOptions(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT);
        PdfFormField submitField = submitBtn.getField();
        submitField.setAction(
                PdfAction.createSubmitForm("http://localhost:8084/GovForm-07-02/formBuilder/pdfresponse.htm",
                        null, PdfAction.SUBMIT_HTML_FORMAT));

        writer.addAnnotation(submitField);

        document.add(table);

        System.out.println("Pdf creation successful");

        document.close();

        ServletOutputStream out = response.getOutputStream();
        baos.writeTo(out);
        out.flush();

    } catch (Exception ex) {
        System.out.println("Could not print reasone::" + ex.toString());

    }

    //////////////////////////////////////// email part////////////////////////////  
    //email functionalities
    // Recipient's email ID needs to be mentioned.
    String to = "tanviranik@gmail.com";

    // Sender's email ID needs to be mentioned
    String from = "tanvir_cse@yahoo.com";

    // Assuming you are sending email from localhost
    String host = "localhost";

    // Get system properties
    Properties properties = System.getProperties();

    // Setup mail server
    properties.setProperty("mail.smtp.host", host);

    // Get the default Session object.
    Session session = Session.getDefaultInstance(properties);

    try {
        // Create a default MimeMessage object.
        MimeMessage message = new MimeMessage(session);

        // Set From: header field of the header.
        message.setFrom(new InternetAddress(from));

        // Set To: header field of the header.
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

        // Set Subject: header field
        message.setSubject("This is the Subject Line!");

        // Now set the actual message
        message.setText("This is actual message");

        // Send message
        Transport.send(message);
        System.out.println("Sent message successfully....");
    } catch (MessagingException mex) {
        mex.printStackTrace();
    }
    //////////////////////////////////////// email part////////////////////////////

    return null;

}

From source file:be.kcbj.placemat.Placemat.java

License:Open Source License

private void createPdf(File file, List<Sponsor> sponsors) throws IOException, DocumentException {
    System.out.println("Generating PDF file " + file.getAbsolutePath());
    Layout layout = new Layout(sponsors);
    System.out.println("Layout = " + layout);

    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream(file));
    document.setPageSize(PageSize.A4.rotate());
    document.setMargins(PADDING_DOC, PADDING_DOC, PADDING_DOC, PADDING_DOC);
    document.open();//from  w w w. j  a v  a 2  s . c o  m

    PdfPTable table = new PdfPTable(layout.getColumnCount());
    table.setWidthPercentage(100);
    table.setSpacingBefore(0f);
    table.setSpacingAfter(0f);
    for (int i = 0; i < sponsors.size(); i++) {
        table.addCell(generateCell(sponsors.get(i), layout.getCellHeight()));
    }
    for (int i = 0; i < layout.getEmptyCellCount(); i++) {
        table.addCell(generateCell(new Sponsor(), layout.getCellHeight()));
    }
    document.add(table);

    document.close();
}

From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java

protected void printSignature() {
    try {/*from   ww  w  .  ja  v  a2s .c o m*/
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(
                new Paragraph(getTran("report.monthly", "signature").toUpperCase() + "\n\n\n\n\n\n\n\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC)));
        cell.setColspan(1);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        table.addCell(cell);
        doc.add(table);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java

protected void printActiveDiagnosis(SessionContainerWO sessionContainerWO) {
    try {/*from  ww w  . ja  v a  2  s  . c o  m*/
        Vector activeProblems = Problem.getActiveProblems(patient.personid);

        if (activeProblems.size() > 0) {
            doc.add(new Paragraph(" "));
            table = new PdfPTable(1);
            table.setWidthPercentage(100);

            // title
            cell = new PdfPCell(new Paragraph(getTran("web.occup", "medwan.common.problemlist").toUpperCase(),
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC)));
            cell.setColspan(1);
            cell.setBorder(PdfPCell.BOX);
            cell.setBorderColor(BaseColor.LIGHT_GRAY);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            // run thru diagnoses
            Problem activeProblem;
            String value;

            for (int n = 0; n < activeProblems.size(); n++) {
                activeProblem = (Problem) activeProblems.elementAt(n);
                value = MedwanQuery.getInstance().getCodeTran(
                        activeProblem.getCodeType() + "code" + activeProblem.getCode(), sPrintLanguage);
                cell = new PdfPCell(new Paragraph(
                        value + " (" + getTran("Web", "since") + " "
                                + dateFormat.format(activeProblem.getBegin()) + ")",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));

                cell.setColspan(1);
                cell.setBorder(PdfPCell.BOX);
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                table.addCell(cell);
            }

            doc.add(table);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java

protected void printWarnings(SessionContainerWO sessionContainerWO) {
    try {//from  ww w  . j  ava  2 s .  c  o m
        if (sessionContainerWO.getHealthRecordVO() != null) {
            Collection alerts = MedwanQuery.getInstance().getTransactionsByType(
                    sessionContainerWO.getHealthRecordVO(), IConstants.TRANSACTION_TYPE_ALERT);
            sessionContainerWO.setAlerts(alerts);

            if (sessionContainerWO.getActiveAlerts().size() > 0) {
                doc.add(new Paragraph(" "));
                table = new PdfPTable(4);
                table.setWidthPercentage(100);

                // title
                cell = new PdfPCell(new Paragraph(getTran("curative", "warning.status.title").toUpperCase(),
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC)));
                cell.setColspan(4);
                cell.setBorder(PdfPCell.BOX);
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                table.addCell(cell);

                // list alerts
                Collection activeAlerts = sessionContainerWO.getActiveAlerts();
                Iterator alertsIter = activeAlerts.iterator();
                TransactionVO transactionVO;
                String sLabel, sComment;
                ItemVO itemVO;

                while (alertsIter.hasNext()) {
                    transactionVO = (TransactionVO) alertsIter.next();

                    // label
                    sLabel = "";
                    itemVO = transactionVO.getItem(IConstants_PREFIX + "ITEM_TYPE_ALERTS_LABEL");
                    if (itemVO != null) {
                        sLabel = checkString(itemVO.getValue());
                    }

                    cell = new PdfPCell(new Paragraph(sLabel, FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
                    cell.setColspan(1);
                    cell.setBorder(PdfPCell.LEFT + PdfPCell.TOP + PdfPCell.BOTTOM); // no right border
                    cell.setBorderColor(BaseColor.LIGHT_GRAY);
                    cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                    table.addCell(cell);

                    // comment
                    sComment = "";
                    itemVO = transactionVO.getItem(IConstants_PREFIX + "ITEM_TYPE_ALERTS_DESCRIPTION");
                    if (itemVO != null) {
                        sComment = checkString(itemVO.getValue());
                    }

                    cell = new PdfPCell(new Paragraph(sComment, FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
                    cell.setColspan(4);
                    cell.setBorder(PdfPCell.RIGHT + PdfPCell.TOP + PdfPCell.BOTTOM); // no left border
                    cell.setBorderColor(BaseColor.LIGHT_GRAY);
                    cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                    table.addCell(cell);
                }

                doc.add(table);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java

protected void printMedication(SessionContainerWO sessionContainerWO) {
    try {/*from  ww  w .  j ava2s .c  o  m*/
        doc.add(new Paragraph(" "));
        table = new PdfPTable(2);
        table.setWidthPercentage(100);

        // main title
        cell = new PdfPCell(new Paragraph(getTran("curative", "medication.status.title").toUpperCase(),
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0),
                        Font.ITALIC)));
        cell.setColspan(2);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(cell);

        Vector chronicMedications = ChronicMedication.find(patient.personid, "", "", "", "OC_CHRONICMED_BEGIN",
                "ASC"), activePrescriptions = Prescription.getActivePrescriptions(patient.personid);

        //*** CHRONIC MEDICATION ******************************************
        if (chronicMedications.size() > 0) {
            PdfPTable medicationTable = new PdfPTable(2);

            // sub title
            cell = new PdfPCell(new Paragraph(getTran("curative", "medication.chronic"), FontFactory.getFont(
                    FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC)));
            cell.setColspan(2);
            cell.setBorder(PdfPCell.BOX);
            cell.setBorderColor(BaseColor.LIGHT_GRAY);
            cell.setVerticalAlignment(PdfPCell.ALIGN_LEFT);
            cell.setBackgroundColor(BGCOLOR_LIGHT);
            medicationTable.addCell(cell);

            // run thru medications
            String sPrescrRule, sProductUnit, timeUnitTran;
            ChronicMedication medication;

            for (int n = 0; n < chronicMedications.size(); n++) {
                medication = (ChronicMedication) chronicMedications.elementAt(n);

                sPrescrRule = getTran("web.prescriptions", "prescriptionrule");
                sPrescrRule = sPrescrRule.replaceAll("#unitspertimeunit#",
                        medication.getUnitsPerTimeUnit() + "");

                // productunits
                if (medication.getUnitsPerTimeUnit() == 1) {
                    sProductUnit = getTran("product.unit", medication.getProduct().getUnit());
                } else {
                    sProductUnit = getTran("product.units", medication.getProduct().getUnit());
                }
                sPrescrRule = sPrescrRule.replaceAll("#productunit#", sProductUnit.toLowerCase());

                // timeunits
                if (medication.getTimeUnitCount() == 1) {
                    sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#", "");
                    timeUnitTran = getTran("prescription.timeunit", medication.getTimeUnit());
                } else {
                    sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#", medication.getTimeUnitCount() + "");
                    timeUnitTran = getTran("prescription.timeunits", medication.getTimeUnit());
                }
                sPrescrRule = sPrescrRule.replaceAll("#timeunit#",
                        timeUnitTran.replaceAll("  ", " ").toLowerCase());

                // product name
                cell = new PdfPCell(new Paragraph(medication.getProduct().getName(),
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                cell.setColspan(1);
                cell.setBorder(PdfPCell.LEFT + PdfPCell.TOP + PdfPCell.BOTTOM); // no right border
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                medicationTable.addCell(cell);

                // prescription rule
                cell = new PdfPCell(new Paragraph(sPrescrRule, FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)));
                cell.setColspan(1);
                cell.setBorder(PdfPCell.RIGHT + PdfPCell.TOP + PdfPCell.BOTTOM); // no left border
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                medicationTable.addCell(cell);
            }

            // add cells to make up with the chronic medications
            if (chronicMedications.size() < activePrescriptions.size()) {
                int missingCellCount = activePrescriptions.size() - chronicMedications.size();
                for (int i = 0; i < missingCellCount; i++) {
                    cell = new PdfPCell();
                    cell.setColspan(2);
                    cell.setBorder(PdfPCell.NO_BORDER);
                    medicationTable.addCell(cell);
                }
            }

            // add chronicmedicationtables to medicationtable
            cell = new PdfPCell(medicationTable);
            cell.setBorder(PdfPCell.BOX);
            cell.setBorderColor(BaseColor.LIGHT_GRAY);
            cell.setPadding(3);
            table.addCell(cell);
        }

        //*** PRESCRIPTIONS ***********************************************
        if (activePrescriptions.size() > 0) {
            PdfPTable medicationTable = new PdfPTable(2);

            // sub title
            cell = new PdfPCell(new Paragraph(getTran("curative", "medication.prescription"),
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC)));
            cell.setColspan(2);
            cell.setBorder(PdfPCell.BOX);
            cell.setBorderColor(BaseColor.LIGHT_GRAY);
            cell.setVerticalAlignment(PdfPCell.ALIGN_LEFT);
            cell.setBackgroundColor(BGCOLOR_LIGHT);
            medicationTable.addCell(cell);

            // run thru medications
            String sPrescrRule, sProductUnit, timeUnitTran;
            Prescription prescription;
            int n;

            for (n = 0; n < activePrescriptions.size(); n++) {
                prescription = (Prescription) activePrescriptions.elementAt(n);

                sPrescrRule = getTran("web.prescriptions", "prescriptionrule");
                sPrescrRule = sPrescrRule.replaceAll("#unitspertimeunit#",
                        prescription.getUnitsPerTimeUnit() + "");

                // productunits
                if (prescription.getUnitsPerTimeUnit() == 1) {
                    sProductUnit = getTran("product.unit", prescription.getProduct().getUnit());
                } else {
                    sProductUnit = getTran("product.units", prescription.getProduct().getUnit());
                }
                sPrescrRule = sPrescrRule.replaceAll("#productunit#", sProductUnit.toLowerCase());

                // timeunits
                if (prescription.getTimeUnitCount() == 1) {
                    sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#", "");
                    timeUnitTran = getTran("prescription.timeunit", prescription.getTimeUnit());
                } else {
                    sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#",
                            prescription.getTimeUnitCount() + "");
                    timeUnitTran = getTran("prescription.timeunits", prescription.getTimeUnit());
                }
                sPrescrRule = sPrescrRule.replaceAll("#timeunit#", timeUnitTran.toLowerCase());

                // product name
                cell = new PdfPCell(new Paragraph(prescription.getProduct().getName(),
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                cell.setColspan(1);
                cell.setBorder(PdfPCell.LEFT + PdfPCell.TOP + PdfPCell.BOTTOM); // no right border
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                medicationTable.addCell(cell);

                // prescription rule
                cell = new PdfPCell(new Paragraph(sPrescrRule, FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)));
                cell.setColspan(1);
                cell.setBorder(PdfPCell.RIGHT + PdfPCell.TOP + PdfPCell.BOTTOM); // no left border
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                medicationTable.addCell(cell);
            }

            // add cells to make up with the active prescriptions
            if (activePrescriptions.size() < chronicMedications.size()) {
                int missingCellCount = chronicMedications.size() - activePrescriptions.size();
                for (int i = 0; i < missingCellCount; i++) {
                    cell = new PdfPCell();
                    cell.setColspan(2);
                    cell.setBorder(PdfPCell.NO_BORDER);
                    medicationTable.addCell(cell);
                }
            }

            // add presciptionssstable to medicationtable
            cell = new PdfPCell(medicationTable);
            cell.setBorder(PdfPCell.BOX);
            cell.setBorderColor(BaseColor.LIGHT_GRAY);
            cell.setPadding(3);
            table.addCell(cell);

            doc.add(table);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java

protected void printKeyData(SessionContainerWO sessionContainerWO) {
    try {//www .j ava2s.  c o  m
        doc.add(new Paragraph(" "));
        table = new PdfPTable(15);
        table.setWidthPercentage(100);

        // kernel-data
        cell = new PdfPCell(new Paragraph(getTran("Web.Occup", "medwan.common.kernel-data").toUpperCase(),
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0),
                        Font.ITALIC)));
        cell.setColspan(15);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(cell);

        // row 1 : last-periodical-examination
        Paragraph par = new Paragraph(
                getTran("Web.Occup", "medwan.common.last-periodical-examination").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        TransactionVO tran = sessionContainerWO.getLastTransaction(IConstants_PREFIX + "TRANSACTION_TYPE_MER");
        ItemVO item;
        if (tran != null) {
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_MER_EXAMINATION_DATE");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD)));
            }
        }
        cell = new PdfPCell(par);
        cell.setColspan(5);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 1 : next-periodical-examination
        par = new Paragraph(
                getTran("Web.Occup", "medwan.common.next-periodical-examination").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        if (sessionContainerWO.getFlags().getLastExaminationReport() != null && sessionContainerWO.getFlags()
                .getLastExaminationReport().getNewExaminationDueDate() != null) {
            par.add(new Chunk(
                    dateFormat.format(sessionContainerWO.getFlags().getLastExaminationReport()
                            .getNewExaminationDueDate()),
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD)));
        }
        cell = new PdfPCell(par);
        cell.setColspan(5);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 1 : next-driver-examination / Volgend onderzoek medische schifting
        par = new Paragraph(getTran("Web.Occup", "medwan.common.next-driver-examination").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        if (sessionContainerWO.getFlags().getLastDrivingCertificate() != null) {

            // CBMT only : only display newExaminationDueDate if patient has riskcode "070" (drivinglicense)
            boolean riskCode070Found = false;

            if (riskCode070Found) {
                String newExamDueDateMinus = ScreenHelper.checkString(sessionContainerWO.getFlags()
                        .getLastDrivingCertificate().getNewExaminationDueDateMinus());
                if (newExamDueDateMinus.length() > 0) {
                    par.add(new Chunk(newExamDueDateMinus.replaceAll("-", "/"),
                            FontFactory.getFont(FontFactory.HELVETICA,
                                    Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD)));
                }
            }
        } else {
            // no data available
            par.add(new Chunk(getTran("Web.Occup", "medwan.common.no-data"), FontFactory.getFont(
                    FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD)));
        }

        cell = new PdfPCell(par);
        cell.setColspan(5);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 2 : Biometrie
        par = new Paragraph(getTran("Web.Occup", "medwan.common.biometry").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        tran = sessionContainerWO.getLastTransactionTypeBiometry();
        if (tran != null) {
            // height
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_BIOMETRY_HEIGHT");
            String sHeight = "", sWeight = "";
            if (item != null) {
                sHeight = item.getValue();
                par.add(new Chunk(getTran("Web.Occup", "medwan.common.length") + ": " + sHeight + " cm\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }

            // weight
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_BIOMETRY_WEIGHT");
            if (item != null) {
                sWeight = item.getValue();
                par.add(new Chunk(getTran("Web.Occup", "medwan.common.weight") + ": " + sWeight + " kg\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }

            // BMI
            if (sWeight.length() > 0 && sHeight.length() > 0) {
                try {
                    DecimalFormat deci = new DecimalFormat("0.0");
                    Float bmi = new Float(Float.parseFloat(sWeight.replaceAll(",", ".")) * 10000
                            / (Float.parseFloat(sHeight.replaceAll(",", "."))
                                    * Float.parseFloat(sHeight.replaceAll(",", "."))));
                    par.add(new Chunk("BMI: " + deci.format(bmi), FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        cell = new PdfPCell(par);
        cell.setColspan(3);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 2 : Urineonderzoek
        par = new Paragraph("URINE\n", FontFactory.getFont(FontFactory.HELVETICA,
                Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC));
        tran = sessionContainerWO.getLastTransactionTypeUrineExamination();
        if (tran != null) {
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_URINE_ALBUMINE");
            if (item != null) {
                par.add(new Chunk("Albumine: " + getTran("Web.Occup", item.getValue()) + "\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_URINE_GLUCOSE");
            if (item != null) {
                par.add(new Chunk("Glucose: " + getTran("Web.Occup", item.getValue()) + "\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_URINE_BLOOD");
            if (item != null) {
                par.add(new Chunk(
                        getTran("Web.Occup", "medwan.common.blood") + ": "
                                + getTran("Web.Occup", item.getValue()),
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
        }

        cell = new PdfPCell(par);
        cell.setColspan(3);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 2 : Audiometrie
        par = new Paragraph(getTran("Web.Occup", "medwan.common.audiometry").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        tran = sessionContainerWO.getLastTransactionTypeAudiometry();
        if (tran != null) {
            par.add(new Chunk(getTran("Web.Occup", "medwan.common.mean-hearing-loss").toUpperCase() + "\n",
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 6 * fontSizePercentage / 100.0), Font.ITALIC)));
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_AUDIOMETRY_RIGHT_LOSS");
            if (item != null) {
                par.add(new Chunk(
                        getTran("Web.Occup", "medwan.common.right") + ": -" + item.getValue() + " dB\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_AUDIOMETRY_LEFT_LOSS");
            if (item != null) {
                par.add(new Chunk(
                        getTran("Web.Occup", "medwan.common.left") + ": -" + item.getValue() + " dB\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
        }
        cell = new PdfPCell(par);
        cell.setColspan(3);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 2 : Visus
        par = new Paragraph(
                getTran("Web.Occup", "medwan.common.vision").toUpperCase() + " - "
                        + getTran("Web.Occup",
                                IConstants_PREFIX + "item_type_opthalmology_screen_visiotest_vision_far")
                                        .toUpperCase()
                        + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        tran = sessionContainerWO.getLastTransactionTypeOphtalmology();
        if (tran != null) {
            par.add(new Chunk(getTran("Web.Occup", "medwan.common.right-left-binocular").toUpperCase() + "\n",
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 6 * fontSizePercentage / 100.0), Font.ITALIC)));
            par.add(new Chunk(getTran("Web.Occup", "medwan.common.without-correction") + ": ",
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OD_WITHOUT_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                    Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OG_WITHOUT_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                    Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_BONI_WITHOUT_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            par.add(new Chunk("\n" + getTran("Web.Occup", "medwan.common.with-correction") + ": ",
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OD_WITH_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                    Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OG_WITH_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                    Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_BONI_WITH_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
        }
        cell = new PdfPCell(par);
        cell.setColspan(3);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 2 : Bloeddruk
        par = new Paragraph(getTran("Web.Occup", "medwan.common.blood-pressure").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        tran = sessionContainerWO.getLastTransactionTypeGeneralClinicalExamination();
        if (tran != null) {
            // right
            ItemVO item1 = tran.getItem(
                    IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_SYSTOLIC_PRESSURE_RIGHT");
            item = tran.getItem(
                    IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_DIASTOLIC_PRESSURE_RIGHT");
            if (item1 != null || item != null) {
                par.add(new Chunk(getTran("Web.Occup", "medwan.common.right") + ": ",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                if (item1 != null) {
                    par.add(new Chunk(item1.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                }
                par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
                if (item != null) {
                    par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                }
                par.add(new Chunk(" mmHg\n", FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }

            // left
            item = tran.getItem(
                    IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_SYSTOLIC_PRESSURE_LEFT");
            item1 = tran.getItem(
                    IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_DIASTOLIC_PRESSURE_LEFT");
            if (item != null || item1 != null) {
                par.add(new Chunk(getTran("Web.Occup", "medwan.common.left") + ": ",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                if (item != null) {
                    par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                }
                par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
                if (item1 != null) {
                    par.add(new Chunk(item1.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                }
                par.add(new Chunk(" mmHg\n", FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
        }

        cell = new PdfPCell(par);
        cell.setColspan(3);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        doc.add(table);
    } catch (Exception e) {
        e.printStackTrace();
    }
}