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

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

Introduction

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

Prototype

public void setBorder(final int border) 

Source Link

Document

Enables/Disables the border on the specified sides.

Usage

From source file:org.techytax.report.helper.PdfReportHelper.java

License:Open Source License

private void addTotalsIn(VatReportData vatReportData, PdfPTable table) throws DocumentException {
    PdfPCell cell;

    PdfPTable subTable = new PdfPTable(2);
    subTable.setWidths(new int[] { 8, 2 });

    Paragraph chunk = new Paragraph("btw in overzicht", headerFont);
    cell = new PdfPCell(chunk);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setColspan(2);//from  www. j  a  va2  s  .  co m
    subTable.addCell(cell);
    Paragraph headerChunk = new Paragraph("Omschrijving", headerFont);
    cell = new PdfPCell(headerChunk);
    subTable.addCell(cell);
    headerChunk = new Paragraph("Subtotaal", headerFont);
    cell = new PdfPCell(headerChunk);
    subTable.addCell(cell);
    PdfPCell tableCell = new PdfPCell(subTable);
    for (VatJournal vatJournal : vatReportData.getVatJournalsIn().getVatJournals()) {
        cell = new PdfPCell(new Paragraph(vatJournal.getCostType(), font));
        subTable.addCell(cell);
        Paragraph chunkMoney = new Paragraph(AmountHelper.formatDecimal(vatJournal.getTotalAmount()), font);
        cell = new PdfPCell(chunkMoney);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        subTable.addCell(cell);
    }

    cell = new PdfPCell(new Paragraph("Totaal in", headerFont));
    subTable.addCell(cell);
    Paragraph chunkMoney = new Paragraph(
            AmountHelper.formatDecimal(
                    vatReportData.getVatDeclarationData().getValueAddedTaxSuppliesServicesGeneralTariff()),
            totalAmountFont);
    cell = new PdfPCell(chunkMoney);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    cell.setBorder(PdfPCell.NO_BORDER);
    subTable.addCell(cell);
    tableCell = new PdfPCell(subTable);
    table.addCell(tableCell);
}

From source file:org.techytax.report.helper.PdfReportHelper.java

License:Open Source License

private void addTotalsOut(VatReportData vatReportData, PdfPTable table) throws DocumentException {
    PdfPCell cell;
    Paragraph chunk;/* w  ww . j av  a2s . c  o  m*/

    PdfPTable subTable = new PdfPTable(2);
    subTable.setWidths(new int[] { 8, 2 });
    chunk = new Paragraph("btw uit overzicht", headerFont);
    cell = new PdfPCell(chunk);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setColspan(2);
    subTable.addCell(cell);
    Paragraph headerChunk = new Paragraph("Omschrijving", headerFont);
    cell = new PdfPCell(headerChunk);
    subTable.addCell(cell);
    headerChunk = new Paragraph("Subtotaal", headerFont);
    cell = new PdfPCell(headerChunk);
    subTable.addCell(cell);
    PdfPCell tableCell = new PdfPCell(subTable);
    for (VatJournal vatJournal : vatReportData.getVatJournalsOut().getVatJournals()) {
        cell = new PdfPCell(new Paragraph(vatJournal.getCostType(), font));
        subTable.addCell(cell);
        Paragraph chunkMoney = new Paragraph(AmountHelper.formatDecimal(vatJournal.getTotalAmount()), font);
        cell = new PdfPCell(chunkMoney);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        subTable.addCell(cell);
    }

    cell = new PdfPCell(new Paragraph("Totaal uit", headerFont));
    subTable.addCell(cell);
    Paragraph chunkMoney = new Paragraph(
            AmountHelper.formatDecimal(vatReportData.getVatDeclarationData().getValueAddedTaxOnInput()),
            totalAmountFont);
    cell = new PdfPCell(chunkMoney);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    cell.setBorder(PdfPCell.NO_BORDER);
    subTable.addCell(cell);
    tableCell = new PdfPCell(subTable);
    table.addCell(tableCell);
}

