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

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

Introduction

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

Prototype

public PdfPTable(PdfPTable table) 

Source Link

Document

Constructs a copy of a PdfPTable.

Usage

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

License:Open Source License

private PdfPTable createActivitiesTable(final AbstractEstimate estimate) throws DocumentException {
    final PdfPTable activitiesTable = new PdfPTable(7);
    activitiesTable.setWidthPercentage(100);
    activitiesTable.setWidths(new float[] { 0.5f, 1f, 3.1f, 1.2f, 0.8f, 1.1f, 1.5f });
    addRow(activitiesTable, true, makePara("Sl No"), centerPara("Quantity"), centerPara("Description"),
            centerPara("Sch. No"), centerPara("Unit"), centerPara("Rate"), centerPara("Amount"));
    Collection<Activity> activities = estimate.getSORActivities();
    int index = 1;
    for (final Activity activity : activities) {
        String estimateUom = "";
        if (activity.getUom() == null)
            estimateUom = activity.getSchedule().getUom().getUom();
        else//from ww  w .  j ava2  s . com
            estimateUom = activity.getUom().getUom();
        addRow(activitiesTable, true, makePara(index++), rightPara(activity.getQuantity()),
                makePara(activity.getSchedule().getDescription()), centerPara(activity.getSchedule().getCode()),
                centerPara(estimateUom), rightPara(toCurrency(activity.getSORCurrentRate())),
                rightPara(toCurrency(activity.getAmount())));
    }
    activities = estimate.getNonSORActivities();
    for (final Activity activity : activities)
        addRow(activitiesTable, true, makePara(index++), rightPara(activity.getQuantity()),
                makePara(activity.getNonSor().getDescription()), centerPara(""),
                centerPara(activity.getNonSor().getUom().getUom()), rightPara(toCurrency(activity.getRate())),
                rightPara(toCurrency(activity.getAmount())));
    addRow(activitiesTable, true, centerPara(""), centerPara(""), makePara(""), rightPara(""), centerPara(""),
            centerPara("TOTAL"), rightPara(toCurrency(estimate.getWorkValue())));
    addRow(activitiesTable, true, centerPara(""), centerPara(""), makePara(""), rightPara(""), centerPara(""),
            centerPara("WORK VALUE"), rightPara(toCurrency(estimate.getWorkValueIncludingTaxes())));

    return activitiesTable;
}

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

License:Open Source License

private void addZoneYearHeader(final AbstractEstimate estimate, final CFinancialYear financialYear)
        throws DocumentException {
    document.add(spacer());/*from  ww  w .j  av  a2  s .  c o  m*/
    final PdfPTable headerTable = new PdfPTable(2);
    headerTable.setWidthPercentage(100);
    headerTable.setWidths(new float[] { 1f, 1f });
    Paragraph financialYearPara = new Paragraph();
    if (financialYear != null)
        financialYearPara = makePara("Budget Year: " + financialYear.getFinYearRange(), Element.ALIGN_RIGHT);
    addRow(headerTable, false, makePara("Estimate Number: " + estimate.getEstimateNumber(), Element.ALIGN_LEFT),
            financialYearPara);

    document.add(headerTable);
    if (estimate.getWard() != null && "Ward".equalsIgnoreCase(estimate.getWard().getBoundaryType().getName())
            && estimate.getWard().getParent() != null && estimate.getWard().getParent().getName() != null)
        document.add(makePara("Ward: " + estimate.getWard().getName() + " / Zone: "
                + estimate.getWard().getParent().getName(), Element.ALIGN_RIGHT));
    else if (estimate.getWard() != null
            && "Zone".equalsIgnoreCase(estimate.getWard().getBoundaryType().getName())
            && estimate.getWard().getParent() != null && estimate.getWard().getParent().getName() != null)
        document.add(makePara("Zone: " + estimate.getWard().getName() + " / Region: "
                + estimate.getWard().getParent().getName(), Element.ALIGN_RIGHT));
    else if (estimate.getWard() != null)
        document.add(makePara("Jurisdiction: " + estimate.getWard().getName() + "("
                + estimate.getWard().getBoundaryType().getName() + ")", Element.ALIGN_RIGHT));
    document.add(spacer());
}

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

License:Open Source License

private void addZoneYearHeaderWithOutEstimateNo(final AbstractEstimate estimate,
        final CFinancialYear financialYear) throws DocumentException {
    final PdfPTable headerTable = new PdfPTable(2);
    headerTable.setWidthPercentage(100);
    headerTable.setWidths(new float[] { 1f, 1f });
    Paragraph financialYearPara = new Paragraph();
    if (financialYear != null)
        financialYearPara = makePara("Budget Year: " + financialYear.getFinYearRange(), Element.ALIGN_RIGHT);
    addRow(headerTable, false, new Paragraph(), financialYearPara);
    document.add(headerTable);//from  w ww. j a v a 2s  .  co  m
    if (estimate.getWard() != null && "Ward".equalsIgnoreCase(estimate.getWard().getBoundaryType().getName())
            && estimate.getWard().getParent() != null && estimate.getWard().getParent().getName() != null)
        document.add(makePara("Ward: " + estimate.getWard().getName() + " / Zone: "
                + estimate.getWard().getParent().getName(), Element.ALIGN_RIGHT));
    else if (estimate.getWard() != null
            && "Zone".equalsIgnoreCase(estimate.getWard().getBoundaryType().getName())
            && estimate.getWard().getParent() != null && estimate.getWard().getParent().getName() != null)
        document.add(makePara("Zone: " + estimate.getWard().getName() + " / Region: "
                + estimate.getWard().getParent().getName(), Element.ALIGN_RIGHT));
    else if (estimate.getWard() != null)
        document.add(makePara("Jurisdiction: " + estimate.getWard().getName() + "("
                + estimate.getWard().getBoundaryType().getName() + ")", Element.ALIGN_RIGHT));
    document.add(spacer());
}

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

License:Open Source License

private PdfPTable createApprovalDetailsTable(final MBHeader mbHeader) throws DocumentException {
    try {/*from w ww.  j a  v a  2s  .c  o  m*/
        final PdfPTable approvaldetailsTable = new PdfPTable(5);
        approvaldetailsTable.setWidthPercentage(100);
        approvaldetailsTable.setWidths(new float[] { 2f, 1f, 1f, 1.5f, 2f });
        addRow(approvaldetailsTable, true, makePara(8, pdfLabel.get("mbpdf.aprvalstep")),
                centerPara(8, pdfLabel.get("mbpdf.name")), centerPara(8, pdfLabel.get("mbpdf.designation")),
                centerPara(8, pdfLabel.get("mbpdf.aprvdon")), centerPara(8, pdfLabel.get("mbpdf.remarks")));
        List<StateHistory<Position>> history = null;
        String code = "";
        if (mbHeader.getCurrentState() != null && mbHeader.getCurrentState().getHistory() != null)
            history = mbHeader.getStateHistory();
        if (history != null) {
            Collections.reverse(history);
            for (final StateHistory<Position> ad : history)
                if (!ad.getValue().equals("NEW") && !ad.getValue().equals("END")) {
                    String nextAction = "";
                    if (ad.getNextAction() != null)
                        nextAction = ad.getNextAction();
                    Long positionId = null;
                    String desgName = null;
                    DeptDesig deptdesig = null;
                    positionId = ad.getOwnerPosition().getId();
                    deptdesig = ad.getOwnerPosition().getDeptDesig();
                    desgName = deptdesig.getDesignation().getName();
                    final PersonalInformation emp = employeeService.getEmpForPositionAndDate(
                            ad.getCreatedDate(), Integer.parseInt(positionId.toString()));
                    code = ad.getValue();
                    final EgwStatus status = (EgwStatus) getPersistenceService()
                            .find("from EgwStatus where moduletype=? and code=?", "MBHeader", code);
                    String state = status.getDescription();
                    if (!nextAction.equalsIgnoreCase(""))
                        state = status.getDescription() + " - " + nextAction;
                    addRow(approvaldetailsTable, true, makePara(8, state), makePara(8, emp.getEmployeeName()),
                            makePara(8, desgName), makePara(8, getDateInFormat(ad.getCreatedDate().toString())),
                            rightPara(8, ad.getComments()));
                }
        }
        return approvaldetailsTable;
    } catch (final Exception e) {
        throw new DocumentException("Exception occured while getting approval details " + e);
    }
}

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

