This sample shows how to extract images from PdfDocument.

Use PdfImage.Save method to save image from PDF document to a stream or a file.

When saving to a file, you should specify an output file name without extension. PdfImage.Save adds extension based on the image data, saves image and returns full output path.

When saving to a stream, PdfImage.Save method returns format of the image data saved to a stream.

C#
using System.Diagnostics;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class ExtractImages
    {
        public static void Main()
        {
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            using (PdfDocument pdf = new PdfDocument(@"Sample Data\gmail-cheat-sheet.pdf"))
            {
                foreach (PdfImage image in pdf.GetImages())
                {
                    string imageFile = image.Save("ExtractedImage");
                    Process.Start(imageFile);

                    // Only extract first image in this sample
                    break;
                }
            }
        }
    }
}
VB
Imports System.Diagnostics

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class ExtractImages
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.

            Using pdf As New PdfDocument("Sample Data\gmail-cheat-sheet.pdf")
                For Each image As PdfImage In pdf.GetImages()
                    Dim imageFile As String = image.Save("ExtractedImage")
                    Process.Start(imageFile)

                    ' Only extract first image in this sample
                    Exit For
                Next
            End Using
        End Sub
    End Class
End Namespace