Example usage for com.lowagie.text Font BOLD

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

Introduction

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

Prototype

int BOLD

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

Click Source Link

Document

this is a possible style.

Usage

From source file:org.egov.works.web.actions.contractorBill.ContractorBillPDFGenerator.java

License:Open Source License

protected void createCertificate() throws DocumentException {
    final Paragraph headerTextPara = new Paragraph(new Chunk(pdfLabel.get("contractorbill.pdf.contractorbill"),
            new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLD)));
    headerTextPara.setAlignment(Element.ALIGN_CENTER);
    document.add(headerTextPara);/* w w  w .ja va 2 s  . co  m*/
    final Paragraph certificateheaderTextPara = new Paragraph(new Chunk(
            pdfLabel.get("contractorbill.pdf.certificate"), new Font(Font.COURIER, LARGE_FONT, Font.BOLD)));
    certificateheaderTextPara.setAlignment(Element.ALIGN_CENTER);
    document.add(certificateheaderTextPara);
    document.add(spacer());
    document.add(spacer());

    document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent1")));
    document.add(spacer());
    document.add(spacer());

    document.add(rightPara(
            pdfLabel.get("contractorbill.pdf.juniorengineer") + "\t \t\t \t \t \t\t \t\t \t \t \t \t"));
    document.add(spacer());
    document.add(rightPara(pdfLabel.get(dateLabel) + "\t \t \t \t\t \t\t \t \t \t \t\t \t\t \t \t \t \t\t \t\t"
            + "\t \t\t \t\t \t \t \t \t\t \t\t\t\t \t\t \t\t"));
    document.add(spacer());

    document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent2")));
    document.add(spacer());
    document.add(spacer());

    document.add(rightPara(pdfLabel.get("contractorbill.pdf.exeasstengineer") + "\t \t"));
    document.add(spacer());
    document.add(rightPara(pdfLabel.get(dateLabel) + "\t \t \t \t\t \t\t \t \t \t \t\t \t\t \t \t \t \t\t \t\t"
            + "\t \t \t \t\t \t\t \t \t \t \t\t \t\t \t \t \t \t\t \t\t\t \t \t\t\t \t\t \t \t \t \t\t \t\t \t \t \t \t\t \t\t \t \t \t \t\t \t\t"));

    document.add(spacer());

    document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent3")));
    document.add(spacer());
    document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent4")));
    document.add(spacer());

    document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent5")));
    document.add(spacer());
    document.add(spacer());

    document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent6")));

    document.add(spacer());
    document.add(spacer());

    document.add(makePara(pdfLabel.get("contractorbill.pdf.juniorengineer")
            + "\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t " + tab2 + tab2
            + "\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t\t \t \t \t \t \t \t \t \t \t \t"
            + pdfLabel.get("contractorbill.pdf.exeasstengineer")));
    document.add(spacer());
    document.add(makePara(pdfLabel.get(dateLabel)
            + "\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t" + tab2 + tab2
            + "\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t"
            + "\t \t \t \t \t \t \t \t " + pdfLabel.get(dateLabel)));
}

From source file:org.egov.works.web.actions.contractorBill.ContractorBillPDFGenerator.java

License:Open Source License

protected PdfPTable createContractorBillHeader(final String title, final int i) {
    final PdfPTable contractorBillHeaderTable = new PdfPTable(3);
    contractorBillHeaderTable.getDefaultCell().setBorderWidth(0);
    if (i == 0) {
        contractorBillHeaderTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        contractorBillHeaderTable.getDefaultCell().setColspan(4);
        contractorBillHeaderTable.addCell(title);
    } else if (i == 1) {
        contractorBillHeaderTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        final Phrase headerTextPara = new Phrase(title, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD));
        contractorBillHeaderTable.getDefaultCell().setColspan(3);
        contractorBillHeaderTable.addCell(headerTextPara);
    } else if (i == 2) {
        contractorBillHeaderTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        contractorBillHeaderTable.getDefaultCell().setColspan(4);
        contractorBillHeaderTable.addCell(title + " " + deptName);
    }/*from  www.jav a2s . co m*/
    return contractorBillHeaderTable;
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

