Example usage for com.lowagie.text.pdf PdfPCell setBorder

List of usage examples for com.lowagie.text.pdf PdfPCell setBorder

Introduction

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

Prototype

public void setBorder(int border) 

Source Link

Document

Enables/Disables the border on the specified sides.

Usage

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

License:Open Source License

public File getPdfFile(String filename) {
    try {/*from  w  ww. j  a  v a2s  . com*/
        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;
}

From source file:org.kuali.kfs.gl.report.TransactionReport.java

License:Open Source License

/**
 * Appends the scrubber totals/statistics and error report to the given (iText) document object.
 * //from   w  w  w .  j  a va 2s.c o  m
 * @param document the PDF document
 * @param headerFont font for header
 * @param textFont font for report text
 * @param errorSortedList list of error'd transactions
 * @param reportErrors map containing transactions and the errors associated with each transaction
 * @param reportSummary list of summary objects
 * @param runDate date report was run
 * @throws DocumentException
 */
public void appendReport(Document document, Font headerFont, Font textFont, List<Transaction> errorSortedList,
        Map<Transaction, List<Message>> reportErrors, List<Summary> reportSummary, Date runDate)
        throws DocumentException {
    // Sort what we get
    Collections.sort(reportSummary);

    float[] summaryWidths = { 80, 20 };
    PdfPTable summary = new PdfPTable(summaryWidths);
    summary.setWidthPercentage(40);
    PdfPCell cell = new PdfPCell(new Phrase("S T A T I S T I C S", headerFont));
    cell.setColspan(2);
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    summary.addCell(cell);

    for (Iterator iter = reportSummary.iterator(); iter.hasNext();) {
        Summary s = (Summary) iter.next();

        cell = new PdfPCell(new Phrase(s.getDescription(), textFont));
        cell.setBorder(Rectangle.NO_BORDER);
        summary.addCell(cell);

        if ("".equals(s.getDescription())) {
            cell = new PdfPCell(new Phrase("", textFont));
            cell.setBorder(Rectangle.NO_BORDER);
            summary.addCell(cell);
        } else {
            DecimalFormat nf = new DecimalFormat("###,###,###,##0");
            cell = new PdfPCell(new Phrase(nf.format(s.getCount()), textFont));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            summary.addCell(cell);
        }
    }
    cell = new PdfPCell(new Phrase(""));
    cell.setColspan(2);
    cell.setBorder(Rectangle.NO_BORDER);
    summary.addCell(cell);

    document.add(summary);

    if (reportErrors != null && reportErrors.size() > 0) {
        float[] warningWidths = { 4, 3, 6, 5, 5, 4, 5, 5, 4, 5, 5, 9, 4, 36 };
        PdfPTable warnings = new PdfPTable(warningWidths);
        warnings.setHeaderRows(2);
        warnings.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("W A R N I N G S", headerFont));
        cell.setColspan(14);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        warnings.addCell(cell);

        // Add headers
        cell = new PdfPCell(new Phrase("Year", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("COA", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Account", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Sacct", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Obj", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("SObj", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("BalTyp", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("ObjTyp", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Prd", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("DocType", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Origin", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("DocNbr", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Seq", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Warning", headerFont));
        warnings.addCell(cell);

        for (Iterator errorIter = errorSortedList.iterator(); errorIter.hasNext();) {
            Transaction tran = (Transaction) errorIter.next();
            boolean first = true;

            List errors = (List) reportErrors.get(tran);
            for (Iterator listIter = errors.iterator(); listIter.hasNext();) {
                String msg = null;
                Object m = listIter.next();
                if (m instanceof Message) {
                    Message mm = (Message) m;
                    msg = mm.getMessage();
                } else {
                    if (m == null) {
                        msg = "";
                    } else {
                        msg = m.toString();
                    }
                }

                if (first) {
                    first = false;

                    if (tran.getUniversityFiscalYear() == null) {
                        cell = new PdfPCell(new Phrase("NULL", textFont));
                    } else {
                        cell = new PdfPCell(new Phrase(tran.getUniversityFiscalYear().toString(), textFont));
                    }
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getChartOfAccountsCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getAccountNumber(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getSubAccountNumber(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialObjectCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialSubObjectCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialBalanceTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialObjectTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getUniversityFiscalPeriodCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialDocumentTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialSystemOriginationCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getDocumentNumber(), textFont));
                    warnings.addCell(cell);
                    if (tran.getTransactionLedgerEntrySequenceNumber() == null) {
                        cell = new PdfPCell(new Phrase("NULL", textFont));
                    } else {
                        cell = new PdfPCell(new Phrase(
                                tran.getTransactionLedgerEntrySequenceNumber().toString(), textFont));
                    }
                    warnings.addCell(cell);
                } else {
                    cell = new PdfPCell(new Phrase("", textFont));
                    cell.setColspan(13);
                    warnings.addCell(cell);
                }
                cell = new PdfPCell(new Phrase(msg, textFont));
                warnings.addCell(cell);
            }
        }
        document.add(warnings);
    }
}

From source file:org.kuali.kfs.module.purap.pdf.PurchaseOrderQuotePdf.java

License:Open Source License

/**
 * A helper method to create a PdfPCell. We can specify the content, font, horizontal alignment, border (borderless, no
 * bottom border, no right border, no top border, etc.
 *
 * @param content              The text content to be displayed in the cell.
 * @param borderless           boolean true if the cell should be borderless.
 * @param noBottom             boolean true if the cell should have borderWidthBottom = 0.
 * @param noRight              boolean true if the cell should have borderWidthRight = 0.
 * @param noTop                boolean true if the cell should have borderWidthTop = 0.
 * @param horizontalAlignment  The desired horizontal alignment for the cell.
 * @param font                 The font type to be used in the cell.
 * @return                     An instance of PdfPCell which content and attributes were set by the input parameters.
 *//*from   w w  w .  j  ava  2  s  .co m*/
private PdfPCell createCell(String content, boolean borderless, boolean noBottom, boolean noRight,
        boolean noTop, int horizontalAlignment, Font font) {
    PdfPCell tableCell = new PdfPCell(new Paragraph(content, font));
    if (borderless) {
        tableCell.setBorder(0);
    }
    if (noBottom) {
        tableCell.setBorderWidthBottom(0);
    }
    if (noTop) {
        tableCell.setBorderWidthTop(0);
    }
    if (noRight) {
        tableCell.setBorderWidthRight(0);
    }
    tableCell.setHorizontalAlignment(horizontalAlignment);
    return tableCell;
}

From source file:org.kuali.kfs.pdp.batch.service.impl.DailyReportServiceImpl.java

License:Educational Community License

protected void addRow(PdfPTable dataTable, DailyReport dr, boolean bold, String name) {
    DecimalFormat af = new DecimalFormat("###,###,##0.00");
    DecimalFormat nf = new DecimalFormat("###,##0");

    Font f = null;//from   w  ww  .j a va  2s . c  om
    if (bold) {
        f = headerFont;

        for (int i = 0; i < 5; i++) {
            PdfPCell cell = new PdfPCell(new Phrase(" ", f));
            cell.setBorder(Rectangle.NO_BORDER);
            dataTable.addCell(cell);
        }
    } else {
        f = textFont;
    }

    PdfPCell cell = new PdfPCell(new Phrase(name, f));
    cell.setBorder(Rectangle.NO_BORDER);
    dataTable.addCell(cell);

    if (!bold) {
        cell = new PdfPCell(new Phrase(dr.getCustomer(), f));
    } else {
        cell = new PdfPCell(new Phrase("", f));
    }
    cell.setBorder(Rectangle.NO_BORDER);
    dataTable.addCell(cell);

    cell = new PdfPCell(new Phrase(af.format(dr.getAmount()), f));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    dataTable.addCell(cell);

    cell = new PdfPCell(new Phrase(nf.format(dr.getPayments()), f));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    dataTable.addCell(cell);

    cell = new PdfPCell(new Phrase(nf.format(dr.getPayees()), f));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    dataTable.addCell(cell);

    if (bold) {
        for (int i = 0; i < 5; i++) {
            PdfPCell cell2 = new PdfPCell(new Phrase(" ", f));
            cell2.setBorder(Rectangle.NO_BORDER);
            dataTable.addCell(cell2);
        }
    }
}

From source file:org.kuali.ole.describe.controller.EditorController.java

License:Open Source License

private PdfPCell getPdfPCellInJustified(String chunk) {
    PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
    pdfPCell.setBorder(pdfPCell.NO_BORDER);
    pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
    return pdfPCell;
}

From source file:org.kuali.ole.describe.controller.EditorController.java

License:Open Source License

private PdfPCell getPdfPCellInLeft(String chunk) {
    PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
    pdfPCell.setBorder(pdfPCell.NO_BORDER);
    pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
    return pdfPCell;
}

From source file:org.mapfish.print.config.layout.LegendsBlock.java

License:Open Source License

private PdfPCell createLine(RenderingContext context, double indent, PJsonObject node, Font pdfFont,
        PJsonObject params) throws DocumentException {
    final String name = node.getString("name");
    final String icon = node.optString("icon");
    final PJsonArray icons = node.optJSONArray("icons");

    final Paragraph result = new Paragraph();
    result.setFont(pdfFont);/* w w w  .j a va 2  s.c o  m*/
    if (icon != null) {
        result.add(PDFUtils.createImageChunk(context, maxIconWidth, maxIconHeight, URI.create(icon), 0.0f));
        result.add(" ");
    }
    if (icons != null) {
        for (int i = 0; i < icons.size(); ++i) {
            String iconItem = icons.getString(i);
            try {
                result.add(PDFUtils.createImageChunk(context, maxIconWidth, maxIconHeight, URI.create(iconItem),
                        0.0f));
                result.add(" ");
            } catch (InvalidValueException e) {
                LOGGER.warn("Failed to create image chunk: " + e.getMessage());
            }
        }
    }
    result.add(name);

    final PdfPCell cell = new PdfPCell(result);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setPadding(0f);
    cell.setPaddingLeft((float) indent);

    if (getBackgroundColorVal(context, params) != null) {
        cell.setBackgroundColor(getBackgroundColorVal(context, params));
    }

    return cell;
}

From source file:org.mapfish.print.PDFUtils.java

License:Open Source License

/**
 * When we have to do some custom drawing in a block that is layed out by
 * iText, we first give an empty table with the good dimensions to iText,
 * then iText will call a callback with the actual position. When that
 * happens, we use the given drawer to do the actual drawing.
 *///www .  j  av  a  2  s .c o m
public static PdfPTable createPlaceholderTable(double width, double height, double spacingAfter,
        ChunkDrawer drawer, HorizontalAlign align, PDFCustomBlocks customBlocks) {
    PdfPTable placeHolderTable = new PdfPTable(1);
    placeHolderTable.setLockedWidth(true);
    placeHolderTable.setTotalWidth((float) width);
    final PdfPCell placeHolderCell = new PdfPCell();
    placeHolderCell.setMinimumHeight((float) height);
    placeHolderCell.setPadding(0f);
    placeHolderCell.setBorder(PdfPCell.NO_BORDER);
    placeHolderTable.addCell(placeHolderCell);
    customBlocks.addChunkDrawer(drawer);
    placeHolderTable.setTableEvent(drawer);
    placeHolderTable.setComplete(true);

    final PdfPCell surroundingCell = new PdfPCell(placeHolderTable);
    surroundingCell.setPadding(0f);
    surroundingCell.setBorder(PdfPCell.NO_BORDER);
    if (align != null) {
        placeHolderTable.setHorizontalAlignment(align.getCode());
        surroundingCell.setHorizontalAlignment(align.getCode());
    }

    PdfPTable surroundingTable = new PdfPTable(1);
    surroundingTable.setSpacingAfter((float) spacingAfter);
    surroundingTable.addCell(surroundingCell);
    surroundingTable.setComplete(true);

    return surroundingTable;
}

From source file:org.odftoolkit.odfdom.converter.internal.itext.stylable.StylableParagraph.java

License:Open Source License

private PdfPCell createCell() {
    PdfPCell cell = new PdfPCell();
    cell.setBorder(Table.NO_BORDER);
    cell.setPadding(0.0f);//  ww  w  .  jav a  2 s  .c om
    cell.setUseBorderPadding(true);
    cell.getColumn().setAdjustFirstLine(false);
    cell.setUseDescender(true);
    return cell;
}

From source file:org.opentestsystem.delivery.testreg.rest.view.PDFReportView.java

License:Open Source License

private PdfPTable createMessageHeaders(final String[] headerColumns, final HierarchyLevel level,
        final String message) throws BadElementException {
    PdfPTable table = null;/*from ww  w.  j  a v a 2 s.c  om*/
    if (level != null && level == HierarchyLevel.CLIENT) {
        table = new PdfPTable(headerColumns.length - 3);
    } else {
        table = new PdfPTable(headerColumns.length);
    }
    table.setWidthPercentage(100);
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph(message, HEADER_MESSAGE_FONT));
    cell.setColspan(headerColumns.length);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);
    return table;
}