Add image to cell

How I will add a image to a cell?

I have created a cell like that

Aspose.Pdf.Cell cell1 = row.Cells.Add(Convert.ToString(dataTable.Rows[i]["Cmpn_Rnk"]));

Now i want to add a image to that cell or another cell behind that.

Getting error at the time of doing this

Aspose.Pdf.Cell cell2 = row.Cells.Add();

Aspose.Pdf.Image img = (Aspose.Pdf.Image)cell2.Paragraphs[0];//paragraph 0 not exist

img.ImageInfo.File = imagePath + ShellUtility.GetImage(showImage).Replace('/','\\');

Thanks

Rakesh

Hello Rakesh,

Please try the following code snippet,

Pdf pdf1 = new Pdf();
//////Create a section in the Pdf instance
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();
////Create a Table object
Aspose.Pdf.Table pdfCurrentTable = new Aspose.Pdf.Table(sec1);
//Set default cell border using BorderInfo object
pdfCurrentTable.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);

Aspose.Pdf.Row row0, row1, row2, row3;
row0 = pdfCurrentTable.Rows.Add();
Aspose.Pdf.Cell cell0, cell1;
cell0 = row0.Cells.Add();
//Create an image object

Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();
//Set the path of image file
image1.ImageInfo.File = @"C:\Temp\Aspose.JPG";
//Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = ImageFileType.Jpeg;
// Add image to paragraph collection of cell
row0.Cells[0].Paragraphs.Add(image1);

sec1.Paragraphs.Add(pdfCurrentTable);
// Create and save the pdf document
pdf1.Save(@"c:\Temp\FontVerdanaIssue.pdf");

Incase of any further issue, please feel free to share.

How do you add an image in line with some text? I’m using c#.
checkMark = image;
variableLab1 = text;

variableCell1.Paragraphs.Add(checkMark + variableLabel1); does not work

// this puts them on 2 different lines.
variableCell1.Paragraphs.Add(checkMark);
variableCell1.Paragraphs.Add(variableLabel1);

Hello Matthew,

Thanks for using our products.

Please visit the following link for required information on how to display image inline with text.

In the event of any further query, please feel free to contact.