1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
|
<HTML
><HEAD
><TITLE
>Forms Data Format functions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.57"><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"><META
NAME="HTTP_EQUIV"
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
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"
>XXI. Forms Data Format functions</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN12134"
></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
>
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 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
> whicht 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 documention 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
><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"
><A
NAME="AEN12157"
></A
><P
><B
>Example 1. Evaluating a FDF document</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
> <?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);
?>
</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
><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-opt.html"
>fdf_set_opt</A
> — Sets an option of a field</DT
><DT
><A
HREF="function.fdf-set-submit-form-action.html"
>fdf_set_submit_form_action</A
> — Sets an javascript action 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
></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
>
|