字体大小太小:将内容从gridview导出到pdf时,c#中出现0错误

字体大小太小:将内容从gridview导出到pdf时,c#中出现0错误,c#,asp.net,C#,Asp.net,我的代码是: using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter hw = new HtmlTextWriter(sw)) { GridView2.AllowPaging = false; GridView2.RenderControl(hw); StringReader sr =

我的代码是:

 using (StringWriter sw = new StringWriter())
  {
  using (HtmlTextWriter hw = new HtmlTextWriter(sw))
            {
                GridView2.AllowPaging = false;
                GridView2.RenderControl(hw);
                StringReader sr = new StringReader(sw.ToString());
                Document pdfDoc = new iTextSharp.text.Document(PageSize.A2);
                HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                pdfDoc.Open();


                htmlparser.Parse(sr);
                pdfDoc.Close();

                Response.ContentType = "application/pdf";
                Response.AddHeader("contentdisposition","attachment;filename=CustomerReport.pdf");
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Write(pdfDoc);
                Response.End();
            }
        }*/

请帮我解决这个问题。在这篇文章中,我得到了
字体大小太小的错误。htmlparser.parse()中的错误

那么您试图编写的HTML是什么呢?它是一个表,其中包含使用GridView从db分配的名称和插槽。我可以看到这一点。我的意思是你需要调试。sr在
Parse
中传递给htmlparser的文本是什么?是否给出了字体大小?也许它真的太小了?错误信息非常清楚。你需要找出如何修复它。你能说清楚你说的是什么吗。如果没有给出大小,它必须采用默认的bt错误显示在这行“htmlparser.parse(sr);”中。你的解析器正在尝试解析某些东西。我不知道它看起来像什么。你似乎不知道它是什么样子。只要我们不知道,我们就找不到错误。基本调试。