Jump to content

Recommended Posts

Posted

Hi All,

 

I am working with iTextSharp 4.0.8 in my ASP.Net application.*I have used Nested Tables in*iTextSharp dll but i am getting Exceptions. Its Not working properly

 

The code i have written is:

privateDocument AddPagesToDocument1(Document document, string strKappaImagePath)

{

//Main Table

Table tblMain = newTable(40,26);

tblMain.Border = Rectangle.NO_BORDER;

tblMain.WidthPercentage = 100;

Cell cellFirst = newCell();

cellFirst.Rowspan = 40;

 

Image imgSide = Image.GetInstance(newUri(@"C:\Kappa_RelatedDocument\iTextSharpTutorial\iTextSharpTutorial\bonImg\sideTekstKappa.gif"));

cellFirst.Add(imgSide);

tblMain.AddCell(cellFirst);

cellFirst = newCell(newPhrase(newChunk("Datum: 30-06-2005",

FontFactory.GetFont(FontFactory.HELVETICA, 10, iTextSharp.text.Font.BOLD))));

cellFirst.Colspan = 19;

cellFirst.Rowspan = 2;

tblMain.AddCell(cellFirst,new System.Drawing.Point(0,1));

//Cell for the Gap Between the 2nd and 3rd columns

cellFirst = newCell("G");

cellFirst.Rowspan = 40;

tblMain.AddCell(cellFirst, new System.Drawing.Point(0, 20));

//2 nd column

cellFirst = newCell();

cellFirst.Colspan = 19;

cellFirst.Rowspan = 5;

cellFirst.Width = 100;

 

Table tblAfhaaladres = newTable(19,5);

tblAfhaaladres.Border = Rectangle.NO_BORDER;

tblAfhaaladres.AutoFillEmptyCells = true;

tblAfhaaladres.WidthPercentage = 100;

Cell cellAfhaaladres = newCell("A1");

cellAfhaaladres.Width = 19;

tblAfhaaladres.AddCell(cellAfhaaladres, new System.Drawing.Point(0, 0));

string strVal = cellAfhaaladres.GetWidthAsString();

cellAfhaaladres = newCell("A2");

cellAfhaaladres.Colspan = 19;

tblAfhaaladres.AddCell(cellAfhaaladres, new System.Drawing.Point(1, 0));

cellAfhaaladres = newCell("A3");

cellAfhaaladres.Colspan = 19;

tblAfhaaladres.AddCell(cellAfhaaladres, new System.Drawing.Point(2, 0));

cellAfhaaladres = newCell("A4");

cellAfhaaladres.Colspan = 19;

tblAfhaaladres.AddCell(cellAfhaaladres, new System.Drawing.Point(3, 0));

cellAfhaaladres = newCell("A5");

cellAfhaaladres.Colspan = 19;

tblAfhaaladres.AddCell(cellAfhaaladres, new System.Drawing.Point(4, 0));

cellFirst.Add(tblAfhaaladres);

//tblMain.InsertTable(tblAfhaaladres, new System.Drawing.Point(2, 1));

tblMain.AddCell(cellFirst, new System.Drawing.Point(2, 1));

//2 nd column

cellFirst = newCell("Bezorgadres:");

cellFirst.Colspan = 19;

cellFirst.Rowspan = 5;

tblMain.AddCell(cellFirst, new System.Drawing.Point(7, 1));

//2nd Column

cellFirst = newCell("Aantal Colli:");

cellFirst.Colspan = 19;

cellFirst.Rowspan = 3;

tblMain.AddCell(cellFirst, new System.Drawing.Point(12, 1));

//2nd Column

cellFirst = newCell("Bijzonderheden:");

cellFirst.Colspan = 19;

cellFirst.Rowspan = 3;

tblMain.AddCell(cellFirst, new System.Drawing.Point(15, 1));

//2nd Column

cellFirst = newCell("Koerier:");

cellFirst.Colspan = 19;

cellFirst.Rowspan = 8;

tblMain.AddCell(cellFirst, new System.Drawing.Point(18, 1));

//3rd Column

cellFirst = newCell();

cellFirst.Colspan = 19;

cellFirst.Rowspan = 9;

imgSide = Image.GetInstance(newUri(@"C:\Kappa_RelatedDocument\iTextSharpTutorial\iTextSharpTutorial\bonImg\kopKappa.gif"));

cellFirst.Add(imgSide);

tblMain.AddCell(cellFirst, new System.Drawing.Point(0, 21));

//3rd Column

cellFirst = newCell("Opdrachtgever en factuuradres:");

cellFirst.Colspan = 19;

cellFirst.Rowspan = 6;

tblMain.AddCell(cellFirst, new System.Drawing.Point(9, 21));

//3rd Column

cellFirst = newCell("Op al onze offerten, overeenkomsten en/ of feitelijke prestaties zijn steeds van toepassing de Kappa Koerier algemene bedrijfsvoorwaarden zoals gedeponeerd ter griffie van de arrondissementsrechtbank te Rotterdam.");

cellFirst.Colspan = 19;

tblMain.AddCell(cellFirst, new System.Drawing.Point(15, 21));

//3rd Column

cellFirst = newCell();

cellFirst.Colspan = 19;

cellFirst.Rowspan = 8;

imgSide = Image.GetInstance(newUri(@"C:\Kappa_RelatedDocument\iTextSharpTutorial\iTextSharpTutorial\bonImg\insert_ontv.gif"));

cellFirst.Add(imgSide);

tblMain.AddCell(cellFirst, new System.Drawing.Point(16, 21));

//3rd Column

cellFirst = newCell("Opdrachtgever en factuuradres:");

cellFirst.Colspan = 19;

cellFirst.Rowspan = 2;

tblMain.AddCell(cellFirst, new System.Drawing.Point(24, 21));

document.Add(tblMain);

return document;

}

The Exception*i am getting while*excecuting the following line:*

 

tblMain.AddCell(cellFirst, new System.Drawing.Point(2, 1));

 

----------------------------

iTextSharp.text.BadElementException: Adding a cell at the location (2,1) with a colspan of 19 and a rowspan of 5 is illegal (beyond boundaries/overlapping)

 

 

=========================

And*i downloaded iTextSharp tutorial also .*The Nested Table section not working in the downloaded tutorial also.

 

 

Any one please help in fixing this issue. its very very urgent for me. Itried in somany ways but i didnt get the solution

 

 

Thanks and Regards,

Laxmikanth.O

 

*

 

More...

 

View All Our Microsoft Related Feeds

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...