PDF Extractor

Extract Text

Extract text from PDFs accurately with Documentize's .NET tools—retrieve, process, and analyze content effortlessly.

Extract Images

Effortlessly extract images from PDF documents from within .NET applications

Export Form Data

Extract and export data from PDF forms (AcroForms) into other formats like CSV using C# .NET

Subsections of PDF Extractor

Extract Text

The Documentize PDF Extractor for .NET simplifies extracting text from PDF documents. Whether you need pure, raw, or plain text, this plugin allows you to extract text efficiently while preserving formatting or omitting it based on your needs.

How to Extract Text from PDF

To extract text from a PDF document, follow these steps:

  1. Create an instance of ExtractTextOptions to configure the extraction options.
  2. Add the input PDF file using the AddInput method.
  3. Run the ExtractText method to extract the text.
  4. Access the extracted text using the ResultContainer.ResultCollection.
1// Create ExtractTextOptions object to set instructions
2var options = new ExtractTextOptions();
3// Add input file path
4options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
5// Perform the process
6var results = PdfExtractor.ExtractText(options);
7// Get the extracted text from the ResultContainer object
8var textExtracted = results.ResultCollection[0].ToString();

Text Extraction Modes

The ExtractTextOptions offers three extraction modes, providing flexibility based on your needs.

  1. Pure Mode: Preserves the original formatting, including spaces and alignment.
  2. Raw Mode: Extracts the text without formatting, useful for raw data processing.
  3. Flatten Mode: Represent PDF content with positioning text fragments by their coordinates.
1// Create ExtractTextOptions object to set TextFormattingMode
2var options = new ExtractTextOptions(TextFormattingMode.Pure);
3// Add input file path
4options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
5// Perform the process
6var results = PdfExtractor.ExtractText(options);
7// Get the extracted text from the ResultContainer object
8var textExtracted = results.ResultCollection[0].ToString();

Key Features:

  • Pure Mode: Extract text while preserving its original formatting.
  • Raw Mode: Extract text without any formatting.
  • Flatten Mode: Extract text without special characters or formatting.

Extract Images

The Documentize PDF 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:

  1. Create an instance of the ExtractImagesOptions class.
  2. Add the input file path to the options using the AddInput method.
  3. Set the output Directory path for images using the AddOutput method.
  4. Process the image extraction using the plugin.
  5. Retrieve the extracted images from the result container.
 1// Create ExtractImagesOptions to set instructions
 2var options = new ExtractImagesOptions();
 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 = PdfExtractor.ExtractImages(options);
 9// Get path to image result
10var imageExtracted = results.ResultCollection[0].ToFile();

Extracting Images from PDF File to Streams without folder

The PdfExtractor plugin supports saving to streams, which allows you to extract images from PDF files into streams without using temporary folders.

 1// Create ExtractImagesOptions to set instructions
 2var options = new ExtractImagesOptions();
 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 = PdfExtractor.ExtractImages(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.

Export Form Data

The Documentize PDF Extractor for .NET plugin provides a seamless way to extract and export data from PDF forms (AcroForms) into other formats like CSV. This dynamic tool simplifies the process of retrieving form field values, allowing for easy data management, transfer, and analysis.

How to Export Form Data from PDF

To export form data from a PDF to CSV, follow these steps:

  1. Create an instance of the ExtractImagesOptions class.
  2. Define export options using the FormExporterValuesToCsvOptions class.
  3. Add input PDF files and specify the output CSV file.
  4. Run the Process method to perform the export.
1// Create ExtractFormDataToDsvOptions object to set instructions
2var options = new ExtractFormDataToDsvOptions(',', true);
3// Add input file path
4options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
5// Set output file path
6options.AddOutput(new FileDataSource("path_to_result_csv_file.csv"));
7// Perform the process
8PdfExtractor.ExtractFormData(options);

Key Features:

  • Export Form Data: Extract data from PDF forms (AcroForms) into CSV or other formats.
  • Data Filtering: Use predicates to filter specific form fields for export based on criteria like field type or page number.
  • Flexible Output: Save exported data for analysis or transfer to spreadsheets, databases, or other document formats.