gpt4 book ai didi

c# - 如何在 asp.net 中增加 pdf 文件的 ASPxGridView 内容大小?

转载 作者:行者123 更新时间:2023-12-05 06:36:00 25 4
gpt4 key购买 nike

如何在下载 PDF 格式时增加 ASPxGridView 内容的大小?我的devexpress版本是13.2,visual studio是2010。

protected void Export_Click(object sender, EventArgs e)
{
ASPxGridView1.DataBind();
ASPxGridViewExporter1.GridViewID = "ASPxGridView1";
ASPxGridViewExporter1.PaperKind = System.Drawing.Printing.PaperKind.A4;
ASPxGridViewExporter1.ReportHeader = "hello";
ASPxGridViewExporter1.WritePdfToResponse("hello.xls");
}`

最佳答案

使用 gridview 而不是 aspxgridview 并试试这个。

 using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
//To Export all pages
GridView2.AllowPaging = false;
this.BindGrid();

GridView2.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
}
}

关于c# - 如何在 asp.net 中增加 pdf 文件的 ASPxGridView 内容大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49442196/

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