Darshan Kshirasagar

Darshan Kshirasagar

  • NA
  • 317
  • 68.9k

Page Panel Content Convert to PDF,but getting empty pdf

Jan 27 2017 3:40 AM
Page Design:
 
<asp:Panel ID="pnlGrid" ScrollBars="Auto" runat="server" Width="100%" Height="700px">
<div style="background-color: lightgray; padding: 0 2px 2px 0; border: solid 1px lightgray;">
<div id="div1" style="background-color: white; padding: 0 1px 1px 0; border-top: 0;
border: none;" runat="server">
<asp:PlaceHolder ID="PlaceHolder1" runat="server" />
<%--<asp:HiddenField ID="hfReport" runat="server" />
<asp:Literal ID="MyLiteral" runat="server" Mode="Transform"></asp:Literal>--%>
</div>
</div>
</asp:Panel>
 
 
Code Behind :
 
 
 
 
 
 
 
protected void btnPDFText_OnClick(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);

StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
div1.RenderControl(htmlTextWriter);

StringReader stringReader = new StringReader(stringWriter.ToString());
Document Doc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(Doc);
PdfWriter.GetInstance(Doc, Response.OutputStream);

Doc.Open();
htmlparser.Parse(stringReader);
Doc.Close();
Response.Write(Doc);
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
 
 
 
 
 Result :
When i,m convert getting empty pdf ..please help me
 
 

Answers (1)