阅读背景:

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

来源:互联网 
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 public void GenerateReport()
        {
        



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: