There has been a lot of talk about Zend Framework 2.0 in the past few weeks. One of the major new features is the consistent use of namespaces through out the framework. This requires that all components be re-written to take advantage of this PHP 5.3 feature.

Although the release of Zend Framework 2.0 is a long way off — currently there is no official release plan — contributors are encouraged to port their components as soon as possible.

Therefore, I am delighted to announce that you can download a version of \Zend\Service\LiveDocx, complete with the latest development version of Zend Framework 2.0 from my account at GitHub.

In particular, take a look at the shipped demo applications, in the directory /demos/Zend/Service/LiveDocx. They illustrate how to use all parts of the framework and offer a good introduction to the usage of namespaces in PHP 5.3, if this topic is new to you.

To whet your appetite, below is the bitmaps demo:

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
use Zend\Date\Date;
use Zend\Service\LiveDocx\MailMerge;
 
$mailMerge = new MailMerge();
 
$mailMerge->setUsername('myUsername')
          ->setPassword('myPassword');
 
$mailMerge->setLocalTemplate('template.docx');
 
$mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')
          ->assign('licensee', 'Daï Lemaitre')
          ->assign('company',  'Megasoft Co-operation')
          ->assign('date',     Date::now()->toString(Date::DATE_LONG))
          ->assign('time',     Date::now()->toString(Date::TIME_LONG))
          ->assign('city',     'Lyon')
          ->assign('country',  'France');
 
$mailMerge->createDocument();
 
// Get all bitmaps
$bitmaps = $mailMerge->getAllBitmaps(100, 'png');      // zoomFactor, format
 
foreach ($bitmaps as $pageNumber => $bitmapData) {
    $filename = sprintf('document-page-%d.png', $pageNumber);
    file_put_contents($filename, $bitmapData);
}
 
unset($mailMerge);

Note, this is development code and should not yet be used in production applications.

原文出處: http://www.phplivedocx.org/ 


    全站熱搜

    Frank 發表在 痞客邦 留言(0) 人氣()