Accusoft.PdfXpress7.Net
Extract Images

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# Example
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…                          
                            }
                        }
                    }
                }
            }
        }
    }
}

 

 


©2018. Accusoft Corporation. All Rights Reserved.

Send Feedback