<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id='function.fdf-add-doc-javascript' xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>fdf_add_doc_javascript</refname>
  <refpurpose>Adds javascript code to the FDF document</refpurpose>
 </refnamediv>
 
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>bool</type><methodname>fdf_add_doc_javascript</methodname>
   <methodparam><type>resource</type><parameter>fdf_document</parameter></methodparam>
   <methodparam><type>string</type><parameter>script_name</parameter></methodparam>
   <methodparam><type>string</type><parameter>script_code</parameter></methodparam>
  </methodsynopsis>
  <para>
   Adds a script to the FDF, which Acrobat then adds to the doc-level scripts
   of a document, once the FDF is imported into it. 
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>fdf_document</parameter></term>
     <listitem>
      <para>
       The FDF document handle, returned by <function>fdf_create</function>,
       <function>fdf_open</function> or <function>fdf_open_string</function>.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>script_name</parameter></term>
     <listitem>
      <para>
       The script name.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>script_code</parameter></term>
     <listitem>
      <para>
       The script code. It is strongly suggested to use <literal>\r</literal>
       for linebreaks within the script code.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &return.success;
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>Adding JavaScript code to a FDF</title>
    <programlisting role="php">
<![CDATA[
<?php
$fdf = fdf_create();
fdf_add_doc_javascript($fdf, "PlusOne", "function PlusOne(x)\r{\r  return x+1;\r}\r");
fdf_save($fdf);
?>
]]>
    </programlisting>
    <simpara>
     will create a FDF like this:
    </simpara>
    <screen>
<![CDATA[
%FDF-1.2
%âãÏÓ
1 0 obj
<<
/FDF << /JavaScript << /Doc [ (PlusOne)(function PlusOne\(x\)\r{\r  return x+1;\r}\r)] >> >>
>>
endobj
trailer
<<
/Root 1 0 R

>>
%%EOF
]]>
    </screen>
   </example>
  </para>
 </refsect1>

</refentry>

<!-- 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:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
