<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Forms Data Format Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="函数参考" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="fam_suspend_monitor" HREF="function.fam-suspend-monitor.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=UTF-8"></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 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.fam-suspend-monitor.html" ACCESSKEY="P" >上一页</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" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.fdf" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XXXVII. Forms Data Format Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN49425" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.intro" >简介</A ></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/acrobat/forms.jsp" TARGET="_top" >http://partners.adobe.com/asn/acrobat/forms.jsp</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 ></H1 ><P > You need the FDF toolkit SDK available from <A HREF="http://partners.adobe.com/asn/acrobat/forms.jsp" TARGET="_top" >http://partners.adobe.com/asn/acrobat/forms.jsp</A >. As of PHP 4.3.0 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 ></H1 ><P > You must compile PHP with <CODE CLASS="option" >--with-fdftk[=DIR]</CODE >. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </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 <CODE CLASS="option" >--with-fdftk=/usr/local</CODE >. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note to Win32 Users: </B > In order for this extension to work, there are <ACRONYM CLASS="acronym" >DLL</ACRONYM > files that must be available to the Windows system <TT CLASS="literal" >PATH</TT >. See the <ACRONYM CLASS="acronym" >FAQ</ACRONYM > titled "<A HREF="faq.installation.html#faq.installation.addtopath" >How do I add my PHP directory to the PATH on Windows</A >" for information on how to do this. Although copying DLL files from the PHP folder into the Windows system directory also works (because the system directory is by default in the systems <TT CLASS="literal" >PATH</TT >), it is not recommended. <SPAN CLASS="emphasis" ><I CLASS="emphasis" >This extension requires the following files to be in the <TT CLASS="literal" >PATH</TT >:</I ></SPAN > <TT CLASS="filename" >fdftk.dll</TT > </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.configuration" >运行时配置</A ></H1 ><P >本扩展模块在 <TT CLASS="filename" >php.ini</TT > 中未定义任何配置选项。</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.resources" >资源类型</A ></H1 ><DIV CLASS="section" ><H2 CLASS="section" ><A NAME="fdf.resources.fdf" >fdf</A ></H2 ><P > Most fdf functions require a <CODE CLASS="parameter" >fdf</CODE > resource as their first parameter. A <CODE CLASS="parameter" >fdf</CODE > resource is a handle to an opened fdf file. <CODE CLASS="parameter" >fdf</CODE > 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 ></H1 ><P >以下常量由本扩展模块定义,因此只有在本扩展模块被编译到 PHP 中,或者在运行时被动态加载后才有效。</P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >FDFValue</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFStatus</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFFile</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFID</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFFf</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFSetFf</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFClearFf</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFFlags</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFSetF</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFClrF</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFAP</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFAS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFAction</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFAA</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFAPRef</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFIF</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFEnter</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFExit</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFDown</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFUp</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFFormat</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFValidate</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFKeystroke</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFCalculate</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFNormalAP</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFRolloverAP</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FDFDownAP</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="fdf.examples" >范例</A ></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="AEN49658" ></A ><P ><B >例 1. Evaluating a FDF document</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#FF8000">// Open fdf from input string provided by the extension<br />// The pdf form contained several input text fields with the names<br />// volume, date, comment, publisher, preparer, and two checkboxes<br />// show_publisher and show_preparer.<br /></font><font color="#0000BB">$fdf </font><font color="#007700">= </font><font color="#0000BB">fdf_open_string</font><font color="#007700">(</font><font color="#0000BB">$HTTP_FDF_DATA</font><font color="#007700">);<br /></font><font color="#0000BB">$volume </font><font color="#007700">= </font><font color="#0000BB">fdf_get_value</font><font color="#007700">(</font><font color="#0000BB">$fdf</font><font color="#007700">, </font><font color="#DD0000">"volume"</font><font color="#007700">);<br />echo </font><font color="#DD0000">"The volume field has the value '<b>$volume</b>'<br />"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$date </font><font color="#007700">= </font><font color="#0000BB">fdf_get_value</font><font color="#007700">(</font><font color="#0000BB">$fdf</font><font color="#007700">, </font><font color="#DD0000">"date"</font><font color="#007700">);<br />echo </font><font color="#DD0000">"The date field has the value '<b>$date</b>'<br />"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$comment </font><font color="#007700">= </font><font color="#0000BB">fdf_get_value</font><font color="#007700">(</font><font color="#0000BB">$fdf</font><font color="#007700">, </font><font color="#DD0000">"comment"</font><font color="#007700">);<br />echo </font><font color="#DD0000">"The comment field has the value '<b>$comment</b>'<br />"</font><font color="#007700">;<br /><br />if (</font><font color="#0000BB">fdf_get_value</font><font color="#007700">(</font><font color="#0000BB">$fdf</font><font color="#007700">, </font><font color="#DD0000">"show_publisher"</font><font color="#007700">) == </font><font color="#DD0000">"On"</font><font color="#007700">) {<br /> </font><font color="#0000BB">$publisher </font><font color="#007700">= </font><font color="#0000BB">fdf_get_value</font><font color="#007700">(</font><font color="#0000BB">$fdf</font><font color="#007700">, </font><font color="#DD0000">"publisher"</font><font color="#007700">);<br /> echo </font><font color="#DD0000">"The publisher field has the value '<b>$publisher</b>'<br />"</font><font color="#007700">;<br />} else<br /> echo </font><font color="#DD0000">"Publisher shall not be shown.<br />"</font><font color="#007700">;<br /><br />if (</font><font color="#0000BB">fdf_get_value</font><font color="#007700">(</font><font color="#0000BB">$fdf</font><font color="#007700">, </font><font color="#DD0000">"show_preparer"</font><font color="#007700">) == </font><font color="#DD0000">"On"</font><font color="#007700">) {<br /> </font><font color="#0000BB">$preparer </font><font color="#007700">= </font><font color="#0000BB">fdf_get_value</font><font color="#007700">(</font><font color="#0000BB">$fdf</font><font color="#007700">, </font><font color="#DD0000">"preparer"</font><font color="#007700">);<br /> echo </font><font color="#DD0000">"The preparer field has the value '<b>$preparer</b>'<br />"</font><font color="#007700">;<br />} else<br /> echo </font><font color="#DD0000">"Preparer shall not be shown.<br />"</font><font color="#007700">;<br /></font><font color="#0000BB">fdf_close</font><font color="#007700">(</font><font color="#0000BB">$fdf</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >目录</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-enum-values.html" >fdf_enum_values</A > -- Call a user defined function for each document value </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-flags.html" >fdf_get_flags</A > -- Gets the flags of a field</DT ><DT ><A HREF="function.fdf-get-opt.html" >fdf_get_opt</A > -- Gets a value from the opt array of a field</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-remove-item.html" >fdf_remove_item</A > -- Sets target frame for form</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-on-import-javascript.html" >fdf_set_on_import_javascript</A > -- Adds javascript code to be executed when Acrobat opens the FDF</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.fam-suspend-monitor.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.fdf-add-doc-javascript.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >fam_suspend_monitor</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >fdf_add_doc_javascript</TD ></TR ></TABLE ></DIV ></BODY ></HTML >