0

I am using iTextsharp to generate a table and print in pdf formant. I am able to use colspan but when i try to use rowspan on PdfPCell it is unable to recognize it. I get "no definition for rowspan"

PdfPTable table = new PdfPTable(9);
            table.WidthPercentage = 90f;
            //set column widths
            int[] firstTablecellwidth = { 20, 10, 5, 5, 10, 10,10,10,10 };
            table.SetWidths(firstTablecellwidth);

            doc1.Add(p1);
            table.AddCell("Name :");
            PdfPCell cell = new PdfPCell(new Phrase("Star Diamonds"));
cell.Colspan = 8;///this works fine
cell.Rowspan = 4; //does not contain definition for rowspan
            table.AddCell(cell);
SamuraiJack
  • 5,131
  • 15
  • 89
  • 195

2 Answers2

1

I remember that Rowspan wasn't defined for PdfPTable when I wrote the first edition of "iText in Action". I also remember that Rowspan was defined when I wrote the second edition of that book (that was actually a rewrite).

Given your claim that you get "no definition for Rowspan", the logical conclusion would be that you're using a mighty old version of iTextSharp. I suggest that you update to iTextSharp 5.5.9 if you want to use the code in your question, or that you upgrade to iText 7 for C# if you're just starting with your project.

Your claim is contradicted by many other answers if you'd say that you're using a recent version of iTextSharp:

Community
  • 1
  • 1
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • you are right i was using older version. Its fixed now.+1 – SamuraiJack Jul 02 '16 at 08:23
  • See if you can answer this one http://stackoverflow.com/q/38158112/2064292 – SamuraiJack Jul 02 '16 at 08:26
  • When you post a question, you can *accept* a correct answer by clicking on the check mark near the score of the answer. The answer to [Unable to change font in iTextsharp?](http://stackoverflow.com/questions/38158112) is rather trivial. – Bruno Lowagie Jul 02 '16 at 08:36
-1

See this forum question discussing the different iTextSharp versions. It should work in the latest iTextsharp version.

Jeroen Heier
  • 3,520
  • 15
  • 31
  • 32
  • 1
    Links may go dead. Please copy the essential part of the solution to your answer, so future visitors of StackOverflow may still benefit from your answer. A good answer gets upvotes, an answer with only a dead link gets downvotes. – Amedee Van Gasse Jul 02 '16 at 07:57
  • thanks, upgrading to newer version helped. See if you can answer this one http://stackoverflow.com/q/38158112/2064292 – SamuraiJack Jul 02 '16 at 08:26