Click or drag to resize

PageExtractImages Method

Extracts all images on this page.

Namespace:  Atalasoft.Imaging.Codec.Pdf
Assembly:  Atalasoft.dotImage.PdfReader (in Atalasoft.dotImage.PdfReader.dll) Version: 11.0.0.0.0.297 (.NET 4.5.2, x86)
Syntax
public ExtractedImageInfo[] ExtractImages()

Return Value

Type: ExtractedImageInfo
Extracted images. Can be of zero length.
Remarks
This method will extract each image embedded in a specified page. The method is more efficient for single image PDF pages as it does not resample the image to fit in the indicated resolution.
Examples
C#
using (FileStream file = new FileStream( 
   string.Format(@"in.pdf", fileName), FileMode.Open, FileAccess.Read))
{
   Document document = new Document(new BinaryReader(file));
   for (int pageIndex=0; pageIndex<document.Pages.Count; pageIndex++)
   {
      Page page = document.Pages[pageIndex];
      ExtractedImageInfo[] images = page.ExtractImages();
      for (int imageIndex=0; null!=images && imageIndex<images.Length; imageIndex++)
      {
         images[imageIndex].Bitmap.Save( 
            string.Format(@"..\..\out_{0}_{1}.bmp", pageIndex, imageIndex));
      }
   }
}
[New Example] (Visual Basic)
Dim file As FileStream = New FileStream( _
   String.Format("in.pdf", fileName), FileMode.Open, FileAccess.Read))
Document document = New Document(New BinaryReader(file))
For pageIndex As Integer = 0 To document.Pages.Count - 1
      Dim page As Page = document.Pages(pageIndex)
      Dim images() As ExtractedImageInfo = page.ExtractImages()
      For imageIndex As Integer = 0 To images.Length)
         images(imageIndex).Bitmap.Save( _
            String.Format( "..\..\out_{0}_{1}.bmp", pageIndex, imageIndex))
     Next
Next
file.Close()
See Also