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;
}