Page 1 of 1

same code, different server, different result ... pls help

Posted: Tue May 03, 2011 11:09 am
by inosent
I have three web pages and one pdf template. The purpose of this is to have a user fill in the from, click submit and have the form contents flow into the pdf file and then render the pdf onscreen so the user can print it out, etc

Here is the initial form page:

Code: Select all

 <?php
    include dirname<__FILE__>.'/mod_process.php';
    echo '<?xml version="1.0" encoding="iso-8859-1"?>',"\n";    // because short_open_tags = On causes a parse error.
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body bgcolor="#FFFFFF" onload__="MM_preloadImages<'textA.gif','closeB.jpg','closeA.jpg'>;checkFreeForm<document.getElementById<'agent_name'>>;" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">

<div id="application">

<?php
    if<isset<$CREATED>>{
?>
   <span class="style4">
    <h1>Your Result</h1>
    <p><a href="<?php echo str_replace<dirname<__FILE__>.'/','',$fdf_file> ?>">Click here to create forms package.</a> </p>
   </span>
<?php
    }
?>
  

<form method="POST" autocomplete="on" NAME="smartform" target="_parent" action="<?php echo $_SERVER['REQUEST_URI'] ?>" onsubmit__="return Validator<smartform>; clickedButton"><a NAME="tab1"></a>
  <center>
<center>
    <table BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH="620" bordercolor="#003399" >

      <tr>

        <td bgcolor="#7C96A5"> 
          <center>
            <a NAME="tab7"></a><span class="style2"><b>BORROWER INFORMATION</b></span>
          </center>
</td>
</tr>
</table>
    

    <table border=0 width="620" align="center" >

  <tr> 
        <td width="51">
        <td width="112"> </td>
        <td width="221"><span class="style4"><b>  Borrower</b></span></td>
        <td width="222"><span class="style4"><b>  Co-Borrower</b></span></td>

  </tr>

  <tr> 
        <td width="51">
</td>
        <td width="112" bgcolor="#E8EBEE"> 
          <div align=right><span class="style4">First Name: </span></div>
    </td>
        <td width="221" bgcolor="#F7F7F7"> <span class="style4"> 
          <input class="left" onblur__="mark<this,'#ffffff','#000000'>" name="b_fname" size="20" maxlength="40" onfocus__="nextfield ='cb_fname'; mark<this,'#FFFF99','#0000FF'>">
          </span> </td>

        <td width="222" bgcolor="#E8EBEE"> <span class="style4"> 
          <input class="left" onblur__="mark<this,'#ffffff','#000000'>" name="cb_fname" size="20" maxlength="40" onfocus__="nextfield ='b_lname'; mark<this,'#FFFF99','#0000FF'>">
      </span> </td>
  </tr>
</tr>
</table>


<center>

    Submission Date: <input type="date" name="creation_date" size="10">

<p><input TYPE="submit" name="submit" value="Submit" onclick__="clickedButton=true">
    

  </center>

  <p>

  <p>

    <input type="hidden" name="MM_insert" value="smartform">
  </form>
<table width="620" border="0" cellspacing="2" cellpadding="0" align="center">

</table>
</div>

</body>
</html>

this is the file that takes the form contents and turns it into an FDF file, which is read by a PDF file:

Code: Select all



<?php

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;
}
?>


last, this is the mod_process.php file that somehow marries the fdf to the pdf and enables an onscreen rendering of the pdf file. It seems to work on one site, but not at the other.

i am trying to figure out

1) how to make the fdf file connect to the pdf file so i can have 100% consistency no matter where the files are hosted

or

2) how to tweak the code so when i click the results link i always get the pdf fil

Code: Select all


<?php
    require_once 'createFDF.php';
  $pdf_file='http://www.americanlaw1.com/apdf/v12.pdf';

    // allow for up to 25 different files to be created, based on the minute
    $min=date('i') % 25;
    
$fdf_file=dirname(__FILE__).'/results/posted-'.$min.'.fdf';
    if(isset($_POST['b_fname'])){
        $_POST['b_cphone']=$_POST['b_cphone'];

        // get the FDF file contents
        $fdf=createFDF($pdf_file,$_POST);

        // Create a file for later use
        if($fp=fopen($fdf_file,'w')){
            fwrite($fp,$fdf,strlen($fdf));
            $CREATED=TRUE;
        }else{
            echo 'Unable to create file: '.$fdf_file.'<br><br>';
            $CREATED=FALSE;
        }
        fclose($fp);
    }
?>



Re: same code, different server, different result ... pls he

Posted: Thu May 05, 2011 3:44 am
by JakeJ
echo phpinfo();

Run that on both servers to see if you're missing a key component on the server it's not working on.

Personally, I prefer TCPDF for pdf creation on the server. But the learning curve can be a bit steep.

Re: same code, different server, different result ... pls he

Posted: Mon May 09, 2011 11:35 am
by inosent1
Hi

if i had a working example of TCPDF i would probably agree.

i did figure out the issue. i placed a .htaccess file in the folder containing the fdf file with a comment 'ForceType application/vnd.fdf' comment