Преглед изворни кода

Updated Zend_Service_LiveDocx_MailMerge to use 2.0 backend.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23022 44c647ce-9c0f-0410-b52a-842ac1e357ba
jonathan_maron пре 15 година
родитељ
комит
48d27c3f13

BIN
demos/Zend/Service/LiveDocx/MailMerge/conference-pass/dailemaitre.jpg


+ 0 - 0
demos/Zend/Service/LiveDocx/MailMerge/conference-pass/document.pdf


+ 36 - 0
demos/Zend/Service/LiveDocx/MailMerge/conference-pass/generate-document.php

@@ -0,0 +1,36 @@
+<?php
+
+require_once dirname(__FILE__) . '/../../common.php';
+
+
+$mailMerge = new Zend_Service_LiveDocx_MailMerge();
+
+$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)
+          ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
+
+/**
+ * Image Source:
+ * iStock_000003413016Medium_business-man-with-hands-up.jpg
+ */
+$photoFilename = 'dailemaitre.jpg';
+
+if (!$mailMerge->imageExists($photoFilename)) {
+    $mailMerge->uploadImage($photoFilename);
+}
+
+$mailMerge->setLocalTemplate('template.docx');
+
+$mailMerge->assign('name',        'Daï Lemaitre')
+          ->assign('company',     'Megasoft Co-operation')
+          ->assign('date',        Zend_Date::now()->toString(Zend_Date::DATE_LONG))
+          ->assign('image:photo', $photoFilename);
+
+$mailMerge->createDocument();
+
+$document = $mailMerge->retrieveDocument('pdf');
+
+file_put_contents('document.pdf', $document);
+
+$mailMerge->deleteImage($photoFilename);
+
+unset($mailMerge);

BIN
demos/Zend/Service/LiveDocx/MailMerge/conference-pass/template.docx


+ 10 - 6
demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats-cached.php

@@ -39,9 +39,10 @@ if (! $formats = $cache->load($cacheId)) {
     
     $formats = new StdClass();
     
-    $formats->template = $mailMerge->getTemplateFormats();
-    $formats->document = $mailMerge->getDocumentFormats();
-    $formats->image    = $mailMerge->getImageFormats();
+    $formats->template    = $mailMerge->getTemplateFormats();
+    $formats->document    = $mailMerge->getDocumentFormats();
+    $formats->imageImport = $mailMerge->getImageImportFormats();
+    $formats->imageExport = $mailMerge->getImageExportFormats();
     
     $cache->save($formats, $cacheId);
     
@@ -59,9 +60,12 @@ printf("Supported TEMPLATE file formats (input)  : %s%s",
     Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->template), PHP_EOL);
 
 printf("Supported DOCUMENT file formats (output) : %s%s",
-    Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->document), PHP_EOL);
+    Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->document), PHP_EOL . PHP_EOL);
 
-printf("Supported IMAGE file formats (output)    : %s%s",
-    Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->image), PHP_EOL);
+printf("Supported IMAGE file formats (import)    : %s%s",
+    Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->imageImport), PHP_EOL);
+
+printf("Supported IMAGE file formats (export)    : %s%s",
+    Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->imageExport), PHP_EOL);
 
 print(PHP_EOL);

+ 6 - 3
demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats.php

@@ -22,10 +22,13 @@ printf("Supported TEMPLATE file formats (input)  : %s%s",
     Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getTemplateFormats()), PHP_EOL);
 
 printf("Supported DOCUMENT file formats (output) : %s%s",
-    Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getDocumentFormats()), PHP_EOL);
+    Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getDocumentFormats()), PHP_EOL . PHP_EOL);
 
-printf("Supported IMAGE file formats (output)    : %s%s",
-    Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getImageFormats()), PHP_EOL);
+printf("Supported IMAGE file formats (import)    : %s%s",
+    Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getImageImportFormats()), PHP_EOL);
+
+printf("Supported IMAGE file formats (export)    : %s%s",
+    Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getImageExportFormats()), PHP_EOL);
 
 print PHP_EOL;
     

BIN
documentation/manual/en/figures/zend.service.livedocx.mailmerge.templates-imagemerge.png


BIN
documentation/manual/en/figures/zend.service.livedocx.mailmerge.templates-imagemerge_zoom.png


+ 160 - 8
documentation/manual/en/module_specs/Zend_Service_LiveDocx.xml

