我创建了一个位置来保存来自asp.net的转换后的PDF,如下所示:
public string fileUploadLoc = ConfigurationManager.AppSettings["PDFFileLoc"];
//set from web.config eg: d:/temp/employeeData
DirectoryInfo destination = new DirectoryInfo(Server.MapPath("~/" + fileUploadLoc));
Directory.CreateDirectory(Server.MapPath("~/" + fileUploadLoc));
destination = new DirectoryInfo(Server.MapPath("~/" + fileUploadLoc));
destination.Create();
我将asp.net页面转换为PDF。如何将转换后的PDF保存到指定的位置。请帮帮我。
答案 0 :(得分:0)
在将文件序列化到响应流之前使用它:
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader(
"content-disposition", string.Format("attachment; filename={0}", fileName));
HttpContext.Current.Response.ContentType = "application/pdf";
//HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.HeaderEncoding = Encoding.UTF8;
答案 1 :(得分:0)
System.IO.FileStream file = new System.IO.FileStream(Server.MapPath("~/" + fileUploadLoc" System.IO.FileMode.OpenOrCreate);
PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, file);