I need to convert several aspx pages to PDF when a button is clicked. This happens after many text boxes are filled and other controls are selected, etc. Wkhtmltopdf renders the pdf very nicely but everything is blank. Basically, when the PDF is created it is in the state that the form was in on load. I want the PDF to be in the state that the form is in when the button is pressed. I need ideas for a way to work around this issue in order to save the pdf with the text boxes filled.
wkhtmltopdf
renders an HTML page it "sees", not how the browser displays it. When you fill out the form, the values in the fields are not part of the underlying HTML structure (though they are part of the DOM). As a work-around, you can do the following:
Capture and save all of the form parameters' values somewhere (session, file, database, etc) when the form is submitted.
Generate a new HTML page using the same code as the form page.
Fill in the form values you had saved directly into the HTML code. In other words, specify the
value
attributes on the form with the inputs you captured.For example, if you have a text field called
customer_name
and the user submittedJohn Doe
, hard-code the value into the tag:<input type="text" name="customer_name" value="John Doe">
Now wkhtmltopdf
can render the form with the values filled out.
来源:https://stackoverflow.com/questions/17701409/how-to-use-wkhtmltopdf-converter-with-filled-text-boxes