Related Article(s):
Last active
December 20, 2022 11:36
-
-
Save GroupDocsGists/29261ce2d647088e60fc3c35eadf1087 to your computer and use it in GitHub Desktop.
Extract Images from PDF using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extract images | |
IEnumerable<PageImageArea> images = parser.GetImages(); | |
// Check if images extraction is supported | |
if (images == null) | |
{ | |
Console.WriteLine("Images extraction isn't supported"); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an instance of Parser class | |
using (Parser parser = new Parser("path/document.pdf")) | |
{ | |
// your code goes here. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using GroupDocs.Parser.Data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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