View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Pdf_Form
{zone-data}

{zone-data:proposer-list}
[Guillaume ORIOL|mailto:goriol@serquant.com]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - March, the 11th 2011: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_Pdf_Form is a simple component that builds interactive forms into PDF documents.
{zone-data}

{zone-data:references}
* [Adobe PDF Specification|http://www.adobe.com/devnet/pdf/pdf_reference.html]
{zone-data}

{zone-data:requirements}
Most requirements take the form of "foo will do ...." or "foo will not support ...", although different words and sentence structure might be used. Adding functionality to your proposal is requirements creep (bad), unless listed below. Discuss major changes with your team first, and then open a "feature improvement" issue against this component.

* This component *will* allow embedding an interactive form into a PDF document.
* This component *will* support the three form actions (submit-form, reset-form, import-data).
* This component *will* implement the missing Zend_Pdf_Action_JavaScript.
{zone-data}

{zone-data:dependencies}
* Zend_Pdf
{zone-data}

{zone-data:operation}
The component is instantiated with a mind-link that ...
{zone-data}

{zone-data:class-list}
* Zend_Pdf
* Zend_Pdf_Form
* Zend_Pdf_Form_Field (abstract)
* Zend_Pdf_Form_Field_Button (abstract)
* Zend_Pdf_Form_Field_Button_Push
* Zend_Pdf_Form_Field_Button_Checkbox
* Zend_Pdf_Form_Field_Button_Radio
* Zend_Pdf_Form_Field_Text
* Zend_Pdf_Form_Field_Choice
* Zend_Pdf_Form_Field_Signature
{zone-data}

{zone-data:use-cases}
||UC-01||

... (see good use cases book)
{zone-data}

{zone-data:skeletons}
{code}
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Pdf
 * @subpackage Actions
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: JavaScript.php 20096 2010-01-06 02:05:09Z bkarwin $
 */

/** Zend_Pdf_Action */
require_once 'Zend/Pdf/Action.php';


/**
 * PDF 'Execute a JavaScript script' action
 * PDF 1.3+ feature
 *
 * @package    Zend_Pdf
 * @subpackage Actions
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Pdf_Action_JavaScript extends Zend_Pdf_Action
{
    /**
     * Object constructor
     *
     * @param Zend_Pdf_Element_Dictionary $dictionary
     * @param SplObjectStorage            $processedActions  list of already processed action dictionaries, used to avoid cyclic references
     */
    public function __construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions)
    {
        parent::__construct($dictionary, $processedActions);

        if ($dictionary->JS === null) {
            require_once 'Zend/Pdf/Exception.php';
            throw new Zend_Pdf_Exception('JavaScript action dictionary entry is required');
        }
    }

    /**
     * Create new Zend_Pdf_Action_JavaScript object using specified script
     *
     * @param Zend_Pdf_Element_String|Zend_Pdf_Element_Stream|string $script
     * @return Zend_Pdf_Action_GoTo
     */
    public static function create($script)
    {
        if (is_string($script)) {
            require_once 'Zend/Pdf/Element/String.php';
            $script = new Zend_Pdf_Element_String($script);
        }

        if (!($script instanceof Zend_Pdf_Element_String) &&
            !($script instanceof Zend_Pdf_Element_Stream)
        ) {
            require_once 'Zend/Pdf/Exception.php';
            throw new Zend_Pdf_Exception('$script parameter must be either , ' .
                'a string, a Zend_Pdf_Element_String object or a ' .
                'Zend_Pdf_Element_Stream object.');
        }

        $dictionary = new Zend_Pdf_Element_Dictionary();
        $dictionary->Type = new Zend_Pdf_Element_Name('Action');
        $dictionary->S    = new Zend_Pdf_Element_Name('JavaScript');
        $dictionary->Next = null;
        $dictionary->JS   = $script;

        return new Zend_Pdf_Action_JavaScript($dictionary, new SplObjectStorage());
    }

    /**
     * Set script to execute
     *
     * @param Zend_Pdf_Element_String|Zend_Pdf_Element_Stream|string $script
     * @return Zend_Pdf_Action_JavaScript
     */
    public function setJavaScript($script)
    {
        if (is_string($script)) {
            require_once 'Zend/Pdf/Element/String.php';
            $script = new Zend_Pdf_Element_String($script);
        }

        if (!($script instanceof Zend_Pdf_Element_String) &&
            !($script instanceof Zend_Pdf_Element_Stream)
        ) {
            require_once 'Zend/Pdf/Exception.php';
            throw new Zend_Pdf_Exception('$script parameter must be either , ' .
                'a string, a Zend_Pdf_Element_String object or a ' .
                'Zend_Pdf_Element_Stream object.');
        }

        $this->_actionDictionary->touch();
        $this->_actionDictionary->JS = $script;

        return $this;
    }

    /**
     * Get script to execute
     *
     * @return Zend_Pdf_Element_String|Zend_Pdf_Element_Stream
     */
    public function getJavaScript()
    {
        return $this->_actionDictionary->JS->value;
    }
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>