PDF Extractor

Trích xuất Văn bản

Trích xuất văn bản từ các tệp 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ừ PDF một cách chính xác với Documentize sử dụ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

Trích xuất Văn bản

The Documentize PDF Extractor for .NET đơn giản hóa việc trích xuất văn bản từ tài liệu PDF. Dù bạn cần văn bản thuần, thô, hay không định dạng, plugin này cho phép bạn trích xuất văn bản một cách hiệu quả đồng thời bảo tồn hoặc loại bỏ định dạng tùy theo nhu cầu.

Cách trích xuất văn bản từ PDF

Để trích xuất văn bản từ một tài liệu PDF, thực hiện các bước sau:

  1. Tạo một thể hiện của ExtractTextOptions để cấu hình các tùy chọn trích xuất.
  2. Thêm tệp PDF đầu vào bằng phương thức AddInput.
  3. Gọi phương thức Extract để thực hiện quá trình trích xuất.
  4. Truy cập văn bản đã trích xuất thông qua 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.Extract(options);
7// Get the extracted text from the ResultContainer object
8var textExtracted = results.ResultCollection[0].ToString();

Các chế độ trích xuất văn bản

ExtractTextOptions cung cấp ba chế độ trích xuất, mang lại sự linh hoạt tùy theo nhu cầu của bạn.

  1. Pure Mode: Giữ nguyên định dạng gốc, bao gồm khoảng trắng và căn chỉnh.
  2. Raw Mode: Trích xuất văn bản mà không có định dạng, hữu ích cho việc xử lý dữ liệu thô.
  3. Flatten Mode: Đại diện nội dung PDF bằng các đoạn văn bản được định vị theo tọa độ.
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.Extract(options);
7// Get the extracted text from the ResultContainer object
8var textExtracted = results.ResultCollection[0].ToString();

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

  • Pure Mode: Trích xuất văn bản đồng thời bảo tồn định dạng gốc của nó.
  • Raw Mode: Trích xuất văn bản mà không có bất kỳ định dạng nào.
  • Flatten Mode: Trích xuất văn bản mà không có ký tự đặc biệt hoặc định dạng.

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 giúp việc trích xuất Siêu dữ liệu từ các tài liệu PDF trở nên đơn giản. Các thuộc tính có sẵn mà bạn có thể quan tâm: Tiêu đề, Tác giả, Chủ đề, Từ khóa, Số trang.

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

Ví dụ dưới đây minh họa cách Trích xuất Thuộc tính (Tiêu đề, Tác giả, Chủ đề, Từ khóa, Số trang) từ tệp PDF. Để trích xuất siêu dữ liệu từ một tài liệu PDF, thực hiện các bước sau:

  1. Tạo một thể hiện của ExtractPropertiesOptions để cấu hình các tùy chọn trích xuất và tệp PDF đầu vào.
  2. Gọi phương thức Extract của PdfExtractor để trích xuất siêu dữ liệu.
  3. Truy cập các thuộc tính đã trích xuất thông qua 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 title = pdfProperties.Title;
6var author = pdfProperties.Author;
7var subject = pdfProperties.Subject;
8var keywords = pdfProperties.Keywords;
9var numberOfPages = pdfProperties.NumberOfPages;

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

Bạn có thể mở luồng tùy ý.

 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 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"));

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

  • Siêu dữ liệu có sẵn: Tiêu đề, Tác giả, Chủ đề, Từ khóa, Số trang.

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