Initial commit.
This commit is contained in:
83
INSTALL.txt
Normal file
83
INSTALL.txt
Normal file
@ -0,0 +1,83 @@
|
||||
INSTALLATION
|
||||
------------
|
||||
|
||||
Zend Framework requires no special installation steps. Simply download the framework,
|
||||
extract it to the folder you would like to keep it in, and add the library directory
|
||||
to your PHP include_path. To use components in the extras library, add the extras/library
|
||||
directory to your PHP include_path, as well.
|
||||
If you would like to use Zend_Tool, simply add bin/zf.bat (for Windows) or
|
||||
bin/zf.sh (for anything else) to your system executable path.
|
||||
|
||||
SYSTEM REQUIREMENTS
|
||||
-------------------
|
||||
|
||||
Zend Framework requires PHP 5.2.11 or later. Please see the system requirements
|
||||
appendix for more detailed information:
|
||||
|
||||
http://framework.zend.com/manual/en/requirements.html
|
||||
|
||||
DEVELOPMENT VERSIONS
|
||||
--------------------
|
||||
|
||||
If you would like to preview enhancements or bug fixes that have not yet been
|
||||
released, you can obtain the current development version of Zend Framework using one
|
||||
of the following methods:
|
||||
|
||||
* Download the latest nightly snapshot. For those who care to brave the cutting
|
||||
(often bleeding) edge, the nightly snapshots represent the latest single-
|
||||
download development version of Zend Framework development. Snapshots are bundled
|
||||
with documentation in English only or in all available languages. If you anticipate
|
||||
updating to the latest development version of Zend Framework often, consider using
|
||||
Subversion as described below.
|
||||
|
||||
http://framework.zend.com/download/snapshot
|
||||
|
||||
* Using a Subversion (SVN) client. Zend Framework is open source software, and
|
||||
the Subversion repository used for its development is publicly available. Consider
|
||||
using SVN to get Zend Framework if you already use SVN for your application
|
||||
development, want to contribute back to the framework, or need to upgrade your
|
||||
framework version very often.
|
||||
|
||||
Exporting is useful if you want to get a particular framework revision without the
|
||||
.svn directories as created in a working copy.
|
||||
|
||||
Checking out a working copy is necessary if you would like to directly contribute
|
||||
to Zend Framework; a working copy can be updated any time with svn update.
|
||||
|
||||
An externals definition is highly convenient for developers already using SVN to
|
||||
manage their application working copies.
|
||||
|
||||
The URL for the trunk of the Zend Framework SVN repository is:
|
||||
|
||||
http://framework.zend.com/svn/framework/trunk
|
||||
|
||||
For more information about Subversion, please see the official website:
|
||||
|
||||
http://subversion.tigris.org
|
||||
|
||||
CONFIGURING THE INCLUDE PATH
|
||||
----------------------------
|
||||
|
||||
Once you have a copy of Zend Framework available, your application will need to
|
||||
access the framework classes. Though there are several ways to achieve this, your
|
||||
PHP include_path needs to contain the path to the Zend Framework classes under the
|
||||
/library directory in this distribution. You can find out more about the PHP
|
||||
include_path configuration directive here:
|
||||
|
||||
http://www.php.net/manual/en/ini.core.php#ini.include-path
|
||||
|
||||
Instructions on how to change PHP configuration directives can be found here:
|
||||
|
||||
http://www.php.net/manual/en/configuration.changes.php
|
||||
|
||||
GETTING STARTED
|
||||
---------------
|
||||
|
||||
A great place to get up-to-speed quickly is the Zend Framework QuickStart:
|
||||
|
||||
http://framework.zend.com/docs/quickstart
|
||||
|
||||
The QuickStart covers some of the most commonly used components of ZF. Since
|
||||
Zend Framework is designed with a use-at-will architecture and components are
|
||||
loosely coupled, you can select and use only those components that are needed for
|
||||
your project.
|
||||
27
LICENSE.txt
Normal file
27
LICENSE.txt
Normal file
@ -0,0 +1,27 @@
|
||||
Copyright (c) 2005-2012, Zend Technologies USA, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Zend Technologies USA, Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
22
README.md
Normal file
22
README.md
Normal file
@ -0,0 +1,22 @@
|
||||
Zend Framework 1 for Composer
|
||||
=============================
|
||||
|
||||
This package is a part of the Zend Framework 1. Each component was separated and put into its own composer package. Some modifications were made for improved [Composer](http://getcomposer.org/) integration. This package can also be found at [Packagist](http://packagist.org/packages/zf1).
|
||||
|
||||
## Why?
|
||||
|
||||
**Size!** Zend Framework is very large and contains a huge amount of files (over 72000 files in the main repository!). If you're only using a part of the framework, using the separated packages will greatly reduce the amount of files. This will make setup faster and easier on your disks.
|
||||
|
||||
**Autoloading!** Explicit `require_once` calls in the source code has been commented out to rely on composer autoloading, this reduces the number of included files to a minimum.
|
||||
|
||||
**Migration!** Zend Framework 2 has been around for a while now, and migrating all your projects takes a lot of time. Using these packages makes it easier to migrate each component separately. Also, some packages doesn't exist in zf2 (such as the zend-search-lucene), now you can continue using that package without requiring the entire framework.
|
||||
|
||||
If you're using major parts of the framework, I would recommend checking out the [zendframework1 package](https://github.com/bombayworks/zendframework1), which contains the entire framework optimized for composer usage.
|
||||
|
||||
## How to use
|
||||
|
||||
Add `"zf1/zend-pdf": "~1.12"` to the require section of your composer.json, include the composer autoloader and you're good to go.
|
||||
|
||||
## Broken dependencies?
|
||||
|
||||
Dependencies have been set automatically based on the [requirements from the zend framework manual](http://framework.zend.com/manual/1.12/en/requirements.introduction.html), if you find any broken dependencies please submit an issue.
|
||||
160
README.txt
Normal file
160
README.txt
Normal file
@ -0,0 +1,160 @@
|
||||
Welcome to the Zend Framework 1.12 Release!
|
||||
|
||||
RELEASE INFORMATION
|
||||
---------------
|
||||
Zend Framework 1.12.3 Release ([INSERT REV NUM HERE]).
|
||||
Released on March 13, 2013
|
||||
|
||||
IMPORTANT FIXES FOR 1.12.3
|
||||
--------------------------
|
||||
|
||||
This release incorporates is primarily aimed to update
|
||||
Zend_Service_Twitter to the Twitter v1.1 API:
|
||||
|
||||
- http://framework.zend.com/issues/browse/ZF-12530
|
||||
|
||||
Because the Twitter v1.1 API is not backwards compatible with v1.0, the
|
||||
API for Zend_Service_Twitter has been changed; if you have been using it
|
||||
previously, you will need to update your code accordingly. Both the
|
||||
end-user and API documentation have been updated to reflect the changes.
|
||||
|
||||
NEW FEATURES
|
||||
============
|
||||
|
||||
Zend_Loader changes
|
||||
----
|
||||
|
||||
A number of autoloaders and autoloader facilities were back ported from
|
||||
ZF2 to provide performant alternatives to those already available in the
|
||||
1.X releases. These include: Zend_Loader_StandardAutoloader, which
|
||||
improves on Zend_Loader_Autoloader by allowing the ability to specify a
|
||||
specific path to associate with a vendor prefix or namespace;
|
||||
Zend_Loader_ClassMapAutoloader, which provides the ability to use lookup
|
||||
tables for autoloading (which are typically the fastest possible way to
|
||||
autoload); and Zend_Loader_AutoloaderFactory, which can both create and
|
||||
update autoloaders for you, as well as register them with
|
||||
spl_autoload_register().
|
||||
|
||||
The Zend_Loader changes were back ported from ZF2 by Matthew Weier
|
||||
O’Phinney
|
||||
|
||||
Zend_EventManager
|
||||
----
|
||||
|
||||
Zend_EventManager is a component that allows you to attach and detach
|
||||
listeners to named events, both on a per-instance basis as well as via
|
||||
shared collections; trigger events; and interrupt execution of
|
||||
listeners.
|
||||
|
||||
Zend_EventManager was back ported from ZF2 by Matthew Weier O’Phinney
|
||||
|
||||
Zend_Http_UserAgent_Features_Adapter_Browscap
|
||||
----
|
||||
|
||||
This class provides a features adapter that calls get_browser() in order
|
||||
to discover mobile device capabilities to inject into UserAgent device
|
||||
instances.
|
||||
|
||||
Browscap (http://browsers.garykeith.com/) is an open project dedicated
|
||||
to collecting an disseminating a “database” of browser capabilities. PHP
|
||||
has built-in support for using these files via the get_browser()
|
||||
function. This function requires that your php.ini provides a browscap
|
||||
entry pointing to the PHP-specific php_browscap.ini file which is
|
||||
available at http://browsers.garykeith.com/stream.asp?PHP_BrowsCapINI.
|
||||
|
||||
Zend_Http_UserAgent_Features_Adapter_Browscap was created by Matthew
|
||||
Weier O’Phinney
|
||||
|
||||
Zend_Mobile_Push
|
||||
----
|
||||
|
||||
Zend_Mobile_Push is a component for implementing push notifications for
|
||||
the 3 major push notification platforms (Apple (Apns), Google (C2dm) and
|
||||
Microsoft (Mpns).
|
||||
|
||||
Zend_Mobile_Push was contributed by Mike Willbanks.
|
||||
|
||||
Zend_Gdata_Analytics
|
||||
----
|
||||
|
||||
Zend_Gdata_Analytics is an extension to Zend_Gdata to allow interaction
|
||||
with Google’s Analytics Data Export API. This extension does not
|
||||
encompass any major changes in the overall operation of Zend_Gdata
|
||||
components.
|
||||
|
||||
Zend_Gdata_Analytics was contributed by Daniel Hartmann.
|
||||
|
||||
Removed features
|
||||
================
|
||||
|
||||
Zend_Http_UserAgent_Features_Adapter_WurflApi
|
||||
----
|
||||
|
||||
Due to the changes in licensing of WURFL, we have removed the WurflApi
|
||||
adapter. We will be providing the WurflApi adapter to ScientiaMobile so
|
||||
that users of WURFL will still have that option.
|
||||
|
||||
Bug Fixes
|
||||
=========
|
||||
|
||||
In addition, over 200 reported issues in the tracker have been fixed.
|
||||
We’d like to particularly thank Adam Lundrigan, Frank Brückner and
|
||||
Martin Hujer for their efforts in making this happen. Thanks also to the
|
||||
many people who ran the ZF1 unit tests and reported their results!
|
||||
|
||||
For a complete list, visit:
|
||||
|
||||
* http://framework.zend.com/issues/secure/IssueNavigator.jspa?requestId=12877
|
||||
* http://framework.zend.com/changelog/
|
||||
|
||||
MIGRATION NOTES
|
||||
---------------
|
||||
|
||||
A detailed list of migration notes may be found at:
|
||||
|
||||
http://framework.zend.com/manual/en/migration.html
|
||||
|
||||
SYSTEM REQUIREMENTS
|
||||
-------------------
|
||||
|
||||
Zend Framework requires PHP 5.2.11 or later. Please see our reference
|
||||
guide for more detailed system requirements:
|
||||
|
||||
http://framework.zend.com/manual/en/requirements.html
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
|
||||
Please see INSTALL.txt.
|
||||
|
||||
QUESTIONS AND FEEDBACK
|
||||
----------------------
|
||||
|
||||
Online documentation can be found at http://framework.zend.com/manual.
|
||||
Questions that are not addressed in the manual should be directed to the
|
||||
appropriate mailing list:
|
||||
|
||||
http://framework.zend.com/wiki/display/ZFDEV/Mailing+Lists
|
||||
|
||||
If you find code in this release behaving in an unexpected manner or
|
||||
contrary to its documented behavior, please create an issue in the Zend
|
||||
Framework issue tracker at:
|
||||
|
||||
http://framework.zend.com/issues
|
||||
|
||||
If you would like to be notified of new releases, you can subscribe to
|
||||
the fw-announce mailing list by sending a blank message to
|
||||
fw-announce-subscribe@lists.zend.com.
|
||||
|
||||
LICENSE
|
||||
-------
|
||||
|
||||
The files in this archive are released under the Zend Framework license.
|
||||
You can find a copy of this license in LICENSE.txt.
|
||||
|
||||
ACKNOWLEDGEMENTS
|
||||
----------------
|
||||
|
||||
The Zend Framework team would like to thank all the contributors to the Zend
|
||||
Framework project, our corporate sponsor, and you, the Zend Framework user.
|
||||
Please visit us sometime soon at http://framework.zend.com.
|
||||
23
composer.json
Normal file
23
composer.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "zf1/zend-pdf",
|
||||
"description": "Zend Framework 1 Pdf package",
|
||||
"keywords": [
|
||||
"framework",
|
||||
"zf1",
|
||||
"zend",
|
||||
"pdf"
|
||||
],
|
||||
"homepage": "http://framework.zend.com/",
|
||||
"license": "BSD-3-Clause",
|
||||
"require": {
|
||||
"php": ">=5.2.11",
|
||||
"zf1/zend-exception": "self.version",
|
||||
"zf1/zend-log": "self.version",
|
||||
"zf1/zend-memory": "self.version"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Zend_Pdf": "library/"
|
||||
}
|
||||
}
|
||||
}
|
||||
1428
library/Zend/Pdf.php
Normal file
1428
library/Zend/Pdf.php
Normal file
File diff suppressed because it is too large
Load Diff
404
library/Zend/Pdf/Action.php
Normal file
404
library/Zend/Pdf/Action.php
Normal file
@ -0,0 +1,404 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Action.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Target */
|
||||
// require_once 'Zend/Pdf/Target.php';
|
||||
|
||||
|
||||
/**
|
||||
* Abstract PDF action representation class
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Pdf_Action extends Zend_Pdf_Target implements RecursiveIterator, Countable
|
||||
{
|
||||
/**
|
||||
* Action dictionary
|
||||
*
|
||||
* @var Zend_Pdf_Element_Dictionary|Zend_Pdf_Element_Object|Zend_Pdf_Element_Reference
|
||||
*/
|
||||
protected $_actionDictionary;
|
||||
|
||||
|
||||
/**
|
||||
* An original list of chained actions
|
||||
*
|
||||
* @var array Array of Zend_Pdf_Action objects
|
||||
*/
|
||||
protected $_originalNextList;
|
||||
|
||||
/**
|
||||
* A list of next actions in actions tree (used for actions chaining)
|
||||
*
|
||||
* @var array Array of Zend_Pdf_Action objects
|
||||
*/
|
||||
public $next = array();
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param Zend_Pdf_Element_Dictionary $dictionary
|
||||
* @param SplObjectStorage $processedActions list of already processed action dictionaries, used to avoid cyclic references
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions)
|
||||
{
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
if ($dictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('$dictionary mast be a direct or an indirect dictionary object.');
|
||||
}
|
||||
|
||||
$this->_actionDictionary = $dictionary;
|
||||
|
||||
if ($dictionary->Next !== null) {
|
||||
if ($dictionary->Next instanceof Zend_Pdf_Element_Dictionary) {
|
||||
// Check if dictionary object is not already processed
|
||||
if (!$processedActions->contains($dictionary->Next)) {
|
||||
$processedActions->attach($dictionary->Next);
|
||||
$this->next[] = Zend_Pdf_Action::load($dictionary->Next, $processedActions);
|
||||
}
|
||||
} else if ($dictionary->Next instanceof Zend_Pdf_Element_Array) {
|
||||
foreach ($dictionary->Next->items as $chainedActionDictionary) {
|
||||
// Check if dictionary object is not already processed
|
||||
if (!$processedActions->contains($chainedActionDictionary)) {
|
||||
$processedActions->attach($chainedActionDictionary);
|
||||
$this->next[] = Zend_Pdf_Action::load($chainedActionDictionary, $processedActions);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('PDF Action dictionary Next entry must be a dictionary or an array.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->_originalNextList = $this->next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load PDF action object using specified dictionary
|
||||
*
|
||||
* @internal
|
||||
* @param Zend_Pdf_Element $dictionary (It's actually Dictionary or Dictionary Object or Reference to a Dictionary Object)
|
||||
* @param SplObjectStorage $processedActions list of already processed action dictionaries, used to avoid cyclic references
|
||||
* @return Zend_Pdf_Action
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function load(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions = null)
|
||||
{
|
||||
if ($processedActions === null) {
|
||||
$processedActions = new SplObjectStorage();
|
||||
}
|
||||
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
if ($dictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('$dictionary mast be a direct or an indirect dictionary object.');
|
||||
}
|
||||
if (isset($dictionary->Type) && $dictionary->Type->value != 'Action') {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Action dictionary Type entry must be set to \'Action\'.');
|
||||
}
|
||||
|
||||
if ($dictionary->S === null) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Action dictionary must contain S entry');
|
||||
}
|
||||
|
||||
switch ($dictionary->S->value) {
|
||||
case 'GoTo':
|
||||
// require_once 'Zend/Pdf/Action/GoTo.php';
|
||||
return new Zend_Pdf_Action_GoTo($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'GoToR':
|
||||
// require_once 'Zend/Pdf/Action/GoToR.php';
|
||||
return new Zend_Pdf_Action_GoToR($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'GoToE':
|
||||
// require_once 'Zend/Pdf/Action/GoToE.php';
|
||||
return new Zend_Pdf_Action_GoToE($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'Launch':
|
||||
// require_once 'Zend/Pdf/Action/Launch.php';
|
||||
return new Zend_Pdf_Action_Launch($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'Thread':
|
||||
// require_once 'Zend/Pdf/Action/Thread.php';
|
||||
return new Zend_Pdf_Action_Thread($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'URI':
|
||||
// require_once 'Zend/Pdf/Action/URI.php';
|
||||
return new Zend_Pdf_Action_URI($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'Sound':
|
||||
// require_once 'Zend/Pdf/Action/Sound.php';
|
||||
return new Zend_Pdf_Action_Sound($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'Movie':
|
||||
// require_once 'Zend/Pdf/Action/Movie.php';
|
||||
return new Zend_Pdf_Action_Movie($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'Hide':
|
||||
// require_once 'Zend/Pdf/Action/Hide.php';
|
||||
return new Zend_Pdf_Action_Hide($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'Named':
|
||||
// require_once 'Zend/Pdf/Action/Named.php';
|
||||
return new Zend_Pdf_Action_Named($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'SubmitForm':
|
||||
// require_once 'Zend/Pdf/Action/SubmitForm.php';
|
||||
return new Zend_Pdf_Action_SubmitForm($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'ResetForm':
|
||||
// require_once 'Zend/Pdf/Action/ResetForm.php';
|
||||
return new Zend_Pdf_Action_ResetForm($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'ImportData':
|
||||
// require_once 'Zend/Pdf/Action/ImportData.php';
|
||||
return new Zend_Pdf_Action_ImportData($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'JavaScript':
|
||||
// require_once 'Zend/Pdf/Action/JavaScript.php';
|
||||
return new Zend_Pdf_Action_JavaScript($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'SetOCGState':
|
||||
// require_once 'Zend/Pdf/Action/SetOCGState.php';
|
||||
return new Zend_Pdf_Action_SetOCGState($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'Rendition':
|
||||
// require_once 'Zend/Pdf/Action/Rendition.php';
|
||||
return new Zend_Pdf_Action_Rendition($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'Trans':
|
||||
// require_once 'Zend/Pdf/Action/Trans.php';
|
||||
return new Zend_Pdf_Action_Trans($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
case 'GoTo3DView':
|
||||
// require_once 'Zend/Pdf/Action/GoTo3DView.php';
|
||||
return new Zend_Pdf_Action_GoTo3DView($dictionary, $processedActions);
|
||||
break;
|
||||
|
||||
default:
|
||||
// require_once 'Zend/Pdf/Action/Unknown.php';
|
||||
return new Zend_Pdf_Action_Unknown($dictionary, $processedActions);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource
|
||||
*
|
||||
* @internal
|
||||
* @return Zend_Pdf_Element
|
||||
*/
|
||||
public function getResource()
|
||||
{
|
||||
return $this->_actionDictionary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump Action and its child actions into PDF structures
|
||||
*
|
||||
* Returns dictionary indirect object or reference
|
||||
*
|
||||
* @internal
|
||||
* @param Zend_Pdf_ElementFactory $factory Object factory for newly created indirect objects
|
||||
* @param SplObjectStorage $processedActions list of already processed actions (used to prevent infinity loop caused by cyclic references)
|
||||
* @return Zend_Pdf_Element_Object|Zend_Pdf_Element_Reference Dictionary indirect object
|
||||
*/
|
||||
public function dumpAction(Zend_Pdf_ElementFactory_Interface $factory, SplObjectStorage $processedActions = null)
|
||||
{
|
||||
if ($processedActions === null) {
|
||||
$processedActions = new SplObjectStorage();
|
||||
}
|
||||
if ($processedActions->contains($this)) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Action chain cyclyc reference is detected.');
|
||||
}
|
||||
$processedActions->attach($this);
|
||||
|
||||
$childListUpdated = false;
|
||||
if (count($this->_originalNextList) != count($this->next)) {
|
||||
// If original and current children arrays have different size then children list was updated
|
||||
$childListUpdated = true;
|
||||
} else if ( !(array_keys($this->_originalNextList) === array_keys($this->next)) ) {
|
||||
// If original and current children arrays have different keys (with a glance to an order) then children list was updated
|
||||
$childListUpdated = true;
|
||||
} else {
|
||||
foreach ($this->next as $key => $childAction) {
|
||||
if ($this->_originalNextList[$key] !== $childAction) {
|
||||
$childListUpdated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($childListUpdated) {
|
||||
$this->_actionDictionary->touch();
|
||||
switch (count($this->next)) {
|
||||
case 0:
|
||||
$this->_actionDictionary->Next = null;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$child = reset($this->next);
|
||||
$this->_actionDictionary->Next = $child->dumpAction($factory, $processedActions);
|
||||
break;
|
||||
|
||||
default:
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
$pdfChildArray = new Zend_Pdf_Element_Array();
|
||||
foreach ($this->next as $child) {
|
||||
|
||||
$pdfChildArray->items[] = $child->dumpAction($factory, $processedActions);
|
||||
}
|
||||
$this->_actionDictionary->Next = $pdfChildArray;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
foreach ($this->next as $child) {
|
||||
$child->dumpAction($factory, $processedActions);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_actionDictionary instanceof Zend_Pdf_Element_Dictionary) {
|
||||
// It's a newly created action. Register it within object factory and return indirect object
|
||||
return $factory->newObject($this->_actionDictionary);
|
||||
} else {
|
||||
// It's a loaded object
|
||||
return $this->_actionDictionary;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// RecursiveIterator interface methods
|
||||
//////////////
|
||||
|
||||
/**
|
||||
* Returns current child action.
|
||||
*
|
||||
* @return Zend_Pdf_Action
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return current($this->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current iterator key
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return key($this->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Go to next child
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
return next($this->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind children
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
return reset($this->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current position is valid
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return current($this->next) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the child action.
|
||||
*
|
||||
* @return Zend_Pdf_Action|null
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return current($this->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RecursiveIterator interface.
|
||||
*
|
||||
* @return bool whether container has any pages
|
||||
*/
|
||||
public function hasChildren()
|
||||
{
|
||||
return count($this->next) > 0;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Countable interface methods
|
||||
//////////////
|
||||
|
||||
/**
|
||||
* count()
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->childOutlines);
|
||||
}
|
||||
}
|
||||
116
library/Zend/Pdf/Action/GoTo.php
Normal file
116
library/Zend/Pdf/Action/GoTo.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: GoTo.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Destination.php';
|
||||
|
||||
// require_once 'Zend/Pdf/Element/Dictionary.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
/**
|
||||
* PDF 'Go to' action
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_GoTo extends Zend_Pdf_Action
|
||||
{
|
||||
/**
|
||||
* GoTo Action destination
|
||||
*
|
||||
* @var Zend_Pdf_Destination
|
||||
*/
|
||||
protected $_destination;
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
$this->_destination = Zend_Pdf_Destination::load($dictionary->D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new Zend_Pdf_Action_GoTo object using specified destination
|
||||
*
|
||||
* @param Zend_Pdf_Destination|string $destination
|
||||
* @return Zend_Pdf_Action_GoTo
|
||||
*/
|
||||
public static function create($destination)
|
||||
{
|
||||
if (is_string($destination)) {
|
||||
// require_once 'Zend/Pdf/Destination/Named.php';
|
||||
$destination = Zend_Pdf_Destination_Named::create($destination);
|
||||
}
|
||||
|
||||
if (!$destination instanceof Zend_Pdf_Destination) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('$destination parameter must be a Zend_Pdf_Destination object or string.');
|
||||
}
|
||||
|
||||
$dictionary = new Zend_Pdf_Element_Dictionary();
|
||||
$dictionary->Type = new Zend_Pdf_Element_Name('Action');
|
||||
$dictionary->S = new Zend_Pdf_Element_Name('GoTo');
|
||||
$dictionary->Next = null;
|
||||
$dictionary->D = $destination->getResource();
|
||||
|
||||
return new Zend_Pdf_Action_GoTo($dictionary, new SplObjectStorage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set goto action destination
|
||||
*
|
||||
* @param Zend_Pdf_Destination|string $destination
|
||||
* @return Zend_Pdf_Action_GoTo
|
||||
*/
|
||||
public function setDestination(Zend_Pdf_Destination $destination)
|
||||
{
|
||||
$this->_destination = $destination;
|
||||
|
||||
$this->_actionDictionary->touch();
|
||||
$this->_actionDictionary->D = $destination->getResource();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get goto action destination
|
||||
*
|
||||
* @return Zend_Pdf_Destination
|
||||
*/
|
||||
public function getDestination()
|
||||
{
|
||||
return $this->_destination;
|
||||
}
|
||||
}
|
||||
39
library/Zend/Pdf/Action/GoTo3DView.php
Normal file
39
library/Zend/Pdf/Action/GoTo3DView.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: GoTo3DView.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Set the current view of a 3D annotation' action
|
||||
* PDF 1.6+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_GoTo3DView extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
38
library/Zend/Pdf/Action/GoToE.php
Normal file
38
library/Zend/Pdf/Action/GoToE.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: GoToE.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Go to a destination in an embedded file' action
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_GoToE extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
38
library/Zend/Pdf/Action/GoToR.php
Normal file
38
library/Zend/Pdf/Action/GoToR.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: GoToR.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Go to a destination in another document' action
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_GoToR extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
39
library/Zend/Pdf/Action/Hide.php
Normal file
39
library/Zend/Pdf/Action/Hide.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Hide.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Set an annotation’s Hidden flag' action
|
||||
* PDF 1.2+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_Hide extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
39
library/Zend/Pdf/Action/ImportData.php
Normal file
39
library/Zend/Pdf/Action/ImportData.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ImportData.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Import field values from a file' action
|
||||
* PDF 1.2+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_ImportData extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
39
library/Zend/Pdf/Action/JavaScript.php
Normal file
39
library/Zend/Pdf/Action/JavaScript.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: JavaScript.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** 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-2012 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
|
||||
{
|
||||
}
|
||||
|
||||
38
library/Zend/Pdf/Action/Launch.php
Normal file
38
library/Zend/Pdf/Action/Launch.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Launch.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Launch an application, usually to open a file' action
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_Launch extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
38
library/Zend/Pdf/Action/Movie.php
Normal file
38
library/Zend/Pdf/Action/Movie.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Movie.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Play a movie' action
|
||||
* PDF 1.2+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_Movie extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
39
library/Zend/Pdf/Action/Named.php
Normal file
39
library/Zend/Pdf/Action/Named.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Named.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Execute an action predefined by the viewer application' action
|
||||
* PDF 1.2+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_Named extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
39
library/Zend/Pdf/Action/Rendition.php
Normal file
39
library/Zend/Pdf/Action/Rendition.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Rendition.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Controls the playing of multimedia content' action
|
||||
* PDF 1.5+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_Rendition extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
39
library/Zend/Pdf/Action/ResetForm.php
Normal file
39
library/Zend/Pdf/Action/ResetForm.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ResetForm.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Set fields to their default values' action
|
||||
* PDF 1.2+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_ResetForm extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
39
library/Zend/Pdf/Action/SetOCGState.php
Normal file
39
library/Zend/Pdf/Action/SetOCGState.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: SetOCGState.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Set the states of optional content groups' action
|
||||
* PDF 1.5+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_SetOCGState extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
39
library/Zend/Pdf/Action/Sound.php
Normal file
39
library/Zend/Pdf/Action/Sound.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Sound.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Play a sound' action representation class
|
||||
* PDF 1.2+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_Sound extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
39
library/Zend/Pdf/Action/SubmitForm.php
Normal file
39
library/Zend/Pdf/Action/SubmitForm.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: SubmitForm.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Send data to a uniform resource locator' action
|
||||
* PDF 1.2+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_SubmitForm extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
38
library/Zend/Pdf/Action/Thread.php
Normal file
38
library/Zend/Pdf/Action/Thread.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Thread.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Begin reading an article thread' action
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_Thread extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
39
library/Zend/Pdf/Action/Trans.php
Normal file
39
library/Zend/Pdf/Action/Trans.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Trans.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Updates the display of a document, using a transition dictionary' action
|
||||
* PDF 1.5+ feature
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_Trans extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
167
library/Zend/Pdf/Action/URI.php
Normal file
167
library/Zend/Pdf/Action/URI.php
Normal file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: URI.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Dictionary.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/String.php';
|
||||
// require_once 'Zend/Pdf/Element/Boolean.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF 'Resolve a uniform resource identifier' action
|
||||
*
|
||||
* A URI action causes a URI to be resolved.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_URI 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
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions)
|
||||
{
|
||||
parent::__construct($dictionary, $processedActions);
|
||||
|
||||
if ($dictionary->URI === null) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('URI action dictionary entry is required');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate URI
|
||||
*
|
||||
* @param string $uri
|
||||
* @return true
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
protected static function _validateUri($uri)
|
||||
{
|
||||
$scheme = parse_url((string)$uri, PHP_URL_SCHEME);
|
||||
if ($scheme === false || $scheme === null) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Invalid URI');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new Zend_Pdf_Action_URI object using specified uri
|
||||
*
|
||||
* @param string $uri The URI to resolve, encoded in 7-bit ASCII
|
||||
* @param boolean $isMap A flag specifying whether to track the mouse position when the URI is resolved
|
||||
* @return Zend_Pdf_Action_URI
|
||||
*/
|
||||
public static function create($uri, $isMap = false)
|
||||
{
|
||||
self::_validateUri($uri);
|
||||
|
||||
$dictionary = new Zend_Pdf_Element_Dictionary();
|
||||
$dictionary->Type = new Zend_Pdf_Element_Name('Action');
|
||||
$dictionary->S = new Zend_Pdf_Element_Name('URI');
|
||||
$dictionary->Next = null;
|
||||
$dictionary->URI = new Zend_Pdf_Element_String($uri);
|
||||
if ($isMap) {
|
||||
$dictionary->IsMap = new Zend_Pdf_Element_Boolean(true);
|
||||
}
|
||||
|
||||
return new Zend_Pdf_Action_URI($dictionary, new SplObjectStorage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set URI to resolve
|
||||
*
|
||||
* @param string $uri The uri to resolve, encoded in 7-bit ASCII.
|
||||
* @return Zend_Pdf_Action_URI
|
||||
*/
|
||||
public function setUri($uri)
|
||||
{
|
||||
$this->_validateUri($uri);
|
||||
|
||||
$this->_actionDictionary->touch();
|
||||
$this->_actionDictionary->URI = new Zend_Pdf_Element_String($uri);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URI to resolve
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUri()
|
||||
{
|
||||
return $this->_actionDictionary->URI->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set IsMap property
|
||||
*
|
||||
* If the IsMap flag is true and the user has triggered the URI action by clicking
|
||||
* an annotation, the coordinates of the mouse position at the time the action is
|
||||
* performed should be transformed from device space to user space and then offset
|
||||
* relative to the upper-left corner of the annotation rectangle.
|
||||
*
|
||||
* @param boolean $isMap A flag specifying whether to track the mouse position when the URI is resolved
|
||||
* @return Zend_Pdf_Action_URI
|
||||
*/
|
||||
public function setIsMap($isMap)
|
||||
{
|
||||
$this->_actionDictionary->touch();
|
||||
|
||||
if ($isMap) {
|
||||
$this->_actionDictionary->IsMap = new Zend_Pdf_Element_Boolean(true);
|
||||
} else {
|
||||
$this->_actionDictionary->IsMap = null;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IsMap property
|
||||
*
|
||||
* If the IsMap flag is true and the user has triggered the URI action by clicking
|
||||
* an annotation, the coordinates of the mouse position at the time the action is
|
||||
* performed should be transformed from device space to user space and then offset
|
||||
* relative to the upper-left corner of the annotation rectangle.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsMap()
|
||||
{
|
||||
return $this->_actionDictionary->IsMap !== null &&
|
||||
$this->_actionDictionary->IsMap->value;
|
||||
}
|
||||
}
|
||||
38
library/Zend/Pdf/Action/Unknown.php
Normal file
38
library/Zend/Pdf/Action/Unknown.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Unknown.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Action */
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
|
||||
|
||||
/**
|
||||
* Unrecognized PDF action
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Action_Unknown extends Zend_Pdf_Action
|
||||
{
|
||||
}
|
||||
|
||||
230
library/Zend/Pdf/Annotation.php
Normal file
230
library/Zend/Pdf/Annotation.php
Normal file
@ -0,0 +1,230 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Annotation
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Annotation.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
|
||||
/**
|
||||
* Abstract PDF annotation representation class
|
||||
*
|
||||
* An annotation associates an object such as a note, sound, or movie with a location
|
||||
* on a page of a PDF document, or provides a way to interact with the user by
|
||||
* means of the mouse and keyboard.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Annotation
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Pdf_Annotation
|
||||
{
|
||||
/**
|
||||
* Annotation dictionary
|
||||
*
|
||||
* @var Zend_Pdf_Element_Dictionary|Zend_Pdf_Element_Object|Zend_Pdf_Element_Reference
|
||||
*/
|
||||
protected $_annotationDictionary;
|
||||
|
||||
/**
|
||||
* Get annotation dictionary
|
||||
*
|
||||
* @internal
|
||||
* @return Zend_Pdf_Element
|
||||
*/
|
||||
public function getResource()
|
||||
{
|
||||
return $this->_annotationDictionary;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set bottom edge of the annotation rectangle.
|
||||
*
|
||||
* @param float $bottom
|
||||
* @return Zend_Pdf_Annotation
|
||||
*/
|
||||
public function setBottom($bottom) {
|
||||
$this->_annotationDictionary->Rect->items[1]->touch();
|
||||
$this->_annotationDictionary->Rect->items[1]->value = $bottom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bottom edge of the annotation rectangle.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getBottom() {
|
||||
return $this->_annotationDictionary->Rect->items[1]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top edge of the annotation rectangle.
|
||||
*
|
||||
* @param float $top
|
||||
* @return Zend_Pdf_Annotation
|
||||
*/
|
||||
public function setTop($top) {
|
||||
$this->_annotationDictionary->Rect->items[3]->touch();
|
||||
$this->_annotationDictionary->Rect->items[3]->value = $top;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get top edge of the annotation rectangle.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTop() {
|
||||
return $this->_annotationDictionary->Rect->items[3]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set right edge of the annotation rectangle.
|
||||
*
|
||||
* @param float $right
|
||||
* @return Zend_Pdf_Annotation
|
||||
*/
|
||||
public function setRight($right) {
|
||||
$this->_annotationDictionary->Rect->items[2]->touch();
|
||||
$this->_annotationDictionary->Rect->items[2]->value = $right;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get right edge of the annotation rectangle.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getRight() {
|
||||
return $this->_annotationDictionary->Rect->items[2]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left edge of the annotation rectangle.
|
||||
*
|
||||
* @param float $left
|
||||
* @return Zend_Pdf_Annotation
|
||||
*/
|
||||
public function setLeft($left) {
|
||||
$this->_annotationDictionary->Rect->items[0]->touch();
|
||||
$this->_annotationDictionary->Rect->items[0]->value = $left;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get left edge of the annotation rectangle.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getLeft() {
|
||||
return $this->_annotationDictionary->Rect->items[0]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return text to be displayed for the annotation or, if this type of annotation
|
||||
* does not display text, an alternate description of the annotation’s contents
|
||||
* in human-readable form.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText() {
|
||||
if ($this->_annotationDictionary->Contents === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->_annotationDictionary->Contents->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text to be displayed for the annotation or, if this type of annotation
|
||||
* does not display text, an alternate description of the annotation’s contents
|
||||
* in human-readable form.
|
||||
*
|
||||
* @param string $text
|
||||
* @return Zend_Pdf_Annotation
|
||||
*/
|
||||
public function setText($text) {
|
||||
// require_once 'Zend/Pdf/Element/String.php';
|
||||
|
||||
if ($this->_annotationDictionary->Contents === null) {
|
||||
$this->_annotationDictionary->touch();
|
||||
$this->_annotationDictionary->Contents = new Zend_Pdf_Element_String($text);
|
||||
} else {
|
||||
$this->_annotationDictionary->Contents->touch();
|
||||
$this->_annotationDictionary->Contents->value = new Zend_Pdf_Element_String($text);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Annotation object constructor
|
||||
*
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $annotationDictionary)
|
||||
{
|
||||
if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
|
||||
}
|
||||
|
||||
$this->_annotationDictionary = $annotationDictionary;
|
||||
|
||||
if ($this->_annotationDictionary->Type !== null &&
|
||||
$this->_annotationDictionary->Type->value != 'Annot') {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Wrong resource type. \'Annot\' expected.');
|
||||
}
|
||||
|
||||
if ($this->_annotationDictionary->Rect === null) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('\'Rect\' dictionary entry is required.');
|
||||
}
|
||||
|
||||
if (count($this->_annotationDictionary->Rect->items) != 4 ||
|
||||
$this->_annotationDictionary->Rect->items[0]->getType() != Zend_Pdf_Element::TYPE_NUMERIC ||
|
||||
$this->_annotationDictionary->Rect->items[1]->getType() != Zend_Pdf_Element::TYPE_NUMERIC ||
|
||||
$this->_annotationDictionary->Rect->items[2]->getType() != Zend_Pdf_Element::TYPE_NUMERIC ||
|
||||
$this->_annotationDictionary->Rect->items[3]->getType() != Zend_Pdf_Element::TYPE_NUMERIC ) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('\'Rect\' dictionary entry must be an array of four numeric elements.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Annotation object from a specified resource
|
||||
*
|
||||
* @internal
|
||||
* @param Zend_Pdf_Element $resource
|
||||
* @return Zend_Pdf_Annotation
|
||||
*/
|
||||
public static function load(Zend_Pdf_Element $resource)
|
||||
{
|
||||
/** @todo implementation */
|
||||
}
|
||||
}
|
||||
101
library/Zend/Pdf/Annotation/FileAttachment.php
Normal file
101
library/Zend/Pdf/Annotation/FileAttachment.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Annotation
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FileAttachment.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Dictionary.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
// require_once 'Zend/Pdf/Element/String.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Annotation */
|
||||
// require_once 'Zend/Pdf/Annotation.php';
|
||||
|
||||
/**
|
||||
* A file attachment annotation contains a reference to a file,
|
||||
* which typically is embedded in the PDF file.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Annotation
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Annotation_FileAttachment extends Zend_Pdf_Annotation
|
||||
{
|
||||
/**
|
||||
* Annotation object constructor
|
||||
*
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $annotationDictionary)
|
||||
{
|
||||
if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
|
||||
}
|
||||
|
||||
if ($annotationDictionary->Subtype === null ||
|
||||
$annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME ||
|
||||
$annotationDictionary->Subtype->value != 'FileAttachment') {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Subtype => FileAttachment entry is requires');
|
||||
}
|
||||
|
||||
parent::__construct($annotationDictionary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create link annotation object
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param string $fileSpecification
|
||||
* @return Zend_Pdf_Annotation_FileAttachment
|
||||
*/
|
||||
public static function create($x1, $y1, $x2, $y2, $fileSpecification)
|
||||
{
|
||||
$annotationDictionary = new Zend_Pdf_Element_Dictionary();
|
||||
|
||||
$annotationDictionary->Type = new Zend_Pdf_Element_Name('Annot');
|
||||
$annotationDictionary->Subtype = new Zend_Pdf_Element_Name('FileAttachment');
|
||||
|
||||
$rectangle = new Zend_Pdf_Element_Array();
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($x1);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($y1);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($x2);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($y2);
|
||||
$annotationDictionary->Rect = $rectangle;
|
||||
|
||||
$fsDictionary = new Zend_Pdf_Element_Dictionary();
|
||||
$fsDictionary->Type = new Zend_Pdf_Element_Name('Filespec');
|
||||
$fsDictionary->F = new Zend_Pdf_Element_String($fileSpecification);
|
||||
|
||||
$annotationDictionary->FS = $fsDictionary;
|
||||
|
||||
|
||||
return new Zend_Pdf_Annotation_FileAttachment($annotationDictionary);
|
||||
}
|
||||
}
|
||||
162
library/Zend/Pdf/Annotation/Link.php
Normal file
162
library/Zend/Pdf/Annotation/Link.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Annotation
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Link.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Dictionary.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Annotation */
|
||||
// require_once 'Zend/Pdf/Annotation.php';
|
||||
|
||||
/**
|
||||
* A link annotation represents either a hypertext link to a destination elsewhere in
|
||||
* the document or an action to be performed.
|
||||
*
|
||||
* Only destinations are used now since only GoTo action can be created by user
|
||||
* in current implementation.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Annotation
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Annotation_Link extends Zend_Pdf_Annotation
|
||||
{
|
||||
/**
|
||||
* Annotation object constructor
|
||||
*
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $annotationDictionary)
|
||||
{
|
||||
if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
|
||||
}
|
||||
|
||||
if ($annotationDictionary->Subtype === null ||
|
||||
$annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME ||
|
||||
$annotationDictionary->Subtype->value != 'Link') {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Subtype => Link entry is requires');
|
||||
}
|
||||
|
||||
parent::__construct($annotationDictionary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create link annotation object
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param Zend_Pdf_Target|string $target
|
||||
* @return Zend_Pdf_Annotation_Link
|
||||
*/
|
||||
public static function create($x1, $y1, $x2, $y2, $target)
|
||||
{
|
||||
if (is_string($target)) {
|
||||
// require_once 'Zend/Pdf/Destination/Named.php';
|
||||
$destination = Zend_Pdf_Destination_Named::create($target);
|
||||
}
|
||||
if (!$target instanceof Zend_Pdf_Target) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('$target parameter must be a Zend_Pdf_Target object or a string.');
|
||||
}
|
||||
|
||||
$annotationDictionary = new Zend_Pdf_Element_Dictionary();
|
||||
|
||||
$annotationDictionary->Type = new Zend_Pdf_Element_Name('Annot');
|
||||
$annotationDictionary->Subtype = new Zend_Pdf_Element_Name('Link');
|
||||
|
||||
$rectangle = new Zend_Pdf_Element_Array();
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($x1);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($y1);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($x2);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($y2);
|
||||
$annotationDictionary->Rect = $rectangle;
|
||||
|
||||
if ($target instanceof Zend_Pdf_Destination) {
|
||||
$annotationDictionary->Dest = $target->getResource();
|
||||
} else {
|
||||
$annotationDictionary->A = $target->getResource();
|
||||
}
|
||||
|
||||
return new Zend_Pdf_Annotation_Link($annotationDictionary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set link annotation destination
|
||||
*
|
||||
* @param Zend_Pdf_Target|string $target
|
||||
* @return Zend_Pdf_Annotation_Link
|
||||
*/
|
||||
public function setDestination($target)
|
||||
{
|
||||
if (is_string($target)) {
|
||||
// require_once 'Zend/Pdf/Destination/Named.php';
|
||||
$destination = Zend_Pdf_Destination_Named::create($target);
|
||||
}
|
||||
if (!$target instanceof Zend_Pdf_Target) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('$target parameter must be a Zend_Pdf_Target object or a string.');
|
||||
}
|
||||
|
||||
$this->_annotationDictionary->touch();
|
||||
$this->_annotationDictionary->Dest = $destination->getResource();
|
||||
if ($target instanceof Zend_Pdf_Destination) {
|
||||
$this->_annotationDictionary->Dest = $target->getResource();
|
||||
$this->_annotationDictionary->A = null;
|
||||
} else {
|
||||
$this->_annotationDictionary->Dest = null;
|
||||
$this->_annotationDictionary->A = $target->getResource();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link annotation destination
|
||||
*
|
||||
* @return Zend_Pdf_Target|null
|
||||
*/
|
||||
public function getDestination()
|
||||
{
|
||||
if ($this->_annotationDictionary->Dest === null &&
|
||||
$this->_annotationDictionary->A === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->_annotationDictionary->Dest !== null) {
|
||||
// require_once 'Zend/Pdf/Destination.php';
|
||||
return Zend_Pdf_Destination::load($this->_annotationDictionary->Dest);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Action.php';
|
||||
return Zend_Pdf_Action::load($this->_annotationDictionary->A);
|
||||
}
|
||||
}
|
||||
}
|
||||
142
library/Zend/Pdf/Annotation/Markup.php
Normal file
142
library/Zend/Pdf/Annotation/Markup.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Annotation
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Markup.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Dictionary.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
// require_once 'Zend/Pdf/Element/String.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Annotation */
|
||||
// require_once 'Zend/Pdf/Annotation.php';
|
||||
|
||||
/**
|
||||
* A markup annotation
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Annotation
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Annotation_Markup extends Zend_Pdf_Annotation
|
||||
{
|
||||
/**
|
||||
* Annotation subtypes
|
||||
*/
|
||||
const SUBTYPE_HIGHLIGHT = 'Highlight';
|
||||
const SUBTYPE_UNDERLINE = 'Underline';
|
||||
const SUBTYPE_SQUIGGLY = 'Squiggly';
|
||||
const SUBTYPE_STRIKEOUT = 'StrikeOut';
|
||||
|
||||
/**
|
||||
* Annotation object constructor
|
||||
*
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $annotationDictionary)
|
||||
{
|
||||
if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
|
||||
}
|
||||
|
||||
if ($annotationDictionary->Subtype === null ||
|
||||
$annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME ||
|
||||
!in_array( $annotationDictionary->Subtype->value,
|
||||
array(self::SUBTYPE_HIGHLIGHT,
|
||||
self::SUBTYPE_UNDERLINE,
|
||||
self::SUBTYPE_SQUIGGLY,
|
||||
self::SUBTYPE_STRIKEOUT) )) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Subtype => Markup entry is omitted or has wrong value.');
|
||||
}
|
||||
|
||||
parent::__construct($annotationDictionary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create markup annotation object
|
||||
*
|
||||
* Text markup annotations appear as highlights, underlines, strikeouts or
|
||||
* jagged ("squiggly") underlines in the text of a document. When opened,
|
||||
* they display a pop-up window containing the text of the associated note.
|
||||
*
|
||||
* $subType parameter may contain
|
||||
* Zend_Pdf_Annotation_Markup::SUBTYPE_HIGHLIGHT
|
||||
* Zend_Pdf_Annotation_Markup::SUBTYPE_UNDERLINE
|
||||
* Zend_Pdf_Annotation_Markup::SUBTYPE_SQUIGGLY
|
||||
* Zend_Pdf_Annotation_Markup::SUBTYPE_STRIKEOUT
|
||||
* for for a highlight, underline, squiggly-underline, or strikeout annotation,
|
||||
* respectively.
|
||||
*
|
||||
* $quadPoints is an array of 8xN numbers specifying the coordinates of
|
||||
* N quadrilaterals default user space. Each quadrilateral encompasses a word or
|
||||
* group of contiguous words in the text underlying the annotation.
|
||||
* The coordinates for each quadrilateral are given in the order
|
||||
* x1 y1 x2 y2 x3 y3 x4 y4
|
||||
* specifying the quadrilateral’s four vertices in counterclockwise order
|
||||
* starting from left bottom corner.
|
||||
* The text is oriented with respect to the edge connecting points
|
||||
* (x1, y1) and (x2, y2).
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param string $text
|
||||
* @param string $subType
|
||||
* @param array $quadPoints [x1 y1 x2 y2 x3 y3 x4 y4]
|
||||
* @return Zend_Pdf_Annotation_Markup
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function create($x1, $y1, $x2, $y2, $text, $subType, $quadPoints)
|
||||
{
|
||||
$annotationDictionary = new Zend_Pdf_Element_Dictionary();
|
||||
|
||||
$annotationDictionary->Type = new Zend_Pdf_Element_Name('Annot');
|
||||
$annotationDictionary->Subtype = new Zend_Pdf_Element_Name($subType);
|
||||
|
||||
$rectangle = new Zend_Pdf_Element_Array();
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($x1);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($y1);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($x2);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($y2);
|
||||
$annotationDictionary->Rect = $rectangle;
|
||||
|
||||
$annotationDictionary->Contents = new Zend_Pdf_Element_String($text);
|
||||
|
||||
if (!is_array($quadPoints) || count($quadPoints) == 0 || count($quadPoints) % 8 != 0) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('$quadPoints parameter must be an array of 8xN numbers');
|
||||
}
|
||||
$points = new Zend_Pdf_Element_Array();
|
||||
foreach ($quadPoints as $quadPoint) {
|
||||
$points->items[] = new Zend_Pdf_Element_Numeric($quadPoint);
|
||||
}
|
||||
$annotationDictionary->QuadPoints = $points;
|
||||
|
||||
return new Zend_Pdf_Annotation_Markup($annotationDictionary);
|
||||
}
|
||||
}
|
||||
95
library/Zend/Pdf/Annotation/Text.php
Normal file
95
library/Zend/Pdf/Annotation/Text.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Annotation
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Text.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Dictionary.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
// require_once 'Zend/Pdf/Element/String.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Annotation */
|
||||
// require_once 'Zend/Pdf/Annotation.php';
|
||||
|
||||
/**
|
||||
* A text annotation represents a "sticky note" attached to a point in the PDF document.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Annotation
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Annotation_Text extends Zend_Pdf_Annotation
|
||||
{
|
||||
/**
|
||||
* Annotation object constructor
|
||||
*
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $annotationDictionary)
|
||||
{
|
||||
if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
|
||||
}
|
||||
|
||||
if ($annotationDictionary->Subtype === null ||
|
||||
$annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME ||
|
||||
$annotationDictionary->Subtype->value != 'Text') {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Subtype => Text entry is requires');
|
||||
}
|
||||
|
||||
parent::__construct($annotationDictionary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create link annotation object
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param string $text
|
||||
* @return Zend_Pdf_Annotation_Text
|
||||
*/
|
||||
public static function create($x1, $y1, $x2, $y2, $text)
|
||||
{
|
||||
$annotationDictionary = new Zend_Pdf_Element_Dictionary();
|
||||
|
||||
$annotationDictionary->Type = new Zend_Pdf_Element_Name('Annot');
|
||||
$annotationDictionary->Subtype = new Zend_Pdf_Element_Name('Text');
|
||||
|
||||
$rectangle = new Zend_Pdf_Element_Array();
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($x1);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($y1);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($x2);
|
||||
$rectangle->items[] = new Zend_Pdf_Element_Numeric($y2);
|
||||
$annotationDictionary->Rect = $rectangle;
|
||||
|
||||
$annotationDictionary->Contents = new Zend_Pdf_Element_String($text);
|
||||
|
||||
return new Zend_Pdf_Annotation_Text($annotationDictionary);
|
||||
}
|
||||
}
|
||||
182
library/Zend/Pdf/Canvas.php
Normal file
182
library/Zend/Pdf/Canvas.php
Normal file
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Style.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
// require_once 'Zend/Pdf/Canvas/Abstract.php';
|
||||
|
||||
/**
|
||||
* Canvas is an abstract rectangle drawing area which can be dropped into
|
||||
* page object at specified place.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Canvas extends Zend_Pdf_Canvas_Abstract
|
||||
{
|
||||
/**
|
||||
* Canvas procedure sets.
|
||||
*
|
||||
* Allowed values: 'PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_procSet = array();
|
||||
|
||||
/**
|
||||
* Canvas width expressed in default user space units (1/72 inch)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $_width;
|
||||
|
||||
/**
|
||||
* Canvas height expressed in default user space units (1/72 inch)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $_height;
|
||||
|
||||
protected $_resources = array('Font' => array(),
|
||||
'XObject' => array(),
|
||||
'ExtGState' => array());
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param float $width
|
||||
* @param float $height
|
||||
*/
|
||||
public function __construct($width, $height)
|
||||
{
|
||||
$this->_width = $width;
|
||||
$this->_height = $height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add procedure set to the canvas description
|
||||
*
|
||||
* @param string $procSetName
|
||||
*/
|
||||
protected function _addProcSet($procSetName)
|
||||
{
|
||||
$this->_procset[$procSetName] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach resource to the canvas
|
||||
*
|
||||
* Method returns a name of the resource which can be used
|
||||
* as a resource reference within drawing instructions stream
|
||||
* Allowed types: 'ExtGState', 'ColorSpace', 'Pattern', 'Shading',
|
||||
* 'XObject', 'Font', 'Properties'
|
||||
*
|
||||
* @param string $type
|
||||
* @param Zend_Pdf_Resource $resource
|
||||
* @return string
|
||||
*/
|
||||
protected function _attachResource($type, Zend_Pdf_Resource $resource)
|
||||
{
|
||||
// Check, that resource is already attached to resource set.
|
||||
$resObject = $resource->getResource();
|
||||
foreach ($this->_resources[$type] as $resName => $collectedResObject) {
|
||||
if ($collectedResObject === $resObject) {
|
||||
return $resName;
|
||||
}
|
||||
}
|
||||
|
||||
$idCounter = 1;
|
||||
do {
|
||||
$newResName = $type[0] . $idCounter++;
|
||||
} while (isset($this->_resources[$type][$newResName]));
|
||||
|
||||
$this->_resources[$type][$newResName] = $resObject;
|
||||
|
||||
return $newResName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns dictionaries of used resources.
|
||||
*
|
||||
* Used for canvas implementations interoperability
|
||||
*
|
||||
* Structure of the returned array:
|
||||
* array(
|
||||
* <resTypeName> => array(
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* ...
|
||||
* ),
|
||||
* <resTypeName> => array(
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* ...
|
||||
* ),
|
||||
* ...
|
||||
* 'ProcSet' => array()
|
||||
* )
|
||||
*
|
||||
* where ProcSet array is a list of used procedure sets names (strings).
|
||||
* Allowed procedure set names: 'PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'
|
||||
*
|
||||
* @internal
|
||||
* @return array
|
||||
*/
|
||||
public function getResources()
|
||||
{
|
||||
$this->_resources['ProcSet'] = array_keys($this->_procSet);
|
||||
return $this->_resources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get drawing instructions stream
|
||||
*
|
||||
* It has to be returned as a PDF stream object to make it reusable.
|
||||
*
|
||||
* @internal
|
||||
* @returns Zend_Pdf_Resource_ContentStream
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
/** @todo implementation */
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the height of this page in points.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the width of this page in points.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->_width;
|
||||
}
|
||||
}
|
||||
1217
library/Zend/Pdf/Canvas/Abstract.php
Normal file
1217
library/Zend/Pdf/Canvas/Abstract.php
Normal file
File diff suppressed because it is too large
Load Diff
493
library/Zend/Pdf/Canvas/Interface.php
Normal file
493
library/Zend/Pdf/Canvas/Interface.php
Normal file
@ -0,0 +1,493 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Style.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Canvas is an abstract rectangle drawing area which can be dropped into
|
||||
* page object at specified place.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Pdf_Canvas_Interface
|
||||
{
|
||||
/**
|
||||
* Returns dictionaries of used resources.
|
||||
*
|
||||
* Used for canvas implementations interoperability
|
||||
*
|
||||
* Structure of the returned array:
|
||||
* array(
|
||||
* <resTypeName> => array(
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* ...
|
||||
* ),
|
||||
* <resTypeName> => array(
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* <resName> => <Zend_Pdf_Resource object>,
|
||||
* ...
|
||||
* ),
|
||||
* ...
|
||||
* 'ProcSet' => array()
|
||||
* )
|
||||
*
|
||||
* where ProcSet array is a list of used procedure sets names (strings).
|
||||
* Allowed procedure set names: 'PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'
|
||||
*
|
||||
* @internal
|
||||
* @return array
|
||||
*/
|
||||
public function getResources();
|
||||
|
||||
/**
|
||||
* Get drawing instructions stream
|
||||
*
|
||||
* It has to be returned as a PDF stream object to make it reusable.
|
||||
*
|
||||
* @internal
|
||||
* @returns Zend_Pdf_Resource_ContentStream
|
||||
*/
|
||||
public function getContents();
|
||||
|
||||
/**
|
||||
* Return canvas height.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getHeight();
|
||||
|
||||
/**
|
||||
* Return canvas width.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getWidth();
|
||||
|
||||
/**
|
||||
* Draw a canvas at the specified location
|
||||
*
|
||||
* If upper right corner is not specified then canvas heght and width
|
||||
* are used.
|
||||
*
|
||||
* @param Zend_Pdf_Canvas_Interface $canvas
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function drawCanvas(Zend_Pdf_Canvas_Interface $canvas, $x1, $y1, $x2 = null, $y2 = null);
|
||||
|
||||
/**
|
||||
* Set fill color.
|
||||
*
|
||||
* @param Zend_Pdf_Color $color
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function setFillColor(Zend_Pdf_Color $color);
|
||||
|
||||
/**
|
||||
* Set line color.
|
||||
*
|
||||
* @param Zend_Pdf_Color $color
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function setLineColor(Zend_Pdf_Color $color);
|
||||
|
||||
/**
|
||||
* Set line width.
|
||||
*
|
||||
* @param float $width
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function setLineWidth($width);
|
||||
|
||||
/**
|
||||
* Set line dashing pattern
|
||||
*
|
||||
* Pattern is an array of floats: array(on_length, off_length, on_length, off_length, ...)
|
||||
* or Zend_Pdf_Page::LINE_DASHING_SOLID constant
|
||||
* Phase is shift from the beginning of line.
|
||||
*
|
||||
* @param mixed $pattern
|
||||
* @param array $phase
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function setLineDashingPattern($pattern, $phase = 0);
|
||||
|
||||
/**
|
||||
* Set current font.
|
||||
*
|
||||
* @param Zend_Pdf_Resource_Font $font
|
||||
* @param float $fontSize
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function setFont(Zend_Pdf_Resource_Font $font, $fontSize);
|
||||
|
||||
/**
|
||||
* Set the style to use for future drawing operations on this page
|
||||
*
|
||||
* @param Zend_Pdf_Style $style
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function setStyle(Zend_Pdf_Style $style);
|
||||
|
||||
/**
|
||||
* Get current font.
|
||||
*
|
||||
* @return Zend_Pdf_Resource_Font $font
|
||||
*/
|
||||
public function getFont();
|
||||
|
||||
/**
|
||||
* Get current font size
|
||||
*
|
||||
* @return float $fontSize
|
||||
*/
|
||||
public function getFontSize();
|
||||
|
||||
/**
|
||||
* Return the style, applied to the page.
|
||||
*
|
||||
* @return Zend_Pdf_Style|null
|
||||
*/
|
||||
public function getStyle();
|
||||
|
||||
/**
|
||||
* Save the graphics state of this page.
|
||||
* This takes a snapshot of the currently applied style, position, clipping area and
|
||||
* any rotation/translation/scaling that has been applied.
|
||||
*
|
||||
* @throws Zend_Pdf_Exception - if a save is performed with an open path
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function saveGS();
|
||||
|
||||
/**
|
||||
* Set the transparancy
|
||||
*
|
||||
* $alpha == 0 - transparent
|
||||
* $alpha == 1 - opaque
|
||||
*
|
||||
* Transparency modes, supported by PDF:
|
||||
* Normal (default), Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight,
|
||||
* SoftLight, Difference, Exclusion
|
||||
*
|
||||
* @param float $alpha
|
||||
* @param string $mode
|
||||
* @throws Zend_Pdf_Exception
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function setAlpha($alpha, $mode = 'Normal');
|
||||
|
||||
/**
|
||||
* Intersect current clipping area with a circle.
|
||||
*
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
* @param float $radius
|
||||
* @param float $startAngle
|
||||
* @param float $endAngle
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function clipCircle($x, $y, $radius, $startAngle = null, $endAngle = null);
|
||||
|
||||
/**
|
||||
* Intersect current clipping area with a polygon.
|
||||
*
|
||||
* Method signatures:
|
||||
* drawEllipse($x1, $y1, $x2, $y2);
|
||||
* drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle);
|
||||
*
|
||||
* @todo process special cases with $x2-$x1 == 0 or $y2-$y1 == 0
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param float $startAngle
|
||||
* @param float $endAngle
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function clipEllipse($x1, $y1, $x2, $y2, $startAngle = null, $endAngle = null);
|
||||
|
||||
/**
|
||||
* Intersect current clipping area with a polygon.
|
||||
*
|
||||
* @param array $x - array of float (the X co-ordinates of the vertices)
|
||||
* @param array $y - array of float (the Y co-ordinates of the vertices)
|
||||
* @param integer $fillMethod
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function clipPolygon($x, $y, $fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING);
|
||||
|
||||
/**
|
||||
* Intersect current clipping area with a rectangle.
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function clipRectangle($x1, $y1, $x2, $y2);
|
||||
|
||||
/**
|
||||
* Draw a circle centered on x, y with a radius of radius.
|
||||
*
|
||||
* Method signatures:
|
||||
* drawCircle($x, $y, $radius);
|
||||
* drawCircle($x, $y, $radius, $fillType);
|
||||
* drawCircle($x, $y, $radius, $startAngle, $endAngle);
|
||||
* drawCircle($x, $y, $radius, $startAngle, $endAngle, $fillType);
|
||||
*
|
||||
*
|
||||
* It's not a really circle, because PDF supports only cubic Bezier curves.
|
||||
* But _very_ good approximation.
|
||||
* It differs from a real circle on a maximum 0.00026 radiuses
|
||||
* (at PI/8, 3*PI/8, 5*PI/8, 7*PI/8, 9*PI/8, 11*PI/8, 13*PI/8 and 15*PI/8 angles).
|
||||
* At 0, PI/4, PI/2, 3*PI/4, PI, 5*PI/4, 3*PI/2 and 7*PI/4 it's exactly a tangent to a circle.
|
||||
*
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
* @param float $radius
|
||||
* @param mixed $param4
|
||||
* @param mixed $param5
|
||||
* @param mixed $param6
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function drawCircle($x, $y, $radius, $param4 = null, $param5 = null, $param6 = null);
|
||||
|
||||
/**
|
||||
* Draw an ellipse inside the specified rectangle.
|
||||
*
|
||||
* Method signatures:
|
||||
* drawEllipse($x1, $y1, $x2, $y2);
|
||||
* drawEllipse($x1, $y1, $x2, $y2, $fillType);
|
||||
* drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle);
|
||||
* drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle, $fillType);
|
||||
*
|
||||
* @todo process special cases with $x2-$x1 == 0 or $y2-$y1 == 0
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param mixed $param5
|
||||
* @param mixed $param6
|
||||
* @param mixed $param7
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function drawEllipse($x1, $y1, $x2, $y2, $param5 = null, $param6 = null, $param7 = null);
|
||||
|
||||
/**
|
||||
* Draw an image at the specified position on the page.
|
||||
*
|
||||
* @param Zend_Pdf_Image $image
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function drawImage(Zend_Pdf_Resource_Image $image, $x1, $y1, $x2, $y2);
|
||||
|
||||
/**
|
||||
* Draw a LayoutBox at the specified position on the page.
|
||||
*
|
||||
* @internal (not implemented now)
|
||||
*
|
||||
* @param Zend_Pdf_Element_LayoutBox $box
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function drawLayoutBox($box, $x, $y);
|
||||
|
||||
/**
|
||||
* Draw a line from x1,y1 to x2,y2.
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function drawLine($x1, $y1, $x2, $y2);
|
||||
|
||||
/**
|
||||
* Draw a polygon.
|
||||
*
|
||||
* If $fillType is Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE or
|
||||
* Zend_Pdf_Page::SHAPE_DRAW_FILL, then polygon is automatically closed.
|
||||
* See detailed description of these methods in a PDF documentation
|
||||
* (section 4.4.2 Path painting Operators, Filling)
|
||||
*
|
||||
* @param array $x - array of float (the X co-ordinates of the vertices)
|
||||
* @param array $y - array of float (the Y co-ordinates of the vertices)
|
||||
* @param integer $fillType
|
||||
* @param integer $fillMethod
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function drawPolygon($x, $y,
|
||||
$fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE,
|
||||
$fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING);
|
||||
/**
|
||||
* Draw a rectangle.
|
||||
*
|
||||
* Fill types:
|
||||
* Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fill rectangle and stroke (default)
|
||||
* Zend_Pdf_Page::SHAPE_DRAW_STROKE - stroke rectangle
|
||||
* Zend_Pdf_Page::SHAPE_DRAW_FILL - fill rectangle
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param integer $fillType
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function drawRectangle($x1, $y1, $x2, $y2, $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE);
|
||||
|
||||
/**
|
||||
* Draw a rounded rectangle.
|
||||
*
|
||||
* Fill types:
|
||||
* Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fill rectangle and stroke (default)
|
||||
* Zend_Pdf_Page::SHAPE_DRAW_STROKE - stroke rectangle
|
||||
* Zend_Pdf_Page::SHAPE_DRAW_FILL - fill rectangle
|
||||
*
|
||||
* radius is an integer representing radius of the four corners, or an array
|
||||
* of four integers representing the radius starting at top left, going
|
||||
* clockwise
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param integer|array $radius
|
||||
* @param integer $fillType
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function drawRoundedRectangle($x1, $y1, $x2, $y2, $radius,
|
||||
$fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE);
|
||||
|
||||
/**
|
||||
* Draw a line of text at the specified position.
|
||||
*
|
||||
* @param string $text
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
* @param string $charEncoding (optional) Character encoding of source text.
|
||||
* Defaults to current locale.
|
||||
* @throws Zend_Pdf_Exception
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function drawText($text, $x, $y, $charEncoding = '');
|
||||
|
||||
/**
|
||||
* Close the path by drawing a straight line back to it's beginning.
|
||||
*
|
||||
* @internal (needs implementation)
|
||||
*
|
||||
* @throws Zend_Pdf_Exception - if a path hasn't been started with pathMove()
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function pathClose();
|
||||
|
||||
/**
|
||||
* Continue the open path in a straight line to the specified position.
|
||||
*
|
||||
* @internal (needs implementation)
|
||||
*
|
||||
* @param float $x - the X co-ordinate to move to
|
||||
* @param float $y - the Y co-ordinate to move to
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function pathLine($x, $y);
|
||||
|
||||
/**
|
||||
* Start a new path at the specified position. If a path has already been started,
|
||||
* move the cursor without drawing a line.
|
||||
*
|
||||
* @internal (needs implementation)
|
||||
*
|
||||
* @param float $x - the X co-ordinate to move to
|
||||
* @param float $y - the Y co-ordinate to move to
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function pathMove($x, $y);
|
||||
|
||||
/**
|
||||
* Rotate the page.
|
||||
*
|
||||
* @param float $x - the X co-ordinate of rotation point
|
||||
* @param float $y - the Y co-ordinate of rotation point
|
||||
* @param float $angle - rotation angle
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function rotate($x, $y, $angle);
|
||||
|
||||
/**
|
||||
* Scale coordination system.
|
||||
*
|
||||
* @param float $xScale - X dimention scale factor
|
||||
* @param float $yScale - Y dimention scale factor
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function scale($xScale, $yScale);
|
||||
|
||||
/**
|
||||
* Translate coordination system.
|
||||
*
|
||||
* @param float $xShift - X coordinate shift
|
||||
* @param float $yShift - Y coordinate shift
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function translate($xShift, $yShift);
|
||||
|
||||
/**
|
||||
* Translate coordination system.
|
||||
*
|
||||
* @param float $x - the X co-ordinate of axis skew point
|
||||
* @param float $y - the Y co-ordinate of axis skew point
|
||||
* @param float $xAngle - X axis skew angle
|
||||
* @param float $yAngle - Y axis skew angle
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function skew($x, $y, $xAngle, $yAngle);
|
||||
|
||||
/**
|
||||
* Writes the raw data to the page's content stream.
|
||||
*
|
||||
* Be sure to consult the PDF reference to ensure your syntax is correct. No
|
||||
* attempt is made to ensure the validity of the stream data.
|
||||
*
|
||||
* @param string $data
|
||||
* @param string $procSet (optional) Name of ProcSet to add.
|
||||
* @return Zend_Pdf_Canvas_Interface
|
||||
*/
|
||||
public function rawWrite($data, $procSet = null);
|
||||
}
|
||||
336
library/Zend/Pdf/Cmap.php
Normal file
336
library/Zend/Pdf/Cmap.php
Normal file
@ -0,0 +1,336 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Fonts
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Cmap.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Abstract helper class for {@link Zend_Pdf_Resource_Font} which manages font
|
||||
* character maps.
|
||||
*
|
||||
* Defines the public interface for concrete subclasses which are responsible
|
||||
* for mapping Unicode characters to the font's glyph numbers. Also provides
|
||||
* shared utility methods.
|
||||
*
|
||||
* Cmap objects should ordinarily be obtained through the factory method
|
||||
* {@link cmapWithTypeData()}.
|
||||
*
|
||||
* The supported character map types are those found in the OpenType spec. For
|
||||
* additional detail on the internal binary format of these tables, see:
|
||||
* <ul>
|
||||
* <li>{@link http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6cmap.html}
|
||||
* <li>{@link http://www.microsoft.com/OpenType/OTSpec/cmap.htm}
|
||||
* <li>{@link http://partners.adobe.com/public/developer/opentype/index_cmap.html}
|
||||
* </ul>
|
||||
*
|
||||
* @todo Write code for Zend_Pdf_FontCmap_HighByteMapping class.
|
||||
* @todo Write code for Zend_Pdf_FontCmap_MixedCoverage class.
|
||||
* @todo Write code for Zend_Pdf_FontCmap_TrimmedArray class.
|
||||
* @todo Write code for Zend_Pdf_FontCmap_SegmentedCoverage class.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Pdf_Cmap
|
||||
{
|
||||
/**** Class Constants ****/
|
||||
|
||||
|
||||
/* Cmap Table Types */
|
||||
|
||||
/**
|
||||
* Byte Encoding character map table type.
|
||||
*/
|
||||
const TYPE_BYTE_ENCODING = 0x00;
|
||||
|
||||
/**
|
||||
* High Byte Mapping character map table type.
|
||||
*/
|
||||
const TYPE_HIGH_BYTE_MAPPING = 0x02;
|
||||
|
||||
/**
|
||||
* Segment Value to Delta Mapping character map table type.
|
||||
*/
|
||||
const TYPE_SEGMENT_TO_DELTA = 0x04;
|
||||
|
||||
/**
|
||||
* Trimmed Table character map table type.
|
||||
*/
|
||||
const TYPE_TRIMMED_TABLE = 0x06;
|
||||
|
||||
/**
|
||||
* Mixed Coverage character map table type.
|
||||
*/
|
||||
const TYPE_MIXED_COVERAGE = 0x08;
|
||||
|
||||
/**
|
||||
* Trimmed Array character map table type.
|
||||
*/
|
||||
const TYPE_TRIMMED_ARRAY = 0x0a;
|
||||
|
||||
/**
|
||||
* Segmented Coverage character map table type.
|
||||
*/
|
||||
const TYPE_SEGMENTED_COVERAGE = 0x0c;
|
||||
|
||||
/**
|
||||
* Static Byte Encoding character map table type. Variant of
|
||||
* {@link TYPE_BYTEENCODING}.
|
||||
*/
|
||||
const TYPE_BYTE_ENCODING_STATIC = 0xf1;
|
||||
|
||||
/**
|
||||
* Unknown character map table type.
|
||||
*/
|
||||
const TYPE_UNKNOWN = 0xff;
|
||||
|
||||
|
||||
/* Special Glyph Names */
|
||||
|
||||
/**
|
||||
* Glyph representing missing characters.
|
||||
*/
|
||||
const MISSING_CHARACTER_GLYPH = 0x00;
|
||||
|
||||
|
||||
|
||||
/**** Public Interface ****/
|
||||
|
||||
|
||||
/* Factory Methods */
|
||||
|
||||
/**
|
||||
* Instantiates the appropriate concrete subclass based on the type of cmap
|
||||
* table and returns the instance.
|
||||
*
|
||||
* The cmap type must be one of the following values:
|
||||
* <ul>
|
||||
* <li>{@link Zend_Pdf_Cmap::TYPE_BYTE_ENCODING}
|
||||
* <li>{@link Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC}
|
||||
* <li>{@link Zend_Pdf_Cmap::TYPE_HIGH_BYTE_MAPPING}
|
||||
* <li>{@link Zend_Pdf_Cmap::TYPE_SEGMENT_TO_DELTA}
|
||||
* <li>{@link Zend_Pdf_Cmap::TYPE_TRIMMED_TABLE}
|
||||
* <li>{@link Zend_Pdf_Cmap::TYPE_MIXED_COVERAGE}
|
||||
* <li>{@link Zend_Pdf_Cmap::TYPE_TRIMMED_ARRAY}
|
||||
* <li>{@link Zend_Pdf_Cmap::TYPE_SEGMENTED_COVERAGE}
|
||||
* </ul>
|
||||
*
|
||||
* Throws an exception if the table type is invalid or the cmap table data
|
||||
* cannot be validated.
|
||||
*
|
||||
* @param integer $cmapType Type of cmap.
|
||||
* @param mixed $cmapData Cmap table data. Usually a string or array.
|
||||
* @return Zend_Pdf_Cmap
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function cmapWithTypeData($cmapType, $cmapData)
|
||||
{
|
||||
switch ($cmapType) {
|
||||
case Zend_Pdf_Cmap::TYPE_BYTE_ENCODING:
|
||||
// require_once 'Zend/Pdf/Cmap/ByteEncoding.php';
|
||||
return new Zend_Pdf_Cmap_ByteEncoding($cmapData);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC:
|
||||
// require_once 'Zend/Pdf/Cmap/ByteEncoding/Static.php';
|
||||
return new Zend_Pdf_Cmap_ByteEncoding_Static($cmapData);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_HIGH_BYTE_MAPPING:
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('High byte mapping cmap currently unsupported',
|
||||
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_SEGMENT_TO_DELTA:
|
||||
// require_once 'Zend/Pdf/Cmap/SegmentToDelta.php';
|
||||
return new Zend_Pdf_Cmap_SegmentToDelta($cmapData);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_TRIMMED_TABLE:
|
||||
// require_once 'Zend/Pdf/Cmap/TrimmedTable.php';
|
||||
return new Zend_Pdf_Cmap_TrimmedTable($cmapData);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_MIXED_COVERAGE:
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Mixed coverage cmap currently unsupported',
|
||||
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_TRIMMED_ARRAY:
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Trimmed array cmap currently unsupported',
|
||||
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_SEGMENTED_COVERAGE:
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Segmented coverage cmap currently unsupported',
|
||||
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
|
||||
|
||||
default:
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Unknown cmap type: $cmapType",
|
||||
Zend_Pdf_Exception::CMAP_UNKNOWN_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Abstract Methods */
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* Parses the raw binary table data. Throws an exception if the table is
|
||||
* malformed.
|
||||
*
|
||||
* @param string $cmapData Raw binary cmap table data.
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
abstract public function __construct($cmapData);
|
||||
|
||||
/**
|
||||
* Returns an array of glyph numbers corresponding to the Unicode characters.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumberForCharacter()}.
|
||||
*
|
||||
* @param array $characterCodes Array of Unicode character codes (code points).
|
||||
* @return array Array of glyph numbers.
|
||||
*/
|
||||
abstract public function glyphNumbersForCharacters($characterCodes);
|
||||
|
||||
/**
|
||||
* Returns the glyph number corresponding to the Unicode character.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
|
||||
* operations.
|
||||
*
|
||||
* @param integer $characterCode Unicode character code (code point).
|
||||
* @return integer Glyph number.
|
||||
*/
|
||||
abstract public function glyphNumberForCharacter($characterCode);
|
||||
|
||||
/**
|
||||
* Returns an array containing the Unicode characters that have entries in
|
||||
* this character map.
|
||||
*
|
||||
* @return array Unicode character codes.
|
||||
*/
|
||||
abstract public function getCoveredCharacters();
|
||||
|
||||
/**
|
||||
* Returns an array containing the glyphs numbers that have entries in this character map.
|
||||
* Keys are Unicode character codes (integers)
|
||||
*
|
||||
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
|
||||
* call, but this method do it in more effective way (prepare complete list instead of searching
|
||||
* glyph for each character code).
|
||||
*
|
||||
* @internal
|
||||
* @return array Array representing <Unicode character code> => <glyph number> pairs.
|
||||
*/
|
||||
abstract public function getCoveredCharactersGlyphs();
|
||||
|
||||
|
||||
/**** Internal Methods ****/
|
||||
|
||||
|
||||
/* Internal Utility Methods */
|
||||
|
||||
/**
|
||||
* Extracts a signed 2-byte integer from a string.
|
||||
*
|
||||
* Integers are always big-endian. Throws an exception if the index is out
|
||||
* of range.
|
||||
*
|
||||
* @param string &$data
|
||||
* @param integer $index Position in string of integer.
|
||||
* @return integer
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
protected function _extractInt2(&$data, $index)
|
||||
{
|
||||
if (($index < 0) | (($index + 1) > strlen($data))) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Index out of range: $index",
|
||||
Zend_Pdf_Exception::INDEX_OUT_OF_RANGE);
|
||||
}
|
||||
$number = ord($data[$index]);
|
||||
if (($number & 0x80) == 0x80) { // negative
|
||||
$number = ~((((~ $number) & 0xff) << 8) | ((~ ord($data[++$index])) & 0xff));
|
||||
} else {
|
||||
$number = ($number << 8) | ord($data[++$index]);
|
||||
}
|
||||
return $number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts an unsigned 2-byte integer from a string.
|
||||
*
|
||||
* Integers are always big-endian. Throws an exception if the index is out
|
||||
* of range.
|
||||
*
|
||||
* @param string &$data
|
||||
* @param integer $index Position in string of integer.
|
||||
* @return integer
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
protected function _extractUInt2(&$data, $index)
|
||||
{
|
||||
if (($index < 0) | (($index + 1) > strlen($data))) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Index out of range: $index",
|
||||
Zend_Pdf_Exception::INDEX_OUT_OF_RANGE);
|
||||
}
|
||||
$number = (ord($data[$index]) << 8) | ord($data[++$index]);
|
||||
return $number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts an unsigned 4-byte integer from a string.
|
||||
*
|
||||
* Integers are always big-endian. Throws an exception if the index is out
|
||||
* of range.
|
||||
*
|
||||
* NOTE: If you ask for a 4-byte unsigned integer on a 32-bit machine, the
|
||||
* resulting value WILL BE SIGNED because PHP uses signed integers internally
|
||||
* for everything. To guarantee portability, be sure to use bitwise or
|
||||
* similar operators on large integers!
|
||||
*
|
||||
* @param string &$data
|
||||
* @param integer $index Position in string of integer.
|
||||
* @return integer
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
protected function _extractUInt4(&$data, $index)
|
||||
{
|
||||
if (($index < 0) | (($index + 3) > strlen($data))) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Index out of range: $index",
|
||||
Zend_Pdf_Exception::INDEX_OUT_OF_RANGE);
|
||||
}
|
||||
$number = (ord($data[$index]) << 24) | (ord($data[++$index]) << 16) |
|
||||
(ord($data[++$index]) << 8) | ord($data[++$index]);
|
||||
return $number;
|
||||
}
|
||||
|
||||
}
|
||||
447
library/Zend/Pdf/Cmap/ByteEncoding.php
Normal file
447
library/Zend/Pdf/Cmap/ByteEncoding.php
Normal file
@ -0,0 +1,447 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Fonts
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ByteEncoding.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Cmap */
|
||||
// require_once 'Zend/Pdf/Cmap.php';
|
||||
|
||||
|
||||
/**
|
||||
* Implements the "byte encoding" character map (type 0).
|
||||
*
|
||||
* This is the (legacy) Apple standard encoding mechanism and provides coverage
|
||||
* for characters in the Mac Roman character set only. Consequently, this cmap
|
||||
* type should be used only as a last resort.
|
||||
*
|
||||
* The mapping from Mac Roman to Unicode can be found at
|
||||
* {@link http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT}.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Cmap_ByteEncoding extends Zend_Pdf_Cmap
|
||||
{
|
||||
/**** Instance Variables ****/
|
||||
|
||||
|
||||
/**
|
||||
* Glyph index array. Stores the actual glyph numbers. The array keys are
|
||||
* the translated Unicode code points.
|
||||
* @var array
|
||||
*/
|
||||
protected $_glyphIndexArray = array();
|
||||
|
||||
|
||||
|
||||
/**** Public Interface ****/
|
||||
|
||||
|
||||
/* Concrete Class Implementation */
|
||||
|
||||
/**
|
||||
* Returns an array of glyph numbers corresponding to the Unicode characters.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumberForCharacter()}.
|
||||
*
|
||||
* @param array $characterCodes Array of Unicode character codes (code points).
|
||||
* @return array Array of glyph numbers.
|
||||
*/
|
||||
public function glyphNumbersForCharacters($characterCodes)
|
||||
{
|
||||
$glyphNumbers = array();
|
||||
foreach ($characterCodes as $key => $characterCode) {
|
||||
|
||||
if (! isset($this->_glyphIndexArray[$characterCode])) {
|
||||
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
continue;
|
||||
}
|
||||
|
||||
$glyphNumbers[$key] = $this->_glyphIndexArray[$characterCode];
|
||||
|
||||
}
|
||||
return $glyphNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the glyph number corresponding to the Unicode character.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
|
||||
* operations.
|
||||
*
|
||||
* @param integer $characterCode Unicode character code (code point).
|
||||
* @return integer Glyph number.
|
||||
*/
|
||||
public function glyphNumberForCharacter($characterCode)
|
||||
{
|
||||
if (! isset($this->_glyphIndexArray[$characterCode])) {
|
||||
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
}
|
||||
return $this->_glyphIndexArray[$characterCode];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the Unicode characters that have entries in
|
||||
* this character map.
|
||||
*
|
||||
* @return array Unicode character codes.
|
||||
*/
|
||||
public function getCoveredCharacters()
|
||||
{
|
||||
return array_keys($this->_glyphIndexArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the glyphs numbers that have entries in this character map.
|
||||
* Keys are Unicode character codes (integers)
|
||||
*
|
||||
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
|
||||
* call, but this method do it in more effective way (prepare complete list instead of searching
|
||||
* glyph for each character code).
|
||||
*
|
||||
* @internal
|
||||
* @return array Array representing <Unicode character code> => <glyph number> pairs.
|
||||
*/
|
||||
public function getCoveredCharactersGlyphs()
|
||||
{
|
||||
return $this->_glyphIndexArray;
|
||||
}
|
||||
|
||||
|
||||
/* Object Lifecycle */
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* Parses the raw binary table data. Throws an exception if the table is
|
||||
* malformed.
|
||||
*
|
||||
* @param string $cmapData Raw binary cmap table data.
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($cmapData)
|
||||
{
|
||||
/* Sanity check: This table must be exactly 262 bytes long.
|
||||
*/
|
||||
$actualLength = strlen($cmapData);
|
||||
if ($actualLength != 262) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Insufficient table data',
|
||||
Zend_Pdf_Exception::CMAP_TABLE_DATA_TOO_SMALL);
|
||||
}
|
||||
|
||||
/* Sanity check: Make sure this is right data for this table type.
|
||||
*/
|
||||
$type = $this->_extractUInt2($cmapData, 0);
|
||||
if ($type != Zend_Pdf_Cmap::TYPE_BYTE_ENCODING) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Wrong cmap table type',
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_TYPE);
|
||||
}
|
||||
|
||||
$length = $this->_extractUInt2($cmapData, 2);
|
||||
if ($length != $actualLength) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Table length ($length) does not match actual length ($actualLength)",
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_LENGTH);
|
||||
}
|
||||
|
||||
/* Mapping tables should be language-independent. The font may not work
|
||||
* as expected if they are not. Unfortunately, many font files in the
|
||||
* wild incorrectly record a language ID in this field, so we can't
|
||||
* call this a failure.
|
||||
*/
|
||||
$language = $this->_extractUInt2($cmapData, 4);
|
||||
if ($language != 0) {
|
||||
// Record a warning here somehow?
|
||||
}
|
||||
|
||||
/* The mapping between the Mac Roman and Unicode characters is static.
|
||||
* For simplicity, just put all 256 glyph indices into one array keyed
|
||||
* off the corresponding Unicode character.
|
||||
*/
|
||||
$i = 6;
|
||||
$this->_glyphIndexArray[0x00] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x01] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x03] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x04] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x05] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x06] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x07] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x08] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x09] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x10] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x11] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x12] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x13] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x14] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x15] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x16] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x17] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x18] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x19] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x20] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x21] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x22] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x23] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x24] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x25] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x26] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x27] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x28] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x29] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x30] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x31] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x32] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x33] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x34] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x35] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x36] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x37] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x38] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x39] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x40] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x41] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x42] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x43] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x44] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x45] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x46] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x47] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x48] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x49] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x50] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x51] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x52] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x53] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x54] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x55] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x56] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x57] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x58] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x59] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x60] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x61] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x62] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x63] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x64] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x65] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x66] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x67] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x68] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x69] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x70] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x71] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x72] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x73] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x74] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x75] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x76] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x77] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x78] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x79] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc4] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc7] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xdc] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe0] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe2] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe4] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe3] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe7] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xea] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xeb] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xed] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xec] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xee] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xef] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf3] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf2] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf4] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xfa] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xfb] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xfc] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2020] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb0] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa2] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa3] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa7] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2022] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xdf] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xae] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2122] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb4] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2260] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x221e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2264] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2265] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2202] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2211] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x220f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x03c0] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x222b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xaa] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xba] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x03a9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xbf] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xac] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x221a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0192] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2248] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2206] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xab] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xbb] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2026] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa0] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc0] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc3] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0152] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0153] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2013] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2014] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x201c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x201d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2018] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2019] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf7] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x25ca] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xff] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0178] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2044] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x20ac] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2039] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x203a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xfb01] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xfb02] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2021] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb7] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x201a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x201e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2030] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc2] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xca] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xcb] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xcd] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xce] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xcf] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xcc] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd3] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd4] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf8ff] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd2] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xda] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xdb] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0131] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02c6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02dc] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xaf] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02d8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02d9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02da] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02dd] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02db] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02c7] = ord($cmapData[$i]);
|
||||
}
|
||||
|
||||
}
|
||||
62
library/Zend/Pdf/Cmap/ByteEncoding/Static.php
Normal file
62
library/Zend/Pdf/Cmap/ByteEncoding/Static.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Fonts
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Static.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Cmap_ByteEncoding */
|
||||
// require_once 'Zend/Pdf/Cmap/ByteEncoding.php';
|
||||
|
||||
|
||||
/**
|
||||
* Custom cmap type used for the Adobe Standard 14 PDF fonts.
|
||||
*
|
||||
* Just like {@link Zend_Pdf_Cmap_ByteEncoding} except that the constructor
|
||||
* takes a predefined array of glyph numbers and can cover any Unicode character.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Cmap_ByteEncoding_Static extends Zend_Pdf_Cmap_ByteEncoding
|
||||
{
|
||||
/**** Public Interface ****/
|
||||
|
||||
|
||||
/* Object Lifecycle */
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param array $cmapData Array whose keys are Unicode character codes and
|
||||
* values are glyph numbers.
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($cmapData)
|
||||
{
|
||||
if (! is_array($cmapData)) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Constructor parameter must be an array',
|
||||
Zend_Pdf_Exception::BAD_PARAMETER_TYPE);
|
||||
}
|
||||
$this->_glyphIndexArray = $cmapData;
|
||||
}
|
||||
|
||||
}
|
||||
407
library/Zend/Pdf/Cmap/SegmentToDelta.php
Normal file
407
library/Zend/Pdf/Cmap/SegmentToDelta.php
Normal file
@ -0,0 +1,407 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Fonts
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: SegmentToDelta.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Cmap */
|
||||
// require_once 'Zend/Pdf/Cmap.php';
|
||||
|
||||
|
||||
/**
|
||||
* Implements the "segment mapping to delta values" character map (type 4).
|
||||
*
|
||||
* This is the Microsoft standard mapping table type for OpenType fonts. It
|
||||
* provides the ability to cover multiple contiguous ranges of the Unicode
|
||||
* character set, with the exception of Unicode Surrogates (U+D800 - U+DFFF).
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Cmap_SegmentToDelta extends Zend_Pdf_Cmap
|
||||
{
|
||||
/**** Instance Variables ****/
|
||||
|
||||
|
||||
/**
|
||||
* The number of segments in the table.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_segmentCount = 0;
|
||||
|
||||
/**
|
||||
* The size of the binary search range for segments.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_searchRange = 0;
|
||||
|
||||
/**
|
||||
* The number of binary search steps required to cover the entire search
|
||||
* range.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_searchIterations = 0;
|
||||
|
||||
/**
|
||||
* Array of ending character codes for each segment.
|
||||
* @var array
|
||||
*/
|
||||
protected $_segmentTableEndCodes = array();
|
||||
|
||||
/**
|
||||
* The ending character code for the segment at the end of the low search
|
||||
* range.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_searchRangeEndCode = 0;
|
||||
|
||||
/**
|
||||
* Array of starting character codes for each segment.
|
||||
* @var array
|
||||
*/
|
||||
protected $_segmentTableStartCodes = array();
|
||||
|
||||
/**
|
||||
* Array of character code to glyph delta values for each segment.
|
||||
* @var array
|
||||
*/
|
||||
protected $_segmentTableIdDeltas = array();
|
||||
|
||||
/**
|
||||
* Array of offsets into the glyph index array for each segment.
|
||||
* @var array
|
||||
*/
|
||||
protected $_segmentTableIdRangeOffsets = array();
|
||||
|
||||
/**
|
||||
* Glyph index array. Stores glyph numbers, used with range offset.
|
||||
* @var array
|
||||
*/
|
||||
protected $_glyphIndexArray = array();
|
||||
|
||||
|
||||
|
||||
/**** Public Interface ****/
|
||||
|
||||
|
||||
/* Concrete Class Implementation */
|
||||
|
||||
/**
|
||||
* Returns an array of glyph numbers corresponding to the Unicode characters.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumberForCharacter()}.
|
||||
*
|
||||
* @param array $characterCodes Array of Unicode character codes (code points).
|
||||
* @return array Array of glyph numbers.
|
||||
*/
|
||||
public function glyphNumbersForCharacters($characterCodes)
|
||||
{
|
||||
$glyphNumbers = array();
|
||||
foreach ($characterCodes as $key => $characterCode) {
|
||||
|
||||
/* These tables only cover the 16-bit character range.
|
||||
*/
|
||||
if ($characterCode > 0xffff) {
|
||||
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Determine where to start the binary search. The segments are
|
||||
* ordered from lowest-to-highest. We are looking for the first
|
||||
* segment whose end code is greater than or equal to our character
|
||||
* code.
|
||||
*
|
||||
* If the end code at the top of the search range is larger, then
|
||||
* our target is probably below it.
|
||||
*
|
||||
* If it is smaller, our target is probably above it, so move the
|
||||
* search range to the end of the segment list.
|
||||
*/
|
||||
if ($this->_searchRangeEndCode >= $characterCode) {
|
||||
$searchIndex = $this->_searchRange;
|
||||
} else {
|
||||
$searchIndex = $this->_segmentCount;
|
||||
}
|
||||
|
||||
/* Now do a binary search to find the first segment whose end code
|
||||
* is greater or equal to our character code. No matter the number
|
||||
* of segments (there may be hundreds in a large font), we will only
|
||||
* need to perform $this->_searchIterations.
|
||||
*/
|
||||
for ($i = 1; $i <= $this->_searchIterations; $i++) {
|
||||
if ($this->_segmentTableEndCodes[$searchIndex] >= $characterCode) {
|
||||
$subtableIndex = $searchIndex;
|
||||
$searchIndex -= $this->_searchRange >> $i;
|
||||
} else {
|
||||
$searchIndex += $this->_searchRange >> $i;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the segment's start code is greater than our character code,
|
||||
* that character is not represented in this font. Move on.
|
||||
*/
|
||||
if ($this->_segmentTableStartCodes[$subtableIndex] > $characterCode) {
|
||||
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->_segmentTableIdRangeOffsets[$subtableIndex] == 0) {
|
||||
/* This segment uses a simple mapping from character code to
|
||||
* glyph number.
|
||||
*/
|
||||
$glyphNumbers[$key] = ($characterCode + $this->_segmentTableIdDeltas[$subtableIndex]) % 65536;
|
||||
|
||||
} else {
|
||||
/* This segment relies on the glyph index array to determine the
|
||||
* glyph number. The calculation below determines the correct
|
||||
* index into that array. It's a little odd because the range
|
||||
* offset in the font file is designed to quickly provide an
|
||||
* address of the index in the raw binary data instead of the
|
||||
* index itself. Since we've parsed the data into arrays, we
|
||||
* must process it a bit differently.
|
||||
*/
|
||||
$glyphIndex = ($characterCode - $this->_segmentTableStartCodes[$subtableIndex] +
|
||||
$this->_segmentTableIdRangeOffsets[$subtableIndex] - $this->_segmentCount +
|
||||
$subtableIndex - 1);
|
||||
$glyphNumbers[$key] = $this->_glyphIndexArray[$glyphIndex];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return $glyphNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the glyph number corresponding to the Unicode character.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
|
||||
* operations.
|
||||
*
|
||||
* @param integer $characterCode Unicode character code (code point).
|
||||
* @return integer Glyph number.
|
||||
*/
|
||||
public function glyphNumberForCharacter($characterCode)
|
||||
{
|
||||
/* This code is pretty much a copy of glyphNumbersForCharacters().
|
||||
* See that method for inline documentation.
|
||||
*/
|
||||
|
||||
if ($characterCode > 0xffff) {
|
||||
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
}
|
||||
|
||||
if ($this->_searchRangeEndCode >= $characterCode) {
|
||||
$searchIndex = $this->_searchRange;
|
||||
} else {
|
||||
$searchIndex = $this->_segmentCount;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $this->_searchIterations; $i++) {
|
||||
if ($this->_segmentTableEndCodes[$searchIndex] >= $characterCode) {
|
||||
$subtableIndex = $searchIndex;
|
||||
$searchIndex -= $this->_searchRange >> $i;
|
||||
} else {
|
||||
$searchIndex += $this->_searchRange >> $i;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_segmentTableStartCodes[$subtableIndex] > $characterCode) {
|
||||
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
}
|
||||
|
||||
if ($this->_segmentTableIdRangeOffsets[$subtableIndex] == 0) {
|
||||
$glyphNumber = ($characterCode + $this->_segmentTableIdDeltas[$subtableIndex]) % 65536;
|
||||
} else {
|
||||
$glyphIndex = ($characterCode - $this->_segmentTableStartCodes[$subtableIndex] +
|
||||
$this->_segmentTableIdRangeOffsets[$subtableIndex] - $this->_segmentCount +
|
||||
$subtableIndex - 1);
|
||||
$glyphNumber = $this->_glyphIndexArray[$glyphIndex];
|
||||
}
|
||||
return $glyphNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the Unicode characters that have entries in
|
||||
* this character map.
|
||||
*
|
||||
* @return array Unicode character codes.
|
||||
*/
|
||||
public function getCoveredCharacters()
|
||||
{
|
||||
$characterCodes = array();
|
||||
for ($i = 1; $i <= $this->_segmentCount; $i++) {
|
||||
for ($code = $this->_segmentTableStartCodes[$i]; $code <= $this->_segmentTableEndCodes[$i]; $code++) {
|
||||
$characterCodes[] = $code;
|
||||
}
|
||||
}
|
||||
return $characterCodes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing the glyphs numbers that have entries in this character map.
|
||||
* Keys are Unicode character codes (integers)
|
||||
*
|
||||
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
|
||||
* call, but this method do it in more effective way (prepare complete list instead of searching
|
||||
* glyph for each character code).
|
||||
*
|
||||
* @internal
|
||||
* @return array Array representing <Unicode character code> => <glyph number> pairs.
|
||||
*/
|
||||
public function getCoveredCharactersGlyphs()
|
||||
{
|
||||
$glyphNumbers = array();
|
||||
|
||||
for ($segmentNum = 1; $segmentNum <= $this->_segmentCount; $segmentNum++) {
|
||||
if ($this->_segmentTableIdRangeOffsets[$segmentNum] == 0) {
|
||||
$delta = $this->_segmentTableIdDeltas[$segmentNum];
|
||||
|
||||
for ($code = $this->_segmentTableStartCodes[$segmentNum];
|
||||
$code <= $this->_segmentTableEndCodes[$segmentNum];
|
||||
$code++) {
|
||||
$glyphNumbers[$code] = ($code + $delta) % 65536;
|
||||
}
|
||||
} else {
|
||||
$code = $this->_segmentTableStartCodes[$segmentNum];
|
||||
$glyphIndex = $this->_segmentTableIdRangeOffsets[$segmentNum] - ($this->_segmentCount - $segmentNum) - 1;
|
||||
|
||||
while ($code <= $this->_segmentTableEndCodes[$segmentNum]) {
|
||||
$glyphNumbers[$code] = $this->_glyphIndexArray[$glyphIndex];
|
||||
|
||||
$code++;
|
||||
$glyphIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $glyphNumbers;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Object Lifecycle */
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* Parses the raw binary table data. Throws an exception if the table is
|
||||
* malformed.
|
||||
*
|
||||
* @param string $cmapData Raw binary cmap table data.
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($cmapData)
|
||||
{
|
||||
/* Sanity check: The table should be at least 23 bytes in size.
|
||||
*/
|
||||
$actualLength = strlen($cmapData);
|
||||
if ($actualLength < 23) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Insufficient table data',
|
||||
Zend_Pdf_Exception::CMAP_TABLE_DATA_TOO_SMALL);
|
||||
}
|
||||
|
||||
/* Sanity check: Make sure this is right data for this table type.
|
||||
*/
|
||||
$type = $this->_extractUInt2($cmapData, 0);
|
||||
if ($type != Zend_Pdf_Cmap::TYPE_SEGMENT_TO_DELTA) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Wrong cmap table type',
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_TYPE);
|
||||
}
|
||||
|
||||
$length = $this->_extractUInt2($cmapData, 2);
|
||||
if ($length != $actualLength) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Table length ($length) does not match actual length ($actualLength)",
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_LENGTH);
|
||||
}
|
||||
|
||||
/* Mapping tables should be language-independent. The font may not work
|
||||
* as expected if they are not. Unfortunately, many font files in the
|
||||
* wild incorrectly record a language ID in this field, so we can't
|
||||
* call this a failure.
|
||||
*/
|
||||
$language = $this->_extractUInt2($cmapData, 4);
|
||||
if ($language != 0) {
|
||||
// Record a warning here somehow?
|
||||
}
|
||||
|
||||
/* These two values are stored premultiplied by two which is convienent
|
||||
* when using the binary data directly, but we're parsing it out to
|
||||
* native PHP data types, so divide by two.
|
||||
*/
|
||||
$this->_segmentCount = $this->_extractUInt2($cmapData, 6) >> 1;
|
||||
$this->_searchRange = $this->_extractUInt2($cmapData, 8) >> 1;
|
||||
|
||||
$this->_searchIterations = $this->_extractUInt2($cmapData, 10) + 1;
|
||||
|
||||
$offset = 14;
|
||||
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
|
||||
$this->_segmentTableEndCodes[$i] = $this->_extractUInt2($cmapData, $offset);
|
||||
}
|
||||
|
||||
$this->_searchRangeEndCode = $this->_segmentTableEndCodes[$this->_searchRange];
|
||||
|
||||
$offset += 2; // reserved bytes
|
||||
|
||||
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
|
||||
$this->_segmentTableStartCodes[$i] = $this->_extractUInt2($cmapData, $offset);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
|
||||
$this->_segmentTableIdDeltas[$i] = $this->_extractInt2($cmapData, $offset); // signed
|
||||
}
|
||||
|
||||
/* The range offset helps determine the index into the glyph index array.
|
||||
* Like the segment count and search range above, it's stored as a byte
|
||||
* multiple in the font, so divide by two as we extract the values.
|
||||
*/
|
||||
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
|
||||
$this->_segmentTableIdRangeOffsets[$i] = $this->_extractUInt2($cmapData, $offset) >> 1;
|
||||
}
|
||||
|
||||
/* The size of the glyph index array varies by font and depends on the
|
||||
* extent of the usage of range offsets versus deltas. Some fonts may
|
||||
* not have any entries in this array.
|
||||
*/
|
||||
for (; $offset < $length; $offset += 2) {
|
||||
$this->_glyphIndexArray[] = $this->_extractUInt2($cmapData, $offset);
|
||||
}
|
||||
|
||||
/* Sanity check: After reading all of the data, we should be at the end
|
||||
* of the table.
|
||||
*/
|
||||
if ($offset != $length) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Ending offset ($offset) does not match length ($length)",
|
||||
Zend_Pdf_Exception::CMAP_FINAL_OFFSET_NOT_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
231
library/Zend/Pdf/Cmap/TrimmedTable.php
Normal file
231
library/Zend/Pdf/Cmap/TrimmedTable.php
Normal file
@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Fonts
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: TrimmedTable.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Cmap */
|
||||
// require_once 'Zend/Pdf/Cmap.php';
|
||||
|
||||
|
||||
/**
|
||||
* Implements the "trimmed table mapping" character map (type 6).
|
||||
*
|
||||
* This table type is preferred over the {@link Zend_Pdf_Cmap_SegmentToDelta}
|
||||
* table when the Unicode characters covered by the font fall into a single
|
||||
* contiguous range.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Cmap_TrimmedTable extends Zend_Pdf_Cmap
|
||||
{
|
||||
/**** Instance Variables ****/
|
||||
|
||||
|
||||
/**
|
||||
* The starting character code covered by this table.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_startCode = 0;
|
||||
|
||||
/**
|
||||
* The ending character code covered by this table.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_endCode = 0;
|
||||
|
||||
/**
|
||||
* Glyph index array. Stores the actual glyph numbers.
|
||||
* @var array
|
||||
*/
|
||||
protected $_glyphIndexArray = array();
|
||||
|
||||
|
||||
|
||||
/**** Public Interface ****/
|
||||
|
||||
|
||||
/* Concrete Class Implementation */
|
||||
|
||||
/**
|
||||
* Returns an array of glyph numbers corresponding to the Unicode characters.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumberForCharacter()}.
|
||||
*
|
||||
* @param array $characterCodes Array of Unicode character codes (code points).
|
||||
* @return array Array of glyph numbers.
|
||||
*/
|
||||
public function glyphNumbersForCharacters($characterCodes)
|
||||
{
|
||||
$glyphNumbers = array();
|
||||
foreach ($characterCodes as $key => $characterCode) {
|
||||
|
||||
if (($characterCode < $this->_startCode) || ($characterCode > $this->_endCode)) {
|
||||
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
continue;
|
||||
}
|
||||
|
||||
$glyphIndex = $characterCode - $this->_startCode;
|
||||
$glyphNumbers[$key] = $this->_glyphIndexArray[$glyphIndex];
|
||||
|
||||
}
|
||||
return $glyphNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the glyph number corresponding to the Unicode character.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
|
||||
* operations.
|
||||
*
|
||||
* @param integer $characterCode Unicode character code (code point).
|
||||
* @return integer Glyph number.
|
||||
*/
|
||||
public function glyphNumberForCharacter($characterCode)
|
||||
{
|
||||
if (($characterCode < $this->_startCode) || ($characterCode > $this->_endCode)) {
|
||||
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
}
|
||||
$glyphIndex = $characterCode - $this->_startCode;
|
||||
return $this->_glyphIndexArray[$glyphIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the Unicode characters that have entries in
|
||||
* this character map.
|
||||
*
|
||||
* @return array Unicode character codes.
|
||||
*/
|
||||
public function getCoveredCharacters()
|
||||
{
|
||||
$characterCodes = array();
|
||||
for ($code = $this->_startCode; $code <= $this->_endCode; $code++) {
|
||||
$characterCodes[] = $code;
|
||||
}
|
||||
return $characterCodes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing the glyphs numbers that have entries in this character map.
|
||||
* Keys are Unicode character codes (integers)
|
||||
*
|
||||
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
|
||||
* call, but this method do it in more effective way (prepare complete list instead of searching
|
||||
* glyph for each character code).
|
||||
*
|
||||
* @internal
|
||||
* @return array Array representing <Unicode character code> => <glyph number> pairs.
|
||||
*/
|
||||
public function getCoveredCharactersGlyphs()
|
||||
{
|
||||
$glyphNumbers = array();
|
||||
for ($code = $this->_startCode; $code <= $this->_endCode; $code++) {
|
||||
$glyphNumbers[$code] = $this->_glyphIndexArray[$code - $this->_startCode];
|
||||
}
|
||||
|
||||
return $glyphNumbers;
|
||||
}
|
||||
|
||||
|
||||
/* Object Lifecycle */
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* Parses the raw binary table data. Throws an exception if the table is
|
||||
* malformed.
|
||||
*
|
||||
* @param string $cmapData Raw binary cmap table data.
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($cmapData)
|
||||
{
|
||||
/* Sanity check: The table should be at least 9 bytes in size.
|
||||
*/
|
||||
$actualLength = strlen($cmapData);
|
||||
if ($actualLength < 9) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Insufficient table data',
|
||||
Zend_Pdf_Exception::CMAP_TABLE_DATA_TOO_SMALL);
|
||||
}
|
||||
|
||||
/* Sanity check: Make sure this is right data for this table type.
|
||||
*/
|
||||
$type = $this->_extractUInt2($cmapData, 0);
|
||||
if ($type != Zend_Pdf_Cmap::TYPE_TRIMMED_TABLE) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Wrong cmap table type',
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_TYPE);
|
||||
}
|
||||
|
||||
$length = $this->_extractUInt2($cmapData, 2);
|
||||
if ($length != $actualLength) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Table length ($length) does not match actual length ($actualLength)",
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_LENGTH);
|
||||
}
|
||||
|
||||
/* Mapping tables should be language-independent. The font may not work
|
||||
* as expected if they are not. Unfortunately, many font files in the
|
||||
* wild incorrectly record a language ID in this field, so we can't
|
||||
* call this a failure.
|
||||
*/
|
||||
$language = $this->_extractUInt2($cmapData, 4);
|
||||
if ($language != 0) {
|
||||
// Record a warning here somehow?
|
||||
}
|
||||
|
||||
$this->_startCode = $this->_extractUInt2($cmapData, 6);
|
||||
|
||||
$entryCount = $this->_extractUInt2($cmapData, 8);
|
||||
$expectedCount = ($length - 10) >> 1;
|
||||
if ($entryCount != $expectedCount) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Entry count is wrong; expected: $expectedCount; actual: $entryCount",
|
||||
Zend_Pdf_Exception::CMAP_WRONG_ENTRY_COUNT);
|
||||
}
|
||||
|
||||
$this->_endCode = $this->_startCode + $entryCount - 1;
|
||||
|
||||
$offset = 10;
|
||||
for ($i = 0; $i < $entryCount; $i++, $offset += 2) {
|
||||
$this->_glyphIndexArray[] = $this->_extractUInt2($cmapData, $offset);
|
||||
}
|
||||
|
||||
/* Sanity check: After reading all of the data, we should be at the end
|
||||
* of the table.
|
||||
*/
|
||||
if ($offset != $length) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Ending offset ($offset) does not match length ($length)",
|
||||
Zend_Pdf_Exception::CMAP_FINAL_OFFSET_NOT_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
53
library/Zend/Pdf/Color.php
Normal file
53
library/Zend/Pdf/Color.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Color.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PDF provides a powerfull facilities for specifying the colors of graphics objects.
|
||||
* This class encapsulates color behaviour.
|
||||
*
|
||||
* Some colors interact with PDF document (create additional objects in a PDF),
|
||||
* others don't do it. That is defined in a subclasses.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Pdf_Color
|
||||
{
|
||||
/**
|
||||
* Instructions, which can be directly inserted into content stream
|
||||
* to switch color.
|
||||
* Color set instructions differ for stroking and nonstroking operations.
|
||||
*
|
||||
* @param boolean $stroking
|
||||
* @return string
|
||||
*/
|
||||
abstract public function instructions($stroking);
|
||||
|
||||
/**
|
||||
* Get color components (color space dependent)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getComponents();
|
||||
}
|
||||
|
||||
126
library/Zend/Pdf/Color/Cmyk.php
Normal file
126
library/Zend/Pdf/Color/Cmyk.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Cmyk.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Color */
|
||||
// require_once 'Zend/Pdf/Color.php';
|
||||
|
||||
/**
|
||||
* CMYK color implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Color_Cmyk extends Zend_Pdf_Color
|
||||
{
|
||||
/**
|
||||
* Cyan level.
|
||||
* 0.0 (zero concentration) - 1.0 (maximum concentration)
|
||||
*
|
||||
* @var Zend_Pdf_Element_Numeric
|
||||
*/
|
||||
private $_c;
|
||||
|
||||
/**
|
||||
* Magenta level.
|
||||
* 0.0 (zero concentration) - 1.0 (maximum concentration)
|
||||
*
|
||||
* @var Zend_Pdf_Element_Numeric
|
||||
*/
|
||||
private $_m;
|
||||
|
||||
/**
|
||||
* Yellow level.
|
||||
* 0.0 (zero concentration) - 1.0 (maximum concentration)
|
||||
*
|
||||
* @var Zend_Pdf_Element_Numeric
|
||||
*/
|
||||
private $_y;
|
||||
|
||||
/**
|
||||
* Key (BlacK) level.
|
||||
* 0.0 (zero concentration) - 1.0 (maximum concentration)
|
||||
*
|
||||
* @var Zend_Pdf_Element_Numeric
|
||||
*/
|
||||
private $_k;
|
||||
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param float $c
|
||||
* @param float $m
|
||||
* @param float $y
|
||||
* @param float $k
|
||||
*/
|
||||
public function __construct($c, $m, $y, $k)
|
||||
{
|
||||
if ($c < 0) { $c = 0; }
|
||||
if ($c > 1) { $c = 1; }
|
||||
|
||||
if ($m < 0) { $m = 0; }
|
||||
if ($m > 1) { $m = 1; }
|
||||
|
||||
if ($y < 0) { $y = 0; }
|
||||
if ($y > 1) { $y = 1; }
|
||||
|
||||
if ($k < 0) { $k = 0; }
|
||||
if ($k > 1) { $k = 1; }
|
||||
|
||||
$this->_c = new Zend_Pdf_Element_Numeric($c);
|
||||
$this->_m = new Zend_Pdf_Element_Numeric($m);
|
||||
$this->_y = new Zend_Pdf_Element_Numeric($y);
|
||||
$this->_k = new Zend_Pdf_Element_Numeric($k);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructions, which can be directly inserted into content stream
|
||||
* to switch color.
|
||||
* Color set instructions differ for stroking and nonstroking operations.
|
||||
*
|
||||
* @param boolean $stroking
|
||||
* @return string
|
||||
*/
|
||||
public function instructions($stroking)
|
||||
{
|
||||
return $this->_c->toString() . ' '
|
||||
. $this->_m->toString() . ' '
|
||||
. $this->_y->toString() . ' '
|
||||
. $this->_k->toString() . ($stroking? " K\n" : " k\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color components (color space dependent)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getComponents()
|
||||
{
|
||||
return array($this->_c->value, $this->_m->value, $this->_y->value, $this->_k->value);
|
||||
}
|
||||
}
|
||||
|
||||
84
library/Zend/Pdf/Color/GrayScale.php
Normal file
84
library/Zend/Pdf/Color/GrayScale.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: GrayScale.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Color */
|
||||
// require_once 'Zend/Pdf/Color.php';
|
||||
|
||||
/**
|
||||
* GrayScale color implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Color_GrayScale extends Zend_Pdf_Color
|
||||
{
|
||||
/**
|
||||
* GrayLevel.
|
||||
* 0.0 (black) - 1.0 (white)
|
||||
*
|
||||
* @var Zend_Pdf_Element_Numeric
|
||||
*/
|
||||
private $_grayLevel;
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param float $grayLevel
|
||||
*/
|
||||
public function __construct($grayLevel)
|
||||
{
|
||||
if ($grayLevel < 0) { $grayLevel = 0; }
|
||||
if ($grayLevel > 1) { $grayLevel = 1; }
|
||||
|
||||
$this->_grayLevel = new Zend_Pdf_Element_Numeric($grayLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructions, which can be directly inserted into content stream
|
||||
* to switch color.
|
||||
* Color set instructions differ for stroking and nonstroking operations.
|
||||
*
|
||||
* @param boolean $stroking
|
||||
* @return string
|
||||
*/
|
||||
public function instructions($stroking)
|
||||
{
|
||||
return $this->_grayLevel->toString() . ($stroking? " G\n" : " g\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color components (color space dependent)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getComponents()
|
||||
{
|
||||
return array($this->_grayLevel->value);
|
||||
}
|
||||
}
|
||||
|
||||
412
library/Zend/Pdf/Color/Html.php
Normal file
412
library/Zend/Pdf/Color/Html.php
Normal file
@ -0,0 +1,412 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Html.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Color */
|
||||
// require_once 'Zend/Pdf/Color.php';
|
||||
|
||||
|
||||
/**
|
||||
* HTML color implementation
|
||||
*
|
||||
* Factory class which vends Zend_Pdf_Color objects from typical HTML
|
||||
* representations.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Color_Html extends Zend_Pdf_Color
|
||||
{
|
||||
|
||||
/**
|
||||
* Color
|
||||
*
|
||||
* @var Zend_Pdf_Color
|
||||
*/
|
||||
private $_color;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param mixed $color
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($color)
|
||||
{
|
||||
$this->_color = self::color($color);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instructions, which can be directly inserted into content stream
|
||||
* to switch color.
|
||||
* Color set instructions differ for stroking and nonstroking operations.
|
||||
*
|
||||
* @param boolean $stroking
|
||||
* @return string
|
||||
*/
|
||||
public function instructions($stroking)
|
||||
{
|
||||
return $this->_color->instructions($stroking);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color components (color space dependent)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getComponents()
|
||||
{
|
||||
return $this->_color->getComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Zend_Pdf_Color object from the HTML representation.
|
||||
*
|
||||
* @param string $color May either be a hexidecimal number of the form
|
||||
* #rrggbb or one of the 140 well-known names (black, white, blue, etc.)
|
||||
* @return Zend_Pdf_Color
|
||||
*/
|
||||
public static function color($color)
|
||||
{
|
||||
$pattern = '/^#([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})$/';
|
||||
if (preg_match($pattern, $color, $matches)) {
|
||||
$r = round((hexdec($matches[1]) / 255), 3);
|
||||
$g = round((hexdec($matches[2]) / 255), 3);
|
||||
$b = round((hexdec($matches[3]) / 255), 3);
|
||||
if (($r == $g) && ($g == $b)) {
|
||||
// require_once 'Zend/Pdf/Color/GrayScale.php';
|
||||
return new Zend_Pdf_Color_GrayScale($r);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Color/Rgb.php';
|
||||
return new Zend_Pdf_Color_Rgb($r, $g, $b);
|
||||
}
|
||||
} else {
|
||||
return Zend_Pdf_Color_Html::namedColor($color);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Zend_Pdf_Color object from the named color.
|
||||
*
|
||||
* @param string $color One of the 140 well-known color names (black, white,
|
||||
* blue, etc.)
|
||||
* @return Zend_Pdf_Color
|
||||
*/
|
||||
public static function namedColor($color)
|
||||
{
|
||||
switch (strtolower($color)) {
|
||||
case 'aqua':
|
||||
$r = 0.0; $g = 1.0; $b = 1.0; break;
|
||||
case 'black':
|
||||
$r = 0.0; $g = 0.0; $b = 0.0; break;
|
||||
case 'blue':
|
||||
$r = 0.0; $g = 0.0; $b = 1.0; break;
|
||||
case 'fuchsia':
|
||||
$r = 1.0; $g = 0.0; $b = 1.0; break;
|
||||
case 'gray':
|
||||
$r = 0.502; $g = 0.502; $b = 0.502; break;
|
||||
case 'green':
|
||||
$r = 0.0; $g = 0.502; $b = 0.0; break;
|
||||
case 'lime':
|
||||
$r = 0.0; $g = 1.0; $b = 0.0; break;
|
||||
case 'maroon':
|
||||
$r = 0.502; $g = 0.0; $b = 0.0; break;
|
||||
case 'navy':
|
||||
$r = 0.0; $g = 0.0; $b = 0.502; break;
|
||||
case 'olive':
|
||||
$r = 0.502; $g = 0.502; $b = 0.0; break;
|
||||
case 'purple':
|
||||
$r = 0.502; $g = 0.0; $b = 0.502; break;
|
||||
case 'red':
|
||||
$r = 1.0; $g = 0.0; $b = 0.0; break;
|
||||
case 'silver':
|
||||
$r = 0.753; $g = 0.753; $b = 0.753; break;
|
||||
case 'teal':
|
||||
$r = 0.0; $g = 0.502; $b = 0.502; break;
|
||||
case 'white':
|
||||
$r = 1.0; $g = 1.0; $b = 1.0; break;
|
||||
case 'yellow':
|
||||
$r = 1.0; $g = 1.0; $b = 0.0; break;
|
||||
|
||||
case 'aliceblue':
|
||||
$r = 0.941; $g = 0.973; $b = 1.0; break;
|
||||
case 'antiquewhite':
|
||||
$r = 0.980; $g = 0.922; $b = 0.843; break;
|
||||
case 'aquamarine':
|
||||
$r = 0.498; $g = 1.0; $b = 0.831; break;
|
||||
case 'azure':
|
||||
$r = 0.941; $g = 1.0; $b = 1.0; break;
|
||||
case 'beige':
|
||||
$r = 0.961; $g = 0.961; $b = 0.863; break;
|
||||
case 'bisque':
|
||||
$r = 1.0; $g = 0.894; $b = 0.769; break;
|
||||
case 'blanchedalmond':
|
||||
$r = 1.0; $g = 1.0; $b = 0.804; break;
|
||||
case 'blueviolet':
|
||||
$r = 0.541; $g = 0.169; $b = 0.886; break;
|
||||
case 'brown':
|
||||
$r = 0.647; $g = 0.165; $b = 0.165; break;
|
||||
case 'burlywood':
|
||||
$r = 0.871; $g = 0.722; $b = 0.529; break;
|
||||
case 'cadetblue':
|
||||
$r = 0.373; $g = 0.620; $b = 0.627; break;
|
||||
case 'chartreuse':
|
||||
$r = 0.498; $g = 1.0; $b = 0.0; break;
|
||||
case 'chocolate':
|
||||
$r = 0.824; $g = 0.412; $b = 0.118; break;
|
||||
case 'coral':
|
||||
$r = 1.0; $g = 0.498; $b = 0.314; break;
|
||||
case 'cornflowerblue':
|
||||
$r = 0.392; $g = 0.584; $b = 0.929; break;
|
||||
case 'cornsilk':
|
||||
$r = 1.0; $g = 0.973; $b = 0.863; break;
|
||||
case 'crimson':
|
||||
$r = 0.863; $g = 0.078; $b = 0.235; break;
|
||||
case 'cyan':
|
||||
$r = 0.0; $g = 1.0; $b = 1.0; break;
|
||||
case 'darkblue':
|
||||
$r = 0.0; $g = 0.0; $b = 0.545; break;
|
||||
case 'darkcyan':
|
||||
$r = 0.0; $g = 0.545; $b = 0.545; break;
|
||||
case 'darkgoldenrod':
|
||||
$r = 0.722; $g = 0.525; $b = 0.043; break;
|
||||
case 'darkgray':
|
||||
$r = 0.663; $g = 0.663; $b = 0.663; break;
|
||||
case 'darkgreen':
|
||||
$r = 0.0; $g = 0.392; $b = 0.0; break;
|
||||
case 'darkkhaki':
|
||||
$r = 0.741; $g = 0.718; $b = 0.420; break;
|
||||
case 'darkmagenta':
|
||||
$r = 0.545; $g = 0.0; $b = 0.545; break;
|
||||
case 'darkolivegreen':
|
||||
$r = 0.333; $g = 0.420; $b = 0.184; break;
|
||||
case 'darkorange':
|
||||
$r = 1.0; $g = 0.549; $b = 0.0; break;
|
||||
case 'darkorchid':
|
||||
$r = 0.6; $g = 0.196; $b = 0.8; break;
|
||||
case 'darkred':
|
||||
$r = 0.545; $g = 0.0; $b = 0.0; break;
|
||||
case 'darksalmon':
|
||||
$r = 0.914; $g = 0.588; $b = 0.478; break;
|
||||
case 'darkseagreen':
|
||||
$r = 0.561; $g = 0.737; $b = 0.561; break;
|
||||
case 'darkslateblue':
|
||||
$r = 0.282; $g = 0.239; $b = 0.545; break;
|
||||
case 'darkslategray':
|
||||
$r = 0.184; $g = 0.310; $b = 0.310; break;
|
||||
case 'darkturquoise':
|
||||
$r = 0.0; $g = 0.808; $b = 0.820; break;
|
||||
case 'darkviolet':
|
||||
$r = 0.580; $g = 0.0; $b = 0.827; break;
|
||||
case 'deeppink':
|
||||
$r = 1.0; $g = 0.078; $b = 0.576; break;
|
||||
case 'deepskyblue':
|
||||
$r = 0.0; $g = 0.749; $b = 1.0; break;
|
||||
case 'dimgray':
|
||||
$r = 0.412; $g = 0.412; $b = 0.412; break;
|
||||
case 'dodgerblue':
|
||||
$r = 0.118; $g = 0.565; $b = 1.0; break;
|
||||
case 'firebrick':
|
||||
$r = 0.698; $g = 0.133; $b = 0.133; break;
|
||||
case 'floralwhite':
|
||||
$r = 1.0; $g = 0.980; $b = 0.941; break;
|
||||
case 'forestgreen':
|
||||
$r = 0.133; $g = 0.545; $b = 0.133; break;
|
||||
case 'gainsboro':
|
||||
$r = 0.863; $g = 0.863; $b = 0.863; break;
|
||||
case 'ghostwhite':
|
||||
$r = 0.973; $g = 0.973; $b = 1.0; break;
|
||||
case 'gold':
|
||||
$r = 1.0; $g = 0.843; $b = 0.0; break;
|
||||
case 'goldenrod':
|
||||
$r = 0.855; $g = 0.647; $b = 0.125; break;
|
||||
case 'greenyellow':
|
||||
$r = 0.678; $g = 1.0; $b = 0.184; break;
|
||||
case 'honeydew':
|
||||
$r = 0.941; $g = 1.0; $b = 0.941; break;
|
||||
case 'hotpink':
|
||||
$r = 1.0; $g = 0.412; $b = 0.706; break;
|
||||
case 'indianred':
|
||||
$r = 0.804; $g = 0.361; $b = 0.361; break;
|
||||
case 'indigo':
|
||||
$r = 0.294; $g = 0.0; $b = 0.510; break;
|
||||
case 'ivory':
|
||||
$r = 1.0; $g = 0.941; $b = 0.941; break;
|
||||
case 'khaki':
|
||||
$r = 0.941; $g = 0.902; $b = 0.549; break;
|
||||
case 'lavender':
|
||||
$r = 0.902; $g = 0.902; $b = 0.980; break;
|
||||
case 'lavenderblush':
|
||||
$r = 1.0; $g = 0.941; $b = 0.961; break;
|
||||
case 'lawngreen':
|
||||
$r = 0.486; $g = 0.988; $b = 0.0; break;
|
||||
case 'lemonchiffon':
|
||||
$r = 1.0; $g = 0.980; $b = 0.804; break;
|
||||
case 'lightblue':
|
||||
$r = 0.678; $g = 0.847; $b = 0.902; break;
|
||||
case 'lightcoral':
|
||||
$r = 0.941; $g = 0.502; $b = 0.502; break;
|
||||
case 'lightcyan':
|
||||
$r = 0.878; $g = 1.0; $b = 1.0; break;
|
||||
case 'lightgoldenrodyellow':
|
||||
$r = 0.980; $g = 0.980; $b = 0.824; break;
|
||||
case 'lightgreen':
|
||||
$r = 0.565; $g = 0.933; $b = 0.565; break;
|
||||
case 'lightgrey':
|
||||
$r = 0.827; $g = 0.827; $b = 0.827; break;
|
||||
case 'lightpink':
|
||||
$r = 1.0; $g = 0.714; $b = 0.757; break;
|
||||
case 'lightsalmon':
|
||||
$r = 1.0; $g = 0.627; $b = 0.478; break;
|
||||
case 'lightseagreen':
|
||||
$r = 0.125; $g = 0.698; $b = 0.667; break;
|
||||
case 'lightskyblue':
|
||||
$r = 0.529; $g = 0.808; $b = 0.980; break;
|
||||
case 'lightslategray':
|
||||
$r = 0.467; $g = 0.533; $b = 0.6; break;
|
||||
case 'lightsteelblue':
|
||||
$r = 0.690; $g = 0.769; $b = 0.871; break;
|
||||
case 'lightyellow':
|
||||
$r = 1.0; $g = 1.0; $b = 0.878; break;
|
||||
case 'limegreen':
|
||||
$r = 0.196; $g = 0.804; $b = 0.196; break;
|
||||
case 'linen':
|
||||
$r = 0.980; $g = 0.941; $b = 0.902; break;
|
||||
case 'magenta':
|
||||
$r = 1.0; $g = 0.0; $b = 1.0; break;
|
||||
case 'mediumaquamarine':
|
||||
$r = 0.4; $g = 0.804; $b = 0.667; break;
|
||||
case 'mediumblue':
|
||||
$r = 0.0; $g = 0.0; $b = 0.804; break;
|
||||
case 'mediumorchid':
|
||||
$r = 0.729; $g = 0.333; $b = 0.827; break;
|
||||
case 'mediumpurple':
|
||||
$r = 0.576; $g = 0.439; $b = 0.859; break;
|
||||
case 'mediumseagreen':
|
||||
$r = 0.235; $g = 0.702; $b = 0.443; break;
|
||||
case 'mediumslateblue':
|
||||
$r = 0.482; $g = 0.408; $b = 0.933; break;
|
||||
case 'mediumspringgreen':
|
||||
$r = 0.0; $g = 0.980; $b = 0.604; break;
|
||||
case 'mediumturquoise':
|
||||
$r = 0.282; $g = 0.820; $b = 0.8; break;
|
||||
case 'mediumvioletred':
|
||||
$r = 0.780; $g = 0.082; $b = 0.522; break;
|
||||
case 'midnightblue':
|
||||
$r = 0.098; $g = 0.098; $b = 0.439; break;
|
||||
case 'mintcream':
|
||||
$r = 0.961; $g = 1.0; $b = 0.980; break;
|
||||
case 'mistyrose':
|
||||
$r = 1.0; $g = 0.894; $b = 0.882; break;
|
||||
case 'moccasin':
|
||||
$r = 1.0; $g = 0.894; $b = 0.710; break;
|
||||
case 'navajowhite':
|
||||
$r = 1.0; $g = 0.871; $b = 0.678; break;
|
||||
case 'oldlace':
|
||||
$r = 0.992; $g = 0.961; $b = 0.902; break;
|
||||
case 'olivedrab':
|
||||
$r = 0.420; $g = 0.557; $b = 0.137; break;
|
||||
case 'orange':
|
||||
$r = 1.0; $g = 0.647; $b = 0.0; break;
|
||||
case 'orangered':
|
||||
$r = 1.0; $g = 0.271; $b = 0.0; break;
|
||||
case 'orchid':
|
||||
$r = 0.855; $g = 0.439; $b = 0.839; break;
|
||||
case 'palegoldenrod':
|
||||
$r = 0.933; $g = 0.910; $b = 0.667; break;
|
||||
case 'palegreen':
|
||||
$r = 0.596; $g = 0.984; $b = 0.596; break;
|
||||
case 'paleturquoise':
|
||||
$r = 0.686; $g = 0.933; $b = 0.933; break;
|
||||
case 'palevioletred':
|
||||
$r = 0.859; $g = 0.439; $b = 0.576; break;
|
||||
case 'papayawhip':
|
||||
$r = 1.0; $g = 0.937; $b = 0.835; break;
|
||||
case 'peachpuff':
|
||||
$r = 1.0; $g = 0.937; $b = 0.835; break;
|
||||
case 'peru':
|
||||
$r = 0.804; $g = 0.522; $b = 0.247; break;
|
||||
case 'pink':
|
||||
$r = 1.0; $g = 0.753; $b = 0.796; break;
|
||||
case 'plum':
|
||||
$r = 0.867; $g = 0.627; $b = 0.867; break;
|
||||
case 'powderblue':
|
||||
$r = 0.690; $g = 0.878; $b = 0.902; break;
|
||||
case 'rosybrown':
|
||||
$r = 0.737; $g = 0.561; $b = 0.561; break;
|
||||
case 'royalblue':
|
||||
$r = 0.255; $g = 0.412; $b = 0.882; break;
|
||||
case 'saddlebrown':
|
||||
$r = 0.545; $g = 0.271; $b = 0.075; break;
|
||||
case 'salmon':
|
||||
$r = 0.980; $g = 0.502; $b = 0.447; break;
|
||||
case 'sandybrown':
|
||||
$r = 0.957; $g = 0.643; $b = 0.376; break;
|
||||
case 'seagreen':
|
||||
$r = 0.180; $g = 0.545; $b = 0.341; break;
|
||||
case 'seashell':
|
||||
$r = 1.0; $g = 0.961; $b = 0.933; break;
|
||||
case 'sienna':
|
||||
$r = 0.627; $g = 0.322; $b = 0.176; break;
|
||||
case 'skyblue':
|
||||
$r = 0.529; $g = 0.808; $b = 0.922; break;
|
||||
case 'slateblue':
|
||||
$r = 0.416; $g = 0.353; $b = 0.804; break;
|
||||
case 'slategray':
|
||||
$r = 0.439; $g = 0.502; $b = 0.565; break;
|
||||
case 'snow':
|
||||
$r = 1.0; $g = 0.980; $b = 0.980; break;
|
||||
case 'springgreen':
|
||||
$r = 0.0; $g = 1.0; $b = 0.498; break;
|
||||
case 'steelblue':
|
||||
$r = 0.275; $g = 0.510; $b = 0.706; break;
|
||||
case 'tan':
|
||||
$r = 0.824; $g = 0.706; $b = 0.549; break;
|
||||
case 'thistle':
|
||||
$r = 0.847; $g = 0.749; $b = 0.847; break;
|
||||
case 'tomato':
|
||||
$r = 0.992; $g = 0.388; $b = 0.278; break;
|
||||
case 'turquoise':
|
||||
$r = 0.251; $g = 0.878; $b = 0.816; break;
|
||||
case 'violet':
|
||||
$r = 0.933; $g = 0.510; $b = 0.933; break;
|
||||
case 'wheat':
|
||||
$r = 0.961; $g = 0.871; $b = 0.702; break;
|
||||
case 'whitesmoke':
|
||||
$r = 0.961; $g = 0.961; $b = 0.961; break;
|
||||
case 'yellowgreen':
|
||||
$r = 0.604; $g = 0.804; $b = 0.196; break;
|
||||
|
||||
default:
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Unknown color name: ' . $color);
|
||||
}
|
||||
if (($r == $g) && ($g == $b)) {
|
||||
// require_once 'Zend/Pdf/Color/GrayScale.php';
|
||||
return new Zend_Pdf_Color_GrayScale($r);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Color/Rgb.php';
|
||||
return new Zend_Pdf_Color_Rgb($r, $g, $b);
|
||||
}
|
||||
}
|
||||
}
|
||||
114
library/Zend/Pdf/Color/Rgb.php
Normal file
114
library/Zend/Pdf/Color/Rgb.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Rgb.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Color */
|
||||
// require_once 'Zend/Pdf/Color.php';
|
||||
|
||||
/**
|
||||
* RGB color implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Color_Rgb extends Zend_Pdf_Color
|
||||
{
|
||||
/**
|
||||
* Red level.
|
||||
* 0.0 (zero concentration) - 1.0 (maximum concentration)
|
||||
*
|
||||
* @var Zend_Pdf_Element_Numeric
|
||||
*/
|
||||
private $_r;
|
||||
|
||||
/**
|
||||
* Green level.
|
||||
* 0.0 (zero concentration) - 1.0 (maximum concentration)
|
||||
*
|
||||
* @var Zend_Pdf_Element_Numeric
|
||||
*/
|
||||
private $_g;
|
||||
|
||||
/**
|
||||
* Blue level.
|
||||
* 0.0 (zero concentration) - 1.0 (maximum concentration)
|
||||
*
|
||||
* @var Zend_Pdf_Element_Numeric
|
||||
*/
|
||||
private $_b;
|
||||
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param float $r
|
||||
* @param float $g
|
||||
* @param float $b
|
||||
*/
|
||||
public function __construct($r, $g, $b)
|
||||
{
|
||||
/** Clamp values to legal limits. */
|
||||
if ($r < 0) { $r = 0; }
|
||||
if ($r > 1) { $r = 1; }
|
||||
|
||||
if ($g < 0) { $g = 0; }
|
||||
if ($g > 1) { $g = 1; }
|
||||
|
||||
if ($b < 0) { $b = 0; }
|
||||
if ($b > 1) { $b = 1; }
|
||||
|
||||
$this->_r = new Zend_Pdf_Element_Numeric($r);
|
||||
$this->_g = new Zend_Pdf_Element_Numeric($g);
|
||||
$this->_b = new Zend_Pdf_Element_Numeric($b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructions, which can be directly inserted into content stream
|
||||
* to switch color.
|
||||
* Color set instructions differ for stroking and nonstroking operations.
|
||||
*
|
||||
* @param boolean $stroking
|
||||
* @return string
|
||||
*/
|
||||
public function instructions($stroking)
|
||||
{
|
||||
return $this->_r->toString() . ' '
|
||||
. $this->_g->toString() . ' '
|
||||
. $this->_b->toString() . ($stroking? " RG\n" : " rg\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color components (color space dependent)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getComponents()
|
||||
{
|
||||
return array($this->_r->value, $this->_g->value, $this->_b->value);
|
||||
}
|
||||
}
|
||||
|
||||
113
library/Zend/Pdf/Destination.php
Normal file
113
library/Zend/Pdf/Destination.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Destination.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Target */
|
||||
// require_once 'Zend/Pdf/Target.php';
|
||||
|
||||
|
||||
/**
|
||||
* Abstract PDF destination representation class
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Pdf_Destination extends Zend_Pdf_Target
|
||||
{
|
||||
/**
|
||||
* Load Destination object from a specified resource
|
||||
*
|
||||
* @internal
|
||||
* @param Zend_Pdf_Element $resource
|
||||
* @return Zend_Pdf_Destination
|
||||
*/
|
||||
public static function load(Zend_Pdf_Element $resource)
|
||||
{
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
if ($resource->getType() == Zend_Pdf_Element::TYPE_NAME || $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
|
||||
// require_once 'Zend/Pdf/Destination/Named.php';
|
||||
return new Zend_Pdf_Destination_Named($resource);
|
||||
}
|
||||
|
||||
if ($resource->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('An explicit destination must be a direct or an indirect array object.');
|
||||
}
|
||||
if (count($resource->items) < 2) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('An explicit destination array must contain at least two elements.');
|
||||
}
|
||||
|
||||
switch ($resource->items[1]->value) {
|
||||
case 'XYZ':
|
||||
// require_once 'Zend/Pdf/Destination/Zoom.php';
|
||||
return new Zend_Pdf_Destination_Zoom($resource);
|
||||
break;
|
||||
|
||||
case 'Fit':
|
||||
// require_once 'Zend/Pdf/Destination/Fit.php';
|
||||
return new Zend_Pdf_Destination_Fit($resource);
|
||||
break;
|
||||
|
||||
case 'FitH':
|
||||
// require_once 'Zend/Pdf/Destination/FitHorizontally.php';
|
||||
return new Zend_Pdf_Destination_FitHorizontally($resource);
|
||||
break;
|
||||
|
||||
case 'FitV':
|
||||
// require_once 'Zend/Pdf/Destination/FitVertically.php';
|
||||
return new Zend_Pdf_Destination_FitVertically($resource);
|
||||
break;
|
||||
|
||||
case 'FitR':
|
||||
// require_once 'Zend/Pdf/Destination/FitRectangle.php';
|
||||
return new Zend_Pdf_Destination_FitRectangle($resource);
|
||||
break;
|
||||
|
||||
case 'FitB':
|
||||
// require_once 'Zend/Pdf/Destination/FitBoundingBox.php';
|
||||
return new Zend_Pdf_Destination_FitBoundingBox($resource);
|
||||
break;
|
||||
|
||||
case 'FitBH':
|
||||
// require_once 'Zend/Pdf/Destination/FitBoundingBoxHorizontally.php';
|
||||
return new Zend_Pdf_Destination_FitBoundingBoxHorizontally($resource);
|
||||
break;
|
||||
|
||||
case 'FitBV':
|
||||
// require_once 'Zend/Pdf/Destination/FitBoundingBoxVertically.php';
|
||||
return new Zend_Pdf_Destination_FitBoundingBoxVertically($resource);
|
||||
break;
|
||||
|
||||
default:
|
||||
// require_once 'Zend/Pdf/Destination/Unknown.php';
|
||||
return new Zend_Pdf_Destination_Unknown($resource);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
122
library/Zend/Pdf/Destination/Explicit.php
Normal file
122
library/Zend/Pdf/Destination/Explicit.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Explicit.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Destination */
|
||||
// require_once 'Zend/Pdf/Destination.php';
|
||||
|
||||
/**
|
||||
* Abstract PDF explicit destination representation class
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Pdf_Destination_Explicit extends Zend_Pdf_Destination
|
||||
{
|
||||
/**
|
||||
* Destination description array
|
||||
*
|
||||
* @var Zend_Pdf_Element_Array
|
||||
*/
|
||||
protected $_destinationArray;
|
||||
|
||||
/**
|
||||
* True if it's a remote destination
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_isRemote;
|
||||
|
||||
/**
|
||||
* Explicit destination object constructor
|
||||
*
|
||||
* @param Zend_Pdf_Element $destinationArray
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $destinationArray)
|
||||
{
|
||||
if ($destinationArray->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Explicit destination resource Array must be a direct or an indirect array object.');
|
||||
}
|
||||
|
||||
$this->_destinationArray = $destinationArray;
|
||||
|
||||
switch (count($this->_destinationArray->items)) {
|
||||
case 0:
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Destination array must contain a page reference.');
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Destination array must contain a destination type name.');
|
||||
break;
|
||||
|
||||
default:
|
||||
// Do nothing
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($this->_destinationArray->items[0]->getType()) {
|
||||
case Zend_Pdf_Element::TYPE_NUMERIC:
|
||||
$this->_isRemote = true;
|
||||
break;
|
||||
|
||||
case Zend_Pdf_Element::TYPE_DICTIONARY:
|
||||
$this->_isRemote = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Destination target must be a page number or page dictionary object.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if it's a remote destination
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isRemote()
|
||||
{
|
||||
return $this->_isRemote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource
|
||||
*
|
||||
* @internal
|
||||
* @return Zend_Pdf_Element
|
||||
*/
|
||||
public function getResource()
|
||||
{
|
||||
return $this->_destinationArray;
|
||||
}
|
||||
}
|
||||
75
library/Zend/Pdf/Destination/Fit.php
Normal file
75
library/Zend/Pdf/Destination/Fit.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Fit.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Destination_Explicit */
|
||||
// require_once 'Zend/Pdf/Destination/Explicit.php';
|
||||
|
||||
/**
|
||||
* Zend_Pdf_Destination_Fit explicit detination
|
||||
*
|
||||
* Destination array: [page /Fit]
|
||||
*
|
||||
* Display the page designated by page, with its contents magnified just enough
|
||||
* to fit the entire page within the window both horizontally and vertically. If
|
||||
* the required horizontal and vertical magnification factors are different, use
|
||||
* the smaller of the two, centering the page within the window in the other
|
||||
* dimension.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Destination_Fit extends Zend_Pdf_Destination_Explicit
|
||||
{
|
||||
/**
|
||||
* Create destination object
|
||||
*
|
||||
* @param Zend_Pdf_Page|integer $page Page object or page number
|
||||
* @return Zend_Pdf_Destination_Fit
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function create($page)
|
||||
{
|
||||
$destinationArray = new Zend_Pdf_Element_Array();
|
||||
|
||||
if ($page instanceof Zend_Pdf_Page) {
|
||||
$destinationArray->items[] = $page->getPageDictionary();
|
||||
} else if (is_integer($page)) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
|
||||
}
|
||||
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Name('Fit');
|
||||
|
||||
return new Zend_Pdf_Destination_Fit($destinationArray);
|
||||
}
|
||||
}
|
||||
75
library/Zend/Pdf/Destination/FitBoundingBox.php
Normal file
75
library/Zend/Pdf/Destination/FitBoundingBox.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FitBoundingBox.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Destination_Explicit */
|
||||
// require_once 'Zend/Pdf/Destination/Explicit.php';
|
||||
|
||||
/**
|
||||
* Zend_Pdf_Destination_FitBoundingBox explicit detination
|
||||
*
|
||||
* Destination array: [page /FitB]
|
||||
*
|
||||
* (PDF 1.1) Display the page designated by page, with its contents magnified
|
||||
* just enough to fit its bounding box entirely within the window both horizontally
|
||||
* and vertically. If the required horizontal and vertical magnification
|
||||
* factors are different, use the smaller of the two, centering the bounding box
|
||||
* within the window in the other dimension.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Destination_FitBoundingBox extends Zend_Pdf_Destination_Explicit
|
||||
{
|
||||
/**
|
||||
* Create destination object
|
||||
*
|
||||
* @param Zend_Pdf_Page|integer $page Page object or page number
|
||||
* @return Zend_Pdf_Destination_FitBoundingBox
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function create($page)
|
||||
{
|
||||
$destinationArray = new Zend_Pdf_Element_Array();
|
||||
|
||||
if ($page instanceof Zend_Pdf_Page) {
|
||||
$destinationArray->items[] = $page->getPageDictionary();
|
||||
} else if (is_integer($page)) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
|
||||
}
|
||||
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Name('FitB');
|
||||
|
||||
return new Zend_Pdf_Destination_FitBoundingBox($destinationArray);
|
||||
}
|
||||
}
|
||||
98
library/Zend/Pdf/Destination/FitBoundingBoxHorizontally.php
Normal file
98
library/Zend/Pdf/Destination/FitBoundingBoxHorizontally.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FitBoundingBoxHorizontally.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Destination_Explicit */
|
||||
// require_once 'Zend/Pdf/Destination/Explicit.php';
|
||||
|
||||
/**
|
||||
* Zend_Pdf_Destination_FitBoundingBoxHorizontally explicit detination
|
||||
*
|
||||
* Destination array: [page /FitBH top]
|
||||
*
|
||||
* (PDF 1.1) Display the page designated by page, with the vertical coordinate
|
||||
* top positioned at the top edge of the window and the contents of the page
|
||||
* magnified just enough to fit the entire width of its bounding box within the
|
||||
* window.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Destination_FitBoundingBoxHorizontally extends Zend_Pdf_Destination_Explicit
|
||||
{
|
||||
/**
|
||||
* Create destination object
|
||||
*
|
||||
* @param Zend_Pdf_Page|integer $page Page object or page number
|
||||
* @param float $top Top edge of displayed page
|
||||
* @return Zend_Pdf_Destination_FitBoundingBoxHorizontally
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function create($page, $top)
|
||||
{
|
||||
$destinationArray = new Zend_Pdf_Element_Array();
|
||||
|
||||
if ($page instanceof Zend_Pdf_Page) {
|
||||
$destinationArray->items[] = $page->getPageDictionary();
|
||||
} else if (is_integer($page)) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
|
||||
}
|
||||
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Name('FitBH');
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
|
||||
|
||||
return new Zend_Pdf_Destination_FitBoundingBoxHorizontally($destinationArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get top edge of the displayed page
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTopEdge()
|
||||
{
|
||||
return $this->_destinationArray->items[2]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top edge of the displayed page
|
||||
*
|
||||
* @param float $top
|
||||
* @return Zend_Pdf_Action_FitBoundingBoxHorizontally
|
||||
*/
|
||||
public function setTopEdge($top)
|
||||
{
|
||||
$this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($top);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
98
library/Zend/Pdf/Destination/FitBoundingBoxVertically.php
Normal file
98
library/Zend/Pdf/Destination/FitBoundingBoxVertically.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FitBoundingBoxVertically.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Destination_Explicit */
|
||||
// require_once 'Zend/Pdf/Destination/Explicit.php';
|
||||
|
||||
/**
|
||||
* Zend_Pdf_Destination_FitBoundingBoxVertically explicit detination
|
||||
*
|
||||
* Destination array: [page /FitBV left]
|
||||
*
|
||||
* (PDF 1.1) Display the page designated by page, with the horizontal coordinate
|
||||
* left positioned at the left edge of the window and the contents of the page
|
||||
* magnified just enough to fit the entire height of its bounding box within the
|
||||
* window.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Destination_FitBoundingBoxVertically extends Zend_Pdf_Destination_Explicit
|
||||
{
|
||||
/**
|
||||
* Create destination object
|
||||
*
|
||||
* @param Zend_Pdf_Page|integer $page Page object or page number
|
||||
* @param float $left Left edge of displayed page
|
||||
* @return Zend_Pdf_Destination_FitBoundingBoxVertically
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function create($page, $left)
|
||||
{
|
||||
$destinationArray = new Zend_Pdf_Element_Array();
|
||||
|
||||
if ($page instanceof Zend_Pdf_Page) {
|
||||
$destinationArray->items[] = $page->getPageDictionary();
|
||||
} else if (is_integer($page)) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
|
||||
}
|
||||
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Name('FitBV');
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
|
||||
|
||||
return new Zend_Pdf_Destination_FitBoundingBoxVertically($destinationArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get left edge of the displayed page
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getLeftEdge()
|
||||
{
|
||||
return $this->_destinationArray->items[2]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left edge of the displayed page
|
||||
*
|
||||
* @param float $left
|
||||
* @return Zend_Pdf_Action_FitBoundingBoxVertically
|
||||
*/
|
||||
public function setLeftEdge($left)
|
||||
{
|
||||
$this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left);
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
98
library/Zend/Pdf/Destination/FitHorizontally.php
Normal file
98
library/Zend/Pdf/Destination/FitHorizontally.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FitHorizontally.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Destination_Explicit */
|
||||
// require_once 'Zend/Pdf/Destination/Explicit.php';
|
||||
|
||||
/**
|
||||
* Zend_Pdf_Destination_FitHorizontally explicit detination
|
||||
*
|
||||
* Destination array: [page /FitH top]
|
||||
*
|
||||
* Display the page designated by page, with the vertical coordinate top positioned
|
||||
* at the top edge of the window and the contents of the page magnified
|
||||
* just enough to fit the entire width of the page within the window.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Destination_FitHorizontally extends Zend_Pdf_Destination_Explicit
|
||||
{
|
||||
/**
|
||||
* Create destination object
|
||||
*
|
||||
* @param Zend_Pdf_Page|integer $page Page object or page number
|
||||
* @param float $top Top edge of displayed page
|
||||
* @return Zend_Pdf_Destination_FitHorizontally
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function create($page, $top)
|
||||
{
|
||||
$destinationArray = new Zend_Pdf_Element_Array();
|
||||
|
||||
if ($page instanceof Zend_Pdf_Page) {
|
||||
$destinationArray->items[] = $page->getPageDictionary();
|
||||
} else if (is_integer($page)) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
|
||||
}
|
||||
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Name('FitH');
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
|
||||
|
||||
return new Zend_Pdf_Destination_FitHorizontally($destinationArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get top edge of the displayed page
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTopEdge()
|
||||
{
|
||||
return $this->_destinationArray->items[2]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top edge of the displayed page
|
||||
*
|
||||
* @param float $top
|
||||
* @return Zend_Pdf_Action_FitHorizontally
|
||||
*/
|
||||
public function setTopEdge($top)
|
||||
{
|
||||
$this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($top);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
171
library/Zend/Pdf/Destination/FitRectangle.php
Normal file
171
library/Zend/Pdf/Destination/FitRectangle.php
Normal file
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FitRectangle.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Destination_Explicit */
|
||||
// require_once 'Zend/Pdf/Destination/Explicit.php';
|
||||
|
||||
/**
|
||||
* Zend_Pdf_Destination_FitRectangle explicit detination
|
||||
*
|
||||
* Destination array: [page /FitR left bottom right top]
|
||||
*
|
||||
* Display the page designated by page, with its contents magnified just enough
|
||||
* to fit the rectangle specified by the coordinates left, bottom, right, and top
|
||||
* entirely within the window both horizontally and vertically. If the required
|
||||
* horizontal and vertical magnification factors are different, use the smaller of
|
||||
* the two, centering the rectangle within the window in the other dimension.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Destination_FitRectangle extends Zend_Pdf_Destination_Explicit
|
||||
{
|
||||
/**
|
||||
* Create destination object
|
||||
*
|
||||
* @param Zend_Pdf_Page|integer $page Page object or page number
|
||||
* @param float $left Left edge of displayed page
|
||||
* @param float $bottom Bottom edge of displayed page
|
||||
* @param float $right Right edge of displayed page
|
||||
* @param float $top Top edge of displayed page
|
||||
* @return Zend_Pdf_Destination_FitRectangle
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function create($page, $left, $bottom, $right, $top)
|
||||
{
|
||||
$destinationArray = new Zend_Pdf_Element_Array();
|
||||
|
||||
if ($page instanceof Zend_Pdf_Page) {
|
||||
$destinationArray->items[] = $page->getPageDictionary();
|
||||
} else if (is_integer($page)) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
|
||||
}
|
||||
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Name('FitR');
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($bottom);
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($right);
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
|
||||
|
||||
return new Zend_Pdf_Destination_FitRectangle($destinationArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get left edge of the displayed page
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getLeftEdge()
|
||||
{
|
||||
return $this->_destinationArray->items[2]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left edge of the displayed page
|
||||
*
|
||||
* @param float $left
|
||||
* @return Zend_Pdf_Action_FitRectangle
|
||||
*/
|
||||
public function setLeftEdge($left)
|
||||
{
|
||||
$this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bottom edge of the displayed page
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getBottomEdge()
|
||||
{
|
||||
return $this->_destinationArray->items[3]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bottom edge of the displayed page
|
||||
*
|
||||
* @param float $bottom
|
||||
* @return Zend_Pdf_Action_FitRectangle
|
||||
*/
|
||||
public function setBottomEdge($bottom)
|
||||
{
|
||||
$this->_destinationArray->items[3] = new Zend_Pdf_Element_Numeric($bottom);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get right edge of the displayed page
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getRightEdge()
|
||||
{
|
||||
return $this->_destinationArray->items[4]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set right edge of the displayed page
|
||||
*
|
||||
* @param float $right
|
||||
* @return Zend_Pdf_Action_FitRectangle
|
||||
*/
|
||||
public function setRightEdge($right)
|
||||
{
|
||||
$this->_destinationArray->items[4] = new Zend_Pdf_Element_Numeric($right);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get top edge of the displayed page
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTopEdge()
|
||||
{
|
||||
return $this->_destinationArray->items[5]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top edge of the displayed page
|
||||
*
|
||||
* @param float $top
|
||||
* @return Zend_Pdf_Action_FitRectangle
|
||||
*/
|
||||
public function setTopEdge($top)
|
||||
{
|
||||
$this->_destinationArray->items[5] = new Zend_Pdf_Element_Numeric($top);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
98
library/Zend/Pdf/Destination/FitVertically.php
Normal file
98
library/Zend/Pdf/Destination/FitVertically.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FitVertically.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Destination_Explicit */
|
||||
// require_once 'Zend/Pdf/Destination/Explicit.php';
|
||||
|
||||
/**
|
||||
* Zend_Pdf_Destination_FitVertically explicit detination
|
||||
*
|
||||
* Destination array: [page /FitV left]
|
||||
*
|
||||
* Display the page designated by page, with the horizontal coordinate left positioned
|
||||
* at the left edge of the window and the contents of the page magnified
|
||||
* just enough to fit the entire height of the page within the window.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Destination_FitVertically extends Zend_Pdf_Destination_Explicit
|
||||
{
|
||||
/**
|
||||
* Create destination object
|
||||
*
|
||||
* @param Zend_Pdf_Page|integer $page Page object or page number
|
||||
* @param float $left Left edge of displayed page
|
||||
* @return Zend_Pdf_Destination_FitVertically
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function create($page, $left)
|
||||
{
|
||||
$destinationArray = new Zend_Pdf_Element_Array();
|
||||
|
||||
if ($page instanceof Zend_Pdf_Page) {
|
||||
$destinationArray->items[] = $page->getPageDictionary();
|
||||
} else if (is_integer($page)) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or page number.');
|
||||
}
|
||||
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Name('FitV');
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
|
||||
|
||||
return new Zend_Pdf_Destination_FitVertically($destinationArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get left edge of the displayed page
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getLeftEdge()
|
||||
{
|
||||
return $this->_destinationArray->items[2]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left edge of the displayed page
|
||||
*
|
||||
* @param float $left
|
||||
* @return Zend_Pdf_Action_FitVertically
|
||||
*/
|
||||
public function setLeftEdge($left)
|
||||
{
|
||||
$this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
101
library/Zend/Pdf/Destination/Named.php
Normal file
101
library/Zend/Pdf/Destination/Named.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Named.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
// require_once 'Zend/Pdf/Element/String.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Destination */
|
||||
// require_once 'Zend/Pdf/Destination.php';
|
||||
|
||||
/**
|
||||
* Destination array: [page /Fit]
|
||||
*
|
||||
* Display the page designated by page, with its contents magnified just enough
|
||||
* to fit the entire page within the window both horizontally and vertically. If
|
||||
* the required horizontal and vertical magnification factors are different, use
|
||||
* the smaller of the two, centering the page within the window in the other
|
||||
* dimension.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Destination_Named extends Zend_Pdf_Destination
|
||||
{
|
||||
/**
|
||||
* Destination name
|
||||
*
|
||||
* @var Zend_Pdf_Element_Name|Zend_Pdf_Element_String
|
||||
*/
|
||||
protected $_nameElement;
|
||||
|
||||
/**
|
||||
* Named destination object constructor
|
||||
*
|
||||
* @param Zend_Pdf_Element $resource
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $resource)
|
||||
{
|
||||
if ($resource->getType() != Zend_Pdf_Element::TYPE_NAME && $resource->getType() != Zend_Pdf_Element::TYPE_STRING) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Named destination resource must be a PDF name or a PDF string.');
|
||||
}
|
||||
|
||||
$this->_nameElement = $resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create named destination object
|
||||
*
|
||||
* @param string $name
|
||||
* @return Zend_Pdf_Destination_Named
|
||||
*/
|
||||
public static function create($name)
|
||||
{
|
||||
return new Zend_Pdf_Destination_Named(new Zend_Pdf_Element_String($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return Zend_Pdf_Element
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->_nameElement->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource
|
||||
*
|
||||
* @internal
|
||||
* @return Zend_Pdf_Element
|
||||
*/
|
||||
public function getResource()
|
||||
{
|
||||
return $this->_nameElement;
|
||||
}
|
||||
}
|
||||
37
library/Zend/Pdf/Destination/Unknown.php
Normal file
37
library/Zend/Pdf/Destination/Unknown.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Unknown.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Destination_Explicit */
|
||||
// require_once 'Zend/Pdf/Destination/Explicit.php';
|
||||
|
||||
|
||||
/**
|
||||
* Unrecognized explicit destination representation class
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Destination_Unknown extends Zend_Pdf_Destination_Explicit
|
||||
{
|
||||
}
|
||||
177
library/Zend/Pdf/Destination/Zoom.php
Normal file
177
library/Zend/Pdf/Destination/Zoom.php
Normal file
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Zoom.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
// require_once 'Zend/Pdf/Element/Null.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Destination_Explicit */
|
||||
// require_once 'Zend/Pdf/Destination/Explicit.php';
|
||||
|
||||
/**
|
||||
* Zend_Pdf_Destination_Zoom explicit detination
|
||||
*
|
||||
* Destination array: [page /XYZ left top zoom]
|
||||
*
|
||||
* Display the page designated by page, with the coordinates (left, top) positioned
|
||||
* at the upper-left corner of the window and the contents of the page
|
||||
* magnified by the factor zoom. A null value for any of the parameters left, top,
|
||||
* or zoom specifies that the current value of that parameter is to be retained unchanged.
|
||||
* A zoom value of 0 has the same meaning as a null value.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Destination
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Destination_Zoom extends Zend_Pdf_Destination_Explicit
|
||||
{
|
||||
/**
|
||||
* Create destination object
|
||||
*
|
||||
* @param Zend_Pdf_Page|integer $page Page object or page number
|
||||
* @param float $left Left edge of displayed page
|
||||
* @param float $top Top edge of displayed page
|
||||
* @param float $zoom Zoom factor
|
||||
* @return Zend_Pdf_Destination_Zoom
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public static function create($page, $left = null, $top = null, $zoom = null)
|
||||
{
|
||||
$destinationArray = new Zend_Pdf_Element_Array();
|
||||
|
||||
if ($page instanceof Zend_Pdf_Page) {
|
||||
$destinationArray->items[] = $page->getPageDictionary();
|
||||
} else if (is_integer($page)) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
|
||||
}
|
||||
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Name('XYZ');
|
||||
|
||||
if ($left === null) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Null();
|
||||
} else {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
|
||||
}
|
||||
|
||||
if ($top === null) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Null();
|
||||
} else {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
|
||||
}
|
||||
|
||||
if ($zoom === null) {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Null();
|
||||
} else {
|
||||
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($zoom);
|
||||
}
|
||||
|
||||
return new Zend_Pdf_Destination_Zoom($destinationArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get left edge of the displayed page (null means viewer application 'current value')
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getLeftEdge()
|
||||
{
|
||||
return $this->_destinationArray->items[2]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left edge of the displayed page (null means viewer application 'current value')
|
||||
*
|
||||
* @param float $left
|
||||
* @return Zend_Pdf_Action_Zoom
|
||||
*/
|
||||
public function setLeftEdge($left)
|
||||
{
|
||||
if ($left === null) {
|
||||
$this->_destinationArray->items[2] = new Zend_Pdf_Element_Null();
|
||||
} else {
|
||||
$this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get top edge of the displayed page (null means viewer application 'current value')
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTopEdge()
|
||||
{
|
||||
return $this->_destinationArray->items[3]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top edge of the displayed page (null means viewer application 'current viewer')
|
||||
*
|
||||
* @param float $top
|
||||
* @return Zend_Pdf_Action_Zoom
|
||||
*/
|
||||
public function setTopEdge($top)
|
||||
{
|
||||
if ($top === null) {
|
||||
$this->_destinationArray->items[3] = new Zend_Pdf_Element_Null();
|
||||
} else {
|
||||
$this->_destinationArray->items[3] = new Zend_Pdf_Element_Numeric($top);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ZoomFactor of the displayed page (null or 0 means viewer application 'current value')
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getZoomFactor()
|
||||
{
|
||||
return $this->_destinationArray->items[4]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ZoomFactor of the displayed page (null or 0 means viewer application 'current viewer')
|
||||
*
|
||||
* @param float $zoom
|
||||
* @return Zend_Pdf_Action_Zoom
|
||||
*/
|
||||
public function setZoomFactor($zoom)
|
||||
{
|
||||
if ($zoom === null) {
|
||||
$this->_destinationArray->items[4] = new Zend_Pdf_Element_Null();
|
||||
} else {
|
||||
$this->_destinationArray->items[4] = new Zend_Pdf_Element_Numeric($zoom);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
176
library/Zend/Pdf/Element.php
Normal file
176
library/Zend/Pdf/Element.php
Normal file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Element.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PDF file element implementation
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Pdf_Element
|
||||
{
|
||||
const TYPE_BOOL = 1;
|
||||
const TYPE_NUMERIC = 2;
|
||||
const TYPE_STRING = 3;
|
||||
const TYPE_NAME = 4;
|
||||
const TYPE_ARRAY = 5;
|
||||
const TYPE_DICTIONARY = 6;
|
||||
const TYPE_STREAM = 7;
|
||||
const TYPE_NULL = 11;
|
||||
|
||||
/**
|
||||
* Reference to the top level indirect object, which contains this element.
|
||||
*
|
||||
* @var Zend_Pdf_Element_Object
|
||||
*/
|
||||
private $_parentObject = null;
|
||||
|
||||
/**
|
||||
* Return type of the element.
|
||||
* See ZPdfPDFConst for possible values
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
abstract public function getType();
|
||||
|
||||
/**
|
||||
* Convert element to a string, which can be directly
|
||||
* written to a PDF file.
|
||||
*
|
||||
* $factory parameter defines operation context.
|
||||
*
|
||||
* @param Zend_Pdf_Factory $factory
|
||||
* @return string
|
||||
*/
|
||||
abstract public function toString($factory = null);
|
||||
|
||||
const CLONE_MODE_SKIP_PAGES = 1; // Do not follow pages during deep copy process
|
||||
const CLONE_MODE_FORCE_CLONING = 2; // Force top level object cloning even it's already processed
|
||||
|
||||
/**
|
||||
* Detach PDF object from the factory (if applicable), clone it and attach to new factory.
|
||||
*
|
||||
* @todo It's nevessry to check if SplObjectStorage class works faster
|
||||
* (Needs PHP 5.3.x to attach object _with_ additional data to storage)
|
||||
*
|
||||
* @param Zend_Pdf_ElementFactory $factory The factory to attach
|
||||
* @param array &$processed List of already processed indirect objects, used to avoid objects duplication
|
||||
* @param integer $mode Cloning mode (defines filter for objects cloning)
|
||||
* @returns Zend_Pdf_Element
|
||||
*/
|
||||
public function makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
|
||||
{
|
||||
return clone $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top level parent indirect object.
|
||||
*
|
||||
* @param Zend_Pdf_Element_Object $parent
|
||||
*/
|
||||
public function setParentObject(Zend_Pdf_Element_Object $parent)
|
||||
{
|
||||
$this->_parentObject = $parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get top level parent indirect object.
|
||||
*
|
||||
* @return Zend_Pdf_Element_Object
|
||||
*/
|
||||
public function getParentObject()
|
||||
{
|
||||
return $this->_parentObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mark object as modified, to include it into new PDF file segment.
|
||||
*
|
||||
* We don't automate this action to keep control on PDF update process.
|
||||
* All new objects are treated as "modified" automatically.
|
||||
*/
|
||||
public function touch()
|
||||
{
|
||||
if ($this->_parentObject !== null) {
|
||||
$this->_parentObject->touch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up resources, used by object
|
||||
*/
|
||||
public function cleanUp()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert PDF element to PHP type.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function toPhp()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert PHP value into PDF element.
|
||||
*
|
||||
* @param mixed $input
|
||||
* @return Zend_Pdf_Element
|
||||
*/
|
||||
public static function phpToPdf($input)
|
||||
{
|
||||
if (is_numeric($input)) {
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
return new Zend_Pdf_Element_Numeric($input);
|
||||
} else if (is_bool($input)) {
|
||||
// require_once 'Zend/Pdf/Element/Boolean.php';
|
||||
return new Zend_Pdf_Element_Boolean($input);
|
||||
} else if (is_array($input)) {
|
||||
$pdfElementsArray = array();
|
||||
$isDictionary = false;
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
if (is_string($key)) {
|
||||
$isDictionary = true;
|
||||
}
|
||||
$pdfElementsArray[$key] = Zend_Pdf_Element::phpToPdf($value);
|
||||
}
|
||||
|
||||
if ($isDictionary) {
|
||||
// require_once 'Zend/Pdf/Element/Dictionary.php';
|
||||
return new Zend_Pdf_Element_Dictionary($pdfElementsArray);
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Element/Array.php';
|
||||
return new Zend_Pdf_Element_Array($pdfElementsArray);
|
||||
}
|
||||
} else {
|
||||
// require_once 'Zend/Pdf/Element/String.php';
|
||||
return new Zend_Pdf_Element_String((string)$input);
|
||||
}
|
||||
}
|
||||
}
|
||||
181
library/Zend/Pdf/Element/Array.php
Normal file
181
library/Zend/Pdf/Element/Array.php
Normal file
@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Array.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Zend_Pdf_Element */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF file 'array' element implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Element_Array extends Zend_Pdf_Element
|
||||
{
|
||||
/**
|
||||
* Array element items
|
||||
*
|
||||
* Array of Zend_Pdf_Element objects
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $items;
|
||||
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param array $val - array of Zend_Pdf_Element objects
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($val = null)
|
||||
{
|
||||
$this->items = new ArrayObject();
|
||||
|
||||
if ($val !== null && is_array($val)) {
|
||||
foreach ($val as $element) {
|
||||
if (!$element instanceof Zend_Pdf_Element) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Array elements must be Zend_Pdf_Element objects');
|
||||
}
|
||||
$this->items[] = $element;
|
||||
}
|
||||
} else if ($val !== null){
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Argument must be an array');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter
|
||||
*
|
||||
* @param string $property
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __get($property) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Undefined property: Zend_Pdf_Element_Array::$' . $property);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setter
|
||||
*
|
||||
* @param mixed $offset
|
||||
* @param mixed $value
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __set($property, $value) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Undefined property: Zend_Pdf_Element_Array::$' . $property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type of the element.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return Zend_Pdf_Element::TYPE_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return object as string
|
||||
*
|
||||
* @param Zend_Pdf_Factory $factory
|
||||
* @return string
|
||||
*/
|
||||
public function toString($factory = null)
|
||||
{
|
||||
$outStr = '[';
|
||||
$lastNL = 0;
|
||||
|
||||
foreach ($this->items as $element) {
|
||||
if (strlen($outStr) - $lastNL > 128) {
|
||||
$outStr .= "\n";
|
||||
$lastNL = strlen($outStr);
|
||||
}
|
||||
|
||||
$outStr .= $element->toString($factory) . ' ';
|
||||
}
|
||||
$outStr .= ']';
|
||||
|
||||
return $outStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach PDF object from the factory (if applicable), clone it and attach to new factory.
|
||||
*
|
||||
* @param Zend_Pdf_ElementFactory $factory The factory to attach
|
||||
* @param array &$processed List of already processed indirect objects, used to avoid objects duplication
|
||||
* @param integer $mode Cloning mode (defines filter for objects cloning)
|
||||
* @returns Zend_Pdf_Element
|
||||
*/
|
||||
public function makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
|
||||
{
|
||||
$newArray = new self();
|
||||
|
||||
foreach ($this->items as $key => $value) {
|
||||
$newArray->items[$key] = $value->makeClone($factory, $processed, $mode);
|
||||
}
|
||||
|
||||
return $newArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top level parent indirect object.
|
||||
*
|
||||
* @param Zend_Pdf_Element_Object $parent
|
||||
*/
|
||||
public function setParentObject(Zend_Pdf_Element_Object $parent)
|
||||
{
|
||||
parent::setParentObject($parent);
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
$item->setParentObject($parent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert PDF element to PHP type.
|
||||
*
|
||||
* Dictionary is returned as an associative array
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function toPhp()
|
||||
{
|
||||
$phpArray = array();
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
$phpArray[] = $item->toPhp();
|
||||
}
|
||||
|
||||
return $phpArray;
|
||||
}
|
||||
}
|
||||
83
library/Zend/Pdf/Element/Boolean.php
Normal file
83
library/Zend/Pdf/Element/Boolean.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Boolean.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Zend_Pdf_Element */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF file 'boolean' element implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Element_Boolean extends Zend_Pdf_Element
|
||||
{
|
||||
/**
|
||||
* Object value
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $value;
|
||||
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param boolean $val
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($val)
|
||||
{
|
||||
if (! is_bool($val)) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Argument must be boolean.');
|
||||
}
|
||||
|
||||
$this->value = $val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return type of the element.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return Zend_Pdf_Element::TYPE_BOOL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return object as string
|
||||
*
|
||||
* @param Zend_Pdf_Factory $factory
|
||||
* @return string
|
||||
*/
|
||||
public function toString($factory = null)
|
||||
{
|
||||
return $this->value ? 'true' : 'false';
|
||||
}
|
||||
}
|
||||
236
library/Zend/Pdf/Element/Dictionary.php
Normal file
236
library/Zend/Pdf/Element/Dictionary.php
Normal file
@ -0,0 +1,236 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Dictionary.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Name.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Element */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
|
||||
/**
|
||||
* PDF file 'dictionary' element implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Element_Dictionary extends Zend_Pdf_Element
|
||||
{
|
||||
/**
|
||||
* Dictionary elements
|
||||
* Array of Zend_Pdf_Element objects ('name' => Zend_Pdf_Element)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_items = array();
|
||||
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param array $val - array of Zend_Pdf_Element objects
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($val = null)
|
||||
{
|
||||
if ($val === null) {
|
||||
return;
|
||||
} else if (!is_array($val)) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Argument must be an array');
|
||||
}
|
||||
|
||||
foreach ($val as $name => $element) {
|
||||
if (!$element instanceof Zend_Pdf_Element) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Array elements must be Zend_Pdf_Element objects');
|
||||
}
|
||||
if (!is_string($name)) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Array keys must be strings');
|
||||
}
|
||||
$this->_items[$name] = $element;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add element to an array
|
||||
*
|
||||
* @name Zend_Pdf_Element_Name $name
|
||||
* @param Zend_Pdf_Element $val - Zend_Pdf_Element object
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function add(Zend_Pdf_Element_Name $name, Zend_Pdf_Element $val)
|
||||
{
|
||||
$this->_items[$name->value] = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dictionary keys
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getKeys()
|
||||
{
|
||||
return array_keys($this->_items);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get handler
|
||||
*
|
||||
* @param string $property
|
||||
* @return Zend_Pdf_Element | null
|
||||
*/
|
||||
public function __get($item)
|
||||
{
|
||||
$element = isset($this->_items[$item]) ? $this->_items[$item]
|
||||
: null;
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set handler
|
||||
*
|
||||
* @param string $property
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set($item, $value)
|
||||
{
|
||||
if ($value === null) {
|
||||
unset($this->_items[$item]);
|
||||
} else {
|
||||
$this->_items[$item] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type of the element.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return Zend_Pdf_Element::TYPE_DICTIONARY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return object as string
|
||||
*
|
||||
* @param Zend_Pdf_Factory $factory
|
||||
* @return string
|
||||
*/
|
||||
public function toString($factory = null)
|
||||
{
|
||||
$outStr = '<<';
|
||||
$lastNL = 0;
|
||||
|
||||
foreach ($this->_items as $name => $element) {
|
||||
if (!is_object($element)) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Wrong data');
|
||||
}
|
||||
|
||||
if (strlen($outStr) - $lastNL > 128) {
|
||||
$outStr .= "\n";
|
||||
$lastNL = strlen($outStr);
|
||||
}
|
||||
|
||||
$nameObj = new Zend_Pdf_Element_Name($name);
|
||||
$outStr .= $nameObj->toString($factory) . ' ' . $element->toString($factory) . ' ';
|
||||
}
|
||||
$outStr .= '>>';
|
||||
|
||||
return $outStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach PDF object from the factory (if applicable), clone it and attach to new factory.
|
||||
*
|
||||
* @param Zend_Pdf_ElementFactory $factory The factory to attach
|
||||
* @param array &$processed List of already processed indirect objects, used to avoid objects duplication
|
||||
* @param integer $mode Cloning mode (defines filter for objects cloning)
|
||||
* @returns Zend_Pdf_Element
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
|
||||
{
|
||||
if (isset($this->_items['Type'])) {
|
||||
if ($this->_items['Type']->value == 'Pages') {
|
||||
// It's a page tree node
|
||||
// skip it and its children
|
||||
return new Zend_Pdf_Element_Null();
|
||||
}
|
||||
|
||||
if ($this->_items['Type']->value == 'Page' &&
|
||||
$mode == Zend_Pdf_Element::CLONE_MODE_SKIP_PAGES
|
||||
) {
|
||||
// It's a page node, skip it
|
||||
return new Zend_Pdf_Element_Null();
|
||||
}
|
||||
}
|
||||
|
||||
$newDictionary = new self();
|
||||
foreach ($this->_items as $key => $value) {
|
||||
$newDictionary->_items[$key] = $value->makeClone($factory, $processed, $mode);
|
||||
}
|
||||
|
||||
return $newDictionary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top level parent indirect object.
|
||||
*
|
||||
* @param Zend_Pdf_Element_Object $parent
|
||||
*/
|
||||
public function setParentObject(Zend_Pdf_Element_Object $parent)
|
||||
{
|
||||
parent::setParentObject($parent);
|
||||
|
||||
foreach ($this->_items as $item) {
|
||||
$item->setParentObject($parent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert PDF element to PHP type.
|
||||
*
|
||||
* Dictionary is returned as an associative array
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function toPhp()
|
||||
{
|
||||
$phpArray = array();
|
||||
|
||||
foreach ($this->_items as $itemName => $item) {
|
||||
$phpArray[$itemName] = $item->toPhp();
|
||||
}
|
||||
|
||||
return $phpArray;
|
||||
}
|
||||
}
|
||||
161
library/Zend/Pdf/Element/Name.php
Normal file
161
library/Zend/Pdf/Element/Name.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Name.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Zend_Pdf_Element */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF file 'name' element implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Element_Name extends Zend_Pdf_Element
|
||||
{
|
||||
/**
|
||||
* Object value
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param string $val
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($val)
|
||||
{
|
||||
settype($val, 'string');
|
||||
if (strpos($val,"\x00") !== false) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Null character is not allowed in PDF Names');
|
||||
}
|
||||
$this->value = (string)$val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return type of the element.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return Zend_Pdf_Element::TYPE_NAME;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Escape string according to the PDF rules
|
||||
*
|
||||
* @param string $inStr
|
||||
* @return string
|
||||
*/
|
||||
public static function escape($inStr)
|
||||
{
|
||||
$outStr = '';
|
||||
|
||||
for ($count = 0; $count < strlen($inStr); $count++) {
|
||||
$nextCode = ord($inStr[$count]);
|
||||
|
||||
switch ($inStr[$count]) {
|
||||
case '(':
|
||||
// fall through to next case
|
||||
case ')':
|
||||
// fall through to next case
|
||||
case '<':
|
||||
// fall through to next case
|
||||
case '>':
|
||||
// fall through to next case
|
||||
case '[':
|
||||
// fall through to next case
|
||||
case ']':
|
||||
// fall through to next case
|
||||
case '{':
|
||||
// fall through to next case
|
||||
case '}':
|
||||
// fall through to next case
|
||||
case '/':
|
||||
// fall through to next case
|
||||
case '%':
|
||||
// fall through to next case
|
||||
case '\\':
|
||||
// fall through to next case
|
||||
case '#':
|
||||
$outStr .= sprintf('#%02X', $nextCode);
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($nextCode >= 33 && $nextCode <= 126 ) {
|
||||
// Visible ASCII symbol
|
||||
$outStr .= $inStr[$count];
|
||||
} else {
|
||||
$outStr .= sprintf('#%02X', $nextCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $outStr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unescape string according to the PDF rules
|
||||
*
|
||||
* @param string $inStr
|
||||
* @return string
|
||||
*/
|
||||
public static function unescape($inStr)
|
||||
{
|
||||
$outStr = '';
|
||||
|
||||
for ($count = 0; $count < strlen($inStr); $count++) {
|
||||
if ($inStr[$count] != '#' ) {
|
||||
$outStr .= $inStr[$count];
|
||||
} else {
|
||||
// Escape sequence
|
||||
$outStr .= chr(base_convert(substr($inStr, $count+1, 2), 16, 10 ));
|
||||
$count +=2;
|
||||
}
|
||||
}
|
||||
return $outStr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return object as string
|
||||
*
|
||||
* @param Zend_Pdf_Factory $factory
|
||||
* @return string
|
||||
*/
|
||||
public function toString($factory = null)
|
||||
{
|
||||
return '/' . self::escape((string)$this->value);
|
||||
}
|
||||
}
|
||||
75
library/Zend/Pdf/Element/Null.php
Normal file
75
library/Zend/Pdf/Element/Null.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Null.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Zend_Pdf_Element */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF file 'null' element implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Element_Null extends Zend_Pdf_Element
|
||||
{
|
||||
/**
|
||||
* Object value. Always null.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $value;
|
||||
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->value = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return type of the element.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return Zend_Pdf_Element::TYPE_NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return object as string
|
||||
*
|
||||
* @param Zend_Pdf_Factory $factory
|
||||
* @return string
|
||||
*/
|
||||
public function toString($factory = null)
|
||||
{
|
||||
return 'null';
|
||||
}
|
||||
}
|
||||
95
library/Zend/Pdf/Element/Numeric.php
Normal file
95
library/Zend/Pdf/Element/Numeric.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Numeric.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Zend_Pdf_Element */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF file 'numeric' element implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Element_Numeric extends Zend_Pdf_Element
|
||||
{
|
||||
/**
|
||||
* Object value
|
||||
*
|
||||
* @var numeric
|
||||
*/
|
||||
public $value;
|
||||
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param numeric $val
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($val)
|
||||
{
|
||||
if ( !is_numeric($val) ) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Argument must be numeric');
|
||||
}
|
||||
|
||||
$this->value = $val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return type of the element.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return Zend_Pdf_Element::TYPE_NUMERIC;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return object as string
|
||||
*
|
||||
* @param Zend_Pdf_Factory $factory
|
||||
* @return string
|
||||
*/
|
||||
public function toString($factory = null)
|
||||
{
|
||||
if (is_integer($this->value)) {
|
||||
return (string)$this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* PDF doesn't support exponental format.
|
||||
* Fixed point format must be used instead
|
||||
*/
|
||||
$prec = 0; $v = $this->value;
|
||||
while (abs( floor($v) - $v ) > 1e-10) {
|
||||
$prec++; $v *= 10;
|
||||
}
|
||||
return sprintf("%.{$prec}F", $this->value);
|
||||
}
|
||||
}
|
||||
284
library/Zend/Pdf/Element/Object.php
Normal file
284
library/Zend/Pdf/Element/Object.php
Normal file
@ -0,0 +1,284 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Object.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Zend_Pdf_Element */
|
||||
// require_once 'Zend/Pdf/Element.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF file 'indirect object' element implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Element_Object extends Zend_Pdf_Element
|
||||
{
|
||||
/**
|
||||
* Object value
|
||||
*
|
||||
* @var Zend_Pdf_Element
|
||||
*/
|
||||
protected $_value;
|
||||
|
||||
/**
|
||||
* Object number within PDF file
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_objNum;
|
||||
|
||||
/**
|
||||
* Generation number
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_genNum;
|
||||
|
||||
/**
|
||||
* Reference to the factory.
|
||||
*
|
||||
* @var Zend_Pdf_ElementFactory
|
||||
*/
|
||||
protected $_factory;
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param Zend_Pdf_Element $val
|
||||
* @param integer $objNum
|
||||
* @param integer $genNum
|
||||
* @param Zend_Pdf_ElementFactory $factory
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $val, $objNum, $genNum, Zend_Pdf_ElementFactory $factory)
|
||||
{
|
||||
if ($val instanceof self) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Object number must not be an instance of Zend_Pdf_Element_Object.');
|
||||
}
|
||||
|
||||
if ( !(is_integer($objNum) && $objNum > 0) ) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Object number must be positive integer.');
|
||||
}
|
||||
|
||||
if ( !(is_integer($genNum) && $genNum >= 0) ) {
|
||||
// require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Generation number must be non-negative integer.');
|
||||
}
|
||||
|
||||
$this->_value = $val;
|
||||
$this->_objNum = $objNum;
|
||||
$this->_genNum = $genNum;
|
||||
$this->_factory = $factory;
|
||||
|
||||
$this->setParentObject($this);
|
||||
|
||||
$factory->registerObject($this, $objNum . ' ' . $genNum);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check, that object is generated by specified factory
|
||||
*
|
||||
* @return Zend_Pdf_ElementFactory
|
||||
*/
|
||||
public function getFactory()
|
||||
{
|
||||
return $this->_factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type of the element.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->_value->getType();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get object number
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getObjNum()
|
||||
{
|
||||
return $this->_objNum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get generation number
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getGenNum()
|
||||
{
|
||||
return $this->_genNum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return reference to the object
|
||||
*
|
||||
* @param Zend_Pdf_Factory $factory
|
||||
* @return string
|
||||
*/
|
||||
public function toString($factory = null)
|
||||
{
|
||||
if ($factory === null) {
|
||||
$shift = 0;
|
||||
} else {
|
||||
$shift = $factory->getEnumerationShift($this->_factory);
|
||||
}
|
||||
|
||||
return $this->_objNum + $shift . ' ' . $this->_genNum . ' R';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dump object to a string to save within PDF file.
|
||||
*
|
||||
* $factory parameter defines operation context.
|
||||
*
|
||||
* @param Zend_Pdf_ElementFactory $factory
|
||||
* @return string
|
||||
*/
|
||||
public function dump(Zend_Pdf_ElementFactory $factory)
|
||||
{
|
||||
$shift = $factory->getEnumerationShift($this->_factory);
|
||||
|
||||
return $this->_objNum + $shift . " " . $this->_genNum . " obj \n"
|
||||
. $this->_value->toString($factory) . "\n"
|
||||
. "endobj\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get handler
|
||||
*
|
||||
* @param string $property
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($property)
|
||||
{
|
||||
return $this->_value->$property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set handler
|
||||
*
|
||||
* @param string $property
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set($property, $value)
|
||||
{
|
||||
$this->_value->$property = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call handler
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return call_user_func_array(array($this->_value, $method), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach PDF object from the factory (if applicable), clone it and attach to new factory.
|
||||
*
|
||||
* @param Zend_Pdf_ElementFactory $factory The factory to attach
|
||||
* @param array &$processed List of already processed indirect objects, used to avoid objects duplication
|
||||
* @param integer $mode Cloning mode (defines filter for objects cloning)
|
||||
* @returns Zend_Pdf_Element
|
||||
*/
|
||||
public function makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
|
||||
{
|
||||
$id = spl_object_hash($this);
|
||||
if (isset($processed[$id])) {
|
||||
// Do nothing if object is already processed
|
||||
// return it
|
||||
return $processed[$id];
|
||||
}
|
||||
|
||||
// Create obect with null value and register it in $processed container
|
||||
$processed[$id] = $clonedObject = $factory->newObject(new Zend_Pdf_Element_Null());
|
||||
|
||||
// Pecursively process actual data
|
||||
$clonedObject->_value = $this->_value->makeClone($factory, $processed, $mode);
|
||||
|
||||
if ($clonedObject->_value instanceof Zend_Pdf_Element_Null) {
|
||||
// Do not store null objects within $processed container since it may be filtered
|
||||
// by $mode parameter but used in some future pass
|
||||
unset($processed[$id]);
|
||||
|
||||
// Return direct null object
|
||||
return $clonedObject->_value;
|
||||
}
|
||||
|
||||
return $clonedObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark object as modified, to include it into new PDF file segment
|
||||
*/
|
||||
public function touch()
|
||||
{
|
||||
$this->_factory->markAsModified($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return object, which can be used to identify object and its references identity
|
||||
*
|
||||
* @return Zend_Pdf_Element_Object
|
||||
*/
|
||||
public function getObject()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up resources, used by object
|
||||
*/
|
||||
public function cleanUp()
|
||||
{
|
||||
$this->_value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert PDF element to PHP type.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function toPhp()
|
||||
{
|
||||
return $this->_value->toPhp();
|
||||
}
|
||||
}
|
||||
453
library/Zend/Pdf/Element/Object/Stream.php
Normal file
453
library/Zend/Pdf/Element/Object/Stream.php
Normal file
@ -0,0 +1,453 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Stream.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
// require_once 'Zend/Pdf/Element/Stream.php';
|
||||
// require_once 'Zend/Pdf/Element/Dictionary.php';
|
||||
// require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Element_Object */
|
||||
// require_once 'Zend/Pdf/Element/Object.php';
|
||||
|
||||
/**
|
||||
* PDF file 'stream object' element implementation
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Element_Object_Stream extends Zend_Pdf_Element_Object
|
||||
{
|
||||
/**
|
||||
* StreamObject dictionary
|
||||
* Required enries:
|
||||
* Length
|
||||
*
|
||||
* @var Zend_Pdf_Element_Dictionary
|
||||
*/
|
||||
private $_dictionary;
|
||||
|
||||
/**
|
||||
* Flag which signals, that stream is decoded
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_streamDecoded;
|
||||
|
||||
/**
|
||||
* Stored original stream object dictionary.
|
||||
* Used to decode stream at access time.
|
||||
*
|
||||
* The only properties affecting decoding are sored here.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
private $_initialDictionaryData = null;
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param mixed $val
|
||||
* @param integer $objNum
|
||||
* @param integer $genNum
|
||||
* @param Zend_Pdf_ElementFactory $factory
|
||||
* @param Zend_Pdf_Element_Dictionary|null $dictionary
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($val, $objNum, $genNum, Zend_Pdf_ElementFactory $factory, $dictionary = null)
|
||||
{
|
||||
parent::__construct(new Zend_Pdf_Element_Stream($val), $objNum, $genNum, $factory);
|
||||
|
||||
if ($dictionary === null) {
|
||||
$this->_dictionary = new Zend_Pdf_Element_Dictionary();
|
||||
$this->_dictionary->Length = new Zend_Pdf_Element_Numeric(strlen( $val ));
|
||||
$this->_streamDecoded = true;
|
||||
} else {
|
||||
$this->_dictionary = $dictionary;
|
||||
$this->_streamDecoded = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract dictionary data which are used to store information and to normalize filters
|
||||
* information before defiltering.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _extractDictionaryData()
|
||||
{
|
||||
$dictionaryArray = array();
|
||||
|
||||
$dictionaryArray['Filter'] = array();
|
||||
$dictionaryArray['DecodeParms'] = array();
|
||||
if ($this->_dictionary->Filter === null) {
|
||||
// Do nothing.
|
||||
} else if ($this->_dictionary->Filter->getType() == Zend_Pdf_Element::TYPE_ARRAY) {
|
||||
foreach ($this->_dictionary->Filter->items as $id => $filter) {
|
||||
$dictionaryArray['Filter'][$id] = $filter->value;
|
||||
$dictionaryArray['DecodeParms'][$id] = array();
|
||||
|
||||
if ($this->_dictionary->DecodeParms !== null ) {
|
||||
if ($this->_dictionary->DecodeParms->items[$id] !== null &&
|
||||
$this->_dictionary->DecodeParms->items[$id]->value !== null ) {
|
||||
foreach ($this->_dictionary->DecodeParms->items[$id]->getKeys() as $paramKey) {
|
||||
$dictionaryArray['DecodeParms'][$id][$paramKey] =
|
||||
$this->_dictionary->DecodeParms->items[$id]->$paramKey->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($this->_dictionary->Filter->getType() != Zend_Pdf_Element::TYPE_NULL) {
|
||||
$dictionaryArray['Filter'][0] = $this->_dictionary->Filter->value;
|
||||
$dictionaryArray['DecodeParms'][0] = array();
|
||||
if ($this->_dictionary->DecodeParms !== null ) {
|
||||
foreach ($this->_dictionary->DecodeParms->getKeys() as $paramKey) {
|
||||
$dictionaryArray['DecodeParms'][0][$paramKey] =
|
||||
$this->_dictionary->DecodeParms->$paramKey->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_dictionary->F !== null) {
|
||||
$dictionaryArray['F'] = $this->_dictionary->F->value;
|
||||
}
|
||||
|
||||
$dictionaryArray['FFilter'] = array();
|
||||
$dictionaryArray['FDecodeParms'] = array();
|
||||
if ($this->_dictionary->FFilter === null) {
|
||||
// Do nothing.
|
||||
} else if ($this->_dictionary->FFilter->getType() == Zend_Pdf_Element::TYPE_ARRAY) {
|
||||
foreach ($this->_dictionary->FFilter->items as $id => $filter) {
|
||||
$dictionaryArray['FFilter'][$id] = $filter->value;
|
||||
$dictionaryArray['FDecodeParms'][$id] = array();
|
||||
|
||||
if ($this->_dictionary->FDecodeParms !== null ) {
|
||||
if ($this->_dictionary->FDecodeParms->items[$id] !== null &&
|
||||
$this->_dictionary->FDecodeParms->items[$id]->value !== null) {
|
||||
foreach ($this->_dictionary->FDecodeParms->items[$id]->getKeys() as $paramKey) {
|
||||
$dictionaryArray['FDecodeParms'][$id][$paramKey] =
|
||||
$this->_dictionary->FDecodeParms->items[$id]->items[$paramKey]->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$dictionaryArray['FFilter'][0] = $this->_dictionary->FFilter->value;
|
||||
$dictionaryArray['FDecodeParms'][0] = array();
|
||||
if ($this->_dictionary->FDecodeParms !== null ) {
|
||||
foreach ($this->_dictionary->FDecodeParms->getKeys() as $paramKey) {
|
||||
$dictionaryArray['FDecodeParms'][0][$paramKey] =
|
||||
$this->_dictionary->FDecodeParms->items[$paramKey]->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $dictionaryArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode stream
|
||||
*
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
private function _decodeStream()
|
||||
{
|
||||
if ($this->_initialDictionaryData === null) {
|
||||
$this->_initialDictionaryData = $this->_extractDictionaryData();
|
||||
}
|
||||
|
||||
/**
|
||||
* All applied stream filters must be processed to decode stream.
|
||||
* If we don't recognize any of applied filetrs an exception should be thrown here
|
||||
*/
|
||||
if (isset($this->_initialDictionaryData['F'])) {
|
||||
/** @todo Check, how external files can be processed. */
|
||||