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

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

Introduction

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

Prototype

public void setPadding(float padding) 

Source Link

Document

Sets the padding of the contents in the cell (space between content and border).

Usage

From source file:pipe.PdfMaker.java

private Element tenthElement(String verkaufspreis, String verkauft_an, String datum) {
    float leading = 9f;
    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(100f);/*from w  w w.  jav a  2  s. c  om*/
    PdfPCell cell;
    //Hier die Header zuerst
    cell = new PdfPCell(new Paragraph("Verkaufspreis", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Verkauft an", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Verkaufsdatum", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    //Ab hier die Werte
    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    Paragraph herkunftInfo = new Paragraph(verkaufspreis, courier);
    herkunftInfo.setLeading(leading);
    cell.addElement(herkunftInfo);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    Paragraph editionInfo = new Paragraph(verkauft_an, courier);
    editionInfo.setLeading(leading);
    cell.addElement(editionInfo);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidth(0.3f);
    cell.setFixedHeight(30f);
    Paragraph yearInfo = new Paragraph(datum, courier);
    yearInfo.setLeading(leading);
    cell.addElement(yearInfo);
    table.addCell(cell);

    return table;
}

From source file:pipe.PdfMaker.java

private Element eleventhElement(String oberflaeche, String bohrung, String filter) {
    float leading = 9f;
    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(100f);/* w  ww. ja  v  a 2 s. c  o  m*/
    PdfPCell cell;
    //Hier die Header zuerst
    cell = new PdfPCell(new Paragraph("Oberflche", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Bohrung", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Filter", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    //Ab hier die Werte
    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    Paragraph herkunftInfo = new Paragraph(oberflaeche, courier);
    herkunftInfo.setLeading(leading);
    cell.addElement(herkunftInfo);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    Paragraph editionInfo = new Paragraph(bohrung, courier);
    editionInfo.setLeading(leading);
    cell.addElement(editionInfo);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidth(0.3f);
    cell.setFixedHeight(18f);
    Paragraph yearInfo = new Paragraph(filter, courier);
    yearInfo.setLeading(leading);
    cell.addElement(yearInfo);
    table.addCell(cell);

    return table;
}

From source file:pipe.PdfMaker.java

private Element twelvethElement(String laenge, String kopfhoehe, String kopfdurchmesser) {
    float leading = 9f;
    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(100f);//  w ww .  j av  a 2s.co m
    PdfPCell cell;
    //Hier die Header zuerst
    cell = new PdfPCell(new Paragraph("Lnge", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Kopfhhe", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Kopfdurchmesser", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    //Ab hier die Werte
    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    Paragraph herkunftInfo = new Paragraph(laenge, courier);
    herkunftInfo.setLeading(leading);
    cell.addElement(herkunftInfo);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    Paragraph editionInfo = new Paragraph(kopfhoehe, courier);
    editionInfo.setLeading(leading);
    cell.addElement(editionInfo);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidth(0.3f);
    cell.setFixedHeight(18f);
    Paragraph yearInfo = new Paragraph(kopfdurchmesser, courier);
    yearInfo.setLeading(leading);
    cell.addElement(yearInfo);
    table.addCell(cell);

    return table;
}

From source file:pipe.PdfMaker.java

private Element thirteenthElement(String gewicht, String farbe) {
    float leading = 9f;
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100f);/*from ww w . j  a  v a  2s  .  com*/
    PdfPCell cell;

    cell = new PdfPCell(new Paragraph("Gewicht", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Farbe", arialSmall));
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    cell.setGrayFill(0.85f);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    cell.setFixedHeight(18f);
    Paragraph mundMatInfo = new Paragraph(gewicht, courier);
    mundMatInfo.setLeading(leading);
    cell.addElement(mundMatInfo);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    cell.setFixedHeight(18f);
    Paragraph modellInfo = new Paragraph(farbe, courier);
    modellInfo.setLeading(leading);
    cell.addElement(modellInfo);
    table.addCell(cell);

    return table;
}

From source file:pipe.PdfMaker.java

private Element fourteenthElement(String zustand, String lagerort) {
    float leading = 9f;
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100f);//from  ww  w.j  a v a2 s . c o m
    PdfPCell cell;

    cell = new PdfPCell(new Paragraph("Zustand", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Lagerort", arialSmall));
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    cell.setGrayFill(0.85f);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    cell.setFixedHeight(18f);
    Paragraph mundMatInfo = new Paragraph(zustand, courier);
    mundMatInfo.setLeading(leading);
    cell.addElement(mundMatInfo);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    cell.setFixedHeight(18f);
    Paragraph modellInfo = new Paragraph(lagerort, courier);
    modellInfo.setLeading(leading);
    cell.addElement(modellInfo);
    table.addCell(cell);

    return table;
}

From source file:pipe.PdfMaker.java

private Element fifteenthElement(String besonderes) {
    float leading = 9f;
    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100f);/*  w w w.  ja v a 2s .c  o m*/
    PdfPCell cell;

    cell = new PdfPCell(new Paragraph("Besonderes", arialSmall));
    cell.setPadding(2);
    cell.setGrayFill(0.85f);
    cell.setBorderWidth(0.3f);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setPadding(2);
    cell.setBorderWidth(0.3f);
    cell.setFixedHeight(30f);
    Paragraph herstellerInfo = new Paragraph(besonderes, courier);
    herstellerInfo.setLeading(leading);
    cell.addElement(herstellerInfo);
    table.addCell(cell);

    return table;
}

From source file:printers.AbstractHorariosPrinter.java

License:Open Source License

private PdfPCell createCeldaHorarioItem(HorarioItem h, int fila, int columna, int numColumnas, int numFilas) {
    Paragraph p;//from w  w  w.  j  av a  2 s . com
    PdfPCell c;
    if (!h.isHuecoLibre()) {

        p = getParagraphForAsignatura(h);
        c = new PdfPCell(p);
        c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        c.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        //Color col = h.getAsignatura().getColorEnTablaDeHorarios();
        Color col = h.getTramo().getColorEnTablaDeHorarios();
        c.setBackgroundColor(new BaseColor(col.getRed(), col.getGreen(), col.getBlue()));
        c.setPadding(5);
        c.setBorderColor(BaseColor.BLACK);
        c.setBorderWidth(1);
        c.setUseBorderPadding(false);
        c.setUseVariableBorders(true);

    } else {
        p = new Paragraph("");//"C"+h.getNumcasilla()+" D"+h.getDiaSemana()+" "+h.getRangoHoras().getInicio());
        c = new PdfPCell(p);
        c.setUseVariableBorders(true);
        c.setBorderColor(BaseColor.LIGHT_GRAY);
        c.setBorderWidth(.3F);
        //            c.setBorder(Rectangle.NO_BORDER);
        if (columna == numColumnas - 1) {
            c.setBorderColorRight(BaseColor.BLACK);
        }
        //            if (fila == numFilas - 1) {
        //                c.setBorder(Rectangle.BOTTOM);
        //            }
        //            if ((columna == numColumnas - 1) && (fila == numFilas - 1)) {
        //                c.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT);
        //            }
    }

    if (h.getNumeroDeCasillasQueOcupa() > 1) {
        c.setRowspan(h.getNumeroDeCasillasQueOcupa());

    }

    return c;
}

From source file:printers.HojaDeFirmaPrinter.java

License:Open Source License

private void creaCuerpo(Document doc, GregorianCalendar dia, ArrayList<HorarioItem> data) {

    Collections.sort(data, new ComparatorHorarioItems());

    PdfPTable t = new PdfPTable(3);
    t.setSpacingBefore(15f);/* www  .  j  av a  2  s . c o m*/
    t.setSpacingAfter(10f);
    t.setWidthPercentage(100);
    Font fontbold = new Font(Font.FontFamily.HELVETICA, 14, Font.BOLD);
    PdfPCell c = new PdfPCell(new Paragraph("Asignatura", fontbold));
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    c.setPadding(5);
    t.addCell(c);
    c = new PdfPCell(new Paragraph("Firma", fontbold));
    c.setPadding(5);
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    c.setPadding(5);
    t.addCell(c);
    c = new PdfPCell(new Paragraph("Incidencias", fontbold));
    c.setPadding(5);
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    t.addCell(c);
    for (HorarioItem h : data) {
        creaFilaFirma(t, h);
    }
    try {
        doc.add(t);
    } catch (DocumentException ex) {
        Logger.getLogger(HojaDeFirmaPrinter.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:printers.HojaDeFirmaPrinter.java

License:Open Source License

/**
 *
 * @param t//from  www.j  a  va2 s.c  o  m
 * @param h
 */
protected void creaFilaFirma(PdfPTable t, HorarioItem h) {
    Font font = new Font(Font.FontFamily.HELVETICA, 12);
    Font fontProfe = new Font(Font.FontFamily.HELVETICA, 10);
    String name = h.getRangoHoras() + "\n" + h.getAsignatura().getNombre();
    name += "\n" + h.getGrupo().getNombreGrupoCursoYCarrera();
    Paragraph p = new Paragraph(name, font);
    PdfPCell c = new PdfPCell(p);
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    c.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    c.setPadding(5);
    c.setFixedHeight(60);
    t.addCell(c);
    String nombreProfesor = h.getProfesor().getNombre() + " " + h.getProfesor().getApellidos();
    p = new Paragraph(nombreProfesor + ":", fontProfe);
    c = new PdfPCell(p);
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    c.setPadding(5);
    t.addCell(c);
    t.addCell("");
}

From source file:quanlyhoadon.PDFProcess.java

public boolean printPDF(String dest, Company company, Bill bill, LinhTinh lt) {
    try {//from  w  w  w  .j ava  2s .  c  o m
        BaseFont urName = BaseFont.createFont("font/Time_New_Roman.TTF", BaseFont.IDENTITY_H,
                BaseFont.EMBEDDED);
        Font nameFont = new Font(urName, 16, Font.BOLD);
        Font addFont = new Font(urName, 12);
        Font boldFont = new Font(urName, 14, Font.BOLD);
        Font contentFont = new Font(urName, 14);
        Font footFont = new Font(urName, 16);

        Document document = new Document(PageSize.A4.rotate());
        PdfWriter.getInstance(document, new FileOutputStream(dest));
        document.open();

        PdfPTable table = new PdfPTable(3);
        table.setWidthPercentage(100);
        table.setWidths(new float[] { 2, 6, 3 });

        //logo
        Image img = Image.getInstance("logo.jpg");
        img.scaleAbsolute(100, 100);
        PdfPCell cell = new PdfPCell(img);
        cell.setBorder(PdfPCell.NO_BORDER);

        //middle content
        String name = company.getName();
        String address = "\n\n?C: " + company.getAddress();
        String phone = "\n\n?T: " + company.getPhone();
        String hed = "\n\n     PHIU B?O GI?";

        Phrase mid = new Phrase();
        mid.add(new Chunk(name, nameFont));
        mid.add(new Chunk(address + phone, addFont));
        mid.add(new Chunk(hed, nameFont));

        PdfPCell midCell = new PdfPCell(mid);
        //      midCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        midCell.setPaddingTop(15);
        midCell.setPaddingLeft(40);
        midCell.setPaddingRight(15);
        midCell.setPaddingBottom(15);
        midCell.setBorder(PdfPCell.NO_BORDER);

        // right content
        String soCt = "S CT: " + bill.getId();
        String date = "\n\nNgy: " + bill.getDate() + "\n\nKho : " + lt.getKho();

        Phrase right = new Phrase();
        right.add(new Chunk(soCt + date, addFont));
        PdfPCell rightCell = new PdfPCell(right);
        rightCell.setPadding(15);
        rightCell.setBorder(PdfPCell.NO_BORDER);

        table.addCell(cell);
        table.addCell(midCell);
        table.addCell(rightCell);

        document.add(table);

        Phrase p1 = new Phrase();
        p1.add(new Chunk("?n v: ", addFont));
        p1.add(new Chunk(lt.getDonVi(), boldFont));
        p1.add(new Chunk("\n?a Ch: \n", addFont));

        Paragraph pagra = new Paragraph(p1);
        pagra.setIndentationLeft(15);
        pagra.setSpacingBefore(10);
        pagra.setSpacingAfter(10);
        document.add(pagra);

        //table lt
        PdfPTable tablList = new PdfPTable(6);

        tablList.setWidthPercentage(100);
        tablList.setWidths(new float[] { 1, 5, 7, 2, 3, 4 });

        String title[] = { "STT", "M Hng", "Tn Hng", "SL", "?n Gi", "Thnh Ti?n" };
        for (int i = 0; i < title.length; ++i) {
            Phrase phr = new Phrase();
            phr.add(new Chunk(title[i], boldFont));
            PdfPCell p = new PdfPCell(phr);
            p.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            tablList.addCell(p);
        }
        //--- add content
        for (int i = 0; i < bill.getCount(); ++i) {
            Phrase[] phrase = new Phrase[6];
            PdfPCell[] pCell = new PdfPCell[6];

            for (int k = 0; k < 6; ++k) {
                phrase[k] = new Phrase();
            }
            phrase[0].add(new Chunk((i + 1) + "", contentFont));
            phrase[1].add(new Chunk(bill.getMaHangAt(i), contentFont));
            phrase[2].add(new Chunk(bill.getTenHangAt(i), contentFont));
            phrase[3].add(new Chunk(bill.getSoLuongAt(i) + "", contentFont));
            phrase[4].add(new Chunk(bill.getDonGiaAt(i) + "", contentFont));
            phrase[5].add(new Chunk(bill.getThanhTienAt(i) + "", contentFont));

            for (int j = 0; j < 6; ++j) {
                pCell[j] = new PdfPCell(phrase[j]);
                pCell[j].setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

                tablList.addCell(pCell[j]);
            }
        }

        PdfPCell cell1 = new PdfPCell(new Phrase(new Chunk("Tng", boldFont)));
        cell1.setColspan(3);
        cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell1);

        //
        PdfPCell cell2 = new PdfPCell(new Phrase(new Chunk("" + bill.getTong(), boldFont)));
        cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell2);

        //
        PdfPCell cell3 = new PdfPCell(new Phrase(new Chunk("", boldFont)));
        cell3.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell3);

        //
        PdfPCell cell4 = new PdfPCell(new Phrase(new Chunk(String.format("%,d", bill.tongTien()), boldFont)));
        cell4.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell4);

        document.add(tablList);
        //-------------------in phuong thuc thanh toan
        Phrase p2 = new Phrase();
        p2.add(new Chunk("Phng thc thanh ton: ", contentFont));
        p2.add(new Chunk(lt.getThanhToan(), boldFont));
        p2.add(new Chunk("\nLu  mua hng min tr li. Vui lng gi phiu trong 7 ngy: ",
                contentFont));

        Paragraph pagra2 = new Paragraph(p2);
        pagra2.setSpacingBefore(5);
        pagra2.setSpacingAfter(5);
        document.add(pagra2);

        //---- footer content
        PdfPTable tblFoot = new PdfPTable(3);

        tblFoot.setWidthPercentage(100);
        tblFoot.setWidths(new float[] { 1, 1, 1 });

        PdfPCell leftFootCell = new PdfPCell(new Phrase(new Chunk("NGI LP ", footFont)));
        PdfPCell midFootCell = new PdfPCell(new Phrase(new Chunk("K TO?N ", footFont)));
        PdfPCell rightFootCell = new PdfPCell(new Phrase(new Chunk("TH TRNG ?N V ", footFont)));

        leftFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        leftFootCell.setBorder(PdfPCell.NO_BORDER);
        midFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        midFootCell.setBorder(PdfPCell.NO_BORDER);
        rightFootCell.setBorder(PdfPCell.NO_BORDER);
        rightFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

        tblFoot.addCell(leftFootCell);
        tblFoot.addCell(midFootCell);
        tblFoot.addCell(rightFootCell);

        document.add(tblFoot);

        //
        document.close();
        JOptionPane.showMessageDialog(null, "In hoadon.pdf thnh cng");
        return true;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null,
                "hoadon.pdf ang c m\nVui lng ng li. Sau  th li");
        e.printStackTrace();
        return false;
    }
}