PDF Extractor

Extract Text

Trích xuất văn bản từ tài liệu PDF một cách chính xác với các công cụ .NET của Documentize — lấy, xử lý và phân tích nội dung một cách dễ dàng.

Trích xuất Hình ảnh

Dễ dàng trích xuất hình ảnh từ tài liệu PDF trong các ứng dụng .NET

Trích xuất thuộc tính / Siêu dữ liệu

Trích xuất siêu dữ liệu từ các tệp PDF một cách chính xác với Documentize bằng C#/.NET

Xuất Dữ liệu Biểu mẫu

Trích xuất và xuất dữ liệu từ biểu mẫu PDF (AcroForms) sang các định dạng khác như CSV bằng C#/.NET

Tiểu mục của 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 file

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

  1. Create an instance of ExtractTextOptions to configure input file path.
  2. Run the Extract method to extract the text.
1```csharp
2// Create ExtractTextOptions object to set input file path
3var options = new ExtractTextOptions("path_to_your_pdf_file.pdf");
4// Perform the process and get the extracted text
5var textExtracted = PdfExtractor.Extract(options);
6```

How to Extract Text from PDF stream

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

  1. Create an instance of ExtractTextOptions to configure input stream.
  2. Run the Extract method to extract the text.
1```csharp
2// Create ExtractTextOptions object to set input stream
3var stream = File.OpenRead("path_to_your_pdf_file.pdf");
4var options = new ExtractTextOptions(stream);
5// Perform the process and get the extracted text
6var textExtracted = PdfExtractor.Extract(options);
7```

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```csharp
2// Create ExtractTextOptions object to set input file path and TextFormattingMode
3var options = new ExtractTextOptions("path_to_your_pdf_file.pdf", TextFormattingMode.Pure);
4// Perform the process and get the extracted text
5var textExtracted = PdfExtractor.Extract(options);
6```

How to Extract Text from PDF file in the shortest possible style

1```csharp
2// Perform the process and get the extracted text
3var textExtracted = PdfExtractor.Extract(new ExtractTextOptions("path_to_your_pdf_file.pdf", TextFormattingMode.Pure));
4```

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.

Trích xuất Hình ảnh

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.

Cách trích xuất hình ảnh từ PDF

Để trích xuất hình ảnh từ một tệp PDF, làm theo các bước sau:

  1. Tạo một thể hiện của lớp ExtractImagesOptions.
  2. Thêm đường dẫn tệp đầu vào vào tùy chọn bằng phương thức AddInput.
  3. Đặt đường dẫn thư mục đầu ra cho các hình ảnh bằng phương thức AddOutput.
  4. Xử lý việc trích xuất hình ảnh bằng plugin.
  5. Lấy các hình ảnh đã trích xuất từ container kết quả.
 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.Extract(options);
 9// Get path to image result
10var imageExtracted = results.ResultCollection[0].ToFile();

Trích xuất hình ảnh từ tệp PDF sang Stream mà không cần thư mục

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.Extract(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}

Các tính năng chính:

  • 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.

Trích xuất thuộc tính / Siêu dữ liệu

The Documentize PDF Extractor for .NET simplifies extracting Metadata from PDF documents. Available properties that may interest you: FileName, Title, Author, Subject, Keywords, Created, Modified, Application, PDF Producer, Number of Pages.

Cách trích xuất siêu dữ liệu từ tệp PDF

The example demonstrates how to Extract Properties (Title, Author, Subject, Keywords, Number of Pages) from PDF file. To extract metadata from a PDF document, follow these steps:

  1. Create an instance of ExtractPropertiesOptions to configure the extraction options and input PDF file.
  2. Run the Extract method of PdfExtractor to extract the metadata.
  3. Access the extracted properties using the PdfProperties.
 1// Create ExtractPropertiesOptions object to set input file
 2var options = new ExtractPropertiesOptions("path_to_your_pdf_file.pdf");
 3// Perform the process and get Properties
 4var pdfProperties = PdfExtractor.Extract(options);
 5var filename = pdfProperties.FileName;
 6var title = pdfProperties.Title;
 7var author = pdfProperties.Author;
 8var subject = pdfProperties.Subject;
 9var keywords = pdfProperties.Keywords;
10var created = pdfProperties.Created;
11var modified = pdfProperties.Modified;
12var application = pdfProperties.Application;
13var pdfProducer = pdfProperties.PdfProducer;
14var numberOfPages = pdfProperties.NumberOfPages;

Cách trích xuất siêu dữ liệu từ luồng PDF

You can open the stream at your own discretion.

 1// Create ExtractPropertiesOptions object to set input stream
 2var stream = File.OpenRead("path_to_your_pdf_file.pdf");
 3var options = new ExtractPropertiesOptions(stream);
 4// Perform the process and get Properties
 5var pdfProperties = PdfExtractor.Extract(options);
 6var title = pdfProperties.Title;
 7var author = pdfProperties.Author;
 8var subject = pdfProperties.Subject;
 9var keywords = pdfProperties.Keywords;
10var created = pdfProperties.Created;
11var modified = pdfProperties.Modified;
12var application = pdfProperties.Application;
13var pdfProducer = pdfProperties.PdfProducer;
14var numberOfPages = pdfProperties.NumberOfPages;

Cách trích xuất siêu dữ liệu từ tệp PDF theo phong cách ngắn gọn nhất

1// Perform the process and get Properties
2var pdfProperties = PdfExtractor.Extract(new ExtractPropertiesOptions("path_to_your_pdf_file.pdf"));

Tính năng chính:

  • Siêu dữ liệu khả dụng: FileName, Title, Author, Subject, Keywords, Created, Modified, Application, PDF Producer, Number of Pages.

Xuất Dữ liệu Biểu mẫu

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.

Cách Xuất Dữ liệu Biểu mẫu từ PDF

Để xuất dữ liệu biểu mẫu từ PDF sang CSV, thực hiện các bước sau:

  1. Tạo một thể hiện của lớp ExtractImagesOptions.
  2. Định nghĩa các tùy chọn xuất bằng lớp FormExporterValuesToCsvOptions.
  3. Thêm các tệp PDF đầu vào và chỉ định tệp CSV đầu ra.
  4. Chạy phương thức Extract để thực hiện việc xuất.
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.Extract(options);

Các tính năng chính:

  • 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.
 Tiếng Việt