iTextSharp Conversion from Table to pdfPTable

Posted by Al. on Stack Overflow See other posts from Stack Overflow or by Al.
Published on 2009-12-11T05:43:48Z Indexed on 2012/09/26 9:39 UTC
Read the original article Hit count: 321

Filed under:
|

I have an old ASP.NET project originally done in ASP.NET 1.1 w/ iText.NET and converted to .NET 2.0 and iTextSharp 4.1.6.0. It uses lots of Table (I'm assuming pdfptable wasn't an option at the time it was created.) I am trying to convert this code to use the latest iTextSharp 5.0.0 dll and now see Table and cell have been removed. I started converting it anyway and soon found there is no equivalent to a lot of the functionality that Table offered. Mainly AddCell no longer allows a col,row setting. There are literally thousands of these calls in this code and the posibility of changing it to generate linearly row by row looks hopeless at the moment. The current code looks something like:

Dim myTable As New Table(NumReq + 2, IngDS.Tables(0).Rows.Count + 3)
        myTable.SetWidths(Width)
        myTable.Width = 100 
        myTable.Padding = 2 

myCell = New Cell(New Phrase("Some Text", New iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 8, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLACK)))
                    myCell.SetHorizontalAlignment(Element.ALIGN_RIGHT)
                    myCell.GrayFill = 0.75 
                    myTable.AddCell(myCell, Row, Col)

myCell = New Cell(New Phrase("Other Text",New iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 8, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLACK)))
                    myCell.GrayFill = 0.75 
                    myTable.AddCell(myCell, Row, Col+1)

Before I embark down that road I was hoping someone would be able to point me in a direction that I'm just totally missing that will make this conversion much more simple.

Any ideas?

Thanks.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about itextsharp