There is another way to not use passthru or pdftk, but only a script made in 2004, but still works well: forge_fdf
this will help you create a fdf that you can easily format in your pdf format, which means that you
Save this in a php file, say generatePdf.php
require_once('forge_fdf.php'); // leave this blank if we're associating the FDF w/ the PDF via URL $pdf_form_url= ""; // default data; these two arrays must ultimately list all of the fields // you desire to alter, even if you just want to set the 'hidden' flag; // // $fdf_data_names= array(); // none of these in this example $fdf_data_strings= array(); // none of these in this example $fdf_data_strings['email']=mb_strtolower($row_delivreur['firstname']).'.'.mb_strtolower($row_delivreur['lastname']).'@gmail.com'; $fields_hidden= array(); $fields_readonly= array(); // set this to retry the previous state $retry_b= false; header( 'content-type: application/vnd.fdf' ); echo forge_fdf( $pdf_form_url, $fdf_data_strings, $fdf_data_names, $fields_hidden, $fields_readonly );
Linking to Pathtoyourpdf / nameofpdffile.pdf # FDF = generatePdf.php will open your PDF file in a browser (alternatively, there is a way to save it to disk, I think I remember), and the field email will be filled with data from MYSQL: mb_strtolower($row_delivreur['firstname']).'.'.mb_strtolower($row_delivreur['lastname']).'@gmail.com'
It works with checkboxes, switch, ... It opens well in firefox, it needs to be tested with other browsers.
Learn more about PDF HACKS
Aureltime Apr 26 2018-11-11T00: 00Z
source share