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

Free Support Forum - aspose.com

Image position on page is not correct when it is inside table's cell using C#

When positioning an image vertically on the top right of a page margin the image ends up in a table cell when the page only contains a table. Please click the link below for example and code. In the document on page 7 is an example of the issue.



You can use ShapeBase.IsLayoutInCell property to set a flag indicating whether the shape is displayed inside a table or outside of it.

In ResizeAndPositionBarcode method, you can use following code to set this property.

bool isInCell = shape.GetAncestor(NodeType.Cell) != null;
if (isInCell)
    shape.IsLayoutInCell = false;

Moreover, you need to save the document with following compatibility options.


If you do not want to optimize document for MsWordVersion.Word2010, you can use layout API to get the position of bookmark/shape inside the table’s cell and set the position of shape using Shape.Left and Shape.Top properties.

I think, you want to save the final document to PDF. So, please use the first approach to get the desired output.

Thank you very much that fixed the issue with the table cell.


Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.