PDF Extractor SDK Explained: Extract Images from PDF - ByteScout

PDF Extractor SDK Explained: Extract Images from PDF

  • Home
  • /
  • Articles
  • /
  • PDF Extractor SDK Explained: Extract Images from PDF

In this program, we’re going to see how we can extract images from the PDF. We are having some images in this PDF. Let’s use this as our sample document. I’m going to include it in the Solution Explorer Window. Right-click then copy and paste it here.

START YOUR FREE TRIAL HERE

How to Extract Images from PDF

We’re going to create an instance of the image extractor class. We are going to load the document, then get the images and we have to keep on iterating to reach all the images. We will just save the current image to the file. Here, using (ImageExtractor extractor = new ImageExtractor(“demo”, “demo”)) also gives the registration keys and name.

Extract Images from PDF

Let’s load the document which is like extractor.LoadDocumentFromFile(“sample_program2.pdf”). Then write if(extractor.GetFirstImage()). Basically, it will confirm like it is having images or not then we have to keep on going until we fetch and reach the end of the images.

Extract Images from PDF Files

At this moment, we are just saving image by creating extractor.SaveCurrentImageToFile(“result”). We have one variable which is var resultFile = $”result_{counter++}.png”; and we also have one counter result int counter = 1.

How to Extract Images from PDF

It’s all fine. Let’s run it and see what we have in the bin folder. If we open the PDF, we are having the three images and it generated three separated results.

Extract Images with PDF Extractor SDK

Tutorials:

prev
next