Class PdfExtractor

معلومات

يمثّل مكوّن Documentize.PdfExtractor. يُستخدم لاستخراج النص، الصور، بيانات النماذج، الخصائص (البيانات التعريفية) من مستندات PDF.

public static class PdfExtractor

Inheritance

objectPdfExtractor

Inherited Members

Methods

Extract(ExtractTextOptions)

استخراج النص من مستند PDF.

public static string Extract(ExtractTextOptions options)

Parameters

  • options ExtractTextOptions: كائن خيارات يحتوي على تعليمات العملية.

Returns

string : النص المستخرج.

Examples

يوضح المثال كيفية استخراج محتوى النص من ملف PDF.

// Create ExtractTextOptions object to set input file path
var options = new ExtractTextOptions("path_to_your_pdf_file.pdf");
// Perform the process and get the extracted text
var textExtracted = PdfExtractor.Extract(options);

يوضح المثال كيفية استخراج محتوى النص من تدفق PDF.

// Create ExtractTextOptions object to set input stream
var stream = File.OpenRead("path_to_your_pdf_file.pdf");
var options = new ExtractTextOptions(stream);
// Perform the process and get the extracted text
var textExtracted = PdfExtractor.Extract(options);

يوضح المثال كيفية استخراج نص مستند PDF مع TextFormattingMode.

// Create ExtractTextOptions object to set input file path and TextFormattingMode
var options = new ExtractTextOptions("path_to_your_pdf_file.pdf", TextFormattingMode.Pure);
// Perform the process and get the extracted text
var textExtracted = PdfExtractor.Extract(options);

يوضح المثال كيفية استخراج النص من ملف PDF بأقصر صيغة ممكنة.

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

Exceptions

ArgumentException

إذا لم تُحدَّد الخيارات.

Extract(ExtractImagesOptions)

استخراج الصور من مستند PDF.

public static ResultContainer Extract(ExtractImagesOptions options)

Parameters

  • options ExtractImagesOptions: كائن خيارات يحتوي على تعليمات العملية.

Returns

ResultContainer : كائن يحتوي على نتيجة العملية.

Examples

يوضح المثال كيفية استخراج الصور من مستند PDF.

// Create ExtractImagesOptions to set instructions
var options = new ExtractImagesOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryData("path_to_results_directory"));
// Perform the process
var results = PdfExtractor.Extract(options);
// Get path to image result
var imageExtracted = results.ResultCollection[0].ToFile();

يوضح المثال كيفية استخراج الصور من مستند PDF إلى تدفقات دون مجلد.

// Create ExtractImagesOptions to set instructions
var options = new ExtractImagesOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Not set output - it will write results to streams
// Perform the process
var results = PdfExtractor.Extract(options);
// Get Stream
var ms = results.ResultCollection[0].ToStream();
// Copy data to file for demo
ms.Seek(0, SeekOrigin.Begin);
using (var fs = File.Create("test_file.png"))
{
    ms.CopyTo(fs);
}

Exceptions

ArgumentException

إذا لم تُحدَّد الخيارات.

Extract(ExtractFormDataToDsvOptions)

استخراج بيانات النموذج من مستند PDF.

public static ResultContainer Extract(ExtractFormDataToDsvOptions options)

Parameters

Returns

ResultContainer : كائن يحتوي على نتيجة العملية.

Examples

يوضح المثال كيفية تصدير قيم النموذج إلى ملف CSV.

// Create ExtractFormDataToDsvOptions object to set instructions
var options = new ExtractFormDataToDsvOptions(',', true);
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_csv_file.csv"));
// Perform the process
PdfExtractor.Extract(options);

يوضح المثال كيفية تصدير قيم النموذج إلى ملف TSV وتعيين الخصائص.

// Create ExtractFormDataToDsvOptions object to set instructions
var options = new ExtractFormDataToDsvOptions();
//Set Delimiter
options.Delimiter = '\t';
//Add Field Names to result
options.AddFieldName = true;
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_csv_file.tsv"));
// Perform the process
PdfExtractor.Extract(options);

Exceptions

ArgumentException

إذا لم تُحدَّد الخيارات.

Extract(ExtractPropertiesOptions)

استخراج الخصائص من مستند PDF.

public static PdfProperties Extract(ExtractPropertiesOptions options)

Parameters

Returns

PdfProperties : كائن يحتوي على نتيجة العملية.

Examples

يوضح المثال كيفية استخراج الخصائص (اسم الملف، العنوان، المؤلف، الموضوع، الكلمات المفتاحية، تاريخ الإنشاء، تاريخ التعديل، التطبيق، منتج PDF، عدد الصفحات) من ملف PDF.

// Create ExtractPropertiesOptions object to set input file
var options = new ExtractPropertiesOptions("path_to_your_pdf_file.pdf");
// Perform the process and get Properties
var pdfProperties = PdfExtractor.Extract(options);
var filename = pdfProperties.FileName;
var title = pdfProperties.Title;
var author = pdfProperties.Author;
var subject = pdfProperties.Subject;
var keywords = pdfProperties.Keywords;
var created = pdfProperties.Created;
var modified = pdfProperties.Modified;
var application = pdfProperties.Application;
var pdfProducer = pdfProperties.PdfProducer;
var numberOfPages = pdfProperties.NumberOfPages;

يوضح المثال كيفية استخراج الخصائص (العنوان، المؤلف، الموضوع، الكلمات المفتاحية، تاريخ الإنشاء، تاريخ التعديل، التطبيق، منتج PDF، عدد الصفحات) من تدفق PDF.

// Create ExtractPropertiesOptions object to set input stream
var stream = File.OpenRead("path_to_your_pdf_file.pdf");
var options = new ExtractPropertiesOptions(stream);
// Perform the process and get Properties
var pdfProperties = PdfExtractor.Extract(options);
var title = pdfProperties.Title;
var author = pdfProperties.Author;
var subject = pdfProperties.Subject;
var keywords = pdfProperties.Keywords;
var created = pdfProperties.Created;
var modified = pdfProperties.Modified;
var application = pdfProperties.Application;
var pdfProducer = pdfProperties.PdfProducer;
var numberOfPages = pdfProperties.NumberOfPages;

يوضح المثال كيفية استخراج الخصائص من ملف PDF بأقصر صيغة ممكنة.

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

Exceptions

ArgumentException

إذا لم تُحدَّد الخيارات.

Namespace: Documentize Assembly: Documentize.dll

 عربي