因此,我使用此代碼將窗體導出導出爲Word。 它的作品很棒..但我希望它出口到PDF,以便它不能被編輯。或者可能是對word文檔,以便身體不能做出改變。將文檔導出爲PDF Asp.net
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=Report.doc");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-word";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
FormView1.DataBind();
FormView1.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
問題是,即使當我更改上面的代碼中的內容類型和標題元素時,它說輸出pdf有錯誤。
我真的想要將文檔轉換爲PDF或使用此代碼生成PDF。
請幫忙。
謝謝..
此外,您可以創建一個HTTP處理程序,它可以將PDF作爲附件流式傳輸到瀏覽器,以便用戶查看和/或保存PDF。我在工作的應用程序中始終使用這個概念。這裏有一篇關於如何[使用ASP.NET HttpHandler生成簡單PDF報告]的博客條目(http://kuujinbo.info/cs/itext_reports.aspx) –