Re: need help to open fdf in browser using php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,
 
there is form in pdf formate like  user name,Full Name and comment.then i created the html form with same field like user name,Full name,comments.i want that when user enter their username,full name and comment in html form..the value of html form field should write in pdf form field and save the pdf form(document) using php.
 
example
i enter user name  =test
full name =test
coment=aaa
 
in html form.
 
i want user name,full name and comment value test ,test,aaa sholud write in pdf form field and save.
 
after saving it should open in browser
..
 
thank
humayoo

--- On Wed, 11/5/08, Aminul Islam <aminulsumon@xxxxxxxxx> wrote:

From: Aminul Islam <aminulsumon@xxxxxxxxx>
Subject: Re:  need help to open fdf in browser using php
To: php-objects@xxxxxxxxxxxxxxx
Date: Wednesday, November 5, 2008, 4:45 AM






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@ yahoo.com>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@ gmail.com <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]

 














      

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux