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



In This Topic
    GetImages Method (PdfPage)
    In This Topic
    Returns a read-only collection that contains image-resources of this page.
    Syntax
    'Declaration
     
    Public Function GetImages() As PdfImageResource()
    public PdfImageResource[] GetImages()
    public: PdfImageResource*[]* GetImages(); 
    public:
    array<PdfImageResource^>^ GetImages(); 

    Return Value

    The read-only collection that contains image-resources of this page.
    Example
    This example shows how to obtain an information about image resources of all PDF pages.
    ''' <summary>
    ''' Gets and prints information about PDF image resources.
    ''' </summary>
    ''' <param name="pdfFileName">The filename of PDF document.</param>
    Public Shared Sub GetImageResourcesInfo(pdfFileName As String)
        ' open PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFileName)
            ' for each PDF page
            For pageIndex As Integer = 0 To document.Pages.Count - 1
                ' get PDF page
                Dim page As Vintasoft.Imaging.Pdf.Tree.PdfPage = document.Pages(pageIndex)
                ' get a collection of PDF image resources of page
                Dim imageResources As Vintasoft.Imaging.Pdf.Tree.PdfImageResource() = page.GetImages()
                ' print the page index and count of image resources
                System.Console.WriteLine("Page {0} Image resources count: {1}", pageIndex + 1, imageResources.Length)
                ' for each image resource
                For Each imageResource As Vintasoft.Imaging.Pdf.Tree.PdfImageResource In imageResources
                    ' print information about image resource
                    System.Console.WriteLine(vbTab & " {0}x{1} {2,5}bpp {3}", imageResource.Width, imageResource.Height, imageResource.BitsPerPixel, imageResource.Compression)
                Next
            Next
        End Using
    End Sub
                
    ' This code example produces the following output: 
      
      Page 1 Image resources count: 9
           157x139    32bpp Zip
           157x139     8bpp Jpeg
           700x596    24bpp Jpeg
           686x585    24bpp Jpeg
           459x317    32bpp Jpeg
           459x317     8bpp Zip, Predictor
           484x487    32bpp Jpeg
           484x487     8bpp Zip, Predictor
           824x537    24bpp Zip
      Page 2 Image resources count: 0
    /// <summary>
    /// Gets and prints information about PDF image resources.
    /// </summary>
    /// <param name="pdfFileName">The filename of PDF document.</param>
    public static void GetImageResourcesInfo(string pdfFileName)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(pdfFileName))
        {
            // for each PDF page
            for (int pageIndex = 0; pageIndex < document.Pages.Count; pageIndex++)
            {
                // get PDF page
                Vintasoft.Imaging.Pdf.Tree.PdfPage page = document.Pages[pageIndex];
                // get a collection of PDF image resources of page
                Vintasoft.Imaging.Pdf.Tree.PdfImageResource[] imageResources = page.GetImages();
                // print the page index and count of image resources
                System.Console.WriteLine("Page {0} Image resources count: {1}", pageIndex + 1, imageResources.Length);
                // for each image resource
                foreach (Vintasoft.Imaging.Pdf.Tree.PdfImageResource imageResource in imageResources)
                {
                    // print information about image resource
                    System.Console.WriteLine("\t {0}x{1} {2,5}bpp {3}",
                        imageResource.Width, imageResource.Height,
                        imageResource.BitsPerPixel, imageResource.Compression);
                }
            }
        }
    }
                
    /* This code example produces the following output: 
                
    Page 1 Image resources count: 9
         157x139    32bpp Zip
         157x139     8bpp Jpeg
         700x596    24bpp Jpeg
         686x585    24bpp Jpeg
         459x317    32bpp Jpeg
         459x317     8bpp Zip, Predictor
         484x487    32bpp Jpeg
         484x487     8bpp Zip, Predictor
         824x537    24bpp Zip
    Page 2 Image resources count: 0         
    */
    Requirements

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

    See Also