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 shows how you can export single image from the PDF file.

Image exported with GemBox.Pdf
Screenshot of 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

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Pdf yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.