-2

我有 2 个网格需要导出为 pdf...

现在我可以出口了.. 但是

我可以区分 2 个网格......这意味着 2 个网格正在添加到一个表中......

我需要两个网格之间的空间,以便我可以区分......

我怎样才能在 2 个网格之间保持空白……这是我的代码

gridview1: gvrpaList gridview1: rptisslst

   protected void btnExportPDF_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);

gvrpaList.AllowPaging = false;

//gvrpaList.DataBind();

gvrpaList.RenderControl(hw);

gvrpaList.HeaderRow.Style.Add("width", "15%");

gvrpaList.HeaderRow.Style.Add("font-size", "15px");

gvrpaList.Style.Add("text-decoration", "none"); 

gvrpaList.Style.Add("font-family", "Arial, Helvetica, sans-serif;");

gvrpaList.Style.Add("font-size", "8px");

rptisslst.AllowPaging = false;

rptisslst.RenderControl(hw);

rptisslst.HeaderRow.Style.Add("width", "15%");

rptisslst.HeaderRow.Style.Add("font-size", "15px");

rptisslst.Style.Add("text-decoration", "none");


rptisslst.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
rptisslst.Style.Add("font-size", "8px");


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);

 byte[] byteArr = Encoding.ASCII.GetBytes(sw.ToString());
 MemoryStream stream = new MemoryStream(byteArr);

 StreamReader stre = new StreamReader(stream);

  pdfDoc.Open();

  htmlparser.Parse(stre);

  pdfDoc.Close();

  Response.Write(pdfDoc);

  Response.End();
   }
   public override void VerifyRenderingInServerForm(Control control)
  {
  // verifies the control is rendered here
   }
4

1 回答 1

0

您可以尝试添加换行符:

gvrpaList.RenderControl(hw);
hw.Write("<br />");
rptisslst.RenderControl(hw);
于 2012-12-18T15:02:35.673 回答