错误文档没有页面。 [英] Error The document has no pages.
问题描述
using(StringWriter sw = new StringWriter())
{
using(HtmlTextWriter hw = new HtmlTextWriter(sw))
{
GridView1.AllowPaging = false;
this.DataBind();
GridView1.RenderControl(hw) ;
StringReader sr = new StringReader(sw.ToString());
文件pdfdoc =新文件(PageSize.A4,10f, 10f,10f,0f);
HTMLWorker htmlparser = new HTMLWorker(pdfdoc);
pdfdoc.PageCount = 1;
PdfWriter.GetInstance( pdfdoc,Response.OutputStream);
pdfdoc.Open();
htmlparser.Parse(sr);
pdfdoc.Close();
Response.ContentType =Application / pdf;
Response.AddHeader(content-disposition,attachemnt; filename = FileName.pdf);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfdoc);
Response.End();
}
}
< blockquote>
您没有在文档中添加新页面
pdfdoc.newPage();
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
GridView1.AllowPaging = false;
this.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);
pdfdoc.PageCount = 1;
PdfWriter.GetInstance(pdfdoc, Response.OutputStream);
pdfdoc.Open();
htmlparser.Parse(sr);
pdfdoc.Close();
Response.ContentType = "Application/pdf";
Response.AddHeader("content-disposition", "attachemnt;filename=FileName.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfdoc);
Response.End();
}
}
Hi,
You did not add a new Page to the document
pdfdoc.newPage();
这篇关于错误文档没有页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!