Export images from PDF files in C# and VB.NET

GemBox.Pdf supports exporting images from the PDF file in JPEG, BMP, PNG or TIFF image formats.

The following example demonstrates how to export single image from the PDF file.

Screenshot of image exported with GemBox.Pdf
Image exported with GemBox.Pdf
Upload your file (Drag file here)
using GemBox.Pdf;
using GemBox.Pdf.Content;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        using (var document = PdfDocument.Load("%InputFileName%"))
            // Iterate through PDF pages and through each page's content elements.
            foreach (var page in document.Pages)
                foreach (var contentElement in page.Content.Elements.All())
                    if (contentElement.ElementType == PdfContentElementType.Image)
                    {
                        // Export an image content element to selected image format.
                        var imageContent = (PdfImageContent)contentElement;
                        imageContent.Save("ExportImages.%OutputFileType%");
                        return;
                    }
    }
}
Imports GemBox.Pdf
Imports GemBox.Pdf.Content

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Using document = PdfDocument.Load("%InputFileName%")
            ' Iterate through PDF pages and through each page's content elements.
            For Each page In document.Pages
                For Each contentElement In page.Content.Elements.All()
                    If contentElement.ElementType = PdfContentElementType.Image Then
                        ' Export an image content element to selected image format.
                        Dim imageContent = CType(contentElement, PdfImageContent)
                        imageContent.Save("ExportImages.%OutputFileType%")
                        Return
                    End If
                Next
            Next
        End Using

    End Sub
End Module

Check next example or download examples from GitHub.