License:Open Source License

private PdfPTable createMbTable() throws DocumentException {
    PdfPTable mbTable;/*www .j a  v a  2s.co  m*/
    if (includeRevisionTypeColumn) {
        mbTable = new PdfPTable(12);
        mbTable.setWidths(new float[] { 1f, 1.5f, 4f, 1.4f, 1.9f, 1.6f, 1.4f, 1.8f, 1.9f, 1.9f, 1.9f, 1.6f });
    } else {
        mbTable = new PdfPTable(11);
        mbTable.setWidths(new float[] { 1f, 1.5f, 4f, 1.9f, 1.6f, 1.4f, 1.8f, 1.9f, 1.9f, 1.9f, 1.6f });
    }
    // main table
    mbTable.setWidthPercentage(100);

    try {
        final Font font = new Font();
        font.setSize(8);
        mbTable.getDefaultCell().setPadding(3);
        mbTable.getDefaultCell().setBorderWidth(1);
        mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.slno"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.schno"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.descofwork"), font)));
        if (includeRevisionTypeColumn)
            mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.revisiontype"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.completedmeasurement"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.unitrate"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.unit"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.totalvalueofcomplwork"), font)));

        // start creating tables for previous measurements
        final PdfPTable previousMbTable = createPreviousMbTable();
        final PdfPCell previousMbCell = new PdfPCell(previousMbTable);
        previousMbCell.setColspan(2);
        mbTable.addCell(previousMbCell);

        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.currentmeasurement"), font)));

        // last column
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.currentcost"), font)));
    } catch (final RuntimeException e) {
        throw new ApplicationRuntimeException(MEASUREMENTBOOK_PDF_ERROR, e);
    }
    return mbTable;
}

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

License:Open Source License

public PdfPTable createPreviousMbTable() {
    final PdfPTable previousMbTable = new PdfPTable(2);
    final Font font = new Font();
    font.setSize(8);//from   w w  w. j a  v a  2  s.c om
    previousMbTable.getDefaultCell().setBorderWidth(1);
    previousMbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    previousMbTable.getDefaultCell().setColspan(2);
    previousMbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.previousmeasurement"), font)));
    previousMbTable.getDefaultCell().setColspan(1);
    previousMbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.pageno"), font)));
    previousMbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.measurements"), font)));
    return previousMbTable;
}

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

License:Open Source License

private PdfPTable createApprovalDetailsTable(final TenderResponse tenderResponse) throws DocumentException {
    try {//w  w  w .j a  v a 2  s.  c o  m
        final PdfPTable approvaldetailsTable = new PdfPTable(5);
        approvaldetailsTable.setWidthPercentage(100);
        approvaldetailsTable.setWidths(new float[] { 1f, 1f, 2f, 1.5f, 2f });
        addRow(approvaldetailsTable, true, makePara(pdfLabel.get("tenderNegotiationpdf.aprvalstep")),
                centerPara(pdfLabel.get("tenderNegotiationpdf.name")),
                centerPara(pdfLabel.get("tenderNegotiationpdf.designation")),
                centerPara(pdfLabel.get("tenderNegotiationpdf.aprvdon")),
                centerPara(pdfLabel.get("tenderNegotiationpdf.remarks")));
        List<StateHistory<Position>> history = null;
        if (tenderResponse.getCurrentState() != null && tenderResponse.getCurrentState().getHistory() != null)
            history = tenderResponse.getStateHistory();
        if (history != null) {
            Collections.reverse(history);
            StateHistory<Position> previous = null;
            for (final StateHistory<Position> ad : history) {
                if (!ad.getValue().equals("NEW") && !ad.getValue().equals("APPROVAL_PENDING")
                        && !ad.getValue().equals("END") && previous != null) {
                    final EgwStatus status = (EgwStatus) getPersistenceService()
                            .find("from EgwStatus where code=?", ad.getValue());
                    final PersonalInformation emp = employeeService.getEmpForPositionAndDate(
                            ad.getCreatedDate(),
                            Integer.parseInt(previous.getOwnerPosition().getId().toString()));
                    addRow(approvaldetailsTable, true, makePara(status.getDescription()),
                            makePara(emp.getEmployeeName()),
                            makePara(previous.getOwnerPosition().getDeptDesig().getDesignation().getName()),
                            makePara(getDateInFormat(ad.getCreatedDate().toString())),
                            rightPara(ad.getComments()));
                }
                previous = ad;
            }
        }
        return approvaldetailsTable;
    } catch (final Exception e) {
        throw new DocumentException("Exception occured while getting approval details " + e);
    }
}

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

