But i am not able to do that on my code...my code is as follows...
BaseFont helvetica = BaseFont.CreateFont("Helvetica", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
iTextSharp.text.Font font = new iTextSharp.text.Font(helvetica, 8, iTextSharp.text.Font.NORMAL);
Chunk chunk = new Chunk("Sponsor this example and send me 1\u20ac.", font);
document.Add(chunk);
PdfPTable rptTable = new PdfPTable(dsreport.Tables[0].Columns.Count);
rptTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
rptTable.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
PdfPCell cell;
foreach (DataColumn dc in dsreport.Tables[0].Columns)
{
rptTable.AddCell(Convert.ToString(dc.ColumnName));
}
for (int i = 0; i < dsreport.Tables[0].Columns.Count; i++)
{
if (i >= 15)
{
PdfTemplate template = writer.DirectContent.CreateTemplate(20, 20);
template.BeginText();
float size = 16;
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
float width = bf.GetWidthPoint(dsreport.Tables[0].Columns[i].ColumnName, size);
template.SetRGBColorFillF(1, 1, 1);
template.SetFontAndSize(bf, size);
template.SetTextMatrix(0, 2);
//template.ShowText(dsreport.Tables[0].Columns[i].ColumnName);
template.EndText();
template.Width = width;
template.Height = size + 2;
Image img = Image.GetInstance(template); img.RotationDegrees =90;
cell = new PdfPCell(img);
cell.BackgroundColor = new Color(0, 0, 255);
rptTable.AddCell(img);
}
else
{
rptTable.AddCell(dsreport.Tables[0].Columns[i].ColumnName);
}
}
Member
16 Points
179 Posts
vertical colum of table in pdf using iTextSharp
Feb 16, 2010 01:25 AM|arvindharitus|LINK
Hi All,
I am using iTextSharp and creating a pdf. In this pdf i want to display the data that i display in grid on web page.
I have a number of columns(35) in that table. and some of them have to show vertcal.
I am trying sample of iTextSharp Chap1011.
http://itextsharp.sourceforge.net/examples/Chap1011.pdf
http://itextsharp.sourceforge.net/examples/Chap1011.cs
But i am not able to do that on my code...my code is as follows...
BaseFont helvetica = BaseFont.CreateFont("Helvetica", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
iTextSharp.text.Font font = new iTextSharp.text.Font(helvetica, 8, iTextSharp.text.Font.NORMAL);
Chunk chunk = new Chunk("Sponsor this example and send me 1\u20ac.", font);
document.Add(chunk);
PdfPTable rptTable = new PdfPTable(dsreport.Tables[0].Columns.Count);
rptTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
rptTable.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
PdfPCell cell;
foreach (DataColumn dc in dsreport.Tables[0].Columns)
{
rptTable.AddCell(Convert.ToString(dc.ColumnName));
}
for (int i = 0; i < dsreport.Tables[0].Columns.Count; i++)
{
if (i >= 15)
{
PdfTemplate template = writer.DirectContent.CreateTemplate(20, 20);
template.BeginText();
float size = 16;
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
float width = bf.GetWidthPoint(dsreport.Tables[0].Columns[i].ColumnName, size);
template.SetRGBColorFillF(1, 1, 1);
template.SetFontAndSize(bf, size);
template.SetTextMatrix(0, 2);
//template.ShowText(dsreport.Tables[0].Columns[i].ColumnName);
template.EndText();
template.Width = width;
template.Height = size + 2;
Image img = Image.GetInstance(template);
img.RotationDegrees =90;
cell = new PdfPCell(img);
cell.BackgroundColor = new Color(0, 0, 255);
rptTable.AddCell(img);
}
else
{
rptTable.AddCell(dsreport.Tables[0].Columns[i].ColumnName);
}
}
Can anybody help me.....
-Arvind
Member
120 Points
34 Posts
Re: vertical colum of table in pdf using iTextSharp
Feb 28, 2010 11:37 PM|Pebble94464|LINK
Small Table ExampleSorry - wrong lib.All-Star
25756 Points
7014 Posts
Re: vertical colum of table in pdf using iTextSharp
Feb 28, 2010 11:42 PM|hans_v|LINK
He's using iTextSharp, not ABCpdf!!!