Forum Moderators: coopster

Message Too Old, No Replies

Open PDF, Pop. w/FDF. now what?

Need help to dynamically save populated PDF

         

jaknmekh

11:34 pm on Jan 17, 2008 (gmt 0)

10+ Year Member



Howdy,

I have figured out how to dynamically populate a PDF with FDF and everything... I would now love to Dynamically SAVE the populated PDF to the server for quick future use and NOT have to populate everytime (for distribution reasons)

So right now I have the pdf and I was thinking of a FOPEN type of function, but I couldn't pass variables into the fopen...

Here is the URL that populates --
<no urls please>

here is my FDF --

<?php
mysql_select_db($database_ControlPanel, $ControlPanel);
$query_createUser = "SELECT * FROM ent_users WHERE email = '".$_GET['email']."'";
$createUser = mysql_query($query_createUser, $ControlPanel) or die(mysql_error());
$row_createUser = mysql_fetch_assoc($createUser);
$totalRows_createUser = mysql_num_rows($createUser);
header("Content-type: application/vnd.fdf");?>

%FDF-1.2
1 0 obj
<< /FDF
<< /F(http://www.example.com/pdf/GeneralSDIRABrochure.pdf)
/Fields
[ << /T(topmostSubform[0].Page1[0].CompanyBig[0]) /V(<?php echo $row_createUser['company'];?>) >>
<< /T(topmostSubform[0].Page1[0].CompanySmallWhite[0]) /V(<?php echo $row_createUser['company'];?>) >>
<< /T(topmostSubform[0].Page1[0].CompanySmallBlack[0]) /V(<?php echo $row_createUser['company'];?>) >>
<< /T(topmostSubform[0].Page1[0].Address[0]) /V(<?php echo $row_createUser['addressMail'];?>) >>
<< /T(topmostSubform[0].Page1[0].CityStateZip[0]) /V(<?php echo $row_createUser['cityMail'].", ".$row_createUser['stateMail']." ".$row_createUser['zipMail'];?>) >>
<< /T(topmostSubform[0].Page1[0].PhoneEmail[0]) /V(<?php echo $row_createUser['phone']." ¦ ".$row_createUser['email'];?>) >>
<< /T(topmostSubform[0].Page2[0].CompanySmallWhite2[0]) /V(<?php echo $row_createUser['company'];?>) >>
<< /T(topmostSubform[0].Page2[0].Website[0]) /V(<?php echo $row_createUser['website'];?>) >>
]
>>
>>
endobj
trailer
<</Root 1 0 R>>
%%EOF

Can anyone help me dynamically save this file?

[edited by: coopster at 11:43 pm (utc) on Jan. 17, 2008]
[edit reason] generalized domain [/edit]

coopster

12:05 am on Jan 18, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, jaknmekh

How about using PHP output buffering [php.net] instead of pushing your output to the browser? Store the output in a string and write the fdf file to your filesystem using one of the Filesystem Functions [php.net].

jaknmekh

12:34 am on Jan 18, 2008 (gmt 0)

10+ Year Member



O ok, I did it...

Thanks so much thats a pretty nifty function!

Thanks.,

jaknmekh

7:38 am on Jan 18, 2008 (gmt 0)

10+ Year Member



Ok, after doing waht you suggested I am having another problem.

I was the visitor to be able to save the file and it keep the populated data.

This is how I have it working right now...

The FDF information is populated and then saved to the ob_start() which is written to the server by the fopen.

But its still a FDF file and when its called it is called as a FDF file.

How do I get the populated PDF to save as a PDF?

Thanks, Hope that makes sense.

coopster

9:09 pm on Jan 18, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, it makes sense. The FDF file contains data which is "read into" the PDF "placeholder" document. You created the FDF and were able to save that, but now you want to store the complete document, meaning the PDF after the FDF data has been read into it. This usually happens via the client application. For example, Adobe Acrobat Reader will pull the pieces together for you and display it. I am not certain how to do so using PHP (or any other languages for that matter) on the server side -- I have never had to do so. All I can offer is the direction that I might start in ... Forms Data Format Functions [php.net]