<HTML ><HEAD ><TITLE >Forms Data Format functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Function Reference" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="unlink" HREF="function.unlink.html"><LINK REL="NEXT" TITLE="fdf_add_doc_javascript" HREF="function.fdf-add-doc-javascript.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation 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" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.fdf-add-doc-javascript.html" ACCESSKEY="N" >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" >XXXI. Forms Data Format functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN27160" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.intro" ></A >Introduction</H1 ><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 ><P > The general idea of FDF is similar to HTML forms. The difference is basically the format how 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 <TT CLASS="literal" >application/vnd.fdf</TT >. 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 > If you look at an FDF-document with a text editor you will find a catalogue object with the name <TT CLASS="literal" >FDF</TT >. Such an object may contain a number of entries like <TT CLASS="literal" >Fields</TT >, <TT CLASS="literal" >F</TT >, <TT CLASS="literal" >Status</TT > etc.. The most commonly used entries are <TT CLASS="literal" >Fields</TT > which points to a list of input fields, and <TT CLASS="literal" >F</TT > which contains the filename of the PDF-document this data belongs to. Those entries are referred to in the FDF documentation as /F-Key or /Status-Key. Modifying this entries is done by functions like <A HREF="function.fdf-set-file.html" ><B CLASS="function" >fdf_set_file()</B ></A > and <A HREF="function.fdf-set-status.html" ><B CLASS="function" >fdf_set_status()</B ></A >. Fields are modified with <A HREF="function.fdf-set-value.html" ><B CLASS="function" >fdf_set_value()</B ></A >, <A HREF="function.fdf-set-opt.html" ><B CLASS="function" >fdf_set_opt()</B ></A > etc.. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.requirements" ></A >Requirements</H1 ><P > You need the FDF toolkit SDK available from <A HREF="http://partners.adobe.com/asn/developer/acrosdk/forms.html" TARGET="_top" >http://partners.adobe.com/asn/developer/acrosdk/forms.html</A >. As of PHP 4.3 you need at least SDK version 5.0. The FDF toolkit library is available in binary form only, platforms supported by Adobe are Win32, Linux, Solaris and AIX. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.installation" ></A >Installation</H1 ><P > You must compile PHP with <TT CLASS="option" >--with-fdftk[=DIR]</TT >. </P ><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 <TT CLASS="filename" >fdftk.h</TT > and the library <TT CLASS="filename" >libfdftk.so</TT > are at the right place. The configure script supports both the directory structure of the FDF SDK distribution and the usual <TT CLASS="filename" >DIR/include</TT > / <TT CLASS="filename" >DIR/lib</TT > layout, so you can point it either directly to the unpacked distribution directory or put the header file and the appropriate library for your platform into e.g. <TT CLASS="filename" >/usr/local/include</TT > and <TT CLASS="filename" >/usr/local/lib</TT > and configure with <TT CLASS="literal" >--with-fdftk=/usr/local</TT >. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note to Win32 Users: </B > In order to enable this module on a Windows environment, you must copy <SPAN CLASS="emphasis" ><I CLASS="emphasis" >fdftk.dll</I ></SPAN > from the DLL folder of the PHP/Win32 binary package to the SYSTEM32 folder of your windows machine. (Ex: C:\WINNT\SYSTEM32 or C:\WINDOWS\SYSTEM32) </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.configuration" ></A >Runtime Configuration</H1 ><P >This extension has no configuration directives defined in <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.resources" ></A >Resource Types</H1 ><DIV CLASS="section" ><H2 CLASS="section" ><A NAME="fdf.resources.fdf" ></A >fdf</H2 ><P > Most fdf functions require a <TT CLASS="parameter" ><I >fdf</I ></TT > resource as their first parameter. A <TT CLASS="parameter" ><I >fdf</I ></TT > resource is a handle to an opened fdf file. <TT CLASS="parameter" ><I >fdf</I ></TT > resources may be obtained using <A HREF="function.fdf-create.html" ><B CLASS="function" >fdf_create()</B ></A >, <A HREF="function.fdf-open.html" ><B CLASS="function" >fdf_open()</B ></A > and <A HREF="function.fdf-open-string.html" ><B CLASS="function" >fdf_open_string()</B ></A >. </P ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.constants" ></A >Predefined Constants</H1 ><P > The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. </P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >FDFValue</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFStatus</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFFile</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFID</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFFf</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFSetFf</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFClearFf</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFFlags</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFSetF</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFClrF</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFAP</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFAS</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFAction</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFAA</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFAPRef</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFIF</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFEnter</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFExit</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFDown</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFUp</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFFormat</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFValidate</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFKeystroke</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFCalculate</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFNormalAP</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFRolloverAP</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFDownAP</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.examples" ></A >Examples</H1 ><P > The following examples shows just the evaluation of form data. <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN27386" ></A ><P ><B >Example 1. Evaluating a FDF document</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php // Open fdf from input string provided by the extension // 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_string($HTTP_FDF_DATA); $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); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</B ></DT ><DT ><A HREF="function.fdf-add-doc-javascript.html" >fdf_add_doc_javascript</A > -- Adds javascript code to the FDF document</DT ><DT ><A HREF="function.fdf-add-template.html" >fdf_add_template</A > -- Adds a template into the 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-errno.html" >fdf_errno</A > -- Return error code for last fdf operation</DT ><DT ><A HREF="function.fdf-error.html" >fdf_error</A > -- Return error description for fdf error code</DT ><DT ><A HREF="function.fdf-get-ap.html" >fdf_get_ap</A > -- Get the appearance of a field</DT ><DT ><A HREF="function.fdf-get-attachment.html" >fdf_get_attachment</A > -- Extracts uploaded file embedded in the FDF</DT ><DT ><A HREF="function.fdf-get-encoding.html" >fdf_get_encoding</A > -- Get the value of the /Encoding key</DT ><DT ><A HREF="function.fdf-get-file.html" >fdf_get_file</A > -- Get the value of the /F 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-get-value.html" >fdf_get_value</A > -- Get the value of a field</DT ><DT ><A HREF="function.fdf-get-version.html" >fdf_get_version</A > -- Gets version number for FDF api or file </DT ><DT ><A HREF="function.fdf-header.html" >fdf_header</A > -- Sets FDF-specific output headers</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-open-string.html" >fdf_open_string</A > -- Read a FDF document from a string</DT ><DT ><A HREF="function.fdf-open.html" >fdf_open</A > -- Open a FDF document</DT ><DT ><A HREF="function.fdf-save-string.html" >fdf_save_string</A > -- Returns the FDF document as a string</DT ><DT ><A HREF="function.fdf-save.html" >fdf_save</A > -- Save a FDF document</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-encoding.html" >fdf_set_encoding</A > -- Sets FDF character encoding</DT ><DT ><A HREF="function.fdf-set-file.html" >fdf_set_file</A > -- Set PDF document to display FDF data in</DT ><DT ><A HREF="function.fdf-set-flags.html" >fdf_set_flags</A > -- Sets a flag of a field</DT ><DT ><A HREF="function.fdf-set-javascript-action.html" >fdf_set_javascript_action</A > -- Sets an javascript action of a field</DT ><DT ><A HREF="function.fdf-set-opt.html" >fdf_set_opt</A > -- Sets an option 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-set-submit-form-action.html" >fdf_set_submit_form_action</A > -- Sets a submit form action of a field</DT ><DT ><A HREF="function.fdf-set-target-frame.html" >fdf_set_target_frame</A > -- Set target frame for form display</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-set-version.html" >fdf_set_version</A > -- Sets version number for a FDF file </DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.unlink.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.fdf-add-doc-javascript.html" ACCESSKEY="N" >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" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >fdf_add_doc_javascript</TD ></TR ></TABLE ></DIV ></BODY ></HTML >