I need to generate a pdf with personal information of a user (personal data), but I need a button that starts the download on the same screen, I do not need to open any other window to view it. Then.
I already have all the HTML with something like this:
<?php
if(isset($_POST['pdf])){
$pdf = new pdfcontroller();
$pdf->generarPdf();
?>
<html>
<head>
</head>
<body>
<form>
{aqui los datos del usuario}
<input class="btn btn-info" type="submit" name="pdf" value="Descargar pdf">
</form>
</body>
</html>
And this is my driver class with the imported library correctly:
require_once(dirname(__FILE__).'/../libs/html2pdf/vendor/autoload.php');
use Spipu\Html2Pdf\Html2Pdf;
class pdfcontroller{
public function generarPdf(){
}
}
Now, I understood that for this library I need to format the HTML and send all the parameters to my driver to generate the pdf and well, that without fail I can solve it, but I hurry the matter that the driver can return an object in pdf or in case to initiate the download of the file.
Thank you very much for your help, I am totally grateful from now on.