Mise à jour des dépendences

This commit is contained in:
Noizette 2020-10-24 00:24:16 +02:00
parent bfecdbfe98
commit 4b3fa030d8
180 changed files with 2026 additions and 737 deletions

View file

@ -96,6 +96,9 @@ class Barcode
case 'C128C': // CODE 128 C
return new Barcode\Code128($code, 'C');
case 'C128RAW': // CODE 128 RAW -- code is a space separated list of codes with startcode but without checkdigit,stop,end ex: "105 12 34"
return new Barcode\Code128($code, 'RAW');
case 'EAN128A': // EAN 128 A
return new Barcode\Code128($code, 'A', true);

View file

@ -148,6 +148,36 @@ class Code128 extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\Bar
];
switch (strtoupper($type)) {
case 'RAW':
$newCode='';
$startid = false;
foreach (explode(" ", $code) as $v) {
if (is_numeric($v) && round($v, 0) == $v) {
if ($v>=0 && $v<=105) {
if ($startid===false) {
$startid=$v;
} else {
$newCode.=chr($v);
}
} else {
throw new \Mpdf\Barcode\BarcodeException('Invalid CODE128RAW barcode value. 0-105 needed');
}
} else {
//double spaces generates empty $v any other is not allowed
if ($v!='') {
throw new \Mpdf\Barcode\BarcodeException('Invalid CODE128RAW barcode value. 0-105 needed');
}
}
}
if ($startid<103 || $startid>105) {
throw new \Mpdf\Barcode\BarcodeException('Invalid CODE128RAW startid value. Must 103,104 or 105 (for A,B or C)');
}
$keys='';
for ($i = 0; $i <= 105; ++$i) {
$keys .= chr($i);
}
$code=$newCode;
break;
case 'A':
$startid = 103;
$keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_';
@ -172,6 +202,9 @@ class Code128 extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\Bar
$newCode = '';
$hclen = (strlen($code) / 2);
for ($i = 0; $i < $hclen; ++$i) {
if ($code[2 * $i]<"0" || $code[2 * $i]>"9" || $code[2 * $i + 1]<"0" || $code[2 * $i + 1]>"9") {
throw new \Mpdf\Barcode\BarcodeException(sprintf('Invalid character "%s" in CODE128C barcode value', $code[$i]));
}
$newCode .= chr((int) ($code[2 * $i] . $code[2 * $i + 1]));
}
$code = $newCode;
@ -192,6 +225,9 @@ class Code128 extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\Bar
if ($ean && $i == 0) {
$sum += 102;
} else {
if (strpos($keys, $code[$i]) === false) {
throw new \Mpdf\Barcode\BarcodeException(sprintf('Invalid character "%s" in CODE128'.$type.' barcode value', $code[$i]));
}
$sum += (strpos($keys, $code[$i]) * ($i + 1));
}
}

View file

@ -70,9 +70,11 @@ class Cache
public function write($filename, $data)
{
$path = $this->getFilePath($filename);
$tempFile = tempnam($this->basePath, 'cache_tmp_');
file_put_contents($tempFile, $data);
file_put_contents($path, $data);
$path = $this->getFilePath($filename);
rename($tempFile, $path);
return $path;
}

View file

@ -514,6 +514,9 @@ class ConfigVariables
'curlTimeout' => 5,
'curlProxy' => null,
'curlProxyAuth' => null,
'curlUserAgent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0.1',
'exposeVersion' => true,
];
}

View file

@ -60,6 +60,7 @@ class DecToOther
'khmer' => 0x17E0,
'cambodian' => 0x17E0,
'lao' => 0x0ED0,
'myanmar' => 0x1040
];
return isset($codePages[$script]) ? $codePages[$script] : 0;

View file

@ -1117,37 +1117,57 @@ class CssManager
{
$sh = [];
$c = preg_match_all('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl)\(.*?\)/', $v, $x); // mPDF 5.6.05
for ($i = 0; $i < $c; $i++) {
$col = preg_replace('/,/', '*', $x[0][$i]);
$col = preg_replace('/,\s/', '*', $x[0][$i]);
$v = str_replace($x[0][$i], $col, $v);
}
$ss = explode(',', $v);
foreach ($ss as $s) {
$new = ['blur' => 0];
$p = explode(' ', trim($s));
if (isset($p[0])) {
$new['x'] = $this->sizeConverter->convert(trim($p[0]), $this->mpdf->FontSize, $this->mpdf->FontSize, false);
}
if (isset($p[1])) {
$new['y'] = $this->sizeConverter->convert(trim($p[1]), $this->mpdf->FontSize, $this->mpdf->FontSize, false);
}
if (isset($p[2])) {
if (preg_match('/^\s*[\.\-0-9]/', $p[2])) {
$new['blur'] = $this->sizeConverter->convert(trim($p[2]), $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
$new['blur'] = $this->sizeConverter->convert(
trim($p[2]),
isset($this->mpdf->blk[$this->mpdf->blklvl]['inner_width']) ? $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'] : 0,
$this->mpdf->FontSize,
false
);
} else {
$new['col'] = $this->colorConverter->convert(preg_replace('/\*/', ',', $p[2]), $this->mpdf->PDFAXwarnings);
}
if (isset($p[3])) {
$new['col'] = $this->colorConverter->convert(preg_replace('/\*/', ',', $p[3]), $this->mpdf->PDFAXwarnings);
}
}
if (!isset($new['col']) || !$new['col']) {
$new['col'] = $this->colorConverter->convert('#888888', $this->mpdf->PDFAXwarnings);
}
if (isset($new['y'])) {
array_unshift($sh, $new);
}
}
return $sh;
}

View file

@ -0,0 +1,8 @@
<?php
namespace Mpdf\Exception;
class FontException extends \Mpdf\MpdfException
{
}

View file

@ -53,9 +53,7 @@ class FontCache
public function binaryWrite($filename, $data)
{
$handle = fopen($this->tempFilename($filename), 'wb');
fwrite($handle, $data);
fclose($handle);
return $this->cache->write($filename, $data);
}
public function jsonWrite($filename, $data)

View file

@ -2824,6 +2824,91 @@ class Svg
$this->svg_string .= $content;
}
/**
* SVGs made with Adobe Illustrator use a style tag and classes instead of inline styles
* See: https://github.com/mpdf/mpdf/issues/450
*
* This function brutally copies the styles inline
* ( Currently only looks for classes as a selector )
*
* @param string $data svg contents
* @return string svg contents
* @author Antonio Norman - softcodex.ch
*/
function mergeStyles($data)
{
$xml = new \DOMDocument();
if (!$xml->loadXML($data, LIBXML_NOERROR)) {
return $data;
}
// Check it's an SVG
$svgNode = $xml->getElementsByTagName('svg');
if ($svgNode->length === 0) {
return $data;
}
// Find the style node
$styles = [];
/** @var $styleNode \DOMNode */
foreach ($svgNode->item(0)->getElementsByTagName('style') as $styleNode) {
preg_match_all('/(\.[^{]+)\s*\{\s*([^}]+)\s*}/m', $styleNode->nodeValue, $matches, PREG_SET_ORDER);
foreach ($matches as $cssBlock) {
$css = preg_replace('/\s{2,}/', ' ', $cssBlock[2]); // Clean spaces or new lines
$selector = trim($cssBlock[1]);
$styles[$selector] = isset($styles[$cssBlock[1]]) ?
$styles[$selector] . ' ' . $css : // Append if the selector is already defined
$css;
}
}
if (empty($styles)) {
return $data;
}
// Recursively loop the nodes inserting the styles inline
$setStylesInline = function (\DOMNode $xml) use ($styles, &$setStylesInline) {
// Apply the styles to the elements
foreach ($xml->childNodes as $node) {
if ($node->hasChildNodes()) {
$setStylesInline($node);
}
if (!$node instanceof \DOMElement) {
continue;
}
// Check the node has the a class with a style
if (!$node->hasAttribute('class')) {
continue;
}
// Allow for class=" class1 class2 "
$classes = explode(' ', $node->getAttribute('class'));
foreach ($classes as $class) {
$class = '.' . trim($class);
if (!empty($class) && isset($styles[$class])) {
$style = $node->hasAttribute('style') ?
$styles[$class] . ' ' . $node->getAttribute('style') :
$styles[$class];
$node->setAttribute('style', $style);
}
}
}
};
$setStylesInline($xml);
return $xml->saveXML();
}
/**
* analise le svg et renvoie aux fonctions precedente our le traitement
*/
@ -2835,6 +2920,8 @@ class Svg
// Converts < to &lt; when not a tag
$data = preg_replace('/<([^!?\/a-zA-Z_:])/i', '&lt;\\1', $data); // mPDF 5.7.4
$data = $this->mergeStyles($data);
if ($this->mpdf->svgAutoFont) {
$data = $this->markScriptToLang($data);
}

View file

