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

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

Introduction

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

Prototype

public void setPaddingRight(float paddingRight) 

Source Link

Document

Setter for property paddingRight.

Usage

From source file:ilarkesto.integration.itext.Cell.java

License:Open Source License

@Override
public Element getITextElement() {
    PdfPCell cell = new PdfPCell();

    cell.setBorderColorTop(getBorderTopColor());
    cell.setBorderColorBottom(getBorderBottomColor());
    cell.setBorderColorLeft(getBorderLeftColor());
    cell.setBorderColorRight(getBorderRightColor());
    cell.setBorderWidthTop(APdfBuilder.mmToPoints(getBorderTopWidth()));
    cell.setBorderWidthBottom(APdfBuilder.mmToPoints(getBorderBottomWidth()));
    cell.setBorderWidthLeft(APdfBuilder.mmToPoints(getBorderLeftWidth()));
    cell.setBorderWidthRight(APdfBuilder.mmToPoints(getBorderRightWidth()));
    cell.setUseBorderPadding(false);//from   w  ww .j a v a  2s.c  o m

    cell.setPadding(0);
    cell.setPaddingTop(APdfBuilder.mmToPoints(getPaddingTop()));
    cell.setPaddingBottom(APdfBuilder.mmToPoints(getPaddingBottom()));
    cell.setPaddingLeft(APdfBuilder.mmToPoints(getPaddingLeft()));
    cell.setPaddingRight(APdfBuilder.mmToPoints(getPaddingRight()));

    cell.setBackgroundColor(getBackgroundColor());
    cell.setExtraParagraphSpace(0);
    cell.setIndent(0);

    cell.setColspan(getColspan());
    for (ItextElement element : elements)
        cell.addElement(element.getITextElement());
    return cell;
}

From source file:net.bull.javamelody.internal.web.pdf.PdfAbstractTableReport.java

License:Apache License

void initTable(List<String> headers, int[] relativeWidths) throws DocumentException {
    assert headers.size() == relativeWidths.length;
    final PdfPTable mytable = new PdfPTable(headers.size());
    mytable.setWidthPercentage(100);//  w ww  . java2  s .com
    mytable.setWidths(relativeWidths);
    mytable.setHeaderRows(1);
    final PdfPCell defaultCell = mytable.getDefaultCell();
    defaultCell.setGrayFill(0.9f);
    defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    defaultCell.setPaddingLeft(0);
    defaultCell.setPaddingRight(0);
    final Font tableHeaderFont = PdfFonts.TABLE_HEADER.getFont();
    for (final String header : headers) {
        mytable.addCell(new Phrase(header, tableHeaderFont));
    }
    defaultCell.setPaddingLeft(2);
    defaultCell.setPaddingRight(2);
    this.table = mytable;
}

From source file:net.bull.javamelody.internal.web.pdf.PdfMBeansReport.java

License:Apache License

private static PdfPTable createAttributesTable() {
    final PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(100);/*from  w  w w .  j av a  2  s  .c  om*/
    final PdfPCell defaultCell = table.getDefaultCell();
    defaultCell.setPaddingLeft(2);
    defaultCell.setPaddingRight(2);
    defaultCell.setVerticalAlignment(Element.ALIGN_TOP);
    defaultCell.setBorder(0);
    return table;
}

From source file:net.bull.javamelody.internal.web.pdf.PdfRuntimeDependenciesReport.java

License:Apache License

private void writeHeader() throws DocumentException {
    final List<String> headers = new ArrayList<String>();
    headers.add("Beans");
    headers.addAll(calledBeans);//from  w w  w .java  2 s .com
    final int[] relativeWidths = new int[headers.size()];
    Arrays.fill(relativeWidths, 0, headers.size(), 1);
    relativeWidths[0] = 4;

    final PdfPTable table = new PdfPTable(headers.size());
    table.setWidthPercentage(100);
    table.setWidths(relativeWidths);
    table.setHeaderRows(1);
    final PdfPCell defaultCell = table.getDefaultCell();
    defaultCell.setGrayFill(0.9f);
    defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    defaultCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    defaultCell.setPaddingLeft(0);
    defaultCell.setPaddingRight(0);
    for (final String header : headers) {
        table.addCell(new Phrase(header, boldCellFont));
        // pas la premire entte de colonne
        defaultCell.setRotation(90);
    }
    defaultCell.setRotation(0);
    defaultCell.setPaddingLeft(2);
    defaultCell.setPaddingRight(2);
    currentTable = table;
}

