Example usage for com.lowagie.text.pdf PdfPTable setSkipFirstHeader

List of usage examples for com.lowagie.text.pdf PdfPTable setSkipFirstHeader

Introduction

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

Prototype

public void setSkipFirstHeader(boolean skipFirstHeader) 

Source Link

Document

Skips the printing of the first header.

Usage

From source file:com.krawler.esp.servlets.ExportPDFServlet.java

License:Open Source License

private int addTable(int stcol, int stpcol, int strow, int stprow, JSONArray store, String[] colwidth2,
        String[] colIndex1, Document document) {
    float[] f = new float[(stpcol - stcol)];
    for (int k = 0; k < f.length; k++)
        f[k] = 20;//from   www  .  j  av a 2 s.co  m
    PdfPTable table = new PdfPTable(f);
    PdfPCell cell = new PdfPCell(new Paragraph("Agenda Details"));
    cell.setColspan(6);
    table.addCell(cell);
    Font font = FontFactory.getFont("Helvetica", 8, Font.BOLD, Color.BLACK);
    Font font1 = FontFactory.getFont("Helvetica", 8, Font.NORMAL, Color.BLACK);
    Font f1;
    int stpcol1 = 0;
    for (int hcol = stcol; hcol < stpcol; hcol++) {
        PdfPCell h1 = new PdfPCell(new Paragraph(colwidth2[hcol], font)); // new
        // Paragraph(colwidth2[hcol],font);
        table.addCell(h1);
    }
    table.setHeaderRows(1);
    try {
        for (int row = strow; row < stprow; row++) {
            if (row % 62 == 61) {
                document.add(table);
                table.deleteBodyRows();
                table.setSkipFirstHeader(true);
            }
            f1 = font1;
            for (int col = stcol; col < stpcol; col++) {
                table.addCell(new Paragraph(store.getJSONObject(row).getString(colIndex1[col]), f1));
            }
        }
        document.newPage();
        document.add(table);

        if (stpcol != colIndex1.length) {
            if ((colIndex1.length - stpcol) > 5) // column limit
                stpcol1 = stpcol + 5;
            else
                stpcol1 = (colIndex1.length - stpcol) + stpcol;
            addTable(stpcol, stpcol1, strow, stprow, store, colwidth2, colIndex1, document);
        }
    } catch (Exception e) {
        e.toString();
    }
    return stpcol;
}

From source file:com.krawler.esp.servlets.ExportProjectReportServlet.java

License:Open Source License

private int addTableTimeLine(int stcol, int stpcol, int strow, int stprow, JSONArray store, String[] colwidth2,
        int maxlevel, Document document) throws JSONException, DocumentException {
    float[] f = new float[(stpcol - stcol) + 1];
    for (int k = 0; k < f.length; k++) {
        f[k] = 20;//from  www .j  a  va 2  s . com
    }
    f[0] = f[0] + 10 * maxlevel;
    PdfPTable table = new PdfPTable(f);

    java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));

    Font font = FontFactory.getFont("Helvetica", 8, Font.BOLD, tColor);
    Font font1 = FontFactory.getFont("Helvetica", 8, Font.NORMAL, tColor);
    Font f1;

    table.setWidthPercentage(90);
    PdfPCell h2 = new PdfPCell(new Paragraph("Name", font)); // new
    if (config.getBoolean("gridBorder"))
        h2.setBorder(PdfPCell.BOX);
    else
        h2.setBorder(0);
    h2.setPadding(2);
    //                h2.setHorizontalAlignment(Element.ALIGN_UNDEFINED);
    // Paragraph(colwidth2[hcol],font);
    table.addCell(h2);
    int stpcol1 = 0;
    for (int hcol = stcol; hcol < stpcol; hcol++) {
        PdfPCell h1 = new PdfPCell(new Paragraph(colwidth2[hcol], font)); // new
        h1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        if (config.getBoolean("gridBorder"))
            h1.setBorder(PdfPCell.BOX);
        else
            h1.setBorder(0);
        h1.setPadding(2);
        // Paragraph(colwidth2[hcol],font);
        table.addCell(h1);
    }
    table.setHeaderRows(1);

    for (int row = strow; row < stprow; row++) {
        if (row % 62 == 61) {
            document.add(table);
            table.deleteBodyRows();
            table.setSkipFirstHeader(true);
        }
        if (store.getJSONObject(row).getBoolean("flag"))
            f1 = font;
        else
            f1 = font1;
        if (store.getJSONObject(row).getString("info").compareTo("") != 0) {
            h2 = new PdfPCell(new Paragraph(store.getJSONObject(row).getString("info"), f1));
            //                    h2.setPaddingLeft((Integer.parseInt(store.getJSONObject(row).getString("level")) * 10) + 5);
        } else {
            h2 = new PdfPCell(new Paragraph(store.getJSONObject(row).getString("info"), f1));
            //                    h2.setPaddingTop(9);
            //                    h2.setPaddingLeft((Integer.parseInt(store.getJSONObject(row).getString("level")) * 10) + 5);
        }

        //                h2.setBorder(0);
        //                h2.setPadding(1);
        //                Color bColor = Color.decode("DDDDDD");

        if (config.getBoolean("gridBorder")) {
            if (store.getJSONObject(row).getBoolean("flag")) {
                h2.setBackgroundColor(new Color(0xEEEEEE));
                h2.setBorder(PdfPCell.LEFT | PdfPCell.BOTTOM);
            } else
                h2.setBorder(PdfPCell.BOX);
        } else {
            h2.setBorder(0);
        }
        h2.setPadding(2);
        h2.setBorderColor(Color.GRAY);
        if (store.getJSONObject(row).getBoolean("flag"))
            h2.setHorizontalAlignment(Element.ALIGN_LEFT);
        else
            h2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        h2.setVerticalAlignment(Element.ALIGN_CENTER);
        table.addCell(h2);
        for (int col = stcol; col < stpcol; col++) {
            Paragraph para = new Paragraph(store.getJSONObject(row).getString(colwidth2[col]), f1);
            PdfPCell h1 = new PdfPCell(para);
            //                    h1.setBorder(0);
            //                    h1.setPadding(1);

            h1.setMinimumHeight(15);
            h1.setHorizontalAlignment(Element.ALIGN_RIGHT);
            h1.setVerticalAlignment(Element.ALIGN_CENTER);
            if (config.getBoolean("gridBorder")) {
                if (store.getJSONObject(row).getBoolean("flag")) {
                    h1.setBorder(PdfPCell.BOTTOM);
                    h1.setBackgroundColor(new Color(0xEEEEEE));
                    if (col == stpcol - 1)
                        h1.setBorder(PdfPCell.BOTTOM | PdfPCell.RIGHT);
                } else
                    h1.setBorder(PdfPCell.BOX);
            } else {
                h1.setBorder(0);
            }
            h1.setPadding(2);
            h1.setBorderColor(Color.GRAY);
            table.addCell(h1);
            //               table.addCell(new Paragraph(store.getJSONObject(row)
            //                     .getString(colwidth2[col]), f1));
        }

    }
    document.add(table);
    document.newPage();
    if (stpcol != colwidth2.length) {
        if ((colwidth2.length - stpcol) > 5) // column limit
            stpcol1 = stpcol + 5;
        else
            stpcol1 = (colwidth2.length - stpcol) + stpcol;
        addTableTimeLine(stpcol, stpcol1, strow, stprow, store, colwidth2, maxlevel, document);
    }

    return stpcol;
}

From source file:com.krawler.esp.servlets.ExportReportServlet.java

License:Open Source License

private int addTable(int stcol, int stpcol, int strow, int stprow, JSONArray store, String[] colwidth2,
        int maxlevel, Document document) {
    float[] f = new float[(stpcol - stcol) + 1];
    for (int k = 0; k < f.length; k++) {
        f[k] = 20;//from  w  w  w.  j  a v  a2s  .com
    }
    f[0] = f[0] + 10 * maxlevel;
    PdfPTable table = new PdfPTable(f);
    Font font = FontFactory.getFont("Helvetica", 8, Font.BOLD, Color.BLACK);
    Font font1 = FontFactory.getFont("Helvetica", 8, Font.NORMAL, Color.BLACK);
    Font f1;
    PdfPCell h2 = new PdfPCell(new Paragraph("", font)); // new
    h2.setBorder(0);
    h2.setPadding(1);
    //                h2.setHorizontalAlignment(Element.ALIGN_UNDEFINED);                                       
    // Paragraph(colwidth2[hcol],font);
    table.addCell(h2);
    int stpcol1 = 0;
    for (int hcol = stcol; hcol < stpcol; hcol++) {
        PdfPCell h1 = new PdfPCell(new Paragraph(colwidth2[hcol], font)); // new
        h1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        h1.setBorder(0);
        h1.setPadding(1);
        // Paragraph(colwidth2[hcol],font);
        table.addCell(h1);
    }
    table.setHeaderRows(1);
    try {
        for (int row = strow; row < stprow; row++) {
            if (row % 62 == 61) {
                document.add(table);
                table.deleteBodyRows();
                table.setSkipFirstHeader(true);
            }
            if (store.getJSONObject(row).getBoolean("flag"))
                f1 = font;
            else
                f1 = font1;
            if (store.getJSONObject(row).getString("info").compareTo("") != 0) {
                h2 = new PdfPCell(new Paragraph(store.getJSONObject(row).getString("info"), f1));
                h2.setPaddingLeft((Integer.parseInt(store.getJSONObject(row).getString("level")) * 10) + 5);
            } else {
                h2 = new PdfPCell(new Paragraph(store.getJSONObject(row).getString("info"), f1));
                h2.setPaddingTop(9);
                h2.setPaddingLeft((Integer.parseInt(store.getJSONObject(row).getString("level")) * 10) + 5);
            }
            h2.setBorder(0);
            h2.setPadding(1);
            if (store.getJSONObject(row).getBoolean("flag"))
                h2.setHorizontalAlignment(Element.ALIGN_LEFT);
            else
                h2.setHorizontalAlignment(Element.ALIGN_RIGHT);
            h2.setVerticalAlignment(Element.ALIGN_CENTER);
            table.addCell(h2);
            for (int col = stcol; col < stpcol; col++) {
                Paragraph para = null;
                if (store.getJSONObject(row).has(colwidth2[col]))
                    para = new Paragraph(store.getJSONObject(row).getString(colwidth2[col]), f1);
                else
                    para = new Paragraph("", f1);
                //                    Paragraph para = new Paragraph(store.getJSONObject(row).getString(colwidth2[col]), f1);
                PdfPCell h1 = new PdfPCell(para);
                h1.setBorder(0);
                h1.setPadding(1);
                h1.setHorizontalAlignment(Element.ALIGN_RIGHT);
                h1.setVerticalAlignment(Element.ALIGN_CENTER);
                table.addCell(h1);
                //               table.addCell(new Paragraph(store.getJSONObject(row)
                //                     .getString(colwidth2[col]), f1));
            }

        }
        document.add(table);
        document.newPage();
        if (stpcol != colwidth2.length) {
            if ((colwidth2.length - stpcol) > 5) // column limit
                stpcol1 = stpcol + 5;
            else
                stpcol1 = (colwidth2.length - stpcol) + stpcol;
            addTable(stpcol, stpcol1, strow, stprow, store, colwidth2, maxlevel, document);
        }

    } catch (com.krawler.utils.json.base.JSONException j) {
        KrawlerLog.op.warn("Problem During Creating JSON Object :" + j.toString());
    } catch (com.lowagie.text.DocumentException de) {
        KrawlerLog.op.warn("Problem While Creating PDF :" + de.toString());
    }
    return stpcol;
}

