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.drools.verifier.doc.DroolsDocsComponentFactory.java

License:Apache License

public void onEndPage(PdfWriter writer, Document document) {

    try {/*from  ww  w  . j a v a  2  s. com*/
        Image image = Image.getInstance(DroolsDocsBuilder.class.getResource("guvnor-webapp.png")); // TODO this image never existed
        image.setAlignment(Image.RIGHT);
        image.scaleAbsolute(100, 30);
        Rectangle page = document.getPageSize();
        PdfPTable head = new PdfPTable(2);

        PdfPCell cell1 = new PdfPCell(image);
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setBorder(0);

        head.addCell(cell1);

        PdfPCell cell2 = new PdfPCell(new Phrase(currentDate, DroolsDocsComponentFactory.HEADER_FOOTER_TEXT));
        cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell2.setBorder(0);

        head.addCell(cell2);

        head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        head.writeSelectedRows(0, -1, document.leftMargin(),
                page.getHeight() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());

    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}

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

License:Open Source License

public void generatePDF() throws ApplicationException {
    logger.debug("FA1---inside generate pdf ");
    generateDisplayData(mbHeader, egBillRegister);
    try {/*from ww w.  j  a va2s.  c  o m*/
        // start header Part
        final PdfPTable contractorBillMainTable = new PdfPTable(11);
        contractorBillMainTable.setWidthPercentage(100);
        contractorBillMainTable
                .setWidths(new float[] { 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f });
        contractorBillMainTable.getDefaultCell().setPadding(4);
        contractorBillMainTable.getDefaultCell().setBorderWidth(1);
        createHeaderRow(contractorBillMainTable);
        createDetailsRows(contractorBillMainTable);
        document.add(contractorBillMainTable);
        document.add(spacer());

        // ---approval details for workflow
        final PdfPTable approvaldetailsTable = createApprovalDetailsTable(egBillRegister);

        if (approvaldetailsTable.getRows().size() != 1) {
            document.add(makePara("Approval Details"));
            document.add(spacer());
            document.add(approvaldetailsTable);
            document.add(spacer());
        }
        if (contractorBillMainTable.getRows().size() > 11)
            document.newPage();
        createFooter();
        // create certificate page
        document.newPage();
        createCertificate();
        document.close();
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException(CONTRACTOR_PDF_ERROR, e);
    }
}

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   ww w. ja  v a  2  s .c  o m*/
    return contractorBillHeaderTable;
}

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

License:Open Source License

protected PdfPTable createDeductionTypeLabelTable() {
    final PdfPTable deductionTypeLabel = new PdfPTable(11);
    deductionTypeLabel.getDefaultCell().setBorderWidth(1);
    deductionTypeLabel.getDefaultCell().setColspan(7);
    deductionTypeLabel.addCell(makePara(pdfLabel.get("contractorbill.pdf.deductions")));
    deductionTypeLabel.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    deductionTypeLabel.getDefaultCell().setColspan(1);
    deductionTypeLabel.addCell("");
    deductionTypeLabel.addCell("");
    deductionTypeLabel.addCell("");
    deductionTypeLabel.addCell("");
    return deductionTypeLabel;
}

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

License:Open Source License

protected PdfPTable createDeductionTypeDataTable() {
    final PdfPTable createcreateDeductionTypeDataTable = new PdfPTable(11);
    createcreateDeductionTypeDataTable.getDefaultCell().setBorderWidth(1);

    // statutory/*w  w w. ja v  a  2  s  .c  om*/
    if (!sortedStatutorySortedList.isEmpty())
        for (final StatutoryDeductionsForBill egBillPayeedetail : sortedStatutorySortedList) {
            // get tot amt for dedcution for all bill for workorder till bill date
            final BigDecimal totStatutoryAmt = getTotStatoryAmountForDeduction(egBillPayeedetail);
            final String resultTotStatuAmt = getIntDecimalParts(totStatutoryAmt);
            final String[] resultTotStatuAry = resultTotStatuAmt.split(":");

            createcreateDeductionTypeDataTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            final String resultAmt = getIntDecimalParts(
                    egBillPayeedetail.getEgBillPayeeDtls().getCreditAmount());
            final String[] resultAry = resultAmt.split(":");
            createcreateDeductionTypeDataTable.getDefaultCell().setColspan(7);
            createcreateDeductionTypeDataTable
                    .addCell(egBillPayeedetail.getEgBillPayeeDtls().getRecovery().getType());
            createcreateDeductionTypeDataTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            createcreateDeductionTypeDataTable.getDefaultCell().setColspan(1);
            createcreateDeductionTypeDataTable.addCell(resultTotStatuAry[0]);// Rs. amt all bill for workorder till billdate
            createcreateDeductionTypeDataTable.addCell(resultTotStatuAry[1]);// Pa, amt all bill for workorder till billdate
            createcreateDeductionTypeDataTable.addCell(resultAry[0]); // Rs. amt for this deduction specific to bill
            createcreateDeductionTypeDataTable.addCell(resultAry[1]);// pa. amt for this deduction specific to bill
        }
    final String type = "advanceAjustment";
    if ("advanceAjustment".equalsIgnoreCase(type)) {
        final BigDecimal totAmt = getTotAmountForAdvanceAdjustment();
        final String resultTotAmt = getIntDecimalParts(totAmt);
        final String[] resultTotAry = resultTotAmt.split(":");
        createcreateDeductionTypeDataTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

        final String resultAmt = getIntDecimalParts(advanceAdjustment);
        final String[] resultAry = resultAmt.split(":");

        createcreateDeductionTypeDataTable.getDefaultCell().setColspan(7);
        createcreateDeductionTypeDataTable.addCell("Advance adjustment ");
        createcreateDeductionTypeDataTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        createcreateDeductionTypeDataTable.getDefaultCell().setColspan(1);

        createcreateDeductionTypeDataTable.addCell(resultTotAry[0]);
        createcreateDeductionTypeDataTable.addCell(resultTotAry[1]);

        createcreateDeductionTypeDataTable.addCell(resultAry[0]); // Rs. amt for this deduction specific to bill
        createcreateDeductionTypeDataTable.addCell(resultAry[1]);// pa. amt for this deduction specific to bill
    }

    // standard deduction
    if (!sortedStandardDeductionList.isEmpty())
        for (final DeductionTypeForBill deductionTypeForBill : sortedStandardDeductionList) {
            final BigDecimal totStandardAmt = getTotStandardAmountForDeduction(deductionTypeForBill);
            final String resultTotStandardAmt = getIntDecimalParts(totStandardAmt);
            final String[] resultTotStandardAry = resultTotStandardAmt.split(":");
            createcreateDeductionTypeDataTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            final String resultAmt = getIntDecimalParts(deductionTypeForBill.getCreditamount());
            final String[] resultAry = resultAmt.split(":");
            createcreateDeductionTypeDataTable.getDefaultCell().setColspan(7);
            createcreateDeductionTypeDataTable.addCell(deductionTypeForBill.getDeductionType());
            createcreateDeductionTypeDataTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            createcreateDeductionTypeDataTable.getDefaultCell().setColspan(1);
            createcreateDeductionTypeDataTable.addCell(resultTotStandardAry[0]);// Rs. amt all bill for workorder till
            // billdate
            createcreateDeductionTypeDataTable.addCell(resultTotStandardAry[1]);// Pa, amt all bill for workorder till
            // billdate
            createcreateDeductionTypeDataTable.addCell(resultAry[0]); // Rs. amt for this deduction for this bill
            createcreateDeductionTypeDataTable.addCell(resultAry[1]);// Pa. amt for this deduction for this bill
        }

    if (!customDeductionList.isEmpty())
        for (final EgBilldetails egBilldetails : customDeductionList) {
            final BigDecimal totCustomAmt = getTotStandardAmountForDeduction(egBilldetails);
            final String resultTotCustomAmt = getIntDecimalParts(totCustomAmt);
            final String[] resultTotCustomAry = resultTotCustomAmt.split(":");
            createcreateDeductionTypeDataTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            final String resultAmt = getIntDecimalParts(egBilldetails.getCreditamount());
            final String[] resultAry = resultAmt.split(":");
            createcreateDeductionTypeDataTable.getDefaultCell().setColspan(7);
            createcreateDeductionTypeDataTable.addCell(chartOfAccountsHibernateDAO
                    .findById(Long.valueOf(egBilldetails.getGlcodeid().toString()), false).getName());
            createcreateDeductionTypeDataTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            createcreateDeductionTypeDataTable.getDefaultCell().setColspan(1);
            createcreateDeductionTypeDataTable.addCell(resultTotCustomAry[0]);// Rs. amt all bill for workorder till billdate
            createcreateDeductionTypeDataTable.addCell(resultTotCustomAry[1]);// Pa, amt all bill for workorder till billdate
            createcreateDeductionTypeDataTable.addCell(resultAry[0]); // amt for this deduction specific to bill
            createcreateDeductionTypeDataTable.addCell(resultAry[1]);
        }

    return createcreateDeductionTypeDataTable;
}

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

