TextBox控件不与出口合作,PDF(iTextSharp的) [英] TextBox controls are not Working with Export To PDF(iTextSharp)

查看:117
本文介绍了TextBox控件不与出口合作,PDF(iTextSharp的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML表单,其中包含标贴和文本框。

I have an HTML form, which contains lables and textboxes.

填写此表格后,将其导出为PDF。

After filling this form, it is exported to PDF.

所有标签文本导出。但是,文本框的文本不会导出为PDF。

All the label Texts are exported. But the textbox text is not exported to PDF.

code

protected void btnExportPDF_Click(object sender, EventArgs e)
{
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "attachment;filename=DecForm.pdf");
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    this.divToPdf.RenderControl(hw);
    StringReader sr = new StringReader(sw.ToString());
    Document pdfDoc = new Document(PageSize.A4, 10, 10, 2, 10);
    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
    PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
    pdfDoc.Open();
    htmlparser.Parse(sr);
    pdfDoc.Close();
    Response.Write(pdfDoc);
    Response.End();
}

为什么不通过导出为PDF文本框中的文字?

Why are the textbox text not exported through to PDF?

推荐答案

我认为,当你渲染 divToPDF 你所得到的HTML的鲜切它不具有的值有被填充在页面上。你可能想看看使用 divToPDF 是你想看看在访问的innerHTML OuterHtml 属性,并使用了。

I think that when you're rendering divToPDF you are getting a fresh cut of the html and it does not have the values there were populated on the page. You may want to look at using the divToPDF is you'll want to look at accessing the InnerHtml or OuterHtml property and use that.

这篇关于TextBox控件不与出口合作,PDF(iTextSharp的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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