Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to place Itextsharp table in fixed position & need only vertical gridlines.
could u please help how do i do this?

Thanks.

int columnCount = PrintGv.Columns.Count;
       int rowCount = PrintGv.Rows.Count;
       int tableRows = rowCount + 3;
       iTextSharp.text.Table grdTable = new iTextSharp.text.Table(columnCount, tableRows);
       grdTable.BorderWidth = 1;
       grdTable.BorderColor = new Color(0, 0, 255);
       grdTable.Cellpadding = 1;
       grdTable.Cellspacing = 1;
       grdTable.AddCell("ItemNo");
       grdTable.AddCell("Qty");
       grdTable.AddCell("Description");

       for (int rowCounter = 0; rowCounter < rowCount; rowCounter++)
       {
           for (int columnCounter = 0; columnCounter < columnCount; columnCounter++)
           {
               string strValue = PrintGv.Rows[rowCounter].Cells[columnCounter].Text;
               grdTable.AddCell(strValue);
           }
       }


       Doc.Add(grdTable);
Posted

1 solution

Hi Mary,

http://blog.rubypdf.com/itextsharp/tutorial01/[^]

here some c# code is the for all your needs using itextSharp.

Any help reply to me.
 
Share this answer
 
Comments
Lancy.net 24-Mar-12 11:14am    
Thanks Shiva for your reply i will try and let you know...
Lancy.net 24-Mar-12 12:58pm    
Hi I am getting a error "The table width must be greater than zero.
"



Stack Trace:


[ArgumentException: The table width must be greater than zero.]
iTextSharp.text.pdf.PdfPTable.WriteSelectedRows(Int32 colStart, Int32 colEnd, Int32 rowStart, Int32 rowEnd, Single xPos, Single yPos, PdfContentByte[] canvases, Boolean reusable) +162
iTextSharp.text.pdf.PdfPTable.WriteSelectedRows(Int32 colStart, Int32 colEnd, Int32 rowStart, Int32 rowEnd, Single xPos, Single yPos, PdfContentByte canvas, Boolean reusable) +458
iTextSharp.text.pdf.PdfPTable.WriteSelectedRows(Int32 colStart, Int32 colEnd, Int32 rowStart, Int32 rowEnd, Single xPos, Single yPos, PdfContentByte canvas) +57
iTextSharp.text.pdf.PdfPTable.WriteSelectedRows(Int32 rowStart, Int32 rowEnd, Single xPos, Single yPos, PdfContentByte canvas) +53
Admin_Pages_DO_Management_Print.btnExport_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\Invoice\Admin_Pages\DO_Management\Print.aspx.cs:223
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900