gpt4 book ai didi

c# - 如何使用 asp.net 将 gridview 图像和数据导出为 PDF 或使用 asp.net 将 gridview 数据导出为 PDF

转载 作者:太空宇宙 更新时间:2023-11-03 16:29:33 24 4
gpt4 key购买 nike

protected void Button4_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition","attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.AllowPaging = false;
GridView1.DataBind();
GridView1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);//this is the error line
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}

最佳答案

为此您必须使用第 3 方控件尝试免费使用 iTextSharp 库

了解更多信息 go here

关于c# - 如何使用 asp.net 将 gridview 图像和数据导出为 PDF 或使用 asp.net 将 gridview 数据导出为 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11260859/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com