@@ -210,11 +210,59 @@
                 </itemizedlist>
             </sect4>
 
-            <sect4 id="zend.service.livedocx.formats.image">
+            <sect4 id="zend.service.livedocx.formats.imageimport">
+                <title>Image File Formats (import):</title>
+
+                <para>
+                    Images can be merged into templates in any of following file formats:
+                </para>
+
+                <itemizedlist>
+                    <listitem>
+                        <para>
+                            <ulink url="http://en.wikipedia.org/wiki/BMP_file_format">BMP</ulink> -
+                            Bitmap image format
+                        </para>
+                    </listitem>
+
+                    <listitem>
+                        <para>
+                            <ulink url="http://en.wikipedia.org/wiki/GIF">GIF</ulink> - Graphics
+                            Interchange Format
+                        </para>
+                    </listitem>
+
+                    <listitem>
+                        <para>
+                            <ulink url="http://en.wikipedia.org/wiki/Jpg">JPG</ulink> - Joint
+                            Photographic Experts Group format
+                        </para>
+                    </listitem>
+
+                    <listitem>
+                        <para>
+                            <ulink
+                                url="http://en.wikipedia.org/wiki/Portable_Network_Graphics">PNG</ulink>
+                            - Portable Network Graphics format
+                        </para>
+                    </listitem>
+
+                    <listitem>
+                        <para>
+                            <ulink
+                                url="http://en.wikipedia.org/wiki/Tagged_Image_File_Format">TIFF</ulink>
+                            - Tagged Image File Format
+                        </para>
+                    </listitem>
+
+                </itemizedlist>
+            </sect4>
+
+            <sect4 id="zend.service.livedocx.formats.imageexport">
                 <title>Image File Formats (output):</title>
 
                 <para>
-                    The resulting document can be saved in any of the following graphical file
+                    The resulting document can be exported to any of the following graphical file
                     formats:
                 </para>
 
@@ -403,6 +451,85 @@ file_put_contents('document.pdf', $document);
             </para>
         </sect3>
 
+
+        <sect3 id="zend.service.livedocx.mailmerge.imagemerge">
+
+            <title>Merging image data</title>
+
+            <para>
+                Using <classname>Zend_Service_LiveDocx_MailMerge</classname> it is also possible to merge images into
+                a template. This feature is useful, for example, in the case of a badge application
+                for a conference. In addition to the name and company name that should appear on
+                the badge, it is possible to insert a photo of the delegate, using the API.
+            </para>
+
+            <para>
+                Even it is sounds a little counter-intuitive, image-merging also work with
+                text fields, as described in the section above. In fact, inserting a text field
+                for an image is identical to inserting a text field for textual information.
+                The only difference is the naming convention of the text field. Whereas, a text
+                field for textual information can have (almost) any identifier, a text field for
+                an image must start with <emphasis>image:</emphasis>. For example, in the case of our badge
+                application, we would have the following fields 3 fields:
+            </para>
+
+            <para>
+                <inlinegraphic
+                    fileref="figures/zend.service.livedocx.mailmerge.templates-imagemerge_zoom.png"
+                    format="PNG" />
+            </para>
+
+            <para>
+                The text field, into which image data will be inserted is called <emphasis>image:photo</emphasis>
+                and can be populated just like any other text field, using the assign method. The
+                text fields <emphasis>name</emphasis> and <emphasis>company</emphasis> are regular
+                text fields for textual information.
+            </para>
+
+            <para>
+                Before we insert graphic data, we first have to upload the image to the backend
+                LiveDocx server. This can be achieved using the <emphasis>uploadImage($filename)</emphasis> method.
+            </para>
+
+            <para>The following code snipped illustrates the flow:</para>
+
+            <programlisting language="php"><![CDATA[
+$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
+
+$phpLiveDocx->setUsername('username')
+            ->setPassword('password');
+
+$photoFilename = 'dailemaitre.jpg';
+
+if (!$phpLiveDocx->imageExists($photoFilename)) {
+    $phpLiveDocx->uploadImage($photoFilename);
+}
+
+$phpLiveDocx->setLocalTemplate('template.docx');
+
+$phpLiveDocx->assign('name',        'Daï Lemaitre')
+            ->assign('company',     'Megasoft Co-operation')
+            ->assign('date',        Zend_Date::now()->toString(Zend_Date::DATE_LONG))
+            ->assign('image:photo', $photoFilename);
+
+$phpLiveDocx->createDocument();
+
+$document = $phpLiveDocx->retrieveDocument('pdf');
+
+file_put_contents('document.pdf', $document);
+
+$phpLiveDocx->deleteImage($photoFilename);
+]]></programlisting>
+
+            <para>
+                Note that all images uploaded to your LiveDocx account must have a unique
+                filename. In the case that you only intend to use the image once (such
+                as is probable for our badge application), it makes sense to immediately
+                delete it from the backend, using the <emphasis>deleteImage($filename)</emphasis> method.
+            </para>
+
+        </sect3>
+
         <sect3 id="zend.service.livedocx.mailmerge.advanced">
             <title>Advanced Mail-Merge</title>
 
