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.

Thu Mar 21, 2013 3:49 am

I want get the all picture in word file, the picture all in the tablecell, I use the following code
Code: Select all
           
           List<Image> images = new List<Image>();
           
            foreach (Section section in doc.Sections)
            {
                foreach (Paragraph paragraph in section.Paragraphs)
                {
                    foreach (DocumentObject docobject in paragraph.ChildObjects)
                    {
                        if (docobject.DocumentObjectType == DocumentObjectType.Picture)
                        {
                            DocPicture picture = docobject as DocPicture;
                            images.Add((Image)picture.Image.Clone());
                        }
                    }
                }
            }

but can't added the picture to list, why ?
How to get the DocPcture Object in word tablecell

liupeng
 
Posts: 2
Joined: Mon Mar 18, 2013 11:34 am

Thu Mar 21, 2013 5:55 am

I found the method,use the following code,can get the picture in tablecell
Code: Select all
            foreach (Table table in doc.Sections[0].Tables)
            {
                foreach (TableRow row in table.Rows)
                {
                    foreach (TableCell cell in row.Cells)
                    {
                        foreach (Paragraph paragraph in cell.Paragraphs)
                        {
                            foreach (DocumentObject docobject in paragraph.ChildObjects)
                            {
                                if (docobject.DocumentObjectType == DocumentObjectType.Picture)
                                {
                                    DocPicture picture = docobject as DocPicture;
                                    images.Add((Image)picture.Image.Clone());
                                }
                            }                           
                        }
                    }
                }
            }

liupeng
 
Posts: 2
Joined: Mon Mar 18, 2013 11:34 am

Fri Mar 22, 2013 1:41 am

Dear liupeng,

Thanks for your inquiry and sharing.
If you have any other issue, please feel free to contact us.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc