Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>wkhtmltopdf hits the page independently of your current browsing session. If you hit it like that, you're going to get what anyone would see when they first go to your page. Probably what you want to do is save the current page using an output buffer, and then run wkhtmltopdf on the saved page. Here's some sample code:</p> <p>sub.php</p> <pre><code>&lt;?php $documentTemplate = file_get_contents ("template.html"); foreach ($_POST as $key =&gt; $postVar) { $documentTemplate = preg_replace ("/name=\"$key\"/", "value=\"$postVar\"", $documentTemplate); } file_put_contents ("out.html", $documentTemplate); shell_exec ("wkhtmltopdf out.html test.pdf"); ?&gt; </code></pre> <p>template.php</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;meta charset="utf-8" /&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;This is a page&lt;/h1&gt; &lt;form action="sub.php" method="post" accept-charset="utf-8"&gt; My Test Field: &lt;input type="text" name="test_field" value=""&gt; &lt;input type="submit" value = "submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Probably in the long run you should have some kind of base template that both pages would use, and one have some markers like value='%valueOfThisVariable%' in your input fields that you can replace with blanks when you present the fields to the user, and fill with the user data when you create the page that you want to write to pdf. Right now it's just going through and replacing all the name='this_name' with value='this_name->value'.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload