GetImages
GetImages()
Extracts images from the document.
public IEnumerable<PageImageArea> GetImages()
Return Value
A collection of PageImageArea objects; null if images extraction isn’t supported.
Remarks
Learn more:
- Extract images from documents
- Extract images to files
- Extract images from Microsoft Office Word documents
- Extract images from Microsoft Office Excel spreadsheets
- Extract images from Microsoft Office PowerPoint presentations
- Extract images from Emails
- Extract images from PDF documents
Examples
The following example shows how to extract all images from the whole document:
// Create an instance of Parser class
using (Parser parser = new Parser(filePath))
{
    // Extract images
    IEnumerable<PageImageArea> images = parser.GetImages();
    // Check if images extraction is supported
    if (images == null)
    {
        Console.WriteLine("Images extraction isn't supported");
        return;
    }
    // Iterate over images
    foreach (PageImageArea image in images)
    {
        // Print a page index, rectangle and image type:
        Console.WriteLine(string.Format("Page: {0}, R: {1}, Type: {2}", image.Page.Index, image.Rectangle, image.FileType));
    }
}
See Also
- class PageImageArea
- class Parser
- namespace GroupDocs.Parser
- assembly GroupDocs.Parser
GetImages(PageAreaOptions)
Extracts images from the document using customization options (to set the rectangular area that contains images).
public IEnumerable<PageImageArea> GetImages(PageAreaOptions options)
| Parameter | Type | Description | 
|---|---|---|
| options | PageAreaOptions | The options for images extraction. | 
Return Value
A collection of PageImageArea objects; null if images extraction isn’t supported.
Remarks
Learn more:
- Extract images from documents
- Extract images to files
- Extract images from document page area
- Extract images from Microsoft Office Word documents
- Extract images from Microsoft Office Excel spreadsheets
- Extract images from Microsoft Office PowerPoint presentations
- Extract images from Emails
- Extract images from PDF documents
Examples
The following example shows how to extract only images from the upper-left courner:
// Create an instance of Parser class
using (Parser parser = new Parser(filePath))
{
    // Create the options which are used for images extraction
    PageAreaOptions options = new PageAreaOptions(new Rectangle(new Point(0, 0), new Size(300, 100)));
    // Extract images from the upper-left courner of a page:
    IEnumerable<PageImageArea> images = parser.GetImages(options);
    // Check if images extraction is supported
    if (images == null)
    {
        Console.WriteLine("Page images extraction isn't supported");
        return;
    }
    // Iterate over images
    foreach (PageImageArea image in images)
    {
        // Print a page index, rectangle and image type:
        Console.WriteLine(string.Format("Page: {0}, R: {1}, Type: {2}", image.Page.Index, image.Rectangle, image.FileType));
    }
}
See Also
- class PageImageArea
- class PageAreaOptions
- class Parser
- namespace GroupDocs.Parser
- assembly GroupDocs.Parser
GetImages(int)
Extracts images from the document page.
public IEnumerable<PageImageArea> GetImages(int pageIndex)
| Parameter | Type | Description | 
|---|---|---|
| pageIndex | Int32 | The zero-based page index. | 
Return Value
A collection of PageImageArea objects; null if images extraction isn’t supported.
Remarks
Learn more:
- Extract images from documents
- Extract images to files
- Extract images from document page
- Extract images from Microsoft Office Word documents
- Extract images from Microsoft Office Excel spreadsheets
- Extract images from Microsoft Office PowerPoint presentations
- Extract images from Emails
- Extract images from PDF documents
Examples
To extract images from a document page the following method is used:
// Create an instance of Parser class
using (Parser parser = new Parser(filePath))
{
    // Check if the document supports images extraction
    if (!parser.Features.Images)
    {
        Console.WriteLine("Document isn't supports images extraction.");
        return;
    }
    
    // Get the document info
    IDocumentInfo documentInfo = parser.GetDocumentInfo();
    // Check if the document has pages
    if (documentInfo.PageCount == 0)
    {
        Console.WriteLine("Document hasn't pages.");
        return;
    }
    
    // Iterate over pages
    for (int pageIndex = 0; pageIndex<documentInfo.PageCount; pageIndex++)
    {
        // Print a page number 
        Console.WriteLine(string.Format("Page {0}/{1}", pageIndex + 1, documentInfo.PageCount));
        // Iterate over images
        // We ignore null-checking as we have checked images extraction feature support earlier
        foreach (PageImageArea image in parser.GetImages(pageIndex))
        {
            // Print a rectangle and image type
            Console.WriteLine(string.Format("R: {0}, Text: {1}", image.Rectangle, image.FileType));
        }
    }
}
See Also
- class PageImageArea
- class Parser
- namespace GroupDocs.Parser
- assembly GroupDocs.Parser
GetImages(int, PageAreaOptions)
Extracts images from the document page using customization options (to set the rectangular area that contains images).
public IEnumerable<PageImageArea> GetImages(int pageIndex, PageAreaOptions options)
| Parameter | Type | Description | 
|---|---|---|
| pageIndex | Int32 | The zero-based page index. | 
| options | PageAreaOptions | The options for images extraction. | 
Return Value
A collection of PageImageArea objects; null if images extraction isn’t supported.
Remarks
Learn more:
- Extract images from documents
- Extract images to files
- Extract images from document page
- Extract images from document page area
- Extract images from Microsoft Office Word documents
- Extract images from Microsoft Office Excel spreadsheets
- Extract images from Microsoft Office PowerPoint presentations
- Extract images from Emails
- Extract images from PDF documents
See Also
- class PageImageArea
- class PageAreaOptions
- class Parser
- namespace GroupDocs.Parser
- assembly GroupDocs.Parser