Last post Jan 07, 2015 01:49 AM by sameer.pantvaidya
Oct 13, 2014 06:22 AM|sameer.pantvaidya|LINK
I'm implementing WKHTMLtoPDF on my web form. Its an aspx page with master page. Everything gets converted fine like image, normal text etc into PDF. But since it's a information filling up form I have some textboxes in it. As I type into
it and try to convert iti in PDF only content other than dynamically changed text, comes.That is .. say if I set 'Text' property of texbox Text="XYZ", then XYZ appears in pdf.. but if I change it.. say to ABC on form.. it doesn't. I tried changing it's
editable content. Same problem occurs.
Oct 14, 2014 01:45 AM|Summer - MSFT|LINK
According to your description, you have been implementing WKHTMLtoPDF on your web form, and everything is ok, but when you change the value of textbox control in form, it doesn’t work.
Based on this situation, I made a test that read THML content to PDF and it works well.
In this test, it will show data accoring to the GridView format
protected void Button2_Click(object sender, EventArgs e)
DataTable dt = new DataTable();
dt.Rows["Name"] = "Mudassar Khan";
//Change the value by the input value
dt.Rows["City"] = TextBox1.Text;
//Bind Datatable to Labels
Label1.Text = dt.Rows["Name"].ToString();
TextBox1.Text = dt.Rows["City"].ToString();
//The method that convert to PDF
The method that convert to PDF:
protected void ExportToPDF(DataTable dt)
//The GridView is just a bridge
GridView GridView1 = new GridView();
GridView1.AllowPaging = false;
GridView1.DataSource = dt;
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/pdf";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
Further information about how to convert to PDF:
If you have any other questions, please feel free to post this forum.
Oct 14, 2014 01:54 AM|KathyW|LINK
Does the server know about the textbox contents changing? Have you posted back the change before trying to create the PDF?
Oct 14, 2014 02:28 AM|sameer.pantvaidya|LINK
Hi Summer.. Thanks for the solution.. But I want to implement it using WKHTMLtoPDF only.
Oct 14, 2014 02:35 AM|sameer.pantvaidya|LINK
Dear Kathy, Yes My problem is around this issue.., Server dont know about the textbox content changing.. I'm not being able to postback/retain the changed text of textbox.. what will
you suggest to go around this issue..
also I have a question that on each 'onchange'(clientside) event of textbox which I tried for setting the value of it to new one, page request is new or same?? If it is new.. how will I pass
the changed textbox content??
Oct 14, 2014 03:34 PM|KathyW|LINK
Since the PDF generating code is on the server, there is nothing you can do other than post back the changes before creating the PDF. The server can't read a change that is only on the user's PC. Why do you think you can't postback the changes first?
Oct 14, 2014 09:01 PM|Summer - MSFT|LINK
Please refer to the link below abot the wkhtmltopdf:
Oct 29, 2014 02:59 AM|May-song|LINK
Could you please tell me that have you solved your problem?
And if yes, could you share your solution and wo could learn from it.
Thank you very much
Jan 07, 2015 01:49 AM|sameer.pantvaidya|LINK
I'm working on it.. I will be posting it. But the forums link above is pretty much usefull.