@ -39,7 +39,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
use Strict;
use FpdiTrait;
const VERSION = '8.0.3';
const VERSION = '8.0.7';
const SCALE = 72 / 25.4;
@ -719,6 +719,15 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
*/
var $curlProxyAuth;
/**
* Set the User-Agent header in the HTTP requests sent by cURL.
*
* @see https://curl.haxx.se/libcurl/c/CURLOPT_USERAGENT.html
*
* @var string User Agent header
*/
var $curlUserAgent;
// Private properties FROM FPDF
var $DisplayPreferences;
var $flowingBlockAttr;
@ -815,6 +824,8 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
var $outerblocktags;
var $innerblocktags;
public $exposeVersion;
/**
* @var string
*/
@ -1070,8 +1081,8 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->tableBackgrounds = [];
$this->uniqstr = '20110230'; // mPDF 5.7.2
$this->kt_y00 = '';
$this->kt_p00 = '';
$this->kt_y00 = 0;
$this->kt_p00 = 0;
$this->BMPonly = [];
$this->page = 0;
$this->n = 2;
@ -5788,28 +5799,49 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
return $s;
}
function MultiCell($w, $h, $txt, $border = 0, $align = '', $fill = 0, $link = '', $directionality = 'ltr', $encoded = false, $OTLdata = false, $maxrows = false)
{
function MultiCell(
$w,
$h,
$txt,
$border = 0,
$align = '',
$fill = 0,
$link = '',
$directionality = 'ltr',
$encoded = false,
$OTLdata = false,
$maxrows = false
) {
// maxrows is called from mpdfform->TEXTAREA
// Parameter (pre-)encoded - When called internally from form::textarea - mb_encoding already done and OTL - but not reverse RTL
// Parameter (pre-)encoded - When called internally from form::textarea -
// mb_encoding already done and OTL - but not reverse RTL
if (!$encoded) {
$txt = $this->purify_utf8_text($txt);
if ($this->text_input_as_HTML) {
$txt = $this->all_entities_to_utf8($txt);
}
if ($this->usingCoreFont) {
$txt = mb_convert_encoding($txt, $this->mb_enc, 'UTF-8');
}
if (preg_match("/([" . $this->pregRTLchars . "])/u", $txt)) {
$this->biDirectional = true;
} // *OTL*
}
/* -- OTL -- */
$OTLdata = [];
if (!is_array($OTLdata)) {
unset($OTLdata);
}
// Use OTL OpenType Table Layout - GSUB & GPOS
if (isset($this->CurrentFont['useOTL']) && $this->CurrentFont['useOTL']) {
$txt = $this->otl->applyOTL($txt, $this->CurrentFont['useOTL']);
$OTLdata = $this->otl->OTLdata;
}
if ($directionality == 'rtl' || $this->biDirectional) {
if (!isset($OTLdata)) {
$unicode = $this->UTF8StringToArray($txt, false);
@ -5819,17 +5851,20 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
}
/* -- END OTL -- */
}
if (!$align) {
$align = $this->defaultAlign;
}
// Output text with automatic or explicit line breaks
$cw = &$this->CurrentFont['cw'];
if ($w == 0) {
$w = $this->w - $this->rMargin - $this->x;
}
$wmax = ($w - ($this->cMarginL + $this->cMarginR));
if ($this->usingCoreFont) {
$s = str_replace("\r", '', $txt);
$nb = strlen($s);
@ -5843,8 +5878,11 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$nb--;
}
}
$b = 0;
if ($border) {
if ($border == 1) {
$border = 'LTRB';
$b = 'LRT';
@ -5860,6 +5898,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$b = is_int(strpos($border, 'T')) ? $b2 . 'T' : $b2;
}
}
$sep = -1;
$i = 0;
$j = 0;
@ -5871,19 +5910,25 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$start_y = $this->y;
if (!$this->usingCoreFont) {
$inclCursive = false;
if (preg_match("/([" . $this->pregCURSchars . "])/u", $s)) {
$inclCursive = true;
}
while ($i < $nb) {
// Get next character
$c = mb_substr($s, $i, 1, $this->mb_enc);
if ($c == "\n") {
// Explicit line break
if ($c === "\n") { // Explicit line break
// WORD SPACING
$this->ResetSpacing();
$tmp = rtrim(mb_substr($s, $j, $i - $j, $this->mb_enc));
$tmpOTLdata = false;
/* -- OTL -- */
if (isset($OTLdata)) {
$tmpOTLdata = $this->otl->sliceOTLdata($OTLdata, $j, $i - $j);
@ -5891,21 +5936,27 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->magic_reverse_dir($tmp, $directionality, $tmpOTLdata);
}
/* -- END OTL -- */
$this->Cell($w, $h, $tmp, $b, 2, $align, $fill, $link, 0, 0, 0, 'M', 0, false, $tmpOTLdata);
if ($maxrows != false && isset($this->form) && ($this->y - $start_y) / $h > $maxrows) {
return false;
}
$i++;
$sep = -1;
$j = $i;
$l = 0;
$ns = 0;
$nl++;
if ($border and $nl == 2) {
$b = $b2;
}
continue;
}
if ($c == " ") {
$sep = $i;
$ls = $l;
@ -5915,15 +5966,19 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$l += $this->GetCharWidthNonCore($c);
if ($l > $wmax) {
// Automatic line break
if ($sep == -1) { // Only one word
if ($i == $j) {
$i++;
}
// WORD SPACING
$this->ResetSpacing();
$tmp = rtrim(mb_substr($s, $j, $i - $j, $this->mb_enc));
$tmpOTLdata = false;
/* -- OTL -- */
if (isset($OTLdata)) {
$tmpOTLdata = $this->otl->sliceOTLdata($OTLdata, $j, $i - $j);
@ -5931,27 +5986,35 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->magic_reverse_dir($tmp, $directionality, $tmpOTLdata);
}
/* -- END OTL -- */
$this->Cell($w, $h, $tmp, $b, 2, $align, $fill, $link, 0, 0, 0, 'M', 0, false, $tmpOTLdata);
} else {
$tmp = rtrim(mb_substr($s, $j, $sep - $j, $this->mb_enc));
$tmpOTLdata = false;
/* -- OTL -- */
if (isset($OTLdata)) {
$tmpOTLdata = $this->otl->sliceOTLdata($OTLdata, $j, $sep - $j);
$this->otl->trimOTLdata($tmpOTLdata, false, true);
}
/* -- END OTL -- */
if ($align == 'J') {
//////////////////////////////////////////
if ($align === 'J') {
// JUSTIFY J using Unicode fonts (Word spacing doesn't work)
// WORD SPACING UNICODE
// Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
$tmp = str_replace(chr(194) . chr(160), chr(32), $tmp);
$len_ligne = $this->GetStringWidth($tmp, false, $tmpOTLdata);
$nb_carac = mb_strlen($tmp, $this->mb_enc);
$nb_spaces = mb_substr_count($tmp, ' ', $this->mb_enc);
// Take off number of Marks
// Use GPOS OTL
if (isset($this->CurrentFont['useOTL']) && ($this->CurrentFont['useOTL'])) {
if (isset($tmpOTLdata['group']) && $tmpOTLdata['group']) {
$nb_carac -= substr_count($tmpOTLdata['group'], 'M');
@ -5960,118 +6023,153 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
list($charspacing, $ws, $kashida) = $this->GetJspacing($nb_carac, $nb_spaces, ((($wmax) - $len_ligne) * Mpdf::SCALE), $inclCursive, $tmpOTLdata);
$this->SetSpacing($charspacing, $ws);
//////////////////////////////////////////
}
if (isset($OTLdata)) {
$this->magic_reverse_dir($tmp, $directionality, $tmpOTLdata);
}
$this->Cell($w, $h, $tmp, $b, 2, $align, $fill, $link, 0, 0, 0, 'M', 0, false, $tmpOTLdata);
$i = $sep + 1;
}
if ($maxrows != false && isset($this->form) && ($this->y - $start_y) / $h > $maxrows) {
return false;
}
$sep = -1;
$j = $i;
$l = 0;
$ns = 0;
$nl++;
if ($border and $nl == 2) {
$b = $b2;
}
} else {
$i++;
}
}
// Last chunk
// WORD SPACING
$this->ResetSpacing();
} else {
while ($i < $nb) {
// Get next character
$c = $s[$i];
if ($c == "\n") {
if ($c === "\n") {
// Explicit line break
// WORD SPACING
$this->ResetSpacing();
$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill, $link);
if ($maxrows != false && isset($this->form) && ($this->y - $start_y) / $h > $maxrows) {
return false;
}
$i++;
$sep = -1;
$j = $i;
$l = 0;
$ns = 0;
$nl++;
if ($border and $nl == 2) {
$b = $b2;
}
continue;
}
if ($c == " ") {
if ($c === ' ') {
$sep = $i;
$ls = $l;
$ns++;
}
$l += $this->GetCharWidthCore($c);
if ($l > $wmax) {
// Automatic line break
if ($sep == -1) {
if ($i == $j) {
$i++;
}
// WORD SPACING
$this->ResetSpacing();
$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill, $link);
} else {
if ($align == 'J') {
if ($align === 'J') {
$tmp = rtrim(substr($s, $j, $sep - $j));
//////////////////////////////////////////
// JUSTIFY J using Unicode fonts (Word spacing doesn't work)
// WORD SPACING NON_UNICODE/CJK
// Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
$tmp = str_replace(chr(160), chr(32), $tmp);
$len_ligne = $this->GetStringWidth($tmp);
$nb_carac = strlen($tmp);
$nb_spaces = substr_count($tmp, ' ');
$tmpOTLdata = [];
list($charspacing, $ws, $kashida) = $this->GetJspacing($nb_carac, $nb_spaces, ((($wmax) - $len_ligne) * Mpdf::SCALE), false, $tmpOTLdata);
$this->SetSpacing($charspacing, $ws);
//////////////////////////////////////////
}
$this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill, $link);
$i = $sep + 1;
}
if ($maxrows != false && isset($this->form) && ($this->y - $start_y) / $h > $maxrows) {
return false;
}
$sep = -1;
$j = $i;
$l = 0;
$ns = 0;
$nl++;
if ($border and $nl == 2) {
$b = $b2;
}
} else {
$i++;
}
}
// Last chunk
// WORD SPACING
$this->ResetSpacing();
}
// Last chunk
if ($border and is_int(strpos($border, 'B'))) {
$b .= 'B';
}
if (!$this->usingCoreFont) {
$tmp = rtrim(mb_substr($s, $j, $i - $j, $this->mb_enc));
$tmpOTLdata = false;
/* -- OTL -- */
if (isset($OTLdata)) {
$tmpOTLdata = $this->otl->sliceOTLdata($OTLdata, $j, $i - $j);
@ -6079,10 +6177,12 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->magic_reverse_dir($tmp, $directionality, $tmpOTLdata);
}
/* -- END OTL -- */
$this->Cell($w, $h, $tmp, $b, 2, $align, $fill, $link, 0, 0, 0, 'M', 0, false, $tmpOTLdata);
} else {
$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill, $link);
}
$this->x = $this->lMargin;
}
@ -7303,8 +7403,8 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
} elseif ($objattr['btype'] === 'QR') {
if (!class_exists('Mpdf\QrCode\QrCode')) {
throw new \Mpdf\MpdfException('Class Mpdf\QrCode\QrCode does not exists. Install the package from Packagist with "composer require mpdf/qrcode"');
if (!class_exists('Mpdf\QrCode\QrCode') || !class_exists('Mpdf\QrCode\Output\Mpdf')) {
throw new \Mpdf\MpdfException('Mpdf\QrCode package was not found. Install the package from Packagist with "composer require mpdf/qrcode"');
}
$barcodeContent = str_replace('\r\n', "\r\n", $objattr['code']);
@ -9428,7 +9528,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
header('Content-disposition: inline; filename="' . $name . '"');
header('Cache-Control: public, must-revalidate, max-age=0');
header('Pragma: public');
header('X-Generator: mPDF ' . static::VERSION);
header('X-Generator: mPDF' . ($this->exposeVersion ? (' ' . static::VERSION) : ''));
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
}
@ -9447,7 +9547,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
header('Content-Transfer-Encoding: binary');
header('Cache-Control: public, must-revalidate, max-age=0');
header('Pragma: public');
header('X-Generator: mPDF ' . static::VERSION);
header('X-Generator: mPDF' . ($this->exposeVersion ? (' ' . static::VERSION) : ''));
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Type: application/pdf');
@ -11325,7 +11425,10 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
return;
}
if (preg_match('@^(mailto|tel|fax):.*@i', $path)) {
// Skip schemes not supported by installed stream wrappers
$wrappers = stream_get_wrappers();
$pattern = sprintf('@^(?!%s)[a-z0-9\.\-+]+:.*@i', implode('|', $wrappers));
if (preg_match($pattern, $path)) {
return;
}
@ -11512,7 +11615,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$ppgno = $decToHebrew->convert($ppgno, $reverse);
} elseif (preg_match('/(arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao)/i', $lowertype, $m)) {
} elseif (preg_match('/(arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao|myanmar)/i', $lowertype, $m)) {
$cp = $decToOther->getCodePage($m[1]);
$ppgno = $decToOther->convert($ppgno, $cp, $checkfont);
@ -12374,7 +12477,9 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$lContent = (isset($arr['L']['content']) ? $arr['L']['content'] : '');
$cContent = (isset($arr['C']['content']) ? $arr['C']['content'] : '');
$rContent = (isset($arr['R']['content']) ? $arr['R']['content'] : '');
list($lw, $cw, $rw) = $this->_shareHeaderFooterWidth($lContent, $cContent, $rContent);
if ($hf == 'H') {
$valign = 'bottom';
$vpadding = '0 0 ' . $this->header_line_spacing . 'em 0';
@ -12382,6 +12487,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$valign = 'top';
$vpadding = '' . $this->footer_line_spacing . 'em 0 0 0';
}
if ($this->directionality == 'rtl') { // table columns get reversed so need different text-alignment
$talignL = 'right';
$talignR = 'left';
@ -12389,22 +12495,29 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$talignL = 'left';
$talignR = 'right';
}
$html = '<table width="100%" style="border-collapse: collapse; margin: 0; vertical-align: ' . $valign . '; color: #000000; ';
if (isset($arr['line']) && $arr['line']) {
$html .= ' border-' . $valign . ': 0.1mm solid #000000;';
}
$html .= '">';
$html .= '<tr>';
$html .= '<td width="' . $lw . '%" style="padding: ' . $vpadding . '; text-align: ' . $talignL . '; ';
if (isset($arr['L']['font-family'])) {
$html .= ' font-family: ' . $arr['L']['font-family'] . ';';
}
if (isset($arr['L']['color'])) {
$html .= ' color: ' . $arr['L']['color'] . ';';
}
if (isset($arr['L']['font-size'])) {
$html .= ' font-size: ' . $arr['L']['font-size'] . 'pt;';
}
if (isset($arr['L']['font-style'])) {
if ($arr['L']['font-style'] == 'B' || $arr['L']['font-style'] == 'BI') {
$html .= ' font-weight: bold;';
@ -12413,17 +12526,22 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$html .= ' font-style: italic;';
}
}
$html .= '">' . $lContent . '</td>';
$html .= '<td width="' . $cw . '%" style="padding: ' . $vpadding . '; text-align: center; ';
if (isset($arr['C']['font-family'])) {
$html .= ' font-family: ' . $arr['C']['font-family'] . ';';
}
if (isset($arr['C']['color'])) {
$html .= ' color: ' . $arr['C']['color'] . ';';
}
if (isset($arr['C']['font-size'])) {
$html .= ' font-size: ' . $arr['L']['font-size'] . 'pt;';
$html .= ' font-size: ' . $arr['C']['font-size'] . 'pt;';
}
if (isset($arr['C']['font-style'])) {
if ($arr['C']['font-style'] == 'B' || $arr['C']['font-style'] == 'BI') {
$html .= ' font-weight: bold;';
@ -12432,17 +12550,22 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$html .= ' font-style: italic;';
}
}
$html .= '">' . $cContent . '</td>';
$html .= '<td width="' . $rw . '%" style="padding: ' . $vpadding . '; text-align: ' . $talignR . '; ';
if (isset($arr['R']['font-family'])) {
$html .= ' font-family: ' . $arr['R']['font-family'] . ';';
}
if (isset($arr['R']['color'])) {
$html .= ' color: ' . $arr['R']['color'] . ';';
}
if (isset($arr['R']['font-size'])) {
$html .= ' font-size: ' . $arr['R']['font-size'] . 'pt;';
}
if (isset($arr['R']['font-style'])) {
if ($arr['R']['font-style'] == 'B' || $arr['R']['font-style'] == 'BI') {
$html .= ' font-weight: bold;';
@ -12451,8 +12574,10 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$html .= ' font-style: italic;';
}
}
$html .= '">' . $rContent . '</td>';
$html .= '</tr></table>';
return $html;
}
@ -12885,7 +13010,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$this->SetFont('arial', '', 7.5, true, true);
$this->x = $this->page_box['outer_width_LR'] + 1.5;
$this->y = 1;
$this->Cell($headerpgwidth, $this->FontSize, $hd, 0, 0, 'L', 0, '', 0, 0, 0, 'M');
$this->Cell(0, $this->FontSize, $hd, 0, 0, 'L', 0, '', 0, 0, 0, 'M');
$this->SetFont($this->default_font, '', $this->original_default_font_size);
}
}
@ -14663,7 +14788,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$prop[1] = $tmp;
}
} else {
return [];
return ['w' => 0, 's' => 0];
}
// Size
$bsize = $this->sizeConverter->convert($prop[0], $refw, $this->FontSize, false);
@ -17942,7 +18067,8 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
// Set font size first so that e.g. MARGIN 0.83em works on font size for this element
if (isset($arrayaux['FONT-SIZE'])) {
$v = $arrayaux['FONT-SIZE'];
if (is_numeric($v[0]) || ($v[0] === '.')) {
$firstLetter = substr($v, 0, 1);
if (is_numeric($firstLetter) || ($firstLetter === '.')) {
if ($type == 'BLOCK' && $this->blklvl > 0 && isset($this->blk[$this->blklvl - 1]['InlineProperties']) && isset($this->blk[$this->blklvl - 1]['InlineProperties']['size'])) {
$mmsize = $this->sizeConverter->convert($v, $this->blk[$this->blklvl - 1]['InlineProperties']['size']);
} elseif ($type == 'TABLECELL') {
@ -26316,7 +26442,7 @@ class Mpdf implements \Psr\Log\LoggerAwareInterface
$rlm = $arrcode['quietR'] / $k; // Right Quiet margin
$tlm = $blm = $arrcode['quietTB'] / $k;
$height = 1; // Overrides
} elseif (in_array($btype, ['C128A', 'C128B', 'C128C', 'EAN128A', 'EAN128B', 'EAN128C', 'C39', 'C39+', 'C39E', 'C39E+', 'S25', 'S25+', 'I25', 'I25+', 'I25B', 'I25B+', 'C93', 'MSI', 'MSI+', 'CODABAR', 'CODE11'])) {
} elseif (in_array($btype, ['C128A', 'C128B', 'C128C', 'C128RAW', 'EAN128A', 'EAN128B', 'EAN128C', 'C39', 'C39+', 'C39E', 'C39E+', 'S25', 'S25+', 'I25', 'I25+', 'I25B', 'I25B+', 'C93', 'MSI', 'MSI+', 'CODABAR', 'CODE11'])) {
$llm = $arrcode['lightmL'] * $xres; // Left Quiet margin
$rlm = $arrcode['lightmR'] * $xres; // Right Quiet margin
$tlm = $blm = $arrcode['lightTB'] * $xres * $height;

View file

@ -178,7 +178,7 @@ class OtlDump
$this->fh = fopen($file, 'rb');
if (!$this->fh) {
throw new \Mpdf\MpdfException(sprintf('Unable to open file "%s"', $file));
throw new \Mpdf\Exception\FontException(sprintf('Unable to open file "%s"', $file));
}
$this->_pos = 0;
@ -196,21 +196,21 @@ class OtlDump
$this->panose = [];
if ($version == 0x4F54544F) {
throw new \Mpdf\MpdfException("Postscript outlines are not supported");
throw new \Mpdf\Exception\FontException("Postscript outlines are not supported");
}
if ($version == 0x74746366 && !$TTCfontID) {
throw new \Mpdf\MpdfException("TTCfontID for a TrueType Collection has to be defined in ttfontdata configuration key (" . $file . ")");
throw new \Mpdf\Exception\FontException("TTCfontID for a TrueType Collection has to be defined in ttfontdata configuration key (" . $file . ")");
}
if (!in_array($version, [0x00010000, 0x74727565]) && !$TTCfontID) {
throw new \Mpdf\MpdfException("Not a TrueType font: version=" . $version);
throw new \Mpdf\Exception\FontException("Not a TrueType font: version=" . $version);
}
if ($TTCfontID > 0) {
$this->version = $version = $this->read_ulong(); // TTC Header version now
if (!in_array($version, [0x00010000, 0x00020000])) {
throw new \Mpdf\MpdfException("Error parsing TrueType Collection: version=" . $version . " - " . $file);
throw new \Mpdf\Exception\FontException("Error parsing TrueType Collection: version=" . $version . " - " . $file);
}
$this->numTTCFonts = $this->read_ulong();
for ($i = 1; $i <= $this->numTTCFonts; $i++) {
@ -259,7 +259,7 @@ class OtlDump
}
$xchecksum = $t['checksum'];
if ($xchecksum != $checksum) {
throw new \Mpdf\MpdfException(sprintf('TTF file "%s": invalid checksum %s table: %s (expected %s)', $this->filename, dechex($checksum[0]) . dechex($checksum[1]), $t['tag'], dechex($xchecksum[0]) . dechex($xchecksum[1])));
throw new \Mpdf\Exception\FontException(sprintf('TTF file "%s": invalid checksum %s table: %s (expected %s)', $this->filename, dechex($checksum[0]) . dechex($checksum[1]), $t['tag'], dechex($xchecksum[0]) . dechex($xchecksum[1])));
}
}
}
@ -473,7 +473,7 @@ class OtlDump
$name_offset = $this->seek_table("name");
$format = $this->read_ushort();
if ($format != 0 && $format != 1) {
throw new \Mpdf\MpdfException("Unknown name table format " . $format);
throw new \Mpdf\Exception\FontException("Error loading font: Unknown name table format " . $format);
}
$numRecords = $this->read_ushort();
$string_data_offset = $name_offset + $this->read_ushort();
@ -495,7 +495,7 @@ class OtlDump
$opos = $this->_pos;
$this->seek($string_data_offset + $offset);
if ($length % 2 != 0) {
throw new \Mpdf\MpdfException("PostScript name is UTF-16BE string of odd length");
throw new \Mpdf\Exception\FontException("Error loading font: PostScript name is UTF-16BE string of odd length");
}
$length /= 2;
$N = '';
@ -536,14 +536,14 @@ class OtlDump
}
}
if (!$psName) {
throw new \Mpdf\MpdfException("Could not find PostScript font name: " . $this->filename);
throw new \Mpdf\Exception\FontException("Error loading font: Could not find PostScript font name: " . $this->filename);
}
if ($debug) {
for ($i = 0; $i < count($psName); $i++) {
$c = $psName[$i];
$oc = ord($c);
if ($oc > 126 || strpos(' [](){}<>/%', $c) !== false) {
throw new \Mpdf\MpdfException("psName=" . $psName . " contains invalid character " . $c . " ie U+" . ord(c));
throw new \Mpdf\Exception\FontException("psName=" . $psName . " contains invalid character " . $c . " ie U+" . ord(c));
}
}
}
@ -581,14 +581,14 @@ class OtlDump
$ver_maj = $this->read_ushort();
$ver_min = $this->read_ushort();
if ($ver_maj != 1) {
throw new \Mpdf\MpdfException('Unknown head table version ' . $ver_maj . '.' . $ver_min);
throw new \Mpdf\Exception\FontException('Error loading font: Unknown head table version ' . $ver_maj . '.' . $ver_min);
}
$this->fontRevision = $this->read_ushort() . $this->read_ushort();
$this->skip(4);
$magic = $this->read_ulong();
if ($magic != 0x5F0F3CF5) {
throw new \Mpdf\MpdfException('Invalid head table magic ' . $magic);
throw new \Mpdf\Exception\FontException('Error loading font: Invalid head table magic ' . $magic);
}
$this->skip(2);
} else {
@ -606,7 +606,7 @@ class OtlDump
$indexToLocFormat = $this->read_ushort();
$glyphDataFormat = $this->read_ushort();
if ($glyphDataFormat != 0) {
throw new \Mpdf\MpdfException('Unknown glyph data format ' . $glyphDataFormat);
throw new \Mpdf\Exception\FontException('Error loading font: Unknown glyph data format ' . $glyphDataFormat);
}
///////////////////////////////////
@ -635,7 +635,7 @@ class OtlDump
if ($fsType == 0x0002 || ($fsType & 0x0300) != 0) {
global $overrideTTFFontRestriction;
if (!$overrideTTFFontRestriction) {
throw new \Mpdf\MpdfException('ERROR - Font file ' . $this->filename . ' cannot be embedded due to copyright restrictions.');
throw new \Mpdf\Exception\FontException('Font file ' . $this->filename . ' cannot be embedded due to copyright restrictions.');
}
$this->restrictedUse = true;
}
@ -685,7 +685,7 @@ class OtlDump
$ver_maj = $this->read_ushort();
$ver_min = $this->read_ushort();
if ($ver_maj < 1 || $ver_maj > 4) {
throw new \Mpdf\MpdfException('Unknown post table version ' . $ver_maj);
throw new \Mpdf\Exception\FontException('Error loading font: Unknown post table version ' . $ver_maj);
}
} else {
$this->skip(4);
@ -715,7 +715,7 @@ class OtlDump
$ver_maj = $this->read_ushort();
$ver_min = $this->read_ushort();
if ($ver_maj != 1) {
throw new \Mpdf\MpdfException('Unknown hhea table version ' . $ver_maj);
throw new \Mpdf\Exception\FontException(sprintf('Error loading font: Unknown hhea table version %s', $ver_maj));
}
$this->skip(28);
} else {
@ -723,11 +723,11 @@ class OtlDump
}
$metricDataFormat = $this->read_ushort();
if ($metricDataFormat != 0) {
throw new \Mpdf\MpdfException('Unknown horizontal metric data format ' . $metricDataFormat);
throw new \Mpdf\Exception\FontException('Error loading font: Unknown horizontal metric data format ' . $metricDataFormat);
}
$numberOfHMetrics = $this->read_ushort();
if ($numberOfHMetrics == 0) {
throw new \Mpdf\MpdfException('Number of horizontal metrics is 0');
throw new \Mpdf\Exception\FontException('Error loading font: Number of horizontal metrics is 0');
}
///////////////////////////////////
@ -738,7 +738,7 @@ class OtlDump
$ver_maj = $this->read_ushort();
$ver_min = $this->read_ushort();
if ($ver_maj != 1) {
throw new \Mpdf\MpdfException('Unknown maxp table version ' . $ver_maj);
throw new \Mpdf\Exception\FontException('Error loading font: Unknown maxp table version ' . $ver_maj);
}
} else {
$this->skip(4);
@ -781,7 +781,7 @@ class OtlDump
}
if (!$unicode_cmap_offset) {
throw new \Mpdf\MpdfException('Font (' . $this->filename . ') does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)');
throw new \Mpdf\Exception\FontException('Font (' . $this->filename . ') does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)');
}
$sipset = false;
@ -858,7 +858,7 @@ class OtlDump
$bctr++;
}
} else {
throw new \Mpdf\MpdfException($names[1] . " : WARNING - The font does not have enough space to map all (unmapped) included glyphs into Private Use Area U+E000 - U+F8FF");
throw new \Mpdf\Exception\FontException(sprintf('Font "%s" does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)', $this->filename));
}
}
$glyphToChar[$gid][] = $bctr;
@ -1568,7 +1568,7 @@ $MarkAttachmentType = ' . var_export($this->MarkAttachmentType, true) . ';
}
}
} else {
throw new \Mpdf\MpdfException("GPOS Lookup Type " . $Lookup[$i]['Type'] . ", Format " . $SubstFormat . " not supported (ttfontsuni.php).");
throw new \Mpdf\Exception\FontException("GPOS Lookup Type " . $Lookup[$i]['Type'] . ", Format " . $SubstFormat . " not supported (ttfontsuni.php).");
}
}
} // LookupType 6: Chaining Contextual Substitution Subtable
@ -1625,7 +1625,7 @@ $MarkAttachmentType = ' . var_export($this->MarkAttachmentType, true) . ';
}
}
} else {
throw new \Mpdf\MpdfException("Lookup Type " . $Lookup[$i]['Type'] . " not supported.");
throw new \Mpdf\Exception\FontException("Lookup Type " . $Lookup[$i]['Type'] . " not supported.");
}
}
}
@ -1807,7 +1807,7 @@ $MarkAttachmentType = ' . var_export($this->MarkAttachmentType, true) . ';
$glyphs = $this->_getCoverage();
$Lookup[$i]['Subtable'][$c]['CoverageInputGlyphs'][] = implode("|", $glyphs);
}
throw new \Mpdf\MpdfException("Lookup Type 5, SubstFormat 3 not tested. Please report this with the name of font used - " . $this->fontkey);
throw new \Mpdf\Exception\FontException("Lookup Type 5, SubstFormat 3 not tested. Please report this with the name of font used - " . $this->fontkey);
}
}
}
@ -2728,7 +2728,7 @@ $MarkAttachmentType = ' . var_export($this->MarkAttachmentType, true) . ';
// Flag & 0x0010 = UseMarkFilteringSet
if ($flag & 0x0010) {
throw new \Mpdf\MpdfException("This font " . $this->fontkey . " contains MarkGlyphSets");
throw new \Mpdf\Exception\FontException("This font " . $this->fontkey . " contains MarkGlyphSets");
$str = "Mark Glyph Set: ";
$str .= $this->MarkGlyphSets[$MarkFilteringSet];
}
@ -3757,21 +3757,21 @@ $MarkAttachmentType = ' . var_export($this->MarkAttachmentType, true) . ';
// Format 1:
//===========
if ($PosFormat == 1) {
throw new \Mpdf\MpdfException("GPOS Lookup Type " . $Type . " Format " . $PosFormat . " not YET TESTED.");
throw new \Mpdf\Exception\FontException("GPOS Lookup Type " . $Type . " Format " . $PosFormat . " not YET TESTED.");
} //===========
// Format 2:
//===========
else {
if ($PosFormat == 2) {
throw new \Mpdf\MpdfException("GPOS Lookup Type " . $Type . " Format " . $PosFormat . " not YET TESTED.");
throw new \Mpdf\Exception\FontException("GPOS Lookup Type " . $Type . " Format " . $PosFormat . " not YET TESTED.");
} //===========
// Format 3:
//===========
else {
if ($PosFormat == 3) {
throw new \Mpdf\MpdfException("GPOS Lookup Type " . $Type . " Format " . $PosFormat . " not YET TESTED.");
throw new \Mpdf\Exception\FontException("GPOS Lookup Type " . $Type . " Format " . $PosFormat . " not YET TESTED.");
} else {
throw new \Mpdf\MpdfException("GPOS Lookup Type " . $Type . ", Format " . $PosFormat . " not supported.");
throw new \Mpdf\Exception\FontException("GPOS Lookup Type " . $Type . ", Format " . $PosFormat . " not supported.");
}
}
}
@ -3785,7 +3785,7 @@ $MarkAttachmentType = ' . var_export($this->MarkAttachmentType, true) . ';
// Format 1:
//===========
if ($PosFormat == 1) {
throw new \Mpdf\MpdfException("GPOS Lookup Type " . $Type . " Format " . $PosFormat . " not TESTED YET.");
throw new \Mpdf\Exception\FontException("GPOS Lookup Type " . $Type . " Format " . $PosFormat . " not TESTED YET.");
} //===========
// Format 2:
//===========
@ -3794,7 +3794,7 @@ $MarkAttachmentType = ' . var_export($this->MarkAttachmentType, true) . ';
$html .= '<div>GPOS Lookup Type 8: Format 2 not yet supported in OTL dump</div>';
continue;
/* NB When developing - cf. GSUB 6.2 */
throw new \Mpdf\MpdfException("GPOS Lookup Type " . $Type . " Format " . $PosFormat . " not TESTED YET.");
throw new \Mpdf\Exception\FontException("GPOS Lookup Type " . $Type . " Format " . $PosFormat . " not TESTED YET.");
} //===========
// Format 3:
//===========
@ -4179,7 +4179,7 @@ $MarkAttachmentType = ' . var_export($this->MarkAttachmentType, true) . ';
$this->glyphPos[] = ($arr[$n + 1]);
}
} else {
throw new \Mpdf\MpdfException('Unknown location table format ' . $indexToLocFormat);
throw new \Mpdf\Exception\FontException('Unknown location table format ' . $indexToLocFormat);
}
}
}

