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 06, 2015 8:09 pm
I'm having trouble obtaining pictures from a Word document. I use the following method to get the pictures:
foreach (Spire.Doc.Section section in document.Sections)
{
foreach (Spire.Doc.Documents.Paragraph paragraph in section.Paragraphs)
{
foreach (DocumentObject docObject in paragraph.ChildObjects)
{
if (docObject.DocumentObjectType == DocumentObjectType.Picture)
{
//get docObject as DocPicture
DocPicture picture = docObject as DocPicture;
//Name Image
String imageName = String.Format(mainPath + @"Pictures\" + String.Format("img_{0}.png", pictureCount));
//Save Image
picture.Image.Save(imageName, System.Drawing.Imaging.ImageFormat.Png);
pictureCount++;
}
}
}
}
This works occasionally because sometimes the pictures seem to be within other pictures or drawings. I've included a sample of these troublesome pictures along with this post. Please tell me how I could save these pictures because the method above won't catch them at all.
Login to view the files attached to this post.
-

robertop19.rp
-
- Posts: 8
- Joined: Mon Apr 27, 2015 10:36 pm
Tue Jul 07, 2015 3:35 am
Hello,
Thanks for your inquiry.
When I load the document you sent, I will get exception information: Value cannot be null.Parameter name: fontName. I have posted this issue to our Dev team. Once it is resolved, we will let you know.
Sincerely,
Betsy
E-iceblue support team
-


Betsy
-
- Posts: 802
- Joined: Mon Jan 19, 2015 6:14 am
Tue Jul 07, 2015 1:25 pm
I'm sorry. Turns out I provided the wrong sample document. I posted a question on this forum before with a question about nullFontName but that's not the case with with this forum question. This reply contains the correct document; the one's with the unreachable pictures.
Login to view the files attached to this post.
-

robertop19.rp
-
- Posts: 8
- Joined: Mon Apr 27, 2015 10:36 pm
Wed Jul 08, 2015 3:42 am
Hello,
Thanks for your information. After investigation, we found that two objects in your document are not pictures, they are group. If you want to extract the picture, please ungroup and then extract the picture.
Sincerely,
Betsy
E-iceblue support team
-


Betsy
-
- Posts: 802
- Joined: Mon Jan 19, 2015 6:14 am
Wed Jul 08, 2015 1:50 pm
Can I ungroup using Spire.Doc C#?
-

robertop19.rp
-
- Posts: 8
- Joined: Mon Apr 27, 2015 10:36 pm
Thu Jul 09, 2015 2:59 am
Hello,
Sorry that at present Spire.Doc doesn’t support to ungroup.
Sincerely,
Betsy
E-iceblue support team
-


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