How to add section breaks around image in document regardless of parent type

I need to search for an image in a document and add sectionbreakcontinuous before and after the image. I’m running across a problem when sometimes the image is within a table and sometimes it’s not within a table. Is there a way to add these section breaks around the image regardless of it’s parent type, ie be able to handle the case where it’s within a table cell and the case where it’s just in a separate paragraph within the document?

Hi,

Thanks for your query. You can insert section break before and after a Shape image by using following code snippet. However, you can not insert section break inside a table by using Aspose.Words at the moment. Unfortunately, this feature is not available at the moment. I have logged this feature as WORDSNET-6873 in our issue tracking system. You will be updated via this forum thread once this feature is available.

We apologize for your inconvenience.

Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = (Shape) doc.GetChild(NodeType.Shape, 0, true);
builder.MoveTo(shape.ParentNode);
builder.InsertBreak(BreakType.SectionBreakContinuous);
builder.MoveTo(shape);
builder.InsertBreak(BreakType.SectionBreakContinuous);
doc.Save(MyDir + "AsposeOut.docx");