License:Open Source License

protected PdfPTable createNetPayableTable() {
    final String resultAmt = getIntDecimalParts(netPayableAmount);
    final String[] resultAry = resultAmt.split(":");
    final PdfPTable createNetPayableData = new PdfPTable(11);
    createNetPayableData.getDefaultCell().setBorderWidth(1);
    createNetPayableData.getDefaultCell().setColspan(9);
    createNetPayableData.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    createNetPayableData.addCell(makePara(
            pdfLabel.get("contractorbill.pdf.netamount") + ":\t" + getNetPayAmtInWords(), Font.UNDERLINE));
    createNetPayableData.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    createNetPayableData.getDefaultCell().setColspan(1);
    createNetPayableData.addCell(resultAry[0]);
    createNetPayableData.addCell(resultAry[1]);
    return createNetPayableData;
}

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

License:Open Source License

protected PdfPTable createWorkValueDataTable() {
    final PdfPTable createWorkValueData = new PdfPTable(11);
    createWorkValueData.getDefaultCell().setBorderWidth(1);
    createWorkValueData.getDefaultCell().setColspan(7);
    createWorkValueData.addCell(makePara(pdfLabel.get("contractorbill.pdf.valueofworkdone")));

    createWorkValueData.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    createWorkValueData.getDefaultCell().setColspan(1);
    final BigDecimal totalBillAmtUptBill = contractorBillService.getTotalValueWoForUptoBillDate(
            egBillRegister.getBilldate(), workOrderId, mbHeader.getWorkOrderEstimate().getId());

    if (totalBillAmtUptBill.compareTo(BigDecimal.ZERO) > 0) {
        final String totalBillAmt = toCurrency(totalBillAmtUptBill.doubleValue());
        try {/*from  w w  w .j  ava 2s . co m*/
            createWorkValueData
                    .addCell(rightPara(blankSpace + totalBillAmt.substring(0, totalBillAmt.indexOf('.'))));
            createWorkValueData.addCell(centerPara(
                    blankSpace + totalBillAmt.substring(totalBillAmt.indexOf('.') + 1, totalBillAmt.length())));
        } catch (final StringIndexOutOfBoundsException e) {
            logger.error("----totalBillAmt has no fractional part----" + e.getMessage());
            createWorkValueData.addCell(centerPara(blankSpace + totalBillAmt));
            createWorkValueData.addCell("00");
        }

    } else {
        createWorkValueData.addCell(" ");
        createWorkValueData.addCell(" ");
    }

    BigDecimal billAmount = BigDecimal.ZERO;
    if (egBillRegister.getBillamount() != null)
        billAmount = egBillRegister.getBillamount();

    if (billAmount.compareTo(BigDecimal.ZERO) > 0) {
        final String billAmt = toCurrency(billAmount.doubleValue());
        try {
            createWorkValueData.addCell(centerPara(blankSpace + billAmt.substring(0, billAmt.indexOf('.'))));
            createWorkValueData.addCell(
                    centerPara(blankSpace + billAmt.substring(billAmt.indexOf('.') + 1, billAmt.length())));
        } catch (final StringIndexOutOfBoundsException e) {
            logger.error("---billAmt has no fractional part---" + e.getMessage());
            createWorkValueData.addCell(centerPara(blankSpace + billAmt));
            createWorkValueData.addCell("");
        }
    } else {
        createWorkValueData.addCell(" ");
        createWorkValueData.addCell(" ");
    }
    return createWorkValueData;
}

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

License:Open Source License

protected PdfPTable createWorkValueLabelTable() {
    final PdfPTable createWorkValueLabel = new PdfPTable(11);
    createWorkValueLabel.getDefaultCell().setBorderWidth(1);
    createWorkValueLabel.getDefaultCell().setColspan(7);
    createWorkValueLabel.addCell(" ");
    createWorkValueLabel.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    createWorkValueLabel.getDefaultCell().setColspan(2);
    createWorkValueLabel//from   w ww .j a  v  a  2  s  . co  m
            .addCell(centerPara(pdfLabel.get("contractorbill.pdf.todate") + "\n" + " Rs.       P."));
    createWorkValueLabel
            .addCell(centerPara(pdfLabel.get("contractorbill.pdf.lastbill") + "\n" + " Rs.       P."));
    return createWorkValueLabel;
}

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

License:Open Source License

protected PdfPTable createDetailsForWorkOrderLabelTable() {
    final PdfPTable detailsForWorkOrderLabel = new PdfPTable(11);
    detailsForWorkOrderLabel.getDefaultCell().setBorderWidth(1);
    detailsForWorkOrderLabel.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    detailsForWorkOrderLabel.getDefaultCell().setColspan(2);
    detailsForWorkOrderLabel.addCell(pdfLabel.get("contractorbill.pdf.projectcode"));
    detailsForWorkOrderLabel.addCell(pdfLabel.get("contractorbill.pdf.assetcode"));
    detailsForWorkOrderLabel.getDefaultCell().setColspan(1);
    detailsForWorkOrderLabel.addCell(pdfLabel.get("contractorbill.pdf.Mbno"));
    detailsForWorkOrderLabel.getDefaultCell().setColspan(2);
    detailsForWorkOrderLabel.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

    detailsForWorkOrderLabel.addCell(blankSpace15 + pdfLabel.get("contractorbill.pdf.pages") + "\n"
            + blankSpace8 + pdfLabel.get("contractorbill.pdf.from") + blankSpace8
            + pdfLabel.get("contractorbill.pdf.to"));
    detailsForWorkOrderLabel.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    detailsForWorkOrderLabel.getDefaultCell().setColspan(4);
    detailsForWorkOrderLabel.addCell(pdfLabel.get("contractorbill.pdf.estimateno") + " " + estimateNumber);
    return detailsForWorkOrderLabel;
}

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

License:Open Source License

protected PdfPTable createWorkDescTable() {
    final PdfPTable workDescTable = new PdfPTable(11);
    workDescTable.getDefaultCell().setBorderWidth(1);
    workDescTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    workDescTable.getDefaultCell().setColspan(7);
    workDescTable/*w  w w. j a  va2s . c o  m*/
            .addCell(pdfLabel.get("contractorbill.pdf.workdescription") + newLine + workDescription + newLine);
    workDescTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    workDescTable.getDefaultCell().setColspan(4);
    workDescTable.addCell(pdfLabel.get("contractorbill.pdf.workcommencedon") + workcommencedOn + newLine
            + pdfLabel.get("contractorbill.pdf.workcompleteon") + workCompletedOn + newLine);
    return workDescTable;
}