This commit is contained in:
wangjinlei
2024-07-17 09:23:45 +08:00
parent edf9deeb1a
commit 881ac3e056
1001 changed files with 41032 additions and 5452 deletions

View File

@@ -0,0 +1,35 @@
name: Bug report 🐛
description: The library does not work as expected
body:
- type: checkboxes
attributes:
label: Guidelines
description: Please confirm this is a bug report and not general troubleshooting.
options:
- label: I understand that [if I fail to adhere to contribution guidelines and/or fail to provide all required details, this issue may be closed without review](https://github.com/mpdf/mpdf/blob/development/.github/CONTRIBUTING.md).
required: true
- type: textarea
attributes:
label: Description of the bug
validations:
required: true
- type: input
attributes:
label: mPDF version
validations:
required: true
- type: input
attributes:
label: PHP Version and environment (server type, cli provider etc., enclosing libraries and their respective versions)
validations:
required: true
- type: textarea
attributes:
label: Reproducible PHP+CSS+HTML snippet suffering by the error
validations:
required: true

View File

@@ -0,0 +1,8 @@
name: Feature request 🚀
description: I would like to have a new functionality added
body:
- type: textarea
attributes:
label: Please describe the new functionality as best as you can.
validations:
required: true

View File

@@ -1,29 +0,0 @@
---
name: Bug report 🐛
about: The library does not work as expected (please use not for troubleshooting)
---
<!--
Fill in provided template with information about the bug
Provide a short and reproducible code example
⚠ Failing to provide necessary information will cause the issue to be closed until appropriately updated.
See Contributing guidelines for further information
-->
### I found this bug
### This is mPDF and PHP version and environment (server/fpm/cli etc) I am using
### This is the PHP code snippet I use
```
<?php
```
### This is the HTML/CSS code snippet I use
```
```

View File

@@ -1,8 +0,0 @@
---
name: Feature request 🚀
about: I would like to have a new functionality added
---
# Feature request
<!-- Please describe the new functionality as best as you can. -->

View File

@@ -1,3 +1,4 @@
blank_issues_enabled: false
contact_links:
- name: General questions and troubleshooting ❓
url: https://github.com/mpdf/mpdf/discussions

View File

@@ -2,5 +2,4 @@ How to disclose potential security issues
============
As mPDF does not have a domain or a dedicated contact apart from its Github repository, to prevent
disclosing maintainers' contacts publicly, please create an Issue about the security issue with means to contact you.
We will reach out to you as soon as possible.
disclosing maintainers' contacts publicly, please use [GitHub's Security Advisories system](https://github.com/mpdf/mpdf/security/advisories).

View File

@@ -25,7 +25,7 @@ jobs:
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"

View File

@@ -26,7 +26,7 @@ jobs:
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"

View File

@@ -30,11 +30,13 @@ jobs:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
operating-system: [ubuntu-latest, windows-latest]
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"

View File

@@ -1,3 +1,18 @@
mPDF 8.2.x
===========================
New features
------------
* Watermark text can now be colored using \Mpdf\Watermark DTO. \Mpdf\WatermarkImage DTO for images. (#1876)
* Added support for `psr/http-message` v2 without dropping v1. (@markdorison, @apotek, @greg-1-anderson, @NigelCunningham #1907)
* PHP 8.3 support in mPDF 8.2.1
* Add support for `page-break-before: avoid;` and `page-break-after: avoid;` for tr elements inside tables
Bugfixes
--------
* Replace character entities with characters when processing the `code` attribute in the `<barcode />` tag
mPDF 8.1.x
===========================
@@ -6,7 +21,10 @@ New features
* Service container for internal services
* Set /Lang entry for better accessibility when document language is available (@cuongmits, #1418)
* More verbose helper methods for `Output`: `OutputBinaryData`, `OutputHttpInline`, `OutputHttpDownload`, `OutputFile`
* More verbose helper methods for `Output`: `OutputBinaryData`, `OutputHttpInline`, `OutputHttpDownload`, `OutputFile` (since v8.1.2)
* Set font-size to `auto` in textarea and input in active forms to resize the font-size (@ChrisB9, #1721)
* PHP 8.2 support in mPDF 8.1.3
* Added support for `psr/log` v3 without dropping v2. (@markdorison, @apotek, @greg-1-anderson, #1857)
Bugfixes
--------
@@ -16,7 +34,8 @@ Bugfixes
* Testing and suppressing PNG file conversion errors
* Prevent hyphenation of urls starting with https and e-mail addresses (@HKandulla, #1634)
* Colorspace restrictor reads mode from Mpdf and works again (Fix for #1094)
* Prevent exception when multiple columns wrap to next page
* Update default `curlUserAgent` configuration variable from Firefox 13 to 108
mPDF 8.0.x
===========================

View File

@@ -18,11 +18,13 @@ Requirements
PHP versions and extensions
---------------------------
- `mPDF >=7.0` is supported on `PHP ^5.6 || ~7.0.0 || ~7.1.0 || ~7.2.0`
- `PHP >=5.6 <7.3.0` is supported for `mPDF >= 7.0`
- `PHP 7.3` is supported since `mPDF v7.1.7`
- `PHP 7.4` is supported since `mPDF v8.0.4`
- `PHP 8.0` is supported since `mPDF v8.0.10`
- `PHP 8.1` is supported as of `mPDF v8.0.13`
- `PHP 8.2` is supported as of `mPDF v8.1.3`
- `PHP 8.3` is supported as of `mPDF v8.2.1`
PHP `mbstring` and `gd` extensions have to be loaded.

View File

@@ -21,21 +21,22 @@
"docs": "http://mpdf.github.io"
},
"require": {
"php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0",
"php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
"ext-gd": "*",
"ext-mbstring": "*",
"mpdf/psr-http-message-shim": "^1.0 || ^2.0",
"mpdf/psr-log-aware-trait": "^2.0 || ^3.0",
"myclabs/deep-copy": "^1.7",
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
"php-http/message-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0 || ^2.0",
"psr/http-message": "^1.0 || ^2.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"setasign/fpdi": "^2.1"
},
"require-dev": {
"mockery/mockery": "^1.3.0",
"mpdf/qrcode": "^1.1.0",
"squizlabs/php_codesniffer": "^3.5.0",
"tracy/tracy": "^2.4",
"tracy/tracy": "~2.5",
"yoast/phpunit-polyfills": "^1.0"
},
"suggest": {
@@ -46,7 +47,10 @@
"autoload": {
"psr-4": {
"Mpdf\\": "src/"
}
},
"files": [
"src/functions.php"
]
},
"autoload-dev": {
"psr-4": {

View File

@@ -6,7 +6,7 @@
<testsuites>
<testsuite name="Tests">
<directory suffix=".php">./tests</directory>
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>

View File

@@ -5,21 +5,22 @@ namespace Mpdf;
use Mpdf\File\LocalContentLoaderInterface;
use Mpdf\File\StreamWrapperChecker;
use Mpdf\Http\ClientInterface;
use Mpdf\Http\Request;
use Mpdf\Log\Context as LogContext;
use Mpdf\PsrHttpMessageShim\Request;
use Mpdf\PsrLogAwareTrait\PsrLogAwareTrait;
use Psr\Log\LoggerInterface;
class AssetFetcher implements \Psr\Log\LoggerAwareInterface
{
use PsrLogAwareTrait;
private $mpdf;
private $contentLoader;
private $http;
private $logger;
public function __construct(Mpdf $mpdf, LocalContentLoaderInterface $contentLoader, ClientInterface $http, LoggerInterface $logger)
{
$this->mpdf = $mpdf;
@@ -82,10 +83,10 @@ class AssetFetcher implements \Psr\Log\LoggerAwareInterface
$this->logger->debug(sprintf('Fetching remote content of file "%s"', $path), ['context' => LogContext::REMOTE_CONTENT]);
/** @var \Mpdf\Http\Response $response */
/** @var \Mpdf\PsrHttpMessageShim\Response $response */
$response = $this->http->sendRequest(new Request('GET', $path));
if ($response->getStatusCode() !== 200) {
if (!str_starts_with((string) $response->getStatusCode(), '2')) {
$message = sprintf('Non-OK HTTP response "%s" on fetching remote content "%s" because of an error', $response->getStatusCode(), $path);
if ($this->mpdf->debug) {
@@ -102,7 +103,7 @@ class AssetFetcher implements \Psr\Log\LoggerAwareInterface
} catch (\InvalidArgumentException $e) {
$message = sprintf('Unable to fetch remote content "%s" because of an error "%s"', $path, $e->getMessage());
if ($this->mpdf->debug) {
throw new \Mpdf\MpdfException($message, 0, $e);
throw new \Mpdf\MpdfException($message, 0, E_ERROR, null, null, $e);
}
$this->logger->warning($message);
@@ -113,12 +114,7 @@ class AssetFetcher implements \Psr\Log\LoggerAwareInterface
public function isPathLocal($path)
{
return strpos($path, '://') === false; // @todo More robust implementation
}
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
return str_starts_with($path, 'file://') || strpos($path, '://') === false; // @todo More robust implementation
}
}

View File

@@ -193,6 +193,10 @@ class ColorConverter
} elseif (strpos($color, '#') === 0) { // case of #nnnnnn or #nnn
$c = $this->processHashColor($color);
} elseif (preg_match('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl|spot)\((.*?)\)/', $color, $m)) {
// ignore colors containing CSS variables
if (str_starts_with(mb_strtolower($m[2]), 'var(--')) {
$m[2] = '0, 0, 0, 100';
}
$c = $this->processModeColor($m[1], explode(',', $m[2]));
}

View File

@@ -515,7 +515,7 @@ class ConfigVariables
'curlExecutionTimeout' => null,
'curlProxy' => null,
'curlProxyAuth' => null,
'curlUserAgent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0.1',
'curlUserAgent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0',
'exposeVersion' => true,
];

View File

@@ -6,7 +6,7 @@ use Mpdf\Color\ColorConverter;
use Mpdf\Css\TextVars;
use Mpdf\File\StreamWrapperChecker;
use Mpdf\Http\ClientInterface;
use Mpdf\Http\Request;
use Mpdf\PsrHttpMessageShim\Request;
use Mpdf\Utils\Arrays;
use Mpdf\Utils\UtfString;

View File

@@ -214,6 +214,10 @@ class Form
$js[] = ['K', $objattr['onKeystroke']];
}
if (!empty($objattr['use_auto_fontsize']) && $objattr['use_auto_fontsize'] === true) {
$this->mpdf->FontSizePt = 0.0;
}
$this->SetFormText($w, $h, $objattr['fieldname'], $val, $val, $objattr['title'], $flags, $fieldalign, false, (isset($objattr['maxlength']) ? $objattr['maxlength'] : false), $js, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false));
} else {
@@ -319,6 +323,11 @@ class Form
if (!empty($objattr['onKeystroke'])) {
$js[] = ['K', $objattr['onKeystroke']];
}
if (!empty($objattr['use_auto_fontsize']) && $objattr['use_auto_fontsize'] === true) {
$this->mpdf->FontSizePt = 0.0;
}
$this->SetFormText($w, $h, $objattr['fieldname'], $texto, $texto, (isset($objattr['title']) ? $objattr['title'] : ''), $flags, $fieldalign, false, -1, $js, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false));
$this->mpdf->SetTColor($this->colorConverter->convert(0, $this->mpdf->PDFAXwarnings));

View File

@@ -53,7 +53,7 @@ class Gradient
$this->mpdf->gradients[$n]['stream'] = '';
for ($i = 0; $i < count($patch_array); $i++) {
$this->mpdf->gradients[$n]['stream'].=chr($patch_array[$i]['f']); //start with the edge flag as 8 bit
$this->mpdf->gradients[$n]['stream'] .= chr($patch_array[$i]['f']); //start with the edge flag as 8 bit
for ($j = 0; $j < count($patch_array[$i]['points']); $j++) {
@@ -93,7 +93,7 @@ class Gradient
$trans = true;
}
} elseif ($colspace === 'Gray') {
$this->mpdf->gradients[$n]['stream'].= $patch_array[$i]['colors'][$j][1];
$this->mpdf->gradients[$n]['stream'] .= $patch_array[$i]['colors'][$j][1];
if ($patch_array[$i]['colors'][$j][2] == 1) {
$trans = true;
} // transparency converted from rgba or cmyka()
@@ -620,15 +620,19 @@ class Gradient
$g['colorspace'] = 'RGB';
$g['extend'] = ['true', 'true'];
$v = trim($m[1]);
// Change commas inside e.g. rgb(x,x,x)
while (preg_match('/(\([^\)]*?),/', $v)) {
$v = preg_replace('/(\([^\)]*?),/', '\\1@', $v);
}
// Remove spaces inside e.g. rgb(x, x, x)
while (preg_match('/(\([^\)]*?)[ ]/', $v)) {
$v = preg_replace('/(\([^\)]*?)[ ]/', '\\1', $v);
}
$bgr = preg_split('/\s*,\s*/', $v);
for ($i = 0; $i < count($bgr); $i++) {
$bgr[$i] = preg_replace('/@/', ',', $bgr[$i]);
}
@@ -645,8 +649,10 @@ class Gradient
$startStops = 0;
}
}
// first part a valid point/angle?
if ($startStops === 1) { // default values
// [<point> || <angle>,] = [<% em px left center right bottom top> || <deg grad rad 0>,]
if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i', $bgr[0], $m)) {
$angle = $m[1] + 0;
@@ -662,16 +668,19 @@ class Gradient
} elseif (trim($first[count($first) - 1]) === '0') {
$angle = 0;
}
if (stripos($bgr[0], 'left') !== false) {
$startx = 0;
} elseif (stripos($bgr[0], 'right') !== false) {
$startx = 1;
} elseif (stripos($bgr[0], 'right') !== false) {
$startx = 0;
}
if (stripos($bgr[0], 'top') !== false) {
$starty = 1;
} elseif (stripos($bgr[0], 'bottom') !== false) {
$starty = 0;
}
// Check for %? ?% or %%
if (preg_match('/(\d+)[%]/i', $first[0], $m)) {
$startx = $m[1] / 100;
@@ -681,6 +690,7 @@ class Gradient
$startx = $m[1];
}
}
if (isset($first[1]) && preg_match('/(\d+)[%]/i', $first[1], $m)) {
$starty = 1 - ($m[1] / 100);
} elseif (!isset($starty) && isset($first[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $first[1], $m)) {
@@ -689,12 +699,15 @@ class Gradient
$starty = $m[1];
}
}
if (isset($startx) && !isset($starty)) {
$starty = 0.5;
}
if (!isset($startx) && isset($starty)) {
$startx = 0.5;
}
} else {
// If neither a <point> or <angle> is specified, i.e. the entire function consists of only <stop> values,
// the gradient axis starts from the top of the box and runs vertically downwards, ending at the bottom of
@@ -704,31 +717,41 @@ class Gradient
$endy = 0;
$endx = 0.5;
}
if (!isset($startx)) {
$startx = false;
}
if (!isset($starty)) {
$starty = false;
}
if (!isset($endx)) {
$endx = false;
}
if (!isset($endy)) {
$endy = false;
}
if (!isset($angle)) {
$angle = false;
}
$g['coords'] = [$startx, $starty, $endx, $endy, $angle, $repeat];
$g['stops'] = [];
for ($i = $startStops; $i < count($bgr); $i++) {
// parse stops
$el = preg_split('/\s+/', trim($bgr[$i]));
// mPDF 5.3.74
$col = $this->colorConverter->convert($el[0], $this->mpdf->PDFAXwarnings);
if (!$col) {
$col = $this->colorConverter->convert(255, $this->mpdf->PDFAXwarnings);
}
if ($col[0] == 1) {
$g['colorspace'] = 'Gray';
} elseif ($col[0] == 4 || $col[0] == 6) {
@@ -737,6 +760,7 @@ class Gradient
$g['stops'][] = $this->getStop($col, $el, true);
}
return $g;
}

View File

@@ -4,16 +4,18 @@ namespace Mpdf\Http;
use Mpdf\Log\Context as LogContext;
use Mpdf\Mpdf;
use Mpdf\PsrHttpMessageShim\Response;
use Mpdf\PsrHttpMessageShim\Stream;
use Mpdf\PsrLogAwareTrait\PsrLogAwareTrait;
use Psr\Http\Message\RequestInterface;
use Psr\Log\LoggerInterface;
class CurlHttpClient implements \Mpdf\Http\ClientInterface, \Psr\Log\LoggerAwareInterface
{
use PsrLogAwareTrait;
private $mpdf;
private $logger;
public function __construct(Mpdf $mpdf, LoggerInterface $logger)
{
$this->mpdf = $mpdf;
@@ -96,7 +98,7 @@ class CurlHttpClient implements \Mpdf\Http\ClientInterface, \Psr\Log\LoggerAware
}
$info = curl_getinfo($ch);
if (isset($info['http_code']) && $info['http_code'] !== 200) {
if (isset($info['http_code']) && !str_starts_with((string) $info['http_code'], '2')) {
$message = sprintf('HTTP error: %d', $info['http_code']);
$this->logger->error($message, ['context' => LogContext::REMOTE_CONTENT]);
@@ -116,9 +118,4 @@ class CurlHttpClient implements \Mpdf\Http\ClientInterface, \Psr\Log\LoggerAware
->withBody(Stream::create($data));
}
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
}

View File

@@ -3,13 +3,16 @@
namespace Mpdf\Http;
use Mpdf\Log\Context as LogContext;
use Mpdf\PsrHttpMessageShim\Response;
use Mpdf\PsrHttpMessageShim\Stream;
use Mpdf\PsrLogAwareTrait\PsrLogAwareTrait;
use Psr\Http\Message\RequestInterface;
use Psr\Log\LoggerInterface;
class SocketHttpClient implements \Mpdf\Http\ClientInterface, \Psr\Log\LoggerAwareInterface
{
private $logger;
use PsrLogAwareTrait;
public function __construct(LoggerInterface $logger)
{
@@ -104,9 +107,4 @@ class SocketHttpClient implements \Mpdf\Http\ClientInterface, \Psr\Log\LoggerAwa
->withBody($stream);
}
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
}

View File

@@ -13,12 +13,15 @@ use Mpdf\Language\ScriptToLanguageInterface;
use Mpdf\Log\Context as LogContext;
use Mpdf\Mpdf;
use Mpdf\Otl;
use Mpdf\PsrLogAwareTrait\PsrLogAwareTrait;
use Mpdf\SizeConverter;
use Psr\Log\LoggerInterface;
class ImageProcessor implements \Psr\Log\LoggerAwareInterface
{
use PsrLogAwareTrait;
/**
* @var \Mpdf\Mpdf
*/
@@ -89,11 +92,6 @@ class ImageProcessor implements \Psr\Log\LoggerAwareInterface
*/
private $assetFetcher;
/**
* @var \Psr\Log\LoggerInterface
*/
public $logger;
public function __construct(
Mpdf $mpdf,
Otl $otl,
@@ -126,18 +124,6 @@ class ImageProcessor implements \Psr\Log\LoggerAwareInterface
$this->failedImages = [];
}
/**
* @param \Psr\Log\LoggerInterface
*
* @return self
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
return $this;
}
public function getImage(&$file, $firstTime = true, $allowvector = true, $orig_srcpath = false, $interpolation = false)
{
// mPDF 6

View File

@@ -10,11 +10,11 @@ use Mpdf\Css\TextVars;
use Mpdf\Log\Context as LogContext;
use Mpdf\Fonts\MetricsGenerator;
use Mpdf\Output\Destination;
use Mpdf\PsrLogAwareTrait\MpdfPsrLogAwareTrait;
use Mpdf\QrCode;
use Mpdf\Utils\Arrays;
use Mpdf\Utils\NumericString;
use Mpdf\Utils\UtfString;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
/**
@@ -30,11 +30,14 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
use Strict;
use FpdiTrait;
use MpdfPsrLogAwareTrait;
const VERSION = '8.1.2';
const VERSION = '8.2.4';
const SCALE = 72 / 25.4;
const OBJECT_IDENTIFIER = "\xbb\xa4\xac";
var $useFixedNormalLineHeight; // mPDF 6
var $useFixedTextBaseline; // mPDF 6
var $adjustFontDescLineheight; // mPDF 6
@@ -830,6 +833,9 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
private $preambleWritten = false;
private $watermarkTextObject;
private $watermarkImageObject;
/**
* @var string
*/
@@ -966,11 +972,6 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
*/
private $scriptToLanguage;
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
/**
* @var \Mpdf\Writer\BaseWriter
*/
@@ -1224,7 +1225,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->breakpoints = []; // used in columnbuffer
$this->tableLevel = 0;
$this->tbctr = []; // counter for nested tables at each level
$this->page_box = [];
$this->page_box = new PageBox();
$this->show_marks = ''; // crop or cross marks
$this->kwt = false;
$this->kwt_height = 0;
@@ -1579,24 +1580,6 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->createdReaders = [];
}
/**
* @param \Psr\Log\LoggerInterface
*
* @return \Mpdf\Mpdf
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
foreach ($this->services as $name) {
if ($this->$name && $this->$name instanceof \Psr\Log\LoggerAwareInterface) {
$this->$name->setLogger($logger);
}
}
return $this;
}
private function initConfig(array $config)
{
$configObject = new ConfigVariables();
@@ -1656,11 +1639,9 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
}
// e.g. A4-L = A4 landscape, A4-P = A4 portrait
$orientation = $orientation ?: 'P';
if (preg_match('/([0-9a-zA-Z]*)-([P,L])/i', $format, $m)) {
$format = $m[1];
$orientation = $m[2];
} elseif (empty($orientation)) {
$orientation = 'P';
list(, $format, $orientation) = $m;
}
$format = PageFormat::getSizeFromName($format);
@@ -1683,11 +1664,11 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
// Page orientation
$orientation = strtolower($orientation);
if ($orientation === 'p' || $orientation == 'portrait') {
if ($orientation === 'p' || $orientation === 'portrait') {
$orientation = 'P';
$this->wPt = $this->fwPt;
$this->hPt = $this->fhPt;
} elseif ($orientation === 'l' || $orientation == 'landscape') {
} elseif ($orientation === 'l' || $orientation === 'landscape') {
$orientation = 'L';
$this->wPt = $this->fhPt;
$this->hPt = $this->fwPt;
@@ -5435,26 +5416,15 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
function applyGPOSpdf($txt, $aix, $x, $y, $OTLdata, $textvar = 0)
{
// Generate PDF string
// ==============================
if ((isset($this->CurrentFont['sip']) && $this->CurrentFont['sip']) || (isset($this->CurrentFont['smp']) && $this->CurrentFont['smp'])) {
$sipset = true;
} else {
$sipset = false;
}
$sipset = (isset($this->CurrentFont['sip']) && $this->CurrentFont['sip'])
|| (isset($this->CurrentFont['smp']) && $this->CurrentFont['smp']);
if ($textvar & TextVars::FC_SMALLCAPS) {
$smcaps = true;
} // IF SmallCaps using transformation, NOT OTL
else {
$smcaps = false;
}
$smcaps = ($textvar & TextVars::FC_SMALLCAPS);
$fontid = $sipset
? $last_fontid = $original_fontid = $this->CurrentFont['subsetfontids'][0]
: $last_fontid = $original_fontid = $this->CurrentFont['i'];
if ($sipset) {
$fontid = $last_fontid = $original_fontid = $this->CurrentFont['subsetfontids'][0];
} else {
$fontid = $last_fontid = $original_fontid = $this->CurrentFont['i'];
}
$SmallCapsON = false; // state: uppercase/not
$lastSmallCapsON = false; // state: uppercase/not
$last_fontsize = $fontsize = $this->FontSizePt;
@@ -5471,14 +5441,9 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$XshiftAfter = 0;
$lastYPlacement = 0;
if ($sipset) {
// mPDF 6 DELETED ********
// $txt= preg_replace('/'.preg_quote($this->aliasNbPg,'/').'/', chr(7), $txt); // ? Need to adjust OTL info
// $txt= preg_replace('/'.preg_quote($this->aliasNbPgGp,'/').'/', chr(8), $txt); // ? Need to adjust OTL info
$tj = '<';
} else {
$tj = '(';
}
$tj = $sipset
? '<'
: '(';
for ($i = 0; $i < count($unicode); $i++) {
$c = $unicode[$i];
@@ -5496,7 +5461,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
}
// XPlacement from GPOS
if (isset($GPOSinfo[$i]['XPlacement']) && $GPOSinfo[$i]['XPlacement']) {
if (!isset($GPOSinfo[$i]['wDir']) || $GPOSinfo[$i]['wDir'] != 'RTL') {
if (!isset($GPOSinfo[$i]['wDir']) || $GPOSinfo[$i]['wDir'] !== 'RTL') {
if (isset($GPOSinfo[$i]['BaseWidth'])) {
$GPOSinfo[$i]['XPlacement'] -= $GPOSinfo[$i]['BaseWidth'];
}
@@ -5518,19 +5483,19 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$XshiftAfter += $wordspacing;
}
if (substr($OTLdata['group'], ($i + 1), 1) != 'M') { // Don't add inter-character spacing before Marks
if (substr($OTLdata['group'], ($i + 1), 1) !== 'M') { // Don't add inter-character spacing before Marks
$XshiftAfter += $charspacing;
}
// ...applyGPOSpdf...
// XAdvance from GPOS - Convert to PDF Text space (thousandths of a unit );
if (((isset($GPOSinfo[$i]['wDir']) && $GPOSinfo[$i]['wDir'] != 'RTL') || !isset($GPOSinfo[$i]['wDir'])) && isset($GPOSinfo[$i]['XAdvanceL']) && $GPOSinfo[$i]['XAdvanceL']) {
if (((isset($GPOSinfo[$i]['wDir']) && $GPOSinfo[$i]['wDir'] !== 'RTL') || !isset($GPOSinfo[$i]['wDir'])) && isset($GPOSinfo[$i]['XAdvanceL']) && $GPOSinfo[$i]['XAdvanceL']) {
$XshiftAfter += $GPOSinfo[$i]['XAdvanceL'] * 1000 / $this->CurrentFont['unitsPerEm'];
} elseif (isset($GPOSinfo[$i]['wDir']) && $GPOSinfo[$i]['wDir'] == 'RTL' && isset($GPOSinfo[$i]['XAdvanceR']) && $GPOSinfo[$i]['XAdvanceR']) {
} elseif (isset($GPOSinfo[$i]['wDir']) && $GPOSinfo[$i]['wDir'] === 'RTL' && isset($GPOSinfo[$i]['XAdvanceR']) && $GPOSinfo[$i]['XAdvanceR']) {
$XshiftAfter += $GPOSinfo[$i]['XAdvanceR'] * 1000 / $this->CurrentFont['unitsPerEm'];
}
} // Character & Word spacing - if NOT OTL
else {
} else { // Character & Word spacing - if NOT OTL
$XshiftAfter += $charspacing;
if ($c == 32) {
$XshiftAfter += $wordspacing;
@@ -5544,7 +5509,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
}
}
if ($YPlacement != $lastYPlacement) {
if ($YPlacement !== $lastYPlacement) {
$groupBreak = true;
}
@@ -5565,7 +5530,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
// $this->CurrentFont['subset'][$this->upperCase[$c]] = $this->upperCase[$c]; // add the CAP to subset
$SmallCapsON = true;
// For $sipset
if (!$lastSmallCapsON) { // Turn ON SmallCaps
if (!$lastSmallCapsON) { // Turn ON SmallCaps
$groupBreak = true;
$fontstretch = $this->smCapsStretch;
$fontsize = $this->FontSizePt * $this->smCapsScale;
@@ -5582,16 +5547,6 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
// Prepare Text and Select Font ID
if ($sipset) {
// mPDF 6 DELETED ********
// if ($c == 7 || $c == 8) {
// if ($original_fontid != $last_fontid) {
// $groupBreak = true;
// $fontid = $original_fontid;
// }
// if ($c == 7) { $tj .= $this->aliasNbPgHex; }
// else { $tj .= $this->aliasNbPgGpHex; }
// continue;
// }
for ($j = 0; $j < 99; $j++) {
$init = array_search($c, $this->CurrentFont['subsets'][$j]);
if ($init !== false) {
@@ -5600,8 +5555,11 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$fontid = $this->CurrentFont['subsetfontids'][$j];
}
$tx = sprintf("%02s", strtoupper(dechex($init)));
break;
} elseif (count($this->CurrentFont['subsets'][$j]) < 255) {
}
if (count($this->CurrentFont['subsets'][$j]) < 255) {
$n = count($this->CurrentFont['subsets'][$j]);
$this->CurrentFont['subsets'][$j][$n] = $c;
if ($this->CurrentFont['subsetfontids'][$j] != $last_fontid) {
@@ -5609,44 +5567,53 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$fontid = $this->CurrentFont['subsetfontids'][$j];
}
$tx = sprintf("%02s", strtoupper(dechex($n)));
break;
} elseif (!isset($this->CurrentFont['subsets'][($j + 1)])) {
}
if (!isset($this->CurrentFont['subsets'][($j + 1)])) {
$this->CurrentFont['subsets'][($j + 1)] = [0 => 0];
$this->CurrentFont['subsetfontids'][($j + 1)] = count($this->fonts) + $this->extraFontSubsets + 1;
$this->extraFontSubsets++;
}
}
} else {
$tx = UtfString::code2utf($c);
if ($this->usingCoreFont) {
$tx = utf8_decode($tx);
$tx = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $tx);
} else {
$tx = $this->writer->utf8ToUtf16BigEndian($tx, false);
}
$tx = $this->writer->escape($tx);
}
// If any settings require a new Text Group
if ($groupBreak || $fontstretch != $last_fontstretch) {
if ($sipset) {
$tj .= '>] TJ ';
} else {
$tj .= ')] TJ ';
}
$tj .= $sipset
? '>] TJ '
: ')] TJ ';
if ($fontid != $last_fontid || $fontsize != $last_fontsize) {
$tj .= sprintf(' /F%d %.3F Tf ', $fontid, $fontsize);
}
if ($fontstretch != $last_fontstretch) {
$tj .= sprintf('%d Tz ', $fontstretch);
}
if ($YPlacement != $lastYPlacement) {
$tj .= sprintf('%.3F Ts ', $YPlacement);
}
if ($sipset) {
$tj .= '[<';
} else {
$tj .= '[(';
}
$tj .= $sipset
? '[<'
: '[(';
}
// Output the code for the txt character
@@ -5667,32 +5634,43 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
// Get YPlacement from next Base character
$nextbase = $i + 1;
while ($OTLdata['group'][$nextbase] != 'C') {
while ($OTLdata['group'][$nextbase] !== 'C') {
$nextbase++;
}
if (isset($GPOSinfo[$nextbase]) && isset($GPOSinfo[$nextbase]['YPlacement']) && $GPOSinfo[$nextbase]['YPlacement']) {
$YPlacement = $GPOSinfo[$nextbase]['YPlacement'] * $this->FontSizePt / $this->CurrentFont['unitsPerEm'];
}
// Prepare Text and Select Font ID
if ($sipset) {
for ($j = 0; $j < 99; $j++) {
$init = array_search($c, $this->CurrentFont['subsets'][$j]);
if ($init !== false) {
if ($this->CurrentFont['subsetfontids'][$j] != $last_fontid) {
$fontid = $this->CurrentFont['subsetfontids'][$j];
}
$tx = sprintf("%02s", strtoupper(dechex($init)));
break;
} elseif (count($this->CurrentFont['subsets'][$j]) < 255) {
}
if (count($this->CurrentFont['subsets'][$j]) < 255) {
$n = count($this->CurrentFont['subsets'][$j]);
$this->CurrentFont['subsets'][$j][$n] = $c;
if ($this->CurrentFont['subsetfontids'][$j] != $last_fontid) {
$fontid = $this->CurrentFont['subsetfontids'][$j];
}
$tx = sprintf("%02s", strtoupper(dechex($n)));
break;
} elseif (!isset($this->CurrentFont['subsets'][($j + 1)])) {
}
if (!isset($this->CurrentFont['subsets'][($j + 1)])) {
$this->CurrentFont['subsets'][($j + 1)] = [0 => 0];
$this->CurrentFont['subsetfontids'][($j + 1)] = count($this->fonts) + $this->extraFontSubsets + 1;
$this->extraFontSubsets++;
@@ -5705,40 +5683,45 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
}
if ($kashida > $tatw) {
// Insert multiple tatweel characters, repositioning the last one to give correct total length
$fontstretch = 100;
$nt = intval($kashida / $tatw);
$nt = (int) ($kashida / $tatw);
$nudgeback = (($nt + 1) * $tatw) - $kashida;
$optx = str_repeat($tx, $nt);
if ($sipset) {
$optx .= sprintf('>%d<', ($nudgeback));
} else {
$optx .= sprintf(')%d(', ($nudgeback));
}
$optx .= $tx; // #last
} else {
// Insert single tatweel character and use fontstretch to get correct length
$fontstretch = ($kashida / $tatw) * 100;
$optx = $tx;
}
if ($sipset) {
$tj .= '>] TJ ';
} else {
$tj .= ')] TJ ';
}
$tj .= $sipset
? '>] TJ '
: ')] TJ ';
if ($fontid != $last_fontid || $fontsize != $last_fontsize) {
$tj .= sprintf(' /F%d %.3F Tf ', $fontid, $fontsize);
}
if ($fontstretch != $last_fontstretch) {
$tj .= sprintf('%d Tz ', $fontstretch);
}
$tj .= sprintf('%.3F Ts ', $YPlacement);
if ($sipset) {
$tj .= '[<';
} else {
$tj .= '[(';
}
$tj .= $sipset
? '[<'
: '[(';
// Output the code for the txt character(s)
$tj .= $optx;
@@ -5750,101 +5733,116 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$lastYPlacement = $YPlacement;
}
$tj .= $sipset
? '>'
: ')';
// Finish up
if ($sipset) {
$tj .= '>';
if ($XshiftAfter) {
$tj .= sprintf('%d', (-$XshiftAfter));
}
if ($last_fontid != $original_fontid) {
$tj .= '] TJ ';
$tj .= sprintf(' /F%d %.3F Tf ', $original_fontid, $fontsize);
$tj .= '[';
}
$tj = preg_replace('/([^\\\])<>/', '\\1 ', $tj);
} else {
$tj .= ')';
if ($XshiftAfter) {
$tj .= sprintf('%d', (-$XshiftAfter));
}
if ($last_fontid != $original_fontid) {
$tj .= '] TJ ';
$tj .= sprintf(' /F%d %.3F Tf ', $original_fontid, $fontsize);
$tj .= '[';
}
$tj = preg_replace('/([^\\\])\(\)/', '\\1 ', $tj);
if ($XshiftAfter) {
$tj .= sprintf('%d', (-$XshiftAfter));
}
$s = sprintf(' BT ' . $aix . ' 0 Tc 0 Tw [%s] TJ ET ', $x, $y, $tj);
if ($last_fontid != $original_fontid) {
$tj .= '] TJ ';
$tj .= sprintf(' /F%d %.3F Tf ', $original_fontid, $fontsize);
$tj .= '[';
}
// echo $s."\n\n"; // exit;
$tj = $sipset
? preg_replace('/([^\\\])<>/', '\\1 ', $tj)
: preg_replace('/([^\\\])\(\)/', '\\1 ', $tj);
return $s;
return sprintf(' BT ' . $aix . ' 0 Tc 0 Tw [%s] TJ ET ', $x, $y, $tj);
}
function _kern($txt, $mode, $aix, $x, $y)
{
if ($mode == 'MBTw') { // Multibyte requiring word spacing
if ($mode === 'MBTw') { // Multibyte requiring word spacing
$space = ' ';
// Convert string to UTF-16BE without BOM
$space = $this->writer->utf8ToUtf16BigEndian($space, false);
$space = $this->writer->escape($space);
$s = sprintf(' BT ' . $aix, $x * Mpdf::SCALE, ($this->h - $y) * Mpdf::SCALE);
$t = explode(' ', $txt);
for ($i = 0; $i < count($t); $i++) {
$tx = $t[$i];
foreach ($t as $i => $iValue) {
$tx = $iValue;
$tj = '(';
$unicode = $this->UTF8StringToArray($tx);
for ($ti = 0; $ti < count($unicode); $ti++) {
if ($ti > 0 && isset($this->CurrentFont['kerninfo'][$unicode[($ti - 1)]][$unicode[$ti]])) {
$kern = -$this->CurrentFont['kerninfo'][$unicode[($ti - 1)]][$unicode[$ti]];
foreach ($unicode as $ti => $tiValue) {
if ($ti > 0 && isset($this->CurrentFont['kerninfo'][$unicode[($ti - 1)]][$tiValue])) {
$kern = -$this->CurrentFont['kerninfo'][$unicode[($ti - 1)]][$tiValue];
$tj .= sprintf(')%d(', $kern);
}
$tc = UtfString::code2utf($unicode[$ti]);
$tc = UtfString::code2utf($tiValue);
$tc = $this->writer->utf8ToUtf16BigEndian($tc, false);
$tj .= $this->writer->escape($tc);
}
$tj .= ')';
$s .= sprintf(' %.3F Tc [%s] TJ', $this->charspacing, $tj);
if (($i + 1) < count($t)) {
$s .= sprintf(' %.3F Tc (%s) Tj', $this->ws + $this->charspacing, $space);
}
}
$s .= ' ET ';
} elseif (!$this->usingCoreFont) {
return $s;
}
if (!$this->usingCoreFont) {
$s = '';
$tj = '(';
$unicode = $this->UTF8StringToArray($txt);
for ($i = 0; $i < count($unicode); $i++) {
if ($i > 0 && isset($this->CurrentFont['kerninfo'][$unicode[($i - 1)]][$unicode[$i]])) {
$kern = -$this->CurrentFont['kerninfo'][$unicode[($i - 1)]][$unicode[$i]];
foreach ($unicode as $i => $iValue) {
if ($i > 0 && isset($this->CurrentFont['kerninfo'][$unicode[($i - 1)]][$iValue])) {
$kern = -$this->CurrentFont['kerninfo'][$unicode[($i - 1)]][$iValue];
$tj .= sprintf(')%d(', $kern);
}
$tx = UtfString::code2utf($unicode[$i]);
$tx = UtfString::code2utf($iValue);
$tx = $this->writer->utf8ToUtf16BigEndian($tx, false);
$tj .= $this->writer->escape($tx);
}
$tj .= ')';
$s .= sprintf(' BT ' . $aix . ' [%s] TJ ET ', $x * Mpdf::SCALE, ($this->h - $y) * Mpdf::SCALE, $tj);
} else { // CORE Font
$s = '';
$tj = '(';
$l = strlen($txt);
for ($i = 0; $i < $l; $i++) {
if ($i > 0 && isset($this->CurrentFont['kerninfo'][$txt[($i - 1)]][$txt[$i]])) {
$kern = -$this->CurrentFont['kerninfo'][$txt[($i - 1)]][$txt[$i]];
$tj .= sprintf(')%d(', $kern);
}
$tj .= $this->writer->escape($txt[$i]);
}
$tj .= ')';
$s .= sprintf(' BT ' . $aix . ' [%s] TJ ET ', $x * Mpdf::SCALE, ($this->h - $y) * Mpdf::SCALE, $tj);
return $s;
}
$s = '';
$tj = '(';
$l = strlen($txt);
for ($i = 0; $i < $l; $i++) {
if ($i > 0 && isset($this->CurrentFont['kerninfo'][$txt[($i - 1)]][$txt[$i]])) {
$kern = -$this->CurrentFont['kerninfo'][$txt[($i - 1)]][$txt[$i]];
$tj .= sprintf(')%d(', $kern);
}
$tj .= $this->writer->escape($txt[$i]);
}
$tj .= ')';
$s .= sprintf(' BT ' . $aix . ' [%s] TJ ET ', $x * Mpdf::SCALE, ($this->h - $y) * Mpdf::SCALE, $tj);
return $s;
}
@@ -7288,7 +7286,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$translate_x = $this->sizeConverter->convert($vv[0], $maxsize_x, false, false);
$tr2 .= $this->transformTranslate($translate_x, 0, true) . ' ';
} elseif ($c == 'translatey' && count($vv)) {
$translate_y = $this->sizeConverter->convert($vv[1], $maxsize_y, false, false);
$translate_y = $this->sizeConverter->convert($vv[0], $maxsize_y, false, false);
$tr2 .= $this->transformTranslate(0, $translate_y, true) . ' ';
} elseif ($c == 'scale' && count($vv)) {
$scale_x = $vv[0] * 100;
@@ -7302,7 +7300,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$scale_x = $vv[0] * 100;
$tr2 .= $this->transformScale($scale_x, 0, $cx, $cy, true) . ' ';
} elseif ($c == 'scaley' && count($vv)) {
$scale_y = $vv[1] * 100;
$scale_y = $vv[0] * 100;
$tr2 .= $this->transformScale(0, $scale_y, $cx, $cy, true) . ' ';
} elseif ($c == 'skew' && count($vv)) {
$angle_x = $this->ConvertAngle($vv[0], false);
@@ -7849,7 +7847,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
/* -- END CSS-IMAGE-FLOAT -- */
} // *TABLES*
// OBJECTS - IMAGES & FORM Elements (NB has already skipped line/page if required - in printbuffer)
if (substr($s, 0, 3) == "\xbb\xa4\xac") { // identifier has been identified!
if (substr($s, 0, 3) == Mpdf::OBJECT_IDENTIFIER) { // identifier has been identified!
$objattr = $this->_getObjAttr($s);
$h_corr = 0;
if ($is_table) { // *TABLES*
@@ -8230,8 +8228,13 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$contentB[count($content) - 1] = preg_replace('/R/', '', $contentB[count($content) - 1]); // ???
}
if ($type == 'hyphen') {
$currContent .= '-';
if ($type === 'hyphen') {
$hyphen = in_array(mb_substr($currContent, -1), ['-', '', '—'], true);
if (!$hyphen) {
$currContent .= '-';
} else {
$savedPreContent[count($savedPreContent) - 1] = '-' . $savedPreContent[count($savedPreContent) - 1];
}
if (!empty($cOTLdata[(count($cOTLdata) - 1)])) {
$cOTLdata[(count($cOTLdata) - 1)]['char_data'][] = ['bidi_class' => 9, 'uni' => 45];
$cOTLdata[(count($cOTLdata) - 1)]['group'] .= 'C';
@@ -9091,12 +9094,14 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
function _getObjAttr($t)
{
$c = explode("\xbb\xa4\xac", $t, 2);
$c = explode(",", $c[1], 2);
$c = explode(Mpdf::OBJECT_IDENTIFIER, $t, 2);
$c = explode(',', $c[1], 2);
foreach ($c as $v) {
$v = explode("=", $v, 2);
$sp[$v[0]] = $v[1];
$v = explode('=', $v, 2);
$sp[$v[0]] = trim($v[1], Mpdf::OBJECT_IDENTIFIER);
}
return (unserialize($sp['objattr']));
}
@@ -9741,6 +9746,13 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->margin_footer = $this->saveHTMLHeader[$n][$OE]['mf'];
$this->w = $this->saveHTMLHeader[$n][$OE]['pw'];
$this->h = $this->saveHTMLHeader[$n][$OE]['ph'];
if ($this->w > $this->h) {
$this->hPt = $this->fwPt;
$this->wPt = $this->fhPt;
} else {
$this->hPt = $this->fhPt;
$this->wPt = $this->fwPt;
}
$rotate = (isset($this->saveHTMLHeader[$n][$OE]['rotate']) ? $this->saveHTMLHeader[$n][$OE]['rotate'] : null);
$this->Reset();
$this->pageoutput[$n] = [];
@@ -9815,6 +9827,13 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->margin_footer = $this->saveHTMLFooter[$n][$OE]['mf'];
$this->w = $this->saveHTMLFooter[$n][$OE]['pw'];
$this->h = $this->saveHTMLFooter[$n][$OE]['ph'];
if ($this->w > $this->h) {
$this->hPt = $this->fwPt;
$this->wPt = $this->fhPt;
} else {
$this->hPt = $this->fhPt;
$this->wPt = $this->fwPt;
}
$rotate = (isset($this->saveHTMLFooter[$n][$OE]['rotate']) ? $this->saveHTMLFooter[$n][$OE]['rotate'] : null);
$this->Reset();
$this->pageoutput[$n] = [];
@@ -10129,6 +10148,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->page++;
$this->pages[$this->page] = '';
}
$this->state = 2;
$resetHTMLHeadersrequired = false;
@@ -10138,15 +10158,15 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
/* -- CSS-PAGE -- */
// Paged media (page-box)
if ($pagesel || (isset($this->page_box['using']) && $this->page_box['using'])) {
if ($pagesel || $this->page_box['using']) {
if ($pagesel || $this->page == 1) {
if ($pagesel || $this->page === 1) {
$first = true;
} else {
$first = false;
}
if ($this->mirrorMargins && ($this->page % 2 == 0)) {
if ($this->mirrorMargins && ($this->page % 2 === 0)) {
$oddEven = 'E';
} else {
$oddEven = 'O';
@@ -10162,7 +10182,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
list($orientation, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $hname, $fname, $bg, $resetpagenum, $pagenumstyle, $suppress, $marks, $newformat) = $this->SetPagedMediaCSS($psel, $first, $oddEven);
if ($this->mirrorMargins && ($this->page % 2 == 0)) {
if ($this->mirrorMargins && ($this->page % 2 === 0)) {
if ($hname) {
$ehvalue = 1;
@@ -10245,15 +10265,15 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
}
}
if ($orientation != $this->CurOrientation || $newformat) {
if ($orientation !== $this->CurOrientation || $newformat) {
// Change orientation
if ($orientation == 'P') {
if ($orientation === 'P') {
$this->wPt = $this->fwPt;
$this->hPt = $this->fhPt;
$this->w = $this->fw;
$this->h = $this->fh;
if (($this->forcePortraitHeaders || $this->forcePortraitMargins) && $this->DefOrientation == 'P') {
if (($this->forcePortraitHeaders || $this->forcePortraitMargins) && $this->DefOrientation === 'P') {
$this->tMargin = $this->orig_tMargin;
$this->bMargin = $this->orig_bMargin;
$this->DeflMargin = $this->orig_lMargin;
@@ -10269,7 +10289,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->w = $this->fh;
$this->h = $this->fw;
if (($this->forcePortraitHeaders || $this->forcePortraitMargins) && $this->DefOrientation == 'P') {
if (($this->forcePortraitHeaders || $this->forcePortraitMargins) && $this->DefOrientation === 'P') {
$this->tMargin = $this->orig_lMargin;
$this->bMargin = $this->orig_rMargin;
$this->DeflMargin = $this->orig_bMargin;
@@ -10290,10 +10310,10 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->pageDim[$this->page]['w'] = $this->w;
$this->pageDim[$this->page]['h'] = $this->h;
$this->pageDim[$this->page]['outer_width_LR'] = isset($this->page_box['outer_width_LR']) ? $this->page_box['outer_width_LR'] : 0;
$this->pageDim[$this->page]['outer_width_TB'] = isset($this->page_box['outer_width_TB']) ? $this->page_box['outer_width_TB'] : 0;
$this->pageDim[$this->page]['outer_width_LR'] = $this->page_box['outer_width_LR'] ?: 0;
$this->pageDim[$this->page]['outer_width_TB'] = $this->page_box['outer_width_TB'] ?: 0;
if (!isset($this->page_box['outer_width_LR']) && !isset($this->page_box['outer_width_TB'])) {
if (!$this->page_box['outer_width_LR'] && !$this->page_box['outer_width_TB']) {
$this->pageDim[$this->page]['bleedMargin'] = 0;
} elseif ($this->bleedMargin <= $this->page_box['outer_width_LR'] && $this->bleedMargin <= $this->page_box['outer_width_TB']) {
$this->pageDim[$this->page]['bleedMargin'] = $this->bleedMargin;
@@ -10573,7 +10593,8 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->SetAlpha($alpha);
$this->SetTColor($this->colorConverter->convert(0, $this->PDFAXwarnings));
$color = $this->watermarkTextObject ? $this->watermarkTextObject->getColor() : 0;
$this->SetTColor($this->colorConverter->convert($color, $this->PDFAXwarnings));
$szfont = $fontsize;
$loop = 0;
@@ -10603,6 +10624,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->Rotate($angle, $wx, $wy);
$this->Text($wx, $wy, $texte, $OTLdata, $textvar);
$this->Rotate(0);
$this->SetTColor($this->colorConverter->convert(0, $this->PDFAXwarnings));
$this->SetAlpha(1);
@@ -13067,17 +13089,41 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
function SetWatermarkText($txt = '', $alpha = -1)
{
if ($txt instanceof \Mpdf\WatermarkText) {
$this->watermarkTextObject = $txt;
$this->watermarkText = $txt->getText();
$this->watermarkTextAlpha = $txt->getAlpha();
$this->watermarkAngle = $txt->getAngle();
$this->watermark_font = $txt->getFont() === null ? $txt->getFont() : $this->watermark_font;
$this->watermark_size = $txt->getSize();
return;
}
if ($alpha >= 0) {
$this->watermarkTextAlpha = $alpha;
}
$this->watermarkText = $txt;
}
function SetWatermarkImage($src, $alpha = -1, $size = 'D', $pos = 'F')
{
if ($src instanceof \Mpdf\WatermarkImage) {
$this->watermarkImage = $src->getPath();
$this->watermark_size = $src->getSize();
$this->watermark_pos = $src->getPosition();
$this->watermarkImageAlpha = $src->getAlpha();
$this->watermarkImgBehind = $src->isBehindContent();
$this->watermarkImgAlphaBlend = $src->getAlphaBlend();
return;
}
if ($alpha >= 0) {
$this->watermarkImageAlpha = $alpha;
}
$this->watermarkImage = $src;
$this->watermark_size = $size;
$this->watermark_pos = $pos;
@@ -13185,7 +13231,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
/* -- WATERMARK -- */
if (($this->watermarkText) && ($this->showWatermarkText)) {
$this->watermark($this->watermarkText, $this->watermarkAngle, 120, $this->watermarkTextAlpha); // Watermark text
$this->watermark($this->watermarkText, $this->watermarkAngle, is_int($this->watermark_size) ? $this->watermark_size : 120, $this->watermarkTextAlpha); // Watermark text
}
if (($this->watermarkImage) && ($this->showWatermarkImage)) {
$this->watermarkImg($this->watermarkImage, $this->watermarkImageAlpha); // Watermark image
@@ -13595,7 +13641,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$objattr['text'] = $e;
$objattr['OTLdata'] = $this->OTLdata;
$this->OTLdata = [];
$te = "\xbb\xa4\xactype=textarea,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$te = Mpdf::OBJECT_IDENTIFIER . "type=textarea,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
if ($this->tdbegin) {
$this->_saveCellTextBuffer($te, $this->HREF);
} else {
@@ -15518,7 +15564,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$objattr['listmarkerposition'] = $listitemposition;
$e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=image,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
$this->_saveTextBuffer($e);
if ($listitemposition == 'inside') {
@@ -15549,7 +15595,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$objattr['fontsizept'] = $this->FontSizePt;
$objattr['fontstyle'] = $this->FontStyle;
$e = "\xbb\xa4\xactype=listmarker,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=listmarker,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
$this->listitem = $this->_saveTextBuffer($e, '', '', true); // true returns array
} elseif (preg_match('/U\+([a-fA-F0-9]+)/i', $listitemtype, $m)) { // SYMBOL 2 (needs new font)
@@ -15587,7 +15633,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$objattr['fontsize'] = $this->FontSize;
$objattr['fontsizept'] = $this->FontSizePt;
$objattr['fontstyle'] = $this->FontStyle;
$e = "\xbb\xa4\xactype=listmarker,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=listmarker,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
$this->listitem = $this->_saveTextBuffer($e, '', '', true); // true returns array
}
@@ -15626,7 +15672,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$objattr['fontsize'] = $this->FontSize;
$objattr['fontsizept'] = $this->FontSizePt;
$objattr['fontstyle'] = $this->FontStyle;
$e = "\xbb\xa4\xactype=listmarker,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=listmarker,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
$this->listitem = $this->_saveTextBuffer($e, '', '', true); // true returns array
}
@@ -16019,7 +16065,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
// First make sure each element/chunk has the OTLdata for Bidi set.
for ($i = 0; $i < $array_size; $i++) {
if (empty($arrayaux[$i][18])) {
if (substr($arrayaux[$i][0], 0, 3) == "\xbb\xa4\xac") { // object identifier has been identified!
if (substr($arrayaux[$i][0], 0, 3) == Mpdf::OBJECT_IDENTIFIER) { // object identifier has been identified!
$unicode = [0xFFFC]; // Object replacement character
} else {
$unicode = $this->UTF8StringToArray($arrayaux[$i][0], false);
@@ -16042,10 +16088,9 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$array_size = count($arrayaux);
}
// Remove empty items // mPDF 6
for ($i = $array_size - 1; $i > 0; $i--) {
if (empty($arrayaux[$i][0]) && (isset($arrayaux[$i][16]) && $arrayaux[$i][16] !== '0') && empty($arrayaux[$i][7])) {
if ('' === $arrayaux[$i][0] && (isset($arrayaux[$i][16]) && $arrayaux[$i][16] !== '0') && empty($arrayaux[$i][7])) {
unset($arrayaux[$i]);
}
}
@@ -16092,7 +16137,8 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
}
// FIXED TO ALLOW IT TO SHOW '0'
if (empty($vetor[0]) && !($vetor[0] === '0') && empty($vetor[7])) { // Ignore empty text and not carrying an internal link
if (empty($vetor[0]) && !($vetor[0] === '0') && empty($vetor[7])) {
// Ignore empty text and not carrying an internal link
// Check if it is the last element. If so then finish printing the block
if ($i == ($array_size - 1)) {
$this->finishFlowingBlock(true);
@@ -16206,7 +16252,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
// SPECIAL CONTENT - IMAGES & FORM OBJECTS
// Print-out special content
if (substr($vetor[0], 0, 3) == "\xbb\xa4\xac") { // identifier has been identified!
if (substr($vetor[0], 0, 3) == Mpdf::OBJECT_IDENTIFIER) { // identifier has been identified!
$objattr = $this->_getObjAttr($vetor[0]);
/* -- TABLES -- */
@@ -19133,7 +19179,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
}
// IMAGES & FORM ELEMENTS
if (substr($line, 0, 3) == "\xbb\xa4\xac") { // inline object - FORM element or IMAGE!
if (substr($line, 0, 3) == Mpdf::OBJECT_IDENTIFIER) { // inline object - FORM element or IMAGE!
$objattr = $this->_getObjAttr($line);
if ($objattr['type'] != 'hr' && isset($objattr['width']) && ($objattr['width'] / $this->shrin_k) > ($maxwidth + 0.0001)) {
if (($objattr['width'] / $this->shrin_k) > $biggestword) {
@@ -20793,7 +20839,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
for ($i = $row + 1; $i < $table['nr']; $i++) {
$cellsset = 0;
for ($j = 0; $j < $table['nc']; $j++) {
if ($table['cells'][$i][$j]) {
if (!empty($table['cells'][$i][$j])) {
if (isset($table['cells'][$i][$j]['colspan'])) {
$cellsset += $table['cells'][$i][$j]['colspan'];
} else {
@@ -21908,10 +21954,10 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
if (isset($cell['textbuffer'])) {
for ($n = 0; $n < count($cell['textbuffer']); $n++) {
$t = $cell['textbuffer'][$n][0];
if (substr($t, 0, 19) == "\xbb\xa4\xactype=nestedtable") {
if (substr($t, 0, 19) == Mpdf::OBJECT_IDENTIFIER . "type=nestedtable") {
$objattr = $this->_getObjAttr($t);
$objattr['col'] = $col;
$cell['textbuffer'][$n][0] = "\xbb\xa4\xactype=nestedtable,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$cell['textbuffer'][$n][0] = Mpdf::OBJECT_IDENTIFIER . "type=nestedtable,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
$this->table[($this->tableLevel + 1)][$objattr['nestedcontent']]['nestedpos'][1] = $col;
}
}
@@ -22192,7 +22238,13 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$extra = $table['max_cell_border_width']['B'] / 2;
}
if ($j == $startcol && ((($y + $maxrowheight + $extra ) > ($pagetrigger + 0.001)) || (($this->keepColumns || !$this->ColActive) && !empty($tablefooter) && ($y + $maxrowheight + $tablefooterrowheight + $extra) > $pagetrigger) && ($this->tableLevel == 1 && $i < ($numrows - $table['headernrows']))) && ($y0 > 0 || $x0 > 0) && !$this->InFooter && $this->autoPageBreak) {
// lookahead for pagebreak
$pagebreaklookahead = 1;
while (isset($table['pagebreak-before']) && isset($table['pagebreak-before'][$i + $pagebreaklookahead]) && $table['pagebreak-before'][$i + $pagebreaklookahead] == 'avoid') {
// pagebreak-after is mapped to pagebreak-before on i+1 in Tags/Tr.php
$pagebreaklookahead++;
}
if ($j == $startcol && ((($y + $pagebreaklookahead * $maxrowheight + $extra ) > ($pagetrigger + 0.001)) || (($this->keepColumns || !$this->ColActive) && !empty($tablefooter) && ($y + $maxrowheight + $tablefooterrowheight + $extra) > $pagetrigger) && ($this->tableLevel == 1 && $i < ($numrows - $table['headernrows']))) && ($y0 > 0 || $x0 > 0) && !$this->InFooter && $this->autoPageBreak) {
if (!$skippage) {
$finalSpread = true;
$firstSpread = true;
@@ -24547,7 +24599,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$th = ($sum_h * $i / $this->NbCol);
foreach ($breaks as $bk => $val) {
if ($val > $th) {
if (($val - $th) < ($th - $breaks[$bk - 1])) {
if (!$bk || ($val - $th) < ($th - $breaks[$bk - 1])) {
$cbr[$i - 1] = $val;
} else {
$cbr[$i - 1] = $breaks[$bk - 1];
@@ -26090,7 +26142,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
{
if (!$this->is_utf8($html)) {
while (mb_convert_encoding(mb_convert_encoding($html, "UTF-32", "UTF-8"), "UTF-8", "UTF-32") != $html) {
while (mb_convert_encoding(mb_convert_encoding($html, "UTF-32", "UTF-8"), "UTF-8", "UTF-32") !== $html) {
$a = @iconv('UTF-8', 'UTF-8', $html);
$error = error_get_last();
@@ -27024,7 +27076,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
if (strlen($html) > (int) $limit) {
throw new \Mpdf\MpdfException(sprintf(
'The HTML code size is larger than pcre.backtrack_limit %d. You should use WriteHTML() with smaller string lengths.',
'The HTML code size is larger than pcre.backtrack_limit %d. You should use WriteHTML() with smaller string lengths. Pass your HTML in smaller chunks.',
$limit
));
}
@@ -27032,7 +27084,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
preg_match_all("/(<annotation.*?>)/si", $html, $m);
if (count($m[1])) {
for ($i = 0; $i < count($m[1]); $i++) {
$sub = preg_replace("/\n/si", "\xbb\xa4\xac", $m[1][$i]);
$sub = preg_replace("/\n/si", Mpdf::OBJECT_IDENTIFIER, $m[1][$i]);
$html = preg_replace('/' . preg_quote($m[1][$i], '/') . '/si', $sub, $html);
}
}
@@ -27170,8 +27222,16 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$html = preg_replace('/<textarea([^>]*)><\/textarea>/si', '<textarea\\1> </textarea>', $html);
$html = preg_replace('/(<table[^>]*>)\s*(<caption)(.*?<\/caption>)(.*?<\/table>)/si', '\\2 position="top"\\3\\1\\4\\2 position="bottom"\\3', $html); // *TABLES*
$html = preg_replace('/<(h[1-6])([^>]*)(>(?:(?!h[1-6]).)*?<\/\\1>\s*<table)/si', '<\\1\\2 keep-with-table="1"\\3', $html); // *TABLES*
$html = preg_replace("/\xbb\xa4\xac/", "\n", $html);
if ($this->use_kwt) {
$returnHtml = preg_replace('/<(h[1-6])([^>]*(?<!\/))(>[^>]*<\/\\1>\s*<table)/si', '<\\1\\2 keep-with-table="1"\\3', $html);
/* If no errors then save the return value */
if (preg_last_error() === PREG_NO_ERROR) {
$html = $returnHtml;
}
}
$html = preg_replace('/' . Mpdf::OBJECT_IDENTIFIER . '/', "\n", $html);
// Fixes <p>&#8377</p> which browser copes with even though it is wrong!
$html = preg_replace("/(&#[x]{0,1}[0-9a-f]{1,5})</i", "\\1;<", $html);

View File

@@ -1539,6 +1539,10 @@ class Otl
continue;
}
if (!isset($this->OTLdata[$ptr + 1])) {
continue;
}
$nextGlyph = $this->OTLdata[$ptr + 1]['hex'];
$nextGID = $this->OTLdata[$ptr + 1]['uni'];
if (isset($this->GSLuCoverage[$lu][$c][$nextGID])) {

56
vendor/mpdf/mpdf/src/PageBox.php vendored Normal file
View File

@@ -0,0 +1,56 @@
<?php
namespace Mpdf;
class PageBox implements \ArrayAccess
{
private $container = [];
public function __construct()
{
$this->container = [
'current' => null,
'outer_width_LR' => null,
'outer_width_TB' => null,
'using' => null,
];
}
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if (!$this->offsetExists($offset)) {
throw new \Mpdf\MpdfException('Invalid key to set for PageBox');
}
$this->container[$offset] = $value;
}
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return array_key_exists($offset, $this->container);
}
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
if (!$this->offsetExists($offset)) {
throw new \Mpdf\MpdfException('Invalid key to set for PageBox');
}
$this->container[$offset] = null;
}
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
if (!$this->offsetExists($offset)) {
throw new \Mpdf\MpdfException('Invalid key to set for PageBox');
}
return $this->container[$offset];
}
}

View File

@@ -4,10 +4,13 @@ namespace Mpdf;
use Psr\Log\LoggerInterface;
use Mpdf\Log\Context as LogContext;
use Mpdf\PsrLogAwareTrait\PsrLogAwareTrait;
class SizeConverter implements \Psr\Log\LoggerAwareInterface
{
use PsrLogAwareTrait;
private $dpi;
private $defaultFontSize;
@@ -17,11 +20,6 @@ class SizeConverter implements \Psr\Log\LoggerAwareInterface
*/
private $mpdf;
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
public function __construct($dpi, $defaultFontSize, Mpdf $mpdf, LoggerInterface $logger)
{
$this->dpi = $dpi;
@@ -30,11 +28,6 @@ class SizeConverter implements \Psr\Log\LoggerAwareInterface
$this->logger = $logger;
}
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* Depends of maxsize value to make % work properly. Usually maxsize == pagewidth
* For text $maxsize = $fontsize

View File

@@ -2297,7 +2297,7 @@ class TTFontFile
$key = $vs['match'][1];
$tag = $v['tag'];
if (isset($loclsubs[$key])) {
${$tag[$loclsubs[$key]]} = $sub;
${$tag}[$loclsubs[$key]] = $sub;
}
$tmp = &$$tag;
$tmp[hexdec($key)] = hexdec($sub);
@@ -2307,7 +2307,7 @@ class TTFontFile
$key = $vs['match'][0];
$tag = $v['tag'];
if (isset($loclsubs[$key])) {
${$tag[$loclsubs[$key]]} = $sub;
${$tag}[$loclsubs[$key]] = $sub;
}
$tmp = &$$tag;
$tmp[hexdec($key)] = hexdec($sub);
@@ -2326,7 +2326,7 @@ class TTFontFile
$key = substr($key, 6, 5);
$tag = $v['tag'];
if (isset($loclsubs[$key])) {
${$tag[$loclsubs[$key]]} = $sub;
${$tag}[$loclsubs[$key]] = $sub;
}
$tmp = &$$tag;
$tmp[hexdec($key)] = hexdec($sub);
@@ -2334,7 +2334,7 @@ class TTFontFile
$key = substr($key, 0, 5);
$tag = $v['tag'];
if (isset($loclsubs[$key])) {
${$tag[$loclsubs[$key]]} = $sub;
${$tag}[$loclsubs[$key]] = $sub;
}
$tmp = &$$tag;
$tmp[hexdec($key)] = hexdec($sub);
@@ -2888,27 +2888,28 @@ class TTFontFile
$lup = $Lookup[$i]['Subtable'][$c]['SubstLookupRecord'][$b]['LookupListIndex'];
$seqIndex = $Lookup[$i]['Subtable'][$c]['SubstLookupRecord'][$b]['SequenceIndex'];
for ($lus = 0; $lus < $Lookup[$lup]['SubtableCount']; $lus++) {
if (count($Lookup[$lup]['Subtable'][$lus]['subs'])) {
foreach ($Lookup[$lup]['Subtable'][$lus]['subs'] as $luss) {
$lookupGlyphs = $luss['Replace'];
$mLen = count($lookupGlyphs);
if (empty($Lookup[$lup]['Subtable'][$lus]['subs']) || ! is_array($Lookup[$lup]['Subtable'][$lus]['subs'])) {
continue;
}
// Only apply if the (first) 'Replace' glyph from the
// Lookup list is in the [inputGlyphs] at ['SequenceIndex']
// then apply the substitution
if (strpos($inputGlyphs[$seqIndex], $lookupGlyphs[0]) === false) {
continue;
}
foreach ($Lookup[$lup]['Subtable'][$lus]['subs'] as $luss) {
$lookupGlyphs = $luss['Replace'];
// Returns e.g. ¦(0612)¦(ignore) (0613)¦(ignore) (0614)¦
$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, $lookupGlyphs, $seqIndex);
$REPL = implode(" ", $luss['substitute']);
// Only apply if the (first) 'Replace' glyph from the
// Lookup list is in the [inputGlyphs] at ['SequenceIndex']
// then apply the substitution
if (strpos($inputGlyphs[$seqIndex], $lookupGlyphs[0]) === false) {
continue;
}
if (strpos("isol fina fin2 fin3 medi med2 init ", $tag) !== false && $scripttag == 'arab') {
$volt[] = ['match' => $lookupGlyphs[0], 'replace' => $REPL, 'tag' => $tag, 'prel' => $backtrackGlyphs, 'postl' => $lookaheadGlyphs, 'ignore' => $ignore];
} else {
$subRule['rules'][] = ['type' => $Lookup[$lup]['Type'], 'match' => $lookupGlyphs, 'replace' => $luss['substitute'], 'seqIndex' => $seqIndex, 'key' => $lookupGlyphs[0],];
}
// Returns e.g. ¦(0612)¦(ignore) (0613)¦(ignore) (0614)¦
$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, $lookupGlyphs, $seqIndex);
$REPL = implode(" ", $luss['substitute']);
if (strpos("isol fina fin2 fin3 medi med2 init ", $tag) !== false && $scripttag == 'arab') {
$volt[] = ['match' => $lookupGlyphs[0], 'replace' => $REPL, 'tag' => $tag, 'prel' => $backtrackGlyphs, 'postl' => $lookaheadGlyphs, 'ignore' => $ignore];
} else {
$subRule['rules'][] = ['type' => $Lookup[$lup]['Type'], 'match' => $lookupGlyphs, 'replace' => $luss['substitute'], 'seqIndex' => $seqIndex, 'key' => $lookupGlyphs[0],];
}
}
}

View File

@@ -2,6 +2,8 @@
namespace Mpdf\Tag;
use Mpdf\Mpdf;
class A extends Tag
{
@@ -19,7 +21,7 @@ class A extends Tag
} else {
$objattr['bklevel'] = 0;
}
$e = "\xbb\xa4\xactype=bookmark,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=bookmark,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
}
/* -- END BOOKMARKS -- */
if ($this->mpdf->tableLevel) { // *TABLES*

View File

@@ -2,6 +2,8 @@
namespace Mpdf\Tag;
use Mpdf\Mpdf;
class Annotation extends Tag
{
@@ -84,7 +86,7 @@ class Annotation extends Tag
$objattr['POPUP'] = true;
}
}
$e = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=annot,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
if ($this->mpdf->tableLevel) {
$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = [$e];
} // *TABLES*

View File

@@ -2,6 +2,8 @@
namespace Mpdf\Tag;
use Mpdf\Mpdf;
class BarCode extends Tag
{
@@ -31,7 +33,7 @@ class BarCode extends Tag
$objattr['border_bottom']['w'] = 0;
$objattr['border_left']['w'] = 0;
$objattr['border_right']['w'] = 0;
$objattr['code'] = $attr['CODE'];
$objattr['code'] = htmlspecialchars_decode($attr['CODE']);
if (isset($attr['TYPE'])) {
$objattr['btype'] = strtoupper(trim($attr['TYPE']));
@@ -249,7 +251,7 @@ class BarCode extends Tag
}
/* -- END CSS-IMAGE-FLOAT -- */
$e = "\xbb\xa4\xactype=barcode,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=barcode,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
/* -- TABLES -- */
// Output it to buffers

View File

@@ -4,6 +4,7 @@ namespace Mpdf\Tag;
use Mpdf\Conversion\DecToAlpha;
use Mpdf\Conversion\DecToRoman;
use Mpdf\Mpdf;
use Mpdf\Utils\Arrays;
use Mpdf\Utils\UtfString;
@@ -246,11 +247,9 @@ abstract class BlockTag extends Tag
/* -- END CSS-PAGE -- */
// If page-box has changed AND/OR PAGE-BREAK-BEFORE
// mPDF 6 (uses $p - preview of properties so blklvl can be imcremented after page-break)
if (!$this->mpdf->tableLevel && (($pagesel && (!isset($this->mpdf->page_box['current'])
|| $pagesel != $this->mpdf->page_box['current']))
|| (isset($p['PAGE-BREAK-BEFORE'])
&& $p['PAGE-BREAK-BEFORE']))) {
// mPDF 6 (uses $p - preview of properties so blklvl can be incremented after page-break)
if (!$this->mpdf->tableLevel && (($pagesel && (!$this->mpdf->page_box['current'] || $pagesel != $this->mpdf->page_box['current']))
|| (isset($p['PAGE-BREAK-BEFORE']) && $p['PAGE-BREAK-BEFORE']))) {
// mPDF 6 pagebreaktype
$startpage = $this->mpdf->page;
$pagebreaktype = $this->mpdf->defaultPagebreakType;
@@ -258,7 +257,7 @@ abstract class BlockTag extends Tag
if ($this->mpdf->ColActive) {
$pagebreaktype = 'cloneall';
}
if ($pagesel && (!isset($this->mpdf->page_box['current']) || $pagesel != $this->mpdf->page_box['current'])) {
if ($pagesel && (!$this->mpdf->page_box['current'] || $pagesel != $this->mpdf->page_box['current'])) {
$pagebreaktype = 'cloneall';
}
$this->mpdf->_preForcedPagebreak($pagebreaktype);
@@ -317,7 +316,7 @@ abstract class BlockTag extends Tag
} // *CSS-PAGE*
} /* -- CSS-PAGE -- */
// Must Add new page if changed page properties
elseif (!isset($this->mpdf->page_box['current']) || $pagesel != $this->mpdf->page_box['current']) {
elseif (!$this->mpdf->page_box['current'] || $pagesel != $this->mpdf->page_box['current']) {
$this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
}
/* -- END CSS-PAGE -- */
@@ -992,7 +991,7 @@ abstract class BlockTag extends Tag
$content = $this->mpdf->textbuffer[0][0];
} else {
for ($i = 0; $i < count($this->mpdf->textbuffer); $i++) {
if (0 !== strpos($this->mpdf->textbuffer[$i][0], "\xbb\xa4\xac")) { //inline object
if (0 !== strpos($this->mpdf->textbuffer[$i][0], Mpdf::OBJECT_IDENTIFIER)) { //inline object
$content .= $this->mpdf->textbuffer[$i][0];
}
}
@@ -1003,7 +1002,7 @@ abstract class BlockTag extends Tag
$objattr['type'] = 'toc';
$objattr['toclevel'] = $this->mpdf->h2toc[$tag];
$objattr['CONTENT'] = htmlspecialchars($content);
$e = "\xbb\xa4\xactype=toc,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=toc,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
array_unshift($this->mpdf->textbuffer, [$e]);
}
/* -- END TOC -- */
@@ -1013,7 +1012,7 @@ abstract class BlockTag extends Tag
$objattr['type'] = 'bookmark';
$objattr['bklevel'] = $this->mpdf->h2bookmarks[$tag];
$objattr['CONTENT'] = $content;
$e = "\xbb\xa4\xactype=toc,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=toc,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
array_unshift($this->mpdf->textbuffer, [$e]);
}
/* -- END BOOKMARKS -- */
@@ -1081,7 +1080,7 @@ abstract class BlockTag extends Tag
// called from after e.g. </table> </div> </div> ... Outputs block margin/border and padding
if (count($this->mpdf->textbuffer) && $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1]) {
if (0 !== strpos($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], "\xbb\xa4\xac")) { // not special content
if (0 !== strpos($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], Mpdf::OBJECT_IDENTIFIER)) { // not special content
// Right trim last content and adjust OTLdata
if (preg_match('/[ ]+$/', $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], $m)) {
$strip = strlen($m[0]);

View File

@@ -2,6 +2,8 @@
namespace Mpdf\Tag;
use Mpdf\Mpdf;
class Bookmark extends Tag
{
@@ -16,7 +18,7 @@ class Bookmark extends Tag
} else {
$objattr['bklevel'] = 0;
}
$e = "\xbb\xa4\xactype=bookmark,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=bookmark,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
if ($this->mpdf->tableLevel) {
$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = [$e];
} // *TABLES*

View File

@@ -2,6 +2,8 @@
namespace Mpdf\Tag;
use Mpdf\Mpdf;
class DotTab extends Tag
{
@@ -45,7 +47,7 @@ class DotTab extends Tag
$objattr['fontfamily'] = $this->mpdf->FontFamily;
$objattr['fontsize'] = $this->mpdf->FontSizePt;
$e = "\xbb\xa4\xactype=dottab,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=dottab,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
/* -- TABLES -- */
// Output it to buffers
if ($this->mpdf->tableLevel) {

View File

@@ -2,6 +2,7 @@
namespace Mpdf\Tag;
use Mpdf\Mpdf;
use Mpdf\Utils\NumericString;
class Hr extends Tag
@@ -100,7 +101,7 @@ class Hr extends Tag
$objattr['type'] = 'hr';
$objattr['height'] = $objattr['linewidth'] + $objattr['margin_top'] + $objattr['margin_bottom'];
$e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=image,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
/* -- TABLES -- */
// Output it to buffers

View File

@@ -407,7 +407,7 @@ class Img extends Tag
$objattr['transform'] = $properties['TRANSFORM'];
}
$e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=image,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
/* -- TABLES -- */
// Output it to buffers
@@ -440,7 +440,7 @@ class Img extends Tag
$objattr['SUBJECT'] = '';
$objattr['OPACITY'] = $this->mpdf->annotOpacity;
$objattr['COLOR'] = $this->colorConverter->convert('yellow', $this->mpdf->PDFAXwarnings);
$e = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=annot,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
if ($this->mpdf->tableLevel) { // *TABLES*
$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = [$e]; // *TABLES*
} // *TABLES*

View File

@@ -2,6 +2,8 @@
namespace Mpdf\Tag;
use Mpdf\Mpdf;
class IndexEntry extends Tag
{
@@ -16,7 +18,7 @@ class IndexEntry extends Tag
$objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
$objattr['type'] = 'indexentry';
$objattr['vertical-align'] = 'T';
$e = "\xbb\xa4\xactype=indexentry,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=indexentry,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
if ($this->mpdf->tableLevel) {
$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = [$e];
} // *TABLES*

View File

@@ -2,6 +2,7 @@
namespace Mpdf\Tag;
use Mpdf\Mpdf;
use Mpdf\Utils\UtfString;
abstract class InlineTag extends Tag
@@ -34,7 +35,7 @@ abstract class InlineTag extends Tag
$objattr['SUBJECT'] = '';
$objattr['OPACITY'] = $this->mpdf->annotOpacity;
$objattr['COLOR'] = $this->colorConverter->convert('yellow', $this->mpdf->PDFAXwarnings);
$annot = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$annot = Mpdf::OBJECT_IDENTIFIER . "type=annot,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
}
/* -- END ANNOTATIONS -- */

View File

@@ -70,7 +70,7 @@ class Input extends Tag
if (isset($properties['FONT-FAMILY'])) {
$this->mpdf->SetFont($properties['FONT-FAMILY'], $this->mpdf->FontStyle, 0, false);
}
if (isset($properties['FONT-SIZE'])) {
if (isset($properties['FONT-SIZE']) && $properties['FONT-SIZE'] !== 'auto') {
$mmsize = $this->sizeConverter->convert($properties['FONT-SIZE'], $this->mpdf->default_font_size / Mpdf::SCALE);
$this->mpdf->SetFontSize($mmsize * Mpdf::SCALE, false);
}
@@ -356,6 +356,11 @@ class Input extends Tag
if (strtoupper($attr['TYPE']) === 'PASSWORD') {
$type = 'PASSWORD';
}
if ($properties['FONT-SIZE'] === 'auto' && $this->mpdf->useActiveForms) {
$objattr['use_auto_fontsize'] = true;
}
if (isset($attr['VALUE'])) {
if ($type === 'PASSWORD') {
$num_stars = mb_strlen($attr['VALUE'], $this->mpdf->mb_enc);
@@ -401,7 +406,7 @@ class Input extends Tag
$objattr['text'] = $texto;
$objattr['width'] = $width;
$objattr['height'] = $height;
$e = "\xbb\xa4\xactype=input,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=input,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
/* -- TABLES -- */
// Output it to buffers

View File

@@ -285,7 +285,7 @@ class Meter extends InlineTag
$objattr['width'] = $w + $extrawidth;
$objattr['image_height'] = $h;
$objattr['image_width'] = $w;
$e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=image,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
if ($this->mpdf->tableLevel) {
$this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];

View File

@@ -27,7 +27,8 @@ class Option extends Tag
$attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mpdf->mb_enc, 'UTF-8');
}
}
$this->mpdf->selectoption['currentVAL'] = $attr['VALUE'];
$this->mpdf->selectoption['currentVAL'] = isset($attr['VALUE']) ? $attr['VALUE'] : $ahtml[$ihtml + 1];
}
public function close(&$ahtml, &$ihtml)

View File

@@ -132,7 +132,7 @@ class Select extends Tag
$objattr['height'] = ($this->mpdf->FontSize * $rows) + ($this->form->form_element_spacing['select']['outer']['v'] * 2)
+ ($this->form->form_element_spacing['select']['inner']['v'] * 2);
$e = "\xbb\xa4\xactype=select,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=select,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
// Output it to buffers
if ($this->mpdf->tableLevel) { // *TABLES*

View File

@@ -712,7 +712,7 @@ class Table extends Tag
$objattr['row'] = $this->mpdf->row;
$objattr['col'] = $this->mpdf->col;
$objattr['level'] = $this->mpdf->tableLevel;
$e = "\xbb\xa4\xactype=nestedtable,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=nestedtable,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
$this->mpdf->_saveCellTextBuffer($e);
$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $tl;
if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {

View File

@@ -420,7 +420,7 @@ class Td extends Tag
}
}
if (isset($attr['ROWSPAN']) && $attr['ROWSPAN'] > 1) {
if (isset($attr['ROWSPAN']) && preg_match('/^\d+$/', $attr['ROWSPAN']) && $attr['ROWSPAN'] > 1) {
$rs = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['rowspan'] = $attr['ROWSPAN'];
}

View File

@@ -64,7 +64,7 @@ class TextArea extends Tag
if (isset($properties['FONT-FAMILY'])) {
$this->mpdf->SetFont($properties['FONT-FAMILY'], '', 0, false);
}
if (isset($properties['FONT-SIZE'])) {
if (isset($properties['FONT-SIZE']) && $properties['FONT-SIZE'] !== 'auto') {
$mmsize = $this->sizeConverter->convert($properties['FONT-SIZE'], $this->mpdf->default_font_size / Mpdf::SCALE);
$this->mpdf->SetFontSize($mmsize * Mpdf::SCALE, false);
}
@@ -143,6 +143,10 @@ class TextArea extends Tag
$objattr['rows'] = $rowsize;
$objattr['cols'] = $colsize;
if ($properties['FONT-SIZE'] === 'auto' && $this->mpdf->useActiveForms) {
$objattr['use_auto_fontsize'] = true;
}
$this->mpdf->specialcontent = serialize($objattr);
if ($this->mpdf->tableLevel) { // *TABLES*

View File

@@ -226,7 +226,7 @@ class TextCircle extends Tag
$objattr['width'] = $w + $extrawidth;
$objattr['type'] = 'textcircle';
$e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=image,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
/* -- TABLES -- */
// Output it to buffers

View File

@@ -2,6 +2,8 @@
namespace Mpdf\Tag;
use Mpdf\Mpdf;
class TocEntry extends Tag
{
@@ -22,7 +24,7 @@ class TocEntry extends Tag
} else {
$objattr['toc_id'] = 0;
}
$e = "\xbb\xa4\xactype=toc,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
$e = Mpdf::OBJECT_IDENTIFIER . "type=toc,objattr=" . serialize($objattr) . Mpdf::OBJECT_IDENTIFIER;
if ($this->mpdf->tableLevel) {
$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = [$e];
} // *TABLES*

View File

@@ -17,6 +17,17 @@ class Tr extends Tag
$this->mpdf->col = -1;
$properties = $this->cssManager->MergeCSS('TABLE', 'TR', $attr);
// write pagebreak markers into row list, so _tableWrite can respect it
if (isset($properties['PAGE-BREAK-BEFORE']) && strtoupper($properties['PAGE-BREAK-BEFORE']) === 'AVOID'
&& !$this->mpdf->ColActive && !$this->mpdf->keep_block_together && !isset($attr['PAGEBREAKAVOIDCHECKED'])) {
$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['pagebreak-before'][$this->mpdf->row] = 'avoid';
}
if (isset($properties['PAGE-BREAK-AFTER']) && strtoupper($properties['PAGE-BREAK-AFTER']) === 'AVOID'
&& !$this->mpdf->ColActive && !$this->mpdf->keep_block_together && !isset($attr['PAGEBREAKAVOIDCHECKED'])) {
$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['pagebreak-before'][$this->mpdf->row + 1] = 'avoid';
}
if (!$this->mpdf->simpleTables && (!isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['borders_separate'])
|| !$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['borders_separate'])) {
if (!empty($properties['BORDER-LEFT'])) {

View File

@@ -36,17 +36,19 @@ class UtfString
{
// Returns the utf string corresponding to the unicode value
if ($num < 128) {
if ($lo) {
return chr($num);
}
return '&#' . $num . ';';
return $lo
? chr($num)
: '&#' . $num . ';';
}
if ($num < 2048) {
return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
}
if ($num < 65536) {
return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
}
if ($num < 2097152) {
return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
}

8
vendor/mpdf/mpdf/src/Watermark.php vendored Normal file
View File

@@ -0,0 +1,8 @@
<?php
namespace Mpdf;
interface Watermark
{
}

72
vendor/mpdf/mpdf/src/WatermarkImage.php vendored Normal file
View File

@@ -0,0 +1,72 @@
<?php
namespace Mpdf;
class WatermarkImage implements \Mpdf\Watermark
{
const SIZE_DEFAULT = 'D';
const SIZE_FIT_PAGE = 'P';
const SIZE_FIT_FRAME = 'F';
const POSITION_CENTER_PAGE = 'P';
const POSITION_CENTER_FRAME = 'F';
/** @var string */
private $path;
/** @var mixed */
private $size;
/** @var mixed */
private $position;
/** @var float */
private $alpha;
/** @var bool */
private $behindContent;
/** @var string */
private $alphaBlend;
public function __construct($path, $size = self::SIZE_DEFAULT, $position = self::POSITION_CENTER_PAGE, $alpha = -1, $behindContent = false, $alphaBlend = 'Normal')
{
$this->path = $path;
$this->size = $size;
$this->position = $position;
$this->alpha = $alpha;
$this->behindContent = $behindContent;
$this->alphaBlend = $alphaBlend;
}
public function getPath()
{
return $this->path;
}
public function getSize()
{
return $this->size;
}
public function getPosition()
{
return $this->position;
}
public function getAlpha()
{
return $this->alpha;
}
public function isBehindContent()
{
return $this->behindContent;
}
public function getAlphaBlend()
{
return $this->alphaBlend;
}
}

66
vendor/mpdf/mpdf/src/WatermarkText.php vendored Normal file
View File

@@ -0,0 +1,66 @@
<?php
namespace Mpdf;
class WatermarkText implements \Mpdf\Watermark
{
/** @var string */
private $text;
/** @var int */
private $size;
/** @var int */
private $angle;
/** @var mixed */
private $color;
/** @var float */
private $alpha;
/** @var string */
private $font;
public function __construct($text, $size = 96, $angle = 45, $color = 0, $alpha = 0.2, $font = null)
{
$this->text = $text;
$this->size = $size;
$this->angle = $angle;
$this->color = $color;
$this->alpha = $alpha;
$this->font = $font;
}
public function getText()
{
return $this->text;
}
public function getSize()
{
return $this->size;
}
public function getAngle()
{
return $this->angle;
}
public function getColor()
{
return $this->color;
}
public function getAlpha()
{
return $this->alpha;
}
public function getFont()
{
return $this->font;
}
}

View File

@@ -6,6 +6,7 @@ use Mpdf\Strict;
use Mpdf\Form;
use Mpdf\Mpdf;
use Mpdf\Pdf\Protection;
use Mpdf\PsrLogAwareTrait\PsrLogAwareTrait;
use Mpdf\Utils\PdfDate;
use Psr\Log\LoggerInterface;
@@ -14,6 +15,7 @@ class MetadataWriter implements \Psr\Log\LoggerAwareInterface
{
use Strict;
use PsrLogAwareTrait;
/**
* @var \Mpdf\Mpdf
@@ -35,11 +37,6 @@ class MetadataWriter implements \Psr\Log\LoggerAwareInterface
*/
private $protection;
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
public function __construct(Mpdf $mpdf, BaseWriter $writer, Form $form, Protection $protection, LoggerInterface $logger)
{
$this->mpdf = $mpdf;
@@ -53,18 +50,19 @@ class MetadataWriter implements \Psr\Log\LoggerAwareInterface
{
$this->writer->object();
$this->mpdf->MetadataRoot = $this->mpdf->n;
$Producer = 'mPDF' . ($this->mpdf->exposeVersion ? (' ' . Mpdf::VERSION) : '');
$z = date('O'); // +0200
$offset = substr($z, 0, 3) . ':' . substr($z, 3, 2);
$CreationDate = date('Y-m-d\TH:i:s') . $offset; // 2006-03-10T10:47:26-05:00 2006-06-19T09:05:17Z
$uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0x0fff) | 0x4000, random_int(0, 0x3fff) | 0x8000, random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0xffff));
$CreationDate = date('Y-m-d\TH:i:s') . $offset; // 2006-03-10T10:47:26-05:00 2006-06-19T09:05:17Z
$uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0x0fff) | 0x4000, random_int(0, 0x3fff) | 0x8000, random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0xffff));
$m = '<?xpacket begin="' . chr(239) . chr(187) . chr(191) . '" id="W5M0MpCehiHzreSzNTczkc9d"?>' . "\n"; // begin = FEFF BOM
$m .= ' <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1-701">' . "\n";
$m .= ' <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' . "\n";
$m .= ' <rdf:Description rdf:about="uuid:' . $uuid . '" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">' . "\n";
$m .= ' <pdf:Producer>' . $Producer . '</pdf:Producer>' . "\n";
$m .= ' <pdf:Producer>' . $this->getProducerString() . '</pdf:Producer>' . "\n";
if (!empty($this->mpdf->keywords)) {
$m .= ' <pdf:Keywords>' . $this->mpdf->keywords . '</pdf:Keywords>' . "\n";
}
@@ -150,7 +148,7 @@ class MetadataWriter implements \Psr\Log\LoggerAwareInterface
public function writeInfo() // _putinfo
{
$this->writer->write('/Producer ' . $this->writer->utf16BigEndianTextString('mPDF' . ($this->mpdf->exposeVersion ? (' ' . $this->getVersionString()) : '')));
$this->writer->write('/Producer ' . $this->writer->utf16BigEndianTextString($this->getProducerString()));
if (!empty($this->mpdf->title)) {
$this->writer->write('/Title ' . $this->writer->utf16BigEndianTextString($this->mpdf->title));
@@ -808,11 +806,6 @@ class MetadataWriter implements \Psr\Log\LoggerAwareInterface
}
}
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
private function getVersionString()
{
$return = Mpdf::VERSION;
@@ -832,4 +825,9 @@ class MetadataWriter implements \Psr\Log\LoggerAwareInterface
return $return;
}
private function getProducerString()
{
return 'mPDF' . ($this->mpdf->exposeVersion ? (' ' . $this->getVersionString()) : '');
}
}

View File

@@ -4,12 +4,14 @@ namespace Mpdf\Writer;
use Mpdf\Strict;
use Mpdf\Mpdf;
use Mpdf\PsrLogAwareTrait\PsrLogAwareTrait;
use Psr\Log\LoggerInterface;
final class ResourceWriter implements \Psr\Log\LoggerAwareInterface
{
use Strict;
use PsrLogAwareTrait;
/**
* @var \Mpdf\Mpdf
@@ -66,11 +68,6 @@ final class ResourceWriter implements \Psr\Log\LoggerAwareInterface
*/
private $javaScriptWriter;
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
public function __construct(
Mpdf $mpdf,
BaseWriter $writer,
@@ -243,14 +240,4 @@ final class ResourceWriter implements \Psr\Log\LoggerAwareInterface
$this->writer->write('endobj');
}
}
/**
* @param \Psr\Log\LoggerInterface $logger
*
* @return void
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
}

25
vendor/mpdf/mpdf/src/functions.php vendored Normal file
View File

@@ -0,0 +1,25 @@
<?php
if (!function_exists('str_starts_with')) {
function str_starts_with($haystack, $needle)
{
return 0 === strncmp($haystack, $needle, \strlen($needle));
}
}
if (!function_exists('str_ends_with')) {
function str_ends_with($haystack, $needle)
{
if ('' === $needle || $needle === $haystack) {
return true;
}
if ('' === $haystack) {
return false;
}
$needleLength = \strlen($needle);
return $needleLength <= \strlen($haystack) && 0 === substr_compare($haystack, $needle, -$needleLength);
}
}

View File

@@ -0,0 +1,16 @@
# psr-http-message-shim
Trait to allow support of different psr/http-message versions.
Based on the psr-log-aware-trait, developed by Matěj Humpál, K Widholm and Mark Dorison.
By including this shim, you can allow composer to resolve your Psr\Http\Message version for you.
## Use
Require the shim.
composer require mpdf/psr-http-message-shim
Modify any use of mpdf's Request.php, Response.php, Stream.php and Uri.php classes to instead use versions
from the Mpdf\HttpMessageShim namespace.

View File

@@ -0,0 +1,28 @@
{
"name": "mpdf/psr-http-message-shim",
"description": "Shim to allow support of different psr/message versions.",
"type": "library",
"require": {
"psr/http-message": "^2.0"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Mpdf\\PsrHttpMessageShim\\": "src/"
}
},
"authors": [
{
"name": "Mark Dorison",
"email": "mark@chromatichq.com"
},
{
"name": "Kristofer Widholm",
"email": "kristofer@chromatichq.com"
},
{
"name": "Nigel Cunningham",
"email": "nigel.cunningham@technocrat.com.au"
}
]
}

View File

@@ -1,7 +1,9 @@
<?php
namespace Mpdf\Http;
namespace Mpdf\PsrHttpMessageShim;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UriInterface;
@@ -66,7 +68,7 @@ class Request implements \Psr\Http\Message\RequestInterface
}
}
public function getRequestTarget()
public function getRequestTarget(): string
{
if ($this->requestTarget !== null) {
return $this->requestTarget;
@@ -83,7 +85,7 @@ class Request implements \Psr\Http\Message\RequestInterface
return $target;
}
public function withRequestTarget($requestTarget)
public function withRequestTarget(string $requestTarget): RequestInterface
{
if (preg_match('#\s#', $requestTarget)) {
throw new \InvalidArgumentException('Invalid request target provided; cannot contain whitespace');
@@ -95,12 +97,12 @@ class Request implements \Psr\Http\Message\RequestInterface
return $new;
}
public function getMethod()
public function getMethod(): string
{
return $this->method;
}
public function withMethod($method)
public function withMethod(string $method): RequestInterface
{
$new = clone $this;
$new->method = $method;
@@ -108,12 +110,12 @@ class Request implements \Psr\Http\Message\RequestInterface
return $new;
}
public function getUri()
public function getUri(): UriInterface
{
return $this->uri;
}
public function withUri(UriInterface $uri, $preserveHost = false)
public function withUri(UriInterface $uri, bool $preserveHost = false): RequestInterface
{
if ($uri === $this->uri) {
return $this;
@@ -152,12 +154,12 @@ class Request implements \Psr\Http\Message\RequestInterface
$this->headers = [$header => [$host]] + $this->headers;
}
public function getProtocolVersion()
public function getProtocolVersion(): string
{
return $this->protocol;
}
public function withProtocolVersion($version)
public function withProtocolVersion(string $version): MessageInterface
{
if ($this->protocol === $version) {
return $this;
@@ -169,17 +171,17 @@ class Request implements \Psr\Http\Message\RequestInterface
return $new;
}
public function getHeaders()
public function getHeaders(): array
{
return $this->headers;
}
public function hasHeader($header)
public function hasHeader(string $header): bool
{
return isset($this->headerNames[strtolower($header)]);
}
public function getHeader($header)
public function getHeader(string $header): array
{
$header = strtolower($header);
@@ -192,12 +194,12 @@ class Request implements \Psr\Http\Message\RequestInterface
return $this->headers[$header];
}
public function getHeaderLine($header)
public function getHeaderLine(string $header):string
{
return implode(', ', $this->getHeader($header));
}
public function withHeader($header, $value)
public function withHeader(string $header, $value): MessageInterface
{
if (!is_array($value)) {
$value = [$value];
@@ -216,7 +218,7 @@ class Request implements \Psr\Http\Message\RequestInterface
return $new;
}
public function withAddedHeader($header, $value)
public function withAddedHeader(string $header, $value): MessageInterface
{
if (!is_array($value)) {
$value = [$value];
@@ -237,7 +239,7 @@ class Request implements \Psr\Http\Message\RequestInterface
return $new;
}
public function withoutHeader($header)
public function withoutHeader(string $header): MessageInterface
{
$normalized = strtolower($header);
@@ -253,7 +255,7 @@ class Request implements \Psr\Http\Message\RequestInterface
return $new;
}
public function getBody()
public function getBody(): StreamInterface
{
if (!$this->stream) {
$this->stream = Stream::create('');
@@ -263,7 +265,7 @@ class Request implements \Psr\Http\Message\RequestInterface
return $this->stream;
}
public function withBody(StreamInterface $body)
public function withBody(StreamInterface $body): MessageInterface
{
if ($body === $this->stream) {
return $this;

View File

@@ -1,8 +1,10 @@
<?php
namespace Mpdf\Http;
namespace Mpdf\PsrHttpMessageShim;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\MessageInterface;
/**
* PSR-7 URI implementation ported from nyholm/psr7 and adapted for PHP 5.6
@@ -64,17 +66,17 @@ class Response implements \Psr\Http\Message\ResponseInterface
$this->protocol = $version;
}
public function getStatusCode()
public function getStatusCode(): int
{
return $this->statusCode;
}
public function getReasonPhrase()
public function getReasonPhrase(): string
{
return $this->reasonPhrase;
}
public function withStatus($code, $reasonPhrase = '')
public function withStatus(int $code, string $reasonPhrase = ''): ResponseInterface
{
if (!\is_int($code) && !\is_string($code)) {
throw new \InvalidArgumentException('Status code has to be an integer');
@@ -95,12 +97,12 @@ class Response implements \Psr\Http\Message\ResponseInterface
return $new;
}
public function getProtocolVersion()
public function getProtocolVersion(): string
{
return $this->protocol;
}
public function withProtocolVersion($version)
public function withProtocolVersion(string $version): MessageInterface
{
if ($this->protocol === $version) {
return $this;
@@ -112,17 +114,17 @@ class Response implements \Psr\Http\Message\ResponseInterface
return $new;
}
public function getHeaders()
public function getHeaders(): array
{
return $this->headers;
}
public function hasHeader($header)
public function hasHeader(string $header): bool
{
return isset($this->headerNames[strtolower($header)]);
}
public function getHeader($header)
public function getHeader(string $header): array
{
$header = strtolower($header);
@@ -135,12 +137,12 @@ class Response implements \Psr\Http\Message\ResponseInterface
return $this->headers[$header];
}
public function getHeaderLine($header)
public function getHeaderLine(string $header): string
{
return implode(', ', $this->getHeader($header));
}
public function withHeader($header, $value)
public function withHeader(string $header, $value): MessageInterface
{
if (!is_array($value)) {
$value = [$value];
@@ -159,7 +161,7 @@ class Response implements \Psr\Http\Message\ResponseInterface
return $new;
}
public function withAddedHeader($header, $value)
public function withAddedHeader(string $header, $value): MessageInterface
{
if (!is_array($value)) {
$value = [$value];
@@ -180,7 +182,7 @@ class Response implements \Psr\Http\Message\ResponseInterface
return $new;
}
public function withoutHeader($header)
public function withoutHeader(string $header): MessageInterface
{
$normalized = strtolower($header);
@@ -196,7 +198,7 @@ class Response implements \Psr\Http\Message\ResponseInterface
return $new;
}
public function getBody()
public function getBody(): StreamInterface
{
if (!$this->stream) {
$this->stream = Stream::create('');
@@ -205,7 +207,7 @@ class Response implements \Psr\Http\Message\ResponseInterface
return $this->stream;
}
public function withBody(StreamInterface $body)
public function withBody(StreamInterface $body): MessageInterface
{
if ($body === $this->stream) {
return $this;

View File

@@ -1,6 +1,6 @@
<?php
namespace Mpdf\Http;
namespace Mpdf\PsrHttpMessageShim;
/**
* @link nyholm/psr7
@@ -104,7 +104,7 @@ class Stream implements \Psr\Http\Message\StreamInterface
$this->close();
}
public function __toString()
public function __toString(): string
{
try {
if ($this->isSeekable()) {
@@ -117,7 +117,7 @@ class Stream implements \Psr\Http\Message\StreamInterface
}
}
public function close()
public function close(): void
{
if (isset($this->stream)) {
if (is_resource($this->stream)) {
@@ -141,14 +141,14 @@ class Stream implements \Psr\Http\Message\StreamInterface
return $result;
}
public function getSize()
public function getSize(): ?int
{
if ($this->size !== null) {
return $this->size;
}
if (!isset($this->stream)) {
return;
return null;
}
// Clear the stat cache if the stream has a URI
@@ -162,9 +162,10 @@ class Stream implements \Psr\Http\Message\StreamInterface
return $this->size;
}
return null;
}
public function tell()
public function tell(): int
{
$result = ftell($this->stream);
@@ -175,17 +176,17 @@ class Stream implements \Psr\Http\Message\StreamInterface
return $result;
}
public function eof()
public function eof(): bool
{
return !$this->stream || feof($this->stream);
}
public function isSeekable()
public function isSeekable(): bool
{
return $this->seekable;
}
public function seek($offset, $whence = SEEK_SET)
public function seek(int $offset, int $whence = SEEK_SET): void
{
if (!$this->seekable) {
throw new \RuntimeException('Stream is not seekable');
@@ -196,17 +197,17 @@ class Stream implements \Psr\Http\Message\StreamInterface
}
}
public function rewind()
public function rewind(): void
{
$this->seek(0);
}
public function isWritable()
public function isWritable(): bool
{
return $this->writable;
}
public function write($string)
public function write(string $string): int
{
if (!$this->writable) {
throw new \RuntimeException('Cannot write to a non-writable stream');
@@ -223,12 +224,12 @@ class Stream implements \Psr\Http\Message\StreamInterface
return $result;
}
public function isReadable()
public function isReadable(): bool
{
return $this->readable;
}
public function read($length)
public function read(int $length): string
{
if (!$this->readable) {
throw new \RuntimeException('Cannot read from non-readable stream');
@@ -237,7 +238,7 @@ class Stream implements \Psr\Http\Message\StreamInterface
return fread($this->stream, $length);
}
public function getContents()
public function getContents(): string
{
if (!isset($this->stream)) {
throw new \RuntimeException('Unable to read stream contents');
@@ -252,7 +253,7 @@ class Stream implements \Psr\Http\Message\StreamInterface
return $contents;
}
public function getMetadata($key = null)
public function getMetadata(?string $key = null): bool
{
if (!isset($this->stream)) {
return $key ? null : [];

View File

@@ -1,13 +1,15 @@
<?php
namespace Mpdf\Http;
namespace Mpdf\PsrHttpMessageShim;
use Psr\Http\Message\UriInterface;
/**
* PSR-7 URI implementation ported from nyholm/psr7 and adapted for PHP 5.6
*
* @link https://github.com/Nyholm/psr7/blob/master/src/Uri.php
*/
final class Uri implements \Psr\Http\Message\UriInterface
final class Uri implements UriInterface
{
private static $schemes = ['http' => 80, 'https' => 443];
@@ -57,17 +59,17 @@ final class Uri implements \Psr\Http\Message\UriInterface
}
}
public function __toString()
public function __toString(): string
{
return self::createUriString($this->scheme, $this->getAuthority(), $this->path, $this->query, $this->fragment);
}
public function getScheme()
public function getScheme(): string
{
return $this->scheme;
}
public function getAuthority()
public function getAuthority(): string
{
if ('' === $this->host) {
return '';
@@ -85,37 +87,37 @@ final class Uri implements \Psr\Http\Message\UriInterface
return $authority;
}
public function getUserInfo()
public function getUserInfo(): string
{
return $this->userInfo;
}
public function getHost()
public function getHost(): string
{
return $this->host;
}
public function getPort()
public function getPort(): ?int
{
return $this->port;
}
public function getPath()
public function getPath(): string
{
return $this->path;
}
public function getQuery()
public function getQuery(): string
{
return $this->query;
}
public function getFragment()
public function getFragment(): string
{
return $this->fragment;
}
public function withScheme($scheme)
public function withScheme(string $scheme): UriInterface
{
if (!\is_string($scheme)) {
throw new \InvalidArgumentException('Scheme must be a string');
@@ -132,7 +134,7 @@ final class Uri implements \Psr\Http\Message\UriInterface
return $new;
}
public function withUserInfo($user, $password = null)
public function withUserInfo(string $user, ?string $password = null): UriInterface
{
$info = $user;
if (null !== $password && '' !== $password) {
@@ -149,7 +151,7 @@ final class Uri implements \Psr\Http\Message\UriInterface
return $new;
}
public function withHost($host)
public function withHost(string $host): UriInterface
{
if (!\is_string($host)) {
throw new \InvalidArgumentException('Host must be a string');
@@ -165,7 +167,7 @@ final class Uri implements \Psr\Http\Message\UriInterface
return $new;
}
public function withPort($port)
public function withPort(?int $port): UriInterface
{
if ($this->port === $port = $this->filterPort($port)) {
return $this;
@@ -177,7 +179,7 @@ final class Uri implements \Psr\Http\Message\UriInterface
return $new;
}
public function withPath($path)
public function withPath(string $path): UriInterface
{
if ($this->path === $path = $this->filterPath($path)) {
return $this;
@@ -189,7 +191,7 @@ final class Uri implements \Psr\Http\Message\UriInterface
return $new;
}
public function withQuery($query)
public function withQuery(string $query): UriInterface
{
if ($this->query === $query = $this->filterQueryAndFragment($query)) {
return $this;
@@ -201,7 +203,7 @@ final class Uri implements \Psr\Http\Message\UriInterface
return $new;
}
public function withFragment($fragment)
public function withFragment(string $fragment): UriInterface
{
if ($this->fragment === $fragment = $this->filterQueryAndFragment($fragment)) {
return $this;
@@ -216,7 +218,7 @@ final class Uri implements \Psr\Http\Message\UriInterface
/**
* Create a URI string from its various parts.
*/
private static function createUriString($scheme, $authority, $path, $query, $fragment)
private static function createUriString(string $scheme, string $authority, string $path, string $query, string $fragment): string
{
$uri = '';
if ('' !== $scheme) {
@@ -258,12 +260,12 @@ final class Uri implements \Psr\Http\Message\UriInterface
/**
* Is a given port non-standard for the current scheme?
*/
private static function isNonStandardPort($scheme, $port)
private static function isNonStandardPort(string $scheme, int $port): bool
{
return !isset(self::$schemes[$scheme]) || $port !== self::$schemes[$scheme];
}
private function filterPort($port)
private function filterPort(int $port): ?int
{
if (null === $port) {
return null;

View File

@@ -0,0 +1,2 @@
composer.lock
vendor/

View File

@@ -0,0 +1,20 @@
# psr-log-aware-trait
Trait to allow support of different psr/log versions.
By including this PsrLogAwareTrait, you can allow composer to resolve your PsrLogger version for you.
## Use
Require the trait.
composer require chromatic/psr-log-aware-trait
In your code, you no longer have to set a $logger property on your classes, since that comes with the trait, and you do not need to implement the `function setLogger()` method, since that also comes along with the trait.
```php
use PsrLogAwareTrait;
```
Will allow you to call `setLogger()` in your classes and fulfil the requirements of the PsrLoggerAwareInterface implementation.

View File

@@ -0,0 +1,24 @@
{
"name": "mpdf/psr-log-aware-trait",
"description": "Trait to allow support of different psr/log versions.",
"type": "library",
"require": {
"psr/log": "^1.0 || ^2.0"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Mpdf\\PsrLogAwareTrait\\": "src/"
}
},
"authors": [
{
"name": "Mark Dorison",
"email": "mark@chromatichq.com"
},
{
"name": "Kristofer Widholm",
"email": "kristofer@chromatichq.com"
}
]
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Mpdf\PsrLogAwareTrait;
use Psr\Log\LoggerInterface;
trait MpdfPsrLogAwareTrait
{
/**
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
if (property_exists($this, 'services') && is_array($this->services)) {
foreach ($this->services as $name) {
if ($this->$name && $this->$name instanceof \Psr\Log\LoggerAwareInterface) {
$this->$name->setLogger($logger);
}
}
}
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Mpdf\PsrLogAwareTrait;
use Psr\Log\LoggerInterface;
trait PsrLogAwareTrait
{
/**
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
}