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 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
|
<?xml version="1.0" encoding="utf-8"?>
<reference id="ref.fdf">
<title>Forms Data Format functions</title>
<titleabbrev>FDF</titleabbrev>
<partintro>
<simpara>
Forms Data Format (FDF) is a format for handling
forms within PDF documents. You should read the documentation at
<ulink url="&spec.pdf.fdf;">&spec.pdf.fdf;</ulink>
for more information on what FDF is and how it is used in general.
</simpara>
<note><simpara>
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.
</simpara></note>
<simpara>
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
(<function>fdf_create</function>) set the values of each input field
(<function>fdf_set_value</function>) and associate it with a PDF form
(<function>fdf_set_file</function>). Finally it has to be sent to the
browser with MimeType <literal>application/vnd.fdf</literal>. The Acrobat
reader plugin of your browser recognizes the MimeType, reads the
associated PDF form and fills in the data from the FDF document.
</simpara>
<simpara>
If you look at an FDF-document with a text editor you will find a
catalogue object with the name <literal>FDF</literal>. Such an object may
contain a number of entries like <literal>Fields</literal>,
<literal>F</literal>, <literal>Status</literal> etc..
The most commonly used entries are <literal>Fields</literal> whicht points
to a list of input fields, and <literal>F</literal> 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 <function>fdf_set_file</function> and
<function>fdf_set_status</function>. Fields are modified with
<function>fdf_set_value</function>, <function>fdf_set_opt</function> etc..
</simpara>
<simpara>
The following examples shows just the evaluation of form data.</simpara>
<simpara></simpara>
<example>
<title>Evaluating a FDF document</title>
<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);
?>
</programlisting>
</example>
</partintro>
<refentry id="function.fdf-open">
<refnamediv>
<refname>fdf_open</refname>
<refpurpose>Open a FDF document</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>fdf_open</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_open</function> function opens
a file with form data. This file must contain the data as returned
from a PDF form. Currently, the file has to be created 'manually'
by using <function>fopen</function> and writing the content
of HTTP_FDF_DATA with <function>fwrite</function> into it.
A mechanism like for HTML form data where for each input
field a variable is created does not exist.</para>
<para>
<example>
<title>Accessing the form data</title>
<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
$fdf = fdf_open("test.fdf");
...
fdf_close($fdf);
?>
</programlisting>
</example></para>
<para>
See also <function>fdf_close</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-close">
<refnamediv>
<refname>fdf_close</refname>
<refpurpose>Close an FDF document</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>fdf_close</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_close</function> function closes the FDF document.</para>
<para>
See also <function>fdf_open</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-create">
<refnamediv>
<refname>fdf_create</refname>
<refpurpose>Create a new FDF document</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>fdf_create</methodname>
<methodparam><type>void</type><parameter/></methodparam>
</methodsynopsis>
<para>
The <function>fdf_create</function> creates a new
FDF document. This function is needed if one would like to
populate input fields in a PDF document with data.</para>
<para>
<example>
<title>Populating a PDF document</title>
<programlisting>
<?php
$outfdf = fdf_create();
fdf_set_value($outfdf, "volume", $volume, 0);
fdf_set_file($outfdf, "http:/testfdf/resultlabel.pdf");
fdf_save($outfdf, "outtest.fdf");
fdf_close($outfdf);
Header("Content-type: application/vnd.fdf");
$fp = fopen("outtest.fdf", "r");
fpassthru($fp);
unlink("outtest.fdf");
?>
</programlisting>
</example></para>
<para>
See also <function>fdf_close</function>,
<function>fdf_save</function>,
<function>fdf_open</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-save">
<refnamediv>
<refname>fdf_save</refname>
<refpurpose>Save a FDF document</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>fdf_save</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_save</function> function saves
a FDF document.
The FDF Toolkit provides a way to output the document to stdout if
the parameter <parameter>filename</parameter>
is '.'. This does not work if PHP is used as an apache module.
In such a case one will have to write to a file and use e.g.
<function>fpassthru</function>. to output it.</para>
<para>
See also <function>fdf_close</function> and example for
<function>fdf_create</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-get-value">
<refnamediv>
<refname>fdf_get_value</refname>
<refpurpose>Get the value of a field</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>fdf_get_value</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
<methodparam><type>string</type><parameter>fieldname</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_get_value</function> function returns the
value of a field.</para>
<para>
See also <function>fdf_set_value</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-set-value">
<refnamediv>
<refname>fdf_set_value</refname>
<refpurpose>Set the value of a field</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>fdf_set_value</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
<methodparam><type>string</type><parameter>fieldname</parameter></methodparam>
<methodparam><type>string</type><parameter>value</parameter></methodparam>
<methodparam><type>int</type><parameter>isName</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_set_value</function> function sets the
value of a field. The last parameter determines if the field value
is to be converted to a PDF Name (<parameter>isName</parameter> = 1)
or set to a PDF String (<parameter>isName</parameter> = 0).</para>
<para>
See also <function>fdf_get_value</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-next-field-name">
<refnamediv>
<refname>fdf_next_field_name</refname>
<refpurpose>Get the next field name</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>fdf_next_field_name</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
<methodparam><type>string</type><parameter>fieldname</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_next_field_name</function> function returns the
name of the field after the field in
<parameter>fieldname</parameter> or the field name of the first field
if the second paramter is &null;.</para>
<para>
See also <function>fdf_set_field</function>,
<function>fdf_get_field</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-set-ap">
<refnamediv>
<refname>fdf_set_ap</refname>
<refpurpose>Set the appearance of a field</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>fdf_set_ap</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
<methodparam><type>string</type><parameter>field_name</parameter></methodparam>
<methodparam><type>int</type><parameter>face</parameter></methodparam>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
<methodparam><type>int</type><parameter>page_number</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_set_ap</function> function sets the
appearance of a field (i.e. the value of the /AP key).
The possible values of <parameter>face</parameter>
are 1=FDFNormalAP, 2=FDFRolloverAP, 3=FDFDownAP.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-set-status">
<refnamediv>
<refname>fdf_set_status</refname>
<refpurpose>Set the value of the /STATUS key</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>fdf_set_status</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
<methodparam><type>string</type><parameter>status</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_set_status</function> sets the value
of the /STATUS key.</para>
<para>
See also <function>fdf_get_status</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-get-status">
<refnamediv>
<refname>fdf_get_status</refname>
<refpurpose>Get the value of the /STATUS key</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>fdf_get_status</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_get_status</function> returns the value
of the /STATUS key.</para>
<para>
See also <function>fdf_set_status</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-set-file">
<refnamediv>
<refname>fdf_set_file</refname>
<refpurpose>Set the value of the /F key</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>fdf_set_file</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_set_file</function> sets the value
of the /F key. The /F key is just a reference to a PDF form
which is to be populated with data.
In a web environment it is a URL (e.g. http:/testfdf/resultlabel.pdf).</para>
<para>
See also <function>fdf_get_file</function> and example for
<function>fdf_create</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-get-file">
<refnamediv>
<refname>fdf_get_file</refname>
<refpurpose>Get the value of the /F key</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>fdf_get_file</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_set_file</function> returns the value
of the /F key.</para>
<para>
See also <function>fdf_set_file</function>.</para>
</refsect1>
</refentry>
<refentry id="function.fdf-set-flags">
<refnamediv>
<refname>fdf_set_flags</refname>
<refpurpose>Sets a flag of a field</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>fdf_set_flags</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
<methodparam><type>string</type><parameter>fieldname</parameter></methodparam>
<methodparam><type>int</type><parameter>whichFlags</parameter></methodparam>
<methodparam><type>int</type><parameter>newFlags</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_set_flags</function> sets certain flags
of the given field <parameter>fieldname</parameter>.
</para>
<para>
See also <function>fdf_set_opt</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fdf-set-opt">
<refnamediv>
<refname>fdf_set_opt</refname>
<refpurpose>Sets an option of a field</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>fdf_set_opt</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
<methodparam><type>string</type><parameter>fieldname</parameter></methodparam>
<methodparam><type>int</type><parameter>element</parameter></methodparam>
<methodparam><type>string</type><parameter>str1</parameter></methodparam>
<methodparam><type>string</type><parameter>str2</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_set_opt</function> sets options
of the given field <parameter>fieldname</parameter>.
</para>
<para>
See also <function>fdf_set_flags</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fdf-set-submit-form-action">
<refnamediv>
<refname>fdf_set_submit_form_action</refname>
<refpurpose>Sets an javascript action of a field</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>fdf_set_submit_form_action</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
<methodparam><type>string</type><parameter>fieldname</parameter></methodparam>
<methodparam><type>int</type><parameter>trigger</parameter></methodparam>
<methodparam><type>string</type><parameter>script</parameter></methodparam>
<methodparam><type>int</type><parameter>flags</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_set_submit_form_action</function> sets a submit form
action for the given field <parameter>fieldname</parameter>.
</para>
<para>
See also <function>fdf_set_javascript_action</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fdf-set-javascript-action">
<refnamediv>
<refname>fdf_set_javascript_action</refname>
<refpurpose>Sets an javascript action of a field</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>fdf_set_javascript_action</methodname>
<methodparam><type>int</type><parameter>fdf_document</parameter></methodparam>
<methodparam><type>string</type><parameter>fieldname</parameter></methodparam>
<methodparam><type>int</type><parameter>trigger</parameter></methodparam>
<methodparam><type>string</type><parameter>script</parameter></methodparam>
</methodsynopsis>
<para>
The <function>fdf_set_javascript_action</function> sets a javascript
action for the given field <parameter>fieldname</parameter>.
</para>
<para>
See also <function>fdf_set_submit_form_action</function>.
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
|