Saturday, 15 February 2014

Populate PDF form with mysql data in php -



Populate PDF form with mysql data in php -

i have pdf next form fields:

cost clicks impressions keyword1 clicks1 cost1 keyword2 clicks2 cost2

and goes 10

i have next code trying figure out way query table , limit of 10 results , populate fields. can't figure out whats best way go doing this, because fdf has have variable associated form field need assigned dynamically. can please help me this. below code have:

<?php error_reporting(e_all); ini_set('display_errors', 1); $con=mysqli_connect("localhost","username","password","my_db"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $result = mysqli_query($con,"select * reports"); $fdf = '%fdf-1.2 1 0 obj<</fdf<< /fields[ <</t(clicks)/v('.$clicks.')>> <</t(impressions)/v('.$impressions.')>> <</t(cost)/v('.$cost.')>> <</t(keyword1)/v('.$keyword1.')>> <</t(clicks1)/v('.$clicks1.')>> <</t(cost1)/v('.$cost1.')>> <</t(keyword2)/v('.$keyword2.')>> <</t(clicks2)/v('.$clicks2.')>> <</t(cost2)/v('.$cost2.')>> ] >> >> endobj trailer <</root 1 0 r>> %%eof'; file_put_contents('fields.fdf', $fdf); $results = shell_exec("pdftk report.pdf fill_form fields.fdf output report_final.pdf flatten");

php mysql pdf pdftk fdf

No comments:

Post a Comment