v25.10
المكوّن الإضافي الجديد PDF Extractor
- Class PdfExtractor: يحتوي على جميع وظائف الإضافات: TextExtractor، ImageExtractor، FormExporter.
- Class TextExtractor: سيتم حذفه قريبًا، استخدم PdfExtractor.
- Class ImageExtractor: سيتم حذفه قريبًا، استخدم PdfExtractor.
- Class FormExporter: سيتم حذفه قريبًا، استخدم PdfExtractor.
- Class TextExtractorOptions: أعيد تسميتها إلى Class ExtractTextOptions.
- Class ImageExtractorOptions: أعيد تسميتها إلى Class ExtractImagesOptions.
- Class FormExportToDsvOptions: أعيد تسميتها إلى Class ExtractFormDataToDsvOptions.
- راجع The New Plugin Architecture.
مثال على الاستخدام:
يوضح المثال كيفية استخراج محتوى النص من مستند PDF.
// Create ExtractTextOptions object to set instructions
var options = new ExtractTextOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Perform the process
var results = PdfExtractor.ExtractText(options);
// Get the extracted text from the ResultContainer object
var textExtracted = results.ResultCollection[0].ToString();مثال على الاستخدام:
يوضح المثال كيفية استخراج محتوى النص من مستند PDF مع TextFormattingMode.
// Create ExtractTextOptions object to set TextFormattingMode
var options = new ExtractTextOptions(TextFormattingMode.Pure);
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Perform the process
var results = PdfExtractor.ExtractText(options);
// Get the extracted text from the ResultContainer object
var textExtracted = results.ResultCollection[0].ToString();مثال على الاستخدام:
يوضح المثال كيفية استخراج الصور من مستند PDF.
// Create ExtractImagesOptions to set instructions
var options = new ExtractImagesOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryDataSource("path_to_results_directory"));
// Perform the process
var results = PdfExtractor.ExtractImages(options);
// Get path to image result
var imageExtracted = results.ResultCollection[0].ToFile();مثال على الاستخدام:
يوضح المثال كيفية تصدير قيم النموذج إلى ملف CSV.
// Create ExtractFormDataToDsvOptions object to set instructions
var options = new ExtractFormDataToDsvOptions(',', true);
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_csv_file.csv"));
// Perform the process
PdfExtractor.ExtractFormData(options);المكوّن الإضافي الجديد PDF Manager
- Class PdfManager: يحتوي على جميع وظائف الإضافات: Merger، Optimizer، Splitter، TableGenerator، TocGenerator.
- Class Merger: سيتم حذفه قريبًا.
- Class Optimizer: سيتم حذفه قريبًا، استخدم PdfManager.
- Class Splitter: سيتم حذفه قريبًا، استخدم PdfManager.
- Class TableGenerator: سيتم حذفه قريبًا، استخدم PdfManager.
- Class TocGenerator: سيتم حذفه قريبًا، استخدم PdfManager.
- راجع The New Plugin Architecture.
مثال على الاستخدام:
يوضح المثال كيفية دمج مستندين PDF.
// Create MergeOptions object to set instructions
var options = new MergeOptions();
// Add input file paths
options.AddInput(new FileDataSource("path_to_your_pdf_file_1.pdf"));
options.AddInput(new FileDataSource("path_to_your_pdf_file_2.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Merge(options);مثال على الاستخدام:
يوضح المثال كيفية تقسيم مستند PDF.
// Create SplitOptions object to set instructions
var options = new SplitOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file paths
options.AddOutput(new FileDataSource("path_to_result_pdf_file_1.pdf"));
options.AddOutput(new FileDataSource("path_to_result_pdf_file_2.pdf"));
// Perform the process
PdfManager.Split(options);مثال على الاستخدام:
يوضح المثال كيفية تحسين مستند PDF.
// Create OptimizeOptions object to set instructions
var options = new OptimizeOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Optimize(options);مثال على الاستخدام:
يوضح المثال كيفية تدوير مستند PDF.
// Create RotateOptions object to set instructions
var options = new RotateOptions();
// Set new Rotation
options.Rotation = Rotation.On90;
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Rotate(options);مثال على الاستخدام:
يوضح المثال كيفية تغيير حجم مستند PDF.
// Create ResizeOptions object to set instructions
var options = new ResizeOptions();
// Set new PageSize
options.PageSize = PageSize.A3;
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Resize(options);مثال على الاستخدام:
يوضح المثال كيفية ضغط مستند PDF.
// Create CompressOptions object to set instructions
var options = new CompressOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Compress(options);مثال على الاستخدام:
يوضح المثال كيفية إضافة جدول إلى ملف PDF.
// Configure table options
var options = new TableOptions();
options.InsertPageBefore(1)
.AddTable()
.AddRow()
.AddCell().AddParagraph("Name")
.AddCell().AddParagraph("Age")
.AddRow()
.AddCell().AddParagraph("Bob")
.AddCell().AddParagraph("12")
.AddRow()
.AddCell().AddParagraph("Sam")
.AddCell().AddParagraph("20")
.AddRow()
.AddCell().AddParagraph("Sandy")
.AddCell().AddParagraph("26")
.AddRow()
.AddCell().AddParagraph("Tom")
.AddCell().AddParagraph("12")
.AddRow()
.AddCell().AddParagraph("Jim")
.AddCell().AddParagraph("27");
// Add input file path
options.AddInput(new FileDataSource("path_to_input.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_output.pdf"));
// Perform the process
PdfManager.AddTable(options);مثال على الاستخدام:
يوضح المثال كيفية إضافة فهرس (Table of Contents) إلى ملف PDF.
// Create TocOptions object to set instructions
var options = new TocOptions();
// Set the Title
options.Title = "My Table of Contents";
// Design Headings
options.Headings.Add(new TocHeading("Introduction", 2));
options.Headings.Add(new TocHeading("Chapter I", 3));
options.Headings.Add(new TocHeading("Chapter II", 4));
options.Headings.Add(new TocHeading("Chapter III", 5));
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.AddTableOfContents(options);مثال على الاستخدام:
يوضح المثال كيفية إضافة فهرس إلى ملف PDF مع إنشاء إشارات مرجعية (bookmarks).
// Create TocOptions object to set instructions
var options = new TocOptions();
// Set the Title
options.Title = "My Table of Contents";
// Generate links in bookmarks
options.GenerateBookmarks = true;
// Design Headings
options.Headings.Add(new TocHeading("Introduction", 2, false, 1));
options.Headings.Add(new TocHeading("Chapter I", 3, true, 1));
options.Headings.Add(new TicHeading("Chapter II", 4, true, 1));
options.Headings.Add(new TocHeading("Example A", 4, true, 2));
options.Headings.Add(new TocHeading("Example B", 4, true, 2));
options.Headings.Add(new TocHeading("Example C", 4, true, 2));
options.Headings.Add(new TocHeading("Example D", 4, true, 2));
options.Headings.Add(new TocHeading("Chapter III", 5, true, 1));
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.AddTableOfContents(options);مثال على الاستخدام:
يوضح المثال كيفية إضافة فهرس إلى ملف PDF وحفظه كتيار (stream).
// Create TocOptions object to set instructions
var options = new TocOptions();
// Set the Title
options.Title = "My Table of Contents";
// Design Headings
options.Headings.Add(new TocHeading("Introduction", 2, false, 1));
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output stream
var outputStream = new MemoryStream();
options.AddOutput(new StreamDataSource(outputStream));
options.CloseOutputStreams = false;
// Perform the process
PdfManager.AddTableOfContents(options);تحسين قابلية الاستخدام لـ TableGenerator
- Class TableGenerator: ثابت ولا يتطلب استخدام مُنشئ.
- Class TableGenerator: تم وضع علامة Obsolete عليه. استخدم PdfManager بدلاً منه.
تحسين قابلية الاستخدام لـ PdfChatGpt
- Class PdfChatGpt: ثابت ولا يتطلب استخدام مُنشئ.
- Class PdfChatGptRequestOptions: تمت إضافة خاصية
CancellationToken(نُقلت من PdfChatGpt).
مثال على الاستخدام:
يوضح المثال كيفية استخدام إضافة PdfChatGpt عن طريق إضافة رسائل إلى الطلب.
var options = new PdfChatGptRequestOptions();
options.AddOutput(new FileDataSource("PdfChatGPT_output.pdf")); // Add the output file path.
options.ApiKey = "Your API key."; // You need to provide the key to access the API.
options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
// for cancel
// var cancelTokenSource = new CancellationTokenSource();
// var cToken = cancelTokenSource.Token;
// options.CancellationToken = cToken;
// Add the request messages.
options.Messages.Add(new Message
{
Content = "You are a helpful assistant.",
Role = Role.System
});
options.Messages.Add(new Message
{
Content = "What is the biggest pizza diameter ever made?",
Role = Role.User
});
// Process the request.
await PdfChatGpt.ProcessAsync(options);الأخطاء التي تم إصلاحها
- تم إصلاح مشكلة ميتا البيانات في تحويل HTML إلى PDF
- تم إصلاح مشاكل تنسيق النص والصور المتقيسة في تحويل PDF إلى PDF/A_3b
- تم إصلاح تقارير خطأ عند طباعة PDF/A الناتج من تحويل PDF إلى PDFA
- تم إصلاح مشكلة وجود خلفية في الصورة الناتجة من تحويل PDF إلى HTML
- تم إصلاح ظهور بعض الأحرف الصينية كصناديق في تحويل HTML إلى PDF
- تم إصلاح عدم احترام الخط المخصص المشفر بـ Base64 في تحويل HTML إلى PDF
- تم إصلاح عدم تطبيق أنماط CSS لحقل النموذج في تحويل HTML إلى PDF
- تم إصلاح عدم رسم المخطط بشكل صحيح في تحويل HTML إلى PDF
- تم إصلاح عدم عرض الأحرف الخاصة في تحويل HTML إلى PDF