如何在Pdf文档中添加Aspx控件值?

问题描述:

在我的页面中,我有一个文本框和一个Button.When我在文本框中输入文本并按提交按钮,文本框值将添加到Pdf文档中,如



输入你的名字:奔驰



但我的问题是,当我按下提交按钮时,数据将被附加在PDF文档中的图像上方。我想要显示在文档的中间。

请帮助我....

我的代码是

Here in my page i have one Textbox and one Button.When i enter the text in textbox and press Submit button the Textbox value will be added in Pdf Document like

Enter u r Name:Benz

but my problem is when i press the submit button the data will be append on above the image in PDF Document.i want to display in the middile of the Document.
pls help me....
My Code is

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Reports in PDF.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
 StringWriter sw = new StringWriter();
sw.Write(lbl1.Text + ":" + txt1.Text);
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();



显示如

姓名:BEnz

IMage

Nmae:

i希望在Name的前面显示文本框值。

请帮我搜索这么多文章。但我没有得到答案。

请帮助我.....


it shows like
Name:BEnz
IMage
Nmae:
i want to display the textbox value in fron of Name.
pls Help me i search so many articles.but i didnt get answer.
pls help me.....

您好,



您可以使用'WkHtmltoPdf .exe'将您的html文件转换为PDF文件。
Hi,

You can use 'WkHtmltoPdf.exe' to convert your html file to PDF file.