HTML-konverterare för .NET
Introduktion till HTML Converter för .NET
HTML Converter för .NET är en kraftfull plugin som gör det möjligt för utvecklare att konvertera PDF-dokument till HTML-sidor. Denna guide ger en översikt över de tillgängliga funktionerna och förklarar hur man utför vanliga uppgifter med hjälp av kodexempler i .Net.
Installera HTML Converter
För att börja med HTML Converter för .NET måste du installera Aspose.Pdf NuGet-paketet. Du kan göra detta genom att köra följande kommando i nuget Package Manager Console:
Install-Package Aspose.PDF
Alternativt kan du ladda ner DLL och lägga till det som en hänvisning till ditt projekt.
Konvertera PDF till HTML
Konvertera PDF-dokument till HTML är en av de viktigaste funktionerna i HTML Converter. PdfHtml
klasser för att ladda PDF-dokumentet och sedan spara det som en HTML-fil.
// 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);