Get Images out of a PDF File. Extract Images from PDF Files to TIFF, JPEG, PNG.

PDF files are great for saving and exchanging formatted files across all platforms and the internet. But sometimes we need to extract image from PDF file and use it in other place, such as Web pages, word processing documents, PowerPoint presentations.

.NET PDF extractor can extract all embedded images(JPG, BMP, TIFF, PNG and GIF) in PDF file and save them to image files. Image format and resolution will be kept.

Using .NET PDF image extraction library, developers can easily and quickly capture high quality image from an entire document, individual pages or specific images.


// Open the pdf file
using (PdfDocument document = PdfReader.Open("file1.pdf", PdfDocumentOpenMode.Import))
{
    int pageIndex = 0;

    // Get all the pdf pages
    foreach (PdfPage page in document.Pages)
    {
        int imageIndex = 0;

        // Find all the images in the pdf page
        foreach (Image image in page.GetImages())
        {
            // Capture each image in the page, you can save it as jpg, png, tiff, bmp and gif.
            // Here is saved as png format, transparent png is also supported.
            image.Save(String.Format(@"{0}-{1}.png", pageIndex + 1, imageIndex + 1), ImageFormat.Png);
            imageIndex++;                       
        }
        pageIndex++;
    }
}

Currently only RGB encoded images (/DeviceRGB) are supported with either (/DCTDecode) or (/FlatEncode) encoding. Image encoded with CCITTFaxDecode filter (TIFF) is supported. (/Indexed) colorspaces are also supported for (/FlatEncode) images including black & white 1bpp images.

More PDF tutorial