Forms Data Format (FDF) is a format for handling forms within PDF documents. You should read the documentation at http://partners.adobe.com/asn/developer/acrosdk/main.html for more information on what FDF is and how it is used in general.
Note: Currently Adobe only provides a libc5 compatible version for Linux. Tests with glibc2 resulted in a segmentation fault. If somebody is able to make it work, please comment on this page.
The general idea of FDF is similar to HTML forms. The diffence is basically the format how filled in data is transmitted to the server when the submit button is pressed (this is actually the Form Data Format) and the format of the form itself (which is the Portable Document Format, PDF). Processing the FDF data is one of the features provided by the fdf functions. But there is more. One may as well take an existing PDF form and populated the input fields with data without modifying the form itself. In such a case one would create a FDF document (fdf_create()) set the values of each input field (fdf_set_value()) and associate it with a PDF form (fdf_set_file()). Finally it has to be sent to the browser with MimeType application/vnd.fdf. The Acrobat reader plugin of your browser recognizes the MimeType, reads the associated PDF form and fills in the data from the FDF document.
The following examples shows just the evaluation of form data.
Example 1. Evaluating a FDF document <?php // Save the FDF data into a temp file $fdffp = fopen("test.fdf", "w"); fwrite($fdffp, $HTTP_FDF_DATA, strlen($HTTP_FDF_DATA)); fclose($fdffp); // Open temp file and evaluate data // The pdf form contained several input text fields with the names // volume, date, comment, publisher, preparer, and two checkboxes // show_publisher and show_preparer. $fdf = fdf_open("test.fdf"); $volume = fdf_get_value($fdf, "volume"); echo "The volume field has the value '<B>$volume</B>'<BR>"; $date = fdf_get_value($fdf, "date"); echo "The date field has the value '<B>$date</B>'<BR>"; $comment = fdf_get_value($fdf, "comment"); echo "The comment field has the value '<B>$comment</B>'<BR>"; if(fdf_get_value($fdf, "show_publisher") == "On") { $publisher = fdf_get_value($fdf, "publisher"); echo "The publisher field has the value '<B>$publisher</B>'<BR>"; } else echo "Publisher shall not be shown.<BR>"; if(fdf_get_value($fdf, "show_preparer") == "On") { $preparer = fdf_get_value($fdf, "preparer"); echo "The preparer field has the value '<B>$preparer</B>'<BR>"; } else echo "Preparer shall not be shown.<BR>"; fdf_close($fdf); ?> |