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

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

Introduction

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

Prototype

public void addElement(Element element) 

Source Link

Document

Adds an iText element to the cell.

Usage

From source file:questions.tables.TableAndHTMLWorker.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    Document document = new Document();
    try {//from   w ww  . ja v  a 2 s  .  c om
        StyleSheet styles = new StyleSheet();
        PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        document.open();
        ArrayList objects;
        objects = HTMLWorker.parseToList(new FileReader(RESOURCE), styles);
        PdfPTable table = new PdfPTable(1);
        PdfPCell cell = new PdfPCell();
        for (int k = 0; k < objects.size(); ++k)
            cell.addElement((Element) objects.get(k));
        table.addCell(cell);
        document.add(table);
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:sms.ReportForms.java

public PdfPCell creatTextCellHeader(String text) {
    PdfPCell cell = new PdfPCell();
    Paragraph p = new Paragraph();
    p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD));
    p.add(text);//www . jav a2  s  .c  o m
    cell.addElement(p);
    cell.setBorder(Rectangle.NO_BORDER);
    return cell;
}

From source file:sms.ReportForms.java

public PdfPCell creatTextCellChart(String text) {
    PdfPCell cell = new PdfPCell();
    Paragraph p = new Paragraph();
    p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD));
    p.add(text);//from w w  w  .  ja va  2 s .  c  om
    cell.addElement(p);
    cell.setRowspan(2);
    cell.setBorder(Rectangle.NO_BORDER);
    return cell;
}

From source file:sms.ReportForms.java

public PdfPCell createTextCell(String text) {

    PdfPCell cell = new PdfPCell();
    Paragraph p = new Paragraph();
    p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 16, Font.BOLD));
    //  p.setFont(Font.BOLD);
    p.setAlignment(Element.ALIGN_CENTER);
    p.add(text);/*from   w w  w.  j  a  v  a 2  s  .co m*/
    cell.addElement(p);
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setVerticalAlignment(Rectangle.NO_BORDER);

    return cell;

}

From source file:storemanagment.Printing.java

public PdfPCell createTextCellNb(String text) {

    PdfPCell cell = new PdfPCell();
    Paragraph p = new Paragraph();

    p.setAlignment(Element.ALIGN_CENTER);
    p.add(text);//from   ww  w .j a v a2s .com
    cell.addElement(p);
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setVerticalAlignment(Rectangle.NO_BORDER);

    return cell;

}

From source file:storemanagment.Printing.java

public PdfPCell creatTextCellTitles(String text) {
    PdfPCell cell = new PdfPCell();
    Paragraph p = new Paragraph();
    p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD));
    p.add(text);//from  w w w .j av a2 s .c om
    cell.addElement(p);
    // cell.setBorder(Rectangle.NO_BORDER);
    return cell;
}

From source file:storemanagment.Printing.java

public PdfPCell createTextCell(String text) {

    PdfPCell cell = new PdfPCell();
    Paragraph p = new Paragraph();
    p.setFont(FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, java.awt.Font.BOLD));
    //  p.setFont(Font.BOLD);
    p.setAlignment(Element.ALIGN_CENTER);
    p.add(text);//from  w  w w.  ja  v  a  2  s. co  m
    cell.addElement(p);
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setVerticalAlignment(Rectangle.NO_BORDER);

    return cell;

}

From source file:storemanagment.Printing.java

public PdfPCell createTextCellNormal(String text) {

    PdfPCell cell = new PdfPCell();
    Paragraph p = new Paragraph();
    // p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD,16,java.awt.Font.BOLD));
    //  p.setFont(Font.BOLD);
    p.setAlignment(Element.ALIGN_CENTER);
    p.add(text);//from  w  w  w .  j  a v a 2  s  . c  o m
    cell.addElement(p);
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setVerticalAlignment(Rectangle.NO_BORDER);

    return cell;

}

From source file:storemanagment.Printing.java

public PdfPCell createTextCellNormalUnderlined(String text) {

    PdfPCell cell = new PdfPCell();
    Paragraph p = new Paragraph();
    // p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD,16,java.awt.Font.BOLD));
    //  p.setFont(Font.BOLD);
    p.setAlignment(Element.ALIGN_CENTER);

    p.add(text);/* w ww.ja  v a2  s .co  m*/

    cell.addElement(p);

    cell.setBorder(Rectangle.NO_BORDER);
    cell.setVerticalAlignment(Rectangle.NO_BORDER);

    return cell;

}

From source file:storemanagment.Printing.java

public PdfPCell createTextCellcolor(String text, int c) {
    PdfPCell cell = new PdfPCell();
    if (c % 2 == 0) {

        Paragraph p = new Paragraph();
        cell.setBackgroundColor(Color.CYAN);
        p.add(text);//  w  w w .j  a va 2 s .c  o m
        cell.addElement(p);
    } else {
        Paragraph p = new Paragraph();
        //cell.setBackgroundColor(Color.CYAN);
        p.add(text);
        cell.addElement(p);
    }

    return cell;

}