Articles in this section
Category / Section

How to insert images in a PdfLightTable?

1 min read

You can insert images into a PdfLightTable by using the BeginCellLayout event handler at the specified row or cell index. Refer to the following code example to draw the image to row index 1:

C#

//Creates DataTable for the source.
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Roll Number", "Student Name" };
dataTable.Rows.Add(values);
values = new object[] { " ", " " };
dataTable.Rows.Add(values);
values = new object[] { "011", "Clay" };
dataTable.Rows.Add(values);
PdfLightTable table = new PdfLightTable();
// Subscribes the cell layout event.
table.BeginCellLayout += new BeginCellLayoutEventHandler(table_BeginCellLayout);
table.DataSource = dataTable;
table.Style.CellPadding = 16;
// Draws the table in a page.
table.Draw(page.Graphics);
doc.Save("Sample.pdf");
// Cell layout event handler.
void table_BeginCellLayout(object sender, BeginCellLayoutEventArgs args)
{
if (args.RowIndex == 1)
{
PdfBitmap pBmp = new PdfBitmap(@"..\..\Data\logo.png");
args.Graphics.DrawImage(pBmp,args.Bounds);
}
}

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/PdfLightTableSample-1979834138.zip

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied