Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Jul 19, 2021 3:35 am

Hi ,

i want to need one help , I try to do identification of Shapes and Text Box in word file .
so i am using --

NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 1, true);

but it is not working properly. unable to identification shapes and text box.
Last edited by Aditya12345 on Tue Jul 20, 2021 4:58 am, edited 1 time in total.

Aditya12345
 
Posts: 2
Joined: Mon Jul 19, 2021 3:15 am

Mon Jul 19, 2021 10:05 am

Hello,

Thanks for your inquiry.
Our Spire.Doc provides getShapeType() to get the shape type, you could according to this method to identify shapes and text box. Please refer to the code below. If there is any question, please feel free to write back.
Code: Select all
        Document doc = new Document();
        doc.loadFromFile("input.docx");
        for (Section section : (Iterable<Section>)doc.getSections()) {
            for (int i = 0; i < section.getParagraphs().getCount(); i++) {
                Paragraph para = section.getParagraphs().get(i);
                for (int j = 0; j < para.getChildObjects().getCount(); j++)
                {
                    DocumentObject obj =para.getChildObjects().get(j);
                    //if the obj is shape object
                    if (obj instanceof ShapeObject)
                    {
                         //get shape type
                        ShapeType type = ((ShapeObject) obj).getShapeType();
                        if (type.equals("Text_Box")){
                            ......
                        }
                        if (type.equals("Rectangle")){
                            ......
                        }
                    }

                }
            }
        }

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Mon Jul 19, 2021 4:27 pm

I try to read , shape name as well as shape inside text that code is not help for me .
Please follow attachment.

Aditya12345
 
Posts: 2
Joined: Mon Jul 19, 2021 3:15 am

Tue Jul 20, 2021 7:18 am

Hello,

Thank you for your feedback.
Our Spire.Doc supports getting the shape names, but the method has not yet been published. I have submitted the requirment to our Dev team, once the method is available, I will inform you.
As for getting the text of shape, please refer to the code below. If there is still any question, please share your sample Word file to help us have a better investigtation. You could attach it here or send to us via email ([email protected]). Thanks in advance.
Code: Select all
        Document doc = new Document();
        doc.loadFromFile("input.docx");
        for (Section section : (Iterable<Section>)doc.getSections()) {
            for (int i = 0; i < section.getParagraphs().getCount(); i++) {
                Paragraph para = section.getParagraphs().get(i);
                for (int j = 0; j < para.getChildObjects().getCount(); j++)
                {
                    DocumentObject obj =para.getChildObjects().get(j);
                   
                    //if the obj is shape object
                    if (obj instanceof ShapeObject)
                    {
                        ShapeObject shape = (ShapeObject) obj;
                        String content = "";
                       
                        //get the child objects of the shape
                        for (int c =0; c < shape.getChildObjects().getCount(); c ++){
                           
                            //get the document object type of the child object
                            DocumentObjectType doType = shape.getChildObjects().get(c).getDocumentObjectType();
                           
                            //If doType is paragraph
                            if (doType.equals(DocumentObjectType.Paragraph)){
                                Paragraph paragraph = (Paragraph)shape.getChildObjects().get(c);
                                //get the text
                                 content += paragraph.getText();
                            }
                        }
                        System.out.println(content);                       
                    }
                }
            }
        }

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Sat Dec 30, 2023 12:09 pm

Annika.Zhou wrote:Hello,

Thank you for your feedback.
Our Spire.Doc supports getting the shape names, but the method has not yet been published. I have submitted the requirment to our Dev team, once the method is available, I will inform you.
....
Sincerely,
Annika
E-iceblue support team


Hello! Has progress been made in publishing these methods?
Sincerely,
Eugene

EugeneMinovich
 
Posts: 4
Joined: Wed Dec 27, 2023 12:36 pm

Tue Jan 02, 2024 1:30 am

Hello,

Thank you for your continued follow-up.
I sincerely apologize for the current unavailability of the shape name retrieval functionality, which is due to limitations in our underlying logic code.
I want to assure you that addressing this issue is of utmost importance to us. I have taken immediate action to urge our development team to prioritize the adjustment of the code and implement this feature as soon as possible.
Rest assured that I am closely monitoring the progress, and once there is any significant advancement or update regarding the implementation of the shape name retrieval feature, I will promptly inform you. Your satisfaction is our top priority, and we are committed to resolving this matter to meet your expectations.
I deeply apologize for any inconvenience this may have caused you. If you have any further questions or concerns, please do not hesitate to reach out to me. I am here to assist you.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.Doc

cron