Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active December 20, 2022 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/29261ce2d647088e60fc3c35eadf1087 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/29261ce2d647088e60fc3c35eadf1087 to your computer and use it in GitHub Desktop.
Extract Images from PDF using C#
// Extract images
IEnumerable<PageImageArea> images = parser.GetImages();
// Check if images extraction is supported
if (images == null)
{
Console.WriteLine("Images extraction isn't supported");
return;
}
// Extract images from PDF using C#
using (Parser parser = new Parser("path/document.pdf"))
{
IEnumerable<PageImageArea> images = parser.GetImages();
// Check if image extraction is supported
if (images == null)
{
Console.WriteLine("Images extraction isn't supported");
return;
}
ImageOptions options = new ImageOptions(ImageFormat.Jpeg);
int imageNumber = 0;
// Iterate over retrieved images
foreach (PageImageArea image in images)
{
// Save Images
image.Save("imageFilePath/image-" + imageNumber.ToString() + ".jpeg", options);
imageNumber++;
}
}
// Create an instance of Parser class
using (Parser parser = new Parser("path/document.pdf"))
{
// your code goes here.
}
using System;
using System.Collections.Generic;
using System.Text;
using GroupDocs.Parser.Data;
// Iterate over retrieved images
foreach (PageImageArea image in images)
{
// Save Images
image.Save("imageFilePath/image-" + imageNumber.ToString() + ".jpeg", new ImageOptions(ImageFormat.Jpeg));
imageNumber++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment