I am using DOMPDF and I want my form input text to be available in PDF format. So when I type something in input fields, and I press export to PDF, I want it to be there. So here is how I planned my solution. The problem appears when I call the PHP with POST from HTML because It does not update the input values. It just sends the blank ones. I need to change that so it updates them.
1) Fill in the input fields with text
2) Click Export to PDF
3) Use JQuery to change the HTML with input values
4) Call the PHP file ($dompdf->loadHtml(file_get_contents('index.php'));
I tried using AJAX for this but it doesn't work. I DON'T need to send ANY data to the PHP File. I just need to call if after the JQuery changed the HTML.
Here's my PHP File:
<?php
require_once 'autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml(file_get_contents('index.php'));
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render('doc.pdf');
// Output the generated PDF to Browser
$dompdf->stream();
?>
And my JQUERY File
function ajax() {
alert('in');
$.ajax({
url: 'jobsheet.php',
type: 'POST',
data: formData,
success:function(response){
alert(response);
}
});
}
If you have any other solution for this, please let me know!