PDF Image Extractor
The Documentize PDF Image Extractor for .NET plugin enables you to effortlessly extract images from PDF documents. It scans your PDF files, identifies embedded images, and extracts them while maintaining their original quality and format. This tool enhances the accessibility of visual content and streamlines the process of retrieving images from PDFs.
How to Extract Images from a PDF
To extract images from a PDF file, follow these steps:
- Create an instance of the
ImageExtractorOptions
class. - Add the input file path to the options using the
AddInput
method. - Set the output Directory path for images using the
AddOutput
method. - Process the image extraction using the plugin.
- Retrieve the extracted images from the result container.
1// Create ImageExtractorOptions to set instructions
2var options = new ImageExtractorOptions();
3// Add input file path
4options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
5// Set output Directory path
6options.AddOutput(new DirectoryDataSource("path_to_results_directory"));
7// Perform the process
8var results = ImageExtractor.Process(options);
9// Get path to image result
10var imageExtracted = results.ResultCollection[0].ToFile();
Extracting Images from PDF File to Streams without folder
The ImageExtractor plugin supports saving to streams, which allows you to extract images from PDF files into streams without using temporary folders.
1// Create ImageExtractorOptions to set instructions
2var options = new ImageExtractorOptions();
3// Add input file path
4options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
5// Not set output - it will write results to streams
6// Perform the process
7var results = ImageExtractor.Process(options);
8// Get Stream
9var ms = results.ResultCollection[0].ToStream();
10// Copy data to file for demo
11ms.Seek(0, SeekOrigin.Begin);
12using (var fs = File.Create("test_file.png"))
13{
14 ms.CopyTo(fs);
15}
Key Features:
- Extract Embedded Images: Identify and extract images from PDF documents.
- Preserve Image Quality: Ensures extracted images retain their original quality.
- Flexible Output: Save extracted images in your preferred format or location.