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.

Wed Aug 17, 2016 10:49 am

i am new don net programmer, sir i want to know how to select each image from word table cell and display them into image control in asp.net

shailendrapandit@ymail.com
 
Posts: 1
Joined: Tue Aug 16, 2016 11:15 am

Thu Aug 18, 2016 2:56 am

Hi,

Thanks for your inquiry.
Here is sample code for your reference:
Code: Select all
            //Create image list to collect extracted image
            List<Image> images = new List<Image>();
            Document doc = new Document();
            //Load a document from disk
            doc.LoadFromFile(FilePath + "8353.docx");
            //Get the first section
            Section sec = doc.Sections[0];
            //Get the first table
            Table table = sec.Tables[0] as Table;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                for (int j = 0; j < table.Rows[i].Cells.Count; j++)
                {
                    //Foreach paragraph in the cell
                    foreach (Paragraph par in table.Rows[i].Cells[j].Paragraphs)
                    {
                        //Get each document object of paragraph items
                        foreach (DocumentObject docObject in par.ChildObjects)
                        {
                            //If Type of Document Object is Picture, add it into image list
                            if (docObject.DocumentObjectType == DocumentObjectType.Picture)
                            {
                                DocPicture picture = docObject as DocPicture;
                                Image ima =  picture.Image;
                                images.Add(ima);
                            }
                        }
                    }
                }
            }

Hope this solution can help you, if there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Fri Aug 19, 2016 7:43 am

Hi,

Did the solution help you ? Has your issue been resolved ?
Thanks for your feedback.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Return to Spire.Doc

cron