From source file:nl.dykema.jxmlnote.spikes.Spacing.java

License:Open Source License

/**
 * Main method.//w ww . j  a v a2 s . com
 * @param    args    no arguments needed
 * @throws DocumentException 
 * @throws IOException
 */
public static void main(String[] args) throws DocumentException, IOException {
    // step 1
    Document document = new Document();
    // step 2
    PdfWriter.getInstance(document, new FileOutputStream(RESULT));
    // step 3
    document.open();
    // step 4
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);
    Phrase p = new Phrase(
            "Dr. iText or: How I Learned to Stop Worrying " + "and Love the Portable Document Format.");
    PdfPCell cell = new PdfPCell(p);
    table.addCell("default leading / spacing");
    table.addCell(cell);
    table.addCell("absolute leading: 20");
    cell.setLeading(20f, 0f);
    table.addCell(cell);
    table.addCell("absolute leading: 3; relative leading: 1.2");
    cell.setLeading(3f, 1.2f);
    table.addCell(cell);
    table.addCell("absolute leading: 0; relative leading: 1.2");
    cell.setLeading(0f, 1.2f);
    table.addCell(cell);
    table.addCell("no leading at all");
    cell.setLeading(0f, 0f);
    table.addCell(cell);
    cell = new PdfPCell(new Phrase("Dr. iText or: How I Learned to Stop Worrying and Love PDF"));
    table.addCell("padding 10");
    cell.setPadding(10);
    table.addCell(cell);
    table.addCell("padding 0");
    cell.setPadding(0);
    table.addCell(cell);
    table.addCell("different padding for left, right, top and bottom");
    cell.setPaddingLeft(20);
    cell.setPaddingRight(50);
    cell.setPaddingTop(0);
    cell.setPaddingBottom(5);
    table.addCell(cell);
    p = new Phrase("iText in Action Second Edition");
    table.getDefaultCell().setPadding(2);
    table.getDefaultCell().setUseAscender(false);
    table.getDefaultCell().setUseDescender(false);
    table.addCell("padding 2; no ascender, no descender");
    table.addCell(p);
    table.getDefaultCell().setUseAscender(true);
    table.getDefaultCell().setUseDescender(false);
    table.addCell("padding 2; ascender, no descender");
    table.addCell(p);
    table.getDefaultCell().setUseAscender(false);
    table.getDefaultCell().setUseDescender(true);
    table.addCell("padding 2; descender, no ascender");
    table.addCell(p);
    table.getDefaultCell().setUseAscender(true);
    table.getDefaultCell().setUseDescender(true);
    table.addCell("padding 2; ascender and descender");
    cell.setPadding(2);
    cell.setUseAscender(true);
    cell.setUseDescender(true);
    table.addCell(p);
    document.add(table);
    // step 5
    document.close();
}

From source file:optika.sql.java

public void eksportoNePdf(String id) {
    Document document = new Document() {
    };/*  ww  w .  j a  v a 2  s  . co m*/
    try {
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("receta.pdf"));
        document.open();
        document.setPageSize(PageSize.A3);

        Image img = Image.getInstance("receta.jpg");
        img.setAbsolutePosition(450f, 10f);

        img.scaleToFit(600, 849);

        img.setAlignment(Image.LEFT | Image.ALIGN_BOTTOM | Image.ALIGN_BASELINE);
        img.setAbsolutePosition(0, 0);
        document.add(img);
        String[][] receta = merrReceten("select * from recetat where id=" + parseInt(id) + ";");
        String[][] tabela = merrReceten("select * from tabela where recetat_id=" + parseInt(id) + ";");
        int[] white = new int[tabela.length];
        for (int i = 0; i < tabela.length; i++) {
            white[i] = 0;
            int bosh = 0;
            for (int j = 3; j < tabela[i].length; j++) {
                if (tabela[i][j] == tabela[i][6]) {
                    continue;
                }

                if (!tabela[i][j].isEmpty()) {
                    bosh = 1;
                }

            }

            if (bosh == 0) {
                white[i] = 1;
            }
        }
        Paragraph data = new Paragraph("Data: " + receta[0][7]);
        data.setSpacingBefore(38);
        data.setSpacingAfter(40);
        PdfPTable table = new PdfPTable(7);
        if (white[0] == 0) {
            table.addCell(getCellPadding("" + tabela[0][3], 1));
        } else {
            table.addCell(getCellWhite("_", 1, 30));
        }
        table.addCell(getCellPadding("" + tabela[0][4], 1));
        table.addCell(getCellPadding("" + tabela[0][5], 1));
        table.addCell(getCellPadding("", 1));
        table.addCell(getCellPadding("" + tabela[0][7], 1));
        table.addCell(getCellPadding("" + tabela[0][8], 1));
        table.addCell(getCellPadding("" + tabela[0][9], 1));
        table.setWidthPercentage(105);
        table.setHorizontalAlignment(-100);

        if (white[1] == 0) {
            table.addCell(getCellPadding("" + tabela[1][3], 1));
        } else {

            table.addCell(getCellWhite("_", 1, 36));
        }
        table.addCell(getCellPadding("" + tabela[1][4], 1));
        table.addCell(getCellPadding("" + tabela[1][5], 1));
        table.addCell(getCellPadding("", 1));
        table.addCell(getCellPadding("" + tabela[1][7], 1));
        table.addCell(getCellPadding("" + tabela[1][8], 1));
        table.addCell(getCellPadding("" + tabela[1][9], 1));
        table.setWidthPercentage(105);
        table.setHorizontalAlignment(-100);

        if (white[2] == 0) {
            if (white[1] == 0) {
                table.addCell(getCell("" + tabela[2][3], 1, 30));

            } else {
                table.addCell(getCellWhite("_", 1, 23));
            }
        } else {

            table.addCell(getCellWhite("_", 1, 28));

        }
        table.addCell(getCell("" + tabela[2][4], 1, 0));
        table.addCell(getCell("" + tabela[2][5], 1, 0));
        table.addCell(getCell("", 1, 0));
        table.addCell(getCell("" + tabela[2][7], 1, 0));
        table.addCell(getCell("" + tabela[2][8], 1, 0));
        table.addCell(getCell("" + tabela[2][9], 1, 0));
        table.setWidthPercentage(105);
        table.setSpacingBefore(27);
        table.setHorizontalAlignment(-100);

        String[][] distanca = merrReceten("select * from distanca where recetat_id=" + parseInt(id) + ";");

        PdfPTable largAfer = new PdfPTable(3);

        if (distanca[0][3].isEmpty()) {
            PdfPCell larg = getCellWhite("_", 2, 15);
            largAfer.addCell(larg);
        } else {
            PdfPCell larg = new PdfPCell(new Phrase("" + distanca[0][3]));
            larg.setPadding(0);
            larg.setHorizontalAlignment(2);
            larg.setBorder(PdfPCell.NO_BORDER);
            larg.setPaddingBottom(20);
            largAfer.addCell(larg);
        }
        largAfer.addCell(getCell("", PdfPCell.ALIGN_RIGHT, 25));

        if (distanca[0][8].isEmpty()) {
            largAfer.addCell(getCellWhite("_", PdfPCell.ALIGN_RIGHT, 15));
        } else {
            largAfer.addCell(getCell("" + distanca[0][8], PdfPCell.ALIGN_RIGHT, 25));
        }
        largAfer.setWidthPercentage(75);
        largAfer.setHorizontalAlignment(350);

        PdfPTable od_os = new PdfPTable(5);
        od_os.addCell(getCell("OD= " + distanca[0][4], 0, 195));
        od_os.addCell(getCell("OS= " + distanca[0][5], 2, 195));
        od_os.addCell(getCell("", 0, 0));
        od_os.addCell(getCell("OD= " + distanca[0][9], 0, 0));
        od_os.addCell(getCell("OS= " + distanca[0][10], 1, 0));
        od_os.setWidthPercentage(90);
        od_os.setHorizontalAlignment(150);

        PdfPTable visusi = new PdfPTable(2);
        if (distanca[0][6].isEmpty()) {
            PdfPCell od_pa = getCellWhite("_", 2, 17);
            od_pa.setPaddingRight(45);
            visusi.addCell(od_pa);
        } else {
            PdfPCell od_pa = getCell(distanca[0][6], 2, 17);
            od_pa.setPaddingRight(45);
            visusi.addCell(od_pa);
        }

        if (distanca[0][11].isEmpty()) {
            visusi.addCell(getCellWhite("_", 2, 17));
        } else {
            visusi.addCell(getCell(distanca[0][11], 2, 17));
        }

        if (distanca[0][7].isEmpty()) {
            PdfPCell os_pa = getCellWhite("_", 2, 17);
            os_pa.setPaddingRight(45);
            visusi.addCell(os_pa);
        } else {
            PdfPCell os_pa = getCell(distanca[0][7], 2, 17);
            os_pa.setPaddingRight(45);
            visusi.addCell(os_pa);
        }

        if (distanca[0][12].isEmpty()) {
            visusi.addCell(getCellWhite("_", 2, 17));
        } else {
            visusi.addCell(getCell(distanca[0][12], 2, 0));
        }
        visusi.setWidthPercentage(100);
        visusi.setHorizontalAlignment(50);

        String[][] admin = merrReceten("select * from admin where id=1;");
        PdfPTable klienti = new PdfPTable(3);
        klienti.addCell(getCell("", 0, 0));
        klienti.addCell(getCell("", 0, 0));
        klienti.addCell(getCell("Emri: " + receta[0][2], 0, 0));

        klienti.addCell(getCell("Celular: " + admin[0][4], 0, 0));
        klienti.addCell(getCell("", 0, 0));
        PdfPCell celReceta = getCell("Celular: " + receta[0][4], 0, 0);
        celReceta.setPaddingTop(5);
        klienti.addCell(celReceta);

        klienti.addCell(getCell("Email: " + admin[0][5], 0, 0));
        klienti.addCell(getCell("", 0, 0));
        PdfPCell emailReceta = getCell("Email: " + receta[0][5], 0, 0);
        emailReceta.setPaddingBottom(5);
        emailReceta.setPaddingTop(5);
        klienti.addCell(emailReceta);

        klienti.addCell(getCell("Adresa: " + admin[0][6], 0, 0));
        klienti.addCell(getCell("", 0, 0));
        klienti.addCell(getCell("Adresa: " + receta[0][6], 0, 0));
        klienti.setSpacingBefore(50);

        PdfPTable kreu = new PdfPTable(1);
        kreu.addCell(getCell(" ", 0, 0));

        document.add(kreu);
        document.add(klienti);
        document.add(data);
        document.add(table);
        document.add(largAfer);
        document.add(od_os);
        document.add(visusi);

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();

}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

