so what's the error you are facing? and do you need to convert html into pdf ? thanks, Aminul On Sun, Nov 2, 2008 at 7:56 PM, birgunj birgunj <birgunjp0071@xxxxxxxxx>wrote: > i want to fill the pdf form field with php script.for this i created the > fdf document which fill the pdf form filed. > but i want to open the fill pdf form field in browser.if we able to open > the fdf document in browser ,the filled pdf form automatically open. > i am sending my code.please provide me any idea or solution. > > 1. > <form method="post" action="submit_form.php"> > <fieldset> > <table> > <tr><td>Enter Your Name</td><td><input type="text" name="Text2" > /></td></tr> > <tr><td>Favorite Color</td><td><input type="text" name="Text3" > /></td></tr> > <tr><td>Age</td><td><input type="text" name="Text4" /></td></tr> > </table> > <p> > <b>Comments:</b><br /> > <textarea name="Text5" rows="5" cols="35"></textarea> > </p> > <input type="submit" value="Generate FDF Data" /> > </fieldset> > </form> > > 2. > > <?php > // check that a form was submitted > if(isset($_POST) && is_array($_POST) && count($_POST)){ > // we will use this array to pass to the createFDF function > $data=array(); > > // This displays all the data that was submitted. You can > // remove this without effecting how the FDF data is generated. > echo'<pre>POST '; print_r($_POST);echo '</pre>'; > > if(isset($_POST['Text2'])){ > // the name field was submitted > $pat='`[^a-z0-9\s]+$`i'; > if(empty($_POST['Text2']) || preg_match($pat,$_POST['Text2'])){ > // no value was submitted or something other than a > // number, letter or space was included > die('Invalid input for Text2 field.'); > }else{ > // if this passed our tests, this is safe > $data['Text2']=$_POST['Text2']; > } > > if(!isset($_POST['Text3'])){ > // Why this? What if someone is spoofing form submissions > // to see how your script works? Only allow the script to > // continue with expected data, don't be lazy and insecure > ;) > die('You did not submit the correct form.'); > } > > // Check your data for ALL FIELDS that you expect, ignore ones > you > // don't care about. This is just an example to illustrate, so > I > // won't check anymore, but I will add them blindly (you don't > want > // to do this in a production environment). > $data['Text3']=$_POST['Text3']; > $data['Text4']=$_POST['Text4']; > $data['Text5']=$_POST['Text5']; > > // I wanted to add the date to the submissions > $data['Text1']=date('Y-m-d H:i:s'); > > // if we got here, the data should be valid, > // time to create our FDF file contents > > // need the function definition > require_once 'createFDF.php'; > > // some variables to use > > // file name will be <the current timestamp>.fdf > $fdf_file=time().'.fdf'; > > // the directory to write the result in > $fdf_dir=dirname(__FILE__).'/results'; > > // need to know what file the data will go into > $pdf_doc='Project3.pdf'; > > // generate the file content > $fdf_data=createFDF($pdf_doc,$data); > > // this is where you'd do any custom handling of the data > // if you wanted to put it in a database, email the > // FDF data, push ti back to the user with a header() call, > etc. > > // write the file out > $tfile=$fdf_dir.'/'.$fdf_file; > if($fp=fopen($fdf_dir.'/'.$fdf_file,'w')){ > fwrite($fp,$fdf_data,strlen($fdf_data)); > echo $fdf_file,' written successfully.'; > }else{ > die('Unable to create file: '..$fdf_dir.'/'.$fdf_file); > } > fclose($fp); > //$fdf= fdf_open($tfile); > //header("Content-type: application/vnd.fdf"); > //readfile($tfile); > //fdf_close($fdf); > //header('Content-type: application/vnd.fdf'); > //header('Content-Disposition: inline; > filename=1225606224.fdf'); > > header("Content-type: application/vnd.fdf"); > $fp = fopen("1225606224.fdf", "r"); > fpassthru($fp); > unlink("1225606224.fdf"); > } > }else{ > echo 'You did not submit a form.'; > } > ?> > > 3. > > <?php > /* > KOIVI HTML Form to FDF Parser for PHP (C) 2004 Justin Koivisto > Version 2.1.2 > Last Modified: 9/12/2005 > > This library is free software; you can redistribute it and/or modify it > under the terms of the GNU Lesser General Public License as published > by > the Free Software Foundation; either version 2.1 of the License, or (at > your option) any later version. > > This library is distributed in the hope that it will be useful, but > WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY > or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public > License for more details. > > You should have received a copy of the GNU Lesser General Public > License > along with this library; if not, write to the Free Software Foundation, > Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > > Full license agreement notice can be found in the LICENSE file > contained > within this distribution package. > > Justin Koivisto > justin.koivisto@xxxxxxxxx <justin.koivisto%40gmail.com> > http://koivi.com > */ > > /* > * createFDF > * > * Takes values submitted via an HTML form and fills in the corresponding > * fields into an FDF file for use with a PDF file with form fields. > * > * @param $file The pdf file that this form is meant for. Can be either > * a url or a file path. > * @param $info The submitted values in key/value pairs. (eg. $_POST) > * @result Returns the FDF file contents for further processing. > */ > function createFDF($file,$info){ > $data="%FDF-1.2\n%âãÏÓ\n1 0 obj\n<< \n/FDF << /Fields [ "; > foreach($info as $field => $val){ > if(is_array($val)){ > $data.='<</T('.$field.')/V['; > foreach($val as $opt) > $data.='('.trim($opt).')'; > $data.=']>>'; > }else{ > $data.='<</T('.$field.')/V('.trim($val).')>>'; > } > } > $data.="] \n/F (".$file.") /ID [ <".md5(time()).">\n] >>". > " \n>> \nendobj\ntrailer\n". > "<<\n/Root 1 0 R \n\n>>\n%%EOF\n"; > return $data; > } > ?> > > thanks > > [Non-text portions of this message have been removed] > > > -- Md. Aminul Islam http://www.shopno-dinga.com Mob: 8801671670797 [Non-text portions of this message have been removed]