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

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

Introduction

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

Prototype

public PdfPCell getDefaultCell() 

Source Link

Document

Gets the default PdfPCell that will be used as reference for all the addCell methods except addCell(PdfPCell).

Usage

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

License:Open Source License

public PdfPTable createMarketTenderNegFormulaTable() {
    final double totTenderNegMarketPer = calculateMarketRate();
    final PdfPTable marketTenderNegFormulaTable = new PdfPTable(2);
    marketTenderNegFormulaTable.getDefaultCell().setBorderWidth(1);
    marketTenderNegFormulaTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    marketTenderNegFormulaTable.getDefaultCell().setColspan(2);
    String formated_perc = null;/*w ww  .  j a  v a2  s  .  com*/
    formated_perc = nf.format(totTenderNegMarketPer);
    marketTenderNegFormulaTable.addCell(
            makePara((totTenderNegMarketPer > 0 ? POSITIVE_SIGN : NEGATIVE_SIGN) + formated_perc + "%"));
    return marketTenderNegFormulaTable;
}

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

License:Open Source License

public PdfPTable createMarketTenderNegTable() {
    final double totTenderNegMarketPer = calculateMarketRate();
    final PdfPTable marketTenderNegQuotedTable = new PdfPTable(2);
    marketTenderNegQuotedTable.getDefaultCell().setBorderWidth(1);
    marketTenderNegQuotedTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    marketTenderNegQuotedTable.getDefaultCell().setColspan(2);
    String perc_amt = null;//from   w w w.ja  va  2  s.c o m
    if (totTenderNegMarketPer >= 0)
        perc_amt = formatter
                .format(totalMarketRateAmt + totalMarketRateAmt * (Math.abs(totTenderNegMarketPer) / 100));
    else
        perc_amt = formatter
                .format(totalMarketRateAmt - totalMarketRateAmt * (Math.abs(totTenderNegMarketPer) / 100));
    marketTenderNegQuotedTable.addCell(makePara(perc_amt));
    return marketTenderNegQuotedTable;
}

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

License:Open Source License

/**
 * start final row for narration/*from  w  w w.ja  v  a 2 s  . c o m*/
 *
 * @param tenderResponse
 * @return
 */
public PdfPTable createTenderNarrationTable(final TenderResponse tenderResponse) {
    final PdfPTable tenderNarrationTable = new PdfPTable(13);
    tenderNarrationTable.getDefaultCell().setBorderWidth(1);
    tenderNarrationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    tenderNarrationTable.getDefaultCell().setColspan(13);
    tenderNarrationTable
            .addCell("\t" + (tenderResponse.getNarration() == null ? "" : tenderResponse.getNarration()));
    return tenderNarrationTable;
}

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

License:Open Source License

/**
 * start for first footer row/*from ww w  .ja va  2 s . co m*/
 */
public PdfPTable createTenderTotalTable() {
    final PdfPTable tenderTotalTable = new PdfPTable(3);
    tenderTotalTable.getDefaultCell().setBorderWidth(1);
    tenderTotalTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    tenderTotalTable.getDefaultCell().setColspan(3);
    tenderTotalTable.addCell(pdfLabel.get("tenderNegotiationpdf.tendertotal"));
    return tenderTotalTable;
}

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

License:Open Source License

public PdfPTable createAsPerEstimateTable(final TenderResponse tenderResponse) {
    final PdfPTable estimateTable = new PdfPTable(3);
    estimateTable.getDefaultCell().setBorderWidth(1);
    estimateTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    estimateTable.getDefaultCell().setColspan(3);
    estimateTable.addCell(pdfLabel.get("tenderNegotiationpdf.asPerEstimate"));
    estimateTable.getDefaultCell().setColspan(1);
    estimateTable.addCell(pdfLabel.get(TENDERNEGOTIATION_RATE));
    estimateTable.addCell(pdfLabel.get("tenderNegotiationpdf.Per"));
    estimateTable.addCell(pdfLabel.get(TENDERNEGOTIATION_AMOUNT));
    return estimateTable;
}

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

License:Open Source License

/**
 * creating tables for before negotion//from w  w w . jav  a 2  s  .  c  o  m
 */
public PdfPTable createBeforeNegotiationTable(final TenderResponse tenderResponse) {
    final PdfPTable beforeNegotiationTable = new PdfPTable(2);
    beforeNegotiationTable.getDefaultCell().setBorderWidth(1);
    beforeNegotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    beforeNegotiationTable.getDefaultCell().setColspan(2);
    beforeNegotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.asPerTender"));
    beforeNegotiationTable.getDefaultCell().setColspan(1);
    beforeNegotiationTable.addCell(pdfLabel.get(TENDERNEGOTIATION_RATE));
    beforeNegotiationTable.addCell(pdfLabel.get(TENDERNEGOTIATION_AMOUNT));
    return beforeNegotiationTable;
}

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

License:Open Source License

public PdfPTable createAfterNegotiationTable(final TenderResponse tenderResponse) {
    final PdfPTable afterNegotiationTable = new PdfPTable(2);
    afterNegotiationTable.getDefaultCell().setBorderWidth(1);
    afterNegotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    afterNegotiationTable.getDefaultCell().setColspan(2);
    String negDate = "";
    if (tenderResponse != null && tenderResponse.getNegotiationDate() != null)
        negDate = sdf.format(tenderResponse.getNegotiationDate());
    afterNegotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.aftneg") + negDate);
    afterNegotiationTable.getDefaultCell().setColspan(1);
    afterNegotiationTable.addCell(pdfLabel.get(TENDERNEGOTIATION_RATE));
    afterNegotiationTable.addCell(pdfLabel.get(TENDERNEGOTIATION_AMOUNT));
    return afterNegotiationTable;
}

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

License:Open Source License

public PdfPTable createMarketRateTable(final TenderResponse tenderResponse) {
    String asOnDate = "";
    if (tenderResponse != null && tenderResponse.getNegotiationDate() != null)
        asOnDate = sdf.format(tenderResponse.getNegotiationDate());
    final PdfPTable marketRateTable = new PdfPTable(2);
    marketRateTable.getDefaultCell().setBorderWidth(1);
    marketRateTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    marketRateTable.getDefaultCell().setColspan(2);
    marketRateTable.addCell(pdfLabel.get("tenderNegotiationpdf.marketratedate") + asOnDate);
    marketRateTable.getDefaultCell().setColspan(1);
    marketRateTable.addCell(pdfLabel.get(TENDERNEGOTIATION_RATE));
    marketRateTable.addCell(pdfLabel.get(TENDERNEGOTIATION_AMOUNT));
    return marketRateTable;
}

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

License:Open Source License

/**
 * create contractor table//from  ww w  .  ja  va 2s.co m
 *
 * @param tenderResponse
 * @return
 * @throws DocumentException
 * @throws ApplicationException
 */
private PdfPTable createContractorTable(final TenderResponse tenderResponse) throws DocumentException {
    final PdfPTable contractorTable = new PdfPTable(3);
    contractorTable.setWidthPercentage(100);
    contractorTable.setWidths(new float[] { 1.6f, 3.6f, 6.6f });
    try {
        contractorTable.getDefaultCell().setPadding(5);
        contractorTable.getDefaultCell().setBorderWidth(1);
        contractorTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        contractorTable.addCell(pdfLabel.get("tenderNegotiationpdf.contractorcode"));
        contractorTable.addCell(pdfLabel.get("tenderNegotiationpdf.contractorname"));
        contractorTable.addCell(pdfLabel.get("tenderNegotiationpdf.contractoraddress"));

        for (final TenderResponseContractors tenderResponseContractors : tenderResponse
                .getTenderResponseContractors()) {
            contractorTable.addCell(centerPara(tenderResponseContractors.getContractor().getCode()));
            contractorTable.addCell(centerPara(tenderResponseContractors.getContractor().getName()));
            contractorTable
                    .addCell(centerPara(tenderResponseContractors.getContractor().getCorrespondenceAddress()));
        }

    } catch (final Exception e) {
        LOGGER.info("Exception while creating contractor table" + e);
    }
    return contractorTable;
}

From source file:org.jsondoc.springmvc.pdf.PdfExportView.java

License:Open Source License

public File getPdfFile(String filename) {
    try {/*from  www . java  2  s .  c o m*/
        File file = new File(filename + "-v" + jsonDoc.getVersion() + FILE_EXTENSION);
        FileOutputStream fileout = new FileOutputStream(file);
        Document document = new Document();
        PdfWriter.getInstance(document, fileout);

        // Header
        HeaderFooter header = new HeaderFooter(new Phrase("Copyright "
                + Calendar.getInstance().get(Calendar.YEAR) + " Paybay Networks - All rights reserved"), false);
        header.setBorder(Rectangle.NO_BORDER);
        header.setAlignment(Element.ALIGN_LEFT);
        document.setHeader(header);

        // Footer
        HeaderFooter footer = new HeaderFooter(new Phrase("Page "), true);
        footer.setBorder(Rectangle.NO_BORDER);
        footer.setAlignment(Element.ALIGN_CENTER);
        document.setFooter(footer);

        document.open();

        //init documentation
        apiDocs = buildApiDocList();
        apiMethodDocs = buildApiMethodDocList(apiDocs);

        Phrase baseUrl = new Phrase("Base url: " + jsonDoc.getBasePath());
        document.add(baseUrl);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);

        int pos = 1;
        for (ApiMethodDoc apiMethodDoc : apiMethodDocs) {
            Phrase phrase = new Phrase(/*"Description: " + */apiMethodDoc.getDescription());
            document.add(phrase);
            document.add(Chunk.NEWLINE);

            PdfPTable table = new PdfPTable(2);
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
            table.setWidthPercentage(100);

            table.setWidths(new int[] { 50, 200 });

            // HEADER CELL START TABLE
            table.addCell(ITextUtils.getHeaderCell("URL"));
            table.addCell(ITextUtils.getHeaderCell("<baseUrl> " + apiMethodDoc.getPath()));
            table.completeRow();

            // FIRST CELL
            table.addCell(ITextUtils.getCell("Http Method", 0));
            table.addCell(ITextUtils.getCell(apiMethodDoc.getVerb().name(), pos));
            pos++;
            table.completeRow();

            // PRODUCES
            if (!apiMethodDoc.getProduces().isEmpty()) {
                table.addCell(ITextUtils.getCell("Produces", 0));
                table.addCell(ITextUtils.getCell(buildApiMethodProduces(apiMethodDoc), pos));
                pos++;
                table.completeRow();
            }

            // CONSUMES
            if (!apiMethodDoc.getConsumes().isEmpty()) {
                table.addCell(ITextUtils.getCell("Consumes", 0));
                table.addCell(ITextUtils.getCell(buildApiMethodConsumes(apiMethodDoc), pos));
                pos++;
                table.completeRow();
            }

            // HEADERS
            if (!apiMethodDoc.getHeaders().isEmpty()) {
                table.addCell(ITextUtils.getCell("Request headers", 0));

                PdfPTable pathParamsTable = new PdfPTable(3);
                pathParamsTable.setWidths(new int[] { 30, 20, 40 });

                pathParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                pathParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

                for (ApiHeaderDoc apiHeaderDoc : apiMethodDoc.getHeaders()) {
                    PdfPCell boldCell = new PdfPCell();
                    Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
                    boldCell.setPhrase(new Phrase(apiHeaderDoc.getName(), fontbold));
                    boldCell.getPhrase().setFont(new Font(Font.BOLD));
                    boldCell.setBorder(Rectangle.NO_BORDER);
                    pathParamsTable.addCell(boldCell);

                    PdfPCell paramCell = new PdfPCell();

                    StringBuilder builder = new StringBuilder();

                    for (String value : apiHeaderDoc.getAllowedvalues())
                        builder.append(value).append(", ");

                    paramCell.setPhrase(new Phrase("Allowed values: " + builder.toString()));
                    paramCell.setBorder(Rectangle.NO_BORDER);

                    pathParamsTable.addCell(paramCell);

                    paramCell.setPhrase(new Phrase(apiHeaderDoc.getDescription()));

                    pathParamsTable.addCell(paramCell);
                    pathParamsTable.completeRow();
                }

                PdfPCell bluBorderCell = new PdfPCell(pathParamsTable);
                bluBorderCell.setBorder(Rectangle.NO_BORDER);
                bluBorderCell.setBorderWidthRight(1f);
                bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR);

                table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos));
                pos++;
                table.completeRow();
            }

            // PATH PARAMS
            if (!apiMethodDoc.getPathparameters().isEmpty()) {
                table.addCell(ITextUtils.getCell("Path params", 0));

                PdfPTable pathParamsTable = new PdfPTable(3);
                pathParamsTable.setWidths(new int[] { 30, 15, 40 });

                pathParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                pathParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

                for (ApiParamDoc apiParamDoc : apiMethodDoc.getPathparameters()) {
                    PdfPCell boldCell = new PdfPCell();
                    Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
                    boldCell.setPhrase(new Phrase(apiParamDoc.getName(), fontbold));
                    boldCell.getPhrase().setFont(new Font(Font.BOLD));
                    boldCell.setBorder(Rectangle.NO_BORDER);
                    pathParamsTable.addCell(boldCell);

                    PdfPCell paramCell = new PdfPCell();
                    paramCell.setPhrase(new Phrase(apiParamDoc.getJsondocType().getOneLineText()));
                    paramCell.setBorder(Rectangle.NO_BORDER);

                    pathParamsTable.addCell(paramCell);

                    paramCell.setPhrase(new Phrase(apiParamDoc.getDescription()));

                    pathParamsTable.addCell(paramCell);
                    pathParamsTable.completeRow();
                }

                PdfPCell bluBorderCell = new PdfPCell(pathParamsTable);
                bluBorderCell.setBorder(Rectangle.NO_BORDER);
                bluBorderCell.setBorderWidthRight(1f);
                bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR);

                table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos));
                pos++;
                table.completeRow();
            }

            // QUERY PARAMS
            if (!apiMethodDoc.getQueryparameters().isEmpty()) {
                table.addCell(ITextUtils.getCell("Query params", 0));

                PdfPTable queryParamsTable = new PdfPTable(3);
                queryParamsTable.setWidths(new int[] { 30, 15, 40 });

                queryParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                queryParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

                for (ApiParamDoc apiParamDoc : apiMethodDoc.getQueryparameters()) {
                    PdfPCell boldCell = new PdfPCell();
                    Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
                    boldCell.setPhrase(new Phrase(apiParamDoc.getName(), fontbold));
                    boldCell.getPhrase().setFont(new Font(Font.BOLD));
                    boldCell.setBorder(Rectangle.NO_BORDER);
                    queryParamsTable.addCell(boldCell);

                    PdfPCell paramCell = new PdfPCell();
                    paramCell.setPhrase(new Phrase(apiParamDoc.getJsondocType().getOneLineText()));
                    paramCell.setBorder(Rectangle.NO_BORDER);

                    queryParamsTable.addCell(paramCell);

                    paramCell.setPhrase(new Phrase(
                            apiParamDoc.getDescription() + ", mandatory: " + apiParamDoc.getRequired()));

                    queryParamsTable.addCell(paramCell);
                    queryParamsTable.completeRow();
                }

                PdfPCell bluBorderCell = new PdfPCell(queryParamsTable);
                bluBorderCell.setBorder(Rectangle.NO_BORDER);
                bluBorderCell.setBorderWidthRight(1f);
                bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR);

                table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos));
                pos++;
                table.completeRow();
            }

            // BODY OBJECT
            if (null != apiMethodDoc.getBodyobject()) {
                table.addCell(ITextUtils.getCell("Body object:", 0));
                String jsonObject = buildJsonFromTemplate(apiMethodDoc.getBodyobject().getJsondocTemplate());
                table.addCell(ITextUtils.getCell(jsonObject, pos));
                pos++;
                table.completeRow();
            }

            // RESPONSE OBJECT
            table.addCell(ITextUtils.getCell("Json response:", 0));
            table.addCell(
                    ITextUtils.getCell(apiMethodDoc.getResponse().getJsondocType().getOneLineText(), pos));
            pos++;
            table.completeRow();

            // RESPONSE STATUS CODE
            table.addCell(ITextUtils.getCell("Status code:", 0));
            table.addCell(ITextUtils.getCell(apiMethodDoc.getResponsestatuscode(), pos));
            pos++;
            table.completeRow();

            table.setSpacingAfter(10f);
            table.setSpacingBefore(5f);
            document.add(table);
        }

        document.close();
        return file;
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    return null;
}