VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.Pdf Namespace / PdfDocument Class / GetImages Method
Example



In This Topic
    GetImages Method (PdfDocument)
    In This Topic
    Returns a collection of image-resources of this PDF document.
    Syntax
    'Declaration
     
    Public Function GetImages() As PdfImageResource()
    public PdfImageResource[] GetImages()
    public: PdfImageResource*[]* GetImages(); 
    public:
    array<PdfImageResource^>^ GetImages(); 

    Return Value

    The collection that contains all image resources of this PDF document.
    Example
    This example shows how to obtain information about all image resources of PDF page.
    ''' <summary>
    ''' Prints information about image-resources of PDF document.
    ''' </summary>
    ''' <param name="pdfFilename">The filename of PDF document.</param>
    Public Shared Sub GetPdfImagesInfo(pdfFilename As String)
        ' open PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename)
            ' get collection of image-resources of PDF document
            Dim images As Vintasoft.Imaging.Pdf.Tree.PdfImageResource() = document.GetImages()
                
            ' print count of image-resource
            System.Console.WriteLine("Images count: {0}", images.Length)
                
            ' for each image-resource
            For Each image As Vintasoft.Imaging.Pdf.Tree.PdfImageResource In images
                ' print information about image-resource
                System.Console.WriteLine(vbTab & "{0,4}x{1,-4} {2,5}bpp {3}", image.Width, image.Height, image.BitsPerPixel, image.Compression)
            Next
        End Using
    End Sub
                
    ' This code example produces the following output: 
      Images count: 11
        189x41      24bpp Jpeg
        120x50      24bpp Jpeg
        122x56      24bpp Jpeg
        143x41      24bpp Jpeg
        216x21      24bpp Jpeg
        106x49       8bpp Zip
        209x30      24bpp Jpeg
        189x24      24bpp Jpeg
        122x42      24bpp Jpeg
          5x7       24bpp Zip
        817x292     24bpp Jpeg
    /// <summary>
    /// Prints information about image-resources of PDF document.
    /// </summary>
    /// <param name="pdfFilename">The filename of PDF document.</param>
    public static void GetPdfImagesInfo(string pdfFilename)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = 
            new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename))
        {
            // get collection of image-resources of PDF document
            Vintasoft.Imaging.Pdf.Tree.PdfImageResource[] images = document.GetImages();
                
            // print count of image-resource
            System.Console.WriteLine("Images count: {0}", images.Length);
                
            // for each image-resource
            foreach (Vintasoft.Imaging.Pdf.Tree.PdfImageResource image in images)
            {
                // print information about image-resource
                System.Console.WriteLine("\t{0,4}x{1,-4} {2,5}bpp {3}", image.Width, image.Height,
                    image.BitsPerPixel, image.Compression);
            }
        }
    }
                
    /* This code example produces the following output: 
    Images count: 11
      189x41      24bpp Jpeg
      120x50      24bpp Jpeg
      122x56      24bpp Jpeg
      143x41      24bpp Jpeg
      216x21      24bpp Jpeg
      106x49       8bpp Zip
      209x30      24bpp Jpeg
      189x24      24bpp Jpeg
      122x42      24bpp Jpeg
        5x7       24bpp Zip
      817x292     24bpp Jpeg
    */
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also