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

Free Support Forum - aspose.com

Problem extracting multiple Textboxs from Shape

I’m having some trouble to extract multiple textboxes from a single Drawing Shape. I’m using the following code to do so:

foreach (Node shapeNode in shape.ChildNodes)
    Paragraph paragraph = (Paragraph)shapeNode;
    foreach (Run run in paragraph.ChildNodes)
        if (run != null && run.HasInnerText)
            String text = run.Text;

The question is: how can I make sure that the text I’m getting is from a Drawing Shape with a single textbox or if there are more than one textboxes inside that Drawing Shape? Because when testing with my doc both situations showed the same behavior, so I couldn’t tell the difference.
I’m attaching the doc I just mentioned. Just to make it clear, I wanna know in the extracting process that the paragraph “Textbox2 line1” is in a different Textbox than “Textbox1 line1” and “Textbox1 line2”
Please help!

Thanks for your request. Please try using the following code:

// Open document
Document doc = new Document(@"Test025\in.doc");
// Get shapes from the document
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
int txtCounter = 0;
string text = string.Empty;
// loop through all shapes
foreach (Shape sp in shapes)
    if (sp.ShapeType == ShapeType.TextBox)
        text += String.Format("TextBox #{0} : {1} \n", txtCounter, sp.ToTxt());

Hope this helps.
Best regards.

That’s what I was looking. Thx a lot!