<HTML ><HEAD ><TITLE >Forms Data Format functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK REL="HOME" TITLE="PHP Manual" HREF="manual.html"><LINK REL="UP" TITLE="Function Reference" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="unlink" HREF="function.unlink.html"><LINK REL="NEXT" TITLE="fdf_open" HREF="function.fdf-open.html"></HEAD ><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.unlink.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.fdf-open.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.fdf" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XVII. Forms Data Format functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN9508" ></A ><P > Forms Data Format (FDF) is a format for handling forms within PDF documents. You should read the documentation at <A HREF="http://partners.adobe.com/asn/developer/acrosdk/forms.html" TARGET="_top" >http://partners.adobe.com/asn/developer/acrosdk/forms.html</A > for more information on what FDF is and how it is used in general.</P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > 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. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > If you run into problems configuring php with fdftk support, check whether the header file FdfTk.h and the library libFdfTk.so are at the right place. They should be in fdftk-dir/include and fdftk-dir/lib. This will not be the case if you just unpack the FdfTk distribution. </P ></BLOCKQUOTE ></DIV ><P > 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 (<A HREF="function.fdf-create.html" ><B CLASS="function" >fdf_create()</B ></A >) set the values of each input field (<A HREF="function.fdf-set-value.html" ><B CLASS="function" >fdf_set_value()</B ></A >) and associate it with a PDF form (<A HREF="function.fdf-set-file.html" ><B CLASS="function" >fdf_set_file()</B ></A >). 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.</P ><P > The following examples shows just the evaluation of form data.</P ><P ></P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><P ><B >Example 1. Evaluating a FDF document</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="programlisting" > 1 2 <?php 3 // Save the FDF data into a temp file 4 $fdffp = fopen("test.fdf", "w"); 5 fwrite($fdffp, $HTTP_FDF_DATA, strlen($HTTP_FDF_DATA)); 6 fclose($fdffp); 7 8 // Open temp file and evaluate data 9 // The pdf form contained several input text fields with the names 10 // volume, date, comment, publisher, preparer, and two checkboxes 11 // show_publisher and show_preparer. 12 $fdf = fdf_open("test.fdf"); 13 $volume = fdf_get_value($fdf, "volume"); 14 echo "The volume field has the value '<B>$volume</B>'<BR>"; 15 16 $date = fdf_get_value($fdf, "date"); 17 echo "The date field has the value '<B>$date</B>'<BR>"; 18 19 $comment = fdf_get_value($fdf, "comment"); 20 echo "The comment field has the value '<B>$comment</B>'<BR>"; 21 22 if(fdf_get_value($fdf, "show_publisher") == "On") { 23 $publisher = fdf_get_value($fdf, "publisher"); 24 echo "The publisher field has the value '<B>$publisher</B>'<BR>"; 25 } else 26 echo "Publisher shall not be shown.<BR>"; 27 28 if(fdf_get_value($fdf, "show_preparer") == "On") { 29 $preparer = fdf_get_value($fdf, "preparer"); 30 echo "The preparer field has the value '<B>$preparer</B>'<BR>"; 31 } else 32 echo "Preparer shall not be shown.<BR>"; 33 fdf_close($fdf); 34 ?> 35 </PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</B ></DT ><DT ><A HREF="function.fdf-open.html" >fdf_open</A > — Open a FDF document</DT ><DT ><A HREF="function.fdf-close.html" >fdf_close</A > — Close an FDF document</DT ><DT ><A HREF="function.fdf-create.html" >fdf_create</A > — Create a new FDF document</DT ><DT ><A HREF="function.fdf-save.html" >fdf_save</A > — Save a FDF document</DT ><DT ><A HREF="function.fdf-get-value.html" >fdf_get_value</A > — Get the value of a field</DT ><DT ><A HREF="function.fdf-set-value.html" >fdf_set_value</A > — Set the value of a field</DT ><DT ><A HREF="function.fdf-next-field-name.html" >fdf_next_field_name</A > — Get the next field name</DT ><DT ><A HREF="function.fdf-set-ap.html" >fdf_set_ap</A > — Set the appearance of a field</DT ><DT ><A HREF="function.fdf-set-status.html" >fdf_set_status</A > — Set the value of the /STATUS key</DT ><DT ><A HREF="function.fdf-get-status.html" >fdf_get_status</A > — Get the value of the /STATUS key</DT ><DT ><A HREF="function.fdf-set-file.html" >fdf_set_file</A > — Set the value of the /F key</DT ><DT ><A HREF="function.fdf-get-file.html" >fdf_get_file</A > — Get the value of the /F key</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.unlink.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="manual.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.fdf-open.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >unlink</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >fdf_open</TD ></TR ></TABLE ></DIV ></BODY ></HTML >