I am currently using wkhtmltopdfwhere I am trying to generate a file .pdfafter a user submits a form to our website. The form data is sent to post.php, where it is well displayed as a formatted web page. I want to create a .pdf file of this exact page.
But the problem starts when you try to execute wkhtmltopdf. I get a continuous loop because I'm trying to create a .pdf from inside this file post.php, which is also the target.
I also tried a include()separate file PHPto process the function exec(), but I still get a continuous loop.
Perhaps the picture below shows:
form.phpwhich contains something like below ...
<form id="ecard" action="post.php" method="post">
<input type="text" name="ecard_message" />
<input type="submit" />
</form>
post.phpwhich contains published data and contains HTMLhow it is ...
<div class="content">
<?php echo $_POST['ecard_message']; ?>
</div>
<?php exec("wkhtmltopdf http://example.com/post.php ecard.pdf"); ?>
My code works when a function exec()runs separately from these files, but how can I execute exec()it automatically in the same process?
Any insight is greatly appreciated.
source
share