View file

@ -31,7 +31,7 @@ class RemoteContentFetcher implements \Psr\Log\LoggerAwareInterface
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0.1'); // mPDF 5.7.4
curl_setopt($ch, CURLOPT_USERAGENT, $this->mpdf->curlUserAgent);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_NOBODY, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

View file

@ -228,7 +228,7 @@ class TTFontFile
$this->fh = fopen($file, 'rb');
if (!$this->fh) {
throw new \Mpdf\MpdfException(sprintf('Unable to open font file "%s"', $file));
throw new \Mpdf\Exception\FontException(sprintf('Unable to open font file "%s"', $file));
}
$this->_pos = 0;
@ -265,21 +265,21 @@ class TTFontFile
$this->panose = [];
if ($version === 0x4F54544F) {
throw new \Mpdf\MpdfException('Postscript outlines are not supported');
throw new \Mpdf\Exception\FontException('Postscript outlines are not supported');
}
if ($version === 0x74746366 && !$TTCfontID) {
throw new \Mpdf\MpdfException(sprintf('TTCfontID for a TrueType Collection is not defined in mPDF "fontdata" configuration (%s)', $file));
throw new \Mpdf\Exception\FontException(sprintf('TTCfontID for a TrueType Collection is not defined in mPDF "fontdata" configuration (%s)', $file));
}
if (!in_array($version, [0x00010000, 0x74727565], true) && !$TTCfontID) {
throw new \Mpdf\MpdfException(sprintf('Not a TrueType font: version=%s)', $version));
throw new \Mpdf\Exception\FontException(sprintf('Not a TrueType font: version=%s)', $version));
}
if ($TTCfontID > 0) {
$this->version = $version = $this->read_ulong(); // TTC Header version now
if (!in_array($version, [0x00010000, 0x00020000], true)) {
throw new \Mpdf\MpdfException(sprintf('Error parsing TrueType Collection: version=%s - (%s)', $version, $file));
throw new \Mpdf\Exception\FontException(sprintf('Error parsing TrueType Collection: version=%s - (%s)', $version, $file));
}
$this->numTTCFonts = $this->read_ulong();
for ($i = 1; $i <= $this->numTTCFonts; $i++) {
@ -332,7 +332,7 @@ class TTFontFile
}
$xchecksum = $t['checksum'];
if ($xchecksum != $checksum) {
throw new \Mpdf\MpdfException(sprintf('TTF file "%s": invalid checksum %s table: %s (expected %s)', $this->filename, dechex($checksum[0]) . dechex($checksum[1]), $t['tag'], dechex($xchecksum[0]) . dechex($xchecksum[1])));
throw new \Mpdf\Exception\FontException(sprintf('TTF file "%s": invalid checksum %s table: %s (expected %s)', $this->filename, dechex($checksum[0]) . dechex($checksum[1]), $t['tag'], dechex($xchecksum[0]) . dechex($xchecksum[1])));
}
}
}
@ -548,7 +548,7 @@ class TTFontFile
$this->fh = fopen($file, 'rb');
if (!$this->fh) {
throw new \Mpdf\MpdfException(sprintf('Unable to open file "%s"', $file));
throw new \Mpdf\Exception\FontException(sprintf('Unable to open file "%s"', $file));
}
$this->_pos = 0;
@ -563,7 +563,7 @@ class TTFontFile
if ($TTCfontID > 0) {
$this->version = $version = $this->read_ulong(); // TTC Header version now
if (!in_array($version, [0x00010000, 0x00020000], true)) {
throw new \Mpdf\MpdfException(sprintf("Error parsing TrueType Collection: version=%s (%s)", $version, $file));
throw new \Mpdf\Exception\FontException(sprintf("Error parsing TrueType Collection: version=%s (%s)", $version, $file));
}
$this->numTTCFonts = $this->read_ulong();
for ($i = 1; $i <= $this->numTTCFonts; $i++) {
@ -616,7 +616,7 @@ class TTFontFile
$bctr++;
} // Avoid overwriting a glyph already mapped in PUA
if ($bctr > 0xF8FF) {
throw new \Mpdf\MpdfException(sprintf('Font "%s" cannot map all included glyphs into Private Use Area U+E000-U+F8FF; cannot use useOTL on this font', $file));
throw new \Mpdf\Exception\FontException(sprintf('Font "%s" cannot map all included glyphs into Private Use Area U+E000-U+F8FF; cannot use useOTL on this font', $file));
}
$glyphToChar[$gid][] = $bctr;
$charToGlyph[$bctr] = $gid;
@ -636,7 +636,7 @@ class TTFontFile
$this->fh = fopen($file, 'rb');
if (!$this->fh) {
throw new \Mpdf\MpdfException(sprintf('Unable to open file "%s"', $file));
throw new \Mpdf\Exception\FontException(sprintf('Unable to open file "%s"', $file));
}
$this->numTTCFonts = 0;
@ -645,10 +645,10 @@ class TTFontFile
if ($version === 0x74746366) {
$this->version = $version = $this->read_ulong(); // TTC Header version now
if (!in_array($version, [0x00010000, 0x00020000], true)) {
throw new \Mpdf\MpdfException(sprintf("Error parsing TrueType Collection: version=%s (%s)", $version, $file));
throw new \Mpdf\Exception\FontException(sprintf("Error parsing TrueType Collection: version=%s (%s)", $version, $file));
}
} else {
throw new \Mpdf\MpdfException(sprintf("Not a TrueType Collection: version=%s (%s)", $version, $file));
throw new \Mpdf\Exception\FontException(sprintf("Not a TrueType Collection: version=%s (%s)", $version, $file));
}
$this->numTTCFonts = $this->read_ulong();
@ -664,7 +664,7 @@ class TTFontFile
$name_offset = $this->seek_table("name");
$format = $this->read_ushort();
if ($format != 0 && $format != 1) {
throw new \Mpdf\MpdfException("Unknown name table format " . $format);
throw new \Mpdf\Exception\FontException("Error loading font: Unknown name table format $format for font $this->filename");
}
$numRecords = $this->read_ushort();
@ -691,7 +691,7 @@ class TTFontFile
$opos = $this->_pos;
$this->seek($string_data_offset + $offset);
if ($length % 2 != 0) {
throw new \Mpdf\MpdfException("PostScript name is UTF-16BE string of odd length");
throw new \Mpdf\Exception\FontException("Error loading font: PostScript name is UTF-16BE string of odd length for font $this->filename");
}
$length /= 2;
$N = '';
@ -728,7 +728,7 @@ class TTFontFile
}
if (!$psName) {
throw new \Mpdf\MpdfException("Could not find PostScript font name: " . $this->filename);
throw new \Mpdf\Exception\FontException("Error loading font: Could not find PostScript font name '$this->filename'");
}
// CHECK IF psName valid (PadaukBook contains illegal characters in Name ID 6 i.e. Postscript Name)
@ -738,7 +738,7 @@ class TTFontFile
$c = $psName[$i];
$oc = ord($c);
if ($oc > 126 || strpos(' [](){}<>/%', $c) !== false) {
//throw new \Mpdf\MpdfException("psName=".$psName." contains invalid character ".$c." ie U+".ord(c));
//throw new \Mpdf\Exception\FontException("psName=".$psName." contains invalid character ".$c." ie U+".ord(c));
$psNameInvalid = true;
break;
}
@ -780,14 +780,14 @@ class TTFontFile
$ver_maj = $this->read_ushort();
$ver_min = $this->read_ushort();
if ($ver_maj != 1) {
throw new \Mpdf\MpdfException('Unknown head table version ' . $ver_maj . '.' . $ver_min);
throw new \Mpdf\Exception\FontException('Error loading font: Unknown head table version ' . $ver_maj . '.' . $ver_min);
}
$this->fontRevision = $this->read_ushort() . $this->read_ushort();
$this->skip(4);
$magic = $this->read_ulong();
if ($magic !== 0x5F0F3CF5) {
throw new \Mpdf\MpdfException('Invalid head table magic ' . $magic);
throw new \Mpdf\Exception\FontException('Error loading font: Invalid head table magic ' . $magic);
}
$this->skip(2);
} else {
@ -806,7 +806,7 @@ class TTFontFile
$indexToLocFormat = $this->read_ushort();
$glyphDataFormat = $this->read_ushort();
if ($glyphDataFormat != 0) {
throw new \Mpdf\MpdfException(sprintf('Unknown glyph data format %s', $glyphDataFormat));
throw new \Mpdf\Exception\FontException(sprintf('Error loading font: Unknown glyph data format %s', $glyphDataFormat));
}
// hhea metrics table
@ -938,7 +938,7 @@ class TTFontFile
if ($debug) {
$ver_maj = $this->read_ushort();
if ($ver_maj < 1 || $ver_maj > 4) {
throw new \Mpdf\MpdfException(sprintf('Unknown post table version %s', $ver_maj));
throw new \Mpdf\Exception\FontException(sprintf('Error loading font: Unknown post table version %s', $ver_maj));
}
} else {
$this->skip(4);
@ -966,7 +966,7 @@ class TTFontFile
if ($debug) {
$ver_maj = $this->read_ushort();
if ($ver_maj != 1) {
throw new \Mpdf\MpdfException(sprintf('Unknown hhea table version %s', $ver_maj));
throw new \Mpdf\Exception\FontException(sprintf('Error loading font: Unknown hhea table version %s', $ver_maj));
}
$this->skip(28);
} else {
@ -976,13 +976,13 @@ class TTFontFile
$metricDataFormat = $this->read_ushort();
if ($metricDataFormat != 0) {
throw new \Mpdf\MpdfException(sprintf('Unknown horizontal metric data format "%s"', $metricDataFormat));
throw new \Mpdf\Exception\FontException(sprintf('Error loading font: Unknown horizontal metric data format "%s"', $metricDataFormat));
}
$numberOfHMetrics = $this->read_ushort();
if ($numberOfHMetrics == 0) {
throw new \Mpdf\MpdfException('Number of horizontal metrics is 0');
throw new \Mpdf\Exception\FontException('Error loading font: Number of horizontal metrics is 0');
}
// maxp - Maximum profile table
@ -990,7 +990,7 @@ class TTFontFile
if ($debug) {
$ver_maj = $this->read_ushort();
if ($ver_maj != 1) {
throw new \Mpdf\MpdfException(sprintf('Unknown maxp table version ', $ver_maj));
throw new \Mpdf\Exception\FontException(sprintf('Error loading font: Unknown maxp table version %s', $ver_maj));
}
} else {
$this->skip(4);
@ -1028,7 +1028,7 @@ class TTFontFile
}
if (!$unicode_cmap_offset) {
throw new \Mpdf\MpdfException(sprintf('Font "%s" does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)', $this->filename));
throw new \Mpdf\Exception\FontException(sprintf('Font "%s" does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)', $this->filename));
}
$sipset = false;
@ -1108,7 +1108,7 @@ class TTFontFile
$bctr++;
}
} else {
throw new \Mpdf\MpdfException(sprintf('The font "%s" does not have enough space to map all (unmapped) included glyphs into Private Use Area U+E000-U+F8FF', $names[1]));
throw new \Mpdf\Exception\FontException(sprintf('The font "%s" does not have enough space to map all (unmapped) included glyphs into Private Use Area U+E000-U+F8FF', $names[1]));
}
}
@ -1340,7 +1340,7 @@ class TTFontFile
$this->MarkGlyphSets = [];
}
} else {
throw new \Mpdf\MpdfException(sprintf('Unable to set font "%s" to use OTL as it does not include OTL tables (or at least not a GDEF table).', $this->filename));
throw new \Mpdf\Exception\FontException(sprintf('Unable to set font "%s" to use OTL as it does not include OTL tables (or at least not a GDEF table).', $this->filename));
}
$GSUB_offset = 0;
@ -1779,7 +1779,7 @@ class TTFontFile
}
}
} else {
throw new \Mpdf\MpdfException("GPOS Lookup Type " . $Lookup[$i]['Type'] . ", Format " . $SubstFormat . " not supported (ttfontsuni.php).");
throw new \Mpdf\Exception\FontException("GPOS Lookup Type " . $Lookup[$i]['Type'] . ", Format " . $SubstFormat . " not supported (ttfontsuni.php).");
}
} // LookupType 6: Chaining Contextual Substitution Subtable
elseif ($Lookup[$i]['Type'] == 6) {
@ -1831,7 +1831,7 @@ class TTFontFile
}
}
} else {
throw new \Mpdf\MpdfException(sprintf('Lookup Type "%s" not supported.', $Lookup[$i]['Type']));
throw new \Mpdf\Exception\FontException(sprintf('Lookup Type "%s" not supported.', $Lookup[$i]['Type']));
}
}
}
@ -1995,7 +1995,7 @@ class TTFontFile
$glyphs = $this->_getCoverage();
$Lookup[$i]['Subtable'][$c]['CoverageInputGlyphs'][] = implode("|", $glyphs);
}
throw new \Mpdf\MpdfException("Lookup Type 5, SubstFormat 3 not tested. Please report this with the name of font used - " . $this->fontkey);
throw new \Mpdf\Exception\FontException("Lookup Type 5, SubstFormat 3 not tested. Please report this with the name of font used - " . $this->fontkey);
}
} // LookupType 6: Chaining Contextual Substitution Subtable
elseif ($Lookup[$i]['Type'] == 6) {
@ -2960,7 +2960,7 @@ class TTFontFile
// Flag & 0x0010 = UseMarkFilteringSet
if ($flag & 0x0010) {
throw new \Mpdf\MpdfException("This font " . $this->fontkey . " contains MarkGlyphSets - Not tested yet");
throw new \Mpdf\Exception\FontException("This font " . $this->fontkey . " contains MarkGlyphSets - Not tested yet");
$str = $this->MarkGlyphSets[$MarkFilteringSet];
}
@ -3449,7 +3449,7 @@ class TTFontFile
$this->fh = fopen($file, 'rb');
if (!$this->fh) {
throw new \Mpdf\MpdfException(sprintf('Unable to open file %s', $file));
throw new \Mpdf\Exception\FontException(sprintf('Unable to open file %s', $file));
}
$this->_pos = 0;
@ -3470,7 +3470,7 @@ class TTFontFile
if ($TTCfontID > 0) {
$this->version = $version = $this->read_ulong(); // TTC Header version now
if (!in_array($version, [0x00010000, 0x00020000], true)) {
throw new \Mpdf\MpdfException(sprintf('Error parsing TrueType Collection: version=%s - %s', $version, $file));
throw new \Mpdf\Exception\FontException(sprintf('Error parsing TrueType Collection: version=%s - %s', $version, $file));
}
$this->numTTCFonts = $this->read_ulong();
for ($i = 1; $i <= $this->numTTCFonts; $i++) {
@ -3519,7 +3519,7 @@ class TTFontFile
}
if (!$unicode_cmap_offset) {
throw new \Mpdf\MpdfException(sprintf('Font "%s" does not have Unicode cmap (platform 3, encoding 1, format 4, or platform 0 [any encoding] format 4)', $this->filename));
throw new \Mpdf\Exception\FontException(sprintf('Font "%s" does not have Unicode cmap (platform 3, encoding 1, format 4, or platform 0 [any encoding] format 4)', $this->filename));
}
$glyphToChar = [];
@ -3535,7 +3535,7 @@ class TTFontFile
$bctr++;
} // Avoid overwriting a glyph already mapped in PUA
if ($bctr > 0xF8FF) {
throw new \Mpdf\MpdfException($file . " : WARNING - Font cannot map all included glyphs into Private Use Area U+E000 - U+F8FF; cannot use useOTL on this font");
throw new \Mpdf\Exception\FontException($file . " : WARNING - Font cannot map all included glyphs into Private Use Area U+E000 - U+F8FF; cannot use useOTL on this font");
}
$glyphToChar[$gid][] = $bctr;
$charToGlyph[$bctr] = $gid;
@ -3940,7 +3940,7 @@ class TTFontFile
$this->fh = fopen($file, 'rb');
if (!$this->fh) {
throw new \Mpdf\MpdfException(sprintf('Unable to open file "%s"', $file));
throw new \Mpdf\Exception\FontException(sprintf('Unable to open file "%s"', $file));
}
$this->filename = $file;
@ -3962,7 +3962,7 @@ class TTFontFile
if ($TTCfontID > 0) {
$this->version = $version = $this->read_ulong(); // TTC Header version now
if (!in_array($version, [0x00010000, 0x00020000])) {
throw new \Mpdf\MpdfException("ERROR - Error parsing TrueType Collection: version=" . $version . " - " . $file);
throw new \Mpdf\Exception\FontException("ERROR - Error parsing TrueType Collection: version=" . $version . " - " . $file);
}
$this->numTTCFonts = $this->read_ulong();
for ($i = 1; $i <= $this->numTTCFonts; $i++) {
@ -4021,7 +4021,7 @@ class TTFontFile
}
if (!$unicode_cmap_offset) {
throw new \Mpdf\MpdfException(sprintf('Font "%s" does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)', $file));
throw new \Mpdf\Exception\FontException(sprintf('Font "%s" does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)', $file));
}
// Format 12 CMAP does characters above Unicode BMP i.e. some HKCS characters U+20000 and above
@ -4627,7 +4627,7 @@ class TTFontFile
$this->glyphPos[] = ($arr[$n + 1]);
}
} else {
throw new \Mpdf\MpdfException('Unknown location table format ' . $indexToLocFormat);
throw new \Mpdf\Exception\FontException('Unknown location table format ' . $indexToLocFormat);
}
}
@ -4753,7 +4753,7 @@ class TTFontFile
$this->fh = fopen($file, 'rb');
if (!$this->fh) {
throw new \Mpdf\MpdfException(sprintf('Unable to open file "%s"', $file));
throw new \Mpdf\Exception\FontException(sprintf('Unable to open file "%s"', $file));
}
$this->_pos = 0;
@ -4774,7 +4774,7 @@ class TTFontFile
if ($TTCfontID > 0) {
$this->version = $version = $this->read_ulong(); // TTC Header version now
if (!in_array($version, [0x00010000, 0x00020000], true)) {
throw new \Mpdf\MpdfException(sprintf('Error parsing TrueType Collection: version=%s - %s', $version, $file));
throw new \Mpdf\Exception\FontException(sprintf('Error parsing TrueType Collection: version=%s - %s', $version, $file));
}
$this->numTTCFonts = $this->read_ulong();
for ($i = 1; $i <= $this->numTTCFonts; $i++) {
@ -4821,7 +4821,7 @@ class TTFontFile
}
if (!$unicode_cmap_offset) {
throw new \Mpdf\MpdfException(sprintf('Font "%s" does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)', $this->filename));
throw new \Mpdf\Exception\FontException(sprintf('Font "%s" does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)', $this->filename));
}
$glyphToChar = [];
@ -4836,7 +4836,7 @@ class TTFontFile
$bctr++;
} // Avoid overwriting a glyph already mapped in PUA (6,400)
if ($bctr > 0xF8FF) {
throw new \Mpdf\MpdfException("Problem. Trying to repackage TF file; not enough space for unmapped glyphs");
throw new \Mpdf\Exception\FontException("Problem. Trying to repackage TF file; not enough space for unmapped glyphs");
}
$glyphToChar[$gid][] = $bctr;
$charToGlyph[$bctr] = $gid;

