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

how to draw a ''dynamic'' image in cell

Hi,

I'd like to draw an image in a PdfLightTable cell. The only sample I have found shows how to use the BeginCellLayout event and there will be drawn a static image in the cell. What I'd like to achieve is to draw a dynamic image. How can I do this?

1 Reply

SS Sri Subhashini M Syncfusion Team July 29, 2009 07:32 AM UTC

Hi Andreas,

Thank you for your interest in Essential PDF.

Drawing dynamic images in table

We can achieve the behavior by choosing the images randomly. Could you please try the below code snippet in your sample and let me know if this helps?


void table_StartCellLayoutHeader(object sender, BeginCellLayoutEventArgs args)
{
int rowIndex = args.RowIndex;
int cellIndex = args.CellIndex;

Random random = new Random(3);
string[] imgPath = new string[] { @"..\..\Data\logo.png", @"..\..\Data\logo.gif", @"..\..\Data\logo.jpg" };
if (rowIndex == 0 && cellIndex == 1)
{
PdfGraphics g = args.Graphics;
PdfImage image = new PdfBitmap(imgPath[random.Next(3)]);
g.DrawImage( image,new RectangleF(args.Bounds.X+10,args.Bounds.Y,args.Bounds.Width -45,args.Bounds.Height));
}
}


Regards,
Suba

Loader.
Live Chat Icon For mobile
Up arrow icon