Convertirile HTML pentru .NET

Introducere la HTML Converter pentru .NET

Convertorul HTML pentru .NET este un plugin puternic care permite dezvoltatorilor să converteze documente PDF în pagini HTML. Acest ghid oferă o imagine de ansamblu a caracteristicilor disponibile și explică cum să se desfășoare sarcini comune folosind exemplele de cod în .Net.

Instalarea HTML Converter

Pentru a începe cu HTML Converter pentru .NET, trebuie să instalați pachetul Aspose.Pdf NuGet. puteți face acest lucru prin executarea următoarelor comenzi în Consola de gestionare a pachetelor Nuget:

Install-Package Aspose.PDF

Alternativ, puteți descărca DLL și adăugați-o ca referință la proiectul dvs.

Conversie PDF în HTML

Converting PDF documents HTML is one of the primary features of the HTML Converter. You can achieve this by using the PdfHtml class to load the PDF document and then saving it as an HTML file.

// 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);
 Română