View file

@ -151,7 +151,7 @@ class BarCode extends Tag
}
if (isset($properties['VERTICAL-ALIGN'])) {
$objattr['vertical-align'] = self::ALIGN[strtolower($properties['VERTICAL-ALIGN'])];
$objattr['vertical-align'] = $this->getAlign($properties['VERTICAL-ALIGN']);
}
if (isset($properties['COLOR']) && $properties['COLOR'] != '') {
$objattr['color'] = $this->colorConverter->convert($properties['COLOR'], $this->mpdf->PDFAXwarnings);
@ -205,7 +205,7 @@ class BarCode extends Tag
$w = ($arrcode['maxw'] * $arrcode['nom-X'] * $objattr['bsize']) + $arrcode['quietL'] + $arrcode['quietR'];
$h = ($arrcode['nom-H'] * $objattr['bsize']) + (2 * $arrcode['quietTB']);
} elseif (in_array($objattr['btype'], ['C128A', 'C128B', 'C128C', 'EAN128A', 'EAN128B', 'EAN128C',
} elseif (in_array($objattr['btype'], ['C128A', 'C128B', 'C128C', 'C128RAW', 'EAN128A', 'EAN128B', 'EAN128C',
'C39', 'C39+', 'C39E', 'C39E+', 'S25', 'S25+', 'I25', 'I25+', 'I25B',
'I25B+', 'C93', 'MSI', 'MSI+', 'CODABAR', 'CODE11'])) {

View file

@ -126,7 +126,7 @@ abstract class BlockTag extends Tag
}
// Cannot set block properties inside table - use Bold to indicate h1-h6
if ($tag === 'CENTER' && $this->mpdf->tdbegin) {
$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['a'] = self::ALIGN['center'];
$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['a'] = $this->getAlign('center');
}
$this->mpdf->InlineProperties['BLOCKINTABLE'] = $this->mpdf->saveInlineProperties();
@ -398,7 +398,7 @@ abstract class BlockTag extends Tag
// mPDF 6
if (!empty($attr['ALIGN'])) {
$currblk['block-align'] = self::ALIGN[strtolower($attr['ALIGN'])];
$currblk['block-align'] = $this->getAlign($attr['ALIGN']);
}
@ -447,7 +447,7 @@ abstract class BlockTag extends Tag
// Cancel Keep-Block-together
$currblk['keep_block_together'] = false;
$this->mpdf->kt_y00 = '';
$this->mpdf->kt_y00 = 0;
$this->mpdf->keep_block_together = 0;
$this->mpdf->blockContext++;
@ -498,7 +498,7 @@ abstract class BlockTag extends Tag
} elseif (isset($properties['FLOAT']) && strtoupper($properties['FLOAT']) === 'LEFT' && !$this->mpdf->ColActive) {
// Cancel Keep-Block-together
$currblk['keep_block_together'] = false;
$this->mpdf->kt_y00 = '';
$this->mpdf->kt_y00 = 0;
$this->mpdf->keep_block_together = 0;
$this->mpdf->blockContext++;
@ -1257,6 +1257,7 @@ abstract class BlockTag extends Tag
$this->mpdf->pageoutput[$this->mpdf->page] = [];
$this->mpdf->y = $this->mpdf->kt_y00;
$ihtml = $this->mpdf->blk[$this->mpdf->blklvl]['array_i'] - 1;
$ahtml[$ihtml + 1] .= ' pagebreakavoidchecked="true";'; // avoid re-iterating; read in OpenTag()

View file

@ -47,7 +47,7 @@ class Columns extends Tag
if ($attr['VALIGN'] === 'J') {
$valign = 'J';
} else {
$valign = self::ALIGN[$attr['VALIGN']];
$valign = $this->getAlign($attr['VALIGN']);
}
} else {
$valign = '';

View file

@ -54,9 +54,9 @@ class Hr extends Tag
$objattr['width'] = $this->sizeConverter->convert($attr['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
}
if (isset($properties['TEXT-ALIGN'])) {
$objattr['align'] = self::ALIGN[strtolower($properties['TEXT-ALIGN'])];
$objattr['align'] = $this->getAlign($properties['TEXT-ALIGN']);
} elseif (isset($attr['ALIGN']) && $attr['ALIGN'] != '') {
$objattr['align'] = self::ALIGN[strtolower($attr['ALIGN'])];
$objattr['align'] = $this->getAlign($attr['ALIGN']);
}
if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) === 'auto') {

View file

@ -128,7 +128,7 @@ class Img extends Tag
}
if (isset($properties['VERTICAL-ALIGN'])) {
$objattr['vertical-align'] = self::ALIGN[strtolower($properties['VERTICAL-ALIGN'])];
$objattr['vertical-align'] = $this->getAlign($properties['VERTICAL-ALIGN']);
}
$w = 0;
$h = 0;

View file

@ -81,9 +81,9 @@ class Input extends Tag
$objattr['fontsize'] = $this->mpdf->FontSizePt;
if ($this->mpdf->useActiveForms) {
if (isset($attr['ALIGN'])) {
$objattr['text_align'] = self::ALIGN[strtolower($attr['ALIGN'])];
$objattr['text_align'] = $this->getAlign($attr['ALIGN']);
} elseif (isset($properties['TEXT-ALIGN'])) {
$objattr['text_align'] = self::ALIGN[strtolower($properties['TEXT-ALIGN'])];
$objattr['text_align'] = $this->getAlign($properties['TEXT-ALIGN']);
}
if (isset($properties['BORDER-TOP-COLOR'])) {
$objattr['border-col'] = $this->colorConverter->convert($properties['BORDER-TOP-COLOR'], $this->mpdf->PDFAXwarnings);
@ -105,7 +105,7 @@ class Input extends Tag
}
if ($properties['VERTICAL-ALIGN']) {
$objattr['vertical-align'] = self::ALIGN[strtolower($properties['VERTICAL-ALIGN'])];
$objattr['vertical-align'] = $this->getAlign($properties['VERTICAL-ALIGN']);
}
switch (strtoupper($attr['TYPE'])) {
@ -199,7 +199,7 @@ class Input extends Tag
$objattr['padding_right'] = 0;
if (isset($properties['VERTICAL-ALIGN'])) {
$objattr['vertical-align'] = self::ALIGN[strtolower($properties['VERTICAL-ALIGN'])];
$objattr['vertical-align'] = $this->getAlign($properties['VERTICAL-ALIGN']);
}
$w = 0;

View file

@ -176,7 +176,7 @@ class Meter extends InlineTag
}
if (isset($properties['VERTICAL-ALIGN'])) {
$objattr['vertical-align'] = self::ALIGN[strtolower($properties['VERTICAL-ALIGN'])];
$objattr['vertical-align'] = $this->getAlign($properties['VERTICAL-ALIGN']);
}
$w = 0;
$h = 0;

View file

@ -163,7 +163,7 @@ class Table extends Tag
}
if (isset($attr['ALIGN']) && array_key_exists(strtolower($attr['ALIGN']), self::ALIGN)) {
$table['a'] = self::ALIGN[strtolower($attr['ALIGN'])];
$table['a'] = $this->getAlign($attr['ALIGN']);
}
if (!$table['a']) {
if ($table['direction'] === 'rtl') {
@ -190,10 +190,10 @@ class Table extends Tag
}
if (isset($properties['VERTICAL-ALIGN']) && array_key_exists(strtolower($properties['VERTICAL-ALIGN']), self::ALIGN)) {
$table['va'] = self::ALIGN[strtolower($properties['VERTICAL-ALIGN'])];
$table['va'] = $this->getAlign($properties['VERTICAL-ALIGN']);
}
if (isset($properties['TEXT-ALIGN']) && array_key_exists(strtolower($properties['TEXT-ALIGN']), self::ALIGN)) {
$table['txta'] = self::ALIGN[strtolower($properties['TEXT-ALIGN'])];
$table['txta'] = $this->getAlign($properties['TEXT-ALIGN']);
}
if (!empty($properties['AUTOSIZE']) && $this->mpdf->tableLevel == 1) {

View file

@ -114,6 +114,12 @@ abstract class Tag
return strtoupper(str_replace('Mpdf\Tag\\', '', $tag));
}
protected function getAlign($property)
{
$property = strtolower($property);
return array_key_exists($property, self::ALIGN) ? self::ALIGN[$property] : '';
}
abstract public function open($attr, &$ahtml, &$ihtml);
abstract public function close(&$ahtml, &$ihtml);

View file

@ -12,19 +12,23 @@ class Td extends Tag
public function open($attr, &$ahtml, &$ihtml)
{
$tag = $this->getTagName();
$this->mpdf->ignorefollowingspaces = true;
$this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
$this->cssManager->tbCSSlvl++;
$this->mpdf->InlineProperties = [];
$this->mpdf->InlineBDF = []; // mPDF 6
$this->mpdf->InlineBDFctr = 0; // mPDF 6
$this->mpdf->tdbegin = true;
$this->mpdf->col++;
while (isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col])) {
$this->mpdf->col++;
}
//Update number column
// Update number column
if ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'] < $this->mpdf->col + 1) {
$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'] = $this->mpdf->col + 1;
}
@ -114,10 +118,10 @@ class Td extends Tag
// INHERITED THEAD CSS Properties
if ($this->mpdf->tablethead) {
if ($this->mpdf->thead_valign_default) {
$c['va'] = self::ALIGN[strtolower($this->mpdf->thead_valign_default)];
$c['va'] = $this->getAlign($this->mpdf->thead_valign_default);
}
if ($this->mpdf->thead_textalign_default) {
$c['a'] = self::ALIGN[strtolower($this->mpdf->thead_textalign_default)];
$c['a'] = $this->getAlign($this->mpdf->thead_textalign_default);
}
if ($this->mpdf->thead_font_weight === 'B') {
$this->mpdf->SetStyle('B', true);
@ -133,10 +137,10 @@ class Td extends Tag
// INHERITED TFOOT CSS Properties
if ($this->mpdf->tabletfoot) {
if ($this->mpdf->tfoot_valign_default) {
$c['va'] = self::ALIGN[strtolower($this->mpdf->tfoot_valign_default)];
$c['va'] = $this->getAlign($this->mpdf->tfoot_valign_default);
}
if ($this->mpdf->tfoot_textalign_default) {
$c['a'] = self::ALIGN[strtolower($this->mpdf->tfoot_textalign_default)];
$c['a'] = $this->getAlign($this->mpdf->tfoot_textalign_default);
}
if ($this->mpdf->tfoot_font_weight === 'B') {
$this->mpdf->SetStyle('B', true);
@ -195,9 +199,9 @@ class Td extends Tag
}
/* -- END BACKGROUNDS -- */
if (isset($properties['VERTICAL-ALIGN'])) {
$c['va'] = self::ALIGN[strtolower($properties['VERTICAL-ALIGN'])];
$c['va'] = $this->getAlign($properties['VERTICAL-ALIGN']);
} elseif (isset($attr['VALIGN'])) {
$c['va'] = self::ALIGN[strtolower($attr['VALIGN'])];
$c['va'] = $this->getAlign($attr['VALIGN']);
}
@ -205,7 +209,7 @@ class Td extends Tag
if (0 === strpos($properties['TEXT-ALIGN'], 'D')) {
$c['a'] = $properties['TEXT-ALIGN'];
} else {
$c['a'] = self::ALIGN[strtolower($properties['TEXT-ALIGN'])];
$c['a'] = $this->getAlign($properties['TEXT-ALIGN']);
}
}
if (!empty($attr['ALIGN'])) {
@ -221,7 +225,7 @@ class Td extends Tag
$c['a'] = 'DPR';
}
} else {
$c['a'] = self::ALIGN[strtolower($attr['ALIGN'])];
$c['a'] = $this->getAlign($attr['ALIGN']);
}
}
@ -458,9 +462,9 @@ class Td extends Tag
if ($this->mpdf->tableLevel == 1) {
$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['footernrows']
= max(
$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['footernrows'],
$this->mpdf->row + 1 - $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['headernrows']
);
$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['footernrows'],
$this->mpdf->row + 1 - $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['headernrows']
);
}
}
$this->mpdf->Reset();

