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

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

Introduction

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

Prototype

public void setColspan(int colspan) 

Source Link

Document

Setter for property colspan.

Usage

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

public void addTotalQuotedFooter(final PdfPTable negotiationTable) {
    negotiationTable.addCell(" ");
    negotiationTable.addCell(" ");
    final PdfPTable tenderQuotedTable = createTotalQuotedValueTable();
    final PdfPCell tenderQuotedTableCell = new PdfPCell(tenderQuotedTable);
    tenderQuotedTableCell.setColspan(5);
    negotiationTable.addCell(tenderQuotedTableCell);
    negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    final PdfPTable befTenderNegQuotedTable = createBefTenderNegQuotedTable();
    final PdfPCell befTenderNegQuotedTableCell = new PdfPCell(befTenderNegQuotedTable);
    befTenderNegQuotedTableCell.setColspan(2);
    negotiationTable.addCell(befTenderNegQuotedTableCell);
    final PdfPTable aftTenderNegQuotedTable = createAftTenderNegQuotedTable();
    final PdfPCell aftTenderNegQuotedTableCell = new PdfPCell(aftTenderNegQuotedTable);
    aftTenderNegQuotedTableCell.setColspan(2);
    negotiationTable.addCell(aftTenderNegQuotedTableCell);
    final PdfPTable marketTenderNegTable = createMarketTenderNegTable();
    final PdfPCell marketTenderNegTableCell = new PdfPCell(marketTenderNegTable);
    marketTenderNegTableCell.setColspan(2);
    negotiationTable.addCell(marketTenderNegTableCell);
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

public void addFinalRow(final PdfPTable negotiationTable, final TenderResponse tenderResponse) {
    final PdfPTable tenderNarrationTable = createTenderNarrationTable(tenderResponse);
    final PdfPCell tenderNarrationTableCell = new PdfPCell(tenderNarrationTable);
    tenderNarrationTableCell.setColspan(13);
    negotiationTable.addCell(tenderNarrationTableCell);
}

From source file:org.emmanet.controllers.PdfView.java

License:Apache License

@Override
protected void buildPdfDocument(Map map, Document doc, PdfWriter writer, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    if (map.get("WebRequestsDAO") != null && request.getParameter("type").equals("req")) {
        WebRequestsDAO wrd = new WebRequestsDAO();
        WebRequests wr = new WebRequests();
        wrd = (WebRequestsDAO) map.get("WebRequestsDAO");

        if (wrd.getRegister_interest() != null) {
            if (wrd.getRegister_interest().equals("1")) {
                pdfTitle = "EMMA Strain Interest Registration Form";
                pdfConditions = false;//  www  .j  a va2  s.c  o  m
            } else if (wrd.getRegister_interest().equals("0")) {
                pdfTitle = "EMMA Mutant Request Form";
                pdfConditions = true;
            }
        }

        Paragraph pHead = new Paragraph(pdfTitle + "\n\n", FontFactory.getFont(FontFactory.HELVETICA, 11));
        pHead.setAlignment(Element.ALIGN_CENTER);
        doc.add(pHead);
        doc.add(new Paragraph(pdfTitle + "\nRequest ID:" + wrd.getId_req() + "\n\n",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 20)));
        Paragraph pSubHead = new Paragraph(
                "Following data have been submitted to EMMA on " + wrd.getTimestamp(),
                FontFactory.getFont(FontFactory.HELVETICA, 11));
        pSubHead.setAlignment(Element.ALIGN_CENTER);

        doc.add(pSubHead);
        doc.add(Chunk.NEWLINE);
        // Space padding underline
        Chunk underlined = new Chunk(
                "                                                                                     "
                        + "                                                                       ");
        underlined.setUnderline(new Color(0x00, 0x00, 0x00), 0.0f, 0.2f, 16.0f, 0.0f,
                PdfContentByte.LINE_CAP_BUTT);//Black line
        doc.add(underlined);
        Font font = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11);
        // Set table cell widths equiv. to 25% and 75%
        float[] widths = { 0.25f, 0.75f };
        PdfPTable table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        PdfPCell cell = new PdfPCell(new Paragraph("Scientist\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        table.addCell("Title");
        table.addCell("" + wrd.getSci_title());
        table.addCell("Firstname");
        table.addCell("" + wrd.getSci_firstname());
        table.addCell("Surname");
        table.addCell("" + wrd.getSci_surname());
        table.addCell("E-mail");
        table.addCell("" + wrd.getSci_e_mail());
        table.addCell("Phone");
        table.addCell("" + wrd.getSci_phone());
        table.addCell("Fax");
        table.addCell("" + wrd.getSci_fax());
        PdfPCell cellShip = new PdfPCell(new Paragraph("\nShipping Contact\n\n", font));
        cellShip.setColspan(2);
        cellShip.setBorder(0);
        table.addCell(cellShip);

        table.addCell("Title");
        table.addCell("" + wrd.getCon_title());
        table.addCell("Firstname");
        table.addCell("" + wrd.getCon_firstname());
        table.addCell("Surname");
        table.addCell("" + wrd.getCon_surname());
        table.addCell("E-mail");
        table.addCell("" + wrd.getCon_e_mail());
        table.addCell("Phone");
        table.addCell("" + wrd.getCon_phone());
        table.addCell("Fax");
        table.addCell("" + wrd.getCon_fax());
        table.addCell("Institution");
        table.addCell("" + wrd.getCon_institution());
        table.addCell("Department");
        table.addCell("" + wrd.getCon_dept());
        table.addCell("Address Line 1");
        table.addCell("" + wrd.getCon_addr_1());
        table.addCell("Address Line 2");
        table.addCell("" + wrd.getCon_addr_2());
        table.addCell("County/province");
        table.addCell("" + wrd.getCon_province());
        table.addCell("Town");
        table.addCell("" + wrd.getCon_town());
        table.addCell("Postcode");
        table.addCell("" + wrd.getCon_postcode());
        table.addCell("Country");
        table.addCell("" + wrd.getCon_country());

        if (!wrd.getRegister_interest().equals("1")) {
            //webrequest is not a roi so these were set above so send them to pdf
            PdfPCell cellBill = new PdfPCell(new Paragraph("\nBilling Details\n\n", font));
            cellBill.setColspan(2);
            cellBill.setBorder(0);
            table.addCell(cellBill);

            table.addCell("VAT reference");
            table.addCell("" + wrd.getBil_vat());
            table.addCell("Purchase Order Number");
            table.addCell("" + wrd.getPO_ref());
            table.addCell("Title");
            table.addCell("" + wrd.getBil_title());
            table.addCell("Firstname");
            table.addCell("" + wrd.getBil_firstname());
            table.addCell("Surname");
            table.addCell("" + wrd.getBil_surname());
            table.addCell("E-mail");
            table.addCell("" + wrd.getBil_e_mail());
            table.addCell("Phone");
            table.addCell("" + wrd.getBil_phone());
            table.addCell("Fax");
            table.addCell("" + wrd.getBil_fax());
            table.addCell("Institution");
            table.addCell("" + wrd.getBil_institution());
            table.addCell("Department");
            table.addCell("" + wrd.getBil_dept());
            table.addCell("Address Line 1");
            table.addCell("" + wrd.getBil_addr_1());
            table.addCell("Address Line 2");
            table.addCell("" + wrd.getBil_addr_2());
            table.addCell("County/province");
            table.addCell("" + wrd.getBil_province());
            table.addCell("Town");
            table.addCell("" + wrd.getBil_town());
            table.addCell("Postcode");
            table.addCell("" + wrd.getBil_postcode());
            table.addCell("Country");
            table.addCell("" + wrd.getBil_country());

            // TODO add europhenome and wtsi_mouse_portal info
        }

        PdfPCell cellStrain = new PdfPCell(new Paragraph("\nStrain Details\n\n", font));
        cellStrain.setColspan(2);
        cellStrain.setBorder(0);

        table.addCell(cellStrain);
        table.addCell("Strain ID");
        table.addCell("" + wrd.getStrain_id());
        table.addCell("Strain name");
        //new String (wrd.getStrain_name().getBytes("UTF-8"));
        //table.addCell("" + wrd.getStrain_name());
        table.addCell("" + new String(wrd.getStrain_name().getBytes("UTF-8")));
        table.addCell("Common Name(s)");
        table.addCell("" + wrd.getCommon_name_s());

        if (wrd.getReq_material() != null) {
            PdfPCell cellMaterial = new PdfPCell(new Paragraph("\nRequested Material\n\n", font));
            cellMaterial.setColspan(2);
            cellMaterial.setBorder(0);

            table.addCell(cellMaterial);
            table.addCell("Material");
            table.addCell("" + wrd.getReq_material());
        }

        if (wrd.getLive_animals() != null) {
            table.addCell("Live Animals");
            table.addCell("Selected");
        }

        if (wrd.getFrozen_emb() != null) {
            table.addCell("Frozen Embryos");
            table.addCell("Selected");
        }

        if (wrd.getFrozen_spe() != null) {
            table.addCell("Frozen Sperm");
            table.addCell("Selected");
        }

        if (pdfConditions) {
            String text = "";
            String text1 = "";
            String text2 = "";
            String header = "";
            String header1 = "";
            String header2 = "";
            if (wrd.getApplication_type().equals("request_only")) {
                text = new StringBuilder().append(text).append(
                        "\nYou have indicated that you have read the conditions and agree to pay the transmittal fee "
                                + "plus shipping costs.")
                        .toString();

                header = new StringBuilder().append(header).append("\nStandard request\n").toString();

            } else if (!wrd.getApplication_type().equals("request_only")) {
                header1 = new StringBuilder().append(header1)
                        .append("\nApplication for Transnational Access Activity").toString();
                if (wrd.getApplication_type().equals("ta_only")) {
                    text1 = new StringBuilder().append(text1).append(
                            "\nYou have indicated that you have read the conditions and have applied for free of charge TA only. "
                                    + "In the case of the TA application being rejected the request process will be terminated.")
                            .toString();
                    header1 = new StringBuilder().append(header1).append(" (TA Option B)\n").toString();
                } else {
                    text1 = new StringBuilder().append(text1).append(
                            "\nYou have indicated that you have read the conditions and have applied for free of charge TA "
                                    + "and have agreed to pay the service charge plus shipping cost if the TA application is rejected.")
                            .toString();
                    header1 = new StringBuilder().append(header1).append(" (TA Option A)\n").toString();
                }

                header2 = new StringBuilder().append(header2).append(
                        "\n\nDescription of project (1/2 page) involving requested EMMA mouse mutant resource. "
                                + "The project description will be used by the Evaluation Committee for selection of applicants:")
                        .toString();
            }

            if (!wrd.getApplication_type().equals("request_only")) {
                //  table.addCell("" + model.get("ta_proj_desc"));
                text2 = new StringBuilder().append(text2).append("\n\n ").append(wrd.getProject_description())
                        .toString();
            }

            if (!wrd.getApplication_type().equals("request_only")) {
                //we have a ta header and text to add
                PdfPCell cellConditions1 = new PdfPCell(new Paragraph(header1, font));

                cellConditions1.setColspan(2);
                cellConditions1.setBorder(0);
                table.addCell(cellConditions1);

                PdfPCell cellConditions2 = new PdfPCell(new Paragraph(text1));

                cellConditions2.setColspan(2);
                cellConditions2.setBorder(0);
                table.addCell(cellConditions2);

                PdfPCell cellConditions3 = new PdfPCell(new Paragraph(header2, font));

                cellConditions3.setColspan(2);
                cellConditions3.setBorder(0);
                table.addCell(cellConditions3);

                PdfPCell cellConditions4 = new PdfPCell(new Paragraph(text2));

                cellConditions4.setColspan(2);
                cellConditions4.setBorder(0);
                table.addCell(cellConditions4);

            } else {

                PdfPCell cellConditions = new PdfPCell(new Paragraph(header, font));
                cellConditions.setColspan(2);
                cellConditions.setBorder(0);
                table.addCell(cellConditions);

                PdfPCell cellConditionsTxt = new PdfPCell(new Paragraph(text));
                cellConditionsTxt.setColspan(2);
                cellConditionsTxt.setBorder(0);
                table.addCell(cellConditionsTxt);
            }
        }
        doc.add(table);
    }

    if (map.get("StrainsDAO") != null && request.getParameter("type").equals("sub")) {
        StrainsDAO sd;
        StrainsManager sm = new StrainsManager();
        PeopleDAO pd;
        PeopleDAO subPDAO = new PeopleDAO();
        PeopleManager pm = new PeopleManager();
        BibliosManager bm = new BibliosManager();

        sd = (StrainsDAO) map.get("StrainsDAO");
        pd = pm.getPerson(sd.getPer_id_per_contact());//For shipping details

        if (sd.getPer_id_per_sub() != null) {
            subPDAO = pm.getPerson(sd.getPer_id_per_sub());
        }

        //RETRIEVE ASSOCIATED SUBMISSION FILES IF PRESENT

        final String submissionID = sd.getSub_id_sub();
        System.out.println("SUBMISSION ID IS::" + submissionID);

        List assocFilesADDITIONAL = new ArrayList();
        List assocFilesSANITARY = new ArrayList();
        List assocFilesCHARACTERISATION = new ArrayList();

        File dir = new File(SUBFORMUPLOAD);
        File[] files;
        files = dir.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                //only add to list if submission id is conatined within file name (which includes path and file name)
                if (submissionID != null && name.startsWith(submissionID)) {
                    return name.toLowerCase().endsWith(".pdf");
                }
                return false;
            }
        });
        System.out.println("Files size is::" + files.length);
        if (files != null && submissionID != null) {
            for (int i = 0; i < files.length; i++) {
                System.out.println("FILEname VALUE " + i + "==" + files[i].getName());
                String file = files[i].getName();
                if (file.startsWith(submissionID) && file.contains((CharSequence) "ADDITIONAL")) {
                    assocFilesADDITIONAL.add(file);
                    System.out.println("ADDITIONAL file " + file);
                } else if (file.startsWith(submissionID) && file.contains((CharSequence) "SANITARYSTATUS")) {
                    assocFilesSANITARY.add(file);
                    System.out.println("SANITARY file " + file);
                } else {
                    assocFilesCHARACTERISATION.add(file);
                    System.out.println("CHARACTERISATION file " + file);
                }
            }
        }

        ServletContext servletContext = request.getSession().getServletContext();
        URL infrafrontierIconURL = servletContext.getResource("/images/infrafrontier/icon/footerlogo.jpg");
        logger.debug("infrafrontierIconURL = " + infrafrontierIconURL);
        URL emmaIconURL = servletContext.getResource("/images/infrafrontier/icon/emma-logo-soft.png");
        logger.debug("emmaIconURL = " + emmaIconURL);
        Image infrafrontierIcon = Image.getInstance(infrafrontierIconURL);
        Image emmaIcon = Image.getInstance(emmaIconURL);

        pdfTitle = "EMMA Mutant Submission Form";
        doc.add(new Chunk(infrafrontierIcon, 0, 0));
        doc.add(new Chunk(emmaIcon, 320, 0));
        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        Paragraph paragraph = new Paragraph(pdfTitle, FontFactory.getFont(FontFactory.HELVETICA_BOLD, 20));
        paragraph.setAlignment(Element.ALIGN_CENTER);
        doc.add(paragraph);

        float[] widths = { 0.25f, 0.75f };
        PdfPTable table = new PdfPTable(widths);
        table.setWidthPercentage(100);
        PdfPCell cell;

        Paragraph pSubHead = new Paragraph(
                "\nThe Following data have been submitted to EMMA on " + sd.getArchiveDAO().getSubmitted(),
                FontFactory.getFont(FontFactory.HELVETICA, 11));
        pSubHead.setAlignment(Element.ALIGN_CENTER);

        doc.add(pSubHead);
        doc.add(Chunk.NEWLINE);
        // Space padding underline
        Chunk underlined = new Chunk(
                "                                                                                     "
                        + "                                                                       ");
        underlined.setUnderline(new Color(0x00, 0x00, 0x00), 0.0f, 0.2f, 16.0f, 0.0f,
                PdfContentByte.LINE_CAP_BUTT);//Black line
        doc.add(underlined);
        Font font = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        // Genotype preparation - strain name [actually, synonym] and description
        // Jira request EMMA-586 - use strain.name instead of synonym (requested by Sabine)
        String strainName = sd.getName();
        pSubHead = new Paragraph(strainName + " / " + sd.getEmma_id() + "\n\n",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11));
        pSubHead.setAlignment(Element.ALIGN_CENTER);
        doc.add(pSubHead);

        // Submitter
        cell = new PdfPCell(new Paragraph("\nSubmitter (Steps 1 and 2 of 11)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        if (sd.getPer_id_per_sub() != null) {
            table.addCell(cell);
            table.addCell("Title");
            table.addCell("" + subPDAO.getTitle());
            table.addCell("Firstname");
            table.addCell("" + subPDAO.getFirstname());
            table.addCell("Surname");
            table.addCell("" + subPDAO.getSurname());
            table.addCell("E-mail");
            table.addCell("" + subPDAO.getEmail());
            table.addCell("Phone");
            table.addCell("" + subPDAO.getPhone());
            table.addCell("Fax");
            table.addCell("" + subPDAO.getFax());
        }
        if (subPDAO.getLabsDAO() != null) {
            table.addCell("Institution");
            table.addCell("" + subPDAO.getLabsDAO().getName());
            table.addCell("Department");
            table.addCell("" + subPDAO.getLabsDAO().getDept());
            table.addCell("Address Line 1");
            table.addCell("" + subPDAO.getLabsDAO().getAddr_line_1());
            table.addCell("Address Line 2");
            table.addCell("" + subPDAO.getLabsDAO().getAddr_line_2());
            table.addCell("County/province");
            table.addCell("" + subPDAO.getLabsDAO().getProvince());
            table.addCell("Town");
            table.addCell("" + subPDAO.getLabsDAO().getTown());
            table.addCell("Postcode");
            table.addCell("" + subPDAO.getLabsDAO().getPostcode());
            table.addCell("Country");
            table.addCell("" + subPDAO.getLabsDAO().getCountry());
        }
        doc.add(table);
        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(underlined);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        // Producer
        cell = new PdfPCell(new Paragraph("Producer (Step 3 of 11)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        table.addCell("Title");
        table.addCell("" + sd.getPeopleDAO().getTitle());
        table.addCell("Firstname");
        table.addCell("" + sd.getPeopleDAO().getFirstname());
        table.addCell("Surname");
        table.addCell("" + sd.getPeopleDAO().getSurname());
        table.addCell("E-mail");
        table.addCell("" + sd.getPeopleDAO().getEmail());
        table.addCell("Phone");
        table.addCell("" + sd.getPeopleDAO().getPhone());
        table.addCell("Fax");
        table.addCell("" + sd.getPeopleDAO().getFax());
        table.addCell("Institution");
        table.addCell("" + sd.getPeopleDAO().getLabsDAO().getName());
        table.addCell("Department");
        table.addCell("" + sd.getPeopleDAO().getLabsDAO().getDept());
        table.addCell("Address Line 1");
        table.addCell("" + sd.getPeopleDAO().getLabsDAO().getAddr_line_1());
        table.addCell("Address Line 2");
        table.addCell("" + sd.getPeopleDAO().getLabsDAO().getAddr_line_2());
        table.addCell("County/province");
        table.addCell("" + sd.getPeopleDAO().getLabsDAO().getProvince());
        table.addCell("Town");
        table.addCell("" + sd.getPeopleDAO().getLabsDAO().getTown());
        table.addCell("Postcode");
        table.addCell("" + sd.getPeopleDAO().getLabsDAO().getPostcode());
        table.addCell("Country");
        table.addCell("" + sd.getPeopleDAO().getLabsDAO().getCountry());
        Integer id_ilar = Utils.tryParseInt(sd.getPeopleDAO().getId_ilar());
        if ((id_ilar != null) && (id_ilar.intValue() > 0)) { // If there is a valid ILAR, display it.
            table.addCell("ILAR");
            table.addCell(sd.getPeopleDAO().getIlarDAO().getLabcode());
        }

        doc.add(table);
        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(underlined);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        // Shipper
        cell = new PdfPCell(new Paragraph("\nShipper (Step 4 of 11)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        table.addCell("Title");
        table.addCell("" + pd.getTitle());
        table.addCell("Firstname");
        table.addCell("" + pd.getFirstname());
        table.addCell("Surname");
        table.addCell("" + pd.getSurname());
        table.addCell("E-mail");
        table.addCell("" + pd.getEmail());
        table.addCell("Phone");
        table.addCell("" + pd.getPhone());
        table.addCell("Fax");
        table.addCell("" + pd.getFax());
        table.addCell("Institution");
        table.addCell("" + pd.getLabsDAO().getName());
        table.addCell("Department");
        table.addCell("" + pd.getLabsDAO().getDept());
        table.addCell("Address Line 1");
        table.addCell("" + pd.getLabsDAO().getAddr_line_1());
        table.addCell("Address Line 2");
        table.addCell("" + pd.getLabsDAO().getAddr_line_2());
        table.addCell("County/province");
        table.addCell("" + pd.getLabsDAO().getProvince());
        table.addCell("Town");
        table.addCell("" + pd.getLabsDAO().getTown());
        table.addCell("Postcode");
        table.addCell("" + pd.getLabsDAO().getPostcode());
        table.addCell("Country");
        table.addCell("" + pd.getLabsDAO().getCountry());

        doc.add(table);
        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(underlined);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        String origBgName = sd.getBackgroundDAO().getName();

        // Genotype
        cell = new PdfPCell(new Paragraph("\nGenotype (Step 5 of 11)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        table.addCell("Strain Name");
        table.addCell("" + strainName);

        table.addCell("Genetic description");
        table.addCell("" + cleanNULLS(sd.getCharact_gen(), false));

        table.addCell("Current genetic background");
        table.addCell("" + cleanNULLS(origBgName, false));

        table.addCell("Number of generations backcrossed");
        table.addCell("" + cleanNULLS(sd.getGeneration(), false));

        table.addCell("Number of generations sib-mated");
        table.addCell("" + cleanNULLS(sd.getSibmatings(), false));

        table.addCell("Breeding history");
        table.addCell("" + sd.getMaintenance());

        doc.add(table);
        doc.add(Chunk.NEWLINE);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        // Genotype - Mutations
        cell = new PdfPCell(new Paragraph("Mutation(s)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        Set sMutations = sd.getMutationsStrainsDAO();

        StringBuffer sDom = new StringBuffer();
        for (Iterator it = sMutations.iterator(); it.hasNext();) {
            MutationsStrainsDAO mutDAO = (MutationsStrainsDAO) it.next();
            if (mutDAO.getMutationsDAO().getDominance() != null) {
                sDom = new StringBuffer(sDom).append(mutDAO.getMutationsDAO().getDominance().toString());
            }

            cell = new PdfPCell(
                    new Paragraph("Type: " + cleanNULLS(mutDAO.getMutationsDAO().getMain_type(), false),
                            FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(
                    new Paragraph("Subtype: " + cleanNULLS(mutDAO.getMutationsDAO().getSub_type(), false),
                            FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(
                    "Affected gene: " + cleanNULLS(
                            mutDAO.getMutationsDAO().getAllelesDAO().getGenesDAO().getName(), false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(
                    "MGI of affected gene: " + cleanNULLS(
                            mutDAO.getMutationsDAO().getAllelesDAO().getGenesDAO().getMgi_ref(), false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(
                    "Affected allele: " + cleanNULLS(mutDAO.getMutationsDAO().getAllelesDAO().getName(), false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(
                    "MGI of affected allele: "
                            + cleanNULLS(mutDAO.getMutationsDAO().getAllelesDAO().getMgi_ref(), false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(
                    "Affected chromosome: " + cleanNULLS(
                            mutDAO.getMutationsDAO().getAllelesDAO().getGenesDAO().getChromosome(), false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(
                    "Dominance pattern: " + cleanNULLS(mutDAO.getMutationsDAO().getDominance(), false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            if (mutDAO.getMutationsDAO().getBackgroundDAO() != null) {
                cell = new PdfPCell(new Paragraph(
                        "Original genetic background: "
                                + cleanNULLS(mutDAO.getMutationsDAO().getBackgroundDAO().getName(), false),
                        FontFactory.getFont(FontFactory.HELVETICA, 11)));
            } else {
                cell = new PdfPCell(new Paragraph("\n"));
            }
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            if (mutDAO.getMutationsDAO().getCh_ano_name() != null) {
                cell = new PdfPCell(new Paragraph(
                        "Chromosomal anomaly name: "
                                + cleanNULLS(mutDAO.getMutationsDAO().getCh_ano_name(), false),
                        FontFactory.getFont(FontFactory.HELVETICA, 11)));
            } else {
                cell = new PdfPCell(new Paragraph("\n"));
            }
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            if (mutDAO.getMutationsDAO().getCh_ano_desc() != null) {
                cell = new PdfPCell(new Paragraph(
                        "Chromosomal anomaly description: "
                                + cleanNULLS(mutDAO.getMutationsDAO().getCh_ano_desc(), false),
                        FontFactory.getFont(FontFactory.HELVETICA, 11)));
            } else {
                cell = new PdfPCell(new Paragraph("\n"));
            }
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(
                    "ES cell line used: " + cleanNULLS(mutDAO.getMutationsDAO().getTm_esline(), false) + "\n\n",
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);
        }

        /* END MUTATIONS*/

        doc.add(table);
        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(underlined);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        cell = new PdfPCell(new Paragraph("\nONE mutant strain is defined by its specific set of mutation(s) "
                + "and its specific genetic background. Therefore strains with the same set of mutation(s) but different "
                + "backgrounds do require DISTINCT submission forms (i.e) ONE form for each background\n\n",
                font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        doc.add(table);
        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(underlined);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        // Phenotype
        cell = new PdfPCell(new Paragraph("\nPhenotype (Step 6 of 11)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("Phenotypic description of homozygous mice\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("" + cleanNULLS(sd.getPheno_text(), true)));
        cell.setColspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("\nPhenotypic description of heterozygous mice\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("" + cleanNULLS(sd.getPheno_text_hetero(), true)));
        cell.setColspan(2);
        table.addCell(cell);
        doc.add(table);

        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(underlined);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        // References
        List bibliosStrains = bm.bibliosStrains(sd.getId_str());
        String acceptedString = ((!bibliosStrains.isEmpty()) && (bibliosStrains.size() > 0) ? "Yes/Accepted"
                : "No/Not known");
        cell = new PdfPCell(new Paragraph("\nReferences (Step 7 of 11)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Paragraph("Has this mouse mutant strain been published or accepted for publication? "
                        + acceptedString + "\n\n", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        for (Iterator it = bibliosStrains.iterator(); it.hasNext();) {
            BibliosStrainsDAO bsdao = (BibliosStrainsDAO) it.next();

            cell = new PdfPCell(
                    new Paragraph("Short description\n\n", FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            if (bsdao.getBibliosDAO().getNotes() != null) {
                cell = new PdfPCell(new Paragraph("" + cleanNULLS(bsdao.getBibliosDAO().getNotes(), true)));
            } else {
                cell = new PdfPCell(new Paragraph("\n"));
            }
            cell.setColspan(2);
            table.addCell(cell);

            String pubmedId = (bsdao.getBibliosDAO().getPubmed_id() == null ? ""
                    : bsdao.getBibliosDAO().getPubmed_id());
            cell = new PdfPCell(
                    new Paragraph("\nPubMed ID: " + pubmedId, FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("Title: " + bsdao.getBibliosDAO().getTitle(),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            String authors = "Authors: " + bsdao.getBibliosDAO().getAuthor1();
            if (bsdao.getBibliosDAO().getAuthor2() != null)
                authors = authors + ", " + bsdao.getBibliosDAO().getAuthor2();
            cell = new PdfPCell(new Paragraph(authors, FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("Journal/Book: " + bsdao.getBibliosDAO().getJournal(),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("Year: " + cleanNULLS(bsdao.getBibliosDAO().getYear(), false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("Volume: " + bsdao.getBibliosDAO().getVolume(),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("Pages: " + bsdao.getBibliosDAO().getPages() + "\n\n",
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);
        }
        doc.add(table);

        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(underlined);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        // Characterization
        cell = new PdfPCell(new Paragraph("\nCharacterization (Step 8 of 11)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(
                "By genotyping \n" + "(e.g. sequence of PCR primers and PCR settings,Southern probes and "
                        + "hybridization protocol)\n\n",
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        if (sd.getResiduesDAO() != null) {
            cell = new PdfPCell(new Paragraph("" + cleanNULLS(sd.getResiduesDAO().getChar_genotyping(), true)));
        } else {
            cell = new PdfPCell(new Paragraph("\n"));
        }
        cell.setColspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("\nBy phenotyping (e.g. coat colour)\n\n",
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        if (sd.getResiduesDAO() != null) {
            cell = new PdfPCell(
                    new Paragraph("" + cleanNULLS(sd.getResiduesDAO().getChar_phenotyping(), true)));
        } else {
            cell = new PdfPCell(new Paragraph("\n"));
        }
        cell.setColspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("\nBy any other means that are not genotyping or phenotyping\n\n",
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        if (sd.getResiduesDAO() != null) {
            cell = new PdfPCell(new Paragraph("" + cleanNULLS(sd.getResiduesDAO().getChar_other(), true)));
        } else {
            cell = new PdfPCell(new Paragraph(""));
        }
        cell.setColspan(2);
        table.addCell(cell);

        //assocFilesCHARACTERISATION

        StringBuffer additionalCharacFiles = new StringBuffer("");
        for (Iterator it = assocFilesCHARACTERISATION.iterator(); it.hasNext();) {
            String fileName = it.next().toString();
            additionalCharacFiles = new StringBuffer(additionalCharacFiles).append("\n        ")
                    .append(fileName);
        }

        cell = new PdfPCell(
                new Paragraph("\nAdditional files uploaded:", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Paragraph("" + additionalCharacFiles, FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        doc.add(table);

        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(underlined);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);

        // Breeding
        cell = new PdfPCell(new Paragraph("\nBreeding (Step 9 of 11)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Paragraph("Are homozygous mice viable? " + cleanNULLS(sd.getMutant_viable(), false),
                        FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        cell = new PdfPCell(
                new Paragraph("Are homozygous mice fertile? " + cleanNULLS(sd.getMutant_fertile(), false),
                        FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "Are heterozygous/hemizygous mice fertile? " + cleanNULLS(sd.getHethemi_fertile(), false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "Are homozygous matings required? " + cleanNULLS(sd.getRequire_homozygous() + "\n\n", false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        if (sd.getResiduesDAO() != null) {
            cell = new PdfPCell(new Paragraph(
                    "" + cleanNULLS(sd.getResiduesDAO().getHomozygous_matings_required_text(), true)));
        } else {
            cell = new PdfPCell(new Paragraph(""));
        }
        cell.setColspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "\nAverage age of reproductive maturity (weeks): "
                        + cleanNULLS(sd.getResiduesDAO().getReproductive_maturity_age(), false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "Average age of reproductive decline (months): "
                        + cleanNULLS(sd.getResiduesDAO().getReproductive_decline_age(), false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "Average length of gestation (days): "
                        + cleanNULLS(sd.getResiduesDAO().getGestation_length(), false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "Average number of pups at birth: " + cleanNULLS(sd.getResiduesDAO().getPups_at_birth(), false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "Average number of pups surviving to weaning: "
                        + cleanNULLS(sd.getResiduesDAO().getPups_at_weaning(), false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "Recommended weaning age (days): " + cleanNULLS(sd.getResiduesDAO().getWeaning_age(), false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "Average number of litters in lifetime: "
                        + cleanNULLS(sd.getResiduesDAO().getLitters_in_lifetime(), false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "Breeding performance: " + cleanNULLS(sd.getResiduesDAO().getBreeding_performance(), false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Paragraph("Husbandry requirements:\n\n", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        if (sd.getResiduesDAO() != null) {
            cell = new PdfPCell(
                    new Paragraph("" + cleanNULLS(sd.getResiduesDAO().getAnimal_husbandry() + "\n", true)));
        } else {
            cell = new PdfPCell(new Paragraph(""));
        }
        cell.setColspan(2);
        table.addCell(cell);

        cell = new PdfPCell(
                new Paragraph("\nAre mice immunicompromised? " + cleanNULLS(sd.getImmunocompromised(), false),
                        FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Paragraph("\nSanitary status:\n\n", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        if (sd.getResiduesDAO() != null) {
            cell = new PdfPCell(
                    new Paragraph("" + cleanNULLS(sd.getResiduesDAO().getCurrent_sanitary_status(), true)));
        } else {
            cell = new PdfPCell(new Paragraph("\n"));
        }
        cell.setColspan(2);

        table.addCell(cell);
        cell = new PdfPCell(
                new Paragraph("\nAnimal welfare:\n\n", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("" + cleanNULLS(sd.getResiduesDAO().getWelfare(), true)));
        cell.setColspan(2);
        table.addCell(cell);

        cell = new PdfPCell(
                new Paragraph("\nRemedial actions:\n\n", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("" + cleanNULLS(sd.getResiduesDAO().getRemedial_actions(), true)));
        cell.setColspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("\nPlease note that under certain circumstances "
                + "(e.g.: long-term cryopreservation by sperm freezing) the strain's original genotype will not "
                + "always be available for future reconstitution of live colonies. Therefore, the original genetic "
                + "background cannot be guaranteed.\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        //assocFilesSANITARY

        StringBuffer additionalSanitaryFiles = new StringBuffer("");
        for (Iterator it = assocFilesSANITARY.iterator(); it.hasNext();) {
            String fileName = it.next().toString();
            additionalSanitaryFiles = new StringBuffer(additionalSanitaryFiles).append("\n        ")
                    .append(fileName);
        }

        cell = new PdfPCell(
                new Paragraph("\nAdditional files uploaded:", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Paragraph("" + additionalSanitaryFiles, FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        doc.add(table);

        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(underlined);
        table = new PdfPTable(widths);
        table.setWidthPercentage(100);
        doc.add(table);

        // Research value
        cell = new PdfPCell(new Paragraph("\n\n\nResearch value (Step 10 of 11)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "Does this strain model a human condition or disease? "
                        + cleanNULLS(sd.getHuman_model(), false),
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        Strains_OmimManager strainsOmimManager = new Strains_OmimManager();
        List<Strains_OmimDAO> strains_omimDAOList = strainsOmimManager.findById_Strains(sd.getId_str());

        if (!strains_omimDAOList.isEmpty()) {
            cell = new PdfPCell(
                    new Paragraph("\nOMIM IDs:\n\n", FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);

            for (Strains_OmimDAO strainsOmimDAO : strains_omimDAOList) {
                cell = new PdfPCell(
                        new Paragraph("" + cleanNULLS(strainsOmimDAO.getOmimDAO().getOmim(), true)));
                cell.setColspan(2);
                table.addCell(cell);
            }
        }

        cell = new PdfPCell(new Paragraph(
                "\n\nIf OMIM IDs are not available, please describe the human condition or disease:\n\n",
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("" + cleanNULLS(sd.getHuman_model_desc(), true)));
        cell.setColspan(2);
        table.addCell(cell);

        // Prep for Research areas
        Set cs = sd.getCategoriesStrainsDAO();
        String otherCategory = "";
        StringBuffer categories = new StringBuffer();
        for (Iterator it = cs.iterator(); it.hasNext();) {
            CategoriesStrainsDAO cd = (CategoriesStrainsDAO) it.next();
            if (cd.getCategoriesDAO().getCurated().compareTo("Y") == 0)
                categories.append("\n        ").append(cd.getCategoriesDAO().getMain_cat());
            else
                otherCategory = cd.getCategoriesDAO().getMain_cat();
        }

        cell = new PdfPCell(new Paragraph("\n\nResearch areas:\n        " + categories + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        Set sRTools = sd.getRtoolsDAO();
        StringBuffer rtools = new StringBuffer("");
        System.out.println("size of rtoolsdao set is :- " + sRTools.size());
        for (Iterator it = sRTools.iterator(); it.hasNext();) {
            RToolsDAO rtd = (RToolsDAO) it.next();
            rtools = new StringBuffer(rtools).append("\n        ")
                    .append(rtd.getCvrtoolsDAO().getDescription());
            //System.out.println("Rtools set iterator value is: " + rtools);
        }

        if ((otherCategory != null) && (otherCategory.trim().length() > 0)) {
            cell = new PdfPCell(new Paragraph("\n\nOther Research areas:\n\n        " + otherCategory + "\n",
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            cell.setColspan(2);
            cell.setBorder(0);
            table.addCell(cell);
        }
        cell = new PdfPCell(new Paragraph("\n\nResearch tools:\n" + rtools,
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        /* END OF Research value */

        doc.add(table);
        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        doc.add(underlined);
        table = new PdfPTable(widths);

        table.setWidthPercentage(100);

        /* Additional information */

        cell = new PdfPCell(new Paragraph("\n\nAdditional information (Step 11 of 11)\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        if (sd.getResiduesDAO() != null) {
            cell = new PdfPCell(new Paragraph(
                    "How many requests for this strain have you received in the last 6 months? "
                            + cleanNULLS(sd.getResiduesDAO().getNumber_of_requests(), false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
        } else {
            cell = new PdfPCell(
                    new Paragraph("How many requests for this strain have you received in the last 6 months? ",
                            FontFactory.getFont(FontFactory.HELVETICA, 11)));
        }

        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        if (sd.getResiduesDAO() != null) {
            cell = new PdfPCell(new Paragraph(
                    "Is this strain being deposited with any other institution or biotechnology company? "
                            + cleanNULLS(sd.getResiduesDAO().getDeposited_elsewhere() + "\n\n", false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
        } else {
            cell = new PdfPCell(new Paragraph(
                    "Is this strain being deposited with any other institution or biotechnology company? ",
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
        }
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        if (sd.getResiduesDAO() != null) {
            if (sd.getResiduesDAO().getIpr_description() != null) {
                cell = new PdfPCell(
                        new Paragraph(cleanNULLS(sd.getResiduesDAO().getDeposited_elsewhere_text(), true)));
                cell.setColspan(2);
                table.addCell(cell);
            }
        }

        if (sd.getResiduesDAO() != null) {
            cell = new PdfPCell(new Paragraph(
                    "\n\nAre other laboratories producing similar strains? "
                            + cleanNULLS(sd.getResiduesDAO().getOther_labos(), false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
        } else {
            cell = new PdfPCell(new Paragraph("\n\nAre other laboratories producing similar strains? ",
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
        }
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        String IPRights = "";
        if (sd.getResiduesDAO() != null) {
            IPRights = sd.getResiduesDAO().getIp_rights();
        } else {
            //do nothing
        }
        cell = new PdfPCell(new Paragraph(
                "Are there any intellectual property rights or patented technologies linked to this strain? "
                        + IPRights + "\n\n",
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        if (sd.getResiduesDAO() != null) {
            if (sd.getResiduesDAO().getIpr_description() != null) {
                cell = new PdfPCell(
                        new Paragraph("" + cleanNULLS(sd.getResiduesDAO().getIpr_description(), true)));
                cell.setColspan(2);
                table.addCell(cell);
            }
        }

        cell = new PdfPCell(new Paragraph(
                "\nIs the producer the exclusive owner of this strain? "
                        + cleanNULLS(sd.getExclusive_owner(), false) + "\n\n",
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("" + cleanNULLS(sd.getEx_owner_description(), true)));
        cell.setColspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(
                "\nDo you have permission from all owners to deposit this strain in the EMMA repository? "
                        + cleanNULLS(sd.getResiduesDAO().getOwner_permission(), false) + "\n\n",
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Paragraph("" + cleanNULLS(sd.getResiduesDAO().getOwner_permission_text(), true)));
        cell.setColspan(2);
        table.addCell(cell);

        String delayedRelease = "";
        if (sd.getResiduesDAO() != null) {
            delayedRelease = cleanNULLS(sd.getResiduesDAO().getDelayed_wanted(), false);
        }
        if (delayedRelease != null && delayedRelease.startsWith("yes")) {
            delayedRelease = new StringBuffer(delayedRelease).append(" (briefly explain below)\n\n").toString();
        }

        cell = new PdfPCell(new Paragraph("\nDo you require delayed release for your strain? " + delayedRelease,
                FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);
        if (delayedRelease != null && delayedRelease.startsWith("yes")) {
            cell = new PdfPCell(new Paragraph("" + sd.getResiduesDAO().getDelayed_description()));
            cell.setColspan(2);
            table.addCell(cell);
        }

        if (sd.getResiduesDAO() != null) {
            cell = new PdfPCell(new Paragraph("\nHow many mice of breeding age could you provide and when?"
                    + "\n\nEstimated date of shipping:\n\nMonth: "
                    + cleanNULLS(sd.getResiduesDAO().getWhen_how_many_month(), false) + "\n\nYear: "
                    + cleanNULLS(sd.getResiduesDAO().getWhen_how_many_year(), false) + "\n\nNumber of males: "
                    + cleanNULLS(sd.getResiduesDAO().getWhen_how_many_males(), false)
                    + "\n\nNumber of females: "
                    + cleanNULLS(sd.getResiduesDAO().getWhen_how_many_females(), false),
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
        } else {
            cell = new PdfPCell(new Paragraph(
                    "\n\nHow many mice of breeding age could you provide and when?"
                            + "\n\nEstimated date of shipping:\n\nMonth: " + "\n\nYear: "
                            + "\n\nNumber of males: " + "\n\nNumber of females: ",
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
        }
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        //assocFilesADDITIONAL

        StringBuffer additionalFiles = new StringBuffer("");
        for (Iterator it = assocFilesADDITIONAL.iterator(); it.hasNext();) {
            String fileName = it.next().toString();
            additionalFiles = new StringBuffer(additionalFiles).append("\n        ").append(fileName);
        }

        cell = new PdfPCell(
                new Paragraph("\nAdditional files uploaded:", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Paragraph("" + additionalFiles, FontFactory.getFont(FontFactory.HELVETICA, 11)));
        cell.setColspan(2);
        cell.setBorder(0);
        table.addCell(cell);

        //            cell = new PdfPCell(new Paragraph("\n\nWere any of the following techniques used in the construction of this mutant?\n\n", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            cell.setColspan(2);
        //            cell.setBorder(0);
        //            table.addCell(cell);
        //
        //            if (sd.getResiduesDAO() != null) {
        //                cell = new PdfPCell(new Paragraph("Cre recombinase-loxP technology? " + cleanNULLS(sd.getResiduesDAO().getCrelox(), false), FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            } else {
        //                cell = new PdfPCell(new Paragraph("Cre recombinase-loxP technology? ", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            }
        //            cell.setColspan(2);
        //            cell.setBorder(0);
        //            table.addCell(cell);
        //
        //            if (sd.getResiduesDAO() != null) {
        //                cell = new PdfPCell(new Paragraph("FLP recombinase technology? " + cleanNULLS(sd.getResiduesDAO().getFlp(), false), FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            } else {
        //                cell = new PdfPCell(new Paragraph("FLP recombinase technology? ", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            }
        //            cell.setColspan(2);
        //            cell.setBorder(0);
        //            table.addCell(cell);
        //
        //            if (sd.getResiduesDAO() != null) {
        //                cell = new PdfPCell(new Paragraph("TET-system technology? " + cleanNULLS(sd.getResiduesDAO().getTet(), false), FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            } else {
        //                cell = new PdfPCell(new Paragraph("TET-system technology? ", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            }
        //            cell.setColspan(2);
        //            cell.setBorder(0);
        //            table.addCell(cell);
        //
        //
        //            if (sd.getResiduesDAO() != null) {
        //                cell = new PdfPCell(new Paragraph("\n\nIf the submission request is accepted when could you provide "
        //                        + "10 females and 6 males (5-12 weeks old)?"
        //                        + "\nEstimated date of shipping\nMonth: " + cleanNULLS(sd.getResiduesDAO().getWhen_mice_month(), false) + "\nYear: " + cleanNULLS(sd.getResiduesDAO().getWhen_mice_year(), false), FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            } else {
        //                cell = new PdfPCell(new Paragraph("\n\nIf the submission request is accepted when could you provide "
        //                        + "10 females and 6 males (5-12 weeks old)?"
        //                        + "\nEstimated date of shipping\nMonth: \nYear:", FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            }
        //
        //            cell.setColspan(2);
        //            cell.setBorder(0);
        //            table.addCell(cell);

        //            if (sd.getResiduesDAO() != null) {
        //                cell = new PdfPCell(new Paragraph("\n\nIf unable to provide this number of mice how many could you provide and when?"
        //                        + "\nEstimated date of shipping\nMonth: " + cleanNULLS(sd.getResiduesDAO().getWhen_how_many_month(), false)
        //                        + "\nYear: " + cleanNULLS(sd.getResiduesDAO().getWhen_how_many_year(), false)
        //                        + "\nNumber of males: " + cleanNULLS(sd.getResiduesDAO().getWhen_how_many_males(), false)
        //                        + "\nNumber of females: " + cleanNULLS(sd.getResiduesDAO().getWhen_how_many_females(), false),
        //                        FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            } else {
        //                cell = new PdfPCell(new Paragraph("\n\nIf unable to provide this number of mice how many could you provide and when?"
        //                        + "\nEstimated date of shipping\nMonth: "
        //                        + "\nYear: "
        //                        + "\nNumber of males: "
        //                        + "\nNumber of females: ",
        //                        FontFactory.getFont(FontFactory.HELVETICA, 11)));
        //            }
        //            cell.setColspan(2);
        //            cell.setBorder(0);
        //            table.addCell(cell);

        /* END OF ADDITIONAL INFORMATION */
        doc.add(table);

        doc.add(Chunk.NEWLINE);
        // Space padding underline
        underlined = new Chunk(
                "                                                                                     "
                        + "                                                                       ");
        underlined.setUnderline(new Color(0x00, 0x00, 0x00), 0.0f, 0.2f, 16.0f, 0.0f,
                PdfContentByte.LINE_CAP_BUTT);//Black line
        doc.add(underlined);

        pSubHead = new Paragraph("The terms and conditions have been accepted.\n\n",
                FontFactory.getFont(FontFactory.HELVETICA, 11));
        pSubHead.setAlignment(Element.ALIGN_CENTER);
        doc.add(pSubHead);
    }
}

From source file:org.emmanet.controllers.RequestFormController.java

License:Apache License

public String createPDF(Map model, String filePath) {
    /* I really don't like this iText library.
     * Takes so much effort to figure it all out
     * to get an acceptable pdf rendition. */

    Document doc = new Document();
    try {//  w  w w .ja  va 2  s  .co m
        System.out.println(model.get("timestamp"));

        PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(filePath));
        doc.open();
        Paragraph pHead = new Paragraph(pdfTitle + "\n\n", FontFactory.getFont(FontFactory.HELVETICA, 11));
        pHead.setAlignment(Element.ALIGN_CENTER);
        doc.add(pHead);
        doc.add(new Paragraph(pdfTitle + "\nRequest ID:" + model.get("requestID") + "\n\n",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 20)));
        Paragraph pSubHead = new Paragraph(
                "Following data have been submitted to EMMA on " + model.get("ftimestamp"),
                FontFactory.getFont(FontFactory.HELVETICA, 11));
        pSubHead.setAlignment(Element.ALIGN_CENTER);

        doc.add(pSubHead);
        doc.add(Chunk.NEWLINE);
        // Space padding underline
        Chunk underlined = new Chunk(
                "                                                                                     "
                        + "                                                                       ");
        underlined.setUnderline(new Color(0x00, 0x00, 0x00), 0.0f, 0.2f, 16.0f, 0.0f,
                PdfContentByte.LINE_CAP_BUTT);//Black line
        doc.add(underlined);
        Font font = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11);
        // Set table cell widths equiv. to 25% and 75%
        float[] widths = { 0.25f, 0.75f };
        PdfPTable table = new PdfPTable(widths);

        table.setWidthPercentage(100);

        PdfPCell cell = new PdfPCell(new Paragraph("Scientist\n\n", font));
        cell.setColspan(2);
        cell.setBorder(0);

        table.addCell(cell);
        table.addCell("Title");
        table.addCell("" + model.get("sci_title"));
        table.addCell("Firstname");
        table.addCell("" + model.get("sci_firstname"));
        table.addCell("Surname");
        table.addCell("" + model.get("sci_surname"));
        table.addCell("E-mail");
        table.addCell("" + model.get("sci_e_mail"));
        table.addCell("Phone");
        table.addCell("" + model.get("sci_phone"));
        table.addCell("Fax");
        table.addCell("" + model.get("sci_fax"));
        PdfPCell cellShip = new PdfPCell(new Paragraph("\nShipping Contact\n\n", font));
        cellShip.setColspan(2);
        cellShip.setBorder(0);
        table.addCell(cellShip);

        table.addCell("Title");
        table.addCell("" + model.get("con_title"));
        table.addCell("Firstname");
        table.addCell("" + model.get("con_firstname"));
        table.addCell("Surname");
        table.addCell("" + model.get("con_surname"));
        table.addCell("E-mail");
        table.addCell("" + model.get("con_e_mail"));
        table.addCell("Phone");
        table.addCell("" + model.get("con_phone"));
        table.addCell("Fax");
        table.addCell("" + model.get("con_fax"));
        table.addCell("Institution");
        table.addCell("" + model.get("con_institution"));
        table.addCell("Department");
        table.addCell("" + model.get("con_dept"));
        table.addCell("Address Line 1");
        table.addCell("" + model.get("con_addr_1"));
        table.addCell("Address Line 2");
        table.addCell("" + model.get("con_addr_2"));
        table.addCell("County/province");
        table.addCell("" + model.get("con_province"));
        table.addCell("Town");
        table.addCell("" + model.get("con_town"));
        table.addCell("Postcode");
        table.addCell("" + model.get("con_postcode"));
        table.addCell("Country");
        table.addCell("" + model.get("con_country"));

        if (!model.get("ROI").equals("1")) {
            //webrequest is not a roi so these were set above so send them to pdf
            PdfPCell cellBill = new PdfPCell(new Paragraph("\nBilling Details\n\n", font));
            cellBill.setColspan(2);
            cellBill.setBorder(0);
            table.addCell(cellBill);

            table.addCell("VAT reference");
            table.addCell("" + model.get("bil_vat"));
            table.addCell("Purchase Order Number");
            table.addCell("" + model.get("PO_ref"));
            table.addCell("Title");
            table.addCell("" + model.get("bil_title"));
            table.addCell("Firstname");
            table.addCell("" + model.get("bil_firstname"));
            table.addCell("Surname");
            table.addCell("" + model.get("bil_surname"));
            table.addCell("E-mail");
            table.addCell("" + model.get("bil_e_mail"));
            table.addCell("Phone");
            table.addCell("" + model.get("bil_phone"));
            table.addCell("Fax");
            table.addCell("" + model.get("bil_fax"));
            table.addCell("Institution");
            table.addCell("" + model.get("bil_institution"));
            table.addCell("Department");
            table.addCell("" + model.get("bil_dept"));
            table.addCell("Address Line 1");
            table.addCell("" + model.get("bil_addr_1"));
            table.addCell("Address Line 2");
            table.addCell("" + model.get("bil_addr_2"));
            table.addCell("County/province");
            table.addCell("" + model.get("bil_province"));
            table.addCell("Town");
            table.addCell("" + model.get("bil_town"));
            table.addCell("Postcode");
            table.addCell("" + model.get("bil_postcode"));
            table.addCell("Country");
            table.addCell("" + model.get("bil_country"));
        }

        PdfPCell cellStrain = new PdfPCell(new Paragraph("\nStrain Details\n\n", font));
        cellStrain.setColspan(2);
        cellStrain.setBorder(0);

        table.addCell(cellStrain);
        table.addCell("Strain ID");
        table.addCell("" + model.get("strain_id"));
        table.addCell("Strain name");
        table.addCell("" + model.get("strain_name"));
        table.addCell("Common Name(s)");
        table.addCell("" + model.get("common_name_s"));

        if (model.get("req_material") != null) {
            PdfPCell cellMaterial = new PdfPCell(new Paragraph("\nRequested Material\n\n", font));
            cellMaterial.setColspan(2);
            cellMaterial.setBorder(0);

            table.addCell(cellMaterial);
            table.addCell("Material");
            table.addCell("" + model.get("req_material"));
        }

        if (model.get("live_animals") != null) {
            table.addCell("Live Animals");
            table.addCell("Selected");
        }

        if (model.get("frozen_emb") != null) {
            table.addCell("Frozen Embryos");
            table.addCell("Selected");
        }

        if (model.get("frozen_spe") != null) {
            table.addCell("Frozen Sperm");
            table.addCell("Selected");
        }

        if (pdfConditions) {
            String text = "";
            String text1 = "";
            String text2 = "";
            String header = "";
            String header1 = "";
            String header2 = "";
            if (model.get("application_type").equals("request_only")) {
                text = new StringBuilder().append(text).append(
                        "\nYou have indicated that you have read the conditions and agree to pay the transmittal fee "
                                + "plus shipping costs.")
                        .toString();

                header = new StringBuilder().append(header).append("\nStandard request\n").toString();

            } else if (!model.get("application_type").equals("request_only")) {
                header1 = new StringBuilder().append(header1)
                        .append("\nApplication for Transnational Access Activity").toString();
                if (model.get("application_type").equals("ta_only")) {
                    text1 = new StringBuilder().append(text1).append(
                            "\nYou have indicated that you have read the conditions and have applied for free of charge TA only. "
                                    + "In the case of the TA application being rejected the request process will be terminated.")
                            .toString();
                    header1 = new StringBuilder().append(header1).append(" (TA Option B)\n").toString();
                } else {
                    text1 = new StringBuilder().append(text1).append(
                            "\nYou have indicated that you have read the conditions and have applied for free of charge TA "
                                    + "and have agreed to pay the service charge plus shipping cost if the TA application is rejected.")
                            .toString();
                    header1 = new StringBuilder().append(header1).append(" (TA Option A)\n").toString();
                }

                header2 = new StringBuilder().append(header2).append(
                        "\n\nDescription of project (1/2 page) involving requested EMMA mouse mutant resource. "
                                + "The project description will be used by the Evaluation Committee for selection of applicants:")
                        .toString();
            }

            if (!model.get("application_type").equals("request_only")) {
                //  table.addCell("" + model.get("ta_proj_desc"));
                text2 = new StringBuilder().append(text2).append("\n\n " + model.get("ta_proj_desc"))
                        .toString();
            }

            if (!model.get("application_type").equals("request_only")) {
                //we have a ta header and text to add
                PdfPCell cellConditions1 = new PdfPCell(new Paragraph(header1, font));

                cellConditions1.setColspan(2);
                cellConditions1.setBorder(0);
                table.addCell(cellConditions1);

                PdfPCell cellConditions2 = new PdfPCell(new Paragraph(text1));

                cellConditions2.setColspan(2);
                cellConditions2.setBorder(0);
                table.addCell(cellConditions2);

                PdfPCell cellConditions3 = new PdfPCell(new Paragraph(header2, font));

                cellConditions3.setColspan(2);
                cellConditions3.setBorder(0);
                table.addCell(cellConditions3);

                PdfPCell cellConditions4 = new PdfPCell(new Paragraph(text2));

                cellConditions4.setColspan(2);
                cellConditions4.setBorder(0);
                table.addCell(cellConditions4);

            } else {

                PdfPCell cellConditions = new PdfPCell(new Paragraph(header, font));
                cellConditions.setColspan(2);
                cellConditions.setBorder(0);
                table.addCell(cellConditions);

                PdfPCell cellConditionsTxt = new PdfPCell(new Paragraph(text));
                cellConditionsTxt.setColspan(2);
                cellConditionsTxt.setBorder(0);
                table.addCell(cellConditionsTxt);
            }

        }
        doc.add(table);

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException e) {
        System.err.println(e.getMessage());
    }

    doc.close();
    return filePath;
}

From source file:org.getobjects.samples.HelloPDF.PDFAction.java

License:Open Source License

/**
 * Add some content to the PDF. This is using iText methods to add some text
 * and a few tables to the given Document.
 * Note how you can reuse higher-level objects once they got added to the
 * document (iText does not keep a higher level structure but directly
 * generates the PDF content).// w w w .j ava 2  s  .c  om
 * 
 * @param _itext - the iText Document object
 * @throws DocumentException
 */
void addContent(Document _itext) throws DocumentException {

    /* a small paragraph */

    _itext.add(new Paragraph("Hello World"));

    /* a simple table (default width is 80%) */

    PdfPTable table = new PdfPTable(3);
    table.setSpacingBefore(10);
    table.setSpacingAfter(10);

    PdfPCell th = new PdfPCell(new Paragraph("Title"));
    th.setColspan(3);
    table.addCell(th);

    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 3; j++)
            table.addCell("" + i + "/" + j);
    }

    _itext.add(table);

    /* readd table with full width */

    table.setWidthPercentage(100);
    _itext.add(table);

    /* readd with align */

    table.setWidthPercentage(60);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    _itext.add(table);

    /* and make a big table to enforce a pagebreak */

    for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 3; j++)
            table.addCell("" + i + "/" + j);
    }
    _itext.add(table);
}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

/**
 * @param model//from w ww.jav  a2s .c  o m
 * @param doc
 * @param a
 * @throws DocumentException
 * @throws IOException
 * @throws BadElementException
 */
private void addSingleActionTable(GTDModel model, Document doc, Action a)
        throws DocumentException, IOException, BadElementException {
    Chunk ch;
    PdfPTable t;
    PdfPCell c;
    t = new PdfPTable(3);
    t.setSpacingBefore(5f);
    t.setWidthPercentage(100f);

    Paragraph ph = newParagraph();
    ch = newChunk(ID);
    ph.add(ch);
    ch = newChunk(String.valueOf(a.getId()));
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);
    c = newCell(ph);
    t.addCell(c);

    ph = newParagraph();
    ch = newChunk(CREATED);
    ph.add(ch);
    ch = newChunk(ApplicationHelper.toISODateTimeString(a.getCreated()));
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);
    c = newCell(ph);
    t.addCell(c);

    ph = newParagraph();
    if (a.isOpen()) {
        ch = newChunk(OPEN);
        ch.getFont().setStyle(Font.BOLD);
        ch.getFont().setColor(COLOR_OPEN);
        ph.add(ch);
        ch = newOpenChunk();
        ph.add(ch);
    } else if (a.isResolved()) {
        ch = newChunk(RESOLVED);
        ch.getFont().setStyle(Font.BOLD);
        ch.getFont().setColor(COLOR_RESOLVED);
        ph.add(ch);
        ch = newResolvedChunk();
        ph.add(ch);
    } else if (a.isDeleted()) {
        ch = newChunk(DELETED);
        ch.getFont().setStyle(Font.BOLD);
        ch.getFont().setColor(COLOR_DELETED);
        ph.add(ch);
        ch = newDeletedChunk();
        ph.add(ch);
    } else {
        ch = newChunk(STALLED);
        ch.getFont().setStyle(Font.BOLD);
        ch.getFont().setColor(COLOR_DELETED);
        ph.add(ch);
        ch = newStalledChunk();
        ph.add(ch);
    }
    c = newCell(ph);
    c.setHorizontalAlignment(Cell.ALIGN_RIGHT);
    t.addCell(c);

    ph = newParagraph();
    ch = newChunk(PRIORITY);
    ph.add(ch);
    ch = newChunk(a.getPriority() == null ? NONE : a.getPriority().toString());
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);
    ch = newChunk(" ");
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);

    if (a.getPriority() == null || a.getPriority() == Priority.None) {
        ch = newNoneStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
    } else if (a.getPriority() == Priority.Low) {
        ch = newLowStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
    } else if (a.getPriority() == Priority.Medium) {
        ch = newLowStarChunk();
        ph.add(ch);
        ch = newMediumStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
    } else if (a.getPriority() == Priority.High) {
        ch = newLowStarChunk();
        ph.add(ch);
        ch = newMediumStarChunk();
        ph.add(ch);
        ch = newHighStarChunk();
        ph.add(ch);
    }

    c = newCell(ph);
    t.addCell(c);

    ph = newParagraph();
    ch = newChunk(REMINDER);
    ph.add(ch);
    ch = newChunk(a.getRemind() != null ? ApplicationHelper.toISODateString(a.getRemind()) : NONE);
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);
    c = newCell(ph);
    t.addCell(c);

    ph = newParagraph();
    ch = newChunk(PROJECT);
    ph.add(ch);
    if (a.getProject() != null) {
        ch = newChunk(model.getProject(a.getProject()).getName());
    } else {
        ch = newChunk(NONE);
    }
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);
    c = newCell(ph);
    t.addCell(c);

    c = newDescriptionCell(a.getDescription());
    c.setColspan(3);
    t.addCell(c);

    if (a.getUrl() != null) {

        ch = newChunk(a.getUrl().toString());
        ch.setAnchor(a.getUrl());
        ch.getFont().setColor(Color.BLUE);

        c = newCell(new Paragraph(ch));
        c.setColspan(3);
        t.addCell(c);
    }

    doc.add(t);
}

From source file:org.jcryptool.visual.euclid.FileExporter.java

License:Open Source License

public void exportToPDF() {
    table = new PdfPTable(5);
    try {/*from w  ww. j av a 2  s  .c  o  m*/
        PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();
        PdfPCell cell = new PdfPCell();
        cell.setColspan(5);
        float[] width = { 1.2f, 3f, 3f, 3f, 3f };
        table.setTotalWidth(width);
        table.addCell("Index");
        table.addCell("Quotient");
        table.addCell("Remainder");
        table.addCell("x");
        table.addCell("y");

        int size = euclid.length;
        String pValue = euclid[2];
        String qValue = euclid[7];
        String yValue = euclid[size - 7];
        String xValue = euclid[size - 6];
        String resultValue = euclid[size - 8];

        for (int i = 0; i < size; i++) {
            table.addCell(new Phrase(euclid[i]));
            System.out.println("3 " + i);
        }

        document.add(new Paragraph("Extended Euclidian"));
        document.add(new Paragraph("gcd(" + pValue + "," + qValue + ")"));
        document.add(new Paragraph("\n"));
        document.add(table);
        document.add(new Paragraph("\n"));

        if (xValue.charAt(0) == '-') {
            xValue = "( " + xValue + " )";
        }
        if (yValue.charAt(0) == '-') {
            yValue = "( " + yValue + " )";
        }
        String tmpValue = " = " + pValue + " * " + yValue + " + " + qValue + " * " + xValue;
        String resultValueString = tmpValue + " = " + resultValue;

        document.add(new Paragraph(
                "The Greatest Common Divisor of " + pValue + " and " + qValue + " is " + resultValue + "."));
        document.add(new Paragraph("gcd(p,q) = p * x + q * y", fontValuesItalic));
        document.add(new Paragraph("gcd(" + pValue + "," + qValue + ")" + resultValueString, fontValuesItalic));
        document.close();

    } catch (FileNotFoundException e) {
        LogUtil.logError(e);
    } catch (DocumentException e) {
        LogUtil.logError(e);
    }
}

From source file:org.jcryptool.visual.xeuclidean.export.FileExporter.java

License:Open Source License

public void exportToPDF() {
    table = new PdfPTable(5);
    try {/*from  www .ja v a2 s  .  c o  m*/
        PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();
        PdfPCell cell = new PdfPCell();
        cell.setColspan(5);
        float[] width = { 1.2f, 3f, 3f, 3f, 3f };
        table.setTotalWidth(width);
        table.addCell("Index");
        table.addCell("Quotient");
        table.addCell("Remainder");
        table.addCell("X");
        table.addCell("Y");

        String pValue = rTmp.get(0).toString();
        String qValue = rTmp.get(1).toString();
        String yValue = yTmp.lastElement().toString();
        String xValue = xTmp.lastElement().toString();
        String resultValue = rTmp.get(qTmp.size() - 2).toString();
        String resultValueString;

        int size = qTmp.size();
        for (int index = 0; index < size; index++) {
            table.addCell(new Phrase(String.valueOf(index), fontValues));
            if (index == 0 || index == qTmp.size() - 1) {
                table.addCell(new Phrase("", fontValues));
            } else {
                table.addCell(new Phrase(qTmp.get(index).toString(), fontValues));
            }
            table.addCell(new Phrase(rTmp.get(index).toString(), fontValues));
            table.addCell(new Phrase(xTmp.get(index).toString(), fontValues));
            table.addCell(new Phrase(yTmp.get(index).toString(), fontValues));
        }

        document.add(new Paragraph("Extended Euclidian"));
        document.add(new Paragraph("gcd(" + pValue + "," + qValue + ")"));
        document.add(new Paragraph("\n"));
        document.add(table);
        document.add(new Paragraph("\n"));

        if (xTmp.lastElement().compareTo(BigInteger.ZERO) < 0) {
            xValue = "( " + xValue + " )";
        }
        if (yTmp.lastElement().compareTo(BigInteger.ZERO) < 0) {
            yValue = "( " + yValue + " )";
        }
        String tmpValue = " = " + pValue + " * " + yValue + " + " + qValue + " * " + xValue;
        resultValueString = tmpValue + " = " + resultValue;

        document.add(new Paragraph(
                "The Greates Common Divisor of " + pValue + " and " + qValue + " is " + resultValue + "."));
        document.add(new Paragraph("gcd(p,q) = p * x + q * y", fontValuesItalic));
        document.add(new Paragraph("gcd(" + rTmp.get(0) + "," + rTmp.get(1) + ")" + resultValueString,
                fontValuesItalic));
        document.close();

    } catch (FileNotFoundException e) {
        LogUtil.logError(e);
    } catch (DocumentException e) {
        LogUtil.logError(e);
    }
}

From source file:org.kuali.kfs.gl.report.TransactionReport.java

License:Open Source License

/**
 * Appends the scrubber totals/statistics and error report to the given (iText) document object.
 * //from   www.j a va 2  s .c o  m
 * @param document the PDF document
 * @param headerFont font for header
 * @param textFont font for report text
 * @param errorSortedList list of error'd transactions
 * @param reportErrors map containing transactions and the errors associated with each transaction
 * @param reportSummary list of summary objects
 * @param runDate date report was run
 * @throws DocumentException
 */
public void appendReport(Document document, Font headerFont, Font textFont, List<Transaction> errorSortedList,
        Map<Transaction, List<Message>> reportErrors, List<Summary> reportSummary, Date runDate)
        throws DocumentException {
    // Sort what we get
    Collections.sort(reportSummary);

    float[] summaryWidths = { 80, 20 };
    PdfPTable summary = new PdfPTable(summaryWidths);
    summary.setWidthPercentage(40);
    PdfPCell cell = new PdfPCell(new Phrase("S T A T I S T I C S", headerFont));
    cell.setColspan(2);
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    summary.addCell(cell);

    for (Iterator iter = reportSummary.iterator(); iter.hasNext();) {
        Summary s = (Summary) iter.next();

        cell = new PdfPCell(new Phrase(s.getDescription(), textFont));
        cell.setBorder(Rectangle.NO_BORDER);
        summary.addCell(cell);

        if ("".equals(s.getDescription())) {
            cell = new PdfPCell(new Phrase("", textFont));
            cell.setBorder(Rectangle.NO_BORDER);
            summary.addCell(cell);
        } else {
            DecimalFormat nf = new DecimalFormat("###,###,###,##0");
            cell = new PdfPCell(new Phrase(nf.format(s.getCount()), textFont));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            summary.addCell(cell);
        }
    }
    cell = new PdfPCell(new Phrase(""));
    cell.setColspan(2);
    cell.setBorder(Rectangle.NO_BORDER);
    summary.addCell(cell);

    document.add(summary);

    if (reportErrors != null && reportErrors.size() > 0) {
        float[] warningWidths = { 4, 3, 6, 5, 5, 4, 5, 5, 4, 5, 5, 9, 4, 36 };
        PdfPTable warnings = new PdfPTable(warningWidths);
        warnings.setHeaderRows(2);
        warnings.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("W A R N I N G S", headerFont));
        cell.setColspan(14);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        warnings.addCell(cell);

        // Add headers
        cell = new PdfPCell(new Phrase("Year", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("COA", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Account", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Sacct", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Obj", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("SObj", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("BalTyp", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("ObjTyp", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Prd", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("DocType", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Origin", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("DocNbr", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Seq", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Warning", headerFont));
        warnings.addCell(cell);

        for (Iterator errorIter = errorSortedList.iterator(); errorIter.hasNext();) {
            Transaction tran = (Transaction) errorIter.next();
            boolean first = true;

            List errors = (List) reportErrors.get(tran);
            for (Iterator listIter = errors.iterator(); listIter.hasNext();) {
                String msg = null;
                Object m = listIter.next();
                if (m instanceof Message) {
                    Message mm = (Message) m;
                    msg = mm.getMessage();
                } else {
                    if (m == null) {
                        msg = "";
                    } else {
                        msg = m.toString();
                    }
                }

                if (first) {
                    first = false;

                    if (tran.getUniversityFiscalYear() == null) {
                        cell = new PdfPCell(new Phrase("NULL", textFont));
                    } else {
                        cell = new PdfPCell(new Phrase(tran.getUniversityFiscalYear().toString(), textFont));
                    }
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getChartOfAccountsCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getAccountNumber(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getSubAccountNumber(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialObjectCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialSubObjectCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialBalanceTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialObjectTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getUniversityFiscalPeriodCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialDocumentTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialSystemOriginationCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getDocumentNumber(), textFont));
                    warnings.addCell(cell);
                    if (tran.getTransactionLedgerEntrySequenceNumber() == null) {
                        cell = new PdfPCell(new Phrase("NULL", textFont));
                    } else {
                        cell = new PdfPCell(new Phrase(
                                tran.getTransactionLedgerEntrySequenceNumber().toString(), textFont));
                    }
                    warnings.addCell(cell);
                } else {
                    cell = new PdfPCell(new Phrase("", textFont));
                    cell.setColspan(13);
                    warnings.addCell(cell);
                }
                cell = new PdfPCell(new Phrase(msg, textFont));
                warnings.addCell(cell);
            }
        }
        document.add(warnings);
    }
}

From source file:org.kuali.kfs.module.ar.report.service.impl.ContractsGrantsInvoiceReportServiceImpl.java

License:Open Source License

/**
 * this method generated the actual pdf for the Contracts & Grants LOC Review Document.
 *
 * @param os//from  w w  w . jav a 2  s . co m
 * @param LOCDocument
 */
protected void generateLOCReviewInPdf(OutputStream os,
        ContractsGrantsLetterOfCreditReviewDocument locDocument) {
    try {
        Document document = new Document(
                new Rectangle(ArConstants.LOCReviewPdf.LENGTH, ArConstants.LOCReviewPdf.WIDTH));
        PdfWriter.getInstance(document, os);
        document.open();

        Paragraph header = new Paragraph();
        Paragraph text = new Paragraph();
        Paragraph title = new Paragraph();

        // Lets write the header
        header.add(new Paragraph(configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_TITLE),
                ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundGroupCode())) {
            header.add(new Paragraph(
                    configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_GROUP_CODE)
                            + locDocument.getLetterOfCreditFundGroupCode(),
                    ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        }
        if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundCode())) {
            header.add(new Paragraph(
                    configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_CODE)
                            + locDocument.getLetterOfCreditFundCode(),
                    ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        }
        header.add(new Paragraph(KFSConstants.BLANK_SPACE));
        header.setAlignment(Element.ALIGN_CENTER);
        title.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_NUMBER)
                        + locDocument.getDocumentNumber(),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        Person person = getPersonService()
                .getPerson(locDocument.getFinancialSystemDocumentHeader().getInitiatorPrincipalId());
        // writing the Document details
        title.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_APP_DOC_STATUS)
                        + locDocument.getFinancialSystemDocumentHeader().getApplicationDocumentStatus(),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        title.add(
                new Paragraph(
                        configService.getPropertyValueAsString(
                                ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_INITIATOR) + person.getName(),
                        ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        title.add(new Paragraph(
                configService
                        .getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_CREATE_DATE)
                        + getDateTimeService().toDateString(
                                locDocument.getFinancialSystemDocumentHeader().getWorkflowCreateDate()),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));

        title.add(new Paragraph(KFSConstants.BLANK_SPACE));
        title.setAlignment(Element.ALIGN_RIGHT);

        text.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_SUBHEADER_AWARDS),
                ArConstants.PdfReportFonts.LOC_REVIEW_SMALL_BOLD));
        text.add(new Paragraph(KFSConstants.BLANK_SPACE));

        document.add(header);
        document.add(title);
        document.add(text);
        PdfPTable table = new PdfPTable(11);
        table.setTotalWidth(ArConstants.LOCReviewPdf.RESULTS_TABLE_WIDTH);
        // fix the absolute width of the table
        table.setLockedWidth(true);

        // relative col widths in proportions - 1/11
        float[] widths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f };
        table.setWidths(widths);
        table.setHorizontalAlignment(0);
        addAwardHeaders(table);
        if (CollectionUtils.isNotEmpty(locDocument.getHeaderReviewDetails())
                && CollectionUtils.isNotEmpty(locDocument.getAccountReviewDetails())) {
            for (ContractsGrantsLetterOfCreditReviewDetail item : locDocument.getHeaderReviewDetails()) {
                table.addCell(Long.toString(item.getProposalNumber()));
                table.addCell(item.getAwardDocumentNumber());
                table.addCell(item.getAgencyNumber());
                table.addCell(item.getCustomerNumber());
                table.addCell(getDateTimeService().toDateString(item.getAwardBeginningDate()));
                table.addCell(getDateTimeService().toDateString(item.getAwardEndingDate()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getAwardBudgetAmount()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getLetterOfCreditAmount()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getClaimOnCashBalance()));
                table.addCell(contractsGrantsBillingUtilityService.formatForCurrency(item.getAmountToDraw()));
                table.addCell(contractsGrantsBillingUtilityService
                        .formatForCurrency(item.getAmountAvailableToDraw()));

                PdfPCell cell = new PdfPCell();
                cell.setPadding(ArConstants.LOCReviewPdf.RESULTS_TABLE_CELL_PADDING);
                cell.setColspan(ArConstants.LOCReviewPdf.RESULTS_TABLE_COLSPAN);
                PdfPTable newTable = new PdfPTable(ArConstants.LOCReviewPdf.INNER_TABLE_COLUMNS);
                newTable.setTotalWidth(ArConstants.LOCReviewPdf.INNER_TABLE_WIDTH);
                // fix the absolute width of the newTable
                newTable.setLockedWidth(true);

                // relative col widths in proportions - 1/8
                float[] newWidths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f };
                newTable.setWidths(newWidths);
                newTable.setHorizontalAlignment(0);
                addAccountsHeaders(newTable);
                for (ContractsGrantsLetterOfCreditReviewDetail newItem : locDocument
                        .getAccountReviewDetails()) {
                    if (item.getProposalNumber().equals(newItem.getProposalNumber())) {
                        newTable.addCell(newItem.getAccountDescription());
                        newTable.addCell(newItem.getChartOfAccountsCode());
                        newTable.addCell(newItem.getAccountNumber());
                        String accountExpirationDate = KFSConstants.EMPTY_STRING;
                        if (!ObjectUtils.isNull(newItem.getAccountExpirationDate())) {
                            accountExpirationDate = getDateTimeService()
                                    .toDateString(newItem.getAccountExpirationDate());
                        }
                        newTable.addCell(accountExpirationDate);
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getAwardBudgetAmount()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getClaimOnCashBalance()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getAmountToDraw()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getFundsNotDrawn()));
                    }
                }
                cell.addElement(newTable);
                table.addCell(cell);

            }
            document.add(table);
        }
        document.close();
    } catch (DocumentException e) {
        LOG.error("problem during ContractsGrantsInvoiceReportServiceImpl.generateInvoiceInPdf()", e);
    }
}