您的位置:首页 > Web前端 > HTML

htmlToPDF by Pechkin ,Web项目使用时64位锁死,其他没问题

2016-05-30 11:10 597 查看
public void GenerateReport()
{
string nowDate = DateTime.Now.ToString("yyyyMMddhhmmss");

string name = "Report-" + nowDate + ".pdf";

string url = Request.Url.ToString();
using (IPechkin pechkin = Factory.Create(new GlobalConfig().SetMargins(0, 0, 0, 0).SetPaperSize(250, 250)))
{

ObjectConfig oc = new ObjectConfig();
oc.SetPrintBackground(true)
.SetLoadImages(true)
.SetScreenMediaType(true)
.SetPageUri(url);

byte[] pdf = pechkin.Convert(oc);

File.WriteAllBytes(name, pdf);

//Response給用戶端下載
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=" + name);//強制下載
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(pdf);
}
}

//需要特别注意dll的引用,libeay32.dll,libgcc_s_dw2-1.dll,mingwm10.dll,ssleay32.dll,wkhtmltox0.dll 放在根目录下,并设置属性为永远输出
Common.Logging.dll
libeay32.dll
libgcc_s_dw2-1.dll
mingwm10.dll
Pechkin.dll
Pechkin.Synchronized.dll
ssleay32.dll
wkhtmltox0.dll
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: