【发布时间】:2013-06-26 12:17:37
【问题描述】:
所以我正在使用此代码将表单视图导出到 Word。 它的效果很好..但我希望它导出为 PDF 以便无法编辑。或者可能是一个word doc,这样body就不能做出改变。
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。
请帮忙。
谢谢..
【问题讨论】:
标签: c# asp.net asp.net-mvc pdf-generation abcpdf