From source file:pdf.FooterHeader.java

License:Open Source License

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfPTable table = new PdfPTable(3);
    try {//from  w  w w .j ava  2  s  .co m
        if (document.getPageNumber() > 1) {
            table.setWidths(new int[] { 24, 24, 2 });
            table.setTotalWidth(527);
            table.setLockedWidth(true);
            table.getDefaultCell().setFixedHeight(20);
            table.getDefaultCell().setBorder(Rectangle.BOTTOM);
            table.addCell(header);
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(String.format("Seite %d von", writer.getPageNumber()));
            PdfPCell cell = new PdfPCell(Image.getInstance(total));
            cell.setBorder(Rectangle.BOTTOM);
            table.addCell(cell);
            table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent());
        }
    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }

    PdfContentByte cb = writer.getDirectContent();
    if (document.getPageNumber() > 1) {
        footer = new Phrase(document.getPageNumber() - 2);
        ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, footer,
                (document.right() - document.left() - 30) / 2 + document.leftMargin(), document.bottom() + 10,
                0);
    }

}

From source file:pdf.PDFDesign.java

public PdfPTable createPriceTable(List<Item> itemList) throws DocumentException, IOException {
    PdfPTable table = new PdfPTable(nColumns);
    table.setWidthPercentage(100.0f);//from  w ww.  j a v  a  2  s.  c  o m
    //PdfContentByte cb = writer.getDirectContent();

    for (int i = 0; i < itemList.size(); i++) {
        Item item = itemList.get(i);
        //cell.setBorder(0);
        //BarcodeEAN code = new BarcodeEAN();
        //code.setCode(item.getBarCode());
        //code.setGuardBars(false);
        //Image im = code.createImageWithBarcode(cb, BaseColor.BLACK, BaseColor.BLACK);
        //p.add(im);//new Chunk(im,0.5f,0.5f));

        PdfPTable innerTable = new PdfPTable(1);

        Paragraph p1 = new Paragraph();
        p1.setFont(titleLineFont);
        String t = item.getTitle();
        String[] split = t.split("//");
        //System.out.println(t);

        for (String split1 : split) {
            p1.add(split1 + "\n");
        }
        PdfPCell innercCell1 = new PdfPCell(p1);
        innercCell1.setLeading(11f, 0f);
        innercCell1.setBorder(0);
        if (t.contains("//")
                && (size.equals("4x6") || size.equals("4x7") || size.equals("5x6") || size.equals("5x7"))) {
            innercCell1.setFixedHeight(titleLineFixedHeight);
        } else {
            innercCell1.setFixedHeight(15.0f);
        }
        //innercCell1.setFixedHeight(titleLineFixedHeight);
        innercCell1.setHorizontalAlignment(Element.ALIGN_CENTER);

        Paragraph p2 = new Paragraph();
        p2.setFont(amountAndPriceLabelLineFont);
        p2.add("Mnostv: " + item.getAmount() + item.getUnit() + "\n");
        PdfPCell innercCell2 = new PdfPCell(p2);
        innercCell2.setLeading(5f + textFontInc, 0f);
        innercCell2.setBorder(0);
        innercCell2.setHorizontalAlignment(Element.ALIGN_CENTER);

        Paragraph p3 = new Paragraph();
        p3.setFont(bigPriceNumberFont);
        p3.add(item.getPrice().substring(0, item.getPrice().length() - 3));
        p3.setFont(decimalPriceNumberFont);
        p3.add(item.getPrice().substring(item.getPrice().length() - 3, item.getPrice().length()));
        p3.setFont(unitPriceLineFont);
        p3.add(item.getCurrency());
        PdfPCell innercCell3 = new PdfPCell(p3);
        if (styleName.equals("style6") /*&& (size.equals("4x7") || size.equals("4x6"))*/) {
            innercCell3 = new PdfPCell(createLine3Table(item, 45 + priceFontInc, 20, 15));
        }
        innercCell3.setBorder(0);
        innercCell3.setLeading(bigPriceNumberLeading, 0f);
        innercCell3.setHorizontalAlignment(Element.ALIGN_CENTER);

        Paragraph p4 = new Paragraph();
        p4.setFont(unitPriceLineFont);
        p4.add("Cena za " + item.getXAmount() + item.getXUnit() + ": " + item.getUnitPrice() + " "
                + item.getCurrency());
        PdfPCell innercCell4 = new PdfPCell(p4);
        innercCell4.setBorder(0);
        innercCell4.setLeading(5f + textFontInc, 0f);
        innercCell4.setHorizontalAlignment(Element.ALIGN_CENTER);

        innerTable.addCell(innercCell1);
        innerTable.addCell(innercCell2);
        innerTable.addCell(innercCell3);
        innerTable.addCell(innercCell4);

        PdfPCell cell = new PdfPCell(innerTable);
        cell.setFixedHeight(cellHeight);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorderColor(BaseColor.GRAY);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell);
    }

    int remainder = itemList.size() % nColumns;
    if (remainder != 0) {
        remainder = nColumns - remainder;
    }
    for (int i = 0; i < remainder; i++) {
        PdfPCell c = new PdfPCell(new Phrase(" "));
        c.setBorderColor(BaseColor.GRAY);
        table.addCell(c);
    }

    return table;
}

