That's what I figured. The API is broken then, since it has a PdfCell
(Phrase) constructor, and a Paragraph extends Phrase, which makes it
a Phrase, so it should be usable.
What about changing new PdfCell(Phrase) to internally do the
addElement for each element of a Paragraph? It seems like this is
what it should do. If not you probably need a SimplePhrase that
extends Phrase that only allows a single element, and then change
PdfCell(Phrase) to PdfCell(SimplePhrase), otherwise correctly written
code (as below) doesn't work, and there is no clue why.
Robert
On Jun 6, 2007, at 4:32 AM, itext-questions-
[EMAIL PROTECTED] wrote:
From: "Paulo Soares" <[EMAIL PROTECTED]>
Date: June 6, 2007 1:55:20 AM CDT
To: "Post all your questions about iText here" <itext-
[EMAIL PROTECTED]>
Subject: Re: [iText-questions] PdfTable.addCell(Phrase) broken?
Reply-To: Post all your questions about iText here <itext-
[EMAIL PROTECTED]>
PdfPTable doesn't support using Paragraph as a container for other
objects. You'll have to use PdfPCell.addElement() for each object.
Paulo
----- Original Message ----- From: "robert engels"
<[EMAIL PROTECTED]>
To: "iText here itext" <[email protected]>
Sent: Tuesday, June 05, 2007 6:50 PM
Subject: [iText-questions] PdfTable.addCell(Phrase) broken?
If I construct a Paragraph that contains a table, and then add the
paragraph to a table using addCell, the table does not appear.
It seems that PdfTable.addCell(Phrase phrase) does not work properly
- since a Paragraph is a Phrase by inheritance.
Is this a known problem? Is there some other way of doing this? The
html may be arbitrary.
sample code:
...
String html = "text<table><tr><td>a table</td></tr></table>";
Paragraph paragraph = toParagraph(html);
PdfXTable tbl = new PdfXTable(1);
tbl.addCell(paragraph);
doc.add(tbl);
...
The toParagraph() is:
protected Paragraph toParagraph(String html) throws IOException {
List list = HTMLWorker.parseToList(new StringReader(html), new
StyleSheet());
Paragraph p = new Paragraph();
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
Element element = (Element) iterator.next();
p.add(element);
}
return p;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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/