Accusoft.PdfXpress5.Net
Extract Images
Send Feedback
PDF Xpress 5 for .NET - User Guide > How To > Extract Images

Glossary Item Box

PDF Xpress™ supports extracting images from a PDF Page.

The following is an example in which a PDF document is opened and an image on each page is then accessed. You can then save to disk, pass the image data to ImagXpress for compression, etc.

C# Copy Code
using Accusoft.PdfXpressSdk;
using System.Drawing;
namespace ExtractImages
{
    class Program
    {
        static void Main(string[] args)
        {
            using (PdfXpress pdf = new PdfXpress())
            {
                pdf.Initialize();
                using (Document doc = new Document(pdf, "document.pdf"))
                {
                    ExtractImageOptions extractOptions = new ExtractImageOptions();
                    for (int pageNumber = 0; pageNumber < doc.PageCount; pageNumber++)
                    {
                        int imageCount = doc.ExtractImages(pageNumber, extractOptions);
                        for (int imageIndex = 0; imageIndex < imageCount; imageIndex++)
                        {
                            PdfImage image = doc.GetExtractedImage(pageNumber, imageIndex);
                            using (Bitmap bp = image.GetBitmap())
                            {
                                //work with the image data here, e.g., save to disk…                           
                            }
                        }
                    }
                }
            }
        }
    }
}
©2012. Accusoft Corporation. All Rights Reserved.