NET 的 HTML 转换器
引入 HTML 转换器为 .NET
HTML Converter for .NET 是一个强大的插件,允许开发人员将 PDF 文档转换为 HTML 页面. 本指南提供了可用的功能的概述,并解释了如何使用代码示例进行常见任务。
安装 HTML 转换器
要開始使用 .NET 的 HTML 轉換器,您必須安裝 Aspose.Pdf NuGet 包。
Install-Package Aspose.PDF
否则,您可以下载 DLL 并将其添加为您的项目的参考。
将 PDF 转换为 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);