public void generatePDF() {
    try {/* w  w  w  . j  av  a 2  s .  com*/
        final Paragraph headerTextPara = new Paragraph(
                new Chunk(headerText, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        String projectCode;
        final String oldEstNo = "";
        HeaderFooter hf;
        headerTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(headerTextPara);
        document.add(makePara("Executing Department:" + estimate.getExecutingDepartment().getName(),
                Element.ALIGN_LEFT));
        if (estimate.getUserDepartment() != null)
            document.add(
                    makePara("User Department:" + estimate.getUserDepartment().getName(), Element.ALIGN_LEFT));

        final CFinancialYear estimateFinancialYear = estimate.getMultiYearEstimates().get(0).getFinancialYear();
        addZoneYearHeader(estimate, estimateFinancialYear);

        document.add(makePara("Name of Work: " + estimate.getName(), Element.ALIGN_LEFT));
        document.add(makePara("Description: " + estimate.getDescription(), Element.ALIGN_LEFT));

        if (estimate.getProjectCode() != null) {
            projectCode = "Project Code : " + estimate.getProjectCode().getCode();
            document.add(makePara(projectCode, Element.ALIGN_LEFT));
            hf = new HeaderFooter(new Phrase("\t  \t  \t  \t \t \t  \t  \t  \t \t \t  \t  \t  \t \t"
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t"
                    + headerText.concat("\n")
                            .concat("\t  \t  \t  \t \t \t  \t  \t  \t \t"
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t ABSTRACT ESTIMATE")
                            .concat("\n\n").concat("Name of Work: " + estimate.getName()).concat("\n")
                            .concat("Description: " + estimate.getDescription()).concat("\n")
                            .concat("Estimate Number: " + estimate.getEstimateNumber()).concat(oldEstNo)
                            .concat("\n").concat(projectCode)),
                    false);
        } else
            hf = new HeaderFooter(new Phrase("\t  \t  \t  \t \t \t  \t  \t  \t \t \t  \t  \t  \t \t"
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t"
                    + headerText.concat("\n")
                            .concat("\t  \t  \t  \t \t \t  \t  \t  \t \t"
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t ABSTRACT ESTIMATE")
                            .concat("\n\n").concat("Name of Work: " + estimate.getName()).concat("\n")
                            .concat("Description: " + estimate.getDescription()).concat("\n")
                            .concat("Estimate Number: " + estimate.getEstimateNumber()).concat(oldEstNo)),
                    false);

        hf.disableBorderSide(Rectangle.TOP);
        hf.disableBorderSide(Rectangle.BOTTOM);
        hf.setLeft(Element.ALIGN_LEFT);
        document.setHeader(hf);
        final PdfPTable overheadsTable = createOverheadsTable(estimate);
        document.add(spacer());
        document.add(overheadsTable);
        document.add(spacer());
        final PdfPTable multiyearTable = createMultiYearTable(estimate);
        document.add(makePara("Year-wise Estimate"));
        document.add(spacer());
        document.add(multiyearTable);
        document.add(spacer());
        document.add(makePara("Estimate Created By: " + estimate.getCreatedBy().getName()));
        document.add(spacer());
        document.add(spacer());
        document.add(makePara("Checked By: "));
        document.newPage();
        addZoneYearHeaderWithOutEstimateNo(estimate, estimateFinancialYear);
        document.add(createActivitiesTable(estimate));
        document.add(spacer());

        final PdfPTable approvaldetailsTable = createApprovalDetailsTable(estimate);
        // TODO:Fixme - commented final out workflow history final details since ordering final of approval is final not
        // getting final listed properly
        /*
         * if (approvaldetailsTable.getRows().size() != 1) { document.add(makePara("Approval Details"));
         * document.add(spacer()); document.add(approvaldetailsTable); }
         */

        final String appropriationNumber = abstractEstimateService
                .getLatestEstimateAppropriationNumber(estimate);

        if (isSkipBudgetCheck()) {
            final PdfPTable depositWorksAppropriationTable = createDepositAppropriationTable(estimate,
                    appropriationNumber);
            if (depositWorksAppropriationTable.getRows().size() != 1)
                if (appropriationNumber != null) {
                    document.newPage();
                    document.add(spacer());
                    document.add(makePara("Deposit Code Appropriation Details"));
                    document.add(spacer());
                    document.add(depositWorksAppropriationTable);
                }
        } else {
            final PdfPTable BudgetaryAppropriationTable = createBudgetaryAppropriationTable(estimate,
                    appropriationNumber);
            final String estimateNumber = estimate.getEstimateNumber();
            if (BudgetaryAppropriationTable.getRows().size() != 1)
                if (!getBudgetDetailUsage(estimateNumber).isEmpty() && appropriationNumber != null) {
                    document.newPage();
                    document.add(spacer());
                    document.add(makePara("Budgetary Appropriation"));
                    document.add(spacer());
                    document.add(BudgetaryAppropriationTable);
                }
        }

        document.newPage();
        document.add(spacer());
        document.add(makePara(
                "EXECUTIVE ENGINEER'S OFFICE,  ZONE.......................................................................",
                Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(makePara(
                "Est No.                                                Unit:                                                 Dept.",
                Element.ALIGN_LEFT));
        document.add(spacer());
        final Paragraph budgetheadTextPara = new Paragraph(
                new Chunk("BUDGET HEAD", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        budgetheadTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(budgetheadTextPara);
        document.add(spacer());
        document.add(makePara("____________________________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(makePara("Rs.                                            ", Element.ALIGN_LEFT));
        document.add(makePara("____________________________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(makePara("Works:                                          ", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(spacer());
        final Paragraph memoTextPara = new Paragraph(
                new Chunk("MEMO", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        memoTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(memoTextPara);
        document.add(makePara("Budget Grant                               ", Element.ALIGN_LEFT));
        document.add(makePara("Amount Appropriated:__________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(makePara("Balance on Hand:                                ", Element.ALIGN_LEFT));
        document.add(
                makePara("Amount of this estimate_________________________________________________________",
                        Element.ALIGN_LEFT));
        document.add(makePara("Balance forward_______________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(
                makePara("Submitted for favour of sanction                           ", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(spacer());
        document.add(
                makePara("A.E.E.Unit " + space1 + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t \t \t \t \t \t \t"
                        + "Exe.Eng.Zone.....................", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(makePara("Sanctioned", Element.ALIGN_CENTER));
        document.add(spacer());
        document.add(spacer());
        document.add(makePara("DATE:" + space1
                + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t"
                + "Asst.Commissioner Zone...............", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(makePara(
                space1 + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t"
                        + "APPROPRIATION No.",
                Element.ALIGN_LEFT));
        document.add(makePara(space1 + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t"
                + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t \t \t \t" + "Date:", Element.ALIGN_LEFT));

        // WF for signature -----
        if (approvaldetailsTable.getRows().size() != 1)
            if (shouldShowApprovalNumber) {
                document.resetHeader();
                document.newPage();
                document.add(
                        makePara("\t  \t  \t  \t \t \t  \t  \t  \t \t \t  \t  \t  \t \t"
                                + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                + "\t  \t  \t  \t \t\t  \t  \t  \t \t"
                                + headerText.concat("\n").concat("\t  \t  \t  \t \t \t  \t  \t  \t \t"
                                        + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                        + "\t  \t  \t  \t \t\t  \t  \t  \t \t ABSTRACT ESTIMATE")
                                        .concat("\n\n")));
                document.add(
                        makePara(
                                "File Current Number :" + space1
                                        + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t \t   " + "Date: \t \t",
                                Element.ALIGN_LEFT));
                document.add(makePara(space1
                        + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t\t  \t  \t  \t \t \t \t \t  \t  \t  \t "
                        + "Department : ", Element.ALIGN_LEFT));
                document.add(spacer());
                final Paragraph headingPara1 = new Paragraph(
                        new Chunk("NOTE FOR ADMINISTRATIVE SANCTION AS PER RULE 78 OF ",
                                new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
                headingPara1.setAlignment(Element.ALIGN_CENTER);
                document.add(headingPara1);
                final Paragraph headingPara2 = new Paragraph(
                        new Chunk("MCMC ACT 1919 ", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
                headingPara2.setAlignment(Element.ALIGN_CENTER);
                document.add(headingPara2);

                document.add(spacer());
                final PdfPTable estimateDetailsTable1 = createEstimateDetailsTable1(estimate);
                document.add(estimateDetailsTable1);
                final PdfPTable budgetDetailsTableFourCols = createBudgetDetailsForEstimateTable(estimate);
                document.add(budgetDetailsTableFourCols);
                final PdfPTable estimateDetailsTable2 = createBalanceAmtCalculationTable(estimate);
                document.add(estimateDetailsTable2);
                document.add(spacer());
                final Paragraph endTextPara = new Paragraph(
                        new Chunk("** END **", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
                endTextPara.setAlignment(Element.ALIGN_CENTER);
                document.add(endTextPara);
            }

        document.close();
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException("estimate.pdf.error", e);
    }
}

From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java

License:Open Source License

public void generatePDF() {
    final String headerText = pdfLabel.get("mbpdf.header");
    try {//from  ww w . j  a  v  a  2s.  c  o  m
        // start header Part
        final Paragraph headerTextPara = new Paragraph(
                new Chunk(headerText, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        headerTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(headerTextPara);
        document.add(spacer());
        if (mbHeader != null) {
            String toPageno = "";
            if (mbHeader.getToPageNo() == null || mbHeader.getToPageNo().intValue() == 0)
                toPageno = mbHeader.getFromPageNo().toString();
            else
                toPageno = mbHeader.getToPageNo().toString();

            document.add(makeParaWithFont(8, " \t  \t  \t  \t \t " + pdfLabel.get("mbpdf.refno")
                    + mbHeader.getMbRefNo()
                    + " \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t "
                    + pdfLabel.get("mbpdf.pageno") + " : " + mbHeader.getFromPageNo() + " to " + toPageno
                    + " \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t "
                    + pdfLabel.get("mbpdf.date") + sdf.format(mbHeader.getMbDate()), Element.ALIGN_LEFT));

        }
        document.add(spacer());
        includeRevisionTypeColumn = false;
        // /Find if revision type Non tendered and Lump sum items are there
        areNTOrLSItemsPresent(mbHeader);
        // creating label row
        PdfPTable mbTable = createMbTable();
        if (mbHeader != null)
            mbTable = createMbData(mbTable, mbHeader);
        document.add(mbTable);
        document.add(spacer());
        document.newPage();
        // approval details table

        PdfPTable approvaldetailsTable = null;
        if (mbHeader != null)
            approvaldetailsTable = createApprovalDetailsTable(mbHeader);
        document.add(makePara(8, pdfLabel.get("mbpdf.approvaldetails")));
        document.add(spacer());
        document.add(approvaldetailsTable);

        document.close();
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException(MEASUREMENTBOOK_PDF_ERROR, e);
    }
}

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

License:Open Source License

public void generatePDF() {
    nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(10);/* www .  j ava  2s  .c o  m*/
    final List<String> tenderTypeList = worksService.getTendertypeList();
    if (tenderTypeList != null && !tenderTypeList.isEmpty())
        percTenderType = tenderTypeList.get(0);
    final String headerText = pdfLabel.get("tenderNegotiationpdf.header");
    try {
        final Paragraph headerTextPara = new Paragraph(
                new Chunk(headerText, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        headerTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(headerTextPara);
        document.add(makePara(cityName, Element.ALIGN_RIGHT));
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getWorksPackage() != null) {
            worksPackgeReq = YES;
            worksPackage = tenderResponse.getTenderEstimate().getWorksPackage();
        }
        String deptName = "";
        if (YES.equalsIgnoreCase(worksPackgeReq)) {
            deptName = tenderResponse.getTenderEstimate().getWorksPackage().getDepartment().getName();
            document.add(makePara(deptName, Element.ALIGN_RIGHT));
            if (getWardList(worksPackage) != null)
                document.add(makePara(
                        pdfLabel.get("tenderNegotiationpdf.ward") + "/"
                                + pdfLabel.get("tenderNegotiationpdf.zone") + getWardList(worksPackage),
                        Element.ALIGN_LEFT));
        } else {
            if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getExecutingDepartment() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getExecutingDepartment()
                            .getName() != null)
                deptName = tenderResponse.getTenderEstimate().getAbstractEstimate().getExecutingDepartment()
                        .getName();
            document.add(makePara(deptName, Element.ALIGN_RIGHT));
            if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getWard().getParent() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getWard() != null)
                document.add(makePara(pdfLabel.get("tenderNegotiationpdf.ward") + "/"
                        + pdfLabel.get("tenderNegotiationpdf.zone")
                        + tenderResponse.getTenderEstimate().getAbstractEstimate().getWard().getName() + "/"
                        + tenderResponse.getTenderEstimate().getAbstractEstimate().getWard().getParent()
                                .getName(),
                        Element.ALIGN_LEFT));
        }
        if (YES.equalsIgnoreCase(worksPackgeReq))
            document.add(makePara(
                    pdfLabel.get("tenderNegotiationpdf.nameofwork")
                            + tenderResponse.getTenderEstimate().getWorksPackage().getName(),
                    Element.ALIGN_LEFT));
        else if (tenderResponse != null && tenderResponse.getTenderEstimate() != null)
            document.add(makePara(
                    pdfLabel.get("tenderNegotiationpdf.nameofwork")
                            + tenderResponse.getTenderEstimate().getAbstractEstimate().getName(),
                    Element.ALIGN_LEFT));
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getTenderHeader() != null
                && tenderResponse.getTenderEstimate().getTenderHeader().getTenderNo() != null)
            document.add(makePara(
                    pdfLabel.get("tenderNumber")
                            + tenderResponse.getTenderEstimate().getTenderHeader().getTenderNo(),
                    Element.ALIGN_LEFT));
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getWorksPackage() != null)
            document.add(makePara(
                    pdfLabel.get("tenderFileNo")
                            + tenderResponse.getTenderEstimate().getWorksPackage().getTenderFileNumber(),
                    Element.ALIGN_LEFT));
        document.add(spacer());
        String tenderDate = "";
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getTenderHeader() != null
                && tenderResponse.getTenderEstimate().getTenderHeader().getTenderDate() != null)
            tenderDate = sdf.format(tenderResponse.getTenderEstimate().getTenderHeader().getTenderDate());
        document.add(
                makePara(pdfLabel.get("tenderNegotiationpdf.tenderdate") + tenderDate, Element.ALIGN_RIGHT));
        document.add(spacer());
        PdfPTable contractorTable = null;
        if (tenderResponse != null) {
            contractorTable = createContractorTable(tenderResponse);
            document.add(contractorTable);
        }
        document.add(spacer());

        if (tenderResponse != null
                && tenderResponse.getTenderEstimate().getTenderType().equalsIgnoreCase(percTenderType)) {
            PdfPTable negotiationTable = null;
            negotiationTable = createNegotiationTable(tenderResponse,
                    tenderResponse.getTenderResponseContractors().get(0).getContractor());
            document.add(negotiationTable);
            document.add(spacer());
            if (negotiationTable != null && negotiationTable.getRows().size() > 8)
                document.newPage();

        } else if (tenderResponse != null
                && !tenderResponse.getTenderEstimate().getTenderType().equalsIgnoreCase(percTenderType))
            createNegotiationTableForContractors(tenderResponse);

        if (tenderResponse != null && tenderResponse.getNegotiationPreparedBy() != null
                && tenderResponse.getNegotiationPreparedBy().getEmployeeName() != null)
            document.add(makePara(pdfLabel.get("tenderNegotiationpdf.preparedby") + " "
                    + tenderResponse.getNegotiationPreparedBy().getEmployeeName()));
        document.add(spacer());
        document.add(spacer());
        document.add(makePara(pdfLabel.get("tenderNegotiationpdf.checkedby")));
        document.newPage();

        PdfPTable approvaldetailsTable = null;
        if (tenderResponse != null)
            approvaldetailsTable = createApprovalDetailsTable(tenderResponse);

        if (approvaldetailsTable != null && approvaldetailsTable.getRows().size() != 1) {
            document.add(makePara(pdfLabel.get("tenderNegotiationpdf.approvaldetails")));
            document.add(spacer());
            document.add(approvaldetailsTable);
        }
        document.close();
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException(TENDER_PDF_ERROR, e);
    }
}

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

License:Open Source License

@Override
public void export(GTDModel model, ActionsCollection collection, OutputStream out,
        ExportAddOn.ExportOrder order, FileFilter ff, boolean compact) throws Exception {

    fontSelector = new FontSelector();
    fontSelectorB = new FontSelector();
    fontSelectorB2 = new FontSelector();
    fontSelectorB4 = new FontSelector();

    baseFont = fontModel.getBaseFont();/*from  ww w  .j a va  2  s  .c o m*/

    for (BaseFont bf : fontModel.getFonts()) {
        fontSelector.addFont(new Font(bf, baseFontSize));
        fontSelectorB.addFont(new Font(bf, baseFontSize, Font.BOLD));
        fontSelectorB2.addFont(new Font(bf, baseFontSize + 2, Font.BOLD));
        fontSelectorB4.addFont(new Font(bf, baseFontSize + 4, Font.BOLD));
    }

    boolean emptyH2 = false;
    boolean emptyH3 = false;

    PdfPTable actionTable = null;

    Document doc = new Document();

    if (sizeSet) {
        doc.setPageSize(pageSize);
    }
    if (marginSet) {
        doc.setMargins(marginLeft, marginRight, marginTop, marginBottom);
    }

    //System.out.println("PDF size "+doc.getPageSize().toString());
    //System.out.println("PDF m "+marginLeft+" "+marginRight+" "+marginTop+" "+marginBottom);

    @SuppressWarnings("unused")
    PdfWriter pw = PdfWriter.getInstance(doc, out);

    doc.addCreationDate();
    doc.addTitle("GTD-Free PDF");
    doc.addSubject("GTD-Free data exported as PDF");

    HeaderFooter footer = new HeaderFooter(newParagraph(), true);
    footer.setAlignment(HeaderFooter.ALIGN_CENTER);
    footer.setBorder(HeaderFooter.TOP);
    doc.setFooter(footer);

    doc.open();

    Phrase ch = newTitle("GTD-Free Data");
    Paragraph p = new Paragraph(ch);
    p.setAlignment(Paragraph.ALIGN_CENTER);

    PdfPTable t = new PdfPTable(1);
    t.setWidthPercentage(100f);
    PdfPCell c = newCell(p);
    c.setBorder(Table.BOTTOM);
    c.setBorderWidth(2.5f);
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    c.setPadding(5f);
    t.addCell(c);
    doc.add(t);

    Iterator<Object> it = collection.iterator(order);

    while (it.hasNext()) {
        Object o = it.next();

        if (o == ActionsCollection.ACTIONS_WITHOUT_PROJECT) {

            if (order == ExportAddOn.ExportOrder.FoldersProjectsActions) {

                doc.add(newSubSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT));

                emptyH2 = false;
                emptyH3 = true;
            } else {

                doc.add(newSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT));

                emptyH2 = true;
                emptyH3 = false;
            }

            continue;
        }

        if (o instanceof Folder) {

            Folder f = (Folder) o;

            if (actionTable != null) {
                doc.add(actionTable);
                actionTable = null;
            }

            if (f.isProject()) {

                if (order == ExportAddOn.ExportOrder.ProjectsActions
                        || order == ExportAddOn.ExportOrder.ProjectsFoldersActions) {

                    if (emptyH2 || emptyH3) {
                        p = newParagraph(NONE_DOT);
                        doc.add(p);
                    }

                    doc.add(newSection(f.getName()));

                    if (compact) {
                        if (f.getDescription() != null && f.getDescription().length() > 0) {
                            p = newParagraph(f.getDescription());
                            p.setIndentationLeft(10f);
                            p.setIndentationRight(10f);
                            doc.add(p);
                        }
                    } else {
                        t = new PdfPTable(2);
                        t.setKeepTogether(true);
                        t.setSpacingBefore(5f);
                        t.setWidthPercentage(66f);
                        t.setWidths(new float[] { 0.33f, 0.66f });

                        c = newCell("ID");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.getId())));
                        t.addCell(c);
                        c = newCell("Type");
                        t.addCell(c);
                        c = newCell(newStrongParagraph("Project"));
                        t.addCell(c);
                        c = newCell("Open");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount())));
                        t.addCell(c);
                        c = newCell("All");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.size())));
                        t.addCell(c);
                        c = newCell("Description");
                        t.addCell(c);
                        c = newDescriptionCell(f.getDescription());
                        t.addCell(c);

                        doc.add(t);
                    }

                    emptyH2 = true;
                    emptyH3 = false;

                } else {

                    if (emptyH3) {
                        p = newParagraph(NONE_DOT);
                        doc.add(p);
                    }

                    doc.add(newSubSection("Project:" + " " + f.getName()));

                    emptyH2 = false;
                    emptyH3 = true;
                }

                continue;

            }
            if (order == ExportAddOn.ExportOrder.FoldersActions
                    || order == ExportAddOn.ExportOrder.FoldersProjectsActions) {

                if (emptyH2 || emptyH3) {
                    p = newParagraph(NONE_DOT);
                    doc.add(p);
                }

                doc.add(newSection(f.getName()));

                if (compact) {
                    if (f.getDescription() != null && f.getDescription().length() > 0) {
                        p = newParagraph(f.getDescription());
                        p.setIndentationLeft(10f);
                        p.setIndentationRight(10f);
                        doc.add(p);
                    }
                } else {

                    t = new PdfPTable(2);
                    t.setKeepTogether(true);
                    t.setSpacingBefore(5f);
                    t.setWidthPercentage(66f);
                    t.setWidths(new float[] { 0.33f, 0.66f });

                    c = newCell("ID");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.getId())));
                    t.addCell(c);

                    String type = "";
                    if (f.isAction()) {
                        type = "Action list";
                    } else if (f.isInBucket()) {
                        type = "In-Bucket";
                    } else if (f.isQueue()) {
                        type = "Next action queue";
                    } else if (f.isReference()) {
                        type = "Reference list";
                    } else if (f.isSomeday()) {
                        type = "Someday/Maybe list";
                    } else if (f.isBuildIn()) {
                        type = "Default list";
                    }

                    c = newCell("Type");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(type));
                    t.addCell(c);
                    c = newCell("Open");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount())));
                    t.addCell(c);
                    c = newCell("All");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.size())));
                    t.addCell(c);
                    c = newCell("Description");
                    t.addCell(c);
                    c = newDescriptionCell(f.getDescription());
                    t.addCell(c);

                    doc.add(t);
                }

                emptyH2 = true;
                emptyH3 = false;

            } else {

                if (emptyH3) {
                    p = newParagraph(NONE_DOT);
                    doc.add(p);
                }

                doc.add(newSubSection("List:" + " " + f.getName()));

                emptyH2 = false;
                emptyH3 = true;

            }

            continue;

        }

        if (o instanceof Action) {
            emptyH2 = false;
            emptyH3 = false;

            Action a = (Action) o;

            if (compact) {

                if (actionTable == null) {
                    actionTable = new PdfPTable(5);
                    actionTable.setWidthPercentage(100f);
                    actionTable.setHeaderRows(1);
                    actionTable.setSpacingBefore(5f);
                    c = newHeaderCell("ID");
                    actionTable.addCell(c);
                    c = newHeaderCell("Pri.");
                    actionTable.addCell(c);
                    c = newHeaderCell("Description");
                    actionTable.addCell(c);
                    c = newHeaderCell("Reminder");
                    actionTable.addCell(c);
                    c = newHeaderCell(CHECK_RESOLVED);
                    actionTable.addCell(c);

                    float width = doc.getPageSize().getWidth() - doc.getPageSize().getBorderWidthLeft()
                            - doc.getPageSize().getBorderWidthRight();
                    int i = model.getLastActionID();
                    float step = baseFontSize - 1;
                    int steps = (int) Math.floor(Math.log10(i)) + 1;
                    // ID column
                    float col1 = 8 + steps * step;
                    // Priority column
                    float col2 = 4 + 3 * (baseFontSize + 4);
                    // Reminder column
                    float col4 = 10 + step * 11;
                    // Resolved column
                    float col5 = 8 + baseFontSize;
                    // Description column
                    float col3 = width - col1 - col2 - col4 - col5;
                    actionTable.setWidths(new float[] { col1, col2, col3, col4, col5 });

                }

                addSingleActionRow(a, actionTable);

            } else {
                addSingleActionTable(model, doc, a);
            }
        }

    }

    if (actionTable != null) {
        doc.add(actionTable);
        actionTable = null;
    }
    if (emptyH2 || emptyH3) {

        p = newParagraph(NONE_DOT);
        doc.add(p);
    }

    //w.writeCharacters("Exported: "+ApplicationHelper.toISODateTimeString(new Date()));

    doc.close();
}

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

License:Open Source License

/**
 * @param model//w  w w . ja  v  a 2s.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.inbio.modeling.core.manager.impl.ExportManagerImpl.java

License:Open Source License

private void addDocumentFooter(Document d, String[] texts) throws DocumentException {

    Font smallFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD);
    Font smallGreenFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD, Color.GREEN);
    Font smallDarkGreenFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD, new Color(135, 194, 53));

    Paragraph footer = new Paragraph();
    this.addLineSeparator(footer, 1);
    footer.setAlignment(Paragraph.ALIGN_CENTER);
    this.addEmptyLine(footer, 1);
    footer.add(new Paragraph(texts[0], smallFont));
    footer.add(new Paragraph(texts[1], smallGreenFont));
    footer.add(new Paragraph(texts[2], smallDarkGreenFont));
    this.addEmptyLine(footer, 1);
    d.add(footer);/*from  ww w. j  a v a 2  s  . co m*/
}

From source file:org.inbio.modeling.core.manager.impl.ExportManagerImpl.java

License:Open Source License

private void addTableRow(Table t, String title, String value) throws BadElementException {

    // Fonts Definition
    Font boldFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD);
    Cell cell = new Cell(new Chunk(title, boldFont));
    cell.setHeader(true);//from w  w  w .jav  a 2s  .  c o m
    t.addCell(cell);
    t.addCell(value);
}

From source file:org.inbio.modeling.core.manager.impl.ExportManagerImpl.java

License:Open Source License

private void addTitleOne(Document d, String text) throws DocumentException {

    Font titleFont = new Font(Font.TIMES_ROMAN, 24, Font.BOLD);

    Paragraph p = new Paragraph();
    this.addEmptyLine(p, 1);
    p.add(new Paragraph(text, titleFont));
    this.addEmptyLine(p, 1);
    d.add(p);/*  ww w  .j ava  2 s.  c  o m*/
}