0

我需要为评分表做报告。我正在使用名为 itextsharp.dll 的第三方控件来生成报告。该程序在本地机器上编译没有错误,但相同的程序在上传到服务器时出错。

就像文档没有页面一样

请让我知道解决方案。

这是我的代码。

    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "attachment;filename=FA1Report.pdf");
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    GridView1.AllowPaging = false;
    GridView1.DataBind();
    GridView1.RenderControl(hw);
    GridView1.HeaderRow.Style.Add("width", "15%");
    GridView1.HeaderRow.Style.Add("font-size", "10px");
    GridView1.Style.Add("text", "Emp Table");
    GridView1.Style.Add("text-decoration", "none");
    GridView1.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
    GridView1.Style.Add("font-size", "8px");
    GridView2.AllowPaging = false;
    GridView2.DataBind();
    GridView2.RenderControl(hw);
    GridView2.HeaderRow.Style.Add("width", "15%");
    GridView2.HeaderRow.Style.Add("font-size", "10px");
    GridView2.Style.Add("text", "Emp Table");
    GridView2.Style.Add("text-decoration", "none");
    GridView2.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
    GridView2.Style.Add("font-size", "8px");
    GridView3.AllowPaging = false;
    GridView3.DataBind();
    GridView3.RenderControl(hw);
    GridView3.HeaderRow.Style.Add("width", "15%");
    GridView3.HeaderRow.Style.Add("font-size", "10px");
    GridView3.Style.Add("text", "Emp Table");
    GridView3.Style.Add("text-decoration", "none");
    GridView3.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
    GridView3.Style.Add("font-size", "8px");
    GridView4.AllowPaging = false;
    GridView4.DataBind();
    GridView4.RenderControl(hw);
    GridView4.HeaderRow.Style.Add("width", "15%");
    GridView4.HeaderRow.Style.Add("font-size", "10px");
    GridView4.Style.Add("text", "Emp Table");
    GridView4.Style.Add("text-decoration", "none");
    GridView4.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
    GridView4.Style.Add("font-size", "8px");
    GridView5.AllowPaging = false;
    GridView5.DataBind();
    GridView5.RenderControl(hw);
    GridView5.HeaderRow.Style.Add("width", "15%");
    GridView5.HeaderRow.Style.Add("font-size", "10px");
    GridView5.Style.Add("text", "Emp Table");
    GridView5.Style.Add("text-decoration", "none");
    GridView5.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
    GridView5.Style.Add("font-size", "8px");
    GridView6.AllowPaging = false;
    GridView6.DataBind();
    GridView6.RenderControl(hw);
    GridView6.HeaderRow.Style.Add("width", "15%");
    GridView6.HeaderRow.Style.Add("font-size", "10px");
    GridView6.Style.Add("text", "Emp Table");
    GridView6.Style.Add("text-decoration", "none");
    GridView6.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
    GridView6.Style.Add("font-size", "8px");
    GridView7.AllowPaging = false;
    GridView7.DataBind();
    GridView7.RenderControl(hw);
    GridView7.HeaderRow.Style.Add("width", "15%");
    GridView7.HeaderRow.Style.Add("font-size", "10px");
    GridView7.Style.Add("text", "Emp Table");
    GridView7.Style.Add("text-decoration", "none");
    GridView7.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
    GridView7.Style.Add("font-size", "8px");
    GridView8.AllowPaging = false;
    GridView8.DataBind();
    GridView8.RenderControl(hw);
    GridView8.HeaderRow.Style.Add("width", "15%");
    GridView8.HeaderRow.Style.Add("font-size", "10px");
    GridView8.Style.Add("text", "Emp Table");
    GridView8.Style.Add("text-decoration", "none");
    GridView8.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
    GridView8.Style.Add("font-size", "8px");
    GridView9.AllowPaging = false;
    GridView9.DataBind();
    GridView9.RenderControl(hw);
    GridView9.HeaderRow.Style.Add("width", "15%");
    GridView9.HeaderRow.Style.Add("font-size", "10px");
    GridView9.Style.Add("text", "Emp Table");
    GridView9.Style.Add("text-decoration", "none");
    GridView9.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
    GridView9.Style.Add("font-size", "8px");
    GridView10.AllowPaging = false;
    GridView10.DataBind();
    GridView10.RenderControl(hw);
    GridView10.HeaderRow.Style.Add("width", "15%");
    GridView10.HeaderRow.Style.Add("font-size", "10px");
    GridView10.Style.Add("text", "Emp Table");
    GridView10.Style.Add("text-decoration", "none");
    GridView10.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
    GridView10.Style.Add("font-size", "8px");
    StringReader sr = new StringReader(sw.ToString());
    Document pdfDoc = new Document(PageSize.A3, 7f, 7f, 7f, 0f);
    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
    PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
    pdfDoc.Open();
    htmlparser.Parse(sr);
    pdfDoc.Close();
    Response.Write(pdfDoc);
    Response.End();
4

0 回答 0