使用 VB.NET 将 HTML 文件输出为 PDF 的最简单方法
easiest way to output HTML file as PDF using VB.NET
我在我的应用程序中生成了一个 HTML 文件。现在我想将其输出为 PDF 文件。如何使用 VB.NET 轻松做到这一点?该过程必须离线,我不能使用任何付费图书馆或 API。
I have write easiest way to write html to pdf code using NRerco Pdf library which available free, Install nuget package
PM > 安装包 NReco.PdfGenerator
Create HtmltoPdf()
{
if (System.IO.File.Exists("HTMLFile.html"))
{
System.IO.File.Delete("HTMLFile.html");
}
System.IO.File.WriteAllText("HTMLFile.html", html);
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
if (System.IO.File.Exists("export.pdf"))
{
System.IO.File.Delete("export.pdf");
}
htmlToPdf.GeneratePdfFromFile("HTMLFile.html", null, "export.pdf");
}
我在我的应用程序中生成了一个 HTML 文件。现在我想将其输出为 PDF 文件。如何使用 VB.NET 轻松做到这一点?该过程必须离线,我不能使用任何付费图书馆或 API。
I have write easiest way to write html to pdf code using NRerco Pdf library which available free, Install nuget package
PM > 安装包 NReco.PdfGenerator
Create HtmltoPdf()
{
if (System.IO.File.Exists("HTMLFile.html"))
{
System.IO.File.Delete("HTMLFile.html");
}
System.IO.File.WriteAllText("HTMLFile.html", html);
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
if (System.IO.File.Exists("export.pdf"))
{
System.IO.File.Delete("export.pdf");
}
htmlToPdf.GeneratePdfFromFile("HTMLFile.html", null, "export.pdf");
}