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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set style for single cell in PdfLightTable?

Platform: WinForms |
Control: PDF |
Published Date: January 11, 2016 |
Last Revised Date: January 11, 2016

How to set style for single cell in PdfLightTable?

Style can be applied to a single cell in PdfLightTable by using BeginCellLayout event handler.

Please refer to the following code example how to set the style for single cell in PdfLightTable:

C#:

//Create the PDF document

PdfDocument doc = new PdfDocument();

//Add the page

PdfPage page = doc.Pages.Add();

//Create the light table

PdfLightTable pdfLightTable = new PdfLightTable();

//Set Data source

pdfLightTable.DataSource = GetData();

//Call the event handlers

pdfLightTable.BeginCellLayout += pdfLightTable_BeginCellLayout;

//Draw the table

pdfLightTable.Draw(page, new RectangleF(new PointF(margin, 70), new SizeF(100,100));

//Save and close the document

doc.Save("sample.pdf");

doc.Close(true);

 

//Begin cell layout

private void pdfLightTable_BeginCellLayout(object sender, BeginCellLayoutEventArgs args)

{

if (args.RowIndex == 0 && args.CellIndex == 0)

{

//skip the cell

args.Skip = true;

//draw the cell

args.Graphics.DrawRectangle(PdfPens.Black, args.Bounds);

//draw the background brush

args.Graphics.DrawRectangle(PdfBrushes.LightBlue, args.Bounds);

//draw the string in cell

args.Graphics.DrawString("Cell Style", new PdfStandardFont(PdfFontFamily.Courier, 10), PdfBrushes.Black, new PointF(args.Bounds.X, args.Bounds.Y));

}

 }

 

Sample link:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfSample1585146640

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon