Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've tried to export the textbox values to the pdf but i was not able to c the textboxvalues though i've taken those into one panel and tried to render that panel. Here the Gridvaluies and Labels.. everything is getting exported to PDF, Except the Textbox Values

What I have tried:

C#
protected void btnconvert_Click(object sender, EventArgs e)
       {
           try
           {
               using (StringWriter sw = new StringWriter())
               {
                   using (HtmlTextWriter hw = new HtmlTextWriter(sw))
                   {
                       //To Export all pages
                       grdaccinfodatewise.AllowPaging = false;
                       BindGrid(); //Method where we bind the data to the Grid
                       //dateMinFilter.RenderControl(hw); //txtMinDate
                       //dateMaxFilter.RenderControl(hw); //txtMaxDate
                       PanelDatewise.RenderControl(hw);
                       grdaccinfodatewise.RenderControl(hw);
                       StringReader sr = new StringReader(sw.ToString());
                       Document pdfDoc = new Document(PageSize.A3, 10f, 10f, 10f, 10f);
                       HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                       PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                       pdfDoc.Open();
                       pdfDoc.NewPage();
                       htmlparser.Parse(sr);
                       pdfDoc.Close();
                       Response.ContentType = "application/pdf";
                       Response.AddHeader("content-disposition", "attachment;filename=pdfExport.pdf");
                       Response.Cache.SetCacheability(HttpCacheability.NoCache);
                       Response.Write(pdfDoc);
                       //Response.End();
                       HttpContext.Current.ApplicationInstance.CompleteRequest();
                   }
               }
           }
           catch (Exception ex)
           {
               throw ex;
           }
       }
Posted
Updated 4-Mar-16 0:02am
v3
Comments
Are those dynamic textboxes?
JanardhanSharma 4-Mar-16 2:51am    
Static textBoxes..
I already implemented.. thank you

pdfDoc.Add(new Phrase("\r\nStart Date : " + this.dateMinFilter.Text.Trim()));
pdfDoc.Add(new Phrase("\r\nEnd Date : " + this.dateMaxFilter.Text.Trim()+"\r\n"));
htmlparser.Parse(sr);
Nice. I added an answer.

1 solution

OP has solved. Adding answer to move it from unanswered list.
Quote:
I already implemented.. thank you
C#
pdfDoc.Add(new Phrase("\r\nStart Date : " + this.dateMinFilter.Text.Trim()));
pdfDoc.Add(new Phrase("\r\nEnd Date : " + this.dateMaxFilter.Text.Trim()+"\r\n"));
htmlparser.Parse(sr);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900