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.
Unfortunately, activation email could not send to your email. Please try again.

Header text in PdfLightTable

Thread ID:

Created:

Updated:

Platform:

Replies:

89515 Aug 26,2009 11:10 AM Sep 15,2009 06:25 AM ASP.NET Web Forms (Classic) 9
loading
Tags: PDF
pegaso
Asked On August 26, 2009 11:10 AM

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

Thank you.

Thiruvenkadam E [Syncfusion]
Replied On August 27, 2009 07:56 AM

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


pegaso
Replied On August 27, 2009 11:10 AM

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.

Sri Subhashini M [Syncfusion]
Replied On August 28, 2009 04:53 AM

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

Aaron Hood
Replied On August 31, 2009 05:14 PM

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

Thiruvenkadam E [Syncfusion]
Replied On September 1, 2009 09:33 PM

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

Aaron Hood
Replied On September 3, 2009 02:20 PM

The DLL build I'm using is 7.302.0.20.

Thiruvenkadam E [Syncfusion]
Replied On September 4, 2009 11:25 AM

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

Aaron Hood
Replied On September 8, 2009 11:51 AM

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

Thiruvenkadam E [Syncfusion]
Replied On September 15, 2009 06:25 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;