We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Table Cell Image

Hi,

Is it possible to add an image in a cell and if so how can we do this ?

Also i have add some text right (or left) next of an image. (vertical alignment ) How can i fix this ?

Francis,

Hi Francis,

1. To add an image in a cell, please follow the following steps:

i. Create an Image object

ii. Create a Paragraph object and add Image object into this

iii. Add this Paragraph object in the Cell.Paragraph collection

2. In order to align text and the image vertically in a cell, I would suggest to add an inner table with two cells in one row for image and text.

I hope this helps; If you still find any confusion and need further assistance please do let us know.

Regards,

Thanks,

First question :

I have also the add small images between pieces of text.

Example :

Important to mention is that the Post-Crack strength up to a deflection of mm (l = Span between the supports of the test beam) has to be measured with a deformation steered test machine.

Second question

How to add some special symbols like : ® FR (g fd)

Regards,

Hi Francis,

Please try using the following code snippet to accomplish your requirement.

[C#]

Pdf pdfConv = new Pdf();
//Create a section in the pdf document

Aspose.Pdf.Section sec1 = pdfConv.Sections.Add();
//Instantiate a table object

Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
//Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);

//Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);
//Set with column widths of the table
tab1.ColumnWidths = "450";

Aspose.Pdf.Image img = new Aspose.Pdf.Image();
img.ImageInfo.File = @"D:\pdftest\TestPDFConversion\TestPDFConversion\Image\Tick.gif";
img.ImageInfo.ImageFileType = ImageFileType.Jpeg;

Text text1 = new Text();
text1.Segments.Add("Important to mention is that the Post-Crack strength up to a deflection of ");
Segment seg2 = text1.Segments.Add();
//indicate seg2's InlineParagraph is a image.
seg2.InlineParagraph = img;
text1.Segments.Add("mm (l = Span between the supports of the test beam) has to be measured with a deformation steered test machine.");
//Create rows in the table and then cells in the rows

Aspose.Pdf.Row row1 = tab1.Rows.Add();
Aspose.Pdf.Cell cell1 = row1.Cells.Add();
//Add the text paragraph to the table
row1.Cells[0].Paragraphs.Add(text1);
//add a second row with special symbols
Text text2 = new Text();
//Create 1st text segment
Segment seg3 = new Segment(((char)226).ToString());
//Set the font name to the TextInfo.FontName property of segment
seg3.TextInfo.FontName = "Symbol";
//Add text segment to the text2 paragraph
text2.Segments.Add(seg3);

//Create rows in the table and then cells in the rows
Aspose.Pdf.Row row2 = tab1.Rows.Add();
Aspose.Pdf.Cell cell2 = row2.Cells.Add();
//Add the text paragraph to the table
row2.Cells[0].Paragraphs.Add(text2);

// save the Pdf file
pdfConv.Save(@"d:\pdftest\Text_with_Image.pdf");

I've also attached the resultant Pdf file, please take a look. In case it does not satisfy your requirment, please feel free to share.

I would also reccomend you to visit the following links Segment.InlineParagraph Property & Set Vertical Alignment of Paragraph to Baseline or Topline