如何将文本框值导出到pdf [英] How to export a text box value to the pdf

查看:92
本文介绍了如何将文本框值导出到pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试将文本框值导出到pdf但是我无法使用文本框值,尽管我已将这些值放入一个面板并尝试渲染该面板。这里的Gridvaluies和Labels ..一切都被导出为PDF,除了文本框值。



我尝试过:



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:

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

推荐答案

OP已经解决了。添加答案将其从未答复的列表中移除。

OP has solved. Adding answer to move it from unanswered list.
引用:

我已经实现了..谢谢

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


这篇关于如何将文本框值导出到pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