Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

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
You do not have the required permissions to view the files attached to this post.

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: 2328
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc