Inserting Image in a Cell


#1

Is there a way to insert an image in to a specific table cell?

Let me know.

Thanks

Narayanan


#2

Here is a sample for you.

====================================================================

Aspose.Pdf.Pdf pdf1 = new Pdf();

Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
sec1.Paragraphs.Add(table1);
table1.ColumnWidths = "70 2cm";

Aspose.Pdf.Row row1 = table1.Rows.Add();

Aspose.Pdf.Cell cell1Row1 = row1.Cells.Add("ColumnsSpan = 2");
cell1Row1.ColumnsSpan = 2;
cell1Row1.Border = new BorderInfo((int)BorderSide.All,0.5F);

Aspose.Pdf.Row row2 = table1.Rows.Add();

Aspose.Pdf.Cell cell1Row2 = row2.Cells.Add("cell1");
cell1Row2.Border = new BorderInfo((int)BorderSide.All,0.5F);

Aspose.Pdf.Cell cell2Row2 = row2.Cells.Add("cell2");

Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();

//Add image object into the Paragraphs specified cell.

cell2Row2.Paragraphs.Add(image1);

//Set the path of image file

image1.ImageInfo.File = "76_57749.jpg";

//Set the type of image using ImageFileType enumeration

image1.ImageInfo.ImageFileType = ImageFileType.Jpeg;

cell2Row2.Border = new BorderInfo((int)BorderSide.All,0.5F,new Aspose.Pdf.Color("Red"));

pdf1.Save("test.pdf");

=====================================================================