Enabled product bundles
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Setasign - Jan Slabon, https://www.setasign.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,141 @@
|
||||
FPDI - Free PDF Document Importer
|
||||
=================================
|
||||
|
||||
[](https://packagist.org/packages/setasign/fpdi)
|
||||
[](https://packagist.org/packages/setasign/fpdi)
|
||||
[](https://packagist.org/packages/setasign/fpdi)
|
||||
[](https://packagist.org/packages/setasign/fpdi)
|
||||
[](https://travis-ci.org/Setasign/FPDI)
|
||||
|
||||
:heavy_exclamation_mark: This document refers to FPDI 2. Version 1 is deprecated and development is discontinued. :heavy_exclamation_mark:
|
||||
|
||||
FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF
|
||||
documents and use them as templates in [FPDF](http://www.fpdf.org), which was developed by Olivier Plathey. Apart
|
||||
from a copy of [FPDF](http://www.fpdf.org), FPDI does not require any special PHP extensions.
|
||||
|
||||
FPDI can also be used as an extension for [TCPDF](https://github.com/tecnickcom/TCPDF), too.
|
||||
|
||||
## Installation with [Composer](https://packagist.org/packages/setasign/fpdi)
|
||||
|
||||
Because FPDI can be used with FPDF or TCPDF we didn't added a fixed dependency in the main
|
||||
composer.json file but we added metadata packages for both
|
||||
[FPDF](https://github.com/Setasign/FPDI-FPDF) and
|
||||
[TCPDF](https://github.com/Setasign/FPDI-TCPDF).
|
||||
|
||||
### Evaluate Dependencies Automatically
|
||||
|
||||
For FPDF add following [package](https://github.com/Setasign/FPDI-FPDF) to your composer.json:
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"setasign/fpdi-fpdf": "^2.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For TCPDF add following [package](https://github.com/Setasign/FPDI-TCPDF) to your composer.json:
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"setasign/fpdi-tcpdf": "^2.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Manual Dependencies
|
||||
|
||||
If you don't want to use the metadata packages, it is up to you to add the dependencies to your
|
||||
composer.json file.
|
||||
|
||||
To use FPDI with FPDF include following in your composer.json file:
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"setasign/fpdf": "^1.8",
|
||||
"setasign/fpdi": "^2.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you want to use TCPDF, your have to update your composer.json respectively to:
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"tecnickcom/tcpdf": "^6.2",
|
||||
"setasign/fpdi": "^2.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Manual Installation
|
||||
|
||||
If you do not use composer, just require the autoload.php in the /src folder:
|
||||
|
||||
```php
|
||||
require_once('src/autoload.php');
|
||||
```
|
||||
|
||||
If you have a PSR-4 autoloader implemented, just register the src path as follows:
|
||||
```php
|
||||
$loader = new \Example\Psr4AutoloaderClass;
|
||||
$loader->register();
|
||||
$loader->addNamespace('setasign\Fpdi', 'path/to/src/');
|
||||
```
|
||||
|
||||
## Changes to Version 1
|
||||
|
||||
Version 2 is a complete rewrite from scratch of FPDI which comes with:
|
||||
- Namespaced code
|
||||
- Clean and up-to-date code base and style
|
||||
- PSR-4 compatible autoloading
|
||||
- Performance improvements by up to 100%
|
||||
- Less memory consumption
|
||||
- Native support for reading PDFs from strings or stream-resources
|
||||
- Support for documents with "invalid" data before their file-header
|
||||
- Optimized page tree resolving
|
||||
- Usage of individual exceptions
|
||||
- Several test types (unit, functional and visual tests)
|
||||
|
||||
We tried to keep the main methods and logical workflow the same as in version 1 but please
|
||||
notice that there were incompatible changes which you should consider when updating to
|
||||
version 2:
|
||||
- You need to load the code using the `src/autoload.php` file instead of `classes/FPDI.php`.
|
||||
- The classes and traits are namespaced now: `setasign\Fpdi`
|
||||
- Page boundaries beginning with a slash, such as `/MediaBox`, are not supported anymore. Remove
|
||||
the slash or use a constant of `PdfReader\PageBoundaries`.
|
||||
- The parameters $x, $y, $width and $height of the `useTemplate()` or `getTemplateSize()`
|
||||
method have more logical correct default values now. Passing `0` as width or height will
|
||||
result in an `InvalidArgumentException` now.
|
||||
- The return value of `getTemplateSize()` had changed to an array with more speaking keys
|
||||
and reusability: Use `width` instead of `w` and `height` instead of `h`.
|
||||
- If you want to use **FPDI with TCPDF** you need to refactor your code to use the class `TcpdfFpdi`
|
||||
instead of `FPDI`.
|
||||
|
||||
## Example and Documentation
|
||||
|
||||
A simple example, that imports a single page and places this onto a new created page:
|
||||
|
||||
```php
|
||||
<?php
|
||||
use setasign\Fpdi;
|
||||
|
||||
// setup the autoload function
|
||||
require_once('vendor/autoload.php');
|
||||
|
||||
// initiate FPDI
|
||||
$pdf = new Fpdi\Fpdi();
|
||||
// add a page
|
||||
$pdf->AddPage();
|
||||
// set the source file
|
||||
$pdf->setSourceFile("Fantastic-Speaker.pdf");
|
||||
// import page 1
|
||||
$tplId = $pdf->importPage(1);
|
||||
// use the imported page and place it at point 10,10 with a width of 100 mm
|
||||
$pdf->useTemplate($tplId, 10, 10, 100);
|
||||
|
||||
$pdf->Output();
|
||||
```
|
||||
|
||||
A full end-user documentation and API reference is available [here](https://manuals.setasign.com/fpdi-manual/).
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "setasign/fpdi",
|
||||
"homepage": "https://www.setasign.com/fpdi",
|
||||
"description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"pdf",
|
||||
"fpdi",
|
||||
"fpdf"
|
||||
],
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"setasign\\Fpdi\\": "src/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.6 || ^7.0",
|
||||
"ext-zlib": "*"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jan Slabon",
|
||||
"email": "jan.slabon@setasign.com",
|
||||
"homepage": "https://www.setasign.com"
|
||||
},
|
||||
{
|
||||
"name": "Maximilian Kresse",
|
||||
"email": "maximilian.kresse@setasign.com",
|
||||
"homepage": "https://www.setasign.com"
|
||||
}
|
||||
],
|
||||
"suggest": {
|
||||
"setasign/fpdf": "FPDI will extend this class but as it is also possible to use \"tecnickcom/tcpdf\" as an alternative there's no fixed dependency configured.",
|
||||
"setasign/fpdi-fpdf": "Use this package to automatically evaluate dependencies to FPDF.",
|
||||
"setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF."
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~5.7",
|
||||
"setasign/fpdf": "~1.8",
|
||||
"tecnickcom/tcpdf": "~6.2"
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"setasign\\Fpdi\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,428 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi;
|
||||
|
||||
/**
|
||||
* Class FpdfTpl
|
||||
*
|
||||
* This class adds a templating feature to FPDF.
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
*/
|
||||
class FpdfTpl extends \FPDF
|
||||
{
|
||||
/**
|
||||
* Data of all created templates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $templates = [];
|
||||
|
||||
/**
|
||||
* The template id for the currently created template.
|
||||
*
|
||||
* @var null|int
|
||||
*/
|
||||
protected $currentTemplateId;
|
||||
|
||||
/**
|
||||
* A counter for template ids.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $templateId = 0;
|
||||
|
||||
/**
|
||||
* Set the page format of the current page.
|
||||
*
|
||||
* @param array $size An array with two values defining the size.
|
||||
* @param string $orientation "L" for landscape, "P" for portrait.
|
||||
*/
|
||||
public function setPageFormat($size, $orientation)
|
||||
{
|
||||
if (!\in_array($orientation, ['P', 'L'], true)) {
|
||||
throw new \InvalidArgumentException(\sprintf(
|
||||
'Invalid page orientation "%s"! Only "P" and "L" are allowed!',
|
||||
$orientation
|
||||
));
|
||||
}
|
||||
|
||||
$size = $this->_getpagesize($size);
|
||||
|
||||
if ($orientation != $this->CurOrientation
|
||||
|| $size[0] != $this->CurPageSize[0]
|
||||
|| $size[1] != $this->CurPageSize[1]
|
||||
) {
|
||||
// New size or orientation
|
||||
if ($orientation === 'P') {
|
||||
$this->w = $size[0];
|
||||
$this->h = $size[1];
|
||||
} else {
|
||||
$this->w = $size[1];
|
||||
$this->h = $size[0];
|
||||
}
|
||||
$this->wPt = $this->w * $this->k;
|
||||
$this->hPt = $this->h * $this->k;
|
||||
$this->PageBreakTrigger = $this->h - $this->bMargin;
|
||||
$this->CurOrientation = $orientation;
|
||||
$this->CurPageSize = $size;
|
||||
|
||||
$this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a template onto the page or another template.
|
||||
*
|
||||
* Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect
|
||||
* ratio.
|
||||
*
|
||||
* @param mixed $tpl The template id
|
||||
* @param array|float|int $x The abscissa of upper-left corner. Alternatively you could use an assoc array
|
||||
* with the keys "x", "y", "width", "height", "adjustPageSize".
|
||||
* @param float|int $y The ordinate of upper-left corner.
|
||||
* @param float|int|null $width The width.
|
||||
* @param float|int|null $height The height.
|
||||
* @param bool $adjustPageSize
|
||||
* @return array The size
|
||||
* @see FpdfTpl::getTemplateSize()
|
||||
*/
|
||||
public function useTemplate($tpl, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
|
||||
{
|
||||
if (!isset($this->templates[$tpl])) {
|
||||
throw new \InvalidArgumentException('Template does not exist!');
|
||||
}
|
||||
|
||||
if (\is_array($x)) {
|
||||
unset($x['tpl']);
|
||||
\extract($x, EXTR_IF_EXISTS);
|
||||
/** @noinspection NotOptimalIfConditionsInspection */
|
||||
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
|
||||
if (\is_array($x)) {
|
||||
$x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$template = $this->templates[$tpl];
|
||||
|
||||
$originalSize = $this->getTemplateSize($tpl);
|
||||
$newSize = $this->getTemplateSize($tpl, $width, $height);
|
||||
if ($adjustPageSize) {
|
||||
$this->setPageFormat($newSize, $newSize['orientation']);
|
||||
}
|
||||
|
||||
$this->_out(
|
||||
// reset standard values, translate and scale
|
||||
\sprintf(
|
||||
'q 0 J 1 w 0 j 0 G 0 g %.4F 0 0 %.4F %.4F %.4F cm /%s Do Q',
|
||||
($newSize['width'] / $originalSize['width']),
|
||||
($newSize['height'] / $originalSize['height']),
|
||||
$x * $this->k,
|
||||
($this->h - $y - $newSize['height']) * $this->k,
|
||||
$template['id']
|
||||
)
|
||||
);
|
||||
|
||||
return $newSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of a template.
|
||||
*
|
||||
* Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect
|
||||
* ratio.
|
||||
*
|
||||
* @param mixed $tpl The template id
|
||||
* @param float|int|null $width The width.
|
||||
* @param float|int|null $height The height.
|
||||
* @return array|bool An array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P)
|
||||
*/
|
||||
public function getTemplateSize($tpl, $width = null, $height = null)
|
||||
{
|
||||
if (!isset($this->templates[$tpl])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($width === null && $height === null) {
|
||||
$width = $this->templates[$tpl]['width'];
|
||||
$height = $this->templates[$tpl]['height'];
|
||||
} elseif ($width === null) {
|
||||
$width = $height * $this->templates[$tpl]['width'] / $this->templates[$tpl]['height'];
|
||||
}
|
||||
|
||||
if ($height === null) {
|
||||
$height = $width * $this->templates[$tpl]['height'] / $this->templates[$tpl]['width'];
|
||||
}
|
||||
|
||||
if ($height <= 0. || $width <= 0.) {
|
||||
throw new \InvalidArgumentException('Width or height parameter needs to be larger than zero.');
|
||||
}
|
||||
|
||||
return [
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
0 => $width,
|
||||
1 => $height,
|
||||
'orientation' => $width > $height ? 'L' : 'P'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins a new template.
|
||||
*
|
||||
* @param float|int|null $width The width of the template. If null, the current page width is used.
|
||||
* @param float|int|null $height The height of the template. If null, the current page height is used.
|
||||
* @return int A template identifier.
|
||||
*/
|
||||
public function beginTemplate($width = null, $height = null)
|
||||
{
|
||||
if ($width === null) {
|
||||
$width = $this->w;
|
||||
}
|
||||
|
||||
if ($height === null) {
|
||||
$height = $this->h;
|
||||
}
|
||||
|
||||
$templateId = $this->getNextTemplateId();
|
||||
|
||||
// initiate buffer with current state of FPDF
|
||||
$buffer = "2 J\n"
|
||||
. \sprintf('%.2F w', $this->LineWidth * $this->k) . "\n";
|
||||
|
||||
if ($this->FontFamily) {
|
||||
$buffer .= \sprintf("BT /F%d %.2F Tf ET\n", $this->CurrentFont['i'], $this->FontSizePt);
|
||||
}
|
||||
|
||||
if ($this->DrawColor !== '0 G') {
|
||||
$buffer .= $this->DrawColor . "\n";
|
||||
}
|
||||
if ($this->FillColor !== '0 g') {
|
||||
$buffer .= $this->FillColor . "\n";
|
||||
}
|
||||
|
||||
$this->templates[$templateId] = [
|
||||
'objectNumber' => null,
|
||||
'id' => 'TPL' . $templateId,
|
||||
'buffer' => $buffer,
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'state' => [
|
||||
'x' => $this->x,
|
||||
'y' => $this->y,
|
||||
'AutoPageBreak' => $this->AutoPageBreak,
|
||||
'bMargin' => $this->bMargin,
|
||||
'tMargin' => $this->tMargin,
|
||||
'lMargin' => $this->lMargin,
|
||||
'rMargin' => $this->rMargin,
|
||||
'h' => $this->h,
|
||||
'w' => $this->w,
|
||||
'FontFamily' => $this->FontFamily,
|
||||
'FontStyle' => $this->FontStyle,
|
||||
'FontSizePt' => $this->FontSizePt,
|
||||
'FontSize' => $this->FontSize
|
||||
]
|
||||
];
|
||||
|
||||
$this->SetAutoPageBreak(false);
|
||||
$this->currentTemplateId = $templateId;
|
||||
|
||||
$this->h = $height;
|
||||
$this->w = $width;
|
||||
|
||||
$this->SetXY($this->lMargin, $this->tMargin);
|
||||
$this->SetRightMargin($this->w - $width + $this->rMargin);
|
||||
|
||||
return $templateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends a template.
|
||||
*
|
||||
* @return bool|int|null A template identifier.
|
||||
*/
|
||||
public function endTemplate()
|
||||
{
|
||||
if (null === $this->currentTemplateId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$templateId = $this->currentTemplateId;
|
||||
$template = $this->templates[$templateId];
|
||||
|
||||
$state = $template['state'];
|
||||
$this->SetXY($state['x'], $state['y']);
|
||||
$this->tMargin = $state['tMargin'];
|
||||
$this->lMargin = $state['lMargin'];
|
||||
$this->rMargin = $state['rMargin'];
|
||||
$this->h = $state['h'];
|
||||
$this->w = $state['w'];
|
||||
$this->SetAutoPageBreak($state['AutoPageBreak'], $state['bMargin']);
|
||||
|
||||
$this->FontFamily = $state['FontFamily'];
|
||||
$this->FontStyle = $state['FontStyle'];
|
||||
$this->FontSizePt = $state['FontSizePt'];
|
||||
$this->FontSize = $state['FontSize'];
|
||||
|
||||
$fontKey = $this->FontFamily . $this->FontStyle;
|
||||
if ($fontKey) {
|
||||
$this->CurrentFont =& $this->fonts[$fontKey];
|
||||
} else {
|
||||
unset($this->CurrentFont);
|
||||
}
|
||||
|
||||
$this->currentTemplateId = null;
|
||||
|
||||
return $templateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next template id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getNextTemplateId()
|
||||
{
|
||||
return $this->templateId++;
|
||||
}
|
||||
|
||||
/* overwritten FPDF methods: */
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function Link($x, $y, $w, $h, $link)
|
||||
{
|
||||
if ($this->currentTemplateId !== null) {
|
||||
throw new \BadMethodCallException('Links cannot be set when writing to a template.');
|
||||
}
|
||||
parent::Link($x, $y, $w, $h, $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function SetLink($link, $y = 0, $page = -1)
|
||||
{
|
||||
if ($this->currentTemplateId !== null) {
|
||||
throw new \BadMethodCallException('Links cannot be set when writing to a template.');
|
||||
}
|
||||
return parent::SetLink($link, $y, $page);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function SetDrawColor($r, $g = null, $b = null)
|
||||
{
|
||||
parent::SetDrawColor($r, $g, $b);
|
||||
if ($this->page === 0 && $this->currentTemplateId !== null) {
|
||||
$this->_out($this->DrawColor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function SetFillColor($r, $g = null, $b = null)
|
||||
{
|
||||
parent::SetFillColor($r, $g, $b);
|
||||
if ($this->page === 0 && $this->currentTemplateId !== null) {
|
||||
$this->_out($this->FillColor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function SetLineWidth($width)
|
||||
{
|
||||
parent::SetLineWidth($width);
|
||||
if ($this->page === 0 && $this->currentTemplateId !== null) {
|
||||
$this->_out(\sprintf('%.2F w', $width * $this->k));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function SetFont($family, $style = '', $size = 0)
|
||||
{
|
||||
parent::SetFont($family, $style, $size);
|
||||
if ($this->page === 0 && $this->currentTemplateId !== null) {
|
||||
$this->_out(\sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function SetFontSize($size)
|
||||
{
|
||||
parent::SetFontSize($size);
|
||||
if ($this->page === 0 && $this->currentTemplateId !== null) {
|
||||
$this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _putimages()
|
||||
{
|
||||
parent::_putimages();
|
||||
|
||||
foreach ($this->templates as $key => $template) {
|
||||
$this->_newobj();
|
||||
$this->templates[$key]['objectNumber'] = $this->n;
|
||||
|
||||
$this->_put('<</Type /XObject /Subtype /Form /FormType 1');
|
||||
$this->_put(\sprintf('/BBox[0 0 %.2F %.2F]', $template['width'] * $this->k, $template['height'] * $this->k));
|
||||
$this->_put('/Resources 2 0 R'); // default resources dictionary of FPDF
|
||||
|
||||
if ($this->compress) {
|
||||
$buffer = \gzcompress($template['buffer']);
|
||||
$this->_put('/Filter/FlateDecode');
|
||||
} else {
|
||||
$buffer = $template['buffer'];
|
||||
}
|
||||
|
||||
$this->_put('/Length ' . \strlen($buffer));
|
||||
$this->_put('>>');
|
||||
$this->_putstream($buffer);
|
||||
$this->_put('endobj');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _putxobjectdict()
|
||||
{
|
||||
foreach ($this->templates as $key => $template) {
|
||||
$this->_put('/' . $template['id'] . ' ' . $template['objectNumber'] . ' 0 R');
|
||||
}
|
||||
|
||||
parent::_putxobjectdict();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function _out($s)
|
||||
{
|
||||
if ($this->currentTemplateId !== null) {
|
||||
$this->templates[$this->currentTemplateId]['buffer'] .= $s . "\n";
|
||||
} else {
|
||||
parent::_out($s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi;
|
||||
|
||||
use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfIndirectObject;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNull;
|
||||
|
||||
/**
|
||||
* Class Fpdi
|
||||
*
|
||||
* This class let you import pages of existing PDF documents into a reusable structure for FPDF.
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
*/
|
||||
class Fpdi extends FpdfTpl
|
||||
{
|
||||
use FpdiTrait;
|
||||
|
||||
/**
|
||||
* FPDI version
|
||||
*
|
||||
* @string
|
||||
*/
|
||||
const VERSION = '2.0.0';
|
||||
|
||||
/**
|
||||
* Draws an imported page or a template onto the page or another template.
|
||||
*
|
||||
* Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect
|
||||
* ratio.
|
||||
*
|
||||
* @param mixed $tpl The template id
|
||||
* @param float|int|array $x The abscissa of upper-left corner. Alternatively you could use an assoc array
|
||||
* with the keys "x", "y", "width", "height", "adjustPageSize".
|
||||
* @param float|int $y The ordinate of upper-left corner.
|
||||
* @param float|int|null $width The width.
|
||||
* @param float|int|null $height The height.
|
||||
* @param bool $adjustPageSize
|
||||
* @return array The size
|
||||
* @see Fpdi::getTemplateSize()
|
||||
*/
|
||||
public function useTemplate($tpl, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
|
||||
{
|
||||
if (isset($this->importedPages[$tpl])) {
|
||||
$size = $this->useImportedPage($tpl, $x, $y, $width, $height, $adjustPageSize);
|
||||
if ($this->currentTemplateId !== null) {
|
||||
$this->templates[$this->currentTemplateId]['resources']['templates']['importedPages'][$tpl] = $tpl;
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
||||
return parent::useTemplate($tpl, $x, $y, $width, $height, $adjustPageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of an imported page or template.
|
||||
*
|
||||
* Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect
|
||||
* ratio.
|
||||
*
|
||||
* @param mixed $tpl The template id
|
||||
* @param float|int|null $width The width.
|
||||
* @param float|int|null $height The height.
|
||||
* @return array|bool An array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P)
|
||||
*/
|
||||
public function getTemplateSize($tpl, $width = null, $height = null)
|
||||
{
|
||||
$size = parent::getTemplateSize($tpl, $width, $height);
|
||||
if (false === $size) {
|
||||
return $this->getImportedPageSize($tpl, $width, $height);
|
||||
}
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _putimages()
|
||||
{
|
||||
$this->currentReaderId = null;
|
||||
parent::_putimages();
|
||||
|
||||
foreach ($this->importedPages as $key => $pageData) {
|
||||
$this->_newobj();
|
||||
$this->importedPages[$key]['objectNumber'] = $this->n;
|
||||
$this->currentReaderId = $pageData['readerId'];
|
||||
$this->writePdfType($pageData['stream']);
|
||||
$this->_put('endobj');
|
||||
}
|
||||
|
||||
foreach (\array_keys($this->readers) as $readerId) {
|
||||
$parser = $this->getPdfReader($readerId)->getParser();
|
||||
$this->currentReaderId = $readerId;
|
||||
|
||||
while (($objectNumber = \array_pop($this->objectsToCopy[$readerId])) !== null) {
|
||||
try {
|
||||
$object = $parser->getIndirectObject($objectNumber);
|
||||
|
||||
} catch (CrossReferenceException $e) {
|
||||
if ($e->getCode() === CrossReferenceException::OBJECT_NOT_FOUND) {
|
||||
$object = PdfIndirectObject::create($objectNumber, 0, new PdfNull());
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$this->writePdfType($object);
|
||||
}
|
||||
}
|
||||
|
||||
$this->currentReaderId = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _putxobjectdict()
|
||||
{
|
||||
foreach ($this->importedPages as $key => $pageData) {
|
||||
$this->_put('/' . $pageData['id'] . ' ' . $pageData['objectNumber'] . ' 0 R');
|
||||
}
|
||||
|
||||
parent::_putxobjectdict();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _put($s, $newLine = true)
|
||||
{
|
||||
if ($newLine) {
|
||||
$this->buffer .= $s . "\n";
|
||||
} else {
|
||||
$this->buffer .= $s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi;
|
||||
|
||||
/**
|
||||
* Base exception class for the FPDI package.
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
*/
|
||||
class FpdiException extends \Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,523 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfArray;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfBoolean;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfDictionary;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfHexString;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfIndirectObject;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfIndirectObjectReference;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfName;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNull;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNumeric;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfStream;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfString;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfToken;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfType;
|
||||
use setasign\Fpdi\PdfReader\PageBoundaries;
|
||||
use setasign\Fpdi\PdfReader\PdfReader;
|
||||
use setasign\Fpdi\PdfReader\PdfReaderException;
|
||||
use /* This namespace/class is used by the commercial FPDI PDF-Parser add-on. */
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
/** @noinspection PhpUndefinedNamespaceInspection */
|
||||
setasign\FpdiPdfParser\PdfParser\PdfParser as FpdiPdfParser;
|
||||
|
||||
/**
|
||||
* The FpdiTrait
|
||||
*
|
||||
* This trait offers the core functionalities of FPDI. By passing them to a trait we can reuse it with e.g. TCPDF in a
|
||||
* very easy way.
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
*/
|
||||
trait FpdiTrait
|
||||
{
|
||||
/**
|
||||
* The pdf reader instances.
|
||||
*
|
||||
* @var PdfReader[]
|
||||
*/
|
||||
protected $readers = [];
|
||||
|
||||
/**
|
||||
* The current reader id.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $currentReaderId;
|
||||
|
||||
/**
|
||||
* Data of all imported pages.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $importedPages = [];
|
||||
|
||||
/**
|
||||
* A map from object numbers of imported objects to new assigned object numbers by FPDF.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $objectMap = [];
|
||||
|
||||
/**
|
||||
* An array with information about objects, which needs to be copied to the resulting document.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $objectsToCopy = [];
|
||||
|
||||
/**
|
||||
* Set the minimal PDF version.
|
||||
*
|
||||
* @param string $pdfVersion
|
||||
*/
|
||||
protected function setMinPdfVersion($pdfVersion)
|
||||
{
|
||||
if (\version_compare($pdfVersion, $this->PDFVersion, '>')) {
|
||||
$this->PDFVersion = $pdfVersion;
|
||||
}
|
||||
}
|
||||
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
/**
|
||||
* Get a new pdf parser instance.
|
||||
*
|
||||
* @param StreamReader $streamReader
|
||||
* @return PdfParser|FpdiPdfParser
|
||||
*/
|
||||
protected function getPdfParserInstance(StreamReader $streamReader)
|
||||
{
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
if (\class_exists(FpdiPdfParser::class)) {
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
return new FpdiPdfParser($streamReader);
|
||||
}
|
||||
|
||||
return new PdfParser($streamReader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an unique reader id by the $file parameter.
|
||||
*
|
||||
* @param string|resource|PdfReader|StreamReader $file An open file descriptor, a path to a file, a PdfReader
|
||||
* instance or a StreamReader instance.
|
||||
* @return string
|
||||
*/
|
||||
protected function getPdfReaderId($file)
|
||||
{
|
||||
if (\is_resource($file)) {
|
||||
$id = (string) $file;
|
||||
} elseif (\is_string($file)) {
|
||||
$id = \realpath($file);
|
||||
if (false === $id) {
|
||||
$id = $file;
|
||||
}
|
||||
} elseif (\is_object($file)) {
|
||||
$id = \spl_object_hash($file);
|
||||
} else {
|
||||
throw new \InvalidArgumentException(
|
||||
\sprintf('Invalid type in $file parameter (%s)', \gettype($file))
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($this->readers[$id])) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
if (\is_resource($file)) {
|
||||
$streamReader = new StreamReader($file);
|
||||
} elseif (\is_string($file)) {
|
||||
$streamReader = StreamReader::createByFile($file);
|
||||
} else {
|
||||
$streamReader = $file;
|
||||
}
|
||||
|
||||
$reader = new PdfReader($this->getPdfParserInstance($streamReader));
|
||||
$this->readers[$id] = $reader;
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pdf reader instance by its id.
|
||||
*
|
||||
* @param string $id
|
||||
* @return PdfReader
|
||||
*/
|
||||
protected function getPdfReader($id)
|
||||
{
|
||||
if (isset($this->readers[$id])) {
|
||||
return $this->readers[$id];
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(
|
||||
\sprintf('No pdf reader with the given id (%s) exists.', $id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source PDF file.
|
||||
*
|
||||
* @param string|resource|StreamReader $file Path to the file or a stream resource or a StreamReader instance.
|
||||
* @return int The page count of the PDF document.
|
||||
*/
|
||||
public function setSourceFile($file)
|
||||
{
|
||||
$this->currentReaderId = $this->getPdfReaderId($file);
|
||||
$this->objectsToCopy[$this->currentReaderId] = [];
|
||||
|
||||
$reader = $this->getPdfReader($this->currentReaderId);
|
||||
$this->setMinPdfVersion($reader->getPdfVersion());
|
||||
|
||||
return $reader->getPageCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports a page.
|
||||
*
|
||||
* @param int $pageNumber The page number.
|
||||
* @param string $box The page boundary to import. Default set to PageBoundaries::CROP_BOX.
|
||||
* @param bool $groupXObject Define the form XObject as a group XObject to support transparency (if used).
|
||||
* @return string A unique string identifying the imported page.
|
||||
* @see PageBoundaries
|
||||
* @throws PdfReaderException
|
||||
*/
|
||||
public function importPage($pageNumber, $box = PageBoundaries::CROP_BOX, $groupXObject = true)
|
||||
{
|
||||
if (null === $this->currentReaderId) {
|
||||
throw new \BadMethodCallException('No reader initiated. Call setSourceFile() first.');
|
||||
}
|
||||
|
||||
$pageId = $this->currentReaderId;
|
||||
|
||||
$pageNumber = (int)$pageNumber;
|
||||
$pageId .= '|' . $pageNumber . '|' . ($groupXObject ? '1' : '0');
|
||||
|
||||
// for backwards compatibility with FPDI 1
|
||||
$box = \ltrim($box, '/');
|
||||
if (!PageBoundaries::isValidName($box)) {
|
||||
throw new \InvalidArgumentException(
|
||||
\sprintf('Box name is invalid: "%s"', $box)
|
||||
);
|
||||
}
|
||||
|
||||
$pageId .= '|' . $box;
|
||||
|
||||
if (isset($this->importedPages[$pageId])) {
|
||||
return $pageId;
|
||||
}
|
||||
|
||||
$reader = $this->getPdfReader($this->currentReaderId);
|
||||
$page = $reader->getPage($pageNumber);
|
||||
|
||||
$bbox = $page->getBoundary($box);
|
||||
if ($bbox === false) {
|
||||
throw new PdfReaderException(
|
||||
\sprintf("Page doesn't have a boundary box (%s).", $box),
|
||||
PdfReaderException::MISSING_DATA
|
||||
);
|
||||
}
|
||||
|
||||
$dict = new PdfDictionary();
|
||||
$dict->value['Type'] = PdfName::create('XObject');
|
||||
$dict->value['Subtype'] = PdfName::create('Form');
|
||||
$dict->value['FormType'] = PdfNumeric::create(1);
|
||||
$dict->value['BBox'] = $bbox->toPdfArray();
|
||||
|
||||
if ($groupXObject) {
|
||||
$this->setMinPdfVersion('1.4');
|
||||
$dict->value['Group'] = PdfDictionary::create([
|
||||
'Type' => PdfName::create('Group'),
|
||||
'S' => PdfName::create('Transparency')
|
||||
]);
|
||||
}
|
||||
|
||||
$resources = $page->getAttribute('Resources');
|
||||
if ($resources !== null) {
|
||||
$dict->value['Resources'] = $resources;
|
||||
}
|
||||
|
||||
list($width, $height) = $page->getWidthAndHeight($box);
|
||||
|
||||
$a = 1;
|
||||
$b = 0;
|
||||
$c = 0;
|
||||
$d = 1;
|
||||
$e = -$bbox->getLlx();
|
||||
$f = -$bbox->getLly();
|
||||
|
||||
$rotation = $page->getRotation();
|
||||
|
||||
if ($rotation !== 0) {
|
||||
$rotation *= -1;
|
||||
$angle = $rotation * M_PI/180;
|
||||
$a = \cos($angle);
|
||||
$b = \sin($angle);
|
||||
$c = -$b;
|
||||
$d = $a;
|
||||
|
||||
switch ($rotation) {
|
||||
case -90:
|
||||
$e = -$bbox->getLly();
|
||||
$f = $bbox->getUrx();
|
||||
break;
|
||||
case -180:
|
||||
$e = $bbox->getUrx();
|
||||
$f = $bbox->getUry();
|
||||
break;
|
||||
case -270:
|
||||
$e = $bbox->getUry();
|
||||
$f = -$bbox->getLlx();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// we need to rotate/translate
|
||||
if ($a != 1 || $b != 0 || $c != 0 || $d != 1 || $e != 0 || $f != 0) {
|
||||
$dict->value['Matrix'] = PdfArray::create([
|
||||
PdfNumeric::create($a), PdfNumeric::create($b), PdfNumeric::create($c),
|
||||
PdfNumeric::create($d), PdfNumeric::create($e), PdfNumeric::create($f)
|
||||
]);
|
||||
}
|
||||
|
||||
// try to use the existing content stream
|
||||
$pageDict = $page->getPageDictionary();
|
||||
|
||||
$contentsObject = PdfType::resolve(PdfDictionary::get($pageDict, 'Contents'), $reader->getParser(), true);
|
||||
$contents = PdfType::resolve($contentsObject, $reader->getParser());
|
||||
|
||||
// just copy the stream reference if it is only a single stream
|
||||
if (($contentsIsStream = ($contents instanceof PdfStream))
|
||||
|| ($contents instanceof PdfArray && \count($contents->value) === 1)
|
||||
) {
|
||||
if ($contentsIsStream) {
|
||||
/**
|
||||
* @var PdfIndirectObject $contentsObject
|
||||
*/
|
||||
$stream = $contents;
|
||||
} else {
|
||||
$stream = PdfType::resolve($contents->value[0], $reader->getParser());
|
||||
}
|
||||
|
||||
$filter = PdfDictionary::get($stream->value, 'Filter');
|
||||
if (!$filter instanceof PdfNull) {
|
||||
$dict->value['Filter'] = $filter;
|
||||
}
|
||||
$length = PdfType::resolve(PdfDictionary::get($stream->value, 'Length'), $reader->getParser());
|
||||
$dict->value['Length'] = $length;
|
||||
$stream->value = $dict;
|
||||
|
||||
// otherwise extract it from the array and re-compress the whole stream
|
||||
} else {
|
||||
$streamContent = $this->compress
|
||||
? \gzcompress($page->getContentStream())
|
||||
: $page->getContentStream();
|
||||
|
||||
$dict->value['Length'] = PdfNumeric::create(\strlen($streamContent));
|
||||
if ($this->compress) {
|
||||
$dict->value['Filter'] = PdfName::create('FlateDecode');
|
||||
}
|
||||
|
||||
$stream = PdfStream::create($dict, $streamContent);
|
||||
}
|
||||
|
||||
$this->importedPages[$pageId] = [
|
||||
'objectNumber' => null,
|
||||
'readerId' => $this->currentReaderId,
|
||||
'id' => 'TPL' . $this->getNextTemplateId(),
|
||||
'width' => $width / $this->k,
|
||||
'height' => $height / $this->k,
|
||||
'stream' => $stream
|
||||
];
|
||||
|
||||
return $pageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an imported page onto the page.
|
||||
*
|
||||
* Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect
|
||||
* ratio.
|
||||
*
|
||||
* @param mixed $pageId The page id
|
||||
* @param float|int|array $x The abscissa of upper-left corner. Alternatively you could use an assoc array
|
||||
* with the keys "x", "y", "width", "height", "adjustPageSize".
|
||||
* @param float|int $y The ordinate of upper-left corner.
|
||||
* @param float|int|null $width The width.
|
||||
* @param float|int|null $height The height.
|
||||
* @param bool $adjustPageSize
|
||||
* @return array The size.
|
||||
* @see Fpdi::getTemplateSize()
|
||||
*/
|
||||
public function useImportedPage($pageId, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
|
||||
{
|
||||
if (\is_array($x)) {
|
||||
unset($x['pageId']);
|
||||
\extract($x, EXTR_IF_EXISTS);
|
||||
/** @noinspection NotOptimalIfConditionsInspection */
|
||||
if (\is_array($x)) {
|
||||
$x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($this->importedPages[$pageId])) {
|
||||
throw new \InvalidArgumentException('Imported page does not exist!');
|
||||
}
|
||||
|
||||
$importedPage = $this->importedPages[$pageId];
|
||||
|
||||
$originalSize = $this->getTemplateSize($pageId);
|
||||
$newSize = $this->getTemplateSize($pageId, $width, $height);
|
||||
if ($adjustPageSize) {
|
||||
$this->setPageFormat($newSize, $newSize['orientation']);
|
||||
}
|
||||
|
||||
$this->_out(
|
||||
// reset standard values, translate and scale
|
||||
\sprintf(
|
||||
'q 0 J 1 w 0 j 0 G 0 g %.4F 0 0 %.4F %.4F %.4F cm /%s Do Q',
|
||||
($newSize['width'] / $originalSize['width']),
|
||||
($newSize['height'] / $originalSize['height']),
|
||||
$x * $this->k,
|
||||
($this->h - $y - $newSize['height']) * $this->k,
|
||||
$importedPage['id']
|
||||
)
|
||||
);
|
||||
|
||||
return $newSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of an imported page.
|
||||
*
|
||||
* Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect
|
||||
* ratio.
|
||||
*
|
||||
* @param mixed $tpl The template id
|
||||
* @param float|int|null $width The width.
|
||||
* @param float|int|null $height The height.
|
||||
* @return array|bool An array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P)
|
||||
*/
|
||||
public function getImportedPageSize($tpl, $width = null, $height = null)
|
||||
{
|
||||
if (isset($this->importedPages[$tpl])) {
|
||||
$importedPage = $this->importedPages[$tpl];
|
||||
|
||||
if ($width === null && $height === null) {
|
||||
$width = $importedPage['width'];
|
||||
$height = $importedPage['height'];
|
||||
} elseif ($width === null) {
|
||||
$width = $height * $importedPage['width'] / $importedPage['height'];
|
||||
}
|
||||
|
||||
if ($height === null) {
|
||||
$height = $width * $importedPage['height'] / $importedPage['width'];
|
||||
}
|
||||
|
||||
if ($height <= 0. || $width <= 0.) {
|
||||
throw new \InvalidArgumentException('Width or height parameter needs to be larger than zero.');
|
||||
}
|
||||
|
||||
return [
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
0 => $width,
|
||||
1 => $height,
|
||||
'orientation' => $width > $height ? 'L' : 'P'
|
||||
];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a PdfType object to the resulting buffer.
|
||||
*
|
||||
* @param PdfType $value
|
||||
*/
|
||||
protected function writePdfType(PdfType $value)
|
||||
{
|
||||
if ($value instanceof PdfNumeric) {
|
||||
if (\is_int($value->value)) {
|
||||
$this->_put($value->value . ' ', false);
|
||||
} else {
|
||||
$this->_put(\rtrim(\rtrim(\sprintf('%.5F', $value->value), '0'), '.') . ' ', false);
|
||||
}
|
||||
|
||||
} elseif ($value instanceof PdfName) {
|
||||
$this->_put('/' . $value->value . ' ', false);
|
||||
|
||||
} elseif ($value instanceof PdfString) {
|
||||
$this->_put('(' . $value->value . ')', false);
|
||||
|
||||
} elseif ($value instanceof PdfHexString) {
|
||||
$this->_put('<' . $value->value . '>');
|
||||
|
||||
} elseif ($value instanceof PdfBoolean) {
|
||||
$this->_put($value->value ? 'true ' : 'false ', false);
|
||||
|
||||
} elseif ($value instanceof PdfArray) {
|
||||
$this->_put('[', false);
|
||||
foreach ($value->value as $entry) {
|
||||
$this->writePdfType($entry);
|
||||
}
|
||||
$this->_put(']');
|
||||
|
||||
} elseif ($value instanceof PdfDictionary) {
|
||||
$this->_put('<<', false);
|
||||
foreach ($value->value as $name => $entry) {
|
||||
$this->_put('/' . $name . ' ', false);
|
||||
$this->writePdfType($entry);
|
||||
}
|
||||
$this->_put('>>');
|
||||
|
||||
} elseif ($value instanceof PdfToken) {
|
||||
$this->_put($value->value);
|
||||
|
||||
} elseif ($value instanceof PdfNull) {
|
||||
$this->_put('null ');
|
||||
|
||||
} elseif ($value instanceof PdfStream) {
|
||||
/**
|
||||
* @var $value PdfStream
|
||||
*/
|
||||
$this->writePdfType($value->value);
|
||||
$this->_put('stream');
|
||||
$this->_put($value->getStream());
|
||||
$this->_put('endstream');
|
||||
|
||||
} elseif ($value instanceof PdfIndirectObjectReference) {
|
||||
if (!isset($this->objectMap[$this->currentReaderId])) {
|
||||
$this->objectMap[$this->currentReaderId] = [];
|
||||
}
|
||||
|
||||
if (!isset($this->objectMap[$this->currentReaderId][$value->value])) {
|
||||
$this->objectMap[$this->currentReaderId][$value->value] = ++$this->n;
|
||||
$this->objectsToCopy[$this->currentReaderId][] = $value->value;
|
||||
}
|
||||
|
||||
$this->_put($this->objectMap[$this->currentReaderId][$value->value] . ' 0 R ', false);
|
||||
|
||||
} elseif ($value instanceof PdfIndirectObject) {
|
||||
/**
|
||||
* @var $value PdfIndirectObject
|
||||
*/
|
||||
$n = $this->objectMap[$this->currentReaderId][$value->objectNumber];
|
||||
$this->_newobj($n);
|
||||
$this->writePdfType($value->value);
|
||||
$this->_put('endobj');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\CrossReference;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfDictionary;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfToken;
|
||||
|
||||
/**
|
||||
* Abstract class for cross-reference reader classes.
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\CrossReference
|
||||
*/
|
||||
abstract class AbstractReader
|
||||
{
|
||||
/**
|
||||
* @var PdfParser
|
||||
*/
|
||||
protected $parser;
|
||||
|
||||
/**
|
||||
* @var PdfDictionary
|
||||
*/
|
||||
protected $trailer;
|
||||
|
||||
/**
|
||||
* AbstractReader constructor.
|
||||
*
|
||||
* @param PdfParser $parser
|
||||
*/
|
||||
public function __construct(PdfParser $parser)
|
||||
{
|
||||
$this->parser = $parser;
|
||||
$this->readTrailer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the trailer dictionary.
|
||||
*
|
||||
* @return PdfDictionary
|
||||
*/
|
||||
public function getTrailer()
|
||||
{
|
||||
return $this->trailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the trailer dictionary.
|
||||
*
|
||||
* @throws CrossReferenceException
|
||||
*/
|
||||
protected function readTrailer()
|
||||
{
|
||||
$trailerKeyword = $this->parser->readValue();
|
||||
if ($trailerKeyword === false ||
|
||||
!($trailerKeyword instanceof PdfToken) ||
|
||||
$trailerKeyword->value !== 'trailer'
|
||||
) {
|
||||
throw new CrossReferenceException(
|
||||
\sprintf(
|
||||
'Unexpected end of cross reference. "trailer"-keyword expected, got: %s',
|
||||
$trailerKeyword instanceof PdfToken ? $trailerKeyword->value : 'nothing'
|
||||
),
|
||||
CrossReferenceException::UNEXPECTED_END
|
||||
);
|
||||
}
|
||||
|
||||
$trailer = $this->parser->readValue();
|
||||
if ($trailer === false || !($trailer instanceof PdfDictionary)) {
|
||||
throw new CrossReferenceException(
|
||||
'Unexpected end of cross reference. Trailer not found.',
|
||||
CrossReferenceException::UNEXPECTED_END
|
||||
);
|
||||
}
|
||||
|
||||
$this->trailer = $trailer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\CrossReference;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfDictionary;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfIndirectObject;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNumeric;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfStream;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfToken;
|
||||
|
||||
/**
|
||||
* Class CrossReference
|
||||
*
|
||||
* This class processes the standard cross reference of a PDF document.
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\CrossReference
|
||||
*/
|
||||
class CrossReference
|
||||
{
|
||||
/**
|
||||
* The byte length in which the "startxref" keyword should be searched.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
static public $trailerSearchLength = 5500;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $fileHeaderOffset = 0;
|
||||
|
||||
/**
|
||||
* @var PdfParser
|
||||
*/
|
||||
protected $parser;
|
||||
|
||||
/**
|
||||
* @var ReaderInterface[]
|
||||
*/
|
||||
protected $readers = [];
|
||||
|
||||
/**
|
||||
* CrossReference constructor.
|
||||
*
|
||||
* @param PdfParser $parser
|
||||
*/
|
||||
public function __construct(PdfParser $parser, $fileHeaderOffset = 0)
|
||||
{
|
||||
$this->parser = $parser;
|
||||
$this->fileHeaderOffset = $fileHeaderOffset;
|
||||
|
||||
$offset = $this->findStartXref();
|
||||
$reader = null;
|
||||
while ($offset !== false) {
|
||||
$reader = $this->readXref($offset + $this->fileHeaderOffset);
|
||||
$trailer = $reader->getTrailer();
|
||||
$this->checkForEncryption($trailer);
|
||||
$this->readers[] = $reader;
|
||||
|
||||
if (isset($trailer->value['Prev'])) {
|
||||
$offset = $trailer->value['Prev']->value;
|
||||
} else {
|
||||
$offset = false;
|
||||
}
|
||||
}
|
||||
|
||||
// fix faulty sub-section header
|
||||
if ($reader instanceof FixedReader) {
|
||||
/**
|
||||
* @var FixedReader $reader
|
||||
*/
|
||||
$reader->fixFaultySubSectionShift();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the cross reference.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->getTrailer()->value['Size']->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the trailer dictionary.
|
||||
*
|
||||
* @return PdfDictionary
|
||||
*/
|
||||
public function getTrailer()
|
||||
{
|
||||
return $this->readers[0]->getTrailer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cross reference readser instances.
|
||||
*
|
||||
* @return ReaderInterface[]
|
||||
*/
|
||||
public function getReaders()
|
||||
{
|
||||
return $this->readers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offset by an object number.
|
||||
*
|
||||
* @param int $objectNumber
|
||||
* @return integer|bool
|
||||
*/
|
||||
public function getOffsetFor($objectNumber)
|
||||
{
|
||||
foreach ($this->getReaders() as $reader) {
|
||||
$offset = $reader->getOffsetFor($objectNumber);
|
||||
if (false !== $offset) {
|
||||
return $offset;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an indirect object by its object number.
|
||||
*
|
||||
* @param int $objectNumber
|
||||
* @return PdfIndirectObject
|
||||
* @throws CrossReferenceException
|
||||
*/
|
||||
public function getIndirectObject($objectNumber)
|
||||
{
|
||||
$offset = $this->getOffsetFor($objectNumber);
|
||||
if (false === $offset) {
|
||||
throw new CrossReferenceException(
|
||||
\sprintf('Object (id:%s) not found.', $objectNumber),
|
||||
CrossReferenceException::OBJECT_NOT_FOUND
|
||||
);
|
||||
}
|
||||
|
||||
$parser = $this->parser;
|
||||
|
||||
$parser->getTokenizer()->clearStack();
|
||||
$parser->getStreamReader()->reset($offset + $this->fileHeaderOffset);
|
||||
|
||||
$object = $parser->readValue();
|
||||
if (false === $object || !($object instanceof PdfIndirectObject)) {
|
||||
throw new CrossReferenceException(
|
||||
\sprintf('Object (id:%s) not found at location (%s).', $objectNumber, $offset),
|
||||
CrossReferenceException::OBJECT_NOT_FOUND
|
||||
);
|
||||
}
|
||||
|
||||
if ($object->objectNumber !== $objectNumber) {
|
||||
throw new CrossReferenceException(
|
||||
\sprintf('Wrong object found, got %s while %s was expected.', $object->objectNumber, $objectNumber),
|
||||
CrossReferenceException::OBJECT_NOT_FOUND
|
||||
);
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the cross-reference table at a given offset.
|
||||
*
|
||||
* Internally the method will try to evaluate the best reader for this cross-reference.
|
||||
*
|
||||
* @param int $offset
|
||||
* @return ReaderInterface
|
||||
* @throws CrossReferenceException
|
||||
*/
|
||||
protected function readXref($offset)
|
||||
{
|
||||
$this->parser->getStreamReader()->reset($offset);
|
||||
$this->parser->getTokenizer()->clearStack();
|
||||
$initValue = $this->parser->readValue();
|
||||
|
||||
return $this->initReaderInstance($initValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a cross-reference reader instance.
|
||||
*
|
||||
* @param PdfToken|PdfIndirectObject $initValue
|
||||
* @return ReaderInterface|bool
|
||||
* @throws CrossReferenceException
|
||||
*/
|
||||
protected function initReaderInstance($initValue)
|
||||
{
|
||||
$position = $this->parser->getStreamReader()->getPosition()
|
||||
+ $this->parser->getStreamReader()->getOffset() + $this->fileHeaderOffset;
|
||||
|
||||
if ($initValue instanceof PdfToken && $initValue->value === 'xref') {
|
||||
try {
|
||||
return new FixedReader($this->parser);
|
||||
} catch (CrossReferenceException $e) {
|
||||
$this->parser->getStreamReader()->reset($position);
|
||||
$this->parser->getTokenizer()->clearStack();
|
||||
|
||||
return new LineReader($this->parser);
|
||||
}
|
||||
}
|
||||
|
||||
if ($initValue instanceof PdfIndirectObject) {
|
||||
// check for encryption
|
||||
$stream = PdfStream::ensure($initValue->value);
|
||||
|
||||
$type = PdfDictionary::get($stream->value, 'Type');
|
||||
if ($type->value !== 'XRef') {
|
||||
throw new CrossReferenceException(
|
||||
'The xref position points to an incorrect object type.',
|
||||
CrossReferenceException::INVALID_DATA
|
||||
);
|
||||
}
|
||||
|
||||
$this->checkForEncryption($stream->value);
|
||||
|
||||
throw new CrossReferenceException(
|
||||
'This PDF document probably uses a compression technique which is not supported by the ' .
|
||||
'free parser shipped with FPDI. (See https://www.setasign.com/fpdi-pdf-parser for more details)',
|
||||
CrossReferenceException::COMPRESSED_XREF
|
||||
);
|
||||
}
|
||||
|
||||
throw new CrossReferenceException(
|
||||
'The xref position points to an incorrect object type.',
|
||||
CrossReferenceException::INVALID_DATA
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for encryption.
|
||||
*
|
||||
* @param PdfDictionary $dictionary
|
||||
* @throws CrossReferenceException
|
||||
*/
|
||||
protected function checkForEncryption(PdfDictionary $dictionary)
|
||||
{
|
||||
if (isset($dictionary->value['Encrypt'])) {
|
||||
throw new CrossReferenceException(
|
||||
'This PDF document is encrypted and cannot be processed with FPDI.',
|
||||
CrossReferenceException::ENCRYPTED
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the start position for the first cross-reference.
|
||||
*
|
||||
* @return int The byte-offset position of the first cross-reference.
|
||||
* @throws CrossReferenceException
|
||||
*/
|
||||
protected function findStartXref()
|
||||
{
|
||||
$reader = $this->parser->getStreamReader();
|
||||
$reader->reset(-self::$trailerSearchLength, self::$trailerSearchLength);
|
||||
|
||||
$buffer = $reader->getBuffer(false);
|
||||
$pos = \strrpos($buffer, 'startxref');
|
||||
$addOffset = 9;
|
||||
if (false === $pos) {
|
||||
// Some corrupted documents uses startref, instead of startxref
|
||||
$pos = \strrpos($buffer, 'startref');
|
||||
if (false === $pos) {
|
||||
throw new CrossReferenceException(
|
||||
'Unable to find pointer to xref table',
|
||||
CrossReferenceException::NO_STARTXREF_FOUND
|
||||
);
|
||||
}
|
||||
$addOffset = 8;
|
||||
}
|
||||
|
||||
$reader->setOffset($pos + $addOffset);
|
||||
|
||||
$value = $this->parser->readValue();
|
||||
if (!($value instanceof PdfNumeric)) {
|
||||
throw new CrossReferenceException(
|
||||
'Invalid data after startxref keyword.',
|
||||
CrossReferenceException::INVALID_DATA
|
||||
);
|
||||
}
|
||||
|
||||
return $value->value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\CrossReference;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParserException;
|
||||
|
||||
/**
|
||||
* Exception used by the CrossReference and Reader classes.
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\CrossReference
|
||||
*/
|
||||
class CrossReferenceException extends PdfParserException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const INVALID_DATA = 0x0101;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const XREF_MISSING = 0x0102;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const ENTRIES_TOO_LARGE = 0x0103;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const ENTRIES_TOO_SHORT = 0x0104;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const NO_ENTRIES = 0x0105;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const NO_TRAILER_FOUND = 0x0106;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const NO_STARTXREF_FOUND = 0x0107;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const NO_XREF_FOUND = 0x0108;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const UNEXPECTED_END = 0x0109;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const OBJECT_NOT_FOUND = 0x010A;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const COMPRESSED_XREF = 0x010B;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const ENCRYPTED = 0x010C;
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\CrossReference;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
|
||||
/**
|
||||
* Class FixedReader
|
||||
*
|
||||
* This reader allows a very less overhead parsing of single entries of the cross-reference, because the main entries
|
||||
* are only read when needed and not in a single run.
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\CrossReference
|
||||
*/
|
||||
class FixedReader extends AbstractReader implements ReaderInterface
|
||||
{
|
||||
/**
|
||||
* @var StreamReader
|
||||
*/
|
||||
protected $reader;
|
||||
|
||||
/**
|
||||
* Data of subsections.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $subSections;
|
||||
|
||||
/**
|
||||
* FixedReader constructor.
|
||||
*
|
||||
* @param PdfParser $parser
|
||||
*/
|
||||
public function __construct(PdfParser $parser)
|
||||
{
|
||||
$this->reader = $parser->getStreamReader();
|
||||
$this->read();
|
||||
parent::__construct($parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all subsection data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSubSections()
|
||||
{
|
||||
return $this->subSections;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getOffsetFor($objectNumber)
|
||||
{
|
||||
foreach ($this->subSections as $offset => list($startObject, $objectCount)) {
|
||||
if ($objectNumber >= $startObject && $objectNumber < ($startObject + $objectCount)) {
|
||||
$position = $offset + 20 * ($objectNumber - $startObject);
|
||||
$this->reader->ensure($position, 20);
|
||||
$line = $this->reader->readBytes(20);
|
||||
if ($line[17] === 'f') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (int) \substr($line, 0, 10);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the cross-reference.
|
||||
*
|
||||
* This reader will only read the subsections in this method. The offsets were resolved individually by this
|
||||
* information.
|
||||
*
|
||||
* @throws CrossReferenceException
|
||||
*/
|
||||
protected function read()
|
||||
{
|
||||
$subSections = [];
|
||||
|
||||
$startObject = $entryCount = $lastLineStart = null;
|
||||
$validityChecked = false;
|
||||
while (($line = $this->reader->readLine(20)) !== false) {
|
||||
if (\strpos($line, 'trailer') !== false) {
|
||||
$this->reader->reset($lastLineStart);
|
||||
break;
|
||||
}
|
||||
|
||||
// jump over if line content doesn't match the expected string
|
||||
if (2 !== \sscanf($line, '%d %d', $startObject, $entryCount)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$oldPosition = $this->reader->getPosition();
|
||||
$position = $oldPosition + $this->reader->getOffset();
|
||||
|
||||
if (!$validityChecked && $entryCount > 0) {
|
||||
$nextLine = $this->reader->readBytes(21);
|
||||
/* Check the next line for maximum of 20 bytes and not longer
|
||||
* By catching 21 bytes and trimming the length should be still 21.
|
||||
*/
|
||||
if (\strlen(\trim($nextLine)) !== 21) {
|
||||
throw new CrossReferenceException(
|
||||
'Cross-reference entries are larger than 20 bytes.',
|
||||
CrossReferenceException::ENTRIES_TOO_LARGE
|
||||
);
|
||||
}
|
||||
|
||||
/* Check for less than 20 bytes: cut the line to 20 bytes and trim; have to result in exactly 18 bytes.
|
||||
* If it would have less bytes the substring would get the first bytes of the next line which would
|
||||
* evaluate to a 20 bytes long string after trimming.
|
||||
*/
|
||||
if (\strlen(\trim(\substr($nextLine, 0, 20))) !== 18) {
|
||||
throw new CrossReferenceException(
|
||||
'Cross-reference entries are less than 20 bytes.',
|
||||
CrossReferenceException::ENTRIES_TOO_SHORT
|
||||
);
|
||||
}
|
||||
|
||||
$validityChecked = true;
|
||||
}
|
||||
|
||||
$subSections[$position] = [$startObject, $entryCount];
|
||||
|
||||
$lastLineStart = $position + $entryCount * 20;
|
||||
$this->reader->reset($lastLineStart);
|
||||
}
|
||||
|
||||
if (\count($subSections) === 0) {
|
||||
throw new CrossReferenceException(
|
||||
'No entries found in cross-reference.',
|
||||
CrossReferenceException::NO_ENTRIES
|
||||
);
|
||||
}
|
||||
|
||||
$this->subSections = $subSections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes an invalid object number shift.
|
||||
*
|
||||
* This method can be used to repair documents with an invalid subsection header:
|
||||
*
|
||||
* <code>
|
||||
* xref
|
||||
* 1 7
|
||||
* 0000000000 65535 f
|
||||
* 0000000009 00000 n
|
||||
* 0000412075 00000 n
|
||||
* 0000412172 00000 n
|
||||
* 0000412359 00000 n
|
||||
* 0000412417 00000 n
|
||||
* 0000412468 00000 n
|
||||
* </code>
|
||||
*
|
||||
* It shall only be called on the first table.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function fixFaultySubSectionShift()
|
||||
{
|
||||
$subSections = $this->getSubSections();
|
||||
if (\count($subSections) > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$subSection = \current($subSections);
|
||||
if ($subSection[0] != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->getOffsetFor(1) === false) {
|
||||
foreach ($subSections as $offset => list($startObject, $objectCount)) {
|
||||
$this->subSections[$offset] = [$startObject - 1, $objectCount];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\CrossReference;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
|
||||
/**
|
||||
* Class LineReader
|
||||
*
|
||||
* This reader class read all cross-reference entries in a single run.
|
||||
* It supports reading cross-references with e.g. invalid data (e.g. entries with a length < or > 20 bytes).
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\CrossReference
|
||||
*/
|
||||
class LineReader extends AbstractReader implements ReaderInterface
|
||||
{
|
||||
/**
|
||||
* The object offsets.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $offsets;
|
||||
|
||||
/**
|
||||
* LineReader constructor.
|
||||
*
|
||||
* @param PdfParser $parser
|
||||
*/
|
||||
public function __construct(PdfParser $parser)
|
||||
{
|
||||
$this->read($this->extract($parser->getStreamReader()));
|
||||
parent::__construct($parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getOffsetFor($objectNumber)
|
||||
{
|
||||
if (isset($this->offsets[$objectNumber])) {
|
||||
return $this->offsets[$objectNumber][0];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all found offsets.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOffsets()
|
||||
{
|
||||
return $this->offsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the cross reference data from the stream reader.
|
||||
*
|
||||
* @param StreamReader $reader
|
||||
* @return string
|
||||
* @throws CrossReferenceException
|
||||
*/
|
||||
protected function extract(StreamReader $reader)
|
||||
{
|
||||
$cycles = -1;
|
||||
$bytesPerCycle = 100;
|
||||
|
||||
$reader->reset(null, $bytesPerCycle);
|
||||
|
||||
while (
|
||||
($trailerPos = \strpos($reader->getBuffer(false), 'trailer', \max($bytesPerCycle * $cycles++, 0))) === false
|
||||
) {
|
||||
if (false === $reader->increaseLength($bytesPerCycle)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (false === $trailerPos) {
|
||||
throw new CrossReferenceException(
|
||||
'Unexpected end of cross reference. trailer-keyword not found.',
|
||||
CrossReferenceException::NO_TRAILER_FOUND
|
||||
);
|
||||
}
|
||||
|
||||
$xrefContent = \substr($reader->getBuffer(false), 0, $trailerPos);
|
||||
$reader->reset($reader->getPosition() + $trailerPos);
|
||||
|
||||
return $xrefContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the cross-reference entries.
|
||||
*
|
||||
* @param string $xrefContent
|
||||
* @throws CrossReferenceException
|
||||
*/
|
||||
protected function read($xrefContent)
|
||||
{
|
||||
// get eol markers in the first 100 bytes
|
||||
\preg_match_all("/(\r\n|\n|\r)/", \substr($xrefContent, 0, 100), $m);
|
||||
|
||||
if (\count($m[0]) === 0) {
|
||||
throw new CrossReferenceException(
|
||||
'No data found in cross-reference.',
|
||||
CrossReferenceException::INVALID_DATA
|
||||
);
|
||||
}
|
||||
|
||||
// count(array_count_values()) is faster then count(array_unique())
|
||||
// @see https://github.com/symfony/symfony/pull/23731
|
||||
// can be reverted for php7.2
|
||||
$differentLineEndings = \count(\array_count_values($m[0]));
|
||||
if ($differentLineEndings > 1) {
|
||||
$lines = \preg_split("/(\r\n|\n|\r)/", $xrefContent, -1, PREG_SPLIT_NO_EMPTY);
|
||||
} else {
|
||||
$lines = \explode($m[0][0], $xrefContent);
|
||||
}
|
||||
|
||||
unset($differentLineEndings, $m);
|
||||
$linesCount = \count($lines);
|
||||
$start = null;
|
||||
$entryCount = 0;
|
||||
|
||||
$offsets = [];
|
||||
|
||||
/** @noinspection ForeachInvariantsInspection */
|
||||
for ($i = 0; $i < $linesCount; $i++) {
|
||||
$line = \trim($lines[$i]);
|
||||
if ($line) {
|
||||
$pieces = \explode(' ', $line);
|
||||
|
||||
$c = \count($pieces);
|
||||
switch ($c) {
|
||||
case 2:
|
||||
$start = (int) $pieces[0];
|
||||
$entryCount += (int) $pieces[1];
|
||||
break;
|
||||
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case 3:
|
||||
switch ($pieces[2]) {
|
||||
case 'n':
|
||||
$offsets[$start] = [(int) $pieces[0], (int) $pieces[1]];
|
||||
$start++;
|
||||
break 2;
|
||||
case 'f':
|
||||
$start++;
|
||||
break 2;
|
||||
}
|
||||
// fall through if pieces doesn't match
|
||||
|
||||
default:
|
||||
throw new CrossReferenceException(
|
||||
\sprintf('Unexpected data in xref table (%s)', \implode(' ', $pieces)),
|
||||
CrossReferenceException::INVALID_DATA
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->offsets = $offsets;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\CrossReference;
|
||||
|
||||
use setasign\Fpdi\PdfParser\Type\PdfDictionary;
|
||||
|
||||
/**
|
||||
* ReaderInterface for cross-reference readers.
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\CrossReference
|
||||
*/
|
||||
interface ReaderInterface
|
||||
{
|
||||
/**
|
||||
* Get an offset by an object number.
|
||||
*
|
||||
* @param int $objectNumber
|
||||
* @return int|bool False if the offset was not found.
|
||||
*/
|
||||
public function getOffsetFor($objectNumber);
|
||||
|
||||
/**
|
||||
* Get the trailer related to this cross reference.
|
||||
*
|
||||
* @return PdfDictionary
|
||||
*/
|
||||
public function getTrailer();
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Filter;
|
||||
|
||||
/**
|
||||
* Class for handling ASCII base-85 encoded data
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Filter
|
||||
*/
|
||||
class Ascii85 implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Decode ASCII85 encoded string.
|
||||
*
|
||||
* @param string $data The input string
|
||||
* @return string
|
||||
* @throws Ascii85Exception
|
||||
*/
|
||||
public function decode($data)
|
||||
{
|
||||
$out = '';
|
||||
$state = 0;
|
||||
$chn = null;
|
||||
|
||||
$l = \strlen($data);
|
||||
|
||||
/** @noinspection ForeachInvariantsInspection */
|
||||
for ($k = 0; $k < $l; ++$k) {
|
||||
$ch = \ord($data[$k]) & 0xff;
|
||||
|
||||
//Start <~
|
||||
if ($k === 0 && $ch === 60 && isset($data[$k + 1]) && (\ord($data[$k + 1]) & 0xFF) === 126) {
|
||||
$k++;
|
||||
continue;
|
||||
}
|
||||
//End ~>
|
||||
if ($ch === 126 && isset($data[$k + 1]) && (\ord($data[$k + 1]) & 0xFF) === 62) {
|
||||
break;
|
||||
}
|
||||
if (\preg_match('/^\s$/', \chr($ch))) {
|
||||
continue;
|
||||
}
|
||||
if ($ch === 122 /* z */ && $state === 0) {
|
||||
$out .= \chr(0) . \chr(0) . \chr(0) . \chr(0);
|
||||
continue;
|
||||
}
|
||||
if ($ch < 33 /* ! */ || $ch > 117 /* u */) {
|
||||
throw new Ascii85Exception(
|
||||
'Illegal character found while ASCII85 decode.',
|
||||
Ascii85Exception::ILLEGAL_CHAR_FOUND
|
||||
);
|
||||
}
|
||||
|
||||
$chn[$state] = $ch - 33;/* ! */
|
||||
$state++;
|
||||
|
||||
if ($state === 5) {
|
||||
$state = 0;
|
||||
$r = 0;
|
||||
for ($j = 0; $j < 5; ++$j) {
|
||||
/** @noinspection UnnecessaryCastingInspection */
|
||||
$r = (int)($r * 85 + $chn[$j]);
|
||||
}
|
||||
|
||||
$out .= \chr($r >> 24)
|
||||
. \chr($r >> 16)
|
||||
. \chr($r >> 8)
|
||||
. \chr($r);
|
||||
}
|
||||
}
|
||||
|
||||
if ($state === 1) {
|
||||
throw new Ascii85Exception(
|
||||
'Illegal length while ASCII85 decode.',
|
||||
Ascii85Exception::ILLEGAL_LENGTH
|
||||
);
|
||||
}
|
||||
|
||||
if ($state === 2) {
|
||||
$r = $chn[0] * 85 * 85 * 85 * 85 + ($chn[1] + 1) * 85 * 85 * 85;
|
||||
$out .= \chr($r >> 24);
|
||||
|
||||
} elseif ($state === 3) {
|
||||
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + ($chn[2] + 1) * 85 * 85;
|
||||
$out .= \chr($r >> 24);
|
||||
$out .= \chr($r >> 16);
|
||||
|
||||
} elseif ($state === 4) {
|
||||
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + $chn[2] * 85 * 85 + ($chn[3] + 1) * 85;
|
||||
$out .= \chr($r >> 24);
|
||||
$out .= \chr($r >> 16);
|
||||
$out .= \chr($r >> 8);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Filter;
|
||||
|
||||
/**
|
||||
* Exception for Ascii85 filter class
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Filter
|
||||
*/
|
||||
class Ascii85Exception extends FilterException
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
const ILLEGAL_CHAR_FOUND = 0x0301;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
const ILLEGAL_LENGTH = 0x0302;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Filter;
|
||||
|
||||
/**
|
||||
* Class for handling ASCII hexadecimal encoded data
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Filter
|
||||
*/
|
||||
class AsciiHex implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Converts an ASCII hexadecimal encoded string into its binary representation.
|
||||
*
|
||||
* @param string $data The input string
|
||||
* @return string
|
||||
*/
|
||||
public function decode($data)
|
||||
{
|
||||
$data = \preg_replace('/[^0-9A-Fa-f]/', '', \rtrim($data, '>'));
|
||||
if ((\strlen($data) % 2) === 1) {
|
||||
$data .= '0';
|
||||
}
|
||||
|
||||
return \pack('H*', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string into ASCII hexadecimal representation.
|
||||
*
|
||||
* @param string $data The input string
|
||||
* @param boolean $leaveEOD
|
||||
* @return string
|
||||
*/
|
||||
public function encode($data, $leaveEOD = false)
|
||||
{
|
||||
$t = \unpack('H*', $data);
|
||||
return \current($t)
|
||||
. ($leaveEOD ? '' : '>');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Filter;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParserException;
|
||||
|
||||
/**
|
||||
* Exception for filters
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Filter
|
||||
*/
|
||||
class FilterException extends PdfParserException
|
||||
{
|
||||
const UNSUPPORTED_FILTER = 0x0201;
|
||||
|
||||
const NOT_IMPLEMENTED = 0x0202;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Filter;
|
||||
|
||||
/**
|
||||
* Interface for filters
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Filter
|
||||
*/
|
||||
interface FilterInterface
|
||||
{
|
||||
/**
|
||||
* Decode a string.
|
||||
*
|
||||
* @param string $data The input string
|
||||
* @return string
|
||||
*/
|
||||
public function decode($data);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Filter;
|
||||
|
||||
/**
|
||||
* Class for handling zlib/deflate encoded data
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Filter
|
||||
*/
|
||||
class Flate implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Checks whether the zlib extension is loaded.
|
||||
*
|
||||
* Used for testing purpose.
|
||||
*
|
||||
* @return boolean
|
||||
* @internal
|
||||
*/
|
||||
protected function extensionLoaded()
|
||||
{
|
||||
return \extension_loaded('zlib');
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes a flate compressed string.
|
||||
*
|
||||
* @param string $data The input string
|
||||
* @return string
|
||||
* @throws FlateException
|
||||
*/
|
||||
public function decode($data)
|
||||
{
|
||||
if ($this->extensionLoaded()) {
|
||||
$oData = $data;
|
||||
$data = @((\strlen($data) > 0) ? \gzuncompress($data) : '');
|
||||
if (false === $data) {
|
||||
// Try this fallback
|
||||
$tries = 1;
|
||||
while ($tries < 10 && ($data === false || \strlen($data) < (\strlen($oData) - $tries - 1))) {
|
||||
$data = @(\gzinflate(\substr($oData, $tries)));
|
||||
$tries++;
|
||||
}
|
||||
|
||||
if (false === $data) {
|
||||
throw new FlateException(
|
||||
'Error while decompressing stream.',
|
||||
FlateException::DECOMPRESS_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new FlateException(
|
||||
'To handle FlateDecode filter, enable zlib support in PHP.',
|
||||
FlateException::NO_ZLIB
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Filter;
|
||||
|
||||
/**
|
||||
* Exception for flate filter class
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Filter
|
||||
*/
|
||||
class FlateException extends FilterException
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
const NO_ZLIB = 0x0401;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
const DECOMPRESS_ERROR = 0x0402;
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Filter;
|
||||
|
||||
/**
|
||||
* Class for handling LZW encoded data
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Filter
|
||||
*/
|
||||
class Lzw implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* @var null|string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $sTable = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $dataLength = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $tIdx;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $bitsToGet = 9;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $bytePointer;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $nextData = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $nextBits = 0;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $andTable = [511, 1023, 2047, 4095];
|
||||
|
||||
/**
|
||||
* Method to decode LZW compressed data.
|
||||
*
|
||||
* @param string $data The compressed data
|
||||
* @return string The uncompressed data
|
||||
* @throws LzwException
|
||||
*/
|
||||
public function decode($data)
|
||||
{
|
||||
if ($data[0] == 0x00 && $data[1] == 0x01) {
|
||||
throw new LzwException(
|
||||
'LZW flavour not supported.',
|
||||
LzwException::LZW_FLAVOUR_NOT_SUPPORTED
|
||||
);
|
||||
}
|
||||
|
||||
$this->initsTable();
|
||||
|
||||
$this->data = $data;
|
||||
$this->dataLength = \strlen($data);
|
||||
|
||||
// Initialize pointers
|
||||
$this->bytePointer = 0;
|
||||
|
||||
$this->nextData = 0;
|
||||
$this->nextBits = 0;
|
||||
|
||||
$oldCode = 0;
|
||||
|
||||
$uncompData = '';
|
||||
|
||||
while (($code = $this->getNextCode()) != 257) {
|
||||
if ($code == 256) {
|
||||
$this->initsTable();
|
||||
$code = $this->getNextCode();
|
||||
|
||||
if ($code == 257) {
|
||||
break;
|
||||
}
|
||||
|
||||
$uncompData .= $this->sTable[$code];
|
||||
$oldCode = $code;
|
||||
|
||||
} else {
|
||||
if ($code < $this->tIdx) {
|
||||
$string = $this->sTable[$code];
|
||||
$uncompData .= $string;
|
||||
|
||||
$this->addStringToTable($this->sTable[$oldCode], $string[0]);
|
||||
$oldCode = $code;
|
||||
} else {
|
||||
$string = $this->sTable[$oldCode];
|
||||
$string .= $string[0];
|
||||
$uncompData .= $string;
|
||||
|
||||
$this->addStringToTable($string);
|
||||
$oldCode = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $uncompData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the string table.
|
||||
*/
|
||||
protected function initsTable()
|
||||
{
|
||||
$this->sTable = [];
|
||||
|
||||
for ($i = 0; $i < 256; $i++) {
|
||||
$this->sTable[$i] = \chr($i);
|
||||
}
|
||||
|
||||
$this->tIdx = 258;
|
||||
$this->bitsToGet = 9;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new string to the string table.
|
||||
*
|
||||
* @param string $oldString
|
||||
* @param string $newString
|
||||
*/
|
||||
protected function addStringToTable($oldString, $newString = '')
|
||||
{
|
||||
$string = $oldString . $newString;
|
||||
|
||||
// Add this new String to the table
|
||||
$this->sTable[$this->tIdx++] = $string;
|
||||
|
||||
if ($this->tIdx == 511) {
|
||||
$this->bitsToGet = 10;
|
||||
} elseif ($this->tIdx == 1023) {
|
||||
$this->bitsToGet = 11;
|
||||
} elseif ($this->tIdx == 2047) {
|
||||
$this->bitsToGet = 12;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next 9, 10, 11 or 12 bits.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
protected function getNextCode()
|
||||
{
|
||||
if ($this->bytePointer == $this->dataLength) {
|
||||
return 257;
|
||||
}
|
||||
|
||||
$this->nextData = ($this->nextData << 8) | (\ord($this->data[$this->bytePointer++]) & 0xff);
|
||||
$this->nextBits += 8;
|
||||
|
||||
if ($this->nextBits < $this->bitsToGet) {
|
||||
$this->nextData = ($this->nextData << 8) | (\ord($this->data[$this->bytePointer++]) & 0xff);
|
||||
$this->nextBits += 8;
|
||||
}
|
||||
|
||||
$code = ($this->nextData >> ($this->nextBits - $this->bitsToGet)) & $this->andTable[$this->bitsToGet - 9];
|
||||
$this->nextBits -= $this->bitsToGet;
|
||||
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Filter;
|
||||
|
||||
/**
|
||||
* Exception for LZW filter class
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Filter
|
||||
*/
|
||||
class LzwException extends FilterException
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
const LZW_FLAVOUR_NOT_SUPPORTED = 0x0501;
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser;
|
||||
|
||||
use setasign\Fpdi\PdfParser\CrossReference\CrossReference;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfArray;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfBoolean;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfDictionary;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfHexString;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfIndirectObject;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfIndirectObjectReference;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfName;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNull;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNumeric;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfString;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfToken;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfType;
|
||||
|
||||
/**
|
||||
* A PDF parser class
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser
|
||||
*/
|
||||
class PdfParser
|
||||
{
|
||||
/**
|
||||
* @var StreamReader
|
||||
*/
|
||||
protected $streamReader;
|
||||
|
||||
/**
|
||||
* @var Tokenizer
|
||||
*/
|
||||
protected $tokenizer;
|
||||
|
||||
/**
|
||||
* The file header.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $fileHeader;
|
||||
|
||||
/**
|
||||
* The offset to the file header.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $fileHeaderOffset;
|
||||
|
||||
/**
|
||||
* @var CrossReference
|
||||
*/
|
||||
protected $xref;
|
||||
|
||||
/**
|
||||
* All read objects.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $objects = [];
|
||||
|
||||
/**
|
||||
* PdfParser constructor.
|
||||
*
|
||||
* @param StreamReader $streamReader
|
||||
*/
|
||||
public function __construct(StreamReader $streamReader)
|
||||
{
|
||||
$this->streamReader = $streamReader;
|
||||
$this->tokenizer = new Tokenizer($streamReader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes cycled references.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function cleanUp()
|
||||
{
|
||||
$this->xref = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stream reader instance.
|
||||
*
|
||||
* @return StreamReader
|
||||
*/
|
||||
public function getStreamReader()
|
||||
{
|
||||
return $this->streamReader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tokenizer instance.
|
||||
*
|
||||
* @return Tokenizer
|
||||
*/
|
||||
public function getTokenizer()
|
||||
{
|
||||
return $this->tokenizer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the file header.
|
||||
*
|
||||
* @throws PdfParserException
|
||||
*/
|
||||
protected function resolveFileHeader()
|
||||
{
|
||||
if ($this->fileHeader) {
|
||||
return $this->fileHeaderOffset;
|
||||
}
|
||||
|
||||
$this->streamReader->reset(0);
|
||||
$offset = false;
|
||||
$maxIterations = 1000;
|
||||
while (true) {
|
||||
$buffer = $this->streamReader->getBuffer(false);
|
||||
$offset = \strpos($buffer, '%PDF-');
|
||||
if (false === $offset) {
|
||||
if (!$this->streamReader->increaseLength(100) || (--$maxIterations === 0)) {
|
||||
throw new PdfParserException(
|
||||
'Unable to find PDF file header.',
|
||||
PdfParserException::FILE_HEADER_NOT_FOUND
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$this->fileHeaderOffset = $offset;
|
||||
$this->streamReader->setOffset($offset);
|
||||
|
||||
$this->fileHeader = \trim($this->streamReader->readLine());
|
||||
return $this->fileHeaderOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cross reference instance.
|
||||
*
|
||||
* @return CrossReference
|
||||
*/
|
||||
public function getCrossReference()
|
||||
{
|
||||
if (null === $this->xref) {
|
||||
$this->xref = new CrossReference($this, $this->resolveFileHeader());
|
||||
}
|
||||
|
||||
return $this->xref;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PDF version.
|
||||
*
|
||||
* @return int[] An array of major and minor version.
|
||||
* @throws PdfParserException
|
||||
*/
|
||||
public function getPdfVersion()
|
||||
{
|
||||
$this->resolveFileHeader();
|
||||
|
||||
if (\preg_match('/%PDF-(\d)\.(\d)/', $this->fileHeader, $result) === 0) {
|
||||
throw new PdfParserException(
|
||||
'Unable to extract PDF version from file header.',
|
||||
PdfParserException::PDF_VERSION_NOT_FOUND
|
||||
);
|
||||
}
|
||||
list(, $major, $minor) = $result;
|
||||
|
||||
$catalog = $this->getCatalog();
|
||||
if (isset($catalog->value['Version'])) {
|
||||
$versionParts = \explode('.', PdfName::unescape(PdfType::resolve($catalog->value['Version'], $this)->value));
|
||||
if (count($versionParts) === 2) {
|
||||
list($major, $minor) = $versionParts;
|
||||
}
|
||||
}
|
||||
|
||||
return [(int) $major, (int) $minor];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the catalog dictionary.
|
||||
*
|
||||
* @return PdfDictionary
|
||||
*/
|
||||
public function getCatalog()
|
||||
{
|
||||
$xref = $this->getCrossReference();
|
||||
$trailer = $xref->getTrailer();
|
||||
|
||||
$catalog = PdfType::resolve(PdfDictionary::get($trailer, 'Root'), $this);
|
||||
|
||||
return PdfDictionary::ensure($catalog);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an indirect object by its object number.
|
||||
*
|
||||
* @param int $objectNumber
|
||||
* @param bool $cache
|
||||
* @return PdfIndirectObject
|
||||
*/
|
||||
public function getIndirectObject($objectNumber, $cache = false)
|
||||
{
|
||||
$objectNumber = (int) $objectNumber;
|
||||
if (isset($this->objects[$objectNumber])) {
|
||||
return $this->objects[$objectNumber];
|
||||
}
|
||||
|
||||
$xref = $this->getCrossReference();
|
||||
$object = $xref->getIndirectObject($objectNumber);
|
||||
|
||||
if ($cache) {
|
||||
$this->objects[$objectNumber] = $object;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a PDF value.
|
||||
*
|
||||
* @param null|bool|string $token
|
||||
* @return bool|PdfArray|PdfBoolean|PdfHexString|PdfName|PdfNull|PdfNumeric|PdfString|PdfToken|PdfIndirectObjectReference
|
||||
*/
|
||||
public function readValue($token = null)
|
||||
{
|
||||
if (null === $token) {
|
||||
$token = $this->tokenizer->getNextToken();
|
||||
}
|
||||
|
||||
if (false === $token) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch ($token) {
|
||||
case '(':
|
||||
return PdfString::parse($this->streamReader);
|
||||
|
||||
case '<':
|
||||
if ($this->streamReader->getByte() === '<') {
|
||||
$this->streamReader->addOffset(1);
|
||||
return PdfDictionary::parse($this->tokenizer, $this->streamReader, $this);
|
||||
}
|
||||
|
||||
return PdfHexString::parse($this->streamReader);
|
||||
|
||||
case '/':
|
||||
return PdfName::parse($this->tokenizer, $this->streamReader);
|
||||
|
||||
case '[':
|
||||
return PdfArray::parse($this->tokenizer, $this);
|
||||
|
||||
default:
|
||||
if (\is_numeric($token)) {
|
||||
if (($token2 = $this->tokenizer->getNextToken()) !== false) {
|
||||
if (\is_numeric($token2)) {
|
||||
if (($token3 = $this->tokenizer->getNextToken()) !== false) {
|
||||
switch ($token3) {
|
||||
case 'obj':
|
||||
return PdfIndirectObject::parse(
|
||||
$token,
|
||||
$token2,
|
||||
$this,
|
||||
$this->tokenizer,
|
||||
$this->streamReader
|
||||
);
|
||||
case 'R':
|
||||
return PdfIndirectObjectReference::create($token, $token2);
|
||||
}
|
||||
|
||||
$this->tokenizer->pushStack($token3);
|
||||
}
|
||||
}
|
||||
|
||||
$this->tokenizer->pushStack($token2);
|
||||
}
|
||||
|
||||
return PdfNumeric::create($token);
|
||||
}
|
||||
|
||||
if ('true' === $token || 'false' === $token) {
|
||||
return PdfBoolean::create('true' === $token);
|
||||
}
|
||||
|
||||
if ('null' === $token) {
|
||||
return new PdfNull();
|
||||
}
|
||||
|
||||
$v = new PdfToken();
|
||||
$v->value = $token;
|
||||
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser;
|
||||
|
||||
use setasign\Fpdi\FpdiException;
|
||||
|
||||
/**
|
||||
* Exception for the pdf parser class
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser
|
||||
*/
|
||||
class PdfParserException extends FpdiException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const NOT_IMPLEMENTED = 0x0001;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const IMPLEMENTED_IN_FPDI_PDF_PARSER = 0x0002;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const INVALID_DATA_TYPE = 0x0003;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const FILE_HEADER_NOT_FOUND = 0x0004;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const PDF_VERSION_NOT_FOUND = 0x0005;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const INVALID_DATA_SIZE = 0x0006;
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser;
|
||||
|
||||
/**
|
||||
* A stream reader class
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser
|
||||
*/
|
||||
class StreamReader
|
||||
{
|
||||
/**
|
||||
* Creates a stream reader instance by a string value.
|
||||
*
|
||||
* @param string $content
|
||||
* @param int $maxMemory
|
||||
* @return StreamReader
|
||||
*/
|
||||
public static function createByString($content, $maxMemory = 2097152)
|
||||
{
|
||||
$h = \fopen('php://temp/maxmemory:' . ((int) $maxMemory), 'r+b');
|
||||
\fwrite($h, $content);
|
||||
\rewind($h);
|
||||
|
||||
return new self($h, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a stream reader instance by a filename.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return StreamReader
|
||||
*/
|
||||
public static function createByFile($filename)
|
||||
{
|
||||
$h = \fopen($filename, 'rb');
|
||||
return new self($h, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines whether the stream should be closed when the stream reader instance is deconstructed or not.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $closeStream;
|
||||
|
||||
/**
|
||||
* The stream resource.
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
protected $stream;
|
||||
|
||||
/**
|
||||
* The byte-offset position in the stream.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $position;
|
||||
|
||||
/**
|
||||
* The byte-offset position in the buffer.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offset;
|
||||
|
||||
/**
|
||||
* The buffer length.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $bufferLength;
|
||||
|
||||
/**
|
||||
* The total length of the stream.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $totalLength;
|
||||
|
||||
/**
|
||||
* The buffer.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $buffer;
|
||||
|
||||
/**
|
||||
* StreamReader constructor.
|
||||
*
|
||||
* @param resource $stream
|
||||
* @param bool $closeStream Defines whether to close the stream resource if the instance is destructed or not.
|
||||
*/
|
||||
public function __construct($stream, $closeStream = false)
|
||||
{
|
||||
if (!\is_resource($stream)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'No stream given.'
|
||||
);
|
||||
}
|
||||
|
||||
$metaData = \stream_get_meta_data($stream);
|
||||
if (!$metaData['seekable']) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Given stream is not seekable!'
|
||||
);
|
||||
}
|
||||
|
||||
$this->stream = $stream;
|
||||
$this->closeStream = $closeStream;
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* The destructor.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if ($this->closeStream) {
|
||||
\fclose($this->stream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the byte length of the buffer.
|
||||
*
|
||||
* @param bool $atOffset
|
||||
* @return int
|
||||
*/
|
||||
public function getBufferLength($atOffset = false)
|
||||
{
|
||||
if ($atOffset === false) {
|
||||
return $this->bufferLength;
|
||||
}
|
||||
|
||||
return $this->bufferLength - $this->offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current position in the stream.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPosition()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current buffer.
|
||||
*
|
||||
* @param bool $atOffset
|
||||
* @return string
|
||||
*/
|
||||
public function getBuffer($atOffset = true)
|
||||
{
|
||||
if (false === $atOffset) {
|
||||
return $this->buffer;
|
||||
}
|
||||
|
||||
$string = \substr($this->buffer, $this->offset);
|
||||
|
||||
return (string) $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a byte at a specific position in the buffer.
|
||||
*
|
||||
* If the position is invalid the method will return false.
|
||||
*
|
||||
* If the $position parameter is set to null the value of $this->offset will be used.
|
||||
*
|
||||
* @param int|null $position
|
||||
* @return string|bool
|
||||
*/
|
||||
public function getByte($position = null)
|
||||
{
|
||||
$position = (int) (null !== $position ? $position : $this->offset);
|
||||
if ($position >= $this->bufferLength &&
|
||||
(!$this->increaseLength() || $position >= $this->bufferLength)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->buffer[$position];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a byte at a specific position, and set the offset to the next byte position.
|
||||
*
|
||||
* If the position is invalid the method will return false.
|
||||
*
|
||||
* If the $position parameter is set to null the value of $this->offset will be used.
|
||||
*
|
||||
* @param int|null $position
|
||||
* @return string|bool
|
||||
*/
|
||||
public function readByte($position = null)
|
||||
{
|
||||
if (null !== $position) {
|
||||
$position = (int) $position;
|
||||
// check if needed bytes are available in the current buffer
|
||||
if (!($position >= $this->position && $position < $this->position + $this->bufferLength)) {
|
||||
$this->reset($position);
|
||||
$offset = $this->offset;
|
||||
} else {
|
||||
$offset = $position - $this->position;
|
||||
}
|
||||
} else {
|
||||
$offset = $this->offset;
|
||||
}
|
||||
|
||||
if ($offset >= $this->bufferLength &&
|
||||
((!$this->increaseLength()) || $offset >= $this->bufferLength)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->offset = $offset + 1;
|
||||
return $this->buffer[$offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* Read bytes from the current or a specific offset position and set the internal pointer to the next byte.
|
||||
*
|
||||
* If the position is invalid the method will return false.
|
||||
*
|
||||
* If the $position parameter is set to null the value of $this->offset will be used.
|
||||
*
|
||||
* @param int $length
|
||||
* @param int|null $position
|
||||
* @return string
|
||||
*/
|
||||
public function readBytes($length, $position = null)
|
||||
{
|
||||
$length = (int) $length;
|
||||
if (null !== $position) {
|
||||
// check if needed bytes are available in the current buffer
|
||||
if (!($position >= $this->position && $position < $this->position + $this->bufferLength)) {
|
||||
$this->reset($position, $length);
|
||||
$offset = $this->offset;
|
||||
} else {
|
||||
$offset = $position - $this->position;
|
||||
}
|
||||
} else {
|
||||
$offset = $this->offset;
|
||||
}
|
||||
|
||||
if (($offset + $length) > $this->bufferLength &&
|
||||
((!$this->increaseLength($length)) || ($offset + $length) > $this->bufferLength)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$bytes = \substr($this->buffer, $offset, $length);
|
||||
$this->offset = $offset + $length;
|
||||
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a line from the current position.
|
||||
*
|
||||
* @param int $length
|
||||
* @return string|bool
|
||||
*/
|
||||
public function readLine($length = 1024)
|
||||
{
|
||||
if (false === $this->ensureContent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$line = '';
|
||||
while ($this->ensureContent()) {
|
||||
$char = $this->readByte();
|
||||
|
||||
if ($char === "\n") {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($char === "\r") {
|
||||
if ($this->getByte() === "\n") {
|
||||
$this->addOffset(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$line .= $char;
|
||||
|
||||
if (\strlen($line) >= $length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the offset position in the current buffer.
|
||||
*
|
||||
* @param int $offset
|
||||
*/
|
||||
public function setOffset($offset)
|
||||
{
|
||||
if ($offset > $this->bufferLength || $offset < 0) {
|
||||
throw new \OutOfRangeException(
|
||||
\sprintf('Offset (%s) out of range (length: %s)', $offset, $this->bufferLength)
|
||||
);
|
||||
}
|
||||
|
||||
$this->offset = (int) $offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current offset in the current buffer.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffset()
|
||||
{
|
||||
return $this->offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an offset to the current offset.
|
||||
*
|
||||
* @param int $offset
|
||||
*/
|
||||
public function addOffset($offset)
|
||||
{
|
||||
$this->setOffset($this->offset + $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that there is at least one character beyond the current offset in the buffer.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ensureContent()
|
||||
{
|
||||
while ($this->offset >= $this->bufferLength) {
|
||||
if (!$this->increaseLength()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stream.
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function getStream()
|
||||
{
|
||||
return $this->stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total available length.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalLength()
|
||||
{
|
||||
if (null === $this->totalLength) {
|
||||
$stat = \fstat($this->stream);
|
||||
$this->totalLength = $stat['size'];
|
||||
}
|
||||
|
||||
return $this->totalLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the buffer to a position and re-read the buffer with the given length.
|
||||
*
|
||||
* If the $pos parameter is negative the start buffer position will be the $pos'th position from
|
||||
* the end of the file.
|
||||
*
|
||||
* If the $pos parameter is negative and the absolute value is bigger then the totalLength of
|
||||
* the file $pos will set to zero.
|
||||
*
|
||||
* @param int|null $pos Start position of the new buffer
|
||||
* @param int $length Length of the new buffer. Mustn't be negative
|
||||
*/
|
||||
public function reset($pos = 0, $length = 200)
|
||||
{
|
||||
if (null === $pos) {
|
||||
$pos = $this->position + $this->offset;
|
||||
} elseif ($pos < 0) {
|
||||
$pos = \max(0, $this->getTotalLength() + $pos);
|
||||
}
|
||||
|
||||
\fseek($this->stream, $pos);
|
||||
|
||||
$this->position = $pos;
|
||||
$this->buffer = $length > 0 ? \fread($this->stream, $length) : '';
|
||||
$this->bufferLength = \strlen($this->buffer);
|
||||
$this->offset = 0;
|
||||
|
||||
// If a stream wrapper is in use it is possible that
|
||||
// length values > 8096 will be ignored, so use the
|
||||
// increaseLength()-method to correct that behavior
|
||||
if ($this->bufferLength < $length && $this->increaseLength($length - $this->bufferLength)) {
|
||||
// increaseLength parameter is $minLength, so cut to have only the required bytes in the buffer
|
||||
$this->buffer = \substr($this->buffer, 0, $length);
|
||||
$this->bufferLength = \strlen($this->buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures bytes in the buffer with a specific length and location in the file.
|
||||
*
|
||||
* @param int $pos
|
||||
* @param int $length
|
||||
* @see reset()
|
||||
*/
|
||||
public function ensure($pos, $length)
|
||||
{
|
||||
if ($pos >= $this->position
|
||||
&& $pos < ($this->position + $this->bufferLength)
|
||||
&& ($this->position + $this->bufferLength) >= ($pos + $length)
|
||||
) {
|
||||
$this->offset = $pos - $this->position;
|
||||
} else {
|
||||
$this->reset($pos, $length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forcefully read more data into the buffer.
|
||||
*
|
||||
* @param int $minLength
|
||||
* @return bool Returns false if the stream reaches the end
|
||||
*/
|
||||
public function increaseLength($minLength = 100)
|
||||
{
|
||||
$length = \max($minLength, 100);
|
||||
|
||||
if (\feof($this->stream) || $this->getTotalLength() === $this->position + $this->bufferLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$newLength = $this->bufferLength + $length;
|
||||
do {
|
||||
$this->buffer .= \fread($this->stream, $newLength - $this->bufferLength);
|
||||
$this->bufferLength = \strlen($this->buffer);
|
||||
} while (($this->bufferLength !== $newLength) && !\feof($this->stream));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser;
|
||||
|
||||
/**
|
||||
* A tokenizer class.
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser
|
||||
*/
|
||||
class Tokenizer
|
||||
{
|
||||
/**
|
||||
* @var StreamReader
|
||||
*/
|
||||
protected $streamReader;
|
||||
|
||||
/**
|
||||
* A token stack.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $stack = [];
|
||||
|
||||
/**
|
||||
* Tokenizer constructor.
|
||||
*
|
||||
* @param StreamReader $streamReader
|
||||
*/
|
||||
public function __construct(StreamReader $streamReader)
|
||||
{
|
||||
$this->streamReader = $streamReader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stream reader instance.
|
||||
*
|
||||
* @return StreamReader
|
||||
*/
|
||||
public function getStreamReader()
|
||||
{
|
||||
return $this->streamReader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the token stack.
|
||||
*/
|
||||
public function clearStack()
|
||||
{
|
||||
$this->stack = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a token onto the stack.
|
||||
*
|
||||
* @param string $token
|
||||
*/
|
||||
public function pushStack($token)
|
||||
{
|
||||
$this->stack[] = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next token.
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
public function getNextToken()
|
||||
{
|
||||
$token = \array_pop($this->stack);
|
||||
if (null !== $token) {
|
||||
return $token;
|
||||
}
|
||||
|
||||
if (($byte = $this->streamReader->readByte()) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($byte === "\x20" ||
|
||||
$byte === "\x0A" ||
|
||||
$byte === "\x0D" ||
|
||||
$byte === "\x0C" ||
|
||||
$byte === "\x09" ||
|
||||
$byte === "\x00"
|
||||
) {
|
||||
if (false === $this->leapWhiteSpaces()) {
|
||||
return false;
|
||||
}
|
||||
$byte = $this->streamReader->readByte();
|
||||
}
|
||||
|
||||
switch ($byte) {
|
||||
case '/':
|
||||
case '[':
|
||||
case ']':
|
||||
case '(':
|
||||
case ')':
|
||||
case '{':
|
||||
case '}':
|
||||
case '<':
|
||||
case '>':
|
||||
return $byte;
|
||||
case '%':
|
||||
$this->streamReader->readLine();
|
||||
return $this->getNextToken();
|
||||
}
|
||||
|
||||
/* This way is faster than checking single bytes.
|
||||
*/
|
||||
$bufferOffset = $this->streamReader->getOffset();
|
||||
do {
|
||||
$lastBuffer = $this->streamReader->getBuffer(false);
|
||||
$pos = \strcspn(
|
||||
$lastBuffer,
|
||||
"\x00\x09\x0A\x0C\x0D\x20()<>[]{}/%",
|
||||
$bufferOffset
|
||||
);
|
||||
} while (
|
||||
// Break the loop if a delimiter or white space char is matched
|
||||
// in the current buffer or increase the buffers length
|
||||
$lastBuffer !== false &&
|
||||
(
|
||||
$bufferOffset + $pos === \strlen($lastBuffer) &&
|
||||
$this->streamReader->increaseLength()
|
||||
)
|
||||
);
|
||||
|
||||
$result = \substr($lastBuffer, $bufferOffset - 1, $pos + 1);
|
||||
$this->streamReader->setOffset($bufferOffset + $pos);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Leap white spaces.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function leapWhiteSpaces()
|
||||
{
|
||||
do {
|
||||
if (!$this->streamReader->ensureContent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$buffer = $this->streamReader->getBuffer(false);
|
||||
$matches = \strspn($buffer, "\x20\x0A\x0C\x0D\x09\x00", $this->streamReader->getOffset());
|
||||
if ($matches > 0) {
|
||||
$this->streamReader->addOffset($matches);
|
||||
}
|
||||
} while ($this->streamReader->getOffset() >= $this->streamReader->getBufferLength());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\Tokenizer;
|
||||
|
||||
/**
|
||||
* Class representing a PDF array object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
* @property array $value The value of the PDF type.
|
||||
*/
|
||||
class PdfArray extends PdfType
|
||||
{
|
||||
/**
|
||||
* Parses an array of the passed tokenizer and parser.
|
||||
*
|
||||
* @param Tokenizer $tokenizer
|
||||
* @param PdfParser $parser
|
||||
* @return bool|self
|
||||
*/
|
||||
public static function parse(Tokenizer $tokenizer, PdfParser $parser)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
// Recurse into this function until we reach the end of the array.
|
||||
while (($token = $tokenizer->getNextToken()) !== ']') {
|
||||
if ($token === false || ($value = $parser->readValue($token)) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result[] = $value;
|
||||
}
|
||||
|
||||
$v = new self;
|
||||
$v->value = $result;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param PdfType[] $values
|
||||
* @return self
|
||||
*/
|
||||
public static function create(array $values = [])
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = $values;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed array is a PdfArray instance with a (optional) specific size.
|
||||
*
|
||||
* @param mixed $array
|
||||
* @param null|int $size
|
||||
* @return self
|
||||
* @throws PdfTypeException
|
||||
*/
|
||||
public static function ensure($array, $size = null)
|
||||
{
|
||||
$result = PdfType::ensureType(self::class, $array, 'Array value expected.');
|
||||
|
||||
if ($size !== null && \count($array->value) !== $size) {
|
||||
throw new PdfTypeException(
|
||||
\sprintf('Array with %s entries expected.', $size),
|
||||
PdfTypeException::INVALID_DATA_SIZE
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
/**
|
||||
* Class representing a boolean PDF object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfBoolean extends PdfType
|
||||
{
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param bool $value
|
||||
* @return self
|
||||
*/
|
||||
public static function create($value)
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = (boolean) $value;
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed value is a PdfBoolean instance.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return self
|
||||
*/
|
||||
public static function ensure($value)
|
||||
{
|
||||
return PdfType::ensureType(self::class, $value, 'Boolean value expected.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
use setasign\Fpdi\PdfParser\Tokenizer;
|
||||
|
||||
/**
|
||||
* Class representing a PDF dictionary object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfDictionary extends PdfType
|
||||
{
|
||||
/**
|
||||
* Parses a dictionary of the passed tokenizer, stream-reader and parser.
|
||||
*
|
||||
* @param Tokenizer $tokenizer
|
||||
* @param StreamReader $streamReader
|
||||
* @param PdfParser $parser
|
||||
* @return bool|self
|
||||
*/
|
||||
public static function parse(Tokenizer $tokenizer, StreamReader $streamReader, PdfParser $parser)
|
||||
{
|
||||
$entries = [];
|
||||
|
||||
while (true) {
|
||||
$token = $tokenizer->getNextToken();
|
||||
if ($token === '>' && $streamReader->getByte() === '>') {
|
||||
$streamReader->addOffset(1);
|
||||
break;
|
||||
}
|
||||
|
||||
$key = $parser->readValue($token);
|
||||
if (false === $key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ensure the first value to be a Name object
|
||||
if (!($key instanceof PdfName)) {
|
||||
$lastToken = null;
|
||||
// ignore all other entries and search for the closing brackets
|
||||
while (($token = $tokenizer->getNextToken()) !== '>' && $token !== false && $lastToken !== '>') {
|
||||
$lastToken = $token;
|
||||
}
|
||||
|
||||
if ($token === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$value = $parser->readValue();
|
||||
if (false === $value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($value instanceof PdfNull) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// catch missing value
|
||||
if ($value instanceof PdfToken && $value->value === '>' && $streamReader->getByte() === '>') {
|
||||
$streamReader->addOffset(1);
|
||||
break;
|
||||
}
|
||||
|
||||
$entries[$key->value] = $value;
|
||||
}
|
||||
|
||||
$v = new self;
|
||||
$v->value = $entries;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param PdfType[] $entries The keys are the name entries of the dictionary.
|
||||
* @return self
|
||||
*/
|
||||
public static function create(array $entries = [])
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = $entries;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value by its key from a dictionary or a default value.
|
||||
*
|
||||
* @param mixed $dictionary
|
||||
* @param string $key
|
||||
* @param PdfType|mixed|null $default
|
||||
* @return PdfNull|PdfType
|
||||
*/
|
||||
public static function get($dictionary, $key, PdfType $default = null)
|
||||
{
|
||||
$dictionary = self::ensure($dictionary);
|
||||
|
||||
if (isset($dictionary->value[$key])) {
|
||||
return $dictionary->value[$key];
|
||||
}
|
||||
|
||||
return $default === null
|
||||
? new PdfNull()
|
||||
: $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed value is a PdfDictionary instance.
|
||||
*
|
||||
* @param mixed $dictionary
|
||||
* @return self
|
||||
*/
|
||||
public static function ensure($dictionary)
|
||||
{
|
||||
return PdfType::ensureType(self::class, $dictionary, 'Dictionary value expected.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
|
||||
/**
|
||||
* Class representing a hexadecimal encoded PDF string object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfHexString extends PdfType
|
||||
{
|
||||
/**
|
||||
* Parses a hexadecimal string object from the stream reader.
|
||||
*
|
||||
* @param StreamReader $streamReader
|
||||
* @return bool|self
|
||||
*/
|
||||
public static function parse(StreamReader $streamReader)
|
||||
{
|
||||
$bufferOffset = $streamReader->getOffset();
|
||||
|
||||
/**
|
||||
* @var string $buffer
|
||||
* @var int $pos
|
||||
*/
|
||||
while (true) {
|
||||
$buffer = $streamReader->getBuffer(false);
|
||||
$pos = \strpos($buffer, '>', $bufferOffset);
|
||||
if (false === $pos) {
|
||||
if (!$streamReader->increaseLength()) {
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$result = \substr($buffer, $bufferOffset, $pos - $bufferOffset);
|
||||
$streamReader->setOffset($pos + 1);
|
||||
|
||||
$v = new self;
|
||||
$v->value = $result;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param string $string The hex encoded string.
|
||||
* @return self
|
||||
*/
|
||||
public static function create($string)
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = $string;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed value is a PdfHexString instance.
|
||||
*
|
||||
* @param mixed $hexString
|
||||
* @return self
|
||||
*/
|
||||
public static function ensure($hexString)
|
||||
{
|
||||
return PdfType::ensureType(self::class, $hexString, 'Hex string value expected.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
use setasign\Fpdi\PdfParser\Tokenizer;
|
||||
|
||||
/**
|
||||
* Class representing an indirect object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfIndirectObject extends PdfType
|
||||
{
|
||||
/**
|
||||
* Parses an indirect object from a tokenizer, parser and stream-reader.
|
||||
*
|
||||
* @param int $objectNumberToken
|
||||
* @param int $objectGenerationNumberToken
|
||||
* @param PdfParser $parser
|
||||
* @param Tokenizer $tokenizer
|
||||
* @param StreamReader $reader
|
||||
* @return bool|self
|
||||
*/
|
||||
public static function parse(
|
||||
$objectNumberToken,
|
||||
$objectGenerationNumberToken,
|
||||
PdfParser $parser,
|
||||
Tokenizer $tokenizer,
|
||||
StreamReader $reader
|
||||
) {
|
||||
$value = $parser->readValue();
|
||||
if ($value === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$nextToken = $tokenizer->getNextToken();
|
||||
if ($nextToken === 'stream') {
|
||||
$value = PdfStream::parse($value, $reader);
|
||||
} elseif ($nextToken !== false) {
|
||||
$tokenizer->pushStack($nextToken);
|
||||
}
|
||||
|
||||
$v = new self;
|
||||
$v->objectNumber = (int) $objectNumberToken;
|
||||
$v->generationNumber = (int) $objectGenerationNumberToken;
|
||||
$v->value = $value;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param int $objectNumber
|
||||
* @param int $generationNumber
|
||||
* @param PdfType $value
|
||||
* @return self
|
||||
*/
|
||||
public static function create($objectNumber, $generationNumber, PdfType $value)
|
||||
{
|
||||
$v = new self;
|
||||
$v->objectNumber = (int) $objectNumber;
|
||||
$v->generationNumber = (int) $generationNumber;
|
||||
$v->value = $value;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed value is a PdfIndirectObject instance.
|
||||
*
|
||||
* @param mixed $indirectObject
|
||||
* @return self
|
||||
*/
|
||||
public static function ensure($indirectObject)
|
||||
{
|
||||
return PdfType::ensureType(self::class, $indirectObject, 'Indirect object expected.');
|
||||
}
|
||||
|
||||
/**
|
||||
* The object number.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $objectNumber;
|
||||
|
||||
/**
|
||||
* The generation number.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $generationNumber;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
/**
|
||||
* Class representing an indirect object reference
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfIndirectObjectReference extends PdfType
|
||||
{
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param int $objectNumber
|
||||
* @param int $generationNumber
|
||||
* @return self
|
||||
*/
|
||||
public static function create($objectNumber, $generationNumber)
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = (int) $objectNumber;
|
||||
$v->generationNumber = (int) $generationNumber;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed value is a PdfIndirectObject instance.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return self
|
||||
*/
|
||||
public static function ensure($value)
|
||||
{
|
||||
return PdfType::ensureType(self::class, $value, 'Indirect reference value expected.');
|
||||
}
|
||||
|
||||
/**
|
||||
* The generation number.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $generationNumber;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
use setasign\Fpdi\PdfParser\Tokenizer;
|
||||
|
||||
/**
|
||||
* Class representing a PDF name object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfName extends PdfType
|
||||
{
|
||||
/**
|
||||
* Parses a name object from the passed tokenizer and stream-reader.
|
||||
*
|
||||
* @param Tokenizer $tokenizer
|
||||
* @param StreamReader $streamReader
|
||||
* @return self
|
||||
*/
|
||||
public static function parse(Tokenizer $tokenizer, StreamReader $streamReader)
|
||||
{
|
||||
$v = new self;
|
||||
if (\strspn($streamReader->getByte(), "\x00\x09\x0A\x0C\x0D\x20()<>[]{}/%") === 0) {
|
||||
$v->value = (string) $tokenizer->getNextToken();
|
||||
return $v;
|
||||
}
|
||||
|
||||
$v->value = '';
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unescapes a name string.
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
static public function unescape($value)
|
||||
{
|
||||
if (false === strpos($value, '#'))
|
||||
return $value;
|
||||
|
||||
return preg_replace_callback('/#[a-fA-F\d]{2}/', function($matches) {
|
||||
return chr(hexdec($matches[0]));
|
||||
}, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param string $string
|
||||
* @return self
|
||||
*/
|
||||
public static function create($string)
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = $string;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed value is a PdfName instance.
|
||||
*
|
||||
* @param mixed $name
|
||||
* @return self
|
||||
*/
|
||||
public static function ensure($name)
|
||||
{
|
||||
return PdfType::ensureType(self::class, $name, 'Name value expected.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
/**
|
||||
* Class representing a PDF null object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfNull extends PdfType
|
||||
{
|
||||
// empty body
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
/**
|
||||
* Class representing a numeric PDF object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfNumeric extends PdfType
|
||||
{
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param int|float $value
|
||||
* @return PdfNumeric
|
||||
*/
|
||||
public static function create($value)
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = $value + 0;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed value is a PdfNumeric instance.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return self
|
||||
*/
|
||||
public static function ensure($value)
|
||||
{
|
||||
return PdfType::ensureType(self::class, $value, 'Numeric value expected.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
use setasign\Fpdi\PdfParser\Filter\Ascii85;
|
||||
use setasign\Fpdi\PdfParser\Filter\AsciiHex;
|
||||
use setasign\Fpdi\PdfParser\Filter\FilterException;
|
||||
use setasign\Fpdi\PdfParser\Filter\Flate;
|
||||
use setasign\Fpdi\PdfParser\Filter\Lzw;
|
||||
use setasign\Fpdi\PdfParser\PdfParserException;
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
use setasign\FpdiPdfParser\PdfParser\Filter\Predictor;
|
||||
|
||||
/**
|
||||
* Class representing a PDF stream object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfStream extends PdfType
|
||||
{
|
||||
/**
|
||||
* Parses a stream from a stream reader.
|
||||
*
|
||||
* @param PdfDictionary $dictionary
|
||||
* @param StreamReader $reader
|
||||
* @return self
|
||||
* @throws PdfTypeException
|
||||
*/
|
||||
public static function parse(PdfDictionary $dictionary, StreamReader $reader)
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = $dictionary;
|
||||
$v->reader = $reader;
|
||||
|
||||
$offset = $reader->getOffset();
|
||||
|
||||
// Find the first "newline"
|
||||
while (($firstByte = $reader->getByte($offset)) !== false) {
|
||||
if ($firstByte !== "\n" && $firstByte !== "\r") {
|
||||
$offset++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (false === $firstByte) {
|
||||
throw new PdfTypeException(
|
||||
'Unable to parse stream data. No newline after the stream keyword found.',
|
||||
PdfTypeException::NO_NEWLINE_AFTER_STREAM_KEYWORD
|
||||
);
|
||||
}
|
||||
|
||||
$sndByte = $reader->getByte($offset + 1);
|
||||
if ($firstByte === "\n" || $firstByte === "\r") {
|
||||
$offset++;
|
||||
}
|
||||
|
||||
if ($sndByte === "\n" && $firstByte !== "\n") {
|
||||
$offset++;
|
||||
}
|
||||
|
||||
$reader->setOffset($offset);
|
||||
// let's only save the byte-offset and read the stream only when needed
|
||||
$v->stream = $reader->getPosition() + $reader->getOffset();
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param PdfDictionary $dictionary
|
||||
* @param string $stream
|
||||
* @return self
|
||||
*/
|
||||
public static function create(PdfDictionary $dictionary, $stream)
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = $dictionary;
|
||||
$v->stream = (string) $stream;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed value is a PdfStream instance.
|
||||
*
|
||||
* @param mixed $stream
|
||||
* @return self
|
||||
*/
|
||||
public static function ensure($stream)
|
||||
{
|
||||
return PdfType::ensureType(self::class, $stream, 'Stream value expected.');
|
||||
}
|
||||
|
||||
/**
|
||||
* The stream or its byte-offset position.
|
||||
*
|
||||
* @var int|string
|
||||
*/
|
||||
protected $stream;
|
||||
|
||||
/**
|
||||
* The stream reader instance.
|
||||
*
|
||||
* @var StreamReader
|
||||
*/
|
||||
protected $reader;
|
||||
|
||||
/**
|
||||
* Get the stream data.
|
||||
*
|
||||
* @param bool $cache Whether cache the stream data or not.
|
||||
* @return bool|string
|
||||
*/
|
||||
public function getStream($cache = false)
|
||||
{
|
||||
if (\is_int($this->stream)) {
|
||||
$length = PdfDictionary::get($this->value, 'Length');
|
||||
$this->reader->reset($this->stream, $length->value);
|
||||
if (!($length instanceof PdfNumeric) || $length->value === 0) {
|
||||
while (true) {
|
||||
$buffer = $this->reader->getBuffer(false);
|
||||
$length = \strpos($buffer, 'endstream');
|
||||
if (false === $length) {
|
||||
if (!$this->reader->increaseLength(100000)) {
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$buffer = \substr($buffer, 0, $length);
|
||||
$lastByte = \substr($buffer, -1);
|
||||
|
||||
// Check for EOL
|
||||
if ($lastByte === "\n") {
|
||||
$buffer = \substr($buffer, 0, -1);
|
||||
}
|
||||
|
||||
$lastByte = \substr($buffer, -1);
|
||||
if ($lastByte === "\r") {
|
||||
$buffer = \substr($buffer, 0, -1);
|
||||
}
|
||||
|
||||
} else {
|
||||
$buffer = $this->reader->getBuffer(false);
|
||||
}
|
||||
if ($cache === false) {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
$this->stream = $buffer;
|
||||
$this->reader = null;
|
||||
}
|
||||
|
||||
return $this->stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unfiltered stream data.
|
||||
*
|
||||
* @return string
|
||||
* @throws FilterException
|
||||
* @throws PdfParserException
|
||||
*/
|
||||
public function getUnfilteredStream()
|
||||
{
|
||||
$stream = $this->getStream();
|
||||
$filters = PdfDictionary::get($this->value, 'Filter');
|
||||
if ($filters instanceof PdfNull) {
|
||||
return $stream;
|
||||
}
|
||||
|
||||
if ($filters instanceof PdfArray) {
|
||||
$filters = $filters->value;
|
||||
} else {
|
||||
$filters = [$filters];
|
||||
}
|
||||
|
||||
$decodeParams = PdfDictionary::get($this->value, 'DecodeParms');
|
||||
if ($decodeParams instanceof PdfArray) {
|
||||
$decodeParams = $decodeParams->value;
|
||||
} else {
|
||||
$decodeParams = [$decodeParams];
|
||||
}
|
||||
|
||||
foreach ($filters as $key => $filter) {
|
||||
if (!($filter instanceof PdfName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$decodeParam = null;
|
||||
if (isset($decodeParams[$key])) {
|
||||
$decodeParam = ($decodeParams[$key] instanceof PdfDictionary ? $decodeParams[$key] : null);
|
||||
}
|
||||
|
||||
switch ($filter->value) {
|
||||
case 'FlateDecode':
|
||||
case 'Fl':
|
||||
case 'LZWDecode':
|
||||
case 'LZW':
|
||||
if (\strpos($filter->value, 'LZW') === 0) {
|
||||
$filterObject = new Lzw();
|
||||
} else {
|
||||
$filterObject = new Flate();
|
||||
}
|
||||
|
||||
$stream = $filterObject->decode($stream);
|
||||
|
||||
if ($decodeParam instanceof PdfDictionary) {
|
||||
$predictor = PdfDictionary::get($decodeParam, 'Predictor', PdfNumeric::create(1));
|
||||
if ($predictor->value !== 1) {
|
||||
if (!\class_exists(Predictor::class)) {
|
||||
throw new PdfParserException(
|
||||
'This PDF document makes use of features which are only implemented in the ' .
|
||||
'commercial "FPDI PDF-Parser" add-on (see https://www.setasign.com/fpdi-pdf-' .
|
||||
'parser).',
|
||||
PdfParserException::IMPLEMENTED_IN_FPDI_PDF_PARSER
|
||||
);
|
||||
}
|
||||
|
||||
$colors = PdfDictionary::get($decodeParam, 'Colors', PdfNumeric::create(1));
|
||||
$bitsPerComponent = PdfDictionary::get(
|
||||
$decodeParam,
|
||||
'BitsPerComponent',
|
||||
PdfNumeric::create(8)
|
||||
);
|
||||
|
||||
$columns = PdfDictionary::get($decodeParam, 'Columns', PdfNumeric::create(1));
|
||||
|
||||
$filterObject = new Predictor(
|
||||
$predictor->value,
|
||||
$colors->value,
|
||||
$bitsPerComponent->value,
|
||||
$columns->value
|
||||
);
|
||||
|
||||
$stream = $filterObject->decode($stream);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'ASCII85Decode':
|
||||
case 'A85':
|
||||
$filterObject = new Ascii85();
|
||||
$stream = $filterObject->decode($stream);
|
||||
break;
|
||||
|
||||
case 'ASCIIHexDecode':
|
||||
case 'AHx':
|
||||
$filterObject = new AsciiHex();
|
||||
$stream = $filterObject->decode($stream);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new FilterException(
|
||||
\sprintf('Unsupported filter "%s".', $filter->value),
|
||||
FilterException::UNSUPPORTED_FILTER
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $stream;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
|
||||
/**
|
||||
* Class representing a PDF string object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfString extends PdfType
|
||||
{
|
||||
/**
|
||||
* Parses a string object from the stream reader.
|
||||
*
|
||||
* @param StreamReader $streamReader
|
||||
* @return self
|
||||
*/
|
||||
public static function parse(StreamReader $streamReader)
|
||||
{
|
||||
$pos = $startPos = $streamReader->getOffset();
|
||||
$openBrackets = 1;
|
||||
do {
|
||||
$buffer = $streamReader->getBuffer(false);
|
||||
for ($length = \strlen($buffer); $openBrackets !== 0 && $pos < $length; $pos++) {
|
||||
switch ($buffer[$pos]) {
|
||||
case '(':
|
||||
$openBrackets++;
|
||||
break;
|
||||
case ')':
|
||||
$openBrackets--;
|
||||
break;
|
||||
case '\\':
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
} while ($openBrackets !== 0 && $streamReader->increaseLength());
|
||||
|
||||
$result = \substr($buffer, $startPos, $openBrackets + $pos - $startPos - 1);
|
||||
$streamReader->setOffset($pos);
|
||||
|
||||
$v = new self;
|
||||
$v->value = $result;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param string $value The string needs to be escaped accordingly.
|
||||
* @return self
|
||||
*/
|
||||
public static function create($value)
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = $value;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed value is a PdfString instance.
|
||||
*
|
||||
* @param mixed $string
|
||||
* @return self
|
||||
*/
|
||||
public static function ensure($string)
|
||||
{
|
||||
return PdfType::ensureType(self::class, $string, 'String value expected.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unescapes escaped sequences in a PDF string according to the PDF specification.
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
*/
|
||||
public static function unescape($s)
|
||||
{
|
||||
$out = '';
|
||||
/** @noinspection ForeachInvariantsInspection */
|
||||
for ($count = 0, $n = \strlen($s); $count < $n; $count++) {
|
||||
if ($s[$count] !== '\\') {
|
||||
$out .= $s[$count];
|
||||
} else {
|
||||
// A backslash at the end of the string - ignore it
|
||||
if ($count === ($n - 1)) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($s[++$count]) {
|
||||
case ')':
|
||||
case '(':
|
||||
case '\\':
|
||||
$out .= $s[$count];
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
$out .= "\x0C";
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
$out .= "\x08";
|
||||
break;
|
||||
|
||||
case 't':
|
||||
$out .= "\x09";
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
$out .= "\x0D";
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
$out .= "\x0A";
|
||||
break;
|
||||
|
||||
case "\r":
|
||||
if ($count !== $n - 1 && $s[$count + 1] === "\n") {
|
||||
$count++;
|
||||
}
|
||||
break;
|
||||
|
||||
case "\n":
|
||||
break;
|
||||
|
||||
default:
|
||||
$actualChar = \ord($s[$count]);
|
||||
// ascii 48 = number 0
|
||||
// ascii 57 = number 9
|
||||
if ($actualChar >= 48 &&
|
||||
$actualChar <= 57) {
|
||||
$oct = '' . $s[$count];
|
||||
|
||||
/** @noinspection NotOptimalIfConditionsInspection */
|
||||
if ($count + 1 < $n &&
|
||||
\ord($s[$count + 1]) >= 48 &&
|
||||
\ord($s[$count + 1]) <= 57
|
||||
) {
|
||||
$count++;
|
||||
$oct .= $s[$count];
|
||||
|
||||
/** @noinspection NotOptimalIfConditionsInspection */
|
||||
if ($count + 1 < $n &&
|
||||
\ord($s[$count + 1]) >= 48 &&
|
||||
\ord($s[$count + 1]) <= 57
|
||||
) {
|
||||
$oct .= $s[++$count];
|
||||
}
|
||||
}
|
||||
|
||||
$out .= \chr(\octdec($oct));
|
||||
} else {
|
||||
// If the character is not one of those defined, the backslash is ignored
|
||||
$out .= $s[$count];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
/**
|
||||
* Class representing PDF token object
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfToken extends PdfType
|
||||
{
|
||||
/**
|
||||
* Helper method to create an instance.
|
||||
*
|
||||
* @param string $token
|
||||
* @return self
|
||||
*/
|
||||
public static function create($token)
|
||||
{
|
||||
$v = new self;
|
||||
$v->value = $token;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the passed value is a PdfToken instance.
|
||||
*
|
||||
* @param mixed $token
|
||||
* @return self
|
||||
*/
|
||||
public static function ensure($token)
|
||||
{
|
||||
return PdfType::ensureType(self::class, $token, 'Token value expected.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
|
||||
/**
|
||||
* A class defining a PDF data type
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfType
|
||||
{
|
||||
/**
|
||||
* Resolves a PdfType value to its value.
|
||||
*
|
||||
* This method is used to evaluate indirect and direct object references until a final value is reached.
|
||||
*
|
||||
* @param PdfType $value
|
||||
* @param PdfParser $parser
|
||||
* @param bool $stopAtIndirectObject
|
||||
* @return PdfType
|
||||
*/
|
||||
public static function resolve(PdfType $value, PdfParser $parser, $stopAtIndirectObject = false)
|
||||
{
|
||||
if ($value instanceof PdfIndirectObject) {
|
||||
if ($stopAtIndirectObject === true) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return self::resolve($value->value, $parser, $stopAtIndirectObject);
|
||||
}
|
||||
|
||||
if ($value instanceof PdfIndirectObjectReference) {
|
||||
return self::resolve($parser->getIndirectObject($value->value), $parser, $stopAtIndirectObject);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that a value is an instance of a specific PDF type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param PdfType $value
|
||||
* @param string $errorMessage
|
||||
* @return mixed
|
||||
* @throws PdfTypeException
|
||||
*/
|
||||
protected static function ensureType($type, $value, $errorMessage)
|
||||
{
|
||||
if (!($value instanceof $type)) {
|
||||
throw new PdfTypeException(
|
||||
$errorMessage,
|
||||
PdfTypeException::INVALID_DATA_TYPE
|
||||
);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the PDF type.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $value;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfParser\Type;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParserException;
|
||||
|
||||
/**
|
||||
* Exception class for pdf type classes
|
||||
*
|
||||
* @package setasign\Fpdi\PdfParser\Type
|
||||
*/
|
||||
class PdfTypeException extends PdfParserException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const NO_NEWLINE_AFTER_STREAM_KEYWORD = 0x0601;
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfReader\DataStructure;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfArray;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNumeric;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfType;
|
||||
|
||||
/**
|
||||
* Class representing a rectangle
|
||||
*
|
||||
* @package setasign\Fpdi\PdfReader\DataStructure
|
||||
*/
|
||||
class Rectangle
|
||||
{
|
||||
/**
|
||||
* @var int|float
|
||||
*/
|
||||
protected $llx;
|
||||
|
||||
/**
|
||||
* @var int|float
|
||||
*/
|
||||
protected $lly;
|
||||
|
||||
/**
|
||||
* @var int|float
|
||||
*/
|
||||
protected $urx;
|
||||
|
||||
/**
|
||||
* @var int|float
|
||||
*/
|
||||
protected $ury;
|
||||
|
||||
/**
|
||||
* Create a rectangle instance by a PdfArray.
|
||||
*
|
||||
* @param PdfArray|mixed $array
|
||||
* @param PdfParser $parser
|
||||
* @return Rectangle
|
||||
*/
|
||||
public static function byPdfArray($array, PdfParser $parser)
|
||||
{
|
||||
$array = PdfArray::ensure(PdfType::resolve($array, $parser), 4)->value;
|
||||
$ax = PdfNumeric::ensure(PdfType::resolve($array[0], $parser))->value;
|
||||
$ay = PdfNumeric::ensure(PdfType::resolve($array[1], $parser))->value;
|
||||
$bx = PdfNumeric::ensure(PdfType::resolve($array[2], $parser))->value;
|
||||
$by = PdfNumeric::ensure(PdfType::resolve($array[3], $parser))->value;
|
||||
|
||||
return new self($ax, $ay, $bx, $by);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rectangle constructor.
|
||||
*
|
||||
* @param float|int $ax
|
||||
* @param float|int $ay
|
||||
* @param float|int $bx
|
||||
* @param float|int $by
|
||||
*/
|
||||
public function __construct($ax, $ay, $bx, $by)
|
||||
{
|
||||
$this->llx = \min($ax, $bx);
|
||||
$this->lly = \min($ay, $by);
|
||||
$this->urx = \max($ax, $bx);
|
||||
$this->ury = \max($ay, $by);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of the rectangle.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->urx - $this->llx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of the rectangle.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->ury - $this->lly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lower left abscissa.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getLlx()
|
||||
{
|
||||
return $this->llx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lower left ordinate.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getLly()
|
||||
{
|
||||
return $this->lly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upper right abscissa.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getUrx()
|
||||
{
|
||||
return $this->urx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upper right ordinate.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getUry()
|
||||
{
|
||||
return $this->ury;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rectangle as an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
$this->llx,
|
||||
$this->lly,
|
||||
$this->urx,
|
||||
$this->ury
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rectangle as a PdfArray.
|
||||
*
|
||||
* @return PdfArray
|
||||
*/
|
||||
public function toPdfArray()
|
||||
{
|
||||
$array = new PdfArray();
|
||||
$array->value[] = PdfNumeric::create($this->llx);
|
||||
$array->value[] = PdfNumeric::create($this->lly);
|
||||
$array->value[] = PdfNumeric::create($this->urx);
|
||||
$array->value[] = PdfNumeric::create($this->ury);
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfReader;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfArray;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfDictionary;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfIndirectObject;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNull;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNumeric;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfStream;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfType;
|
||||
use setasign\Fpdi\PdfReader\DataStructure\Rectangle;
|
||||
|
||||
/**
|
||||
* Class representing a page of a PDF document
|
||||
*
|
||||
* @package setasign\Fpdi\PdfReader
|
||||
*/
|
||||
class Page
|
||||
{
|
||||
/**
|
||||
* @var PdfIndirectObject
|
||||
*/
|
||||
protected $pageObject;
|
||||
|
||||
/**
|
||||
* @var PdfDictionary
|
||||
*/
|
||||
protected $pageDictionary;
|
||||
|
||||
/**
|
||||
* @var PdfParser
|
||||
*/
|
||||
protected $parser;
|
||||
|
||||
/**
|
||||
* Inherited attributes
|
||||
*
|
||||
* @var null|array
|
||||
*/
|
||||
protected $inheritedAttributes;
|
||||
|
||||
/**
|
||||
* Page constructor.
|
||||
*
|
||||
* @param PdfIndirectObject $page
|
||||
* @param PdfParser $parser
|
||||
*/
|
||||
public function __construct(PdfIndirectObject $page, PdfParser $parser)
|
||||
{
|
||||
$this->pageObject = $page;
|
||||
$this->parser = $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the indirect object of this page.
|
||||
*
|
||||
* @return PdfIndirectObject
|
||||
*/
|
||||
public function getPageObject()
|
||||
{
|
||||
return $this->pageObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dictionary of this page.
|
||||
*
|
||||
* @return PdfDictionary
|
||||
*/
|
||||
public function getPageDictionary()
|
||||
{
|
||||
if (null === $this->pageDictionary) {
|
||||
$this->pageDictionary = PdfDictionary::ensure(PdfType::resolve($this->getPageObject(), $this->parser));
|
||||
}
|
||||
|
||||
return $this->pageDictionary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a page attribute.
|
||||
*
|
||||
* @param string $name
|
||||
* @param bool $inherited
|
||||
* @return PdfType|null
|
||||
*/
|
||||
public function getAttribute($name, $inherited = true)
|
||||
{
|
||||
$dict = $this->getPageDictionary();
|
||||
|
||||
if (isset($dict->value[$name])) {
|
||||
return $dict->value[$name];
|
||||
}
|
||||
|
||||
$inheritedKeys = ['Resources', 'MediaBox', 'CropBox', 'Rotate'];
|
||||
if ($inherited && \in_array($name, $inheritedKeys, true)) {
|
||||
if (null === $this->inheritedAttributes) {
|
||||
$this->inheritedAttributes = [];
|
||||
$inheritedKeys = \array_filter($inheritedKeys, function ($key) use ($dict) {
|
||||
return !isset($dict->value[$key]);
|
||||
});
|
||||
|
||||
if (\count($inheritedKeys) > 0) {
|
||||
$parentDict = PdfType::resolve(PdfDictionary::get($dict, 'Parent'), $this->parser);
|
||||
while ($parentDict instanceof PdfDictionary) {
|
||||
foreach ($inheritedKeys as $index => $key) {
|
||||
if (isset($parentDict->value[$key])) {
|
||||
$this->inheritedAttributes[$key] = $parentDict->value[$key];
|
||||
unset($inheritedKeys[$index]);
|
||||
}
|
||||
}
|
||||
|
||||
/** @noinspection NotOptimalIfConditionsInspection */
|
||||
if (isset($parentDict->value['Parent']) && \count($inheritedKeys) > 0) {
|
||||
$parentDict = PdfType::resolve(PdfDictionary::get($parentDict, 'Parent'), $this->parser);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->inheritedAttributes[$name])) {
|
||||
return $this->inheritedAttributes[$name];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rotation value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRotation()
|
||||
{
|
||||
$rotation = $this->getAttribute('Rotate');
|
||||
if (null === $rotation) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$rotation = PdfNumeric::ensure(PdfType::resolve($rotation, $this->parser))->value % 360;
|
||||
|
||||
if ($rotation < 0) {
|
||||
$rotation += 360;
|
||||
}
|
||||
|
||||
return $rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a boundary of this page.
|
||||
*
|
||||
* @param string $box
|
||||
* @param bool $fallback
|
||||
* @return bool|Rectangle
|
||||
* @see PageBoundaries
|
||||
*/
|
||||
public function getBoundary($box = PageBoundaries::CROP_BOX, $fallback = true)
|
||||
{
|
||||
$value = $this->getAttribute($box);
|
||||
|
||||
if (null !== $value) {
|
||||
return Rectangle::byPdfArray($value, $this->parser);
|
||||
}
|
||||
|
||||
if (false === $fallback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch ($box) {
|
||||
case PageBoundaries::BLEED_BOX:
|
||||
case PageBoundaries::TRIM_BOX:
|
||||
case PageBoundaries::ART_BOX:
|
||||
return $this->getBoundary(PageBoundaries::CROP_BOX, true);
|
||||
case PageBoundaries::CROP_BOX:
|
||||
return $this->getBoundary(PageBoundaries::MEDIA_BOX, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width and height of this page.
|
||||
*
|
||||
* @param string $box
|
||||
* @param bool $fallback
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getWidthAndHeight($box = PageBoundaries::CROP_BOX, $fallback = true)
|
||||
{
|
||||
$boundary = $this->getBoundary($box, $fallback);
|
||||
if (false === $boundary) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$rotation = $this->getRotation();
|
||||
$interchange = ($rotation / 90) % 2;
|
||||
|
||||
return [
|
||||
$interchange ? $boundary->getHeight() : $boundary->getWidth(),
|
||||
$interchange ? $boundary->getWidth() : $boundary->getHeight()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw content stream.
|
||||
*
|
||||
* @return string
|
||||
* @throws PdfReaderException
|
||||
*/
|
||||
public function getContentStream()
|
||||
{
|
||||
$dict = $this->getPageDictionary();
|
||||
$contents = PdfType::resolve(PdfDictionary::get($dict, 'Contents'), $this->parser);
|
||||
if ($contents instanceof PdfNull) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($contents instanceof PdfArray) {
|
||||
$result = [];
|
||||
foreach ($contents->value as $content) {
|
||||
$content = PdfType::resolve($content, $this->parser);
|
||||
if (!($content instanceof PdfStream)) {
|
||||
continue;
|
||||
}
|
||||
$result[] = $content->getUnfilteredStream();
|
||||
}
|
||||
|
||||
return \implode("\n", $result);
|
||||
}
|
||||
|
||||
if ($contents instanceof PdfStream) {
|
||||
return $contents->getUnfilteredStream();
|
||||
}
|
||||
|
||||
throw new PdfReaderException(
|
||||
'Array or stream expected.',
|
||||
PdfReaderException::UNEXPECTED_DATA_TYPE
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfReader;
|
||||
|
||||
/**
|
||||
* An abstract class for page boundary constants and some helper methods
|
||||
*
|
||||
* @package setasign\Fpdi\PdfReader
|
||||
*/
|
||||
abstract class PageBoundaries
|
||||
{
|
||||
/**
|
||||
* MediaBox
|
||||
*
|
||||
* The media box defines the boundaries of the physical medium on which the page is to be printed.
|
||||
*
|
||||
* @see PDF 32000-1:2008 - 14.11.2 Page Boundaries
|
||||
* @var string
|
||||
*/
|
||||
const MEDIA_BOX = 'MediaBox';
|
||||
|
||||
/**
|
||||
* CropBox
|
||||
*
|
||||
* The crop box defines the region to which the contents of the page shall be clipped (cropped) when displayed or
|
||||
* printed.
|
||||
*
|
||||
* @see PDF 32000-1:2008 - 14.11.2 Page Boundaries
|
||||
* @var string
|
||||
*/
|
||||
const CROP_BOX = 'CropBox';
|
||||
|
||||
/**
|
||||
* BleedBox
|
||||
*
|
||||
* The bleed box defines the region to which the contents of the page shall be clipped when output in a
|
||||
* production environment.
|
||||
*
|
||||
* @see PDF 32000-1:2008 - 14.11.2 Page Boundaries
|
||||
* @var string
|
||||
*/
|
||||
const BLEED_BOX = 'BleedBox';
|
||||
|
||||
/**
|
||||
* TrimBox
|
||||
*
|
||||
* The trim box defines the intended dimensions of the finished page after trimming.
|
||||
*
|
||||
* @see PDF 32000-1:2008 - 14.11.2 Page Boundaries
|
||||
* @var string
|
||||
*/
|
||||
const TRIM_BOX = 'TrimBox';
|
||||
|
||||
/**
|
||||
* ArtBox
|
||||
*
|
||||
* The art box defines the extent of the page’s meaningful content (including potential white space) as intended
|
||||
* by the page’s creator.
|
||||
*
|
||||
* @see PDF 32000-1:2008 - 14.11.2 Page Boundaries
|
||||
* @var string
|
||||
*/
|
||||
const ART_BOX = 'ArtBox';
|
||||
|
||||
/**
|
||||
* All page boundaries
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $all = array(
|
||||
self::MEDIA_BOX,
|
||||
self::CROP_BOX,
|
||||
self::BLEED_BOX,
|
||||
self::TRIM_BOX,
|
||||
self::ART_BOX
|
||||
);
|
||||
|
||||
/**
|
||||
* Checks if a name is a valid page boundary name.
|
||||
*
|
||||
* @param string $name The boundary name
|
||||
* @return boolean A boolean value whether the name is valid or not.
|
||||
*/
|
||||
public static function isValidName($name)
|
||||
{
|
||||
return \in_array($name, self::$all, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfReader;
|
||||
|
||||
use setasign\Fpdi\PdfParser\PdfParser;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfArray;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfDictionary;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfIndirectObjectReference;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNumeric;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfType;
|
||||
|
||||
/**
|
||||
* A PDF reader class
|
||||
*
|
||||
* @package setasign\Fpdi\PdfReader
|
||||
*/
|
||||
class PdfReader
|
||||
{
|
||||
/**
|
||||
* @var PdfParser
|
||||
*/
|
||||
protected $parser;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $pageCount;
|
||||
|
||||
/**
|
||||
* Indirect objects of resolved pages.
|
||||
*
|
||||
* @var PdfIndirectObjectReference[]
|
||||
*/
|
||||
protected $pages = [];
|
||||
|
||||
/**
|
||||
* PdfReader constructor.
|
||||
*
|
||||
* @param PdfParser $parser
|
||||
*/
|
||||
public function __construct(PdfParser $parser)
|
||||
{
|
||||
$this->parser = $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* PdfReader destructor.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if ($this->parser !== null) {
|
||||
/** @noinspection PhpInternalEntityUsedInspection */
|
||||
$this->parser->cleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pdf parser instance.
|
||||
*
|
||||
* @return PdfParser
|
||||
*/
|
||||
public function getParser()
|
||||
{
|
||||
return $this->parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PDF version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPdfVersion()
|
||||
{
|
||||
return \implode('.', $this->parser->getPdfVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page count.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPageCount()
|
||||
{
|
||||
if ($this->pageCount === null) {
|
||||
$catalog = $this->parser->getCatalog();
|
||||
|
||||
$pages = PdfType::resolve(PdfDictionary::get($catalog, 'Pages'), $this->parser);
|
||||
$count = PdfType::resolve(PdfDictionary::get($pages, 'Count'), $this->parser);
|
||||
|
||||
$this->pageCount = PdfNumeric::ensure($count)->value;
|
||||
}
|
||||
|
||||
return $this->pageCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a page instance.
|
||||
*
|
||||
* @param int $pageNumber
|
||||
* @return Page
|
||||
*/
|
||||
public function getPage($pageNumber)
|
||||
{
|
||||
if (!\is_numeric($pageNumber)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Page number needs to be a number.'
|
||||
);
|
||||
}
|
||||
|
||||
if ($pageNumber < 1 || $pageNumber > $this->getPageCount()) {
|
||||
throw new \InvalidArgumentException(
|
||||
\sprintf(
|
||||
'Page number "%s" out of available page range (1 - %s)',
|
||||
$pageNumber,
|
||||
$this->getPageCount()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->readPages();
|
||||
|
||||
$page = $this->pages[$pageNumber - 1];
|
||||
|
||||
if ($page instanceof PdfIndirectObjectReference) {
|
||||
$readPages = function ($kids) use (&$readPages) {
|
||||
$kids = PdfArray::ensure($kids);
|
||||
|
||||
/** @noinspection LoopWhichDoesNotLoopInspection */
|
||||
foreach ($kids->value as $reference) {
|
||||
$reference = PdfIndirectObjectReference::ensure($reference);
|
||||
$object = $this->parser->getIndirectObject($reference->value);
|
||||
$type = PdfDictionary::get($object->value, 'Type');
|
||||
|
||||
if ($type->value === 'Pages') {
|
||||
return $readPages(PdfDictionary::get($object->value, 'Kids'));
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
throw new PdfReaderException(
|
||||
'Kids array cannot be empty.',
|
||||
PdfReaderException::KIDS_EMPTY
|
||||
);
|
||||
};
|
||||
|
||||
$page = $this->parser->getIndirectObject($page->value);
|
||||
$dict = PdfType::resolve($page, $this->parser);
|
||||
$type = PdfDictionary::get($dict, 'Type');
|
||||
if ($type->value === 'Pages') {
|
||||
$kids = PdfType::resolve(PdfDictionary::get($dict, 'Kids'), $this->parser);
|
||||
$page = $this->pages[$pageNumber - 1] = $readPages($kids);
|
||||
} else {
|
||||
$this->pages[$pageNumber - 1] = $page;
|
||||
}
|
||||
}
|
||||
|
||||
return new Page($page, $this->parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Walk the page tree and resolve all indirect objects of all pages.
|
||||
*/
|
||||
protected function readPages()
|
||||
{
|
||||
if (\count($this->pages) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$readPages = function ($kids, $count) use (&$readPages) {
|
||||
$kids = PdfArray::ensure($kids);
|
||||
$isLeaf = $count->value === \count($kids->value);
|
||||
|
||||
foreach ($kids->value as $reference) {
|
||||
$reference = PdfIndirectObjectReference::ensure($reference);
|
||||
|
||||
if ($isLeaf) {
|
||||
$this->pages[] = $reference;
|
||||
continue;
|
||||
}
|
||||
|
||||
$object = $this->parser->getIndirectObject($reference->value);
|
||||
$type = PdfDictionary::get($object->value, 'Type');
|
||||
|
||||
if ($type->value === 'Pages') {
|
||||
$readPages(PdfDictionary::get($object->value, 'Kids'), PdfDictionary::get($object->value, 'Count'));
|
||||
} else {
|
||||
$this->pages[] = $object;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$catalog = $this->parser->getCatalog();
|
||||
$pages = PdfType::resolve(PdfDictionary::get($catalog, 'Pages'), $this->parser);
|
||||
$count = PdfType::resolve(PdfDictionary::get($pages, 'Count'), $this->parser);
|
||||
$kids = PdfType::resolve(PdfDictionary::get($pages, 'Kids'), $this->parser);
|
||||
$readPages($kids, $count);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi\PdfReader;
|
||||
|
||||
use setasign\Fpdi\FpdiException;
|
||||
|
||||
/**
|
||||
* Exception for the pdf reader class
|
||||
*
|
||||
* @package setasign\Fpdi\PdfReader
|
||||
*/
|
||||
class PdfReaderException extends FpdiException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const KIDS_EMPTY = 0x0101;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const UNEXPECTED_DATA_TYPE = 0x0102;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const MISSING_DATA = 0x0103;
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
namespace setasign\Fpdi;
|
||||
|
||||
use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException;
|
||||
use setasign\Fpdi\PdfParser\Filter\AsciiHex;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfHexString;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfIndirectObject;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNull;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfNumeric;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfStream;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfString;
|
||||
use setasign\Fpdi\PdfParser\Type\PdfType;
|
||||
|
||||
/**
|
||||
* Class TcpdfFpdi
|
||||
*
|
||||
* This class let you import pages of existing PDF documents into a reusable structure for TCPDF.
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
*/
|
||||
class TcpdfFpdi extends \TCPDF
|
||||
{
|
||||
use FpdiTrait {
|
||||
writePdfType as fpdiWritePdfType;
|
||||
useImportedPage as fpdiUseImportedPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* FPDI version
|
||||
*
|
||||
* @string
|
||||
*/
|
||||
const VERSION = '2.0.0';
|
||||
|
||||
/**
|
||||
* A counter for template ids.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $templateId = 0;
|
||||
|
||||
/**
|
||||
* The currently used object number.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $currentObjectNumber;
|
||||
|
||||
/**
|
||||
* Get the next template id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getNextTemplateId()
|
||||
{
|
||||
return $this->templateId++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an imported page onto the page or another template.
|
||||
*
|
||||
* Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect
|
||||
* ratio.
|
||||
*
|
||||
* @param mixed $tpl The template id
|
||||
* @param float|int|array $x The abscissa of upper-left corner. Alternatively you could use an assoc array
|
||||
* with the keys "x", "y", "width", "height", "adjustPageSize".
|
||||
* @param float|int $y The ordinate of upper-left corner.
|
||||
* @param float|int|null $width The width.
|
||||
* @param float|int|null $height The height.
|
||||
* @param bool $adjustPageSize
|
||||
* @return array The size
|
||||
* @see FpdiTrait::getTemplateSize()
|
||||
*/
|
||||
public function useTemplate($tpl, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
|
||||
{
|
||||
return $this->useImportedPage($tpl, $x, $y, $width, $height, $adjustPageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an imported page onto the page.
|
||||
*
|
||||
* Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect
|
||||
* ratio.
|
||||
*
|
||||
* @param mixed $pageId The page id
|
||||
* @param float|int|array $x The abscissa of upper-left corner. Alternatively you could use an assoc array
|
||||
* with the keys "x", "y", "width", "height", "adjustPageSize".
|
||||
* @param float|int $y The ordinate of upper-left corner.
|
||||
* @param float|int|null $width The width.
|
||||
* @param float|int|null $height The height.
|
||||
* @param bool $adjustPageSize
|
||||
* @return array The size.
|
||||
* @see Fpdi::getTemplateSize()
|
||||
*/
|
||||
public function useImportedPage($pageId, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
|
||||
{
|
||||
$size = $this->fpdiUseImportedPage($pageId, $x, $y, $width, $height, $adjustPageSize);
|
||||
if ($this->inxobj) {
|
||||
$importedPage = $this->importedPages[$pageId];
|
||||
$this->xobjects[$this->xobjid]['importedPages'][$importedPage['id']] = $pageId;
|
||||
}
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of an imported page.
|
||||
*
|
||||
* Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect
|
||||
* ratio.
|
||||
*
|
||||
* @param mixed $tpl The template id
|
||||
* @param float|int|null $width The width.
|
||||
* @param float|int|null $height The height.
|
||||
* @return array|bool An array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P)
|
||||
*/
|
||||
public function getTemplateSize($tpl, $width = null, $height = null)
|
||||
{
|
||||
return $this->getImportedPageSize($tpl, $width, $height);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _getxobjectdict()
|
||||
{
|
||||
$out = parent::_getxobjectdict();
|
||||
|
||||
foreach ($this->importedPages as $key => $pageData) {
|
||||
$out .= '/' . $pageData['id'] . ' ' . $pageData['objectNumber'] . ' 0 R ';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _putxobjects()
|
||||
{
|
||||
foreach ($this->importedPages as $key => $pageData) {
|
||||
$this->currentObjectNumber = $this->_newobj();
|
||||
$this->importedPages[$key]['objectNumber'] = $this->currentObjectNumber;
|
||||
$this->currentReaderId = $pageData['readerId'];
|
||||
$this->writePdfType($pageData['stream']);
|
||||
$this->_put('endobj');
|
||||
}
|
||||
|
||||
foreach (\array_keys($this->readers) as $readerId) {
|
||||
$parser = $this->getPdfReader($readerId)->getParser();
|
||||
$this->currentReaderId = $readerId;
|
||||
|
||||
while (($objectNumber = \array_pop($this->objectsToCopy[$readerId])) !== null) {
|
||||
try {
|
||||
$object = $parser->getIndirectObject($objectNumber);
|
||||
|
||||
} catch (CrossReferenceException $e) {
|
||||
if ($e->getCode() === CrossReferenceException::OBJECT_NOT_FOUND) {
|
||||
$object = PdfIndirectObject::create($objectNumber, 0, new PdfNull());
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$this->writePdfType($object);
|
||||
}
|
||||
}
|
||||
|
||||
// let's prepare resources for imported pages in templates
|
||||
foreach ($this->xobjects as $xObjectId => $data) {
|
||||
if (!isset($data['importedPages'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($data['importedPages'] as $id => $pageKey) {
|
||||
$page = $this->importedPages[$pageKey];
|
||||
$this->xobjects[$xObjectId]['xobjects'][$id] = ['n' => $page['objectNumber']];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
parent::_putxobjects();
|
||||
$this->currentObjectNumber = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append content to the buffer of TCPDF.
|
||||
*
|
||||
* @param string $s
|
||||
* @param bool $newLine
|
||||
*/
|
||||
protected function _put($s, $newLine = true)
|
||||
{
|
||||
if ($newLine) {
|
||||
$this->setBuffer($s . "\n");
|
||||
} else {
|
||||
$this->setBuffer($s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin a new object and return the object number.
|
||||
*
|
||||
* @param int|string $objid Object ID (leave empty to get a new ID).
|
||||
* @return int object number
|
||||
*/
|
||||
protected function _newobj($objid = '')
|
||||
{
|
||||
$this->_out($this->_getobj($objid));
|
||||
return $this->n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a PdfType object to the resulting buffer.
|
||||
*
|
||||
* @param PdfType $value
|
||||
*/
|
||||
protected function writePdfType(PdfType $value)
|
||||
{
|
||||
if (!$this->encrypted) {
|
||||
$this->fpdiWritePdfType($value);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($value instanceof PdfString) {
|
||||
$string = PdfString::unescape($value->value);
|
||||
$string = $this->_encrypt_data($this->currentObjectNumber, $string);
|
||||
$value->value = \TCPDF_STATIC::_escape($string);
|
||||
|
||||
} elseif ($value instanceof PdfHexString) {
|
||||
$filter = new AsciiHex();
|
||||
$string = $filter->decode($value->value);
|
||||
$string = $this->_encrypt_data($this->currentObjectNumber, $string);
|
||||
$value->value = $filter->encode($string, true);
|
||||
|
||||
} elseif ($value instanceof PdfStream) {
|
||||
$stream = $value->getStream();
|
||||
$stream = $this->_encrypt_data($this->currentObjectNumber, $stream);
|
||||
$dictionary = $value->value;
|
||||
$dictionary->value['Length'] = PdfNumeric::create(\strlen($stream));
|
||||
$value = PdfStream::create($dictionary, $stream);
|
||||
|
||||
} elseif ($value instanceof PdfIndirectObject) {
|
||||
/**
|
||||
* @var $value PdfIndirectObject
|
||||
*/
|
||||
$this->currentObjectNumber = $this->objectMap[$this->currentReaderId][$value->objectNumber];
|
||||
}
|
||||
|
||||
$this->fpdiWritePdfType($value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of FPDI
|
||||
*
|
||||
* @package setasign\Fpdi
|
||||
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
spl_autoload_register(function ($class) {
|
||||
if (strpos($class, 'setasign\Fpdi\\') === 0) {
|
||||
$filename = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 14)) . '.php';
|
||||
$fullpath = __DIR__ . DIRECTORY_SEPARATOR . $filename;
|
||||
|
||||
if (file_exists($fullpath)) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
require_once $fullpath;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
//namespace PHPMathParser;
|
||||
|
||||
class WCJ_Parenthesis extends WCJ_TerminalExpression {
|
||||
|
||||
protected $precedence = 6;
|
||||
|
||||
public function operate(WCJ_Stack $stack) {
|
||||
}
|
||||
|
||||
public function getPrecedence() {
|
||||
return $this->precedence;
|
||||
}
|
||||
|
||||
public function isNoOp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isParenthesis() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isOpen() {
|
||||
return $this->value == '(';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WCJ_Number extends WCJ_TerminalExpression {
|
||||
|
||||
public function operate(WCJ_Stack $stack) {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract class WCJ_Operator extends WCJ_TerminalExpression {
|
||||
|
||||
protected $precedence = 0;
|
||||
protected $leftAssoc = true;
|
||||
|
||||
public function getPrecedence() {
|
||||
return $this->precedence;
|
||||
}
|
||||
|
||||
public function isLeftAssoc() {
|
||||
return $this->leftAssoc;
|
||||
}
|
||||
|
||||
public function isOperator() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WCJ_Addition extends WCJ_Operator {
|
||||
|
||||
protected $precedence = 4;
|
||||
|
||||
public function operate(WCJ_Stack $stack) {
|
||||
return $stack->pop()->operate($stack) + $stack->pop()->operate($stack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WCJ_Subtraction extends WCJ_Operator {
|
||||
|
||||
protected $precedence = 4;
|
||||
|
||||
public function operate(WCJ_Stack $stack) {
|
||||
$left = $stack->pop()->operate($stack);
|
||||
$right = $stack->pop()->operate($stack);
|
||||
return $right - $left;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WCJ_Multiplication extends WCJ_Operator {
|
||||
|
||||
protected $precedence = 5;
|
||||
|
||||
public function operate(WCJ_Stack $stack) {
|
||||
return $stack->pop()->operate($stack) * $stack->pop()->operate($stack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WCJ_Division extends WCJ_Operator {
|
||||
|
||||
protected $precedence = 5;
|
||||
|
||||
public function operate(WCJ_Stack $stack) {
|
||||
$left = $stack->pop()->operate($stack);
|
||||
$right = $stack->pop()->operate($stack);
|
||||
return $right / $left;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WCJ_Power extends WCJ_Operator {
|
||||
|
||||
protected $precedence = 5;
|
||||
|
||||
public function operate(WCJ_Stack $stack) {
|
||||
$left = $stack->pop()->operate($stack);
|
||||
$right = $stack->pop()->operate($stack);
|
||||
return pow($left,$right);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
//namespace PHPMathParser;
|
||||
|
||||
require_once 'Stack.php';
|
||||
require_once 'TerminalExpression.php';
|
||||
require_once 'Expressions.php';
|
||||
|
||||
class WCJ_Math {
|
||||
|
||||
protected $variables = array();
|
||||
|
||||
public function evaluate($string) {
|
||||
$stack = $this->parse($string);
|
||||
return $this->run($stack);
|
||||
}
|
||||
|
||||
public function parse($string) {
|
||||
$tokens = $this->tokenize($string);
|
||||
$output = new WCJ_Stack();
|
||||
$operators = new WCJ_Stack();
|
||||
foreach ($tokens as $token) {
|
||||
$token = $this->extractVariables($token);
|
||||
$expression = WCJ_TerminalExpression::factory($token);
|
||||
if ($expression->isOperator()) {
|
||||
$this->parseOperator($expression, $output, $operators);
|
||||
} elseif ($expression->isParenthesis()) {
|
||||
$this->parseParenthesis($expression, $output, $operators);
|
||||
} else {
|
||||
$output->push($expression);
|
||||
}
|
||||
}
|
||||
while (($op = $operators->pop())) {
|
||||
if ($op->isParenthesis()) {
|
||||
throw new RuntimeException('Mismatched Parenthesis');
|
||||
}
|
||||
$output->push($op);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function registerVariable($name, $value) {
|
||||
$this->variables[$name] = $value;
|
||||
}
|
||||
|
||||
public function run(WCJ_Stack $stack) {
|
||||
while (($operator = $stack->pop()) && $operator->isOperator()) {
|
||||
$value = $operator->operate($stack);
|
||||
if (!is_null($value)) {
|
||||
$stack->push(WCJ_TerminalExpression::factory($value));
|
||||
}
|
||||
}
|
||||
return $operator ? $operator->render() : $this->render($stack);
|
||||
}
|
||||
|
||||
protected function extractVariables($token) {
|
||||
if ($token[0] == '$') {
|
||||
$key = substr($token, 1);
|
||||
return isset($this->variables[$key]) ? $this->variables[$key] : 0;
|
||||
}
|
||||
return $token;
|
||||
}
|
||||
|
||||
protected function render(WCJ_Stack $stack) {
|
||||
$output = '';
|
||||
while (($el = $stack->pop())) {
|
||||
$output .= $el->render();
|
||||
}
|
||||
if ($output) {
|
||||
return $output;
|
||||
}
|
||||
throw new RuntimeException('Could not render output');
|
||||
}
|
||||
|
||||
protected function parseParenthesis(WCJ_TerminalExpression $expression, WCJ_Stack $output, WCJ_Stack $operators) {
|
||||
if ($expression->isOpen()) {
|
||||
$operators->push($expression);
|
||||
} else {
|
||||
$clean = false;
|
||||
while (($end = $operators->pop())) {
|
||||
if ($end->isParenthesis()) {
|
||||
$clean = true;
|
||||
break;
|
||||
} else {
|
||||
$output->push($end);
|
||||
}
|
||||
}
|
||||
if (!$clean) {
|
||||
throw new RuntimeException('Mismatched Parenthesis');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseOperator(WCJ_TerminalExpression $expression, WCJ_Stack $output, WCJ_Stack $operators) {
|
||||
$end = $operators->poke();
|
||||
if (!$end) {
|
||||
$operators->push($expression);
|
||||
} elseif ($end->isOperator()) {
|
||||
do {
|
||||
if ($expression->isLeftAssoc() && $expression->getPrecedence() <= $end->getPrecedence()) {
|
||||
$output->push($operators->pop());
|
||||
} elseif (!$expression->isLeftAssoc() && $expression->getPrecedence() < $end->getPrecedence()) {
|
||||
$output->push($operators->pop());
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (($end = $operators->poke()) && $end->isOperator());
|
||||
$operators->push($expression);
|
||||
} else {
|
||||
$operators->push($expression);
|
||||
}
|
||||
}
|
||||
|
||||
protected function tokenize($string) {
|
||||
$parts = preg_split('((\f+|\+|-|\(|\)|\*|\^|/)|\s+)', $string, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
||||
$parts = array_map('trim', $parts);
|
||||
return $parts;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
//namespace PHPMathParser;
|
||||
|
||||
class WCJ_Stack {
|
||||
|
||||
protected $data = array();
|
||||
|
||||
public function push($element) {
|
||||
$this->data[] = $element;
|
||||
}
|
||||
|
||||
public function poke() {
|
||||
return end($this->data);
|
||||
}
|
||||
|
||||
public function pop() {
|
||||
return array_pop($this->data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
//namespace PHPMathParser;
|
||||
|
||||
abstract class WCJ_TerminalExpression {
|
||||
|
||||
protected $value = '';
|
||||
|
||||
public function __construct($value) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public static function factory($value) {
|
||||
|
||||
// var_dump($value);
|
||||
if (is_object($value) && $value instanceof WCJ_TerminalExpression) {
|
||||
return $value;
|
||||
} elseif (is_numeric($value)) {
|
||||
return new WCJ_Number($value);
|
||||
} elseif ($value == '+') {
|
||||
return new WCJ_Addition($value);
|
||||
} elseif ($value == '-') {
|
||||
return new WCJ_Subtraction($value);
|
||||
} elseif ($value == '*') {
|
||||
return new WCJ_Multiplication($value);
|
||||
} elseif ($value == '/') {
|
||||
return new WCJ_Division($value);
|
||||
} elseif (in_array($value, array('(', ')'))) {
|
||||
return new WCJ_Parenthesis($value);
|
||||
} elseif ($value == '^') {
|
||||
return new WCJ_Power($value);
|
||||
}
|
||||
throw new Exception('Undefined Value ' . $value);
|
||||
}
|
||||
|
||||
abstract public function operate(WCJ_Stack $stack);
|
||||
|
||||
public function isOperator() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isParenthesis() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isNoOp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,858 @@
|
||||
**********************************************************************
|
||||
* TCPDF LICENSE
|
||||
**********************************************************************
|
||||
|
||||
TCPDF is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
@@ -0,0 +1,84 @@
|
||||
# TCPDF
|
||||
*PHP PDF Library*
|
||||
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_donations¤cy_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20TCPDF%20project)
|
||||
*Please consider supporting this project by making a donation via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations¤cy_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20TCPDF%20project)*
|
||||
|
||||
* **category** Library
|
||||
* **author** Nicola Asuni <info@tecnick.com>
|
||||
* **copyright** 2002-2016 Nicola Asuni - Tecnick.com LTD
|
||||
* **license** http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* **link** http://www.tcpdf.org
|
||||
* **source** https://github.com/tecnickcom/TCPDF
|
||||
|
||||
|
||||
## IMPORTANT
|
||||
A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support.
|
||||
This version should be considered obsolete, new projects should use the new version as soon it will become stable.
|
||||
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
PHP library for generating PDF documents on-the-fly.
|
||||
|
||||
### Main Features:
|
||||
* no external libraries are required for the basic functions;
|
||||
* all standard page formats, custom page formats, custom margins and units of measure;
|
||||
* UTF-8 Unicode and Right-To-Left languages;
|
||||
* TrueTypeUnicode, OpenTypeUnicode v1, TrueType, OpenType v1, Type1 and CID-0 fonts;
|
||||
* font subsetting;
|
||||
* methods to publish some XHTML + CSS code, Javascript and Forms;
|
||||
* images, graphic (geometric figures) and transformation methods;
|
||||
* supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/script/formats.php)
|
||||
* 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extension, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix, QR-Code, PDF417;
|
||||
* JPEG and PNG ICC profiles, Grayscale, RGB, CMYK, Spot Colors and Transparencies;
|
||||
* automatic page header and footer management;
|
||||
* document encryption up to 256 bit and digital signature certifications;
|
||||
* transactions to UNDO commands;
|
||||
* PDF annotations, including links, text and file attachments;
|
||||
* text rendering modes (fill, stroke and clipping);
|
||||
* multiple columns mode;
|
||||
* no-write page regions;
|
||||
* bookmarks, named destinations and table of content;
|
||||
* text hyphenation;
|
||||
* text stretching and spacing (tracking);
|
||||
* automatic page break, line break and text alignments including justification;
|
||||
* automatic page numbering and page groups;
|
||||
* move and delete pages;
|
||||
* page compression (requires php-zlib extension);
|
||||
* XOBject Templates;
|
||||
* Layers and object visibility.
|
||||
* PDF/A-1b support.
|
||||
|
||||
### Third party fonts:
|
||||
|
||||
This library may include third party font files released with different licenses.
|
||||
|
||||
All the PHP files on the fonts directory are subject to the general TCPDF license (GNU-LGPLv3),
|
||||
they do not contain any binary data but just a description of the general properties of a particular font.
|
||||
These files can be also generated on the fly using the font utilities and TCPDF methods.
|
||||
|
||||
All the original binary TTF font files have been renamed for compatibility with TCPDF and compressed using the gzcompress PHP function that uses the ZLIB data format (.z files).
|
||||
|
||||
The binary files (.z) that begins with the prefix "free" have been extracted from the GNU FreeFont collection (GNU-GPLv3).
|
||||
The binary files (.z) that begins with the prefix "pdfa" have been derived from the GNU FreeFont, so they are subject to the same license.
|
||||
For the details of Copyright, License and other information, please check the files inside the directory fonts/freefont-20120503
|
||||
Link : http://www.gnu.org/software/freefont/
|
||||
|
||||
The binary files (.z) that begins with the prefix "dejavu" have been extracted from the DejaVu fonts 2.33 (Bitstream) collection.
|
||||
For the details of Copyright, License and other information, please check the files inside the directory fonts/dejavu-fonts-ttf-2.33
|
||||
Link : http://dejavu-fonts.org
|
||||
|
||||
The binary files (.z) that begins with the prefix "ae" have been extracted from the Arabeyes.org collection (GNU-GPLv2).
|
||||
Link : http://projects.arabeyes.org/
|
||||
|
||||
### ICC profile:
|
||||
|
||||
TCPDF includes the sRGB.icc profile from the icc-profiles-free Debian package:
|
||||
https://packages.debian.org/source/stable/icc-profiles-free
|
||||
|
||||
|
||||
## Developer(s) Contact
|
||||
|
||||
* Nicola Asuni <info@tecnick.com>
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "tecnickcom/tcpdf",
|
||||
"version": "6.2.13",
|
||||
"homepage": "http://www.tcpdf.org/",
|
||||
"type": "library",
|
||||
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
|
||||
"keywords": ["PDF","tcpdf","PDFD32000-2008","qrcode","datamatrix","pdf417","barcodes"],
|
||||
"license": "LGPLv3",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicola Asuni",
|
||||
"email": "info@tecnick.com",
|
||||
"homepage": "http://nicolaasuni.tecnick.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"config",
|
||||
"include",
|
||||
"tcpdf.php",
|
||||
"tcpdf_parser.php",
|
||||
"tcpdf_import.php",
|
||||
"tcpdf_barcodes_1d.php",
|
||||
"tcpdf_barcodes_2d.php",
|
||||
"include/tcpdf_colors.php",
|
||||
"include/tcpdf_filters.php",
|
||||
"include/tcpdf_font_data.php",
|
||||
"include/tcpdf_fonts.php",
|
||||
"include/tcpdf_images.php",
|
||||
"include/tcpdf_static.php",
|
||||
"include/barcodes/datamatrix.php",
|
||||
"include/barcodes/pdf417.php",
|
||||
"include/barcodes/qrcode.php"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_config.php
|
||||
// Begin : 2004-06-11
|
||||
// Last Update : 2014-12-11
|
||||
//
|
||||
// Description : Configuration file for TCPDF.
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2004-2014 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with TCPDF. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* Configuration file for TCPDF.
|
||||
* @author Nicola Asuni
|
||||
* @package com.tecnick.tcpdf
|
||||
* @version 4.9.005
|
||||
* @since 2004-10-27
|
||||
*/
|
||||
|
||||
// IMPORTANT:
|
||||
// If you define the constant K_TCPDF_EXTERNAL_CONFIG, all the following settings will be ignored.
|
||||
// If you use the tcpdf_autoconfig.php, then you can overwrite some values here.
|
||||
|
||||
|
||||
/**
|
||||
* Installation path (/var/www/tcpdf/).
|
||||
* By default it is automatically calculated but you can also set it as a fixed string to improve performances.
|
||||
*/
|
||||
//define ('K_PATH_MAIN', '');
|
||||
|
||||
/**
|
||||
* URL path to tcpdf installation folder (http://localhost/tcpdf/).
|
||||
* By default it is automatically set but you can also set it as a fixed string to improve performances.
|
||||
*/
|
||||
//define ('K_PATH_URL', '');
|
||||
|
||||
/**
|
||||
* Path for PDF fonts.
|
||||
* By default it is automatically set but you can also set it as a fixed string to improve performances.
|
||||
*/
|
||||
//define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/');
|
||||
|
||||
/**
|
||||
* Default images directory.
|
||||
* By default it is automatically set but you can also set it as a fixed string to improve performances.
|
||||
*/
|
||||
//define ('K_PATH_IMAGES', '');
|
||||
|
||||
/**
|
||||
* Deafult image logo used be the default Header() method.
|
||||
* Please set here your own logo or an empty string to disable it.
|
||||
*/
|
||||
//define ('PDF_HEADER_LOGO', '');
|
||||
|
||||
/**
|
||||
* Header logo image width in user units.
|
||||
*/
|
||||
//define ('PDF_HEADER_LOGO_WIDTH', 0);
|
||||
|
||||
/**
|
||||
* Cache directory for temporary files (full path).
|
||||
*/
|
||||
//define ('K_PATH_CACHE', '/tmp/');
|
||||
|
||||
/**
|
||||
* Generic name for a blank image.
|
||||
*/
|
||||
define ('K_BLANK_IMAGE', '_blank.png');
|
||||
|
||||
/**
|
||||
* Page format.
|
||||
*/
|
||||
define ('PDF_PAGE_FORMAT', 'A4');
|
||||
|
||||
/**
|
||||
* Page orientation (P=portrait, L=landscape).
|
||||
*/
|
||||
define ('PDF_PAGE_ORIENTATION', 'P');
|
||||
|
||||
/**
|
||||
* Document creator.
|
||||
*/
|
||||
define ('PDF_CREATOR', 'TCPDF');
|
||||
|
||||
/**
|
||||
* Document author.
|
||||
*/
|
||||
define ('PDF_AUTHOR', 'TCPDF');
|
||||
|
||||
/**
|
||||
* Header title.
|
||||
*/
|
||||
define ('PDF_HEADER_TITLE', 'TCPDF Example');
|
||||
|
||||
/**
|
||||
* Header description string.
|
||||
*/
|
||||
define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org");
|
||||
|
||||
/**
|
||||
* Document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch].
|
||||
*/
|
||||
define ('PDF_UNIT', 'mm');
|
||||
|
||||
/**
|
||||
* Header margin.
|
||||
*/
|
||||
define ('PDF_MARGIN_HEADER', 5);
|
||||
|
||||
/**
|
||||
* Footer margin.
|
||||
*/
|
||||
define ('PDF_MARGIN_FOOTER', 10);
|
||||
|
||||
/**
|
||||
* Top margin.
|
||||
*/
|
||||
define ('PDF_MARGIN_TOP', 27);
|
||||
|
||||
/**
|
||||
* Bottom margin.
|
||||
*/
|
||||
define ('PDF_MARGIN_BOTTOM', 25);
|
||||
|
||||
/**
|
||||
* Left margin.
|
||||
*/
|
||||
define ('PDF_MARGIN_LEFT', 15);
|
||||
|
||||
/**
|
||||
* Right margin.
|
||||
*/
|
||||
define ('PDF_MARGIN_RIGHT', 15);
|
||||
|
||||
/**
|
||||
* Default main font name.
|
||||
*/
|
||||
define ('PDF_FONT_NAME_MAIN', 'helvetica');
|
||||
|
||||
/**
|
||||
* Default main font size.
|
||||
*/
|
||||
define ('PDF_FONT_SIZE_MAIN', 10);
|
||||
|
||||
/**
|
||||
* Default data font name.
|
||||
*/
|
||||
define ('PDF_FONT_NAME_DATA', 'helvetica');
|
||||
|
||||
/**
|
||||
* Default data font size.
|
||||
*/
|
||||
define ('PDF_FONT_SIZE_DATA', 8);
|
||||
|
||||
/**
|
||||
* Default monospaced font name.
|
||||
*/
|
||||
define ('PDF_FONT_MONOSPACED', 'courier');
|
||||
|
||||
/**
|
||||
* Ratio used to adjust the conversion of pixels to user units.
|
||||
*/
|
||||
define ('PDF_IMAGE_SCALE_RATIO', 1.25);
|
||||
|
||||
/**
|
||||
* Magnification factor for titles.
|
||||
*/
|
||||
define('HEAD_MAGNIFICATION', 1.1);
|
||||
|
||||
/**
|
||||
* Height of cell respect font height.
|
||||
*/
|
||||
define('K_CELL_HEIGHT_RATIO', 1.25);
|
||||
|
||||
/**
|
||||
* Title magnification respect main font size.
|
||||
*/
|
||||
define('K_TITLE_MAGNIFICATION', 1.3);
|
||||
|
||||
/**
|
||||
* Reduction factor for small font.
|
||||
*/
|
||||
define('K_SMALL_RATIO', 2/3);
|
||||
|
||||
/**
|
||||
* Set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language.
|
||||
*/
|
||||
define('K_THAI_TOPCHARS', true);
|
||||
|
||||
/**
|
||||
* If true allows to call TCPDF methods using HTML syntax
|
||||
* IMPORTANT: For security reason, disable this feature if you are printing user HTML content.
|
||||
*/
|
||||
/*
|
||||
* Booster modification (Algoritmika)
|
||||
*
|
||||
* @version 3.4.4
|
||||
* @since 3.4.4
|
||||
*/
|
||||
//define('K_TCPDF_CALLS_IN_HTML', false);
|
||||
define( 'K_TCPDF_CALLS_IN_HTML', true );
|
||||
|
||||
/**
|
||||
* If true and PHP version is greater than 5, then the Error() method throw new exception instead of terminating the execution.
|
||||
*/
|
||||
define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
|
||||
|
||||
/**
|
||||
* Default timezone for datetime functions
|
||||
*/
|
||||
define('K_TIMEZONE', 'UTC');
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Courier';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=600;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>33,'FontBBox'=>'[-23 -250 715 805]','ItalicAngle'=>0,'Ascent'=>805,'Descent'=>-250,'Leading'=>0,'CapHeight'=>562,'XHeight'=>426,'StemV'=>51,'StemH'=>51,'AvgWidth'=>600,'MaxWidth'=>600,'MissingWidth'=>600);
|
||||
$cw=array(0=>600,1=>600,2=>600,3=>600,4=>600,5=>600,6=>600,7=>600,8=>600,9=>600,10=>600,11=>600,12=>600,13=>600,14=>600,15=>600,16=>600,17=>600,18=>600,19=>600,20=>600,21=>600,22=>600,23=>600,24=>600,25=>600,26=>600,27=>600,28=>600,29=>600,30=>600,31=>600,32=>600,33=>600,34=>600,35=>600,36=>600,37=>600,38=>600,39=>600,40=>600,41=>600,42=>600,43=>600,44=>600,45=>600,46=>600,47=>600,48=>600,49=>600,50=>600,51=>600,52=>600,53=>600,54=>600,55=>600,56=>600,57=>600,58=>600,59=>600,60=>600,61=>600,62=>600,63=>600,64=>600,65=>600,66=>600,67=>600,68=>600,69=>600,70=>600,71=>600,72=>600,73=>600,74=>600,75=>600,76=>600,77=>600,78=>600,79=>600,80=>600,81=>600,82=>600,83=>600,84=>600,85=>600,86=>600,87=>600,88=>600,89=>600,90=>600,91=>600,92=>600,93=>600,94=>600,95=>600,96=>600,97=>600,98=>600,99=>600,100=>600,101=>600,102=>600,103=>600,104=>600,105=>600,106=>600,107=>600,108=>600,109=>600,110=>600,111=>600,112=>600,113=>600,114=>600,115=>600,116=>600,117=>600,118=>600,119=>600,120=>600,121=>600,122=>600,123=>600,124=>600,125=>600,126=>600,127=>600,128=>600,129=>600,130=>600,131=>600,132=>600,133=>600,134=>600,135=>600,136=>600,137=>600,138=>600,139=>600,140=>600,141=>600,142=>600,143=>600,144=>600,145=>600,146=>600,147=>600,148=>600,149=>600,150=>600,151=>600,152=>600,153=>600,154=>600,155=>600,156=>600,157=>600,158=>600,159=>600,160=>600,161=>600,162=>600,163=>600,164=>600,165=>600,166=>600,167=>600,168=>600,169=>600,170=>600,171=>600,172=>600,173=>600,174=>600,175=>600,176=>600,177=>600,178=>600,179=>600,180=>600,181=>600,182=>600,183=>600,184=>600,185=>600,186=>600,187=>600,188=>600,189=>600,190=>600,191=>600,192=>600,193=>600,194=>600,195=>600,196=>600,197=>600,198=>600,199=>600,200=>600,201=>600,202=>600,203=>600,204=>600,205=>600,206=>600,207=>600,208=>600,209=>600,210=>600,211=>600,212=>600,213=>600,214=>600,215=>600,216=>600,217=>600,218=>600,219=>600,220=>600,221=>600,222=>600,223=>600,224=>600,225=>600,226=>600,227=>600,228=>600,229=>600,230=>600,231=>600,232=>600,233=>600,234=>600,235=>600,236=>600,237=>600,238=>600,239=>600,240=>600,241=>600,242=>600,243=>600,244=>600,245=>600,246=>600,247=>600,248=>600,249=>600,250=>600,251=>600,252=>600,253=>600,254=>600,255=>600);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Courier-Bold';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=600;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>33,'FontBBox'=>'[-113 -250 749 801]','ItalicAngle'=>0,'Ascent'=>801,'Descent'=>-250,'Leading'=>0,'CapHeight'=>562,'XHeight'=>439,'StemV'=>106,'StemH'=>84,'AvgWidth'=>600,'MaxWidth'=>600,'MissingWidth'=>600);
|
||||
$cw=array(0=>600,1=>600,2=>600,3=>600,4=>600,5=>600,6=>600,7=>600,8=>600,9=>600,10=>600,11=>600,12=>600,13=>600,14=>600,15=>600,16=>600,17=>600,18=>600,19=>600,20=>600,21=>600,22=>600,23=>600,24=>600,25=>600,26=>600,27=>600,28=>600,29=>600,30=>600,31=>600,32=>600,33=>600,34=>600,35=>600,36=>600,37=>600,38=>600,39=>600,40=>600,41=>600,42=>600,43=>600,44=>600,45=>600,46=>600,47=>600,48=>600,49=>600,50=>600,51=>600,52=>600,53=>600,54=>600,55=>600,56=>600,57=>600,58=>600,59=>600,60=>600,61=>600,62=>600,63=>600,64=>600,65=>600,66=>600,67=>600,68=>600,69=>600,70=>600,71=>600,72=>600,73=>600,74=>600,75=>600,76=>600,77=>600,78=>600,79=>600,80=>600,81=>600,82=>600,83=>600,84=>600,85=>600,86=>600,87=>600,88=>600,89=>600,90=>600,91=>600,92=>600,93=>600,94=>600,95=>600,96=>600,97=>600,98=>600,99=>600,100=>600,101=>600,102=>600,103=>600,104=>600,105=>600,106=>600,107=>600,108=>600,109=>600,110=>600,111=>600,112=>600,113=>600,114=>600,115=>600,116=>600,117=>600,118=>600,119=>600,120=>600,121=>600,122=>600,123=>600,124=>600,125=>600,126=>600,127=>600,128=>600,129=>600,130=>600,131=>600,132=>600,133=>600,134=>600,135=>600,136=>600,137=>600,138=>600,139=>600,140=>600,141=>600,142=>600,143=>600,144=>600,145=>600,146=>600,147=>600,148=>600,149=>600,150=>600,151=>600,152=>600,153=>600,154=>600,155=>600,156=>600,157=>600,158=>600,159=>600,160=>600,161=>600,162=>600,163=>600,164=>600,165=>600,166=>600,167=>600,168=>600,169=>600,170=>600,171=>600,172=>600,173=>600,174=>600,175=>600,176=>600,177=>600,178=>600,179=>600,180=>600,181=>600,182=>600,183=>600,184=>600,185=>600,186=>600,187=>600,188=>600,189=>600,190=>600,191=>600,192=>600,193=>600,194=>600,195=>600,196=>600,197=>600,198=>600,199=>600,200=>600,201=>600,202=>600,203=>600,204=>600,205=>600,206=>600,207=>600,208=>600,209=>600,210=>600,211=>600,212=>600,213=>600,214=>600,215=>600,216=>600,217=>600,218=>600,219=>600,220=>600,221=>600,222=>600,223=>600,224=>600,225=>600,226=>600,227=>600,228=>600,229=>600,230=>600,231=>600,232=>600,233=>600,234=>600,235=>600,236=>600,237=>600,238=>600,239=>600,240=>600,241=>600,242=>600,243=>600,244=>600,245=>600,246=>600,247=>600,248=>600,249=>600,250=>600,251=>600,252=>600,253=>600,254=>600,255=>600);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Courier-BoldOblique';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=600;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>97,'FontBBox'=>'[-57 -250 869 801]','ItalicAngle'=>-12,'Ascent'=>801,'Descent'=>-250,'Leading'=>0,'CapHeight'=>562,'XHeight'=>439,'StemV'=>106,'StemH'=>84,'AvgWidth'=>600,'MaxWidth'=>600,'MissingWidth'=>600);
|
||||
$cw=array(0=>600,1=>600,2=>600,3=>600,4=>600,5=>600,6=>600,7=>600,8=>600,9=>600,10=>600,11=>600,12=>600,13=>600,14=>600,15=>600,16=>600,17=>600,18=>600,19=>600,20=>600,21=>600,22=>600,23=>600,24=>600,25=>600,26=>600,27=>600,28=>600,29=>600,30=>600,31=>600,32=>600,33=>600,34=>600,35=>600,36=>600,37=>600,38=>600,39=>600,40=>600,41=>600,42=>600,43=>600,44=>600,45=>600,46=>600,47=>600,48=>600,49=>600,50=>600,51=>600,52=>600,53=>600,54=>600,55=>600,56=>600,57=>600,58=>600,59=>600,60=>600,61=>600,62=>600,63=>600,64=>600,65=>600,66=>600,67=>600,68=>600,69=>600,70=>600,71=>600,72=>600,73=>600,74=>600,75=>600,76=>600,77=>600,78=>600,79=>600,80=>600,81=>600,82=>600,83=>600,84=>600,85=>600,86=>600,87=>600,88=>600,89=>600,90=>600,91=>600,92=>600,93=>600,94=>600,95=>600,96=>600,97=>600,98=>600,99=>600,100=>600,101=>600,102=>600,103=>600,104=>600,105=>600,106=>600,107=>600,108=>600,109=>600,110=>600,111=>600,112=>600,113=>600,114=>600,115=>600,116=>600,117=>600,118=>600,119=>600,120=>600,121=>600,122=>600,123=>600,124=>600,125=>600,126=>600,127=>600,128=>600,129=>600,130=>600,131=>600,132=>600,133=>600,134=>600,135=>600,136=>600,137=>600,138=>600,139=>600,140=>600,141=>600,142=>600,143=>600,144=>600,145=>600,146=>600,147=>600,148=>600,149=>600,150=>600,151=>600,152=>600,153=>600,154=>600,155=>600,156=>600,157=>600,158=>600,159=>600,160=>600,161=>600,162=>600,163=>600,164=>600,165=>600,166=>600,167=>600,168=>600,169=>600,170=>600,171=>600,172=>600,173=>600,174=>600,175=>600,176=>600,177=>600,178=>600,179=>600,180=>600,181=>600,182=>600,183=>600,184=>600,185=>600,186=>600,187=>600,188=>600,189=>600,190=>600,191=>600,192=>600,193=>600,194=>600,195=>600,196=>600,197=>600,198=>600,199=>600,200=>600,201=>600,202=>600,203=>600,204=>600,205=>600,206=>600,207=>600,208=>600,209=>600,210=>600,211=>600,212=>600,213=>600,214=>600,215=>600,216=>600,217=>600,218=>600,219=>600,220=>600,221=>600,222=>600,223=>600,224=>600,225=>600,226=>600,227=>600,228=>600,229=>600,230=>600,231=>600,232=>600,233=>600,234=>600,235=>600,236=>600,237=>600,238=>600,239=>600,240=>600,241=>600,242=>600,243=>600,244=>600,245=>600,246=>600,247=>600,248=>600,249=>600,250=>600,251=>600,252=>600,253=>600,254=>600,255=>600);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Courier-Oblique';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=600;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>97,'FontBBox'=>'[-27 -250 849 805]','ItalicAngle'=>-12,'Ascent'=>805,'Descent'=>-250,'Leading'=>0,'CapHeight'=>562,'XHeight'=>426,'StemV'=>51,'StemH'=>51,'AvgWidth'=>600,'MaxWidth'=>600,'MissingWidth'=>600);
|
||||
$cw=array(0=>600,1=>600,2=>600,3=>600,4=>600,5=>600,6=>600,7=>600,8=>600,9=>600,10=>600,11=>600,12=>600,13=>600,14=>600,15=>600,16=>600,17=>600,18=>600,19=>600,20=>600,21=>600,22=>600,23=>600,24=>600,25=>600,26=>600,27=>600,28=>600,29=>600,30=>600,31=>600,32=>600,33=>600,34=>600,35=>600,36=>600,37=>600,38=>600,39=>600,40=>600,41=>600,42=>600,43=>600,44=>600,45=>600,46=>600,47=>600,48=>600,49=>600,50=>600,51=>600,52=>600,53=>600,54=>600,55=>600,56=>600,57=>600,58=>600,59=>600,60=>600,61=>600,62=>600,63=>600,64=>600,65=>600,66=>600,67=>600,68=>600,69=>600,70=>600,71=>600,72=>600,73=>600,74=>600,75=>600,76=>600,77=>600,78=>600,79=>600,80=>600,81=>600,82=>600,83=>600,84=>600,85=>600,86=>600,87=>600,88=>600,89=>600,90=>600,91=>600,92=>600,93=>600,94=>600,95=>600,96=>600,97=>600,98=>600,99=>600,100=>600,101=>600,102=>600,103=>600,104=>600,105=>600,106=>600,107=>600,108=>600,109=>600,110=>600,111=>600,112=>600,113=>600,114=>600,115=>600,116=>600,117=>600,118=>600,119=>600,120=>600,121=>600,122=>600,123=>600,124=>600,125=>600,126=>600,127=>600,128=>600,129=>600,130=>600,131=>600,132=>600,133=>600,134=>600,135=>600,136=>600,137=>600,138=>600,139=>600,140=>600,141=>600,142=>600,143=>600,144=>600,145=>600,146=>600,147=>600,148=>600,149=>600,150=>600,151=>600,152=>600,153=>600,154=>600,155=>600,156=>600,157=>600,158=>600,159=>600,160=>600,161=>600,162=>600,163=>600,164=>600,165=>600,166=>600,167=>600,168=>600,169=>600,170=>600,171=>600,172=>600,173=>600,174=>600,175=>600,176=>600,177=>600,178=>600,179=>600,180=>600,181=>600,182=>600,183=>600,184=>600,185=>600,186=>600,187=>600,188=>600,189=>600,190=>600,191=>600,192=>600,193=>600,194=>600,195=>600,196=>600,197=>600,198=>600,199=>600,200=>600,201=>600,202=>600,203=>600,204=>600,205=>600,206=>600,207=>600,208=>600,209=>600,210=>600,211=>600,212=>600,213=>600,214=>600,215=>600,216=>600,217=>600,218=>600,219=>600,220=>600,221=>600,222=>600,223=>600,224=>600,225=>600,226=>600,227=>600,228=>600,229=>600,230=>600,231=>600,232=>600,233=>600,234=>600,235=>600,236=>600,237=>600,238=>600,239=>600,240=>600,241=>600,242=>600,243=>600,244=>600,245=>600,246=>600,247=>600,248=>600,249=>600,250=>600,251=>600,252=>600,253=>600,254=>600,255=>600);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Helvetica';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=513;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>32,'FontBBox'=>'[-166 -225 1000 931]','ItalicAngle'=>0,'Ascent'=>931,'Descent'=>-225,'Leading'=>0,'CapHeight'=>718,'XHeight'=>523,'StemV'=>88,'StemH'=>76,'AvgWidth'=>513,'MaxWidth'=>1015,'MissingWidth'=>513);
|
||||
$cw=array(0=>500,1=>500,2=>500,3=>500,4=>500,5=>500,6=>500,7=>500,8=>500,9=>500,10=>500,11=>500,12=>500,13=>500,14=>500,15=>500,16=>500,17=>500,18=>500,19=>500,20=>500,21=>500,22=>500,23=>500,24=>500,25=>500,26=>500,27=>500,28=>500,29=>500,30=>500,31=>500,32=>278,33=>278,34=>355,35=>556,36=>556,37=>889,38=>667,39=>191,40=>333,41=>333,42=>389,43=>584,44=>278,45=>333,46=>278,47=>278,48=>556,49=>556,50=>556,51=>556,52=>556,53=>556,54=>556,55=>556,56=>556,57=>556,58=>278,59=>278,60=>584,61=>584,62=>584,63=>556,64=>1015,65=>667,66=>667,67=>722,68=>722,69=>667,70=>611,71=>778,72=>722,73=>278,74=>500,75=>667,76=>556,77=>833,78=>722,79=>778,80=>667,81=>778,82=>722,83=>667,84=>611,85=>722,86=>667,87=>944,88=>667,89=>667,90=>611,91=>278,92=>278,93=>277,94=>469,95=>556,96=>333,97=>556,98=>556,99=>500,100=>556,101=>556,102=>278,103=>556,104=>556,105=>222,106=>222,107=>500,108=>222,109=>833,110=>556,111=>556,112=>556,113=>556,114=>333,115=>500,116=>278,117=>556,118=>500,119=>722,120=>500,121=>500,122=>500,123=>334,124=>260,125=>334,126=>584,127=>500,128=>655,129=>500,130=>222,131=>278,132=>333,133=>1000,134=>556,135=>556,136=>333,137=>1000,138=>667,139=>250,140=>1000,141=>500,142=>611,143=>500,144=>500,145=>222,146=>221,147=>333,148=>333,149=>350,150=>556,151=>1000,152=>333,153=>1000,154=>500,155=>250,156=>938,157=>500,158=>500,159=>667,160=>278,161=>278,162=>556,163=>556,164=>556,165=>556,166=>260,167=>556,168=>333,169=>737,170=>370,171=>448,172=>584,173=>333,174=>737,175=>333,176=>606,177=>584,178=>350,179=>350,180=>333,181=>556,182=>537,183=>278,184=>333,185=>350,186=>365,187=>448,188=>869,189=>869,190=>879,191=>556,192=>667,193=>667,194=>667,195=>667,196=>667,197=>667,198=>1000,199=>722,200=>667,201=>667,202=>667,203=>667,204=>278,205=>278,206=>278,207=>278,208=>722,209=>722,210=>778,211=>778,212=>778,213=>778,214=>778,215=>584,216=>778,217=>722,218=>722,219=>722,220=>722,221=>667,222=>666,223=>611,224=>556,225=>556,226=>556,227=>556,228=>556,229=>556,230=>896,231=>500,232=>556,233=>556,234=>556,235=>556,236=>251,237=>251,238=>251,239=>251,240=>556,241=>556,242=>556,243=>556,244=>556,245=>556,246=>556,247=>584,248=>611,249=>556,250=>556,251=>556,252=>556,253=>500,254=>555,255=>500);
|
||||
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Helvetica-Bold';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=535;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>32,'FontBBox'=>'[-170 -228 1003 962]','ItalicAngle'=>0,'Ascent'=>962,'Descent'=>-228,'Leading'=>0,'CapHeight'=>718,'XHeight'=>532,'StemV'=>140,'StemH'=>118,'AvgWidth'=>535,'MaxWidth'=>1000,'MissingWidth'=>535);
|
||||
$cw=array(0=>278,1=>278,2=>278,3=>278,4=>278,5=>278,6=>278,7=>278,8=>278,9=>278,10=>278,11=>278,12=>278,13=>278,14=>278,15=>278,16=>278,17=>278,18=>278,19=>278,20=>278,21=>278,22=>278,23=>278,24=>278,25=>278,26=>278,27=>278,28=>278,29=>278,30=>278,31=>278,32=>278,33=>333,34=>474,35=>556,36=>556,37=>889,38=>722,39=>238,40=>333,41=>333,42=>389,43=>584,44=>278,45=>333,46=>278,47=>278,48=>556,49=>556,50=>556,51=>556,52=>556,53=>556,54=>556,55=>556,56=>556,57=>556,58=>333,59=>333,60=>584,61=>584,62=>584,63=>611,64=>975,65=>722,66=>722,67=>722,68=>722,69=>667,70=>611,71=>778,72=>722,73=>278,74=>556,75=>722,76=>611,77=>833,78=>722,79=>778,80=>667,81=>778,82=>722,83=>667,84=>611,85=>722,86=>667,87=>944,88=>667,89=>667,90=>611,91=>333,92=>278,93=>333,94=>584,95=>556,96=>333,97=>556,98=>611,99=>556,100=>611,101=>556,102=>333,103=>611,104=>611,105=>278,106=>278,107=>556,108=>278,109=>889,110=>611,111=>611,112=>611,113=>611,114=>389,115=>556,116=>333,117=>611,118=>556,119=>778,120=>556,121=>556,122=>500,123=>389,124=>280,125=>389,126=>584,127=>350,128=>556,129=>350,130=>278,131=>556,132=>500,133=>1000,134=>556,135=>556,136=>333,137=>1000,138=>667,139=>333,140=>1000,141=>350,142=>611,143=>350,144=>350,145=>278,146=>278,147=>500,148=>500,149=>350,150=>556,151=>1000,152=>333,153=>1000,154=>556,155=>333,156=>944,157=>350,158=>500,159=>667,160=>278,161=>333,162=>556,163=>556,164=>556,165=>556,166=>280,167=>556,168=>333,169=>737,170=>370,171=>556,172=>584,173=>333,174=>737,175=>333,176=>400,177=>584,178=>333,179=>333,180=>333,181=>611,182=>556,183=>278,184=>333,185=>333,186=>365,187=>556,188=>834,189=>834,190=>834,191=>611,192=>722,193=>722,194=>722,195=>722,196=>722,197=>722,198=>1000,199=>722,200=>667,201=>667,202=>667,203=>667,204=>278,205=>278,206=>278,207=>278,208=>722,209=>722,210=>778,211=>778,212=>778,213=>778,214=>778,215=>584,216=>778,217=>722,218=>722,219=>722,220=>722,221=>667,222=>667,223=>611,224=>556,225=>556,226=>556,227=>556,228=>556,229=>556,230=>889,231=>556,232=>556,233=>556,234=>556,235=>556,236=>278,237=>278,238=>278,239=>278,240=>611,241=>611,242=>611,243=>611,244=>611,245=>611,246=>611,247=>584,248=>611,249=>611,250=>611,251=>611,252=>611,253=>556,254=>611,255=>556);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Helvetica-BoldOblique';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=535;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>96,'FontBBox'=>'[-174 -228 1114 962]','ItalicAngle'=>-12,'Ascent'=>962,'Descent'=>-228,'Leading'=>0,'CapHeight'=>718,'XHeight'=>532,'StemV'=>140,'StemH'=>118,'AvgWidth'=>535,'MaxWidth'=>1000,'MissingWidth'=>535);
|
||||
$cw=array(0=>278,1=>278,2=>278,3=>278,4=>278,5=>278,6=>278,7=>278,8=>278,9=>278,10=>278,11=>278,12=>278,13=>278,14=>278,15=>278,16=>278,17=>278,18=>278,19=>278,20=>278,21=>278,22=>278,23=>278,24=>278,25=>278,26=>278,27=>278,28=>278,29=>278,30=>278,31=>278,32=>278,33=>333,34=>474,35=>556,36=>556,37=>889,38=>722,39=>238,40=>333,41=>333,42=>389,43=>584,44=>278,45=>333,46=>278,47=>278,48=>556,49=>556,50=>556,51=>556,52=>556,53=>556,54=>556,55=>556,56=>556,57=>556,58=>333,59=>333,60=>584,61=>584,62=>584,63=>611,64=>975,65=>722,66=>722,67=>722,68=>722,69=>667,70=>611,71=>778,72=>722,73=>278,74=>556,75=>722,76=>611,77=>833,78=>722,79=>778,80=>667,81=>778,82=>722,83=>667,84=>611,85=>722,86=>667,87=>944,88=>667,89=>667,90=>611,91=>333,92=>278,93=>333,94=>584,95=>556,96=>333,97=>556,98=>611,99=>556,100=>611,101=>556,102=>333,103=>611,104=>611,105=>278,106=>278,107=>556,108=>278,109=>889,110=>611,111=>611,112=>611,113=>611,114=>389,115=>556,116=>333,117=>611,118=>556,119=>778,120=>556,121=>556,122=>500,123=>389,124=>280,125=>389,126=>584,127=>350,128=>556,129=>350,130=>278,131=>556,132=>500,133=>1000,134=>556,135=>556,136=>333,137=>1000,138=>667,139=>333,140=>1000,141=>350,142=>611,143=>350,144=>350,145=>278,146=>278,147=>500,148=>500,149=>350,150=>556,151=>1000,152=>333,153=>1000,154=>556,155=>333,156=>944,157=>350,158=>500,159=>667,160=>278,161=>333,162=>556,163=>556,164=>556,165=>556,166=>280,167=>556,168=>333,169=>737,170=>370,171=>556,172=>584,173=>333,174=>737,175=>333,176=>400,177=>584,178=>333,179=>333,180=>333,181=>611,182=>556,183=>278,184=>333,185=>333,186=>365,187=>556,188=>834,189=>834,190=>834,191=>611,192=>722,193=>722,194=>722,195=>722,196=>722,197=>722,198=>1000,199=>722,200=>667,201=>667,202=>667,203=>667,204=>278,205=>278,206=>278,207=>278,208=>722,209=>722,210=>778,211=>778,212=>778,213=>778,214=>778,215=>584,216=>778,217=>722,218=>722,219=>722,220=>722,221=>667,222=>667,223=>611,224=>556,225=>556,226=>556,227=>556,228=>556,229=>556,230=>889,231=>556,232=>556,233=>556,234=>556,235=>556,236=>278,237=>278,238=>278,239=>278,240=>611,241=>611,242=>611,243=>611,244=>611,245=>611,246=>611,247=>584,248=>611,249=>611,250=>611,251=>611,252=>611,253=>556,254=>611,255=>556);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Helvetica-Oblique';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=513;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>96,'FontBBox'=>'[-170 -225 1116 931]','ItalicAngle'=>-12,'Ascent'=>931,'Descent'=>-225,'Leading'=>0,'CapHeight'=>718,'XHeight'=>523,'StemV'=>88,'StemH'=>76,'AvgWidth'=>513,'MaxWidth'=>1015,'MissingWidth'=>513);
|
||||
$cw=array(0=>278,1=>278,2=>278,3=>278,4=>278,5=>278,6=>278,7=>278,8=>278,9=>278,10=>278,11=>278,12=>278,13=>278,14=>278,15=>278,16=>278,17=>278,18=>278,19=>278,20=>278,21=>278,22=>278,23=>278,24=>278,25=>278,26=>278,27=>278,28=>278,29=>278,30=>278,31=>278,32=>278,33=>278,34=>355,35=>556,36=>556,37=>889,38=>667,39=>191,40=>333,41=>333,42=>389,43=>584,44=>278,45=>333,46=>278,47=>278,48=>556,49=>556,50=>556,51=>556,52=>556,53=>556,54=>556,55=>556,56=>556,57=>556,58=>278,59=>278,60=>584,61=>584,62=>584,63=>556,64=>1015,65=>667,66=>667,67=>722,68=>722,69=>667,70=>611,71=>778,72=>722,73=>278,74=>500,75=>667,76=>556,77=>833,78=>722,79=>778,80=>667,81=>778,82=>722,83=>667,84=>611,85=>722,86=>667,87=>944,88=>667,89=>667,90=>611,91=>278,92=>278,93=>278,94=>469,95=>556,96=>333,97=>556,98=>556,99=>500,100=>556,101=>556,102=>278,103=>556,104=>556,105=>222,106=>222,107=>500,108=>222,109=>833,110=>556,111=>556,112=>556,113=>556,114=>333,115=>500,116=>278,117=>556,118=>500,119=>722,120=>500,121=>500,122=>500,123=>334,124=>260,125=>334,126=>584,127=>350,128=>556,129=>350,130=>222,131=>556,132=>333,133=>1000,134=>556,135=>556,136=>333,137=>1000,138=>667,139=>333,140=>1000,141=>350,142=>611,143=>350,144=>350,145=>222,146=>222,147=>333,148=>333,149=>350,150=>556,151=>1000,152=>333,153=>1000,154=>500,155=>333,156=>944,157=>350,158=>500,159=>667,160=>278,161=>333,162=>556,163=>556,164=>556,165=>556,166=>260,167=>556,168=>333,169=>737,170=>370,171=>556,172=>584,173=>333,174=>737,175=>333,176=>400,177=>584,178=>333,179=>333,180=>333,181=>556,182=>537,183=>278,184=>333,185=>333,186=>365,187=>556,188=>834,189=>834,190=>834,191=>611,192=>667,193=>667,194=>667,195=>667,196=>667,197=>667,198=>1000,199=>722,200=>667,201=>667,202=>667,203=>667,204=>278,205=>278,206=>278,207=>278,208=>722,209=>722,210=>778,211=>778,212=>778,213=>778,214=>778,215=>584,216=>778,217=>722,218=>722,219=>722,220=>722,221=>667,222=>667,223=>611,224=>556,225=>556,226=>556,227=>556,228=>556,229=>556,230=>889,231=>500,232=>556,233=>556,234=>556,235=>556,236=>278,237=>278,238=>278,239=>278,240=>556,241=>556,242=>556,243=>556,244=>556,245=>556,246=>556,247=>584,248=>611,249=>556,250=>556,251=>556,252=>556,253=>500,254=>556,255=>500);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
$type = 'cidfont0';
|
||||
$name = 'STSongStd-Light-Acro';
|
||||
$displayname = 'STSong Light (Simp. Chinese)';
|
||||
$desc = array(
|
||||
'Ascent' => 752,
|
||||
'Descent' => -271,
|
||||
'CapHeight' => 737,
|
||||
'Flags' => 6,
|
||||
'FontBBox' => '[-25 -254 1000 880]',
|
||||
'ItalicAngle' => 0,
|
||||
'StemV' => 58,
|
||||
'Style' => '<< /Panose <000000000400000000000000> >>',
|
||||
);
|
||||
$cidinfo = array(
|
||||
'Registry' => 'Adobe',
|
||||
'Ordering' => 'GB1',
|
||||
'Supplement' => '2',
|
||||
);
|
||||
$enc = 'UniGB-UCS2-H';
|
||||
|
||||
// underline position, needs checking:
|
||||
$up = -130;
|
||||
$ut = 40;
|
||||
|
||||
$dw = 1000;
|
||||
$cw = array(
|
||||
32 => 207, 33 => 270, 34 => 342, 35 => 467, 36 => 462, 37 => 797, 38 => 710, 39 => 239, 40 => 374, 41 => 374,
|
||||
42 => 423, 43 => 605, 44 => 238, 45 => 375, 46 => 238, 47 => 334, 48 => 462, 49 => 462, 50 => 462, 51 => 462,
|
||||
52 => 462, 53 => 462, 54 => 462, 55 => 462, 56 => 462, 57 => 462, 58 => 238, 59 => 238, 60 => 605, 61 => 605,
|
||||
62 => 605, 63 => 344, 64 => 748, 65 => 684, 66 => 560, 67 => 695, 68 => 739, 69 => 563, 70 => 511, 71 => 729,
|
||||
72 => 793, 73 => 318, 74 => 312, 75 => 666, 76 => 526, 77 => 896, 78 => 758, 79 => 772, 80 => 544, 81 => 772,
|
||||
82 => 628, 83 => 465, 84 => 607, 85 => 753, 86 => 711, 87 => 972, 88 => 647, 89 => 620, 90 => 607, 91 => 374,
|
||||
92 => 333, 93 => 374, 94 => 606, 95 => 500, 96 => 239, 97 => 417, 98 => 503, 99 => 427, 100 => 529, 101 => 415,
|
||||
102 => 264, 103 => 444, 104 => 518, 105 => 241, 106 => 230, 107 => 495, 108 => 228, 109 => 793, 110 => 527, 111 => 524,
|
||||
112 => 524, 113 => 504, 114 => 338, 115 => 336, 116 => 277, 117 => 517, 118 => 450, 119 => 652, 120 => 466, 121 => 452,
|
||||
122 => 407, 123 => 370, 124 => 258, 125 => 370, 126 => 605
|
||||
);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Symbol';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=587;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>4,'FontBBox'=>'[-180 -293 1090 1010]','ItalicAngle'=>0,'Ascent'=>1010,'Descent'=>-293,'Leading'=>0,'CapHeight'=>1010,'StemV'=>85,'StemH'=>92,'AvgWidth'=>587,'MaxWidth'=>1042,'MissingWidth'=>587);
|
||||
$cw=array(0=>587,1=>587,2=>587,3=>587,4=>587,5=>587,6=>587,7=>587,8=>587,9=>587,10=>587,11=>587,12=>587,13=>587,14=>587,15=>587,16=>587,17=>587,18=>587,19=>587,20=>587,21=>587,22=>587,23=>587,24=>587,25=>587,26=>587,27=>587,28=>587,29=>587,30=>587,31=>587,32=>250,33=>333,34=>713,35=>500,36=>549,37=>833,38=>778,39=>439,40=>333,41=>333,42=>500,43=>549,44=>250,45=>549,46=>250,47=>278,48=>500,49=>500,50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>278,59=>278,60=>549,61=>549,62=>549,63=>444,64=>549,65=>722,66=>667,67=>722,68=>612,69=>611,70=>763,71=>603,72=>722,73=>333,74=>631,75=>722,76=>686,77=>889,78=>722,79=>722,80=>768,81=>741,82=>556,83=>592,84=>611,85=>690,86=>439,87=>768,88=>645,89=>795,90=>611,91=>333,92=>863,93=>333,94=>658,95=>500,96=>500,97=>631,98=>549,99=>549,100=>494,101=>439,102=>521,103=>411,104=>603,105=>329,106=>603,107=>549,108=>549,109=>576,110=>521,111=>549,112=>549,113=>521,114=>549,115=>603,116=>439,117=>576,118=>713,119=>686,120=>493,121=>686,122=>494,123=>480,124=>200,125=>480,126=>549,127=>587,128=>587,129=>587,130=>587,131=>587,132=>587,133=>587,134=>587,135=>587,136=>587,137=>587,138=>587,139=>587,140=>587,141=>587,142=>587,143=>587,144=>587,145=>587,146=>587,147=>587,148=>587,149=>587,150=>587,151=>587,152=>587,153=>587,154=>587,155=>587,156=>587,157=>587,158=>587,159=>587,160=>750,161=>620,162=>247,163=>549,164=>167,165=>713,166=>500,167=>753,168=>753,169=>753,170=>753,171=>1042,172=>987,173=>603,174=>987,175=>603,176=>400,177=>549,178=>411,179=>549,180=>549,181=>713,182=>494,183=>460,184=>549,185=>549,186=>549,187=>549,188=>1000,189=>603,190=>1000,191=>658,192=>823,193=>686,194=>795,195=>987,196=>768,197=>768,198=>823,199=>768,200=>768,201=>713,202=>713,203=>713,204=>713,205=>713,206=>713,207=>713,208=>768,209=>713,210=>790,211=>790,212=>890,213=>823,214=>549,215=>250,216=>713,217=>603,218=>603,219=>1042,220=>987,221=>603,222=>987,223=>603,224=>494,225=>329,226=>790,227=>790,228=>786,229=>713,230=>384,231=>384,232=>384,233=>384,234=>384,235=>384,236=>494,237=>494,238=>494,239=>494,240=>587,241=>329,242=>274,243=>686,244=>686,245=>686,246=>384,247=>384,248=>384,249=>384,250=>384,251=>384,252=>494,253=>494,254=>494,255=>587);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Times-Roman';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=495;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>32,'FontBBox'=>'[-168 -218 1000 898]','ItalicAngle'=>0,'Ascent'=>898,'Descent'=>-218,'Leading'=>0,'CapHeight'=>662,'XHeight'=>450,'StemV'=>84,'StemH'=>28,'AvgWidth'=>495,'MaxWidth'=>1000,'MissingWidth'=>495);
|
||||
$cw=array(0=>250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250,10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250,20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250,30=>250,31=>250,32=>250,33=>333,34=>408,35=>500,36=>500,37=>833,38=>778,39=>180,40=>333,41=>333,42=>500,43=>564,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>278,59=>278,60=>564,61=>564,62=>564,63=>444,64=>921,65=>722,66=>667,67=>667,68=>722,69=>611,70=>556,71=>722,72=>722,73=>333,74=>389,75=>722,76=>611,77=>889,78=>722,79=>722,80=>556,81=>722,82=>667,83=>556,84=>611,85=>722,86=>722,87=>944,88=>722,89=>722,90=>611,91=>333,92=>278,93=>333,94=>469,95=>500,96=>333,97=>444,98=>500,99=>444,100=>500,101=>444,102=>333,103=>500,104=>500,105=>278,106=>278,107=>500,108=>278,109=>778,110=>500,111=>500,112=>500,113=>500,114=>333,115=>389,116=>278,117=>500,118=>500,119=>722,120=>500,121=>500,122=>444,123=>480,124=>200,125=>480,126=>541,127=>350,128=>500,129=>350,130=>333,131=>500,132=>444,133=>1000,134=>500,135=>500,136=>333,137=>1000,138=>556,139=>333,140=>889,141=>350,142=>611,143=>350,144=>350,145=>333,146=>333,147=>444,148=>444,149=>350,150=>500,151=>1000,152=>333,153=>980,154=>389,155=>333,156=>722,157=>350,158=>444,159=>722,160=>250,161=>333,162=>500,163=>500,164=>500,165=>500,166=>200,167=>500,168=>333,169=>760,170=>276,171=>500,172=>564,173=>333,174=>760,175=>333,176=>400,177=>564,178=>300,179=>300,180=>333,181=>500,182=>453,183=>250,184=>333,185=>300,186=>310,187=>500,188=>750,189=>750,190=>750,191=>444,192=>722,193=>722,194=>722,195=>722,196=>722,197=>722,198=>889,199=>667,200=>611,201=>611,202=>611,203=>611,204=>333,205=>333,206=>333,207=>333,208=>722,209=>722,210=>722,211=>722,212=>722,213=>722,214=>722,215=>564,216=>722,217=>722,218=>722,219=>722,220=>722,221=>722,222=>556,223=>500,224=>444,225=>444,226=>444,227=>444,228=>444,229=>444,230=>667,231=>444,232=>444,233=>444,234=>444,235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>500,242=>500,243=>500,244=>500,245=>500,246=>500,247=>564,248=>500,249=>500,250=>500,251=>500,252=>500,253=>500,254=>500,255=>500);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Times-Bold';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=516;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>32,'FontBBox'=>'[-168 -218 1000 935]','ItalicAngle'=>0,'Ascent'=>935,'Descent'=>-218,'Leading'=>0,'CapHeight'=>676,'XHeight'=>461,'StemV'=>139,'StemH'=>44,'AvgWidth'=>516,'MaxWidth'=>1000,'MissingWidth'=>516);
|
||||
$cw=array(0=>250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250,10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250,20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250,30=>250,31=>250,32=>250,33=>333,34=>555,35=>500,36=>500,37=>1000,38=>833,39=>278,40=>333,41=>333,42=>500,43=>570,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333,60=>570,61=>570,62=>570,63=>500,64=>930,65=>722,66=>667,67=>722,68=>722,69=>667,70=>611,71=>778,72=>778,73=>389,74=>500,75=>778,76=>667,77=>944,78=>722,79=>778,80=>611,81=>778,82=>722,83=>556,84=>667,85=>722,86=>722,87=>1000,88=>722,89=>722,90=>667,91=>333,92=>278,93=>333,94=>581,95=>500,96=>333,97=>500,98=>556,99=>444,100=>556,101=>444,102=>333,103=>500,104=>556,105=>278,106=>333,107=>556,108=>278,109=>833,110=>556,111=>500,112=>556,113=>556,114=>444,115=>389,116=>333,117=>556,118=>500,119=>722,120=>500,121=>500,122=>444,123=>394,124=>220,125=>394,126=>520,127=>350,128=>500,129=>350,130=>333,131=>500,132=>500,133=>1000,134=>500,135=>500,136=>333,137=>1000,138=>556,139=>333,140=>1000,141=>350,142=>667,143=>350,144=>350,145=>333,146=>333,147=>500,148=>500,149=>350,150=>500,151=>1000,152=>333,153=>1000,154=>389,155=>333,156=>722,157=>350,158=>444,159=>722,160=>250,161=>333,162=>500,163=>500,164=>500,165=>500,166=>220,167=>500,168=>333,169=>747,170=>300,171=>500,172=>570,173=>333,174=>747,175=>333,176=>400,177=>570,178=>300,179=>300,180=>333,181=>556,182=>540,183=>250,184=>333,185=>300,186=>330,187=>500,188=>750,189=>750,190=>750,191=>500,192=>722,193=>722,194=>722,195=>722,196=>722,197=>722,198=>1000,199=>722,200=>667,201=>667,202=>667,203=>667,204=>389,205=>389,206=>389,207=>389,208=>722,209=>722,210=>778,211=>778,212=>778,213=>778,214=>778,215=>570,216=>778,217=>722,218=>722,219=>722,220=>722,221=>722,222=>611,223=>556,224=>500,225=>500,226=>500,227=>500,228=>500,229=>500,230=>722,231=>444,232=>444,233=>444,234=>444,235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>556,242=>500,243=>500,244=>500,245=>500,246=>500,247=>570,248=>500,249=>556,250=>556,251=>556,252=>556,253=>500,254=>556,255=>500);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Times-BoldItalic';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=501;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>96,'FontBBox'=>'[-200 -218 996 921]','ItalicAngle'=>-15,'Ascent'=>921,'Descent'=>-218,'Leading'=>0,'CapHeight'=>669,'XHeight'=>462,'StemV'=>121,'StemH'=>42,'AvgWidth'=>501,'MaxWidth'=>1000,'MissingWidth'=>501);
|
||||
$cw=array(0=>250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250,10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250,20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250,30=>250,31=>250,32=>250,33=>389,34=>555,35=>500,36=>500,37=>833,38=>778,39=>278,40=>333,41=>333,42=>500,43=>570,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333,60=>570,61=>570,62=>570,63=>500,64=>832,65=>667,66=>667,67=>667,68=>722,69=>667,70=>667,71=>722,72=>778,73=>389,74=>500,75=>667,76=>611,77=>889,78=>722,79=>722,80=>611,81=>722,82=>667,83=>556,84=>611,85=>722,86=>667,87=>889,88=>667,89=>611,90=>611,91=>333,92=>278,93=>333,94=>570,95=>500,96=>333,97=>500,98=>500,99=>444,100=>500,101=>444,102=>333,103=>500,104=>556,105=>278,106=>278,107=>500,108=>278,109=>778,110=>556,111=>500,112=>500,113=>500,114=>389,115=>389,116=>278,117=>556,118=>444,119=>667,120=>500,121=>444,122=>389,123=>348,124=>220,125=>348,126=>570,127=>350,128=>500,129=>350,130=>333,131=>500,132=>500,133=>1000,134=>500,135=>500,136=>333,137=>1000,138=>556,139=>333,140=>944,141=>350,142=>611,143=>350,144=>350,145=>333,146=>333,147=>500,148=>500,149=>350,150=>500,151=>1000,152=>333,153=>1000,154=>389,155=>333,156=>722,157=>350,158=>389,159=>611,160=>250,161=>389,162=>500,163=>500,164=>500,165=>500,166=>220,167=>500,168=>333,169=>747,170=>266,171=>500,172=>606,173=>333,174=>747,175=>333,176=>400,177=>570,178=>300,179=>300,180=>333,181=>576,182=>500,183=>250,184=>333,185=>300,186=>300,187=>500,188=>750,189=>750,190=>750,191=>500,192=>667,193=>667,194=>667,195=>667,196=>667,197=>667,198=>944,199=>667,200=>667,201=>667,202=>667,203=>667,204=>389,205=>389,206=>389,207=>389,208=>722,209=>722,210=>722,211=>722,212=>722,213=>722,214=>722,215=>570,216=>722,217=>722,218=>722,219=>722,220=>722,221=>611,222=>611,223=>500,224=>500,225=>500,226=>500,227=>500,228=>500,229=>500,230=>722,231=>444,232=>444,233=>444,234=>444,235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>556,242=>500,243=>500,244=>500,245=>500,246=>500,247=>570,248=>500,249=>556,250=>556,251=>556,252=>556,253=>444,254=>500,255=>444);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Times-Italic';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=491;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>96,'FontBBox'=>'[-169 -217 1010 883]','ItalicAngle'=>-15.5,'Ascent'=>883,'Descent'=>-217,'Leading'=>0,'CapHeight'=>653,'XHeight'=>441,'StemV'=>76,'StemH'=>32,'AvgWidth'=>491,'MaxWidth'=>1000,'MissingWidth'=>491);
|
||||
$cw=array(0=>250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250,10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250,20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250,30=>250,31=>250,32=>250,33=>333,34=>420,35=>500,36=>500,37=>833,38=>778,39=>214,40=>333,41=>333,42=>500,43=>675,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333,60=>675,61=>675,62=>675,63=>500,64=>920,65=>611,66=>611,67=>667,68=>722,69=>611,70=>611,71=>722,72=>722,73=>333,74=>444,75=>667,76=>556,77=>833,78=>667,79=>722,80=>611,81=>722,82=>611,83=>500,84=>556,85=>722,86=>611,87=>833,88=>611,89=>556,90=>556,91=>389,92=>278,93=>389,94=>422,95=>500,96=>333,97=>500,98=>500,99=>444,100=>500,101=>444,102=>278,103=>500,104=>500,105=>278,106=>278,107=>444,108=>278,109=>722,110=>500,111=>500,112=>500,113=>500,114=>389,115=>389,116=>278,117=>500,118=>444,119=>667,120=>444,121=>444,122=>389,123=>400,124=>275,125=>400,126=>541,127=>350,128=>500,129=>350,130=>333,131=>500,132=>556,133=>889,134=>500,135=>500,136=>333,137=>1000,138=>500,139=>333,140=>944,141=>350,142=>556,143=>350,144=>350,145=>333,146=>333,147=>556,148=>556,149=>350,150=>500,151=>889,152=>333,153=>980,154=>389,155=>333,156=>667,157=>350,158=>389,159=>556,160=>250,161=>389,162=>500,163=>500,164=>500,165=>500,166=>275,167=>500,168=>333,169=>760,170=>276,171=>500,172=>675,173=>333,174=>760,175=>333,176=>400,177=>675,178=>300,179=>300,180=>333,181=>500,182=>523,183=>250,184=>333,185=>300,186=>310,187=>500,188=>750,189=>750,190=>750,191=>500,192=>611,193=>611,194=>611,195=>611,196=>611,197=>611,198=>889,199=>667,200=>611,201=>611,202=>611,203=>611,204=>333,205=>333,206=>333,207=>333,208=>722,209=>667,210=>722,211=>722,212=>722,213=>722,214=>722,215=>675,216=>722,217=>722,218=>722,219=>722,220=>722,221=>556,222=>611,223=>500,224=>500,225=>500,226=>500,227=>500,228=>500,229=>500,230=>667,231=>444,232=>444,233=>444,234=>444,235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>500,242=>500,243=>500,244=>500,245=>500,246=>500,247=>675,248=>500,249=>500,250=>500,251=>500,252=>500,253=>444,254=>500,255=>444);
|
||||
// --- EOF ---
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='ZapfDingbats';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=746;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>4,'FontBBox'=>'[-1 -143 981 820]','ItalicAngle'=>0,'Ascent'=>820,'Descent'=>-143,'Leading'=>0,'CapHeight'=>820,'StemV'=>90,'StemH'=>28,'AvgWidth'=>746,'MaxWidth'=>1016,'MissingWidth'=>746);
|
||||
$cw=array(0=>746,1=>746,2=>746,3=>746,4=>746,5=>746,6=>746,7=>746,8=>746,9=>746,10=>746,11=>746,12=>746,13=>746,14=>746,15=>746,16=>746,17=>746,18=>746,19=>746,20=>746,21=>746,22=>746,23=>746,24=>746,25=>746,26=>746,27=>746,28=>746,29=>746,30=>746,31=>746,32=>278,33=>974,34=>961,35=>974,36=>980,37=>719,38=>789,39=>790,40=>791,41=>690,42=>960,43=>939,44=>549,45=>855,46=>911,47=>933,48=>911,49=>945,50=>974,51=>755,52=>846,53=>762,54=>761,55=>571,56=>677,57=>763,58=>760,59=>759,60=>754,61=>494,62=>552,63=>537,64=>577,65=>692,66=>786,67=>788,68=>788,69=>790,70=>793,71=>794,72=>816,73=>823,74=>789,75=>841,76=>823,77=>833,78=>816,79=>831,80=>923,81=>744,82=>723,83=>749,84=>790,85=>792,86=>695,87=>776,88=>768,89=>792,90=>759,91=>707,92=>708,93=>682,94=>701,95=>826,96=>815,97=>789,98=>789,99=>707,100=>687,101=>696,102=>689,103=>786,104=>787,105=>713,106=>791,107=>785,108=>791,109=>873,110=>761,111=>762,112=>762,113=>759,114=>759,115=>892,116=>892,117=>788,118=>784,119=>438,120=>138,121=>277,122=>415,123=>392,124=>392,125=>668,126=>668,127=>746,128=>390,129=>390,130=>317,131=>317,132=>276,133=>276,134=>509,135=>509,136=>410,137=>410,138=>234,139=>234,140=>334,141=>334,142=>746,143=>746,144=>746,145=>746,146=>746,147=>746,148=>746,149=>746,150=>746,151=>746,152=>746,153=>746,154=>746,155=>746,156=>746,157=>746,158=>746,159=>746,160=>746,161=>732,162=>544,163=>544,164=>910,165=>667,166=>760,167=>760,168=>776,169=>595,170=>694,171=>626,172=>788,173=>788,174=>788,175=>788,176=>788,177=>788,178=>788,179=>788,180=>788,181=>788,182=>788,183=>788,184=>788,185=>788,186=>788,187=>788,188=>788,189=>788,190=>788,191=>788,192=>788,193=>788,194=>788,195=>788,196=>788,197=>788,198=>788,199=>788,200=>788,201=>788,202=>788,203=>788,204=>788,205=>788,206=>788,207=>788,208=>788,209=>788,210=>788,211=>788,212=>894,213=>838,214=>1016,215=>458,216=>748,217=>924,218=>748,219=>918,220=>927,221=>928,222=>928,223=>834,224=>873,225=>828,226=>924,227=>924,228=>917,229=>930,230=>931,231=>463,232=>883,233=>836,234=>836,235=>867,236=>867,237=>696,238=>696,239=>874,240=>746,241=>874,242=>760,243=>946,244=>771,245=>865,246=>771,247=>888,248=>967,249=>888,250=>831,251=>873,252=>927,253=>970,254=>918,255=>746);
|
||||
// --- EOF ---
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,462 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_colors.php
|
||||
// Version : 1.0.004
|
||||
// Begin : 2002-04-09
|
||||
// Last Update : 2014-04-25
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2002-2013 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with TCPDF. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description : Array of WEB safe colors
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* PHP color class for TCPDF
|
||||
* @author Nicola Asuni
|
||||
* @package com.tecnick.tcpdf
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TCPDF_COLORS
|
||||
* PHP color class for TCPDF
|
||||
* @package com.tecnick.tcpdf
|
||||
* @version 1.0.004
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_COLORS {
|
||||
|
||||
/**
|
||||
* Array of WEB safe colors
|
||||
* @public static
|
||||
*/
|
||||
public static $webcolor = array (
|
||||
'aliceblue' => 'f0f8ff',
|
||||
'antiquewhite' => 'faebd7',
|
||||
'aqua' => '00ffff',
|
||||
'aquamarine' => '7fffd4',
|
||||
'azure' => 'f0ffff',
|
||||
'beige' => 'f5f5dc',
|
||||
'bisque' => 'ffe4c4',
|
||||
'black' => '000000',
|
||||
'blanchedalmond' => 'ffebcd',
|
||||
'blue' => '0000ff',
|
||||
'blueviolet' => '8a2be2',
|
||||
'brown' => 'a52a2a',
|
||||
'burlywood' => 'deb887',
|
||||
'cadetblue' => '5f9ea0',
|
||||
'chartreuse' => '7fff00',
|
||||
'chocolate' => 'd2691e',
|
||||
'coral' => 'ff7f50',
|
||||
'cornflowerblue' => '6495ed',
|
||||
'cornsilk' => 'fff8dc',
|
||||
'crimson' => 'dc143c',
|
||||
'cyan' => '00ffff',
|
||||
'darkblue' => '00008b',
|
||||
'darkcyan' => '008b8b',
|
||||
'darkgoldenrod' => 'b8860b',
|
||||
'dkgray' => 'a9a9a9',
|
||||
'darkgray' => 'a9a9a9',
|
||||
'darkgrey' => 'a9a9a9',
|
||||
'darkgreen' => '006400',
|
||||
'darkkhaki' => 'bdb76b',
|
||||
'darkmagenta' => '8b008b',
|
||||
'darkolivegreen' => '556b2f',
|
||||
'darkorange' => 'ff8c00',
|
||||
'darkorchid' => '9932cc',
|
||||
'darkred' => '8b0000',
|
||||
'darksalmon' => 'e9967a',
|
||||
'darkseagreen' => '8fbc8f',
|
||||
'darkslateblue' => '483d8b',
|
||||
'darkslategray' => '2f4f4f',
|
||||
'darkslategrey' => '2f4f4f',
|
||||
'darkturquoise' => '00ced1',
|
||||
'darkviolet' => '9400d3',
|
||||
'deeppink' => 'ff1493',
|
||||
'deepskyblue' => '00bfff',
|
||||
'dimgray' => '696969',
|
||||
'dimgrey' => '696969',
|
||||
'dodgerblue' => '1e90ff',
|
||||
'firebrick' => 'b22222',
|
||||
'floralwhite' => 'fffaf0',
|
||||
'forestgreen' => '228b22',
|
||||
'fuchsia' => 'ff00ff',
|
||||
'gainsboro' => 'dcdcdc',
|
||||
'ghostwhite' => 'f8f8ff',
|
||||
'gold' => 'ffd700',
|
||||
'goldenrod' => 'daa520',
|
||||
'gray' => '808080',
|
||||
'grey' => '808080',
|
||||
'green' => '008000',
|
||||
'greenyellow' => 'adff2f',
|
||||
'honeydew' => 'f0fff0',
|
||||
'hotpink' => 'ff69b4',
|
||||
'indianred' => 'cd5c5c',
|
||||
'indigo' => '4b0082',
|
||||
'ivory' => 'fffff0',
|
||||
'khaki' => 'f0e68c',
|
||||
'lavender' => 'e6e6fa',
|
||||
'lavenderblush' => 'fff0f5',
|
||||
'lawngreen' => '7cfc00',
|
||||
'lemonchiffon' => 'fffacd',
|
||||
'lightblue' => 'add8e6',
|
||||
'lightcoral' => 'f08080',
|
||||
'lightcyan' => 'e0ffff',
|
||||
'lightgoldenrodyellow' => 'fafad2',
|
||||
'ltgray' => 'd3d3d3',
|
||||
'lightgray' => 'd3d3d3',
|
||||
'lightgrey' => 'd3d3d3',
|
||||
'lightgreen' => '90ee90',
|
||||
'lightpink' => 'ffb6c1',
|
||||
'lightsalmon' => 'ffa07a',
|
||||
'lightseagreen' => '20b2aa',
|
||||
'lightskyblue' => '87cefa',
|
||||
'lightslategray' => '778899',
|
||||
'lightslategrey' => '778899',
|
||||
'lightsteelblue' => 'b0c4de',
|
||||
'lightyellow' => 'ffffe0',
|
||||
'lime' => '00ff00',
|
||||
'limegreen' => '32cd32',
|
||||
'linen' => 'faf0e6',
|
||||
'magenta' => 'ff00ff',
|
||||
'maroon' => '800000',
|
||||
'mediumaquamarine' => '66cdaa',
|
||||
'mediumblue' => '0000cd',
|
||||
'mediumorchid' => 'ba55d3',
|
||||
'mediumpurple' => '9370d8',
|
||||
'mediumseagreen' => '3cb371',
|
||||
'mediumslateblue' => '7b68ee',
|
||||
'mediumspringgreen' => '00fa9a',
|
||||
'mediumturquoise' => '48d1cc',
|
||||
'mediumvioletred' => 'c71585',
|
||||
'midnightblue' => '191970',
|
||||
'mintcream' => 'f5fffa',
|
||||
'mistyrose' => 'ffe4e1',
|
||||
'moccasin' => 'ffe4b5',
|
||||
'navajowhite' => 'ffdead',
|
||||
'navy' => '000080',
|
||||
'oldlace' => 'fdf5e6',
|
||||
'olive' => '808000',
|
||||
'olivedrab' => '6b8e23',
|
||||
'orange' => 'ffa500',
|
||||
'orangered' => 'ff4500',
|
||||
'orchid' => 'da70d6',
|
||||
'palegoldenrod' => 'eee8aa',
|
||||
'palegreen' => '98fb98',
|
||||
'paleturquoise' => 'afeeee',
|
||||
'palevioletred' => 'd87093',
|
||||
'papayawhip' => 'ffefd5',
|
||||
'peachpuff' => 'ffdab9',
|
||||
'peru' => 'cd853f',
|
||||
'pink' => 'ffc0cb',
|
||||
'plum' => 'dda0dd',
|
||||
'powderblue' => 'b0e0e6',
|
||||
'purple' => '800080',
|
||||
'red' => 'ff0000',
|
||||
'rosybrown' => 'bc8f8f',
|
||||
'royalblue' => '4169e1',
|
||||
'saddlebrown' => '8b4513',
|
||||
'salmon' => 'fa8072',
|
||||
'sandybrown' => 'f4a460',
|
||||
'seagreen' => '2e8b57',
|
||||
'seashell' => 'fff5ee',
|
||||
'sienna' => 'a0522d',
|
||||
'silver' => 'c0c0c0',
|
||||
'skyblue' => '87ceeb',
|
||||
'slateblue' => '6a5acd',
|
||||
'slategray' => '708090',
|
||||
'slategrey' => '708090',
|
||||
'snow' => 'fffafa',
|
||||
'springgreen' => '00ff7f',
|
||||
'steelblue' => '4682b4',
|
||||
'tan' => 'd2b48c',
|
||||
'teal' => '008080',
|
||||
'thistle' => 'd8bfd8',
|
||||
'tomato' => 'ff6347',
|
||||
'turquoise' => '40e0d0',
|
||||
'violet' => 'ee82ee',
|
||||
'wheat' => 'f5deb3',
|
||||
'white' => 'ffffff',
|
||||
'whitesmoke' => 'f5f5f5',
|
||||
'yellow' => 'ffff00',
|
||||
'yellowgreen' => '9acd32'
|
||||
); // end of web colors
|
||||
|
||||
/**
|
||||
* Array of valid JavaScript color names
|
||||
* @public static
|
||||
*/
|
||||
public static $jscolor = array ('transparent', 'black', 'white', 'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'dkGray', 'gray', 'ltGray');
|
||||
|
||||
/**
|
||||
* Array of Spot colors (C,M,Y,K,name)
|
||||
* Color keys must be in lowercase and without spaces.
|
||||
* As long as no open standard for spot colours exists, you have to buy a colour book by one of the colour manufacturers and insert the values and names of spot colours directly.
|
||||
* Common industry standard spot colors are: ANPA-COLOR, DIC, FOCOLTONE, GCMI, HKS, PANTONE, TOYO, TRUMATCH.
|
||||
* @public static
|
||||
*/
|
||||
public static $spotcolor = array (
|
||||
// special registration colors
|
||||
'none' => array( 0, 0, 0, 0, 'None'),
|
||||
'all' => array(100, 100, 100, 100, 'All'),
|
||||
// standard CMYK colors
|
||||
'cyan' => array(100, 0, 0, 0, 'Cyan'),
|
||||
'magenta' => array( 0, 100, 0, 0, 'Magenta'),
|
||||
'yellow' => array( 0, 0, 100, 0, 'Yellow'),
|
||||
'key' => array( 0, 0, 0, 100, 'Key'),
|
||||
// alias
|
||||
'white' => array( 0, 0, 0, 0, 'White'),
|
||||
'black' => array( 0, 0, 0, 100, 'Black'),
|
||||
// standard RGB colors
|
||||
'red' => array( 0, 100, 100, 0, 'Red'),
|
||||
'green' => array(100, 0, 100, 0, 'Green'),
|
||||
'blue' => array(100, 100, 0, 0, 'Blue'),
|
||||
// Add here standard spot colors or dynamically define them with AddSpotColor()
|
||||
// ...
|
||||
); // end of spot colors
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
* Return the Spot color array.
|
||||
* @param $name (string) Name of the spot color.
|
||||
* @param $spotc (array) Reference to an array of spot colors.
|
||||
* @return (array) Spot color array or false if not defined.
|
||||
* @since 5.9.125 (2011-10-03)
|
||||
* @public static
|
||||
*/
|
||||
public static function getSpotColor($name, &$spotc) {
|
||||
if (isset($spotc[$name])) {
|
||||
return $spotc[$name];
|
||||
}
|
||||
$color = preg_replace('/[\s]*/', '', $name); // remove extra spaces
|
||||
$color = strtolower($color);
|
||||
if (isset(self::$spotcolor[$color])) {
|
||||
if (!isset($spotc[$name])) {
|
||||
$i = (1 + count($spotc));
|
||||
$spotc[$name] = array('C' => self::$spotcolor[$color][0], 'M' => self::$spotcolor[$color][1], 'Y' => self::$spotcolor[$color][2], 'K' => self::$spotcolor[$color][3], 'name' => self::$spotcolor[$color][4], 'i' => $i);
|
||||
}
|
||||
return $spotc[self::$spotcolor[$color][4]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array (RGB or CMYK) from an html color name, or a six-digit (i.e. #3FE5AA), or three-digit (i.e. #7FF) hexadecimal color, or a javascript color array, or javascript color name.
|
||||
* @param $hcolor (string) HTML color.
|
||||
* @param $spotc (array) Reference to an array of spot colors.
|
||||
* @param $defcol (array) Color to return in case of error.
|
||||
* @return array RGB or CMYK color, or false in case of error.
|
||||
* @public static
|
||||
*/
|
||||
public static function convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R'=>128,'G'=>128,'B'=>128)) {
|
||||
$color = preg_replace('/[\s]*/', '', $hcolor); // remove extra spaces
|
||||
$color = strtolower($color);
|
||||
// check for javascript color array syntax
|
||||
if (strpos($color, '[') !== false) {
|
||||
if (preg_match('/[\[][\"\'](t|g|rgb|cmyk)[\"\'][\,]?([0-9\.]*)[\,]?([0-9\.]*)[\,]?([0-9\.]*)[\,]?([0-9\.]*)[\]]/', $color, $m) > 0) {
|
||||
$returncolor = array();
|
||||
switch ($m[1]) {
|
||||
case 'cmyk': {
|
||||
// RGB
|
||||
$returncolor['C'] = max(0, min(100, (floatval($m[2]) * 100)));
|
||||
$returncolor['M'] = max(0, min(100, (floatval($m[3]) * 100)));
|
||||
$returncolor['Y'] = max(0, min(100, (floatval($m[4]) * 100)));
|
||||
$returncolor['K'] = max(0, min(100, (floatval($m[5]) * 100)));
|
||||
break;
|
||||
}
|
||||
case 'rgb': {
|
||||
// RGB
|
||||
$returncolor['R'] = max(0, min(255, (floatval($m[2]) * 255)));
|
||||
$returncolor['G'] = max(0, min(255, (floatval($m[3]) * 255)));
|
||||
$returncolor['B'] = max(0, min(255, (floatval($m[4]) * 255)));
|
||||
break;
|
||||
}
|
||||
case 'g': {
|
||||
// grayscale
|
||||
$returncolor['G'] = max(0, min(255, (floatval($m[2]) * 255)));
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
default: {
|
||||
// transparent (empty array)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $returncolor;
|
||||
}
|
||||
} elseif ((substr($color, 0, 4) != 'cmyk') AND (substr($color, 0, 3) != 'rgb') AND (($dotpos = strpos($color, '.')) !== false)) {
|
||||
// remove class parent (i.e.: color.red)
|
||||
$color = substr($color, ($dotpos + 1));
|
||||
if ($color == 'transparent') {
|
||||
// transparent (empty array)
|
||||
return array();
|
||||
}
|
||||
}
|
||||
if (strlen($color) == 0) {
|
||||
return $defcol;
|
||||
}
|
||||
// RGB ARRAY
|
||||
if (substr($color, 0, 3) == 'rgb') {
|
||||
$codes = substr($color, 4);
|
||||
$codes = str_replace(')', '', $codes);
|
||||
$returncolor = explode(',', $codes);
|
||||
foreach ($returncolor as $key => $val) {
|
||||
if (strpos($val, '%') > 0) {
|
||||
// percentage
|
||||
$returncolor[$key] = (255 * intval($val) / 100);
|
||||
} else {
|
||||
$returncolor[$key] = intval($val);
|
||||
}
|
||||
// normalize value
|
||||
$returncolor[$key] = max(0, min(255, $returncolor[$key]));
|
||||
}
|
||||
return $returncolor;
|
||||
}
|
||||
// CMYK ARRAY
|
||||
if (substr($color, 0, 4) == 'cmyk') {
|
||||
$codes = substr($color, 5);
|
||||
$codes = str_replace(')', '', $codes);
|
||||
$returncolor = explode(',', $codes);
|
||||
foreach ($returncolor as $key => $val) {
|
||||
if (strpos($val, '%') !== false) {
|
||||
// percentage
|
||||
$returncolor[$key] = (100 * intval($val) / 100);
|
||||
} else {
|
||||
$returncolor[$key] = intval($val);
|
||||
}
|
||||
// normalize value
|
||||
$returncolor[$key] = max(0, min(100, $returncolor[$key]));
|
||||
}
|
||||
return $returncolor;
|
||||
}
|
||||
if ($color[0] != '#') {
|
||||
// COLOR NAME
|
||||
if (isset(self::$webcolor[$color])) {
|
||||
// web color
|
||||
$color_code = self::$webcolor[$color];
|
||||
} else {
|
||||
// spot color
|
||||
$returncolor = self::getSpotColor($color, $spotc);
|
||||
if ($returncolor === false) {
|
||||
$returncolor = $defcol;
|
||||
}
|
||||
return $returncolor;
|
||||
}
|
||||
} else {
|
||||
$color_code = substr($color, 1);
|
||||
}
|
||||
// HEXADECIMAL REPRESENTATION
|
||||
switch (strlen($color_code)) {
|
||||
case 3: {
|
||||
// 3-digit RGB hexadecimal representation
|
||||
$r = substr($color_code, 0, 1);
|
||||
$g = substr($color_code, 1, 1);
|
||||
$b = substr($color_code, 2, 1);
|
||||
$returncolor = array();
|
||||
$returncolor['R'] = max(0, min(255, hexdec($r.$r)));
|
||||
$returncolor['G'] = max(0, min(255, hexdec($g.$g)));
|
||||
$returncolor['B'] = max(0, min(255, hexdec($b.$b)));
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
// 6-digit RGB hexadecimal representation
|
||||
$returncolor = array();
|
||||
$returncolor['R'] = max(0, min(255, hexdec(substr($color_code, 0, 2))));
|
||||
$returncolor['G'] = max(0, min(255, hexdec(substr($color_code, 2, 2))));
|
||||
$returncolor['B'] = max(0, min(255, hexdec(substr($color_code, 4, 2))));
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
// 8-digit CMYK hexadecimal representation
|
||||
$returncolor = array();
|
||||
$returncolor['C'] = max(0, min(100, round(hexdec(substr($color_code, 0, 2)) / 2.55)));
|
||||
$returncolor['M'] = max(0, min(100, round(hexdec(substr($color_code, 2, 2)) / 2.55)));
|
||||
$returncolor['Y'] = max(0, min(100, round(hexdec(substr($color_code, 4, 2)) / 2.55)));
|
||||
$returncolor['K'] = max(0, min(100, round(hexdec(substr($color_code, 6, 2)) / 2.55)));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$returncolor = $defcol;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $returncolor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a color array into a string representation.
|
||||
* @param $c (array) Array of colors.
|
||||
* @return (string) The color array representation.
|
||||
* @since 5.9.137 (2011-12-01)
|
||||
* @public static
|
||||
*/
|
||||
public static function getColorStringFromArray($c) {
|
||||
$c = array_values($c);
|
||||
$color = '[';
|
||||
switch (count($c)) {
|
||||
case 4: {
|
||||
// CMYK
|
||||
$color .= sprintf('%F %F %F %F', (max(0, min(100, floatval($c[0]))) / 100), (max(0, min(100, floatval($c[1]))) / 100), (max(0, min(100, floatval($c[2]))) / 100), (max(0, min(100, floatval($c[3]))) / 100));
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
// RGB
|
||||
$color .= sprintf('%F %F %F', (max(0, min(255, floatval($c[0]))) / 255), (max(0, min(255, floatval($c[1]))) / 255), (max(0, min(255, floatval($c[2]))) / 255));
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
// grayscale
|
||||
$color .= sprintf('%F', (max(0, min(255, floatval($c[0]))) / 255));
|
||||
break;
|
||||
}
|
||||
}
|
||||
$color .= ']';
|
||||
return $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert color to javascript color.
|
||||
* @param $color (string) color name or "#RRGGBB"
|
||||
* @protected
|
||||
* @since 2.1.002 (2008-02-12)
|
||||
* @public static
|
||||
*/
|
||||
public static function _JScolor($color) {
|
||||
if (substr($color, 0, 1) == '#') {
|
||||
return sprintf("['RGB',%F,%F,%F]", (hexdec(substr($color, 1, 2)) / 255), (hexdec(substr($color, 3, 2)) / 255), (hexdec(substr($color, 5, 2)) / 255));
|
||||
}
|
||||
if (!in_array($color, self::$jscolor)) {
|
||||
// default transparent color
|
||||
$color = $jscolor[0];
|
||||
}
|
||||
return 'color.'.$color;
|
||||
}
|
||||
|
||||
|
||||
} // END OF TCPDF_COLORS CLASS
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
@@ -0,0 +1,481 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_filters.php
|
||||
// Version : 1.0.001
|
||||
// Begin : 2011-05-23
|
||||
// Last Update : 2014-04-25
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2013 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the License
|
||||
// along with TCPDF. If not, see
|
||||
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description : This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.001
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TCPDF_FILTERS
|
||||
* This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @brief This is a PHP class for decoding common PDF filters.
|
||||
* @version 1.0.001
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_FILTERS {
|
||||
|
||||
/**
|
||||
* Define a list of available filter decoders.
|
||||
* @private static
|
||||
*/
|
||||
private static $available_filters = array('ASCIIHexDecode', 'ASCII85Decode', 'LZWDecode', 'FlateDecode', 'RunLengthDecode');
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get a list of available decoding filters.
|
||||
* @return (array) Array of available filter decoders.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function getAvailableFilters() {
|
||||
return self::$available_filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode data using the specified filter type.
|
||||
* @param $filter (string) Filter name.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilter($filter, $data) {
|
||||
switch ($filter) {
|
||||
case 'ASCIIHexDecode': {
|
||||
return self::decodeFilterASCIIHexDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'ASCII85Decode': {
|
||||
return self::decodeFilterASCII85Decode($data);
|
||||
break;
|
||||
}
|
||||
case 'LZWDecode': {
|
||||
return self::decodeFilterLZWDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'FlateDecode': {
|
||||
return self::decodeFilterFlateDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'RunLengthDecode': {
|
||||
return self::decodeFilterRunLengthDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'CCITTFaxDecode': {
|
||||
return self::decodeFilterCCITTFaxDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'JBIG2Decode': {
|
||||
return self::decodeFilterJBIG2Decode($data);
|
||||
break;
|
||||
}
|
||||
case 'DCTDecode': {
|
||||
return self::decodeFilterDCTDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'JPXDecode': {
|
||||
return self::decodeFilterJPXDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'Crypt': {
|
||||
return self::decodeFilterCrypt($data);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return self::decodeFilterStandard($data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- FILTERS (PDF 32000-2008 - 7.4 Filters) ------------------------------
|
||||
|
||||
/**
|
||||
* Standard
|
||||
* Default decoding filter (leaves data unchanged).
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterStandard($data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* ASCIIHexDecode
|
||||
* Decodes data encoded in an ASCII hexadecimal representation, reproducing the original binary data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterASCIIHexDecode($data) {
|
||||
// initialize string to return
|
||||
$decoded = '';
|
||||
// all white-space characters shall be ignored
|
||||
$data = preg_replace('/[\s]/', '', $data);
|
||||
// check for EOD character: GREATER-THAN SIGN (3Eh)
|
||||
$eod = strpos($data, '>');
|
||||
if ($eod !== false) {
|
||||
// remove EOD and extra data (if any)
|
||||
$data = substr($data, 0, $eod);
|
||||
$eod = true;
|
||||
}
|
||||
// get data length
|
||||
$data_length = strlen($data);
|
||||
if (($data_length % 2) != 0) {
|
||||
// odd number of hexadecimal digits
|
||||
if ($eod) {
|
||||
// EOD shall behave as if a 0 (zero) followed the last digit
|
||||
$data = substr($data, 0, -1).'0'.substr($data, -1);
|
||||
} else {
|
||||
self::Error('decodeFilterASCIIHexDecode: invalid code');
|
||||
}
|
||||
}
|
||||
// check for invalid characters
|
||||
if (preg_match('/[^a-fA-F\d]/', $data) > 0) {
|
||||
self::Error('decodeFilterASCIIHexDecode: invalid code');
|
||||
}
|
||||
// get one byte of binary data for each pair of ASCII hexadecimal digits
|
||||
$decoded = pack('H*', $data);
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* ASCII85Decode
|
||||
* Decodes data encoded in an ASCII base-85 representation, reproducing the original binary data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterASCII85Decode($data) {
|
||||
// initialize string to return
|
||||
$decoded = '';
|
||||
// all white-space characters shall be ignored
|
||||
$data = preg_replace('/[\s]/', '', $data);
|
||||
// remove start sequence 2-character sequence <~ (3Ch)(7Eh)
|
||||
if (strpos($data, '<~') !== false) {
|
||||
// remove EOD and extra data (if any)
|
||||
$data = substr($data, 2);
|
||||
}
|
||||
// check for EOD: 2-character sequence ~> (7Eh)(3Eh)
|
||||
$eod = strpos($data, '~>');
|
||||
if ($eod !== false) {
|
||||
// remove EOD and extra data (if any)
|
||||
$data = substr($data, 0, $eod);
|
||||
}
|
||||
// data length
|
||||
$data_length = strlen($data);
|
||||
// check for invalid characters
|
||||
if (preg_match('/[^\x21-\x75,\x74]/', $data) > 0) {
|
||||
self::Error('decodeFilterASCII85Decode: invalid code');
|
||||
}
|
||||
// z sequence
|
||||
$zseq = chr(0).chr(0).chr(0).chr(0);
|
||||
// position inside a group of 4 bytes (0-3)
|
||||
$group_pos = 0;
|
||||
$tuple = 0;
|
||||
$pow85 = array((85*85*85*85), (85*85*85), (85*85), 85, 1);
|
||||
$last_pos = ($data_length - 1);
|
||||
// for each byte
|
||||
for ($i = 0; $i < $data_length; ++$i) {
|
||||
// get char value
|
||||
$char = ord($data[$i]);
|
||||
if ($char == 122) { // 'z'
|
||||
if ($group_pos == 0) {
|
||||
$decoded .= $zseq;
|
||||
} else {
|
||||
self::Error('decodeFilterASCII85Decode: invalid code');
|
||||
}
|
||||
} else {
|
||||
// the value represented by a group of 5 characters should never be greater than 2^32 - 1
|
||||
$tuple += (($char - 33) * $pow85[$group_pos]);
|
||||
if ($group_pos == 4) {
|
||||
$decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8).chr($tuple);
|
||||
$tuple = 0;
|
||||
$group_pos = 0;
|
||||
} else {
|
||||
++$group_pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($group_pos > 1) {
|
||||
$tuple += $pow85[($group_pos - 1)];
|
||||
}
|
||||
// last tuple (if any)
|
||||
switch ($group_pos) {
|
||||
case 4: {
|
||||
$decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
$decoded .= chr($tuple >> 24).chr($tuple >> 16);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
$decoded .= chr($tuple >> 24);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
self::Error('decodeFilterASCII85Decode: invalid code');
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* LZWDecode
|
||||
* Decompresses data encoded using the LZW (Lempel-Ziv-Welch) adaptive compression method, reproducing the original text or binary data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterLZWDecode($data) {
|
||||
// initialize string to return
|
||||
$decoded = '';
|
||||
// data length
|
||||
$data_length = strlen($data);
|
||||
// convert string to binary string
|
||||
$bitstring = '';
|
||||
for ($i = 0; $i < $data_length; ++$i) {
|
||||
$bitstring .= sprintf('%08b', ord($data{$i}));
|
||||
}
|
||||
// get the number of bits
|
||||
$data_length = strlen($bitstring);
|
||||
// initialize code length in bits
|
||||
$bitlen = 9;
|
||||
// initialize dictionary index
|
||||
$dix = 258;
|
||||
// initialize the dictionary (with the first 256 entries).
|
||||
$dictionary = array();
|
||||
for ($i = 0; $i < 256; ++$i) {
|
||||
$dictionary[$i] = chr($i);
|
||||
}
|
||||
// previous val
|
||||
$prev_index = 0;
|
||||
// while we encounter EOD marker (257), read code_length bits
|
||||
while (($data_length > 0) AND (($index = bindec(substr($bitstring, 0, $bitlen))) != 257)) {
|
||||
// remove read bits from string
|
||||
$bitstring = substr($bitstring, $bitlen);
|
||||
// update number of bits
|
||||
$data_length -= $bitlen;
|
||||
if ($index == 256) { // clear-table marker
|
||||
// reset code length in bits
|
||||
$bitlen = 9;
|
||||
// reset dictionary index
|
||||
$dix = 258;
|
||||
$prev_index = 256;
|
||||
// reset the dictionary (with the first 256 entries).
|
||||
$dictionary = array();
|
||||
for ($i = 0; $i < 256; ++$i) {
|
||||
$dictionary[$i] = chr($i);
|
||||
}
|
||||
} elseif ($prev_index == 256) {
|
||||
// first entry
|
||||
$decoded .= $dictionary[$index];
|
||||
$prev_index = $index;
|
||||
} else {
|
||||
// check if index exist in the dictionary
|
||||
if ($index < $dix) {
|
||||
// index exist on dictionary
|
||||
$decoded .= $dictionary[$index];
|
||||
$dic_val = $dictionary[$prev_index].$dictionary[$index][0];
|
||||
// store current index
|
||||
$prev_index = $index;
|
||||
} else {
|
||||
// index do not exist on dictionary
|
||||
$dic_val = $dictionary[$prev_index].$dictionary[$prev_index][0];
|
||||
$decoded .= $dic_val;
|
||||
}
|
||||
// update dictionary
|
||||
$dictionary[$dix] = $dic_val;
|
||||
++$dix;
|
||||
// change bit length by case
|
||||
if ($dix == 2047) {
|
||||
$bitlen = 12;
|
||||
} elseif ($dix == 1023) {
|
||||
$bitlen = 11;
|
||||
} elseif ($dix == 511) {
|
||||
$bitlen = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* FlateDecode
|
||||
* Decompresses data encoded using the zlib/deflate compression method, reproducing the original text or binary data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterFlateDecode($data) {
|
||||
// initialize string to return
|
||||
$decoded = @gzuncompress($data);
|
||||
if ($decoded === false) {
|
||||
self::Error('decodeFilterFlateDecode: invalid code');
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* RunLengthDecode
|
||||
* Decompresses data encoded using a byte-oriented run-length encoding algorithm.
|
||||
* @param $data (string) Data to decode.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterRunLengthDecode($data) {
|
||||
// initialize string to return
|
||||
$decoded = '';
|
||||
// data length
|
||||
$data_length = strlen($data);
|
||||
$i = 0;
|
||||
while($i < $data_length) {
|
||||
// get current byte value
|
||||
$byte = ord($data{$i});
|
||||
if ($byte == 128) {
|
||||
// a length value of 128 denote EOD
|
||||
break;
|
||||
} elseif ($byte < 128) {
|
||||
// if the length byte is in the range 0 to 127
|
||||
// the following length + 1 (1 to 128) bytes shall be copied literally during decompression
|
||||
$decoded .= substr($data, ($i + 1), ($byte + 1));
|
||||
// move to next block
|
||||
$i += ($byte + 2);
|
||||
} else {
|
||||
// if length is in the range 129 to 255,
|
||||
// the following single byte shall be copied 257 - length (2 to 128) times during decompression
|
||||
$decoded .= str_repeat($data{($i + 1)}, (257 - $byte));
|
||||
// move to next block
|
||||
$i += 2;
|
||||
}
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* CCITTFaxDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
|
||||
* Decompresses data encoded using the CCITT facsimile standard, reproducing the original data (typically monochrome image data at 1 bit per pixel).
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterCCITTFaxDecode($data) {
|
||||
self::Error('~decodeFilterCCITTFaxDecode: this method has not been yet implemented');
|
||||
//return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* JBIG2Decode (NOT IMPLEMETED - RETURN AN EXCEPTION)
|
||||
* Decompresses data encoded using the JBIG2 standard, reproducing the original monochrome (1 bit per pixel) image data (or an approximation of that data).
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterJBIG2Decode($data) {
|
||||
self::Error('~decodeFilterJBIG2Decode: this method has not been yet implemented');
|
||||
//return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* DCTDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
|
||||
* Decompresses data encoded using a DCT (discrete cosine transform) technique based on the JPEG standard, reproducing image sample data that approximates the original data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterDCTDecode($data) {
|
||||
self::Error('~decodeFilterDCTDecode: this method has not been yet implemented');
|
||||
//return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* JPXDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
|
||||
* Decompresses data encoded using the wavelet-based JPEG2000 standard, reproducing the original image data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterJPXDecode($data) {
|
||||
self::Error('~decodeFilterJPXDecode: this method has not been yet implemented');
|
||||
//return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crypt (NOT IMPLEMETED - RETURN AN EXCEPTION)
|
||||
* Decrypts data encrypted by a security handler, reproducing the data as it was before encryption.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterCrypt($data) {
|
||||
self::Error('~decodeFilterCrypt: this method has not been yet implemented');
|
||||
//return $data;
|
||||
}
|
||||
|
||||
// --- END FILTERS SECTION -------------------------------------------------
|
||||
|
||||
/**
|
||||
* Throw an exception.
|
||||
* @param $msg (string) The error message
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function Error($msg) {
|
||||
throw new Exception('TCPDF_PARSER ERROR: '.$msg);
|
||||
}
|
||||
|
||||
} // END OF TCPDF_FILTERS CLASS
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_images.php
|
||||
// Version : 1.0.005
|
||||
// Begin : 2002-08-03
|
||||
// Last Update : 2014-11-15
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2002-2014 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the License
|
||||
// along with TCPDF. If not, see
|
||||
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description :
|
||||
// Static image methods used by the TCPDF class.
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This is a PHP class that contains static image methods for the TCPDF class.<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.005
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TCPDF_IMAGES
|
||||
* Static image methods used by the TCPDF class.
|
||||
* @package com.tecnick.tcpdf
|
||||
* @brief PHP class for generating PDF documents without requiring external extensions.
|
||||
* @version 1.0.005
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_IMAGES {
|
||||
|
||||
/**
|
||||
* Array of hinheritable SVG properties.
|
||||
* @since 5.0.000 (2010-05-02)
|
||||
* @public static
|
||||
*/
|
||||
public static $svginheritprop = array('clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cursor', 'direction', 'display', 'fill', 'fill-opacity', 'fill-rule', 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'image-rendering', 'kerning', 'letter-spacing', 'marker', 'marker-end', 'marker-mid', 'marker-start', 'pointer-events', 'shape-rendering', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-rendering', 'visibility', 'word-spacing', 'writing-mode');
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
* Return the image type given the file name or array returned by getimagesize() function.
|
||||
* @param $imgfile (string) image file name
|
||||
* @param $iminfo (array) array of image information returned by getimagesize() function.
|
||||
* @return string image type
|
||||
* @since 4.8.017 (2009-11-27)
|
||||
* @public static
|
||||
*/
|
||||
public static function getImageFileType($imgfile, $iminfo=array()) {
|
||||
$type = '';
|
||||
if (isset($iminfo['mime']) AND !empty($iminfo['mime'])) {
|
||||
$mime = explode('/', $iminfo['mime']);
|
||||
if ((count($mime) > 1) AND ($mime[0] == 'image') AND (!empty($mime[1]))) {
|
||||
$type = strtolower(trim($mime[1]));
|
||||
}
|
||||
}
|
||||
if (empty($type)) {
|
||||
$fileinfo = pathinfo($imgfile);
|
||||
if (isset($fileinfo['extension']) AND (!TCPDF_STATIC::empty_string($fileinfo['extension']))) {
|
||||
$type = strtolower(trim($fileinfo['extension']));
|
||||
}
|
||||
}
|
||||
if ($type == 'jpg') {
|
||||
$type = 'jpeg';
|
||||
}
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the transparency for the given GD image.
|
||||
* @param $new_image (image) GD image object
|
||||
* @param $image (image) GD image object.
|
||||
* return GD image object.
|
||||
* @since 4.9.016 (2010-04-20)
|
||||
* @public static
|
||||
*/
|
||||
public static function setGDImageTransparency($new_image, $image) {
|
||||
// default transparency color (white)
|
||||
$tcol = array('red' => 255, 'green' => 255, 'blue' => 255);
|
||||
// transparency index
|
||||
$tid = imagecolortransparent($image);
|
||||
$palletsize = imagecolorstotal($image);
|
||||
if (($tid >= 0) AND ($tid < $palletsize)) {
|
||||
// get the colors for the transparency index
|
||||
$tcol = imagecolorsforindex($image, $tid);
|
||||
}
|
||||
$tid = imagecolorallocate($new_image, $tcol['red'], $tcol['green'], $tcol['blue']);
|
||||
imagefill($new_image, 0, 0, $tid);
|
||||
imagecolortransparent($new_image, $tid);
|
||||
return $new_image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the loaded image to a PNG and then return a structure for the PDF creator.
|
||||
* This function requires GD library and write access to the directory defined on K_PATH_CACHE constant.
|
||||
* @param $image (image) Image object.
|
||||
* @param $tempfile (string) Temporary file name.
|
||||
* return image PNG image object.
|
||||
* @since 4.9.016 (2010-04-20)
|
||||
* @public static
|
||||
*/
|
||||
public static function _toPNG($image, $tempfile) {
|
||||
// turn off interlaced mode
|
||||
imageinterlace($image, 0);
|
||||
// create temporary PNG image
|
||||
imagepng($image, $tempfile);
|
||||
// remove image from memory
|
||||
imagedestroy($image);
|
||||
// get PNG image data
|
||||
$retvars = self::_parsepng($tempfile);
|
||||
// tidy up by removing temporary image
|
||||
unlink($tempfile);
|
||||
return $retvars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the loaded image to a JPEG and then return a structure for the PDF creator.
|
||||
* This function requires GD library and write access to the directory defined on K_PATH_CACHE constant.
|
||||
* @param $image (image) Image object.
|
||||
* @param $quality (int) JPEG quality.
|
||||
* @param $tempfile (string) Temporary file name.
|
||||
* return image JPEG image object.
|
||||
* @public static
|
||||
*/
|
||||
public static function _toJPEG($image, $quality, $tempfile) {
|
||||
imagejpeg($image, $tempfile, $quality);
|
||||
imagedestroy($image);
|
||||
$retvars = self::_parsejpeg($tempfile);
|
||||
// tidy up by removing temporary image
|
||||
unlink($tempfile);
|
||||
return $retvars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract info from a JPEG file without using the GD library.
|
||||
* @param $file (string) image file to parse
|
||||
* @return array structure containing the image data
|
||||
* @public static
|
||||
*/
|
||||
public static function _parsejpeg($file) {
|
||||
// check if is a local file
|
||||
if (!@file_exists($file)) {
|
||||
// try to encode spaces on filename
|
||||
$tfile = str_replace(' ', '%20', $file);
|
||||
if (@file_exists($tfile)) {
|
||||
$file = $tfile;
|
||||
}
|
||||
}
|
||||
$a = getimagesize($file);
|
||||
if (empty($a)) {
|
||||
//Missing or incorrect image file
|
||||
return false;
|
||||
}
|
||||
if ($a[2] != 2) {
|
||||
// Not a JPEG file
|
||||
return false;
|
||||
}
|
||||
// bits per pixel
|
||||
$bpc = isset($a['bits']) ? intval($a['bits']) : 8;
|
||||
// number of image channels
|
||||
if (!isset($a['channels'])) {
|
||||
$channels = 3;
|
||||
} else {
|
||||
$channels = intval($a['channels']);
|
||||
}
|
||||
// default colour space
|
||||
switch ($channels) {
|
||||
case 1: {
|
||||
$colspace = 'DeviceGray';
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
$colspace = 'DeviceRGB';
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
$colspace = 'DeviceCMYK';
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$channels = 3;
|
||||
$colspace = 'DeviceRGB';
|
||||
break;
|
||||
}
|
||||
}
|
||||
// get file content
|
||||
$data = file_get_contents($file);
|
||||
// check for embedded ICC profile
|
||||
$icc = array();
|
||||
$offset = 0;
|
||||
while (($pos = strpos($data, "ICC_PROFILE\0", $offset)) !== false) {
|
||||
// get ICC sequence length
|
||||
$length = (TCPDF_STATIC::_getUSHORT($data, ($pos - 2)) - 16);
|
||||
// marker sequence number
|
||||
$msn = max(1, ord($data[($pos + 12)]));
|
||||
// number of markers (total of APP2 used)
|
||||
$nom = max(1, ord($data[($pos + 13)]));
|
||||
// get sequence segment
|
||||
$icc[($msn - 1)] = substr($data, ($pos + 14), $length);
|
||||
// move forward to next sequence
|
||||
$offset = ($pos + 14 + $length);
|
||||
}
|
||||
// order and compact ICC segments
|
||||
if (count($icc) > 0) {
|
||||
ksort($icc);
|
||||
$icc = implode('', $icc);
|
||||
if ((ord($icc[36]) != 0x61) OR (ord($icc[37]) != 0x63) OR (ord($icc[38]) != 0x73) OR (ord($icc[39]) != 0x70)) {
|
||||
// invalid ICC profile
|
||||
$icc = false;
|
||||
}
|
||||
} else {
|
||||
$icc = false;
|
||||
}
|
||||
return array('w' => $a[0], 'h' => $a[1], 'ch' => $channels, 'icc' => $icc, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'DCTDecode', 'data' => $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract info from a PNG file without using the GD library.
|
||||
* @param $file (string) image file to parse
|
||||
* @return array structure containing the image data
|
||||
* @public static
|
||||
*/
|
||||
public static function _parsepng($file) {
|
||||
$f = @fopen($file, 'rb');
|
||||
if ($f === false) {
|
||||
// Can't open image file
|
||||
return false;
|
||||
}
|
||||
//Check signature
|
||||
if (fread($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
|
||||
// Not a PNG file
|
||||
return false;
|
||||
}
|
||||
//Read header chunk
|
||||
fread($f, 4);
|
||||
if (fread($f, 4) != 'IHDR') {
|
||||
//Incorrect PNG file
|
||||
return false;
|
||||
}
|
||||
$w = TCPDF_STATIC::_freadint($f);
|
||||
$h = TCPDF_STATIC::_freadint($f);
|
||||
$bpc = ord(fread($f, 1));
|
||||
$ct = ord(fread($f, 1));
|
||||
if ($ct == 0) {
|
||||
$colspace = 'DeviceGray';
|
||||
} elseif ($ct == 2) {
|
||||
$colspace = 'DeviceRGB';
|
||||
} elseif ($ct == 3) {
|
||||
$colspace = 'Indexed';
|
||||
} else {
|
||||
// alpha channel
|
||||
fclose($f);
|
||||
return 'pngalpha';
|
||||
}
|
||||
if (ord(fread($f, 1)) != 0) {
|
||||
// Unknown compression method
|
||||
fclose($f);
|
||||
return false;
|
||||
}
|
||||
if (ord(fread($f, 1)) != 0) {
|
||||
// Unknown filter method
|
||||
fclose($f);
|
||||
return false;
|
||||
}
|
||||
if (ord(fread($f, 1)) != 0) {
|
||||
// Interlacing not supported
|
||||
fclose($f);
|
||||
return false;
|
||||
}
|
||||
fread($f, 4);
|
||||
$channels = ($ct == 2 ? 3 : 1);
|
||||
$parms = '/DecodeParms << /Predictor 15 /Colors '.$channels.' /BitsPerComponent '.$bpc.' /Columns '.$w.' >>';
|
||||
//Scan chunks looking for palette, transparency and image data
|
||||
$pal = '';
|
||||
$trns = '';
|
||||
$data = '';
|
||||
$icc = false;
|
||||
$n = TCPDF_STATIC::_freadint($f);
|
||||
do {
|
||||
$type = fread($f, 4);
|
||||
if ($type == 'PLTE') {
|
||||
// read palette
|
||||
$pal = TCPDF_STATIC::rfread($f, $n);
|
||||
fread($f, 4);
|
||||
} elseif ($type == 'tRNS') {
|
||||
// read transparency info
|
||||
$t = TCPDF_STATIC::rfread($f, $n);
|
||||
if ($ct == 0) { // DeviceGray
|
||||
$trns = array(ord($t[1]));
|
||||
} elseif ($ct == 2) { // DeviceRGB
|
||||
$trns = array(ord($t[1]), ord($t[3]), ord($t[5]));
|
||||
} else { // Indexed
|
||||
if ($n > 0) {
|
||||
$trns = array();
|
||||
for ($i = 0; $i < $n; ++ $i) {
|
||||
$trns[] = ord($t{$i});
|
||||
}
|
||||
}
|
||||
}
|
||||
fread($f, 4);
|
||||
} elseif ($type == 'IDAT') {
|
||||
// read image data block
|
||||
$data .= TCPDF_STATIC::rfread($f, $n);
|
||||
fread($f, 4);
|
||||
} elseif ($type == 'iCCP') {
|
||||
// skip profile name
|
||||
$len = 0;
|
||||
while ((ord(fread($f, 1)) != 0) AND ($len < 80)) {
|
||||
++$len;
|
||||
}
|
||||
// get compression method
|
||||
if (ord(fread($f, 1)) != 0) {
|
||||
// Unknown filter method
|
||||
fclose($f);
|
||||
return false;
|
||||
}
|
||||
// read ICC Color Profile
|
||||
$icc = TCPDF_STATIC::rfread($f, ($n - $len - 2));
|
||||
// decompress profile
|
||||
$icc = gzuncompress($icc);
|
||||
fread($f, 4);
|
||||
} elseif ($type == 'IEND') {
|
||||
break;
|
||||
} else {
|
||||
TCPDF_STATIC::rfread($f, $n + 4);
|
||||
}
|
||||
$n = TCPDF_STATIC::_freadint($f);
|
||||
} while ($n);
|
||||
if (($colspace == 'Indexed') AND (empty($pal))) {
|
||||
// Missing palette
|
||||
fclose($f);
|
||||
return false;
|
||||
}
|
||||
fclose($f);
|
||||
return array('w' => $w, 'h' => $h, 'ch' => $channels, 'icc' => $icc, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'FlateDecode', 'parms' => $parms, 'pal' => $pal, 'trns' => $trns, 'data' => $data);
|
||||
}
|
||||
|
||||
} // END OF TCPDF_IMAGES CLASS
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
File diff suppressed because it is too large
Load Diff
24485
backend/wordpress/wp-content/plugins/woocommerce-jetpack/includes/lib/tcpdf/tcpdf.php
Executable file
24485
backend/wordpress/wp-content/plugins/woocommerce-jetpack/includes/lib/tcpdf/tcpdf.php
Executable file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_autoconfig.php
|
||||
// Version : 1.1.1
|
||||
// Begin : 2013-05-16
|
||||
// Last Update : 2014-12-18
|
||||
// Authors : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2014 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the License
|
||||
// along with TCPDF. If not, see
|
||||
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description : Try to automatically configure some TCPDF
|
||||
// constants if not defined.
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Try to automatically configure some TCPDF constants if not defined.
|
||||
* @package com.tecnick.tcpdf
|
||||
* @version 1.1.1
|
||||
*/
|
||||
|
||||
// DOCUMENT_ROOT fix for IIS Webserver
|
||||
if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) {
|
||||
if(isset($_SERVER['SCRIPT_FILENAME'])) {
|
||||
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])));
|
||||
} elseif(isset($_SERVER['PATH_TRANSLATED'])) {
|
||||
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])));
|
||||
} else {
|
||||
// define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www')
|
||||
$_SERVER['DOCUMENT_ROOT'] = '/';
|
||||
}
|
||||
}
|
||||
$_SERVER['DOCUMENT_ROOT'] = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT']);
|
||||
if (substr($_SERVER['DOCUMENT_ROOT'], -1) != '/') {
|
||||
$_SERVER['DOCUMENT_ROOT'] .= '/';
|
||||
}
|
||||
|
||||
// Load main configuration file only if the K_TCPDF_EXTERNAL_CONFIG constant is set to false.
|
||||
if (!defined('K_TCPDF_EXTERNAL_CONFIG') OR !K_TCPDF_EXTERNAL_CONFIG) {
|
||||
// define a list of default config files in order of priority
|
||||
$tcpdf_config_files = array(dirname(__FILE__).'/config/tcpdf_config.php', '/etc/php-tcpdf/tcpdf_config.php', '/etc/tcpdf/tcpdf_config.php', '/etc/tcpdf_config.php');
|
||||
foreach ($tcpdf_config_files as $tcpdf_config) {
|
||||
if (@file_exists($tcpdf_config) AND is_readable($tcpdf_config)) {
|
||||
require_once($tcpdf_config);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined('K_PATH_MAIN')) {
|
||||
define ('K_PATH_MAIN', dirname(__FILE__).'/');
|
||||
}
|
||||
|
||||
if (!defined('K_PATH_FONTS')) {
|
||||
define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/');
|
||||
}
|
||||
|
||||
if (!defined('K_PATH_URL')) {
|
||||
$k_path_url = K_PATH_MAIN; // default value for console mode
|
||||
if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) {
|
||||
if(isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND (strtolower($_SERVER['HTTPS']) != 'off')) {
|
||||
$k_path_url = 'https://';
|
||||
} else {
|
||||
$k_path_url = 'http://';
|
||||
}
|
||||
$k_path_url .= $_SERVER['HTTP_HOST'];
|
||||
$k_path_url .= str_replace( '\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1)));
|
||||
}
|
||||
define ('K_PATH_URL', $k_path_url);
|
||||
}
|
||||
|
||||
if (!defined('K_PATH_IMAGES')) {
|
||||
$tcpdf_images_dirs = array(K_PATH_MAIN.'examples/images/', K_PATH_MAIN.'images/', '/usr/share/doc/php-tcpdf/examples/images/', '/usr/share/doc/tcpdf/examples/images/', '/usr/share/doc/php/tcpdf/examples/images/', '/var/www/tcpdf/images/', '/var/www/html/tcpdf/images/', '/usr/local/apache2/htdocs/tcpdf/images/', K_PATH_MAIN);
|
||||
foreach ($tcpdf_images_dirs as $tcpdf_images_path) {
|
||||
if (@file_exists($tcpdf_images_path)) {
|
||||
define ('K_PATH_IMAGES', $tcpdf_images_path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined('PDF_HEADER_LOGO')) {
|
||||
$tcpdf_header_logo = '';
|
||||
if (@file_exists(K_PATH_IMAGES.'tcpdf_logo.jpg')) {
|
||||
$tcpdf_header_logo = 'tcpdf_logo.jpg';
|
||||
}
|
||||
define ('PDF_HEADER_LOGO', $tcpdf_header_logo);
|
||||
}
|
||||
|
||||
if (!defined('PDF_HEADER_LOGO_WIDTH')) {
|
||||
if (!empty($tcpdf_header_logo)) {
|
||||
define ('PDF_HEADER_LOGO_WIDTH', 30);
|
||||
} else {
|
||||
define ('PDF_HEADER_LOGO_WIDTH', 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined('K_PATH_CACHE')) {
|
||||
$K_PATH_CACHE = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir();
|
||||
if (substr($K_PATH_CACHE, -1) != '/') {
|
||||
$K_PATH_CACHE .= '/';
|
||||
}
|
||||
define ('K_PATH_CACHE', $K_PATH_CACHE);
|
||||
}
|
||||
|
||||
if (!defined('K_BLANK_IMAGE')) {
|
||||
define ('K_BLANK_IMAGE', '_blank.png');
|
||||
}
|
||||
|
||||
if (!defined('PDF_PAGE_FORMAT')) {
|
||||
define ('PDF_PAGE_FORMAT', 'A4');
|
||||
}
|
||||
|
||||
if (!defined('PDF_PAGE_ORIENTATION')) {
|
||||
define ('PDF_PAGE_ORIENTATION', 'P');
|
||||
}
|
||||
|
||||
if (!defined('PDF_CREATOR')) {
|
||||
define ('PDF_CREATOR', 'TCPDF');
|
||||
}
|
||||
|
||||
if (!defined('PDF_AUTHOR')) {
|
||||
define ('PDF_AUTHOR', 'TCPDF');
|
||||
}
|
||||
|
||||
if (!defined('PDF_HEADER_TITLE')) {
|
||||
define ('PDF_HEADER_TITLE', 'TCPDF Example');
|
||||
}
|
||||
|
||||
if (!defined('PDF_HEADER_STRING')) {
|
||||
define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org");
|
||||
}
|
||||
|
||||
if (!defined('PDF_UNIT')) {
|
||||
define ('PDF_UNIT', 'mm');
|
||||
}
|
||||
|
||||
if (!defined('PDF_MARGIN_HEADER')) {
|
||||
define ('PDF_MARGIN_HEADER', 5);
|
||||
}
|
||||
|
||||
if (!defined('PDF_MARGIN_FOOTER')) {
|
||||
define ('PDF_MARGIN_FOOTER', 10);
|
||||
}
|
||||
|
||||
if (!defined('PDF_MARGIN_TOP')) {
|
||||
define ('PDF_MARGIN_TOP', 27);
|
||||
}
|
||||
|
||||
if (!defined('PDF_MARGIN_BOTTOM')) {
|
||||
define ('PDF_MARGIN_BOTTOM', 25);
|
||||
}
|
||||
|
||||
if (!defined('PDF_MARGIN_LEFT')) {
|
||||
define ('PDF_MARGIN_LEFT', 15);
|
||||
}
|
||||
|
||||
if (!defined('PDF_MARGIN_RIGHT')) {
|
||||
define ('PDF_MARGIN_RIGHT', 15);
|
||||
}
|
||||
|
||||
if (!defined('PDF_FONT_NAME_MAIN')) {
|
||||
define ('PDF_FONT_NAME_MAIN', 'helvetica');
|
||||
}
|
||||
|
||||
if (!defined('PDF_FONT_SIZE_MAIN')) {
|
||||
define ('PDF_FONT_SIZE_MAIN', 10);
|
||||
}
|
||||
|
||||
if (!defined('PDF_FONT_NAME_DATA')) {
|
||||
define ('PDF_FONT_NAME_DATA', 'helvetica');
|
||||
}
|
||||
|
||||
if (!defined('PDF_FONT_SIZE_DATA')) {
|
||||
define ('PDF_FONT_SIZE_DATA', 8);
|
||||
}
|
||||
|
||||
if (!defined('PDF_FONT_MONOSPACED')) {
|
||||
define ('PDF_FONT_MONOSPACED', 'courier');
|
||||
}
|
||||
|
||||
if (!defined('PDF_IMAGE_SCALE_RATIO')) {
|
||||
define ('PDF_IMAGE_SCALE_RATIO', 1.25);
|
||||
}
|
||||
|
||||
if (!defined('HEAD_MAGNIFICATION')) {
|
||||
define('HEAD_MAGNIFICATION', 1.1);
|
||||
}
|
||||
|
||||
if (!defined('K_CELL_HEIGHT_RATIO')) {
|
||||
define('K_CELL_HEIGHT_RATIO', 1.25);
|
||||
}
|
||||
|
||||
if (!defined('K_TITLE_MAGNIFICATION')) {
|
||||
define('K_TITLE_MAGNIFICATION', 1.3);
|
||||
}
|
||||
|
||||
if (!defined('K_SMALL_RATIO')) {
|
||||
define('K_SMALL_RATIO', 2/3);
|
||||
}
|
||||
|
||||
if (!defined('K_THAI_TOPCHARS')) {
|
||||
define('K_THAI_TOPCHARS', true);
|
||||
}
|
||||
|
||||
if (!defined('K_TCPDF_CALLS_IN_HTML')) {
|
||||
define('K_TCPDF_CALLS_IN_HTML', false);
|
||||
}
|
||||
|
||||
if (!defined('K_TCPDF_THROW_EXCEPTION_ERROR')) {
|
||||
define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
|
||||
}
|
||||
|
||||
if (!defined('K_TIMEZONE')) {
|
||||
define('K_TIMEZONE', @date_default_timezone_get());
|
||||
}
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_barcodes_2d.php
|
||||
// Version : 1.0.015
|
||||
// Begin : 2009-04-07
|
||||
// Last Update : 2014-05-20
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2009-2014 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with TCPDF. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description : PHP class to creates array representations for
|
||||
// 2D barcodes to be used with TCPDF.
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* PHP class to creates array representations for 2D barcodes to be used with TCPDF.
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.015
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TCPDF2DBarcode
|
||||
* PHP class to creates array representations for 2D barcodes to be used with TCPDF (http://www.tcpdf.org).
|
||||
* @package com.tecnick.tcpdf
|
||||
* @version 1.0.015
|
||||
* @author Nicola Asuni
|
||||
*/
|
||||
class TCPDF2DBarcode {
|
||||
|
||||
/**
|
||||
* Array representation of barcode.
|
||||
* @protected
|
||||
*/
|
||||
protected $barcode_array = false;
|
||||
|
||||
/**
|
||||
* This is the class constructor.
|
||||
* Return an array representations for 2D barcodes:<ul>
|
||||
* <li>$arrcode['code'] code to be printed on text label</li>
|
||||
* <li>$arrcode['num_rows'] required number of rows</li>
|
||||
* <li>$arrcode['num_cols'] required number of columns</li>
|
||||
* <li>$arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)</li></ul>
|
||||
* @param $code (string) code to print
|
||||
* @param $type (string) type of barcode: <ul><li>DATAMATRIX : Datamatrix (ISO/IEC 16022)</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional. To use a comma character ',' on text options, replace it with the character 255: "\xff".</li><li>QRCODE : QRcode Low error correction</li><li>QRCODE,L : QRcode Low error correction</li><li>QRCODE,M : QRcode Medium error correction</li><li>QRCODE,Q : QRcode Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>TEST : Test matrix</li></ul>
|
||||
*/
|
||||
public function __construct($code, $type) {
|
||||
$this->setBarcode($code, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array representations of barcode.
|
||||
* @return array
|
||||
*/
|
||||
public function getBarcodeArray() {
|
||||
return $this->barcode_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send barcode as SVG image object to the standard output.
|
||||
* @param $w (int) Width of a single rectangle element in user units.
|
||||
* @param $h (int) Height of a single rectangle element in user units.
|
||||
* @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent).
|
||||
* @public
|
||||
*/
|
||||
public function getBarcodeSVG($w=3, $h=3, $color='black') {
|
||||
// send headers
|
||||
$code = $this->getBarcodeSVGcode($w, $h, $color);
|
||||
header('Content-Type: application/svg+xml');
|
||||
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
|
||||
header('Pragma: public');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
header('Content-Disposition: inline; filename="'.md5($code).'.svg";');
|
||||
//header('Content-Length: '.strlen($code));
|
||||
echo $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a SVG string representation of barcode.
|
||||
* @param $w (int) Width of a single rectangle element in user units.
|
||||
* @param $h (int) Height of a single rectangle element in user units.
|
||||
* @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent).
|
||||
* @return string SVG code.
|
||||
* @public
|
||||
*/
|
||||
public function getBarcodeSVGcode($w=3, $h=3, $color='black') {
|
||||
// replace table for special characters
|
||||
$repstr = array("\0" => '', '&' => '&', '<' => '<', '>' => '>');
|
||||
$svg = '<'.'?'.'xml version="1.0" standalone="no"'.'?'.'>'."\n";
|
||||
$svg .= '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'."\n";
|
||||
$svg .= '<svg width="'.round(($this->barcode_array['num_cols'] * $w), 3).'" height="'.round(($this->barcode_array['num_rows'] * $h), 3).'" version="1.1" xmlns="http://www.w3.org/2000/svg">'."\n";
|
||||
$svg .= "\t".'<desc>'.strtr($this->barcode_array['code'], $repstr).'</desc>'."\n";
|
||||
$svg .= "\t".'<g id="elements" fill="'.$color.'" stroke="none">'."\n";
|
||||
// print barcode elements
|
||||
$y = 0;
|
||||
// for each row
|
||||
for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) {
|
||||
$x = 0;
|
||||
// for each column
|
||||
for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) {
|
||||
if ($this->barcode_array['bcode'][$r][$c] == 1) {
|
||||
// draw a single barcode cell
|
||||
$svg .= "\t\t".'<rect x="'.$x.'" y="'.$y.'" width="'.$w.'" height="'.$h.'" />'."\n";
|
||||
}
|
||||
$x += $w;
|
||||
}
|
||||
$y += $h;
|
||||
}
|
||||
$svg .= "\t".'</g>'."\n";
|
||||
$svg .= '</svg>'."\n";
|
||||
return $svg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an HTML representation of barcode.
|
||||
* @param $w (int) Width of a single rectangle element in pixels.
|
||||
* @param $h (int) Height of a single rectangle element in pixels.
|
||||
* @param $color (string) Foreground color for bar elements (background is transparent).
|
||||
* @return string HTML code.
|
||||
* @public
|
||||
*/
|
||||
public function getBarcodeHTML($w=10, $h=10, $color='black') {
|
||||
$html = '<div style="font-size:0;position:relative;width:'.($w * $this->barcode_array['num_cols']).'px;height:'.($h * $this->barcode_array['num_rows']).'px;">'."\n";
|
||||
// print barcode elements
|
||||
$y = 0;
|
||||
// for each row
|
||||
for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) {
|
||||
$x = 0;
|
||||
// for each column
|
||||
for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) {
|
||||
if ($this->barcode_array['bcode'][$r][$c] == 1) {
|
||||
// draw a single barcode cell
|
||||
$html .= '<div style="background-color:'.$color.';width:'.$w.'px;height:'.$h.'px;position:absolute;left:'.$x.'px;top:'.$y.'px;"> </div>'."\n";
|
||||
}
|
||||
$x += $w;
|
||||
}
|
||||
$y += $h;
|
||||
}
|
||||
$html .= '</div>'."\n";
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a PNG image representation of barcode (requires GD or Imagick library).
|
||||
* @param $w (int) Width of a single rectangle element in pixels.
|
||||
* @param $h (int) Height of a single rectangle element in pixels.
|
||||
* @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent).
|
||||
* @public
|
||||
*/
|
||||
public function getBarcodePNG($w=3, $h=3, $color=array(0,0,0)) {
|
||||
$data = $this->getBarcodePngData($w, $h, $color);
|
||||
// send headers
|
||||
header('Content-Type: image/png');
|
||||
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
|
||||
header('Pragma: public');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
//header('Content-Length: '.strlen($data));
|
||||
echo $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a PNG image representation of barcode (requires GD or Imagick library).
|
||||
* @param $w (int) Width of a single rectangle element in pixels.
|
||||
* @param $h (int) Height of a single rectangle element in pixels.
|
||||
* @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent).
|
||||
* @return image or false in case of error.
|
||||
* @public
|
||||
*/
|
||||
public function getBarcodePngData($w=3, $h=3, $color=array(0,0,0)) {
|
||||
// calculate image size
|
||||
$width = ($this->barcode_array['num_cols'] * $w);
|
||||
$height = ($this->barcode_array['num_rows'] * $h);
|
||||
if (function_exists('imagecreate')) {
|
||||
// GD library
|
||||
$imagick = false;
|
||||
$png = imagecreate($width, $height);
|
||||
$bgcol = imagecolorallocate($png, 255, 255, 255);
|
||||
imagecolortransparent($png, $bgcol);
|
||||
$fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]);
|
||||
} elseif (extension_loaded('imagick')) {
|
||||
$imagick = true;
|
||||
$bgcol = new imagickpixel('rgb(255,255,255');
|
||||
$fgcol = new imagickpixel('rgb('.$color[0].','.$color[1].','.$color[2].')');
|
||||
$png = new Imagick();
|
||||
$png->newImage($width, $height, 'none', 'png');
|
||||
$bar = new imagickdraw();
|
||||
$bar->setfillcolor($fgcol);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// print barcode elements
|
||||
$y = 0;
|
||||
// for each row
|
||||
for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) {
|
||||
$x = 0;
|
||||
// for each column
|
||||
for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) {
|
||||
if ($this->barcode_array['bcode'][$r][$c] == 1) {
|
||||
// draw a single barcode cell
|
||||
if ($imagick) {
|
||||
$bar->rectangle($x, $y, ($x + $w - 1), ($y + $h - 1));
|
||||
} else {
|
||||
imagefilledrectangle($png, $x, $y, ($x + $w - 1), ($y + $h - 1), $fgcol);
|
||||
}
|
||||
}
|
||||
$x += $w;
|
||||
}
|
||||
$y += $h;
|
||||
}
|
||||
if ($imagick) {
|
||||
$png->drawimage($bar);
|
||||
return $png;
|
||||
} else {
|
||||
ob_start();
|
||||
imagepng($png);
|
||||
$imagedata = ob_get_clean();
|
||||
imagedestroy($png);
|
||||
return $imagedata;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the barcode.
|
||||
* @param $code (string) code to print
|
||||
* @param $type (string) type of barcode: <ul><li>DATAMATRIX : Datamatrix (ISO/IEC 16022)</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional. To use a comma character ',' on text options, replace it with the character 255: "\xff".</li><li>QRCODE : QRcode Low error correction</li><li>QRCODE,L : QRcode Low error correction</li><li>QRCODE,M : QRcode Medium error correction</li><li>QRCODE,Q : QRcode Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>TEST : Test matrix</li></ul>
|
||||
* @return array
|
||||
*/
|
||||
public function setBarcode($code, $type) {
|
||||
$mode = explode(',', $type);
|
||||
$qrtype = strtoupper($mode[0]);
|
||||
switch ($qrtype) {
|
||||
case 'DATAMATRIX': { // DATAMATRIX (ISO/IEC 16022)
|
||||
require_once(dirname(__FILE__).'/include/barcodes/datamatrix.php');
|
||||
$qrcode = new Datamatrix($code);
|
||||
$this->barcode_array = $qrcode->getBarcodeArray();
|
||||
$this->barcode_array['code'] = $code;
|
||||
break;
|
||||
}
|
||||
case 'PDF417': { // PDF417 (ISO/IEC 15438:2006)
|
||||
require_once(dirname(__FILE__).'/include/barcodes/pdf417.php');
|
||||
if (!isset($mode[1]) OR ($mode[1] === '')) {
|
||||
$aspectratio = 2; // default aspect ratio (width / height)
|
||||
} else {
|
||||
$aspectratio = floatval($mode[1]);
|
||||
}
|
||||
if (!isset($mode[2]) OR ($mode[2] === '')) {
|
||||
$ecl = -1; // default error correction level (auto)
|
||||
} else {
|
||||
$ecl = intval($mode[2]);
|
||||
}
|
||||
// set macro block
|
||||
$macro = array();
|
||||
if (isset($mode[3]) AND ($mode[3] !== '') AND isset($mode[4]) AND ($mode[4] !== '') AND isset($mode[5]) AND ($mode[5] !== '')) {
|
||||
$macro['segment_total'] = intval($mode[3]);
|
||||
$macro['segment_index'] = intval($mode[4]);
|
||||
$macro['file_id'] = strtr($mode[5], "\xff", ',');
|
||||
for ($i = 0; $i < 7; ++$i) {
|
||||
$o = $i + 6;
|
||||
if (isset($mode[$o]) AND ($mode[$o] !== '')) {
|
||||
// add option
|
||||
$macro['option_'.$i] = strtr($mode[$o], "\xff", ',');
|
||||
}
|
||||
}
|
||||
}
|
||||
$qrcode = new PDF417($code, $ecl, $aspectratio, $macro);
|
||||
$this->barcode_array = $qrcode->getBarcodeArray();
|
||||
$this->barcode_array['code'] = $code;
|
||||
break;
|
||||
}
|
||||
case 'QRCODE': { // QR-CODE
|
||||
require_once(dirname(__FILE__).'/include/barcodes/qrcode.php');
|
||||
if (!isset($mode[1]) OR (!in_array($mode[1],array('L','M','Q','H')))) {
|
||||
$mode[1] = 'L'; // Ddefault: Low error correction
|
||||
}
|
||||
$qrcode = new QRcode($code, strtoupper($mode[1]));
|
||||
$this->barcode_array = $qrcode->getBarcodeArray();
|
||||
$this->barcode_array['code'] = $code;
|
||||
break;
|
||||
}
|
||||
case 'RAW':
|
||||
case 'RAW2': { // RAW MODE
|
||||
// remove spaces
|
||||
$code = preg_replace('/[\s]*/si', '', $code);
|
||||
if (strlen($code) < 3) {
|
||||
break;
|
||||
}
|
||||
if ($qrtype == 'RAW') {
|
||||
// comma-separated rows
|
||||
$rows = explode(',', $code);
|
||||
} else { // RAW2
|
||||
// rows enclosed in square parentheses
|
||||
$code = substr($code, 1, -1);
|
||||
$rows = explode('][', $code);
|
||||
}
|
||||
$this->barcode_array['num_rows'] = count($rows);
|
||||
$this->barcode_array['num_cols'] = strlen($rows[0]);
|
||||
$this->barcode_array['bcode'] = array();
|
||||
foreach ($rows as $r) {
|
||||
$this->barcode_array['bcode'][] = str_split($r, 1);
|
||||
}
|
||||
$this->barcode_array['code'] = $code;
|
||||
break;
|
||||
}
|
||||
case 'TEST': { // TEST MODE
|
||||
$this->barcode_array['num_rows'] = 5;
|
||||
$this->barcode_array['num_cols'] = 15;
|
||||
$this->barcode_array['bcode'] = array(
|
||||
array(1,1,1,0,1,1,1,0,1,1,1,0,1,1,1),
|
||||
array(0,1,0,0,1,0,0,0,1,0,0,0,0,1,0),
|
||||
array(0,1,0,0,1,1,0,0,1,1,1,0,0,1,0),
|
||||
array(0,1,0,0,1,0,0,0,0,0,1,0,0,1,0),
|
||||
array(0,1,0,0,1,1,1,0,1,1,1,0,0,1,0));
|
||||
$this->barcode_array['code'] = $code;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->barcode_array = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end of class
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_import.php
|
||||
// Version : 1.0.001
|
||||
// Begin : 2011-05-23
|
||||
// Last Update : 2013-09-17
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2013 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the License
|
||||
// along with TCPDF. If not, see
|
||||
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description : This is a PHP class extension of the TCPDF library to
|
||||
// import existing PDF documents.
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* !!! THIS CLASS IS UNDER DEVELOPMENT !!!
|
||||
* This is a PHP class extension of the TCPDF (http://www.tcpdf.org) library to import existing PDF documents.<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.001
|
||||
*/
|
||||
|
||||
// include the TCPDF class
|
||||
require_once(dirname(__FILE__).'/tcpdf.php');
|
||||
// include PDF parser class
|
||||
require_once(dirname(__FILE__).'/tcpdf_parser.php');
|
||||
|
||||
/**
|
||||
* @class TCPDF_IMPORT
|
||||
* !!! THIS CLASS IS UNDER DEVELOPMENT !!!
|
||||
* PHP class extension of the TCPDF (http://www.tcpdf.org) library to import existing PDF documents.<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @brief PHP class extension of the TCPDF library to import existing PDF documents.
|
||||
* @version 1.0.001
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_IMPORT extends TCPDF {
|
||||
|
||||
/**
|
||||
* Import an existing PDF document
|
||||
* @param $filename (string) Filename of the PDF document to import.
|
||||
* @return true in case of success, false otherwise
|
||||
* @public
|
||||
* @since 1.0.000 (2011-05-24)
|
||||
*/
|
||||
public function importPDF($filename) {
|
||||
// load document
|
||||
$rawdata = file_get_contents($filename);
|
||||
if ($rawdata === false) {
|
||||
$this->Error('Unable to get the content of the file: '.$filename);
|
||||
}
|
||||
// configuration parameters for parser
|
||||
$cfg = array(
|
||||
'die_for_errors' => false,
|
||||
'ignore_filter_decoding_errors' => true,
|
||||
'ignore_missing_filter_decoders' => true,
|
||||
);
|
||||
try {
|
||||
// parse PDF data
|
||||
$pdf = new TCPDF_PARSER($rawdata, $cfg);
|
||||
} catch (Exception $e) {
|
||||
die($e->getMessage());
|
||||
}
|
||||
// get the parsed data
|
||||
$data = $pdf->getParsedData();
|
||||
// release some memory
|
||||
unset($rawdata);
|
||||
|
||||
// ...
|
||||
|
||||
|
||||
print_r($data); // DEBUG
|
||||
|
||||
|
||||
unset($pdf);
|
||||
}
|
||||
|
||||
} // END OF CLASS
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
@@ -0,0 +1,815 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_parser.php
|
||||
// Version : 1.0.16
|
||||
// Begin : 2011-05-23
|
||||
// Last Update : 2015-04-28
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2015 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the License
|
||||
// along with TCPDF. If not, see
|
||||
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description : This is a PHP class for parsing PDF documents.
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This is a PHP class for parsing PDF documents.<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.15
|
||||
*/
|
||||
|
||||
// include class for decoding filters
|
||||
require_once(dirname(__FILE__).'/include/tcpdf_filters.php');
|
||||
|
||||
/**
|
||||
* @class TCPDF_PARSER
|
||||
* This is a PHP class for parsing PDF documents.<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @brief This is a PHP class for parsing PDF documents..
|
||||
* @version 1.0.15
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_PARSER {
|
||||
|
||||
/**
|
||||
* Raw content of the PDF document.
|
||||
* @private
|
||||
*/
|
||||
private $pdfdata = '';
|
||||
|
||||
/**
|
||||
* XREF data.
|
||||
* @protected
|
||||
*/
|
||||
protected $xref = array();
|
||||
|
||||
/**
|
||||
* Array of PDF objects.
|
||||
* @protected
|
||||
*/
|
||||
protected $objects = array();
|
||||
|
||||
/**
|
||||
* Class object for decoding filters.
|
||||
* @private
|
||||
*/
|
||||
private $FilterDecoders;
|
||||
|
||||
/**
|
||||
* Array of configuration parameters.
|
||||
* @private
|
||||
*/
|
||||
private $cfg = array(
|
||||
'die_for_errors' => false,
|
||||
'ignore_filter_decoding_errors' => true,
|
||||
'ignore_missing_filter_decoders' => true,
|
||||
);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parse a PDF document an return an array of objects.
|
||||
* @param $data (string) PDF data to parse.
|
||||
* @param $cfg (array) Array of configuration parameters:
|
||||
* 'die_for_errors' : if true termitate the program execution in case of error, otherwise thows an exception;
|
||||
* 'ignore_filter_decoding_errors' : if true ignore filter decoding errors;
|
||||
* 'ignore_missing_filter_decoders' : if true ignore missing filter decoding errors.
|
||||
* @public
|
||||
* @since 1.0.000 (2011-05-24)
|
||||
*/
|
||||
public function __construct($data, $cfg=array()) {
|
||||
if (empty($data)) {
|
||||
$this->Error('Empty PDF data.');
|
||||
}
|
||||
// find the pdf header starting position
|
||||
if (($trimpos = strpos($data, '%PDF-')) === FALSE) {
|
||||
$this->Error('Invalid PDF data: missing %PDF header.');
|
||||
}
|
||||
// get PDF content string
|
||||
$this->pdfdata = substr($data, $trimpos);
|
||||
// get length
|
||||
$pdflen = strlen($this->pdfdata);
|
||||
// set configuration parameters
|
||||
$this->setConfig($cfg);
|
||||
// get xref and trailer data
|
||||
$this->xref = $this->getXrefData();
|
||||
// parse all document objects
|
||||
$this->objects = array();
|
||||
foreach ($this->xref['xref'] as $obj => $offset) {
|
||||
if (!isset($this->objects[$obj]) AND ($offset > 0)) {
|
||||
// decode objects with positive offset
|
||||
$this->objects[$obj] = $this->getIndirectObject($obj, $offset, true);
|
||||
}
|
||||
}
|
||||
// release some memory
|
||||
unset($this->pdfdata);
|
||||
$this->pdfdata = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the configuration parameters.
|
||||
* @param $cfg (array) Array of configuration parameters:
|
||||
* 'die_for_errors' : if true termitate the program execution in case of error, otherwise thows an exception;
|
||||
* 'ignore_filter_decoding_errors' : if true ignore filter decoding errors;
|
||||
* 'ignore_missing_filter_decoders' : if true ignore missing filter decoding errors.
|
||||
* @public
|
||||
*/
|
||||
protected function setConfig($cfg) {
|
||||
if (isset($cfg['die_for_errors'])) {
|
||||
$this->cfg['die_for_errors'] = !!$cfg['die_for_errors'];
|
||||
}
|
||||
if (isset($cfg['ignore_filter_decoding_errors'])) {
|
||||
$this->cfg['ignore_filter_decoding_errors'] = !!$cfg['ignore_filter_decoding_errors'];
|
||||
}
|
||||
if (isset($cfg['ignore_missing_filter_decoders'])) {
|
||||
$this->cfg['ignore_missing_filter_decoders'] = !!$cfg['ignore_missing_filter_decoders'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of parsed PDF document objects.
|
||||
* @return (array) Array of parsed PDF document objects.
|
||||
* @public
|
||||
* @since 1.0.000 (2011-06-26)
|
||||
*/
|
||||
public function getParsedData() {
|
||||
return array($this->xref, $this->objects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Cross-Reference (xref) table and trailer data from PDF document data.
|
||||
* @param $offset (int) xref offset (if know).
|
||||
* @param $xref (array) previous xref array (if any).
|
||||
* @return Array containing xref and trailer data.
|
||||
* @protected
|
||||
* @since 1.0.000 (2011-05-24)
|
||||
*/
|
||||
protected function getXrefData($offset=0, $xref=array()) {
|
||||
if ($offset == 0) {
|
||||
// find last startxref
|
||||
if (preg_match_all('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_SET_ORDER, $offset) == 0) {
|
||||
$this->Error('Unable to find startxref');
|
||||
}
|
||||
$matches = array_pop($matches);
|
||||
$startxref = $matches[1];
|
||||
} elseif (strpos($this->pdfdata, 'xref', $offset) == $offset) {
|
||||
// Already pointing at the xref table
|
||||
$startxref = $offset;
|
||||
} elseif (preg_match('/([0-9]+[\s][0-9]+[\s]obj)/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) {
|
||||
// Cross-Reference Stream object
|
||||
$startxref = $offset;
|
||||
} elseif (preg_match('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) {
|
||||
// startxref found
|
||||
$startxref = $matches[1][0];
|
||||
} else {
|
||||
$this->Error('Unable to find startxref');
|
||||
}
|
||||
// check xref position
|
||||
if (strpos($this->pdfdata, 'xref', $startxref) == $startxref) {
|
||||
// Cross-Reference
|
||||
$xref = $this->decodeXref($startxref, $xref);
|
||||
} else {
|
||||
// Cross-Reference Stream
|
||||
$xref = $this->decodeXrefStream($startxref, $xref);
|
||||
}
|
||||
if (empty($xref)) {
|
||||
$this->Error('Unable to find xref');
|
||||
}
|
||||
return $xref;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the Cross-Reference section
|
||||
* @param $startxref (int) Offset at which the xref section starts (position of the 'xref' keyword).
|
||||
* @param $xref (array) Previous xref array (if any).
|
||||
* @return Array containing xref and trailer data.
|
||||
* @protected
|
||||
* @since 1.0.000 (2011-06-20)
|
||||
*/
|
||||
protected function decodeXref($startxref, $xref=array()) {
|
||||
$startxref += 4; // 4 is the length of the word 'xref'
|
||||
// skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP)
|
||||
$offset = $startxref + strspn($this->pdfdata, "\x00\x09\x0a\x0c\x0d\x20", $startxref);
|
||||
// initialize object number
|
||||
$obj_num = 0;
|
||||
// search for cross-reference entries or subsection
|
||||
while (preg_match('/([0-9]+)[\x20]([0-9]+)[\x20]?([nf]?)(\r\n|[\x20]?[\r\n])/', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
|
||||
if ($matches[0][1] != $offset) {
|
||||
// we are on another section
|
||||
break;
|
||||
}
|
||||
$offset += strlen($matches[0][0]);
|
||||
if ($matches[3][0] == 'n') {
|
||||
// create unique object index: [object number]_[generation number]
|
||||
$index = $obj_num.'_'.intval($matches[2][0]);
|
||||
// check if object already exist
|
||||
if (!isset($xref['xref'][$index])) {
|
||||
// store object offset position
|
||||
$xref['xref'][$index] = intval($matches[1][0]);
|
||||
}
|
||||
++$obj_num;
|
||||
} elseif ($matches[3][0] == 'f') {
|
||||
++$obj_num;
|
||||
} else {
|
||||
// object number (index)
|
||||
$obj_num = intval($matches[1][0]);
|
||||
}
|
||||
}
|
||||
// get trailer data
|
||||
if (preg_match('/trailer[\s]*<<(.*)>>/isU', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
|
||||
$trailer_data = $matches[1][0];
|
||||
if (!isset($xref['trailer']) OR empty($xref['trailer'])) {
|
||||
// get only the last updated version
|
||||
$xref['trailer'] = array();
|
||||
// parse trailer_data
|
||||
if (preg_match('/Size[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
|
||||
$xref['trailer']['size'] = intval($matches[1]);
|
||||
}
|
||||
if (preg_match('/Root[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
|
||||
$xref['trailer']['root'] = intval($matches[1]).'_'.intval($matches[2]);
|
||||
}
|
||||
if (preg_match('/Encrypt[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
|
||||
$xref['trailer']['encrypt'] = intval($matches[1]).'_'.intval($matches[2]);
|
||||
}
|
||||
if (preg_match('/Info[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
|
||||
$xref['trailer']['info'] = intval($matches[1]).'_'.intval($matches[2]);
|
||||
}
|
||||
if (preg_match('/ID[\s]*[\[][\s]*[<]([^>]*)[>][\s]*[<]([^>]*)[>]/i', $trailer_data, $matches) > 0) {
|
||||
$xref['trailer']['id'] = array();
|
||||
$xref['trailer']['id'][0] = $matches[1];
|
||||
$xref['trailer']['id'][1] = $matches[2];
|
||||
}
|
||||
}
|
||||
if (preg_match('/Prev[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
|
||||
// get previous xref
|
||||
$xref = $this->getXrefData(intval($matches[1]), $xref);
|
||||
}
|
||||
} else {
|
||||
$this->Error('Unable to find trailer');
|
||||
}
|
||||
return $xref;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the Cross-Reference Stream section
|
||||
* @param $startxref (int) Offset at which the xref section starts.
|
||||
* @param $xref (array) Previous xref array (if any).
|
||||
* @return Array containing xref and trailer data.
|
||||
* @protected
|
||||
* @since 1.0.003 (2013-03-16)
|
||||
*/
|
||||
protected function decodeXrefStream($startxref, $xref=array()) {
|
||||
// try to read Cross-Reference Stream
|
||||
$xrefobj = $this->getRawObject($startxref);
|
||||
$xrefcrs = $this->getIndirectObject($xrefobj[1], $startxref, true);
|
||||
if (!isset($xref['trailer']) OR empty($xref['trailer'])) {
|
||||
// get only the last updated version
|
||||
$xref['trailer'] = array();
|
||||
$filltrailer = true;
|
||||
} else {
|
||||
$filltrailer = false;
|
||||
}
|
||||
if (!isset($xref['xref'])) {
|
||||
$xref['xref'] = array();
|
||||
}
|
||||
$valid_crs = false;
|
||||
$columns = 0;
|
||||
$sarr = $xrefcrs[0][1];
|
||||
if (!is_array($sarr)) {
|
||||
$sarr = array();
|
||||
}
|
||||
foreach ($sarr as $k => $v) {
|
||||
if (($v[0] == '/') AND ($v[1] == 'Type') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == '/') AND ($sarr[($k +1)][1] == 'XRef'))) {
|
||||
$valid_crs = true;
|
||||
} elseif (($v[0] == '/') AND ($v[1] == 'Index') AND (isset($sarr[($k +1)]))) {
|
||||
// first object number in the subsection
|
||||
$index_first = intval($sarr[($k +1)][1][0][1]);
|
||||
// number of entries in the subsection
|
||||
$index_entries = intval($sarr[($k +1)][1][1][1]);
|
||||
} elseif (($v[0] == '/') AND ($v[1] == 'Prev') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'numeric'))) {
|
||||
// get previous xref offset
|
||||
$prevxref = intval($sarr[($k +1)][1]);
|
||||
} elseif (($v[0] == '/') AND ($v[1] == 'W') AND (isset($sarr[($k +1)]))) {
|
||||
// number of bytes (in the decoded stream) of the corresponding field
|
||||
$wb = array();
|
||||
$wb[0] = intval($sarr[($k +1)][1][0][1]);
|
||||
$wb[1] = intval($sarr[($k +1)][1][1][1]);
|
||||
$wb[2] = intval($sarr[($k +1)][1][2][1]);
|
||||
} elseif (($v[0] == '/') AND ($v[1] == 'DecodeParms') AND (isset($sarr[($k +1)][1]))) {
|
||||
$decpar = $sarr[($k +1)][1];
|
||||
foreach ($decpar as $kdc => $vdc) {
|
||||
if (($vdc[0] == '/') AND ($vdc[1] == 'Columns') AND (isset($decpar[($kdc +1)]) AND ($decpar[($kdc +1)][0] == 'numeric'))) {
|
||||
$columns = intval($decpar[($kdc +1)][1]);
|
||||
} elseif (($vdc[0] == '/') AND ($vdc[1] == 'Predictor') AND (isset($decpar[($kdc +1)]) AND ($decpar[($kdc +1)][0] == 'numeric'))) {
|
||||
$predictor = intval($decpar[($kdc +1)][1]);
|
||||
}
|
||||
}
|
||||
} elseif ($filltrailer) {
|
||||
if (($v[0] == '/') AND ($v[1] == 'Size') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'numeric'))) {
|
||||
$xref['trailer']['size'] = $sarr[($k +1)][1];
|
||||
} elseif (($v[0] == '/') AND ($v[1] == 'Root') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'objref'))) {
|
||||
$xref['trailer']['root'] = $sarr[($k +1)][1];
|
||||
} elseif (($v[0] == '/') AND ($v[1] == 'Info') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'objref'))) {
|
||||
$xref['trailer']['info'] = $sarr[($k +1)][1];
|
||||
} elseif (($v[0] == '/') AND ($v[1] == 'Encrypt') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'objref'))) {
|
||||
$xref['trailer']['encrypt'] = $sarr[($k +1)][1];
|
||||
} elseif (($v[0] == '/') AND ($v[1] == 'ID') AND (isset($sarr[($k +1)]))) {
|
||||
$xref['trailer']['id'] = array();
|
||||
$xref['trailer']['id'][0] = $sarr[($k +1)][1][0][1];
|
||||
$xref['trailer']['id'][1] = $sarr[($k +1)][1][1][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
// decode data
|
||||
if ($valid_crs AND isset($xrefcrs[1][3][0])) {
|
||||
// number of bytes in a row
|
||||
$rowlen = ($columns + 1);
|
||||
// convert the stream into an array of integers
|
||||
$sdata = unpack('C*', $xrefcrs[1][3][0]);
|
||||
// split the rows
|
||||
$sdata = array_chunk($sdata, $rowlen);
|
||||
// initialize decoded array
|
||||
$ddata = array();
|
||||
// initialize first row with zeros
|
||||
$prev_row = array_fill (0, $rowlen, 0);
|
||||
// for each row apply PNG unpredictor
|
||||
foreach ($sdata as $k => $row) {
|
||||
// initialize new row
|
||||
$ddata[$k] = array();
|
||||
// get PNG predictor value
|
||||
$predictor = (10 + $row[0]);
|
||||
// for each byte on the row
|
||||
for ($i=1; $i<=$columns; ++$i) {
|
||||
// new index
|
||||
$j = ($i - 1);
|
||||
$row_up = $prev_row[$j];
|
||||
if ($i == 1) {
|
||||
$row_left = 0;
|
||||
$row_upleft = 0;
|
||||
} else {
|
||||
$row_left = $row[($i - 1)];
|
||||
$row_upleft = $prev_row[($j - 1)];
|
||||
}
|
||||
switch ($predictor) {
|
||||
case 10: { // PNG prediction (on encoding, PNG None on all rows)
|
||||
$ddata[$k][$j] = $row[$i];
|
||||
break;
|
||||
}
|
||||
case 11: { // PNG prediction (on encoding, PNG Sub on all rows)
|
||||
$ddata[$k][$j] = (($row[$i] + $row_left) & 0xff);
|
||||
break;
|
||||
}
|
||||
case 12: { // PNG prediction (on encoding, PNG Up on all rows)
|
||||
$ddata[$k][$j] = (($row[$i] + $row_up) & 0xff);
|
||||
break;
|
||||
}
|
||||
case 13: { // PNG prediction (on encoding, PNG Average on all rows)
|
||||
$ddata[$k][$j] = (($row[$i] + (($row_left + $row_up) / 2)) & 0xff);
|
||||
break;
|
||||
}
|
||||
case 14: { // PNG prediction (on encoding, PNG Paeth on all rows)
|
||||
// initial estimate
|
||||
$p = ($row_left + $row_up - $row_upleft);
|
||||
// distances
|
||||
$pa = abs($p - $row_left);
|
||||
$pb = abs($p - $row_up);
|
||||
$pc = abs($p - $row_upleft);
|
||||
$pmin = min($pa, $pb, $pc);
|
||||
// return minimum distance
|
||||
switch ($pmin) {
|
||||
case $pa: {
|
||||
$ddata[$k][$j] = (($row[$i] + $row_left) & 0xff);
|
||||
break;
|
||||
}
|
||||
case $pb: {
|
||||
$ddata[$k][$j] = (($row[$i] + $row_up) & 0xff);
|
||||
break;
|
||||
}
|
||||
case $pc: {
|
||||
$ddata[$k][$j] = (($row[$i] + $row_upleft) & 0xff);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: { // PNG prediction (on encoding, PNG optimum)
|
||||
$this->Error('Unknown PNG predictor');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$prev_row = $ddata[$k];
|
||||
} // end for each row
|
||||
// complete decoding
|
||||
$sdata = array();
|
||||
// for every row
|
||||
foreach ($ddata as $k => $row) {
|
||||
// initialize new row
|
||||
$sdata[$k] = array(0, 0, 0);
|
||||
if ($wb[0] == 0) {
|
||||
// default type field
|
||||
$sdata[$k][0] = 1;
|
||||
}
|
||||
$i = 0; // count bytes in the row
|
||||
// for every column
|
||||
for ($c = 0; $c < 3; ++$c) {
|
||||
// for every byte on the column
|
||||
for ($b = 0; $b < $wb[$c]; ++$b) {
|
||||
if (isset($row[$i])) {
|
||||
$sdata[$k][$c] += ($row[$i] << (($wb[$c] - 1 - $b) * 8));
|
||||
}
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
}
|
||||
$ddata = array();
|
||||
// fill xref
|
||||
if (isset($index_first)) {
|
||||
$obj_num = $index_first;
|
||||
} else {
|
||||
$obj_num = 0;
|
||||
}
|
||||
foreach ($sdata as $k => $row) {
|
||||
switch ($row[0]) {
|
||||
case 0: { // (f) linked list of free objects
|
||||
break;
|
||||
}
|
||||
case 1: { // (n) objects that are in use but are not compressed
|
||||
// create unique object index: [object number]_[generation number]
|
||||
$index = $obj_num.'_'.$row[2];
|
||||
// check if object already exist
|
||||
if (!isset($xref['xref'][$index])) {
|
||||
// store object offset position
|
||||
$xref['xref'][$index] = $row[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: { // compressed objects
|
||||
// $row[1] = object number of the object stream in which this object is stored
|
||||
// $row[2] = index of this object within the object stream
|
||||
$index = $row[1].'_0_'.$row[2];
|
||||
$xref['xref'][$index] = -1;
|
||||
break;
|
||||
}
|
||||
default: { // null objects
|
||||
break;
|
||||
}
|
||||
}
|
||||
++$obj_num;
|
||||
}
|
||||
} // end decoding data
|
||||
if (isset($prevxref)) {
|
||||
// get previous xref
|
||||
$xref = $this->getXrefData($prevxref, $xref);
|
||||
}
|
||||
return $xref;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object type, raw value and offset to next object
|
||||
* @param $offset (int) Object offset.
|
||||
* @return array containing object type, raw value and offset to next object
|
||||
* @protected
|
||||
* @since 1.0.000 (2011-06-20)
|
||||
*/
|
||||
protected function getRawObject($offset=0) {
|
||||
$objtype = ''; // object type to be returned
|
||||
$objval = ''; // object value to be returned
|
||||
// skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP)
|
||||
$offset += strspn($this->pdfdata, "\x00\x09\x0a\x0c\x0d\x20", $offset);
|
||||
// get first char
|
||||
$char = $this->pdfdata[$offset];
|
||||
// get object type
|
||||
switch ($char) {
|
||||
case '%': { // \x25 PERCENT SIGN
|
||||
// skip comment and search for next token
|
||||
$next = strcspn($this->pdfdata, "\r\n", $offset);
|
||||
if ($next > 0) {
|
||||
$offset += $next;
|
||||
return $this->getRawObject($offset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '/': { // \x2F SOLIDUS
|
||||
// name object
|
||||
$objtype = $char;
|
||||
++$offset;
|
||||
if (preg_match('/^([^\x00\x09\x0a\x0c\x0d\x20\s\x28\x29\x3c\x3e\x5b\x5d\x7b\x7d\x2f\x25]+)/', substr($this->pdfdata, $offset, 256), $matches) == 1) {
|
||||
$objval = $matches[1]; // unescaped value
|
||||
$offset += strlen($objval);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '(': // \x28 LEFT PARENTHESIS
|
||||
case ')': { // \x29 RIGHT PARENTHESIS
|
||||
// literal string object
|
||||
$objtype = $char;
|
||||
++$offset;
|
||||
$strpos = $offset;
|
||||
if ($char == '(') {
|
||||
$open_bracket = 1;
|
||||
while ($open_bracket > 0) {
|
||||
if (!isset($this->pdfdata{$strpos})) {
|
||||
break;
|
||||
}
|
||||
$ch = $this->pdfdata{$strpos};
|
||||
switch ($ch) {
|
||||
case '\\': { // REVERSE SOLIDUS (5Ch) (Backslash)
|
||||
// skip next character
|
||||
++$strpos;
|
||||
break;
|
||||
}
|
||||
case '(': { // LEFT PARENHESIS (28h)
|
||||
++$open_bracket;
|
||||
break;
|
||||
}
|
||||
case ')': { // RIGHT PARENTHESIS (29h)
|
||||
--$open_bracket;
|
||||
break;
|
||||
}
|
||||
}
|
||||
++$strpos;
|
||||
}
|
||||
$objval = substr($this->pdfdata, $offset, ($strpos - $offset - 1));
|
||||
$offset = $strpos;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '[': // \x5B LEFT SQUARE BRACKET
|
||||
case ']': { // \x5D RIGHT SQUARE BRACKET
|
||||
// array object
|
||||
$objtype = $char;
|
||||
++$offset;
|
||||
if ($char == '[') {
|
||||
// get array content
|
||||
$objval = array();
|
||||
do {
|
||||
// get element
|
||||
$element = $this->getRawObject($offset);
|
||||
$offset = $element[2];
|
||||
$objval[] = $element;
|
||||
} while ($element[0] != ']');
|
||||
// remove closing delimiter
|
||||
array_pop($objval);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '<': // \x3C LESS-THAN SIGN
|
||||
case '>': { // \x3E GREATER-THAN SIGN
|
||||
if (isset($this->pdfdata{($offset + 1)}) AND ($this->pdfdata{($offset + 1)} == $char)) {
|
||||
// dictionary object
|
||||
$objtype = $char.$char;
|
||||
$offset += 2;
|
||||
if ($char == '<') {
|
||||
// get array content
|
||||
$objval = array();
|
||||
do {
|
||||
// get element
|
||||
$element = $this->getRawObject($offset);
|
||||
$offset = $element[2];
|
||||
$objval[] = $element;
|
||||
} while ($element[0] != '>>');
|
||||
// remove closing delimiter
|
||||
array_pop($objval);
|
||||
}
|
||||
} else {
|
||||
// hexadecimal string object
|
||||
$objtype = $char;
|
||||
++$offset;
|
||||
if (($char == '<') AND (preg_match('/^([0-9A-Fa-f\x09\x0a\x0c\x0d\x20]+)>/iU', substr($this->pdfdata, $offset), $matches) == 1)) {
|
||||
// remove white space characters
|
||||
$objval = strtr($matches[1], "\x09\x0a\x0c\x0d\x20", '');
|
||||
$offset += strlen($matches[0]);
|
||||
} elseif (($endpos = strpos($this->pdfdata, '>', $offset)) !== FALSE) {
|
||||
$offset = $endpos + 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (substr($this->pdfdata, $offset, 6) == 'endobj') {
|
||||
// indirect object
|
||||
$objtype = 'endobj';
|
||||
$offset += 6;
|
||||
} elseif (substr($this->pdfdata, $offset, 4) == 'null') {
|
||||
// null object
|
||||
$objtype = 'null';
|
||||
$offset += 4;
|
||||
$objval = 'null';
|
||||
} elseif (substr($this->pdfdata, $offset, 4) == 'true') {
|
||||
// boolean true object
|
||||
$objtype = 'boolean';
|
||||
$offset += 4;
|
||||
$objval = 'true';
|
||||
} elseif (substr($this->pdfdata, $offset, 5) == 'false') {
|
||||
// boolean false object
|
||||
$objtype = 'boolean';
|
||||
$offset += 5;
|
||||
$objval = 'false';
|
||||
} elseif (substr($this->pdfdata, $offset, 6) == 'stream') {
|
||||
// start stream object
|
||||
$objtype = 'stream';
|
||||
$offset += 6;
|
||||
if (preg_match('/^([\r]?[\n])/isU', substr($this->pdfdata, $offset), $matches) == 1) {
|
||||
$offset += strlen($matches[0]);
|
||||
if (preg_match('/(endstream)[\x09\x0a\x0c\x0d\x20]/isU', substr($this->pdfdata, $offset), $matches, PREG_OFFSET_CAPTURE) == 1) {
|
||||
$objval = substr($this->pdfdata, $offset, $matches[0][1]);
|
||||
$offset += $matches[1][1];
|
||||
}
|
||||
}
|
||||
} elseif (substr($this->pdfdata, $offset, 9) == 'endstream') {
|
||||
// end stream object
|
||||
$objtype = 'endstream';
|
||||
$offset += 9;
|
||||
} elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+R/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) {
|
||||
// indirect object reference
|
||||
$objtype = 'objref';
|
||||
$offset += strlen($matches[0]);
|
||||
$objval = intval($matches[1]).'_'.intval($matches[2]);
|
||||
} elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+obj/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) {
|
||||
// object start
|
||||
$objtype = 'obj';
|
||||
$objval = intval($matches[1]).'_'.intval($matches[2]);
|
||||
$offset += strlen ($matches[0]);
|
||||
} elseif (($numlen = strspn($this->pdfdata, '+-.0123456789', $offset)) > 0) {
|
||||
// numeric object
|
||||
$objtype = 'numeric';
|
||||
$objval = substr($this->pdfdata, $offset, $numlen);
|
||||
$offset += $numlen;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return array($objtype, $objval, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content of indirect object.
|
||||
* @param $obj_ref (string) Object number and generation number separated by underscore character.
|
||||
* @param $offset (int) Object offset.
|
||||
* @param $decoding (boolean) If true decode streams.
|
||||
* @return array containing object data.
|
||||
* @protected
|
||||
* @since 1.0.000 (2011-05-24)
|
||||
*/
|
||||
protected function getIndirectObject($obj_ref, $offset=0, $decoding=true) {
|
||||
$obj = explode('_', $obj_ref);
|
||||
if (($obj === false) OR (count($obj) != 2)) {
|
||||
$this->Error('Invalid object reference: '.$obj);
|
||||
return;
|
||||
}
|
||||
$objref = $obj[0].' '.$obj[1].' obj';
|
||||
// ignore leading zeros
|
||||
$offset += strspn($this->pdfdata, '0', $offset);
|
||||
if (strpos($this->pdfdata, $objref, $offset) != $offset) {
|
||||
// an indirect reference to an undefined object shall be considered a reference to the null object
|
||||
return array('null', 'null', $offset);
|
||||
}
|
||||
// starting position of object content
|
||||
$offset += strlen($objref);
|
||||
// get array of object content
|
||||
$objdata = array();
|
||||
$i = 0; // object main index
|
||||
do {
|
||||
$oldoffset = $offset;
|
||||
// get element
|
||||
$element = $this->getRawObject($offset);
|
||||
$offset = $element[2];
|
||||
// decode stream using stream's dictionary information
|
||||
if ($decoding AND ($element[0] == 'stream') AND (isset($objdata[($i - 1)][0])) AND ($objdata[($i - 1)][0] == '<<')) {
|
||||
$element[3] = $this->decodeStream($objdata[($i - 1)][1], $element[1]);
|
||||
}
|
||||
$objdata[$i] = $element;
|
||||
++$i;
|
||||
} while (($element[0] != 'endobj') AND ($offset != $oldoffset));
|
||||
// remove closing delimiter
|
||||
array_pop($objdata);
|
||||
// return raw object content
|
||||
return $objdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content of object, resolving indect object reference if necessary.
|
||||
* @param $obj (string) Object value.
|
||||
* @return array containing object data.
|
||||
* @protected
|
||||
* @since 1.0.000 (2011-06-26)
|
||||
*/
|
||||
protected function getObjectVal($obj) {
|
||||
if ($obj[0] == 'objref') {
|
||||
// reference to indirect object
|
||||
if (isset($this->objects[$obj[1]])) {
|
||||
// this object has been already parsed
|
||||
return $this->objects[$obj[1]];
|
||||
} elseif (isset($this->xref[$obj[1]])) {
|
||||
// parse new object
|
||||
$this->objects[$obj[1]] = $this->getIndirectObject($obj[1], $this->xref[$obj[1]], false);
|
||||
return $this->objects[$obj[1]];
|
||||
}
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the specified stream.
|
||||
* @param $sdic (array) Stream's dictionary array.
|
||||
* @param $stream (string) Stream to decode.
|
||||
* @return array containing decoded stream data and remaining filters.
|
||||
* @protected
|
||||
* @since 1.0.000 (2011-06-22)
|
||||
*/
|
||||
protected function decodeStream($sdic, $stream) {
|
||||
// get stream length and filters
|
||||
$slength = strlen($stream);
|
||||
if ($slength <= 0) {
|
||||
return array('', array());
|
||||
}
|
||||
$filters = array();
|
||||
foreach ($sdic as $k => $v) {
|
||||
if ($v[0] == '/') {
|
||||
if (($v[1] == 'Length') AND (isset($sdic[($k + 1)])) AND ($sdic[($k + 1)][0] == 'numeric')) {
|
||||
// get declared stream length
|
||||
$declength = intval($sdic[($k + 1)][1]);
|
||||
if ($declength < $slength) {
|
||||
$stream = substr($stream, 0, $declength);
|
||||
$slength = $declength;
|
||||
}
|
||||
} elseif (($v[1] == 'Filter') AND (isset($sdic[($k + 1)]))) {
|
||||
// resolve indirect object
|
||||
$objval = $this->getObjectVal($sdic[($k + 1)]);
|
||||
if ($objval[0] == '/') {
|
||||
// single filter
|
||||
$filters[] = $objval[1];
|
||||
} elseif ($objval[0] == '[') {
|
||||
// array of filters
|
||||
foreach ($objval[1] as $flt) {
|
||||
if ($flt[0] == '/') {
|
||||
$filters[] = $flt[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// decode the stream
|
||||
$remaining_filters = array();
|
||||
foreach ($filters as $filter) {
|
||||
if (in_array($filter, TCPDF_FILTERS::getAvailableFilters())) {
|
||||
try {
|
||||
$stream = TCPDF_FILTERS::decodeFilter($filter, $stream);
|
||||
} catch (Exception $e) {
|
||||
$emsg = $e->getMessage();
|
||||
if ((($emsg[0] == '~') AND !$this->cfg['ignore_missing_filter_decoders'])
|
||||
OR (($emsg[0] != '~') AND !$this->cfg['ignore_filter_decoding_errors'])) {
|
||||
$this->Error($e->getMessage());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// add missing filter to array
|
||||
$remaining_filters[] = $filter;
|
||||
}
|
||||
}
|
||||
return array($stream, $remaining_filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an exception or print an error message and die if the K_TCPDF_PARSER_THROW_EXCEPTION_ERROR constant is set to true.
|
||||
* @param $msg (string) The error message
|
||||
* @public
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
*/
|
||||
public function Error($msg) {
|
||||
if ($this->cfg['die_for_errors']) {
|
||||
die('<strong>TCPDF_PARSER ERROR: </strong>'.$msg);
|
||||
} else {
|
||||
throw new Exception('TCPDF_PARSER ERROR: '.$msg);
|
||||
}
|
||||
}
|
||||
|
||||
} // END OF TCPDF_PARSER CLASS
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
@@ -0,0 +1 @@
|
||||
deny from all
|
||||
@@ -0,0 +1,28 @@
|
||||
./tcpdf_addfont.php -b -t Type1 -f 4 -e symbol -i pdfasymbol.pfb
|
||||
./tcpdf_addfont.php -b -t Type1 -f 4 -i pdfazapfdingbats.pfb
|
||||
./tcpdf_addfont.php -b -t Type1 -f 32 -e cp1252 -i pdfatimes.pfb,pdfatimesb.pfb,pdfahelvetica.pfb,pdfahelveticab.pfb
|
||||
./tcpdf_addfont.php -b -t Type1 -f 33 -e cp1252 -i pdfacourier.pfb,pdfacourierb.pfb
|
||||
./tcpdf_addfont.php -b -t Type1 -f 96 -e cp1252 -i pdfahelveticabi.pfb,pdfahelveticai.pfb,pdfatimesi.pfb,pdfatimesbi.pfb
|
||||
./tcpdf_addfont.php -b -t Type1 -f 97 -e cp1252 -i pdfacourieri.pfb,pdfacourierbi.pfb
|
||||
|
||||
|
||||
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 32 -i DejaVuSans.ttf,DejaVuSans-Bold.ttf,DejaVuSansCondensed.ttf,DejaVuSansCondensed-Bold.ttf,DejaVuSans-ExtraLight.ttf,DejaVuSerif.ttf,DejaVuSerif-Bold.ttf,DejaVuSerifCondensed.ttf,DejaVuSerifCondensed-Bold.ttf
|
||||
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 33 -i DejaVuSansMono.ttf,DejaVuSansMono-Bold.ttf
|
||||
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 96 -i DejaVuSans-BoldOblique.ttf,DejaVuSansCondensed-BoldOblique.ttf,DejaVuSansCondensed-Oblique.ttf,DejaVuSerifCondensed-BoldItalic.ttf,DejaVuSerifCondensed-Italic.ttf,DejaVuSerif-Italic.ttf,DejaVuSerif-BoldItalic.ttf,DejaVuSans-Oblique.ttf
|
||||
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 97 -i DejaVuSansMono-BoldOblique.ttf,DejaVuSansMono-Oblique.ttf
|
||||
|
||||
|
||||
|
||||
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 32 -i FreeSans.ttf,FreeSansBold.ttf,FreeSerif.ttf,FreeSerifBold.ttf
|
||||
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 33 -i FreeMono.ttf,FreeMonoBold.ttf
|
||||
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 96 -i FreeSansBoldOblique.ttf,FreeSansOblique.ttf,FreeSerifBoldItalic.ttf,FreeSerifItalic.ttf
|
||||
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 97 -i FreeMonoBoldOblique.ttf,FreeMonoOblique.ttf
|
||||
|
||||
|
||||
./tcpdf_addfont.php -b -t TrueTypeUnicode -i aeAlArabiya.ttf,aeFurat.ttf
|
||||
|
||||
|
||||
./tcpdf_addfont.php -b -t CID0JP -f 32 -i cid0jp.ttf
|
||||
./tcpdf_addfont.php -b -t CID0KR -f 32 -i cid0kr.ttf
|
||||
./tcpdf_addfont.php -b -t CID0CS -f 32 -i cid0cs.ttf
|
||||
./tcpdf_addfont.php -b -t CID0CT -f 32 -i cid0ct.ttf
|
||||
@@ -0,0 +1,269 @@
|
||||
#!/usr/bin/php -q
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_addfont.php
|
||||
// Version : 1.0.002
|
||||
// Begin : 2013-05-13
|
||||
// Last Update : 2013-08-05
|
||||
// Authors : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// Remi Collet
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2013 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the License
|
||||
// along with TCPDF. If not, see
|
||||
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description : This is a command line script to generate TCPDF fonts.
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This is a command line script to generate TCPDF fonts.<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @version 1.0.000
|
||||
*/
|
||||
|
||||
if (php_sapi_name() != 'cli') {
|
||||
echo 'You need to run this command from console.';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$tcpdf_include_dirs = array(realpath(dirname(__FILE__).'/../tcpdf.php'), '/usr/share/php/tcpdf/tcpdf.php', '/usr/share/tcpdf/tcpdf.php', '/usr/share/php-tcpdf/tcpdf.php', '/var/www/tcpdf/tcpdf.php', '/var/www/html/tcpdf/tcpdf.php', '/usr/local/apache2/htdocs/tcpdf/tcpdf.php');
|
||||
foreach ($tcpdf_include_dirs as $tcpdf_include_path) {
|
||||
if (@file_exists($tcpdf_include_path)) {
|
||||
require_once($tcpdf_include_path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display help guide for this command.
|
||||
*/
|
||||
function showHelp() {
|
||||
$help = <<<EOD
|
||||
tcpdf_addfont - command line tool to convert fonts for the TCPDF library.
|
||||
|
||||
Usage: tcpdf_addfont.php [ options ] -i fontfile[,fontfile]...
|
||||
|
||||
Options:
|
||||
|
||||
-t
|
||||
--type Font type. Leave empty for autodetect mode.
|
||||
Valid values are:
|
||||
TrueTypeUnicode
|
||||
TrueType
|
||||
Type1
|
||||
CID0JP = CID-0 Japanese
|
||||
CID0KR = CID-0 Korean
|
||||
CID0CS = CID-0 Chinese Simplified
|
||||
CID0CT = CID-0 Chinese Traditional
|
||||
|
||||
-e
|
||||
--enc Name of the encoding table to use. Leave empty for
|
||||
default mode. Omit this parameter for TrueType Unicode
|
||||
and symbolic fonts like Symbol or ZapfDingBats.
|
||||
|
||||
-f
|
||||
--flags Unsigned 32-bit integer containing flags specifying
|
||||
various characteristics of the font (PDF32000:2008 -
|
||||
9.8.2 Font Descriptor Flags): +1 for fixed font; +4 for
|
||||
symbol or +32 for non-symbol; +64 for italic. Fixed and
|
||||
Italic mode are generally autodetected so you have to
|
||||
set it to 32 = non-symbolic font (default) or 4 =
|
||||
symbolic font.
|
||||
|
||||
-o
|
||||
--outpath Output path for generated font files (must be writeable
|
||||
by the web server). Leave empty for default font folder.
|
||||
|
||||
-p
|
||||
--platid Platform ID for CMAP table to extract (when building a
|
||||
Unicode font for Windows this value should be 3, for
|
||||
Macintosh should be 1).
|
||||
|
||||
-n
|
||||
--encid Encoding ID for CMAP table to extract (when building a
|
||||
Unicode font for Windows this value should be 1, for
|
||||
Macintosh should be 0). When Platform ID is 3, legal
|
||||
values for Encoding ID are: 0=Symbol, 1=Unicode,
|
||||
2=ShiftJIS, 3=PRC, 4=Big5, 5=Wansung, 6=Johab,
|
||||
7=Reserved, 8=Reserved, 9=Reserved, 10=UCS-4.
|
||||
|
||||
-b
|
||||
--addcbbox Includes the character bounding box information on the
|
||||
php font file.
|
||||
|
||||
-l
|
||||
--link Link to system font instead of copying the font data #
|
||||
(not transportable) - Note: do not work with Type1 fonts.
|
||||
|
||||
-i
|
||||
--fonts Comma-separated list of input font files.
|
||||
|
||||
-h
|
||||
--help Display this help and exit.
|
||||
EOD;
|
||||
echo $help."\n\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// remove the name of the executing script
|
||||
array_shift($argv);
|
||||
|
||||
// no options chosen
|
||||
if (!is_array($argv)) {
|
||||
showHelp();
|
||||
}
|
||||
|
||||
// initialize the array of options
|
||||
$options = array('type'=>'', 'enc'=>'', 'flags'=>32, 'outpath'=>K_PATH_FONTS, 'platid'=>3, 'encid'=>1, 'addcbbox'=>false, 'link'=>false);
|
||||
|
||||
// short input options
|
||||
$sopt = '';
|
||||
$sopt .= 't:';
|
||||
$sopt .= 'e:';
|
||||
$sopt .= 'f:';
|
||||
$sopt .= 'o:';
|
||||
$sopt .= 'p:';
|
||||
$sopt .= 'n:';
|
||||
$sopt .= 'b';
|
||||
$sopt .= 'l';
|
||||
$sopt .= 'i:';
|
||||
$sopt .= 'h';
|
||||
|
||||
// long input options
|
||||
$lopt = array();
|
||||
$lopt[] = 'type:';
|
||||
$lopt[] = 'enc:';
|
||||
$lopt[] = 'flags:';
|
||||
$lopt[] = 'outpath:';
|
||||
$lopt[] = 'platid:';
|
||||
$lopt[] = 'encid:';
|
||||
$lopt[] = 'addcbbox';
|
||||
$lopt[] = 'link';
|
||||
$lopt[] = 'fonts:';
|
||||
$lopt[] = 'help';
|
||||
|
||||
// parse input options
|
||||
$inopt = getopt($sopt, $lopt);
|
||||
|
||||
// import options (with some sanitization)
|
||||
foreach ($inopt as $opt => $val) {
|
||||
switch ($opt) {
|
||||
case 't':
|
||||
case 'type': {
|
||||
if (in_array($val, array('TrueTypeUnicode', 'TrueType', 'Type1', 'CID0JP', 'CID0KR', 'CID0CS', 'CID0CT'))) {
|
||||
$options['type'] = $val;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'e':
|
||||
case 'enc': {
|
||||
$options['enc'] = $val;
|
||||
break;
|
||||
}
|
||||
case 'f':
|
||||
case 'flags': {
|
||||
$options['flags'] = intval($val);
|
||||
break;
|
||||
}
|
||||
case 'o':
|
||||
case 'outpath': {
|
||||
$options['outpath'] = realpath($val);
|
||||
if (substr($options['outpath'], -1) != '/') {
|
||||
$options['outpath'] .= '/';
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'p':
|
||||
case 'platid': {
|
||||
$options['platid'] = min(max(1, intval($val)), 3);
|
||||
break;
|
||||
}
|
||||
case 'n':
|
||||
case 'encid': {
|
||||
$options['encid'] = min(max(0, intval($val)), 10);
|
||||
break;
|
||||
}
|
||||
case 'b':
|
||||
case 'addcbbox': {
|
||||
$options['addcbbox'] = true;
|
||||
break;
|
||||
}
|
||||
case 'l':
|
||||
case 'link': {
|
||||
$options['link'] = true;
|
||||
break;
|
||||
}
|
||||
case 'i':
|
||||
case 'fonts': {
|
||||
$options['fonts'] = explode(',', $val);
|
||||
break;
|
||||
}
|
||||
case 'h':
|
||||
case 'help':
|
||||
default: {
|
||||
showHelp();
|
||||
break;
|
||||
}
|
||||
} // end of switch
|
||||
} // end of while loop
|
||||
|
||||
if (empty($options['fonts'])) {
|
||||
echo "ERROR: missing input fonts (try --help for usage)\n\n";
|
||||
exit(2);
|
||||
}
|
||||
|
||||
// check the output path
|
||||
if (!is_dir($options['outpath']) OR !is_writable($options['outpath'])) {
|
||||
echo "ERROR: Can't write to ".$options['outpath']."\n\n";
|
||||
exit(3);
|
||||
}
|
||||
|
||||
echo "\n>>> Converting fonts for TCPDF:\n";
|
||||
|
||||
echo '*** Output dir set to '.$options['outpath']."\n";
|
||||
|
||||
// check if there are conversion errors
|
||||
$errors = false;
|
||||
|
||||
foreach ($options['fonts'] as $font) {
|
||||
$fontfile = realpath($font);
|
||||
$fontname = TCPDF_FONTS::addTTFfont($fontfile, $options['type'], $options['enc'], $options['flags'], $options['outpath'], $options['platid'], $options['encid'], $options['addcbbox'], $options['link']);
|
||||
if ($fontname === false) {
|
||||
$errors = true;
|
||||
echo "--- ERROR: can't add ".$font."\n";
|
||||
} else {
|
||||
echo "+++ OK : ".$fontfile.' added as '.$fontname."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($errors) {
|
||||
echo "--- Process completed with ERRORS!\n\n";
|
||||
exit(4);
|
||||
}
|
||||
|
||||
echo ">>> Process successfully completed!\n\n";
|
||||
exit(0);
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
11
backend/wordpress/wp-content/plugins/woocommerce-jetpack/includes/lib/timepicker/jquery.timepicker.min.css
vendored
Executable file
11
backend/wordpress/wp-content/plugins/woocommerce-jetpack/includes/lib/timepicker/jquery.timepicker.min.css
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* jQuery Timepicker - v1.3.2 - 2014-09-13
|
||||
* http://timepicker.co
|
||||
*
|
||||
* Enhances standard form input fields helping users to select (or type) times.
|
||||
*
|
||||
* Copyright (c) 2014 Willington Vega; Licensed MIT, GPL
|
||||
*/
|
||||
|
||||
|
||||
.ui-timepicker-container{position:absolute;overflow:hidden;box-sizing:border-box}.ui-timepicker{box-sizing:content-box;display:block;height:205px;list-style:none outside none;margin:0;padding:0 1px;text-align:center}.ui-timepicker-viewport{box-sizing:content-box;display:block;height:205px;margin:0;padding:0;overflow:auto;overflow-x:hidden}.ui-timepicker-standard{font-family:Verdana,Arial,sans-serif;font-size:1.1em;background-color:#FFF;border:1px solid #AAA;color:#222;margin:0;padding:2px}.ui-timepicker-standard a{border:1px solid transparent;color:#222;display:block;padding:.2em .4em;text-decoration:none}.ui-timepicker-standard .ui-state-hover{background-color:#DADADA;border:1px solid #999;font-weight:400;color:#212121}.ui-timepicker-standard .ui-menu-item{margin:0;padding:0}.ui-timepicker-corners,.ui-timepicker-corners .ui-corner-all{-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}.ui-timepicker-hidden{display:none}.ui-timepicker-no-scrollbar .ui-timepicker{border:0}
|
||||
10
backend/wordpress/wp-content/plugins/woocommerce-jetpack/includes/lib/timepicker/jquery.timepicker.min.js
vendored
Executable file
10
backend/wordpress/wp-content/plugins/woocommerce-jetpack/includes/lib/timepicker/jquery.timepicker.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 430 B |
@@ -0,0 +1,179 @@
|
||||
/***********************************
|
||||
* Layout
|
||||
***********************************/
|
||||
.wSelect-el {
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
border: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
.wSelect {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
*display: inline;
|
||||
zoom: 1;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.wSelect-arrow {
|
||||
position: absolute;
|
||||
width: 30px;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
height: 100%;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0px center;
|
||||
}
|
||||
.wSelect-hover .wSelect-arrow,
|
||||
.wSelect-active .wSelect-arrow {
|
||||
background-position: -30px center;
|
||||
}
|
||||
.wSelect.wSelect-multiple {
|
||||
overflow: hidden;
|
||||
}
|
||||
.wSelect-selected {
|
||||
margin: 0px 35px 0px 5px;
|
||||
padding: 5px 0;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 center;
|
||||
}
|
||||
.wSelect-options-holder {
|
||||
position: absolute;
|
||||
display: none;
|
||||
left: 0px;
|
||||
z-index: 200;
|
||||
overflow: hidden;
|
||||
}
|
||||
.wSelect-multiple .wSelect-options-holder {
|
||||
position: relative !important;
|
||||
display: block !important;
|
||||
top: auto !important;
|
||||
z-index: auto !important;
|
||||
border: none !important;
|
||||
}
|
||||
.wSelect-options {
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.wSelect-option {
|
||||
background-repeat: no-repeat;
|
||||
background-position: 5px center;
|
||||
margin-bottom: 1px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.wSelect-option-last {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.wSelect-option-value {
|
||||
margin: 0 5px;
|
||||
padding: 5px 0;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 center;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
.wSelect-option-disabled .wSelect-option-value {
|
||||
filter: alpha(opacity=20);
|
||||
opacity: 0.2;
|
||||
}
|
||||
.wSelect-option-icon {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* Theme - classic
|
||||
***********************************/
|
||||
.wSelect-theme-classic.wSelect {
|
||||
border: solid #CCC 1px;
|
||||
color: #555;
|
||||
background-color: #FAFAFA;
|
||||
font-size: 12px;
|
||||
font-family: verdana;
|
||||
line-height: 20px;
|
||||
min-width: 100px;
|
||||
max-width: 300px;
|
||||
margin-bottom: 7px;
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
}
|
||||
.wSelect-arrow {
|
||||
background-image: url('./img/arrow-down.png');
|
||||
}
|
||||
.wSelect-theme-classic.wSelect-hover,
|
||||
.wSelect-theme-classic.wSelect-active {
|
||||
border-color: rgb(82, 168, 236);
|
||||
border-color: rgba(82, 168, 236, 0.8);
|
||||
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
||||
}
|
||||
.wSelect-theme-classic .wSelect-options-holder {
|
||||
background-color: #FAFAFA;
|
||||
border: solid #CACACA 1px;
|
||||
border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
min-width: 100px;
|
||||
max-width: 300px;
|
||||
}
|
||||
.wSelect-theme-classic .wSelect-options {
|
||||
border: solid #FAFAFA 1px;
|
||||
border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
}
|
||||
.wSelect-theme-classic .wSelect-option {
|
||||
background-color: #FFF;
|
||||
color: #333;
|
||||
}
|
||||
.wSelect-theme-classic .wSelect-option-disabled {
|
||||
background-color: #FFF !important;
|
||||
color: #333 !important;
|
||||
}
|
||||
.wSelect-theme-classic .wSelect-option-selected,
|
||||
.wSelect-theme-classic .wSelect-option:hover {
|
||||
background-color: #99AAFF;
|
||||
color: #FAFAFA;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* Labels
|
||||
***********************************/
|
||||
.wLabel-top,
|
||||
.wLabel-left,
|
||||
.wLabel-left-top {
|
||||
vertical-align: middle;
|
||||
font-size: 10px;
|
||||
line-height: 16px;
|
||||
color: #999;
|
||||
display: block;
|
||||
margin: 5px 0 3px 3px;
|
||||
}
|
||||
.wLabel-left-top {
|
||||
vertical-align: top;
|
||||
}
|
||||
@media screen and (min-width: 600px) {
|
||||
.wLabel-left,
|
||||
.wLabel-left-top {
|
||||
display: inline-block;
|
||||
*display: inline;
|
||||
zoom: 1;
|
||||
width: 70px;
|
||||
text-align: right;
|
||||
margin: 0 0 7px 0;
|
||||
}
|
||||
}
|
||||
1
backend/wordpress/wp-content/plugins/woocommerce-jetpack/includes/lib/wSelect/wSelect.min.js
vendored
Executable file
1
backend/wordpress/wp-content/plugins/woocommerce-jetpack/includes/lib/wSelect/wSelect.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user