View file

@ -75,9 +75,9 @@ class TextArea extends Tag
$objattr['fontsize'] = $this->mpdf->FontSizePt;
if ($this->mpdf->useActiveForms) {
if (isset($properties['TEXT-ALIGN'])) {
$objattr['text_align'] = self::ALIGN[strtolower($properties['TEXT-ALIGN'])];
$objattr['text_align'] = $this->getAlign($properties['TEXT-ALIGN']);
} elseif (isset($attr['ALIGN'])) {
$objattr['text_align'] = self::ALIGN[strtolower($attr['ALIGN'])];
$objattr['text_align'] = $this->getAlign($attr['ALIGN']);
}
if (isset($properties['OVERFLOW']) && strtolower($properties['OVERFLOW']) === 'hidden') {
$objattr['donotscroll'] = true;
@ -110,7 +110,7 @@ class TextArea extends Tag
);
}
if (isset($properties['VERTICAL-ALIGN'])) {
$objattr['vertical-align'] = self::ALIGN[strtolower($properties['VERTICAL-ALIGN'])];
$objattr['vertical-align'] = $this->getAlign($properties['VERTICAL-ALIGN']);
}
$colsize = 20; //HTML default value

View file

@ -54,7 +54,7 @@ class MetadataWriter implements \Psr\Log\LoggerAwareInterface
{
$this->writer->object();
$this->mpdf->MetadataRoot = $this->mpdf->n;
$Producer = 'mPDF ' . Mpdf::VERSION;
$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
@ -151,7 +151,7 @@ class MetadataWriter implements \Psr\Log\LoggerAwareInterface
public function writeInfo() // _putinfo
{
$this->writer->write('/Producer ' . $this->writer->utf16BigEndianTextString('mPDF ' . $this->getVersionString()));
$this->writer->write('/Producer ' . $this->writer->utf16BigEndianTextString('mPDF' . ($this->mpdf->exposeVersion ? (' ' . $this->getVersionString()) : '')));
if (!empty($this->mpdf->title)) {
$this->writer->write('/Title ' . $this->writer->utf16BigEndianTextString($this->mpdf->title));
@ -455,23 +455,29 @@ class MetadataWriter implements \Psr\Log\LoggerAwareInterface
}
if ($this->mpdf->hasOC || count($this->mpdf->layers)) {
$p = $v = $h = $l = $loff = $lall = $as = '';
if ($this->mpdf->hasOC) {
if (($this->mpdf->hasOC & 1) === 1) {
$p = $this->mpdf->n_ocg_print . ' 0 R';
}
if (($this->mpdf->hasOC & 2) === 2) {
$v = $this->mpdf->n_ocg_view . ' 0 R';
}
if (($this->mpdf->hasOC & 4) === 4) {
$h = $this->mpdf->n_ocg_hidden . ' 0 R';
}
$as = "<</Event /Print /OCGs [$p $v $h] /Category [/Print]>> <</Event /View /OCGs [$p $v $h] /Category [/View]>>";
}
if (count($this->mpdf->layers)) {
foreach ($this->mpdf->layers as $k => $layer) {
if (strtolower($this->mpdf->layerDetails[$k]['state']) === 'hidden') {
if (isset($this->mpdf->layerDetails[$k]) && strtolower($this->mpdf->layerDetails[$k]['state']) === 'hidden') {
$loff .= $layer['n'] . ' 0 R ';
} else {
$l .= $layer['n'] . ' 0 R ';
@ -479,11 +485,14 @@ class MetadataWriter implements \Psr\Log\LoggerAwareInterface
$lall .= $layer['n'] . ' 0 R ';
}
}
$this->writer->write("/OCProperties <</OCGs [$p $v $h $lall] /D <</ON [$p $l] /OFF [$v $h $loff] ");
$this->writer->write("/Order [$v $p $h $lall] ");
if ($as) {
$this->writer->write("/AS [$as] ");
}
$this->writer->write('>>>>');
}
}