Image and text side by side in cell


I need to insert 1-3 images next to a text in a cell. I’ve tried creating paragraphs, but they are placed under each other. Instead, I need the objects (image and text) next to each other. Whether there be 1, 2 or 3 images is determined dynamically from user selections.

Which is the best approach to insert objects next to each other in a cell?


Dear dpouls1,

Thank you for considering Aspose.

You can use nested table - add a new table in the cell and put each text and image paragraph in a cell of the new table.



Thanks for speedy reply.


Another similar problem:

When creating a table, I don’t know the width of the columns. Is there any way to set the columnwidth later from the width of a string for example?

I want to create a table which contains a cell containing a table containing N cells as follows:


Can I determine the ColumnWidth from the length of a string and can I set the nested tables ColumnWidth from the parent table ColumnWidth?


Dear dpouls1,

Thank you for considering Aspose.

Please refer to Getting minimum column width in the programmer’s guide. The example shows how to get minimum width of a column and set the width after the data is added into table. If you use nested table, you should determine the width of nested table and then calculate the width of the parent table.


That almost covers our needs. Is there a function GetMaxColumnWidth which measures the width of a cell from a String without hyphenation?

We need to show many row of data in the Pdf and there’s nok room for a row to take up 2 lines.


Dear dpouls1,

Thank you for considering Aspose.

There is no such a function but I’d like to add it for you. It will be available within 2 days.


That would be great. Looking forward to the new hotfix.

Just so that we are agreed on the function, please consider this String:

"Thank you for considering Aspose"

GetMinColumnWidth will return the width of "considering"

The new GetMaxColumnWidth will return the width of “Thank you for considering Aspose”


Dear dpouls1,

Thank you for considering Aspose.

Please download hot fix 1.6.7 here.


First I add an Aspose.Pdf.Text element(CellText): CellTableCell.Paragraphs.Add(CellText)
The CellText contains TextInfo where I align the text left/right, whether its a number or not.

Second I set the max width of the tablecolumn of the cell I just created: CellTableCell.FitWidth = CellTable.GetMaxColumnWidth(CellIndexOfCellJustCreated)

My problem is that the second step resets the TextInfo of the cell, which results in all text aligning left.


Nevermind - my mistake, second step should be: