.net - 将 HTML 转换为 PDF - 用于 ASP.net 的任何库

标签 .net asp.net pdf

就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the help center为指导。




9年前关闭。




是否有任何 .net 库可以将 HTML 输出转换为 PDF --- 在 asp.net 应用程序中。

是否免费都无所谓

最佳答案

根据我自己的经验,我建议 ABCpdf库(它不是免费的,但您可以获得试用许可证)。查看他们的 documentation有关如何将 HTML 输出添加到 PDF 文档的部分。

快速示例:

string html = "<html>....</html>";
WebSupergoo.ABCpdf7.Doc doc = new WebSupergoo.ABCpdf7.Doc();

doc.Rect.Left = 10;
doc.Rect.Bottom = 50;
doc.Rect.Top = 750;
doc.Rect.Right = 600;    

doc.SetInfo(0, "License", "[your license code || trial license"]);    
doc.Page = doc.AddPage();

int pageID = doc.AddImageHtml(html, true, 1024, true);
while (doc.Chainable(pageID))
{
    doc.Page = doc.AddPage();
    pageID = doc.AddImageToChain(pageID);
}

for(int i = 1; i < doc.PageCount; i++)
{
    doc.PageNumber = i;
    doc.Flatten();
}

doc.Save("myfile.pdf");

希望这会帮助你。

关于.net - 将 HTML 转换为 PDF - 用于 ASP.net 的任何库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4677594/

相关文章:

c# - 什么是 DetailsView.EnableModelValidation?

C# Telnet 库

c# - Pdfium .NET SDK 中的打印功能

c# - 连接字符串错误

java - 使用 iText7 验证/添加 PDF 签名

node.js - pdfmake 不包含 node.js 中的字体/文本

c# - Task<T> 中的单线程计时器和/或间隔

c# - 从 MemberExpression 和 Constant 创建 Func<T, bool>

c# - 如何在图像上放置标签

html <hr> 标签奇怪显示