@@ -565,7 +692,7 @@ file_put_contents('document.pdf', $document);
             <para>
                 In addition to document file formats,
                 <classname>Zend_Service_LiveDocx_MailMerge</classname> also allows documents to be
-                saved to a number of image file formats (<acronym>BMP</acronym>,
+                exported to a number of image file formats (<acronym>BMP</acronym>,
                 <acronym>GIF</acronym>, <acronym>JPG</acronym>, <acronym>PNG</acronym> and
                 <acronym>TIFF</acronym>). Each page of the document is saved to one file.
             </para>
@@ -583,7 +710,7 @@ file_put_contents('document.pdf', $document);
                 relative to the original page size. The range of this parameter is 10 to 400.
                 <varname>$format</varname> is the format of the images returned by this method. The
                 supported formats can be obtained by calling
-                <methodname>getImageFormats()</methodname>.
+                <methodname>getImageExportFormats()</methodname>.
             </para>
 
             <programlisting language="php"><![CDATA[
@@ -857,11 +984,36 @@ Zend_Debug::dump($phpLiveDocx->getDocumentFormats());
 ]]></programlisting>
             </example>
 
-            <example id="zend.service.livedocx.mailmerge.information.getimageformats">
-                <title>Get Array of Supported Image File Formats</title>
+            <example id="zend.service.livedocx.mailmerge.information.getimageimportformats">
+                <title>Get Array of Supported Image Import File Formats</title>
+
+                <para>
+                    The following code returns and displays an array of all supported imput image file
+                    formats.
+                </para>
+
+                <programlisting language="php"><![CDATA[
+$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
+
+$phpLiveDocx->setUsername('myUsername')
+            ->setPassword('myPassword');
+
+Zend_Debug::dump($phpLiveDocx->getImageImportFormats());
+]]></programlisting>
+
+                <para>
+                    <emphasis>NOTE:</emphasis> As the return value of this method changes very
+                    infrequently, it is highly recommended to use a cache, such as
+                    <classname>Zend_Cache</classname> - this will considerably speed up your
+                    application.
+                </para>
+            </example>
+            
+            <example id="zend.service.livedocx.mailmerge.information.getimageexportformats">
+                <title>Get Array of Supported Image Export File Formats</title>
 
                 <para>
-                    The following code returns and displays an array of all supported image file
+                    The following code returns and displays an array of all supported export image file
                     formats. This method is particularly useful in the case that a combo list should
                     be displayed that allows the end-user to select the output format of the
                     documentation generation process.
@@ -873,7 +1025,7 @@ $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 $phpLiveDocx->setUsername('myUsername')
             ->setPassword('myPassword');
 
-Zend_Debug::dump($phpLiveDocx->getImageFormats());
+Zend_Debug::dump($phpLiveDocx->getImageExportFormats());
 ]]></programlisting>
 
                 <para>

+ 1 - 1
library/Zend/Service/LiveDocx.php

@@ -34,7 +34,7 @@ class Zend_Service_LiveDocx
      * LiveDocx service version
      * @since LiveDocx 1.0
      */
-    const VERSION = '1.2';
+    const VERSION = '2.0';
 
     /**
      * SOAP client used to connect to LiveDocx service

+ 183 - 23
library/Zend/Service/LiveDocx/MailMerge.php

@@ -40,7 +40,8 @@ class Zend_Service_LiveDocx_MailMerge extends Zend_Service_LiveDocx
      * URI of LiveDocx.MailMerge WSDL
      * @since LiveDocx 1.0 
      */
-    const WSDL = 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL';
+    //const WSDL = 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL';
+    const WSDL = 'https://api.livedocx.com/2.0/mailmerge.asmx?WSDL';
 
     /**
      * Field values
@@ -85,6 +86,12 @@ class Zend_Service_LiveDocx_MailMerge extends Zend_Service_LiveDocx
      */
     public function setLocalTemplate($filename)
     {
+        if (!is_readable($filename)) {
+            throw new Zend_Service_LiveDocx_Exception(
+                'Cannot read local template from disk.'
+            );
+        }
+
         $this->logIn();
         
         try {
@@ -838,27 +845,6 @@ class Zend_Service_LiveDocx_MailMerge extends Zend_Service_LiveDocx
 
         return $ret;
     }
-    
-    /*
-     * Return supported image formats (lowercase)
-     *
-     * @return array
-     * @since  LiveDocx 1.2
-     */
-    public function getImageFormats()
-    {
-        $this->logIn();
-        
-        $ret    = array();
-        $result = $this->getSoapClient()->GetImageFormats();
-
-        if (isset($result->GetImageFormatsResult->string)) {
-            $ret = $result->GetImageFormatsResult->string;
-            $ret = array_map('strtolower', $ret);
-        }
-
-        return $ret;
-    }
         
     /**
      * Return the names of all fonts that are installed on backend server
@@ -898,7 +884,178 @@ class Zend_Service_LiveDocx_MailMerge extends Zend_Service_LiveDocx
         }
 
         return $ret;
-    }    
+    }
+
+    /**
+     * Return supported image formats from which can be imported (lowercase)
+     *
+     * @return array
+     * @since  LiveDocx 2.0
+     */
+    public function getImageImportFormats()
+    {
+        $this->logIn();
+
+        $ret    = array();
+        $result = $this->getSoapClient()->GetImageImportFormats();
+
+        if (isset($result->GetImageImportFormatsResult->string)) {
+            $ret = $result->GetImageImportFormatsResult->string;
+            $ret = array_map('strtolower', $ret);
+        }
+
+        return $ret;
+    }
+
+    /**
+     * Return supported image formats to which can be exported (lowercase)
+     *
+     * @return array
+     * @since  LiveDocx 2.0
+     */
+    public function getImageExportFormats()
+    {
+        $this->logIn();
+
+        $ret    = array();
+        $result = $this->getSoapClient()->GetImageExportFormats();
+
+        if (isset($result->GetImageExportFormatsResult->string)) {
+            $ret = $result->GetImageExportFormatsResult->string;
+            $ret = array_map('strtolower', $ret);
+        }
+
+        return $ret;
+    }
+
+    /*
+     * Return supported image formats (lowercase)
+     *
+     * @return array
+     * @since  LiveDocx 1.2
+     * @deprecated since LiveDocx 2.0
+     */
+    public function getImageFormats()
+    {
+        $replacement = 'getImageExportFormats';
+
+        /*
+        $errorMessage = sprintf(
+                        "%s::%s is deprecated as of LiveDocx 2.0. "
+                      . "It has been replaced by %s::%s() (drop in replacement)",
+                        __CLASS__, __FUNCTION__, __CLASS__, $replacement);
+
+        trigger_error($errorMessage, E_USER_NOTICE);
+        */
+        
+        return $this->$replacement();
+    }
+
+    /**
+     * Upload an image file to LiveDocx service
+     *
+     * @param  string $filename
+     * @return void
+     * @throws Zend_Service_LiveDocx_Exception
+     * @since  LiveDocx 2.0
+     */
+    public function uploadImage($filename)
+    {
+        $this->logIn();
+
+        try {
+            $this->getSoapClient()->UploadImage(array(
+                'image'    => base64_encode(file_get_contents($filename)),
+                'filename' => basename($filename),
+            ));
+        } catch (Exception $e) {
+            require_once 'Zend/Service/LiveDocx/Exception.php';
+            throw new Zend_Service_LiveDocx_Exception(
+                'Cannot upload image', 0, $e
+            );
+        }
+    }
+
+    /**
+     * Download an image file from LiveDocx service
+     *
+     * @param  string $filename
+     * @return void
+     * @throws Zend_Service_LiveDocx_Exception
+     * @since  LiveDocx 2.0
+     */
+    public function downloadImage($filename)
+    {
+        $this->logIn();
+
+        try {
+            $result = $this->getSoapClient()->DownloadImage(array(
+                'filename' => basename($filename),
+            ));
+        } catch (Exception $e) {
+            require_once 'Zend/Service/LiveDocx/Exception.php';
+            throw new Zend_Service_LiveDocx_Exception(
+                'Cannot download image', 0, $e
+            );
+        }
+
+        return base64_decode($result->DownloadImageResult);
+    }
+
+    /**
+     * List all images stored on LiveDocx service
+     *
+     * @return array
+     * @since  LiveDocx 2.0
+     */
+    public function listImages()
+    {
+        $this->logIn();
+
+        $ret    = array();
+        $result = $this->getSoapClient()->ListImages();
+
+        if (isset($result->ListImagesResult)) {
+            $ret = $this->_backendListArrayToMultiAssocArray($result->ListImagesResult);
+        }
+
+        return $ret;
+    }
+
+    /**
+     * Delete an image file from LiveDocx service
+     *
+     * @param  string $filename
+     * @return void
+     * @throws Zend_Service_LiveDocx_Exception
+     * @since  LiveDocx 2.0
+     */
+    public function deleteImage($filename)
+    {
+        $this->logIn();
+
+        $this->getSoapClient()->DeleteImage(array(
+            'filename' => basename($filename),
+        ));
+    }
+
+    /**
+     * Check whether an image file is available on LiveDocx service
+     *
+     * @param  string $filename
+     * @return boolean
+     * @since  LiveDocx 2.0
+     */
+    public function imageExists($filename)
+    {
+        $this->logIn();
+
+        $result = $this->getSoapClient()->ImageExists(array(
+            'filename' => basename($filename),
+        ));
+
+        return (boolean) $result->ImageExistsResult;
+    }
 
     /**
      * Convert LiveDocx service return value from list methods to consistent PHP array
@@ -975,4 +1132,7 @@ class Zend_Service_LiveDocx_MailMerge extends Zend_Service_LiveDocx
 
         return array_merge($arrayKeys, $arrayValues);
     }
+
+    // -------------------------------------------------------------------------
+
 }

+ 1 - 1
tests/Zend/Service/LiveDocx/LiveDocxTest.php

@@ -89,7 +89,7 @@ class Zend_Service_LiveDocX_LiveDocxTest extends PHPUnit_Framework_TestCase
     
     public function testGetVersion ()
     {
-        $expectedResults = '1.2';
+        $expectedResults = '2.0';
         $this->assertEquals($expectedResults, $this->phpLiveDocx->getVersion());
     }
 }

BIN
tests/Zend/Service/LiveDocx/MailMerge/image-01.png


BIN
tests/Zend/Service/LiveDocx/MailMerge/image-02.png


+ 107 - 25
tests/Zend/Service/LiveDocx/MailMergeTest.php

@@ -44,7 +44,9 @@ class Zend_Service_LiveDocx_MailMergeTest extends PHPUnit_Framework_TestCase
 {
     const TEST_TEMPLATE_1 = 'phpunit-template.docx';
     const TEST_TEMPLATE_2 = 'phpunit-template-block-fields.doc';
-    const ENDPOINT = 'https://api.livedocx.com/1.2/mailmerge.asmx?wsdl';
+    const TEST_IMAGE_1 = 'image-01.png';
+    const TEST_IMAGE_2 = 'image-02.png';
+    const ENDPOINT = 'https://api.livedocx.com/2.0/mailmerge.asmx?wsdl';
 
     public $path;
     public $phpLiveDocx;
@@ -276,11 +278,11 @@ class Zend_Service_LiveDocx_MailMergeTest extends PHPUnit_Framework_TestCase
         // - DOC because of ???
 
         $expectedResults = array(
-            'docx' => '50fe2abd9b42e67c3126d355768b6e75',
-            'rtf'  => '24f950ff620ba194fe5900c3a5360570',
-            'txd'  => '22d7a7558b19ba8be9fe03b35068cf20',
-            'txt'  => '3dc103f033ef6efba770c8196059d96d',
-            'html' => '8b91dc8617651b6e3142d0716c0f616a',
+            'docx' => 'f21728491855c27a9e64a47266c2a720',
+            'rtf'  => 'fb75deabf481b0264927cb4a5c9db765',
+            'txd'  => 'd1f645405ded0718edff6ae6f50a496e',
+            'txt'  => 'ec2f680646540edd79cd22773fa7e183',
+            'html' => 'e3a28523794b0071501c09f791f8c795',
         );
 
         // Remote Template
@@ -331,11 +333,11 @@ class Zend_Service_LiveDocx_MailMergeTest extends PHPUnit_Framework_TestCase
         // - PDF because of the timestamp in meta data
         // - DOC because of ???
         $expectedResults = array(
-            'docx' => '0697e57da0c886dee9fa2d5c98335121',
-            'rtf'  => '9a3f448519e2be0da08a13702fd9d48b',
-            'txd'  => 'f76a6575e74db5b15b4c4be76157bc03',
-            'txt'  => 'e997415fd0d5e766b2490fed9386da21',
-            'html' => '2dfafbb8f81281dbbae99e131963cd50',
+            'docx' => '2757b4d10c8c031d8f501231be39fcfe',
+            'rtf'  => '2997e531011d826f315291fca1351988',
+            'txd'  => '8377a5a62f2e034974fc299c322d137f',
+            'txt'  => 'a7d23668f81b314e15d653ab657316f9',
+            'html' => '57365a2ff02347a7863626317505e037',
         );
 
         // Remote Template
@@ -373,10 +375,16 @@ class Zend_Service_LiveDocx_MailMergeTest extends PHPUnit_Framework_TestCase
         $this->assertEquals($expectedResults, $this->phpLiveDocx->getDocumentFormats());
     }
 
-    public function testGetImageFormats()
+    public function testGetImageImportFormats()
+    {
+        $expectedResults = array('bmp' , 'gif' , 'jpg' , 'png' , 'tiff', 'wmf');
+        $this->assertEquals($expectedResults, $this->phpLiveDocx->getImageImportFormats());
+    }
+
+    public function testGetImageExportFormats()
     {
         $expectedResults = array('bmp' , 'gif' , 'jpg' , 'png' , 'tiff');
-        $this->assertEquals($expectedResults, $this->phpLiveDocx->getImageFormats());
+        $this->assertEquals($expectedResults, $this->phpLiveDocx->getImageExportFormats());
     }
    
     // -------------------------------------------------------------------------
@@ -394,17 +402,17 @@ class Zend_Service_LiveDocx_MailMergeTest extends PHPUnit_Framework_TestCase
         );
 
         $expectedResults = array(
-            'bmp'  => 'c588ee10d63e0598fe3541a032f509d6',
-            'gif'  => '2edd4066dda5f4c2049717137d76cf58',
-            'jpg'  => '8766618c572f19ceccc39af7ad0c8478',
-            'png'  => '1e12e4937b9ccb0fa6d78dcd342b7f28',
-            'tiff' => '014ae48643e3a50f691b7d9442605426',
+            'bmp'  => 'a1934f2153172f021847af7ece9049ce',
+            'gif'  => 'd7281d7b6352ff897917e25d6b92746f',
+            'jpg'  => 'e0b20ea2c9a6252886f689f227109085',
+            'png'  => 'c449f0c2726f869e9a42156e366f1bf9',
+            'tiff' => '20a96a94762a531e9879db0aa6bd673f',
         );
 
         $this->phpLiveDocx->setLocalTemplate($this->path . DIRECTORY_SEPARATOR . self::TEST_TEMPLATE_1);
         $this->phpLiveDocx->assign($testValues);
         $this->phpLiveDocx->createDocument();
-        foreach($this->phpLiveDocx->getImageFormats() as $format) {
+        foreach($this->phpLiveDocx->getImageExportFormats() as $format) {
             $bitmaps = $this->phpLiveDocx->getBitmaps(1, 1, 20, $format);
             $this->assertEquals($expectedResults[$format], md5(serialize($bitmaps)));
         }
@@ -423,17 +431,17 @@ class Zend_Service_LiveDocx_MailMergeTest extends PHPUnit_Framework_TestCase
         );
 
         $expectedResults = array(
-            'bmp'  => '0ae732498dd3798fc51c1ccccd09e3e3',
-            'gif'  => '9a5f7bfa2aafd8b99f6955b8bdbb8bf7',
-            'jpg'  => '38550446bfc84af3ddd1a0f3339a84dd',
-            'png'  => 'a3b5517bb118db67b8a8259652a389c2',
-            'tiff' => 'b49aa783c14bc7f07776d816085894a3',
+            'bmp'  => 'e8a884ee61c394deec8520fb397d1cf1',
+            'gif'  => '2255fee47b4af8438b109efc3cb0d304',
+            'jpg'  => 'e1acfc3001fc62567de2a489eccdb552',
+            'png'  => '15eac34d08e602cde042862b467fa865',
+            'tiff' => '98bad79380a80c9cc43dfffc5158d0f9',
         );
 
         $this->phpLiveDocx->setLocalTemplate($this->path . DIRECTORY_SEPARATOR . self::TEST_TEMPLATE_1);
         $this->phpLiveDocx->assign($testValues);
         $this->phpLiveDocx->createDocument();
-        foreach($this->phpLiveDocx->getImageFormats() as $format) {
+        foreach($this->phpLiveDocx->getImageExportFormats() as $format) {
             $bitmaps = $this->phpLiveDocx->getAllBitmaps(20, $format);
             $this->assertEquals($expectedResults[$format], md5(serialize($bitmaps)));
         }
@@ -576,6 +584,80 @@ class Zend_Service_LiveDocx_MailMergeTest extends PHPUnit_Framework_TestCase
 
     // -------------------------------------------------------------------------
 
+    public function testUploadImage()
+    {
+        $this->phpLiveDocx->deleteImage(self::TEST_IMAGE_2);
+        $this->assertNull($this->phpLiveDocx->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_2));
+        $this->phpLiveDocx->deleteImage(self::TEST_IMAGE_2);
+    }
+
+    public function testDownloadImage()
+    {
+        $expectedResults = 'f8b663e465acd570414395d5c33541ab';
+        $this->phpLiveDocx->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_2);
+        $image = $this->phpLiveDocx->downloadImage(self::TEST_IMAGE_2);
+        $this->assertEquals($expectedResults, md5($image));
+    }
+
+    public function testDeleteImage()
+    {
+        $this->phpLiveDocx->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_2);
+        $this->phpLiveDocx->deleteImage(self::TEST_IMAGE_2);
+        $imageDeleted = true;
+        foreach($this->phpLiveDocx->listImages() as $image) {
+            if($image['filename'] == self::TEST_IMAGE_2) {
+                $imageDeleted = false;
+            }
+        }
+        $this->assertTrue($imageDeleted);
+    }
+
+    public function testListImages()
+    {
+        $this->phpLiveDocx->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_1);
+        $this->phpLiveDocx->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_2);
+
+        // Where images uploaded and are being listed?
+        $testImage1Exists = false;
+        $testImage2Exists = false;
+
+        $images = $this->phpLiveDocx->listImages();
+        foreach($images as $image) {
+            if(self::TEST_IMAGE_1 === $image['filename']) {
+                $testImage1Exists = true;
+            } elseif(self::TEST_IMAGE_2 === $image['filename']) {
+                $testImage2Exists = true;
+            }
+        }
+        $this->assertTrue($testImage1Exists && $testImage2Exists);
+
+        // Is all info about images available?
+        $expectedResults = array('filename', 'fileSize', 'createTime', 'modifyTime');
+        foreach($images as $image) {
+            $this->assertEquals($expectedResults, array_keys($image));
+        }
+
+        // Is all info about images correct?
+        foreach($images as $image) {
+            $this->assertTrue(strlen($image['filename']) > 0);
+            $this->assertTrue($image['fileSize'] > 1);
+            $this->assertTrue($image['createTime'] > mktime(0, 0, 0, 1, 1, 1980));
+            $this->assertTrue($image['modifyTime'] > mktime(0, 0, 0, 1, 1, 1980));
+        }
+
+        $this->phpLiveDocx->deleteImage(self::TEST_IMAGE_1);
+        $this->phpLiveDocx->deleteImage(self::TEST_IMAGE_2);
+    }
+
+    public function testImageExists()
+    {
+        $this->phpLiveDocx->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_2);
+        $this->assertTrue($this->phpLiveDocx->imageExists(self::TEST_IMAGE_2));
+        $this->phpLiveDocx->deleteImage(self::TEST_IMAGE_2);
+    }
+
+    // -------------------------------------------------------------------------
+
     public function testAssocArrayToArrayOfArrayOfString()
     {
         $testValues = array(