The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

BrianHiltbrunner (1) [Avatar] Offline
Hi. I have been using the itext in action book to help me through a project I have and things have gone pretty well. But now the project has taken a nasty turn and they want to know if I can generate html instead of a pdf doc.

I am using pdfptables and pdfpcells all over the place. Which of course do not work for html generation (at least as I understand it). I see in the book that there is a class called SimpleTable that is able to produce html or pdf. But the sample on page 190 is a little small. I know that the book is about pdf generation and not about html generation. So I am hoping that there is another example online or in the book (that I may have missed) that you could refer me to that would show how to use SimpleTable in more detail.

If there are no examples on using this class could you give me a hint on how to specify the number of columns? I am sure that it is easy but I am missing it.

Thanks in advance!

blowagie (284) [Avatar] Offline
Re: SimpleTable
SimpleTable reintroduces the concept of rows. The number of columns in a SimpleTable is the number of cells in the first row that is added.
SimpleTable was created for parsers: when a <table> tag is encounterd, a SimpleTable instance is created. We don't know the number of columns yet. When a <tr> is encountered, a SimpleCell of type ROW is created. We still don't know how many columns there are. Each time a <td> is encounterd, a SimpleCell of type CELL is created, and cells are added to the SimpleCell of type ROW until we encounter </tr>.
Only then we know the number of columns.
In spite of the warnings about the old Table class, you could also use class Table to create the HTML. As a matter of fact, SimpleTable uses class Table behind the scenes to generate the HTML.
Note that the HTML producing capabilities of iText were written for debugging purposes. The HTML that is produced isn't always elegant.