I believe that a PdfPCell cannot accept directly a Paragraph as Element...in 
fact if you see its constructors you will notice that there isn't a constructor 
which takes a Parapgraph as arguments...

Try using a Chunck:
PdfPCell pdfPCell = new PdfPCell(new Phrase(chunk));

A paragraph can be composed by more chunks... you could do:
List chunks = paragraph.getChunks();
for (Iterator iterator = chunks.iterator(); iterator.hasNext();) {
     Chunk chunk = (Chunk)iterator.next();
     // Creo una cella con la chunk appena recuperata
     PdfPCell pdfPCell = new PdfPCell(new Phrase(chunk));
        ...
}

Bye

Raffaele

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Eric
Summkeller
Sent: venerdì 22 dicembre 2006 15.11
To: [email protected]
Subject: [iText-questions] Problem with PdfPCell and addElement


I would like to create a header. For this I create a PdfPTable with one 
PdfPCell and add some Pararaphs into the PdfPCell with the addElement method. 
My Problem is that the Document is empty. 
Any ideas?

Code:

Rectangle page = document.getPageSize();
PdfPTable table = new PdfPTable(1);
PdfPCell cell = new PdfPCell();
Paragraph paragraph = new Paragraph("Hello World");
cell.addElement(paragraph);
table.addCell(cell);
table.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin
());
table.writeSelectedRows(0, -1, document.leftMargin(), document.topMargin(), 
writer.getDirectContent());



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to