在此介绍 两种方法。
一个是asppdf;一个是abcpdf。
都是收费的组件。需要注册码,但是也有破解的和trial的。
asppdf:http://www.persits.com/asppdf.exe (可以在http://www.asppdf.com/download.html输入一个email获取一个序列号)
abcpdf:http://down.chinaz.com/soft/4509.htm (带有注册码)
asp.net2.0下测试:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ASPPDFLib;
using System.Reflection;
using ABCpdf4;
public partial class _1 : System.Web.UI.Page
...{
protected void Page_Load(object sender, EventArgs e)
...{
testasppdf();
testabcpdf();
}
private void testabcpdf()
...{
DocClass doc = new DocClass();
doc.Page = doc.AddPage(Missing.Value);
//http://10.1.4.43/bbs/index.php?boardid=37
//int id = doc.AddImageUrl("http://localhost:2592/test1/2.aspx", true, 500, false);
int id = doc.AddImageUrl("http://www.google.com/", true, 500, false);
while ("1".Equals(doc.GetInfo(id, "Truncated")))
...{
doc.Page = doc.AddPage(Missing.Value);
id = doc.AddImageToChain(id);
}
doc.Save(Server.MapPath("2.pdf"));
}
private void testasppdf()
...{
IPdfManager objPdf = new PdfManager();
// Create empty document
IPdfDocument objDoc = objPdf.CreateDocument(Missing.Value);
// IPdfFont font = objDoc.Fonts.LoadFromFile("C:\Windows\Fonts\simhei.ttf");
objDoc.ImportFromUrl("http://www.google.com/", Missing.Value, Missing.Value, Missing.Value);
String strFilename = objDoc.Save(Server.MapPath("1.pdf"), false);
}
}
asppdf不支持中文:
abcpdf不错,需要手动设置尺寸,下图是没有设置的:
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/kimmking/archive/2008/01/07/2029351.aspx