From source file:pdf.PDFDesign.java

private PdfPTable createStyle6_4x7Table(List<Item> list) throws DocumentException, IOException {
    PdfPTable table = new PdfPTable(nColumns);
    table.setWidthPercentage(100.0f);//from ww  w. j  av a 2 s .com

    for (int i = 0; i < list.size(); i++) {
        Item item = list.get(i);
        PdfPTable innerTable = new PdfPTable(1);
        Paragraph p1 = new Paragraph();
        p1.setFont(titleLineFont);
        String t = item.getTitle();
        String[] split = t.split("//");
        for (String split1 : split) {
            p1.add(split1 + "\n");
        }
        PdfPCell innercCell1 = new PdfPCell(p1);
        innercCell1.setBorder(0);
        if (t.contains("//")) {
            innercCell1.setFixedHeight(titleLineFixedHeight);
        } else {
            innercCell1.setFixedHeight(15.0f + textFontInc);
        }
        innercCell1.setHorizontalAlignment(Element.ALIGN_CENTER);

        Paragraph p2 = new Paragraph();
        p2.setFont(amountAndPriceLabelLineFont);
        p2.add("Mnostv: " + item.getAmount() + item.getUnit() + "\n");
        PdfPCell innercCell2 = new PdfPCell(p2);
        innercCell2.setLeading(5f, 0f);
        innercCell2.setBorder(0);
        innercCell2.setFixedHeight(12.0f);
        innercCell2.setHorizontalAlignment(Element.ALIGN_CENTER);

        PdfPCell innercCell3 = new PdfPCell(createLine3Table(item, 0, 0, 0));
        innercCell3.setBorder(0);
        innercCell3.setLeading(2.0f, 0f);
        innercCell3.setFixedHeight(67.0f);
        innercCell3.setHorizontalAlignment(Element.ALIGN_CENTER);

        Paragraph p4 = new Paragraph();
        p4.setFont(unitPriceLineFont);
        p4.add("Cena za 1" + item.getXUnit() + ": " + item.getUnitPrice() + " " + item.getCurrency());
        PdfPCell innercCell4 = new PdfPCell(p4);
        innercCell4.setBorder(0);
        innercCell4.setLeading(1f, 0f);
        innercCell4.setHorizontalAlignment(Element.ALIGN_CENTER);

        innerTable.addCell(innercCell1);
        innerTable.addCell(innercCell2);
        innerTable.addCell(innercCell3);
        innerTable.addCell(innercCell4);

        PdfPCell cell = new PdfPCell(innerTable);
        cell.setFixedHeight(cellHeight);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorderColor(BaseColor.GRAY);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell);
    }

    int remainder = list.size() % nColumns;
    if (remainder != 0) {
        remainder = nColumns - remainder;
    }
    for (int i = 0; i < remainder; i++) {
        PdfPCell c = new PdfPCell(new Phrase(" "));
        c.setBorderColor(BaseColor.GRAY);
        table.addCell(c);
    }
    return table;
}

