首页 新闻 会员 周边 捐助

abcpdf.dll占用内存好大呀,谁用过这个控件的请帮忙指点

0
悬赏园豆:20 [已关闭问题] 关闭于 2009-06-23 11:44

abcpdf.dll占用内存好大呀,谁用过这个控件的请帮忙指点,代码如下,谢谢大家

public static string HtmlPrintPdf(string WebUrl, string fileName, string filePath)
        {
            string pdfFileName = "";
            int id = 0;
            Doc doc = new Doc();
            try
            {
                string url = WebUrl + fileName + ".htm";
                doc.Rect.Inset(5, 10);
                doc.Page = doc.AddPage();
                id = doc.AddImageUrl(url);
                while ("1".Equals(doc.GetInfo(id, "Truncated")))
                {
                    doc.Page = doc.AddPage();
                    id = doc.AddImageToChain(id);
                }

                //add page number
                for (int i = 1; i <= doc.PageCount; i++)
                {
                    doc.PageNumber = i;
                    doc.Pos.X = (doc.MediaBox.Width / 2) - 20;
                    doc.Pos.Y = -7;
                    doc.AddText("Page:" + i.ToString() + "/" + doc.PageCount.ToString());
                    doc.Flatten();
                }

                pdfFileName = filePath + fileName + ".pdf";

                if (File.Exists(pdfFileName))
                {
                    File.Delete(pdfFileName);
                }
                doc.Save(pdfFileName);
                url = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                doc.Delete(id);
                doc.Clear();
                doc.Dispose();
                doc = null; WebUrl = null; fileName = null; filePath = null;
            }
            return pdfFileName;
        }

风浪的主页 风浪 | 老鸟四级 | 园豆:2996
提问于:2009-06-22 14:35
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册