License:Open Source License

/**
 * create negotiation table main table// www.  j  a v  a 2  s .c  o m
 *
 * @param tenderResponse
 * @return
 * @throws DocumentException
 * @throws ApplicationException
 */
private PdfPTable createNegotiationTable(final TenderResponse tenderResponse, final Contractor contractor)
        throws DocumentException {
    final PdfPTable negotiationTable = new PdfPTable(13);
    negotiationTable.setWidthPercentage(100);
    negotiationTable.setWidths(
            new float[] { 0.5f, 1f, 3.6f, 1.5f, 1.1f, 0.9f, 1.5f, 1.7f, 1.7f, 1.7f, 1.7f, 1.7f, 1.7f });
    try {
        negotiationTable.getDefaultCell().setPadding(5);
        negotiationTable.getDefaultCell().setBorderWidth(1);
        negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.slno"));
        negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.scheduleno"));
        negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.descofwork"));
        negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.quantity"));

        /**
         * start creating tables for Estimate, before negotion, after negotiation and marketRate
         */

        final PdfPTable estimateTable = createAsPerEstimateTable(tenderResponse);
        estimateTable.setWidths(new float[] { 0.45f, 0.37f, 0.62f });
        final PdfPCell estimateCell = new PdfPCell(estimateTable);
        estimateCell.setColspan(3);
        negotiationTable.addCell(estimateCell);

        final PdfPTable beforeNegotiationTable = createBeforeNegotiationTable(tenderResponse);
        final PdfPCell beforeNegotiationCell = new PdfPCell(beforeNegotiationTable);
        beforeNegotiationCell.setColspan(2);
        negotiationTable.addCell(beforeNegotiationCell);

        final PdfPTable afterNegotiationTable = createAfterNegotiationTable(tenderResponse);
        final PdfPCell afterNegotiationCell = new PdfPCell(afterNegotiationTable);
        afterNegotiationCell.setColspan(2);
        negotiationTable.addCell(afterNegotiationCell);
        final PdfPTable marketRateTable = createMarketRateTable(tenderResponse);
        final PdfPCell marketRateCell = new PdfPCell(marketRateTable);
        marketRateCell.setColspan(2);
        negotiationTable.addCell(marketRateCell);
        /**
         * end creating tables for before negotion, after negotiation and marketRate
         */
        if (YES.equalsIgnoreCase(worksPackgeReq))
            createNegotiationTableDataForWp(tenderResponse, negotiationTable, contractor);
        else
            createNegotiationTableData(tenderResponse, negotiationTable, contractor);
        createNegotiationTableFooter(negotiationTable);
        addRowFooter(negotiationTable);
        addTotalQuotedFooter(negotiationTable);
        addFinalRow(negotiationTable, tenderResponse);
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException(TENDER_PDF_ERROR, e);
    }
    return negotiationTable;
}

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

License:Open Source License

public PdfPTable createTenderPercentageTable() {
    final PdfPTable tenderPercentageTable = new PdfPTable(5);
    tenderPercentageTable.getDefaultCell().setBorderWidth(1);
    tenderPercentageTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    tenderPercentageTable.getDefaultCell().setColspan(5);
    tenderPercentageTable.addCell(pdfLabel.get("tenderNegotiationpdf.percentage"));
    return tenderPercentageTable;
}

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

License:Open Source License

public PdfPTable createTotalQuotedValueTable() {
    final PdfPTable tenderQuotedTable = new PdfPTable(5);
    tenderQuotedTable.getDefaultCell().setBorderWidth(1);
    tenderQuotedTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    tenderQuotedTable.getDefaultCell().setColspan(5);
    tenderQuotedTable.addCell(pdfLabel.get("tenderNegotiationpdf.quoted.total"));
    return tenderQuotedTable;
}