将HTML转换成PDF格式 - 为ASP.net的任何库 [英] Convert HTML to PDF - Any library for ASP.net

查看:109
本文介绍了将HTML转换成PDF格式 - 为ASP.net的任何库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有.NET库,将一个HTML输出转换为PDF格式---在一个asp.net应用程序。

Is there any .net library which would convert a HTML output to PDF --- in an asp.net application.

不要紧,如果它是免费的或不

Doesn't matter if it is free or not

推荐答案

根据我自己的经验,我建议的 ABCpdf 库(它不是免费的,但你可以得到一个试用许可证)。看看他们文档部分。

Based on my own experience I'd suggest ABCpdf library (it's not free, but you can get a trial license). Check out their documentation section for how to add HTML output to the PDF document.

简单的例子:

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

希望这会帮助你。

Hope this will help you.

这篇关于将HTML转换成PDF格式 - 为ASP.net的任何库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