【发布时间】:2012-09-24 08:22:43
【问题描述】:
我想生成一个pdf文档然后下载
//this is file name
var fileName = name + "_" + DateTime.Now.ToShortDateString() + ".pdf";
//here I generate my pdf document
string fullpath= GeneratePDF();
bool existFile= File.Exists(fullpath);
//here I check if this document exists
if (existFile)
{
HttpContext.Current.Response.ContentType = "Application/pdf";
HttpContext.Current.Response.AppendHeader("Content-Disposition",
"attachment; filename=" + fileName);
HttpContext.Current.Response.TransmitFile(fullpath);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
遍历所有cod后,文档创建成功,但无法下载
【问题讨论】:
-
doesn't work不是软件开发人员在互联网论坛上提问时应该给出的问题描述。这是不了解或不关心计算机如何工作的标准用户最常使用的问题描述。
标签: c# asp.net pdf-generation