我正在將HTML內容導出爲PDF。文件不以'%PDF-'開頭
System.IO.StringWriter sWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWriter = new HtmlTextWriter(sWriter);
Response.Buffer = true;
FormId.RenderControl(htmlWriter);
Response.ContentType = "application/pdf";
// Added appropriate headers
Response.AddHeader("Content-Disposition", "inline; filename=XXX.pdf");
Response.AddHeader("Content-Length", htmlWriter.ToString().Length.ToString());
Response.Output.Write(sWriter.ToString());
Response.Flush();
Response.Close();
FormId是內容的我事業部過去..
我得到的錯誤是「文件不以%pdf-開始」
我已經包括Response.clear( );輸出不是
sWriter實際上是否給你一個有效的PDF文件?檢查它的前四個字節。 – paxdiablo 2009-02-06 05:29:01