wkhtmltoPDF input textbox's 'text' not coming in converted/generated pdf RRS feed

  • Question

  • User-955115217 posted

    Hi Friends,

    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 innerText/HTML/ value by javascript,jquery but still dynamically changed value do not gets converted into PDF.. and the ERRO reads.. input HTML element doesnot support Text insertion. I tried replacing Textbox with Div with editable content. Same problem occurs.

    Any help??

    Monday, October 13, 2014 6:22 AM


All replies

  • User-1151753377 posted

    Hi sameer.pantvaidya,

    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)
                    //Populate DataTable
                    DataTable dt = new DataTable();
                    dt.Rows[0]["Name"] = "Mudassar Khan";
    //Change the value by the input value
                    dt.Rows[0]["City"] = TextBox1.Text;
                    //Bind Datatable to Labels
                    Label1.Text = dt.Rows[0]["Name"].ToString();
                    TextBox1.Text = dt.Rows[0]["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";
                Response.AddHeader("content-disposition", "attachment;filename=HTML.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);
                PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

    Further information about how to convert to PDF:




    If you have any other questions, please feel free to post this forum.

    Best Regards,


    Tuesday, October 14, 2014 1:45 AM
  • User409696431 posted

    Does the server know about the textbox contents changing?  Have you posted back the change before trying to create the PDF?

    Tuesday, October 14, 2014 1:54 AM
  • User-955115217 posted

    Hi Summer.. Thanks for the solution.. But I want to implement it using WKHTMLtoPDF only.

    Tuesday, October 14, 2014 2:28 AM
  • User-955115217 posted

    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??

    Tuesday, October 14, 2014 2:35 AM
  • User409696431 posted

    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?

    Tuesday, October 14, 2014 3:34 PM
  • User-1151753377 posted


    Please refer to the link below abot the wkhtmltopdf:


    Best Regards,


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 14, 2014 9:01 PM
  • User-1538479794 posted


    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


    Wednesday, October 29, 2014 2:59 AM
  • User-955115217 posted

    Dear May-song,

    I'm working on it.. I will be posting it. But the forums link above is pretty much usefull.

    Wednesday, January 7, 2015 1:49 AM