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.
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.
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.
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.
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.
also available as: