We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Header text in PdfLightTable

Hi,
how i can set the header text in PdfLightTable?

Thank you.

9 Replies

TE Thiruvenkadam E Syncfusion Team August 27, 2009 11:56 AM UTC

Hi pegaso,

Thank you for your interest in Syncfusion products.

Set the header text in PdfLightTable

We can able to set the header text in PdfLightTable by using table.Columns[index].ColumnName property.

Kindly refer the below code snippet which helps to set the header text in PdfLightTable.


//Create PDF document
PdfDocument doc = new PdfDocument();
//Create a font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create Pdf pen for drawing broder
PdfPen borderPen = new PdfPen(PdfBrushes.DarkBlue);
borderPen.Width = 0;
//Add a page.
PdfPage page = doc.Pages.Add();
//Use DataTable as source
PdfLightTable table = new PdfLightTable();
//Create datatable
DataTable dataTable = GetTable(30, 5);
//Set Data source
table.DataSource = dataTable;
//Set Column Headers
table.Columns[0].ColumnName = "Employee Name";
table.Columns[1].ColumnName = "Office Phone";
table.Columns[2].ColumnName = "Office Email";
PdfCellStyle headerStyle = new PdfCellStyle(font, PdfBrushes.White, PdfPens.DarkBlue);
brush = new PdfSolidBrush(Color.FromArgb(33, 67, 126));
headerStyle.BackgroundBrush = brush;
//Set header row style
table.Style.HeaderStyle = headerStyle;
//Show the header row
table.Style.ShowHeader = true;
//Repeate header in all the pages
table.Style.RepeatHeader = true;
//Set header data from column caption
table.Style.HeaderSource = PdfHeaderSource.ColumnCaptions;
//Set layout properties
PdfLayoutFormat format = new PdfLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
//Draw table
table.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Sample.pdf");

private DataTable GetTable(int rowCount, int colCount)
{
DataTable temp = new DataTable();
for (int i = 0; i < colCount; i++)
temp.Columns.Add("Column" + i.ToString());

for (int j = 0; j < rowCount; j++)
{
string[] value = new string[colCount];
for (int i = 0; i < colCount; i++)
value[i] = i.ToString() + "," + j.ToString();
temp.Rows.Add(value);
}
return temp;
}
}


Please do find the sample from the below specified location which demonstrates Set the Header text in PdfLightTable and let me know if this helps,

http://files.syncfusion.com/support/PDF.Windows/F89515/TableHeader.zip

Regards,
Thiru



PE pegaso August 27, 2009 03:10 PM UTC

Hi Thiruvenkadam,
sorry but your example doesn't work, please try. It's like my script:

PdfLightTable table = new PdfLightTable();

table.DataSource = Dt;

table.Columns[0].ColumnName = "Employee Name";
table.Columns[1].ColumnName = "Office Phone";
table.Columns[2].ColumnName = "Office Email";

PdfCellStyle headerStyle = new PdfCellStyle(Font_Bold11, PdfBrushes.Black, PdfPens.Black);
PdfSolidBrush brush = new PdfSolidBrush(Color.FromArgb(200, 200, 200));

headerStyle.BackgroundBrush = brush;
table.Style.HeaderStyle = headerStyle;
table.Style.ShowHeader = true;
table.Style.RepeatHeader = true;

table.Style.HeaderSource = PdfHeaderSource.ColumnCaptions;
table.Draw(doc.Pages[doc.Pages.Count - 1], bounds, layoutFormat);

doc.Save("Elenco", Response, HttpReadType.Save);
doc.Close(true);

Have you another example?

Thank you.


SS Sri Subhashini M Syncfusion Team August 28, 2009 08:53 AM UTC

Hi Pegaso,

I was able to reproduce the issue which you mentioned here. The issue has been fixed and it is available with our latest development build. Kindly refer the below link for weekly development build updates,

http://www.syncfusion.com/downloads/development-builds

Could you please try our latest development build release and let me know if this helps?

Regards,
Suba


AH Aaron Hood August 31, 2009 09:14 PM UTC

I'm having the same issue. When I got the latest build it says invalid key when I re-enter my evaluation key.


TE Thiruvenkadam E Syncfusion Team September 2, 2009 01:33 AM UTC

Hi Pegaso,

I am sorry for the inconvenience caused.

Could you please update in which latest build version you have tried to reproduce the reported issue ,this will help us with our further investigation on the issue.

Please let us know if you have any questions.

Regards,
Thiru


AH Aaron Hood September 3, 2009 06:20 PM UTC

The DLL build I'm using is 7.302.0.20.


TE Thiruvenkadam E Syncfusion Team September 4, 2009 03:25 PM UTC

Hi Aaron,

The reported issue has been fixed and it is available with our latest development build[7.4.0.5]. Kindly refer the below link for weekly development build updates,

http://www.syncfusion.com/downloads/development-builds

Could you please try our latest development build[7.4.0.5] release and let us know if this helps?

Regards,
Thiru


AH Aaron Hood September 8, 2009 03:51 PM UTC

I was able to solve this via Direct-Trac Support. I was sent a new dll that fixed the bug.


TE Thiruvenkadam E Syncfusion Team September 15, 2009 10:25 AM UTC

Hi Aaron,

Thanks for the update.

Glad to hear that the problem has been resolved.

Please let us know if you need any further information.

Regards,
Thiru


Loader.
Live Chat Icon For mobile
Up arrow icon