HTML átalakító .NET

Bevezetés a HTML Converter for .NET

A HTML Converter for .NET egy erőteljes plugin, amely lehetővé teszi a fejlesztők számára, hogy PDF dokumentumokat HTML oldalakká alakítsanak át. Ez az útmutató áttekintést nyújt a rendelkezésre álló funkciókról, és magyarázza, hogyan kell közös feladatokat végezni kódminták használatával a .Net-ben.

A HTML Converter telepítése

Ahhoz, hogy elkezdje a HTML Converter for .NET, telepítse az Aspose.Pdf NuGet csomagot. Ezt a következő parancsot futtathatja a Nu Get Package Manager Console-ban:

Install-Package Aspose.PDF

Alternatív módon letöltheti a DLL-t, és referenciaként hozzáadhatja a projekthez.

PDF átalakítása HTML-re

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