Hi Richard,
Thanks for your inquiry.
Generally, to determine which section the element is in, you need to analyze it according to the internal structure of the document. To help us investigate your issue more accurately and quickly, please share your input file with us. You could upload here or send it to us(
support@e-iceblue.com) via email.
Meanwhile, I made a simple demo for you, and attached is my input document, you could test it with the latest
Spire.Doc Pack(hot fix) Version:8.4.7.
- Code: Select all
Document doc = new Document();
doc.LoadFromFile("test.docx");
//Get the section of the table
Table table = doc.Sections[0].Tables[0] as Table;
Section tableSection = table.Owner.Owner as Section;
//Get the section of the table cell
TableCell cell = table.Rows[0].Cells[0];
Section cellSection = cell.Owner.Owner.Owner.Owner as Section;
//Get the section of the paragraph
Paragraph para1 = doc.Sections[0].Paragraphs[1];
Section paragraphSection = para1.Owner.Owner as Section;
//Get the section of the picture
Paragraph para2 = doc.Sections[1].Paragraphs[1];
foreach (DocumentObject docObj in para2.ChildObjects)
{
if (docObj.DocumentObjectType == DocumentObjectType.Picture)
{
DocPicture picture = docObj as DocPicture;
Section pcitureSection = picture.OwnerParagraph.Owner.Owner as Section;
}
}
Sincerely,
Rachel
E-iceblue support team
Login to view the files attached to this post.