【问题标题】:how to export gridview image and data to PDF using asp.net or Export gridview data to PDF using asp.net如何使用 asp.net 将 gridview 图像和数据导出到 PDF 或使用 asp.net 将 gridview 数据导出到 PDF
【发布时间】:2012-06-30 22:19:49
【问题描述】:
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();  
}

【问题讨论】:

    标签: c# asp.net ajax components


    【解决方案1】:

    您必须为此使用第 3 方控制 尝试免费使用 iText Sharp 库

    更多信息go here

    【讨论】:

    • 我导出到文本中的 gridview 值..但不只导出到图像我如何导入 pdf 中的图像?
    • Hey Jintha arun.. 你解决了这个问题吗??如果是,请您发布答案..
    猜你喜欢
    • 1970-01-01
    • 2018-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-27
    • 2010-12-12
    • 2018-05-05
    • 1970-01-01
    相关资源
    最近更新 更多