From source file:pdf.PDFDesign.java

private PdfPTable createLine3Table(Item item, int s1, int s2, int s3) throws DocumentException {
    if (s1 != 0 && s1 != 0 && s3 != 0) {
        bigPriceNumberFont.setSize(s1);//from  w ww . ja va2 s.c  om
        decimalPriceNumberFont.setSize(s2);
        decimalPriceNumberFont.setSize(s3);
    } else {
        bigPriceNumberFont.setSize(70);
    }
    Paragraph p3 = new Paragraph();
    p3.setFont(bigPriceNumberFont);
    p3.add(item.getPrice().substring(0, item.getPrice().length() - 3));

    Paragraph p3_2 = new Paragraph();
    p3_2.setFont(decimalPriceNumberFont);
    p3_2.add(item.getPrice().substring(item.getPrice().length() - 2, item.getPrice().length()));

    Paragraph p3_3 = new Paragraph();
    p3_3.setFont(decimalPriceNumberFont);
    p3_3.add(item.getCurrency());

    PdfPTable table = new PdfPTable(2);
    if (item.getPrice().length() == 6) {
        table.setWidths(new float[] { 2.8f, 1 });
    } else if (item.getPrice().length() == 5) {
        table.setWidths(new float[] { 1.8f, 1 });
    } else {
        table.setWidths(new float[] { 1.5f, 1 });
    }
    PdfPCell cell = new PdfPCell(p3);
    cell.setRowspan(2);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

    if (s1 != 0 && s1 != 0 && s3 != 0) {
        cell.setLeading(42.0f, 0f);
    } else {
        cell.setLeading(55.0f, 0f);
    }
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell(p3_2);
    cell.setRowspan(1);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell(p3_3);
    cell.setRowspan(1);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setBorder(0);
    table.addCell(cell);

    return table;
}

From source file:pdf.PDFDesign.java

private PdfPCell createEuroCell(Item item) throws DocumentException, IOException {
    Font descFont = new Font(droidsans, 12, Font.NORMAL, color);
    Font unitPriceFont = new Font(droidsans, 10, Font.NORMAL, color);

    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100f);//www  .j  a v a2s .co m
    PdfPCell cell;
    Paragraph p;

    cell = new PdfPCell();
    p = new Paragraph();
    p.setFont(descFont);
    p.add(item.getTitle());
    cell.setFixedHeight(28f);
    cell.setPhrase(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell();
    p = new Paragraph();
    p.setFont(descFont);
    p.add(item.getAmount() + item.getUnit());
    cell.setFixedHeight(16f);
    cell.setPhrase(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBorder(0);
    table.addCell(cell);

    table.addCell(createEuroInnerPrice(item));

    cell = new PdfPCell();
    p = new Paragraph();
    p.setFont(unitPriceFont);
    p.add("Cena za 1" + item.getXUnit() + ": " + item.getUnitPrice() + item.getCurrency() + "/"
            + item.getSecondUnitPrice() + item.getSecondCurrency());
    cell.setPhrase(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBorder(0);
    cell.setLeading(2f, 0f);
    table.addCell(cell);

    PdfPCell finalCell = new PdfPCell(table);
    finalCell.setFixedHeight(117.4f);
    finalCell.setBorderColor(BaseColor.GRAY);
    return finalCell;
}

From source file:pdf.PDFDesign.java

private PdfPCell createEuroInnerPrice(Item item) throws DocumentException {
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100f);/*w  w  w.ja va2 s  . c  o m*/
    table.setWidths(new float[] { 1f, 1f });

    table.addCell(createEuroInnerInnerPrice(item.getPrice(), item.getCurrency(), true));
    table.addCell(createEuroInnerInnerPrice(item.getSecondPrice(), item.getSecondCurrency(), false));

    PdfPCell finalCell = new PdfPCell(table);
    finalCell.setFixedHeight(57f);
    finalCell.setLeading(20f, 0f);
    finalCell.setBorder(0);
    return finalCell;
}

From source file:pdf.PDFDesign.java

private PdfPCell createEuroInnerInnerPrice(String price, String curr, boolean isFirst)
        throws DocumentException {

    Font bigPriceFont = new Font(droidsans, 40, Font.BOLD, color);
    Font smallPriceFont = new Font(droidsans, 18, Font.NORMAL, color);
    Font unitFont = new Font(droidsans, 12, Font.NORMAL, color);

    PdfPTable table = new PdfPTable(2);
    table.setWidths(new float[] { 3f, 1f });
    PdfPCell cell;
    Paragraph para;//  ww w  . j  a  v a  2s .  c  om

    para = new Paragraph("");
    para.setFont(bigPriceFont);
    if (price.length() >= 4) {
        para.add(price.substring(0, price.length() - 3));
    }
    cell = new PdfPCell(para);
    cell.setRowspan(2);
    cell.setFixedHeight(57f);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setBorder(0);
    table.addCell(cell);

    para = new Paragraph("");
    para.setFont(smallPriceFont);
    if (price.length() >= 4) {
        para.add(price.substring(price.length() - 2, price.length()));
    }
    cell = new PdfPCell(para);
    cell.setRowspan(1);
    cell.setFixedHeight(35f);
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setBorder(0);
    table.addCell(cell);

    para = new Paragraph();
    para.setFont(unitFont);
    para.add(curr);
    cell = new PdfPCell(para);
    cell.setRowspan(1);
    cell.setFixedHeight(22f);
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setBorder(0);
    table.addCell(cell);

    PdfPCell finalCell = new PdfPCell(table);
    finalCell.setBorder(0);
    /*if (isFirst) {
     finalCell.setBorder(Rectangle.RIGHT);
     }*/
    return finalCell;
}

From source file:pdf.PDFDesign.java

private PdfPCell createEuro_6_Cell(Item item) throws DocumentException {
    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100f);//from ww w .jav a2 s  .c om

    PdfPCell cell;
    Paragraph p;

    cell = new PdfPCell();
    p = new Paragraph();
    p.setFont(new Font(droidsans, 13, Font.NORMAL, color));
    String t = item.getTitle();
    String[] split = t.split("//");
    for (String split1 : split) {
        p.add(split1 + "\n");
    }
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setPhrase(p);
    cell.setColspan(2);
    cell.setFixedHeight(30f);
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell();
    p = new Paragraph();
    p.setFont(new Font(droidsans, 11, Font.NORMAL, color));
    p.add(item.getAmount() + "" + item.getUnit());
    cell.setPhrase(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    table.addCell(cell);

    table.addCell(createEuro_6_InnerPrice(item));

    cell = new PdfPCell();
    p = new Paragraph();
    p.setFont(new Font(droidsans, 11, Font.NORMAL, color));
    p.add("Cena za 1" + item.getXUnit() + ": " + item.getUnitPrice() + item.getCurrency() + "/"
            + item.getSecondUnitPrice() + item.getSecondCurrency());
    cell.setPhrase(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBorder(0);
    table.addCell(cell);

    PdfPCell finalCell = new PdfPCell(table);
    finalCell.setFixedHeight(cellHeight);//175f
    finalCell.setBorderColor(BaseColor.GRAY);
    return finalCell;
}