محول إتش تي إم إل للNET
مقدمة في محول إتش تي إم إل للNET
محول إتش تي إم إل للNET هو مكون إضافي قوي يمكّن المطورين من تحويل مستندات بي دي اف إلى صفحات إتش تي إم إل. يوفر هذا الدليل نظرة عامة على الميزات المتاحة ويشرح كيفية أداء المهام الشائعة باستخدام أمثلة رمز في NET.
تثبيت محول إتش تي إم إل
لبدء استخدام محول إتش تي إم إل للNET، تحتاج إلى تثبيت حزمة Aspose.Pdf NuGet. يمكنك القيام بذلك عن طريق تشغيل الأمر التالي في وحدة تحكم مدير الحزم NuGet:
Install-Package Aspose.PDF
بديلًا، يمكنك تحميل DLL وإضافتها كمرجع إلى مشروعك.
تحويل بي دي اف إلى إتش تي إم إل
تحويل مستندات بي دي اف إلى إتش تي إم إل هو واحد من الميزات الرئيسية لمحول إتش تي إم إل. يمكنك تحقيق ذلك باستخدام فئة PdfHtml
لتحميل مستند بي دي اف ثم حفظه كملف إتش تي إم إل.
// Specify the input and output paths for the PDF document.
var inputPath = Path.Combine(@"C:\Samples\", "sample.pdf");
var outputPath = Path.Combine(@"C:\Samples\", "sample.html");
// Create a new instance of the PdfHtml class.
var plugin = new PdfHtml();
// Create a new instance of the PdfToHtmlOptions class.
var options = new PdfToHtmlOptions(PdfToHtmlOptions.SaveDataType.FileWithEmbeddedResources);
// Add the input and output paths to the PdfToHtmlOptions.
options.AddInput(new FileDataSource(inputPath));
options.AddOutput(new FileDataSource(outputPath));
// Process the PDF to HTML conversion and get the result container.
var resultContainer = plugin.Process(options);
// Get the result from the result container.
var result = resultContainer.ResultCollection[0];
// Print the result to the console.
Console.WriteLine(result);