Extract images from Microsoft Office Word documents
Extract images from Microsoft Office Word documents
Leave feedback
To extract images from Microsoft Office Word documents GetImages methods are used. By default images are extracted with its original format. With using ImageOptions class it is possible to extract images from Microsoft Office Word documents as bmp, gif, jpeg, png and webp formats.
Warning
GetImagesmethod returns null value if image extraction isn’t supported for the document. For example, image extraction isn’t supported for TXT files. Therefore, for TXT file GetImages method returns null. If Microsoft Office Word document has no images, GetImages method returns an empty collection.
Here are the steps to extract images from Microsoft Office Word document to PNG-files:
Instantiate Parser object for the initial document;
Call GetImages method and obtain the collection of image objects;
Iterate through the collection and save image contents to the file.
The following example demonstrates how to extract images from Microsoft Office Word document:
// Create an instance of Parser classusing(Parserparser=newParser(filePath)){// Extract images from documentIEnumerable<PageImageArea>images=parser.GetImages();// Create the options to save images in PNG formatImageOptionsoptions=newImageOptions(ImageFormat.Png);intimageNumber=0;// Iterate over imagesforeach(PageImageAreaimageinimages){// Save the image to the png fileimage.Save(imageNumber.ToString()+".png",options);imageNumber++;}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to parse documents and extract data from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Parser App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.