private PdfPCell newCell(Paragraph p) throws BadElementException {
    PdfPCell c = new PdfPCell(p);
    c.setBorder(PdfPCell.BOX);/*from  w  w w  .  ja  va  2 s  . com*/
    c.setBorderWidth(0.1f);
    c.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    c.setPaddingBottom(3f);
    c.setPaddingLeft(3f);
    c.setPaddingRight(3f);
    c.setPaddingTop(0f);
    c.setUseBorderPadding(true);
    return c;
}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

private PdfPCell newDescriptionCell(String s) throws DocumentException, IOException {
    PdfPCell c = newCell(s);
    c.setPaddingBottom(5f);// w ww.j  a v a  2s .c o m
    c.setPaddingLeft(5f);
    c.setPaddingRight(5f);
    c.setPaddingTop(2f);
    return c;
}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

private Element newSection(String s) throws DocumentException, IOException {
    Phrase c = fontSelectorB2.process(s);
    Paragraph p = new Paragraph(c);

    PdfPTable t = new PdfPTable(1);
    t.setSpacingBefore(15f);/*from   w ww .  j av  a  2  s.c o  m*/
    t.setSpacingAfter(7f);
    t.setWidthPercentage(100f);

    PdfPCell ce = newCell(p);
    ce.setBorder(PdfPCell.BOTTOM);
    ce.setBorderWidth(1f);
    ce.setPaddingLeft(0);
    ce.setPaddingRight(0);

    t.addCell(ce);

    return t;
}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

private Element newSubSection(String s) throws DocumentException, IOException {
    Phrase c = fontSelectorB.process(s);
    Paragraph p = new Paragraph(c);

    PdfPTable t = new PdfPTable(1);
    t.setSpacingBefore(7f);//  ww w  .j a va  2 s  .  com
    t.setSpacingAfter(5f);
    t.setWidthPercentage(100f);

    PdfPCell ce = newCell(p);
    ce.setBorder(PdfPCell.BOTTOM);
    ce.setBorderWidth(0.75f);
    ce.setPaddingLeft(0);
    ce.setPaddingRight(0);

    t.addCell(ce);

    return t;
}