From source file:com.krawler.spring.hrms.printreport.PrintAppraisalReportDAOImp.java

License:Open Source License

public void createPDFPriview(HttpServletRequest request, HttpServletResponse response, JSONArray obj,
        Map<String, String> personalData) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Document document = new Document(PageSize.A4.rotate(), 25, 25, 25, 25);

    PdfWriter writer = null;/*from w  w  w .  j  av a 2 s  . c  o m*/
    try {
        HashMap<String, Object> requestParams = new HashMap<String, Object>();

        boolean isQuestion = request.getParameter("question").equals("true") ? true : false;
        boolean promotion = request.getParameter("promotion").equals("false") ? false : true;
        Boolean isMyAppraisal = Boolean.parseBoolean(personalData.get("isMyAppraisal"));
        CompanyPreferences companyPreferences = (CompanyPreferences) hibernateTemplate
                .get(CompanyPreferences.class, sessionHandlerImplObj.getCompanyid(request));
        writer = PdfWriter.getInstance(document, baos);
        writer.setPageEvent(new EndPage());
        document.open();
        java.awt.Color tColor = new Color(9, 9, 9);
        //fontSmallBold.setColor(tColor);

        //heading
        PdfPTable headTable = new PdfPTable(1);
        headTable.setTotalWidth(90);
        headTable.setWidthPercentage(100);
        headTable.setSpacingBefore(20);
        PdfPCell headcell = new PdfPCell(
                new Paragraph(fontFamilySelector.process(messageSource.getMessage("hrms.common.AppraisalForm",
                        null, RequestContextUtils.getLocale(request)), FontContext.REGULAR_BOLD_HELVETICA)));
        headcell.setBackgroundColor(new Color(0xEEEEEE));
        headcell.setPadding(5);
        headTable.addCell(headcell);
        document.add(headTable);
        //heading

        //Details
        int flag = 0;
        String appDetailsParam[] = {
                messageSource.getMessage("hrms.performance.appraisal.cycle.name", null,
                        RequestContextUtils.getLocale(request)) + ":  ",
                messageSource.getMessage("hrms.common.employee.name", null,
                        RequestContextUtils.getLocale(request)) + ":  ",
                messageSource.getMessage("hrms.performance.appraisal.cycle.period", null,
                        RequestContextUtils.getLocale(request)) + ":  ",
                messageSource.getMessage("hrms.Masters.Designation", null,
                        RequestContextUtils.getLocale(request)) + ":  ",
                messageSource.getMessage("hrms.performance.performance.rating", null,
                        RequestContextUtils.getLocale(request)) + "*:  " };
        String appDetailsValue[] = { personalData.get("appcycname"), personalData.get("empname"),
                messageSource.getMessage("hrms.common.form", null, RequestContextUtils.getLocale(request))
                        + ": " + personalData.get("startdate") + " "
                        + messageSource.getMessage("hrms.common.to", null,
                                RequestContextUtils.getLocale(request))
                        + ": " + personalData.get("enddate"),
                personalData.get("desgname"), personalData.get("performance") };

        requestParams.clear();
        requestParams.put("companyid", sessionHandlerImplObj.getCompanyid(request));
        requestParams.put("checklink", "promotion");
        if (!hrmsCommonDAOObj.checkModule(requestParams).isSuccessFlag()) {
            flag = 1;
        }

        PdfPTable appDetailsTable = new PdfPTable(2);
        appDetailsTable.setWidthPercentage(100);
        appDetailsTable.setWidths(new float[] { 55, 75 });
        if (isMyAppraisal) {
            flag = 1;
        }

        for (int i = 0; i < (appDetailsParam.length - flag); i++) {
            PdfPCell pcell = new PdfPCell(new Paragraph(
                    fontFamilySelector.process(appDetailsParam[i], FontContext.MEDIUM_BOLD_HELVETICA)));
            pcell.setBorder(0);
            pcell.setPaddingTop(10);
            pcell.setPaddingLeft(15);
            pcell.setPaddingBottom(4);
            pcell.setBorderColor(new Color(0xF2F2F2));
            pcell.setHorizontalAlignment(Element.ALIGN_LEFT);
            pcell.setVerticalAlignment(Element.ALIGN_LEFT);
            appDetailsTable.addCell(pcell);

            PdfPCell pcell1 = new PdfPCell(new Paragraph(
                    fontFamilySelector.process(appDetailsValue[i], FontContext.SMALL_NORMAL_HELVETICA)));
            pcell1.setBorder(0);
            pcell1.setPaddingTop(10);
            pcell1.setPaddingLeft(15);
            pcell1.setPaddingBottom(4);
            pcell1.setBorderColor(new Color(0xF2F2F2));
            pcell1.setHorizontalAlignment(Element.ALIGN_LEFT);
            pcell1.setVerticalAlignment(Element.ALIGN_LEFT);
            appDetailsTable.addCell(pcell1);
        }

        requestParams.clear();
        requestParams.put("companyid", sessionHandlerImplObj.getCompanyid(request));
        requestParams.put("checklink", "overallcomments");
        if (hrmsCommonDAOObj.checkModule(requestParams).isSuccessFlag()) {
            PdfPCell pcell = new PdfPCell(new Paragraph(fontFamilySelector.process(
                    (isMyAppraisal
                            ? messageSource.getMessage("hrms.performance.self.overall.comment", null,
                                    RequestContextUtils.getLocale(request)) + ":  "
                            : messageSource.getMessage("hrms.performance.overall.appraiser.comments", null,
                                    RequestContextUtils.getLocale(request)) + ":  "),
                    FontContext.MEDIUM_BOLD_HELVETICA)));
            pcell.setBorder(0);
            pcell.setPaddingTop(10);
            pcell.setPaddingLeft(15);
            pcell.setPaddingBottom(4);
            pcell.setBorderColor(new Color(0xF2F2F2));
            pcell.setHorizontalAlignment(Element.ALIGN_LEFT);
            pcell.setVerticalAlignment(Element.ALIGN_LEFT);
            appDetailsTable.addCell(pcell);

            PdfPCell pcell1 = new PdfPCell(new Paragraph(fontFamilySelector.process(
                    (isMyAppraisal ? personalData.get("selfcomment") : personalData.get("empcomment")),
                    FontContext.SMALL_NORMAL_HELVETICA)));
            pcell1.setBorder(0);
            pcell1.setPaddingTop(10);
            pcell1.setPaddingLeft(15);
            pcell1.setPaddingBottom(4);
            pcell1.setBorderColor(new Color(0xF2F2F2));
            pcell1.setHorizontalAlignment(Element.ALIGN_LEFT);
            pcell1.setVerticalAlignment(Element.ALIGN_LEFT);
            appDetailsTable.addCell(pcell1);
        }

        requestParams.clear();
        requestParams.put("companyid", sessionHandlerImplObj.getCompanyid(request));
        requestParams.put("checklink", "promotion");
        if (!isMyAppraisal && hrmsCommonDAOObj.checkModule(requestParams).isSuccessFlag()) {
            PdfPCell pcell = new PdfPCell(new Paragraph(fontFamilySelector.process(
                    messageSource.getMessage("hrms.performance.promotion.recommendation", null,
                            RequestContextUtils.getLocale(request)) + ":  ",
                    FontContext.MEDIUM_BOLD_HELVETICA)));
            pcell.setBorder(0);
            pcell.setPaddingTop(10);
            pcell.setPaddingLeft(15);
            pcell.setPaddingBottom(4);
            pcell.setBorderColor(new Color(0xF2F2F2));
            pcell.setHorizontalAlignment(Element.ALIGN_LEFT);
            pcell.setVerticalAlignment(Element.ALIGN_LEFT);
            appDetailsTable.addCell(pcell);

            PdfPCell pcell1 = new PdfPCell(new Paragraph(fontFamilySelector.process(
                    (promotion
                            ? messageSource.getMessage("hrms.MasterData.Yes", null,
                                    RequestContextUtils.getLocale(request))
                            : messageSource.getMessage("hrms.MasterData.No", null,
                                    RequestContextUtils.getLocale(request))),
                    FontContext.SMALL_NORMAL_HELVETICA)));
            pcell1.setBorder(0);
            pcell1.setPaddingTop(10);
            pcell1.setPaddingLeft(15);
            pcell1.setPaddingBottom(4);
            pcell1.setBorderColor(new Color(0xF2F2F2));
            pcell1.setHorizontalAlignment(Element.ALIGN_LEFT);
            pcell1.setVerticalAlignment(Element.ALIGN_LEFT);
            appDetailsTable.addCell(pcell1);
        }

        if (promotion && !isMyAppraisal && hrmsCommonDAOObj.checkModule(requestParams).isSuccessFlag()) {
            String[] appDetaisPromotionParam = {
                    messageSource.getMessage("hrms.performance.new.department", null,
                            RequestContextUtils.getLocale(request)) + ":  ",
                    messageSource.getMessage("hrms.performance.new.designation", null,
                            RequestContextUtils.getLocale(request)) + ":  ",
                    messageSource.getMessage("hrms.performance.salary.increment", null,
                            RequestContextUtils.getLocale(request)) + "(%):  " };
            String[] appDetaisPromotionValue = {
                    personalData.get("newDept") != null ? personalData.get("newDept") : "",
                    personalData.get("newDesig") != null ? personalData.get("newDesig") : "",
                    personalData.get("salInc") != null ? personalData.get("salInc") : "" };
            for (int i = 0; i < appDetaisPromotionParam.length; i++) {
                PdfPCell pcell = new PdfPCell(new Paragraph(fontFamilySelector
                        .process(appDetaisPromotionParam[i], FontContext.MEDIUM_BOLD_HELVETICA)));
                pcell.setBorder(0);
                pcell.setPaddingTop(10);
                pcell.setPaddingLeft(15);
                pcell.setPaddingBottom(4);
                pcell.setBorderColor(new Color(0xF2F2F2));
                pcell.setHorizontalAlignment(Element.ALIGN_LEFT);
                pcell.setVerticalAlignment(Element.ALIGN_LEFT);
                appDetailsTable.addCell(pcell);

                PdfPCell pcell1 = new PdfPCell(new Paragraph(fontFamilySelector
                        .process(appDetaisPromotionValue[i], FontContext.SMALL_NORMAL_HELVETICA)));
                pcell1.setBorder(0);
                pcell1.setPaddingTop(10);
                pcell1.setPaddingLeft(15);
                pcell1.setPaddingBottom(4);
                pcell1.setBorderColor(new Color(0xF2F2F2));
                pcell1.setHorizontalAlignment(Element.ALIGN_LEFT);
                pcell1.setVerticalAlignment(Element.ALIGN_LEFT);
                appDetailsTable.addCell(pcell1);
            }
        }
        document.add(appDetailsTable);
        //Details

        //Comp
        requestParams.clear();
        requestParams.put("companyid", sessionHandlerImplObj.getCompanyid(request));
        requestParams.put("checklink", "competency");
        if (hrmsCommonDAOObj.checkModule(requestParams).isSuccessFlag()) {
            try {
                if (!isQuestion) {
                    JSONArray jsonComp = obj.getJSONArray(0);
                    if (!isMyAppraisal) {
                        String[] compParam = {
                                messageSource.getMessage("hrms.performance.competency", null,
                                        RequestContextUtils.getLocale(request)),
                                messageSource.getMessage("hrms.performance.competency.description", null,
                                        RequestContextUtils.getLocale(request)),
                                messageSource.getMessage("hrms.performance.weightage", null,
                                        RequestContextUtils.getLocale(request)),
                                messageSource.getMessage("hrms.performance.appraiser.rating", null,
                                        RequestContextUtils.getLocale(request)),
                                messageSource.getMessage("hrms.performance.appraiser.comment", null,
                                        RequestContextUtils.getLocale(request)) };
                        String[] colParam = { "cmptname", "cmptdesc", "cmptwt", "manrat", "mancompcomment" };
                        PdfPTable questionTable = null;
                        if (companyPreferences.isWeightage()) {
                            questionTable = new PdfPTable(5);
                            questionTable.setWidths(new float[] { 50, 60, 30, 30, 42 });
                        } else {
                            questionTable = new PdfPTable(4);
                            questionTable.setWidths(new float[] { 50, 60, 30, 42 });
                        }
                        questionTable.setWidthPercentage(100);
                        questionTable.setSpacingBefore(20);
                        questionTable.setHeaderRows(1);
                        for (int i = 0; i < compParam.length; i++) {
                            if (!(!companyPreferences.isWeightage() && i == 2)) {
                                PdfPCell pgcell = new PdfPCell(new Paragraph(fontFamilySelector
                                        .process(compParam[i], FontContext.MEDIUM_BOLD_HELVETICA)));
                                pgcell.setBorder(0);
                                pgcell.setBorder(PdfPCell.BOX);
                                pgcell.setPadding(4);
                                pgcell.setBorderColor(Color.GRAY);
                                pgcell.setHorizontalAlignment(Element.ALIGN_CENTER);
                                questionTable.addCell(pgcell);
                            }
                        }

                        for (int i = 0; i < jsonComp.length(); i++) {
                            for (int j = 0; j < colParam.length; j++) {
                                if (!(!companyPreferences.isWeightage() && j == 2)) {
                                    PdfPCell pcell = null;
                                    if (j != 3)
                                        pcell = new PdfPCell(
                                                new Paragraph(fontFamilySelector.process(
                                                        jsonComp.getJSONObject(i).has(colParam[j]) ? jsonComp
                                                                .getJSONObject(i).getString(colParam[j]) : "",
                                                        FontContext.SMALL_NORMAL_HELVETICA)));
                                    else {
                                        pcell = new PdfPCell(new Paragraph(fontFamilySelector.process(
                                                jsonComp.getJSONObject(i).has(colParam[j])
                                                        ? (jsonComp.getJSONObject(i).getString(colParam[j])
                                                                .equals("0")
                                                                        ? ""
                                                                        : jsonComp.getJSONObject(i)
                                                                                .getString(colParam[j]))
                                                        : "",
                                                FontContext.SMALL_NORMAL_HELVETICA)));
                                    }
                                    pcell.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                                    pcell.setBorderColor(Color.GRAY);
                                    pcell.setPadding(4);
                                    pcell.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    pcell.setVerticalAlignment(Element.ALIGN_CENTER);
                                    questionTable.addCell(pcell);
                                }
                            }
                        }
                        document.add(questionTable);
                    } else {
                        String[] compParam = {
                                messageSource.getMessage("hrms.performance.competency", null,
                                        RequestContextUtils.getLocale(request)),
                                messageSource.getMessage("hrms.performance.competency.description", null,
                                        RequestContextUtils.getLocale(request)),
                                messageSource.getMessage("hrms.performance.weightage", null,
                                        RequestContextUtils.getLocale(request)),
                                messageSource.getMessage("hrms.performance.self.rating", null,
                                        RequestContextUtils.getLocale(request)),
                                messageSource.getMessage("hrms.performance.self.comments", null,
                                        RequestContextUtils.getLocale(request)) };
                        String[] colParam = { "cmptname", "cmptdesc", "cmptwt", "emprat", "empcompcomment" };
                        PdfPTable questionTable = null;
                        if (companyPreferences.isWeightage()) {
                            questionTable = new PdfPTable(5);
                            questionTable.setWidths(new float[] { 50, 60, 30, 30, 42 });
                        } else {
                            questionTable = new PdfPTable(4);
                            questionTable.setWidths(new float[] { 50, 60, 30, 42 });
                        }
                        questionTable.setWidthPercentage(100);
                        questionTable.setSpacingBefore(20);
                        questionTable.setHeaderRows(1);
                        for (int i = 0; i < compParam.length; i++) {
                            if (!(!companyPreferences.isWeightage() && i == 2)) {
                                PdfPCell pgcell = new PdfPCell(new Paragraph(fontFamilySelector
                                        .process(compParam[i], FontContext.MEDIUM_BOLD_HELVETICA)));
                                pgcell.setBorder(0);
                                pgcell.setBorder(PdfPCell.BOX);
                                pgcell.setPadding(4);
                                pgcell.setBorderColor(Color.GRAY);
                                pgcell.setHorizontalAlignment(Element.ALIGN_CENTER);
                                questionTable.addCell(pgcell);
                            }
                        }

                        for (int i = 0; i < jsonComp.length(); i++) {
                            for (int j = 0; j < colParam.length; j++) {
                                if (!(!companyPreferences.isWeightage() && j == 2)) {
                                    PdfPCell pcell;
                                    if (j != 3)
                                        pcell = new PdfPCell(
                                                new Paragraph(fontFamilySelector.process(
                                                        jsonComp.getJSONObject(i).has(colParam[j]) ? jsonComp
                                                                .getJSONObject(i).getString(colParam[j]) : "",
                                                        FontContext.SMALL_NORMAL_HELVETICA)));
                                    else
                                        pcell = new PdfPCell(new Paragraph(fontFamilySelector.process(
                                                jsonComp.getJSONObject(i).has(colParam[j])
                                                        ? (jsonComp.getJSONObject(i).getString(colParam[j])
                                                                .equals("0")
                                                                        ? ""
                                                                        : jsonComp.getJSONObject(i)
                                                                                .getString(colParam[j]))
                                                        : "",
                                                FontContext.SMALL_NORMAL_HELVETICA)));
                                    pcell.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                                    pcell.setBorderColor(Color.GRAY);
                                    pcell.setPadding(4);
                                    pcell.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    pcell.setVerticalAlignment(Element.ALIGN_CENTER);
                                    questionTable.addCell(pcell);
                                }
                            }
                        }
                        document.add(questionTable);
                    }
                } else {//Questions
                    try {
                        JSONArray jsonQues = obj.getJSONArray(1);
                        JSONArray jsonAnsTemp = obj.getJSONArray(2);
                        JSONArray jsonAns = new JSONArray();

                        PdfPTable quesMainTable = new PdfPTable(1);
                        quesMainTable.setTotalWidth(90);
                        quesMainTable.setWidthPercentage(100);
                        quesMainTable.setSpacingBefore(20);
                        quesMainTable.setSkipFirstHeader(true);
                        PdfPCell quesHeadcell = new PdfPCell(new Paragraph(fontFamilySelector.process(
                                messageSource.getMessage("hrms.performance.qualitative.appraisal", null,
                                        RequestContextUtils.getLocale(request)),
                                FontContext.MEDIUM_BOLD_HELVETICA)));
                        quesHeadcell.setPadding(5);
                        quesMainTable.addCell(quesHeadcell);
                        document.add(quesMainTable);

                        PdfPTable[] quesTable = new PdfPTable[jsonQues.length()];

                        try {
                            for (int i = 0; i < jsonQues.length(); i++) {
                                String qid = (String) jsonQues.getJSONObject(i).get("qdescription");
                                for (int j = 0; j < jsonAnsTemp.length(); j++) {
                                    try {
                                        if (qid.equals((String) jsonAnsTemp.getJSONObject(j).get("question"))) {
                                            jsonAns.put(jsonAnsTemp.getJSONObject(j));
                                            break;
                                        }
                                    } catch (JSONException e) {
                                        jsonAns.put("");
                                    }
                                }
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        for (int i = 0; i < jsonQues.length(); i++) {
                            quesTable[i] = new PdfPTable(2);
                            quesTable[i].setWidthPercentage(90);
                            quesTable[i].setWidths(new float[] { 10, 80 });
                            quesTable[i].setSpacingBefore(20);
                            quesTable[i].setHeaderRows(1);

                            PdfPCell pgcell1 = new PdfPCell(new Paragraph(fontFamilySelector.process(
                                    messageSource.getMessage("hrms.performance.que", null,
                                            RequestContextUtils.getLocale(request)) + ".",
                                    FontContext.SMALL_NORMAL_HELVETICA)));
                            pgcell1.setBorder(0);
                            pgcell1.setBorder(PdfPCell.BOX);
                            pgcell1.setPadding(4);
                            pgcell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                            quesTable[i].addCell(pgcell1);

                            PdfPCell pgcell2 = new PdfPCell(
                                    new Paragraph(
                                            fontFamilySelector
                                                    .process(
                                                            jsonQues.getJSONObject(i).has("qdesc") ? jsonQues
                                                                    .getJSONObject(i).getString("qdesc") : "",
                                                            FontContext.SMALL_NORMAL_HELVETICA)));
                            pgcell2.setBorder(0);
                            pgcell2.setBorder(PdfPCell.BOX);
                            pgcell2.setPadding(4);
                            pgcell2.setHorizontalAlignment(Element.ALIGN_LEFT);
                            quesTable[i].addCell(pgcell2);

                            int cnt = 0;
                            try {
                                cnt = jsonQues.getJSONObject(i).has("qans")
                                        ? Integer.parseInt(jsonQues.getJSONObject(i).getString("qans"))
                                        : 0;
                            } catch (NumberFormatException e) {
                                e.printStackTrace();
                            }
                            if (jsonAns.length() > 0) {
                                JSONArray arr = jsonAns.getJSONObject(i).getJSONArray("answer");
                                for (int j = 0; j < arr.length(); j++) {
                                    PdfPCell pcell1 = new PdfPCell(new Paragraph(fontFamilySelector
                                            .process((j + 1) + "", FontContext.SMALL_NORMAL_HELVETICA)));
                                    pcell1.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                                    pcell1.setBorderColor(Color.GRAY);
                                    pcell1.setPadding(4);
                                    pcell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    pcell1.setVerticalAlignment(Element.ALIGN_CENTER);
                                    quesTable[i].addCell(pcell1);

                                    PdfPCell pcell2 = new PdfPCell(new Paragraph(fontFamilySelector.process(
                                            arr.getJSONObject(j).getString("" + j + ""),
                                            FontContext.SMALL_NORMAL_HELVETICA)));
                                    pcell2.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                                    pcell2.setBorderColor(Color.GRAY);
                                    pcell2.setPadding(4);
                                    pcell2.setHorizontalAlignment(Element.ALIGN_LEFT);
                                    pcell2.setVerticalAlignment(Element.ALIGN_CENTER);
                                    quesTable[i].addCell(pcell2);
                                }
                            } else {
                                for (int j = 0; j < cnt; j++) {
                                    PdfPCell pcell1 = new PdfPCell(new Paragraph(fontFamilySelector
                                            .process((j + 1) + "", FontContext.SMALL_NORMAL_HELVETICA)));
                                    pcell1.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                                    pcell1.setBorderColor(Color.GRAY);
                                    pcell1.setPadding(4);
                                    pcell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    pcell1.setVerticalAlignment(Element.ALIGN_CENTER);
                                    quesTable[i].addCell(pcell1);

                                    PdfPCell pcell = new PdfPCell(new Paragraph(fontFamilySelector.process("",
                                            FontContext.SMALL_NORMAL_HELVETICA)));
                                    pcell.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                                    pcell.setBorderColor(Color.GRAY);
                                    pcell.setPadding(4);
                                    pcell.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    pcell.setVerticalAlignment(Element.ALIGN_CENTER);
                                    quesTable[i].addCell(pcell);
                                }
                            }
                            PdfPCell pcell = new PdfPCell(new Paragraph(
                                    fontFamilySelector.process(" ", FontContext.SMALL_NORMAL_HELVETICA)));
                            pcell.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                            pcell.setBorderColor(Color.GRAY);
                            pcell.setPadding(4);
                            pcell.setHorizontalAlignment(Element.ALIGN_CENTER);
                            pcell.setVerticalAlignment(Element.ALIGN_CENTER);
                            //questionTable.addCell(pcell);

                            document.add(quesTable[i]);
                        }
                        //document.add(questionTable);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        //Comp

        //Goals
        requestParams.clear();
        requestParams.put("companyid", sessionHandlerImplObj.getCompanyid(request));
        requestParams.put("checklink", "goal");
        if (hrmsCommonDAOObj.checkModule(requestParams).isSuccessFlag()) {
            try {
                JSONArray jsonGoals = obj.getJSONArray(3);
                if (!isMyAppraisal) {
                    String goalParam[] = {
                            messageSource.getMessage("hrms.performance.goals", null,
                                    RequestContextUtils.getLocale(request)),
                            messageSource.getMessage("hrms.performance.percent.completed", null,
                                    RequestContextUtils.getLocale(request)),
                            messageSource.getMessage("hrms.performance.goal.weightage", null,
                                    RequestContextUtils.getLocale(request)),
                            messageSource.getMessage("hrms.performance.appraiser.rating", null,
                                    RequestContextUtils.getLocale(request)),
                            messageSource.getMessage("hrms.performance.appraiser.comment", null,
                                    RequestContextUtils.getLocale(request)) };
                    String colHeader[] = { "gname", "gcomplete", "gwth", "gmanrat", "mangoalcomment" };
                    PdfPTable goalTable = null;
                    if (companyPreferences.isWeightage()) {
                        goalTable = new PdfPTable(5);
                        goalTable.setWidths(new float[] { 50, 60, 30, 30, 42 });
                    } else {
                        goalTable = new PdfPTable(4);
                        goalTable.setWidths(new float[] { 50, 60, 30, 42 });
                    }
                    goalTable.setWidthPercentage(100);
                    goalTable.setSpacingBefore(20);
                    goalTable.setHeaderRows(1);
                    for (int i = 0; i < goalParam.length; i++) {
                        if (!(!companyPreferences.isWeightage() && i == 2)) {
                            PdfPCell pgcell = new PdfPCell(new Paragraph(fontFamilySelector
                                    .process(goalParam[i], FontContext.MEDIUM_BOLD_HELVETICA)));
                            pgcell.setBorder(0);
                            pgcell.setBorder(PdfPCell.BOX);
                            pgcell.setPadding(4);
                            pgcell.setBorderColor(Color.GRAY);
                            pgcell.setHorizontalAlignment(Element.ALIGN_CENTER);
                            goalTable.addCell(pgcell);
                        }
                    }

                    for (int i = 0; i < jsonGoals.length(); i++) {
                        for (int j = 0; j < colHeader.length; j++) {
                            if (!(!companyPreferences.isWeightage() && j == 2)) {
                                PdfPCell pcell;
                                if (j != 3)
                                    pcell = new PdfPCell(
                                            new Paragraph(
                                                    fontFamilySelector
                                                            .process(
                                                                    jsonGoals.getJSONObject(i).has(colHeader[j])
                                                                            ? jsonGoals.getJSONObject(i)
                                                                                    .getString(colHeader[j])
                                                                            : "",
                                                                    FontContext.SMALL_NORMAL_HELVETICA)));
                                else
                                    pcell = new PdfPCell(new Paragraph(fontFamilySelector.process(
                                            jsonGoals.getJSONObject(i).has(colHeader[j])
                                                    ? (jsonGoals.getJSONObject(i).getString(colHeader[j])
                                                            .equals("0")
                                                                    ? ""
                                                                    : jsonGoals.getJSONObject(i)
                                                                            .getString(colHeader[j]))
                                                    : "",
                                            FontContext.SMALL_NORMAL_HELVETICA)));
                                pcell.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                                pcell.setBorderColor(Color.GRAY);
                                pcell.setPadding(4);
                                pcell.setHorizontalAlignment(Element.ALIGN_CENTER);
                                pcell.setVerticalAlignment(Element.ALIGN_CENTER);
                                goalTable.addCell(pcell);
                            }
                        }
                    }
                    document.add(goalTable);
                } else {
                    String goalParam[] = {
                            messageSource.getMessage("hrms.performance.goals", null,
                                    RequestContextUtils.getLocale(request)),
                            messageSource.getMessage("hrms.performance.percent.completed", null,
                                    RequestContextUtils.getLocale(request)),
                            messageSource.getMessage("hrms.performance.goal.weightage", null,
                                    RequestContextUtils.getLocale(request)),
                            messageSource.getMessage("hrms.performance.self.rating", null,
                                    RequestContextUtils.getLocale(request)),
                            messageSource.getMessage("hrms.performance.self.comments", null,
                                    RequestContextUtils.getLocale(request)),
                            messageSource.getMessage("hrms.common.assigned.by", null,
                                    RequestContextUtils.getLocale(request)) };
                    String colHeader[] = { "gname", "gcomplete", "gwth", "gemprat", "empgoalcomment",
                            "assignedby" };
                    PdfPTable goalTable = null;
                    if (companyPreferences.isWeightage()) {
                        goalTable = new PdfPTable(6);
                        goalTable.setWidths(new float[] { 50, 60, 30, 50, 42, 60 });
                    } else {
                        goalTable = new PdfPTable(5);
                        goalTable.setWidths(new float[] { 50, 60, 50, 42, 60 });
                    }
                    goalTable.setWidthPercentage(100);
                    goalTable.setSpacingBefore(20);
                    goalTable.setHeaderRows(1);
                    for (int i = 0; i < goalParam.length; i++) {
                        if (!(!companyPreferences.isWeightage() && i == 2)) {
                            PdfPCell pgcell = new PdfPCell(new Paragraph(fontFamilySelector
                                    .process(goalParam[i], FontContext.MEDIUM_BOLD_HELVETICA)));
                            pgcell.setBorder(0);
                            pgcell.setBorder(PdfPCell.BOX);
                            pgcell.setPadding(4);
                            pgcell.setBorderColor(Color.GRAY);
                            pgcell.setHorizontalAlignment(Element.ALIGN_CENTER);
                            goalTable.addCell(pgcell);
                        }
                    }

                    for (int i = 0; i < jsonGoals.length(); i++) {
                        for (int j = 0; j < colHeader.length; j++) {
                            if (!(!companyPreferences.isWeightage() && j == 2)) {
                                PdfPCell pcell;
                                if (j != 3)
                                    pcell = new PdfPCell(
                                            new Paragraph(
                                                    fontFamilySelector
                                                            .process(
                                                                    jsonGoals.getJSONObject(i).has(colHeader[j])
                                                                            ? jsonGoals.getJSONObject(i)
                                                                                    .getString(colHeader[j])
                                                                            : "",
                                                                    FontContext.SMALL_NORMAL_HELVETICA)));
                                else
                                    pcell = new PdfPCell(new Paragraph(fontFamilySelector.process(
                                            jsonGoals.getJSONObject(i).has(colHeader[j])
                                                    ? (jsonGoals.getJSONObject(i).getString(colHeader[j])
                                                            .equals("0")
                                                                    ? ""
                                                                    : jsonGoals.getJSONObject(i)
                                                                            .getString(colHeader[j]))
                                                    : "",
                                            FontContext.SMALL_NORMAL_HELVETICA)));
                                pcell.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                                pcell.setBorderColor(Color.GRAY);
                                pcell.setPadding(4);
                                pcell.setHorizontalAlignment(Element.ALIGN_CENTER);
                                pcell.setVerticalAlignment(Element.ALIGN_CENTER);
                                goalTable.addCell(pcell);
                            }
                        }
                    }
                    document.add(goalTable);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        //Goals

        document.newPage();
        document.close();
        response.setHeader("Content-Disposition", "attachment; filename=\"" + "App_Form" + ".pdf\"");
        response.setContentType("application/octet-stream");
        response.setContentLength(baos.size());
        response.getOutputStream().write(baos.toByteArray());
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        writer.close();
    }
}