| Línea 1... |
Línea 1... |
| 1 |
<?php
|
1 |
<?php
|
| 2 |
//============================================================+
|
2 |
//============================================================+
|
| 3 |
// File name : tcpdf.php
|
3 |
// File name : tcpdf.php
|
| 4 |
// Version : 6.6.5
|
4 |
// Version : 6.8.2
|
| 5 |
// Begin : 2002-08-03
|
5 |
// Begin : 2002-08-03
|
| 6 |
// Last Update : 2023-09-06
|
6 |
// Last Update : 2024-12-23
|
| 7 |
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
7 |
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
| 8 |
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
8 |
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
| 9 |
// -------------------------------------------------------------------
|
9 |
// -------------------------------------------------------------------
|
| 10 |
// Copyright (C) 2002-2023 Nicola Asuni - Tecnick.com LTD
|
10 |
// Copyright (C) 2002-2025 Nicola Asuni - Tecnick.com LTD
|
| 11 |
//
|
11 |
//
|
| 12 |
// This file is part of TCPDF software library.
|
12 |
// This file is part of TCPDF software library.
|
| 13 |
//
|
13 |
//
|
| 14 |
// TCPDF is free software: you can redistribute it and/or modify it
|
14 |
// TCPDF is free software: you can redistribute it and/or modify it
|
| 15 |
// under the terms of the GNU Lesser General Public License as
|
15 |
// under the terms of the GNU Lesser General Public License as
|
| Línea 102... |
Línea 102... |
| 102 |
* <li>PDF/A-1b support.</li>
|
102 |
* <li>PDF/A-1b support.</li>
|
| 103 |
* </ul>
|
103 |
* </ul>
|
| 104 |
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
|
104 |
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
|
| 105 |
* @package com.tecnick.tcpdf
|
105 |
* @package com.tecnick.tcpdf
|
| 106 |
* @author Nicola Asuni
|
106 |
* @author Nicola Asuni
|
| 107 |
* @version 6.6.5
|
107 |
* @version 6.8.2
|
| 108 |
*/
|
108 |
*/
|
| Línea 109... |
Línea 109... |
| 109 |
|
109 |
|
| 110 |
// TCPDF configuration
|
110 |
// TCPDF configuration
|
| 111 |
require_once(dirname(__FILE__).'/tcpdf_autoconfig.php');
|
111 |
require_once(dirname(__FILE__).'/tcpdf_autoconfig.php');
|
| Línea 126... |
Línea 126... |
| 126 |
* @class TCPDF
|
126 |
* @class TCPDF
|
| 127 |
* PHP class for generating PDF documents without requiring external extensions.
|
127 |
* PHP class for generating PDF documents without requiring external extensions.
|
| 128 |
* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
|
128 |
* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
|
| 129 |
* @package com.tecnick.tcpdf
|
129 |
* @package com.tecnick.tcpdf
|
| 130 |
* @brief PHP class for generating PDF documents without requiring external extensions.
|
130 |
* @brief PHP class for generating PDF documents without requiring external extensions.
|
| 131 |
* @version 6.6.5
|
131 |
* @version 6.8.2
|
| 132 |
* @author Nicola Asuni - info@tecnick.com
|
132 |
* @author Nicola Asuni - info@tecnick.com
|
| 133 |
* @IgnoreAnnotation("protected")
|
133 |
* @IgnoreAnnotation("protected")
|
| 134 |
* @IgnoreAnnotation("public")
|
134 |
* @IgnoreAnnotation("public")
|
| 135 |
* @IgnoreAnnotation("pre")
|
135 |
* @IgnoreAnnotation("pre")
|
| 136 |
*/
|
136 |
*/
|
| Línea 836... |
Línea 836... |
| 836 |
* @protected
|
836 |
* @protected
|
| 837 |
* @since 5.0.005 (2010-05-12)
|
837 |
* @since 5.0.005 (2010-05-12)
|
| 838 |
*/
|
838 |
*/
|
| 839 |
protected $file_id;
|
839 |
protected $file_id;
|
| Línea -... |
Línea 840... |
| - |
|
840 |
|
| - |
|
841 |
/**
|
| - |
|
842 |
* Internal secret used to encrypt data.
|
| - |
|
843 |
* @protected
|
| - |
|
844 |
* @since 6.7.5 (2024-03-21)
|
| - |
|
845 |
*/
|
| - |
|
846 |
protected $hash_key;
|
| 840 |
|
847 |
|
| Línea 841... |
Línea 848... |
| 841 |
// --- bookmark ---
|
848 |
// --- bookmark ---
|
| 842 |
|
849 |
|
| 843 |
/**
|
850 |
/**
|
| Línea 1878... |
Línea 1885... |
| 1878 |
*/
|
1885 |
*/
|
| 1879 |
public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false) {
|
1886 |
public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false) {
|
| 1880 |
// set file ID for trailer
|
1887 |
// set file ID for trailer
|
| 1881 |
$serformat = (is_array($format) ? json_encode($format) : $format);
|
1888 |
$serformat = (is_array($format) ? json_encode($format) : $format);
|
| 1882 |
$this->file_id = md5(TCPDF_STATIC::getRandomSeed('TCPDF'.$orientation.$unit.$serformat.$encoding));
|
1889 |
$this->file_id = md5(TCPDF_STATIC::getRandomSeed('TCPDF'.$orientation.$unit.$serformat.$encoding));
|
| - |
|
1890 |
$this->hash_key = hash_hmac('sha256', TCPDF_STATIC::getRandomSeed($this->file_id), TCPDF_STATIC::getRandomSeed('TCPDF'), false);
|
| 1883 |
$this->font_obj_ids = array();
|
1891 |
$this->font_obj_ids = array();
|
| 1884 |
$this->page_obj_id = array();
|
1892 |
$this->page_obj_id = array();
|
| 1885 |
$this->form_obj_id = array();
|
1893 |
$this->form_obj_id = array();
|
| 1886 |
|
- |
|
| 1887 |
// set pdf/a mode
|
1894 |
// set pdf/a mode
|
| 1888 |
if ($pdfa != false) {
|
1895 |
if ($pdfa != false) {
|
| 1889 |
$this->pdfa_mode = true;
|
1896 |
$this->pdfa_mode = true;
|
| 1890 |
$this->pdfa_version = $pdfa; // 1 or 3
|
1897 |
$this->pdfa_version = $pdfa; // 1 or 3
|
| 1891 |
} else
|
1898 |
} else
|
| Línea 2998... |
Línea 3005... |
| 2998 |
* @since 1.0
|
3005 |
* @since 1.0
|
| 2999 |
*/
|
3006 |
*/
|
| 3000 |
public function Error($msg) {
|
3007 |
public function Error($msg) {
|
| 3001 |
// unset all class variables
|
3008 |
// unset all class variables
|
| 3002 |
$this->_destroy(true);
|
3009 |
$this->_destroy(true);
|
| - |
|
3010 |
$msg = htmlspecialchars(string: $msg, encoding: 'UTF-8');
|
| 3003 |
if (defined('K_TCPDF_THROW_EXCEPTION_ERROR') AND !K_TCPDF_THROW_EXCEPTION_ERROR) {
|
3011 |
if (defined('K_TCPDF_THROW_EXCEPTION_ERROR') AND !K_TCPDF_THROW_EXCEPTION_ERROR) {
|
| 3004 |
die('<strong>TCPDF ERROR: </strong>'.$msg);
|
3012 |
die('<strong>TCPDF ERROR: </strong>'.$msg);
|
| 3005 |
} else {
|
3013 |
} else {
|
| 3006 |
throw new Exception('TCPDF ERROR: '.$msg);
|
3014 |
throw new Exception('TCPDF ERROR: '.$msg);
|
| 3007 |
}
|
3015 |
}
|
| Línea 4425... |
Línea 4433... |
| 4425 |
}
|
4433 |
}
|
| 4426 |
} else {
|
4434 |
} else {
|
| 4427 |
$this->Error('Unknow font type: '.$type.'');
|
4435 |
$this->Error('Unknow font type: '.$type.'');
|
| 4428 |
}
|
4436 |
}
|
| 4429 |
// set name if unset
|
4437 |
// set name if unset
|
| 4430 |
if (!isset($name) OR empty($name)) {
|
4438 |
if (empty($name)) {
|
| 4431 |
$name = $fontkey;
|
4439 |
$name = $fontkey;
|
| 4432 |
}
|
4440 |
}
|
| 4433 |
// create artificial font style variations if missing (only works with non-embedded fonts)
|
4441 |
// create artificial font style variations if missing (only works with non-embedded fonts)
|
| 4434 |
if (($type != 'core') AND $missing_style) {
|
4442 |
if (($type != 'core') AND $missing_style) {
|
| 4435 |
// style variations
|
4443 |
// style variations
|
| Línea 4468... |
Línea 4476... |
| 4468 |
$this->setFontBuffer($fontkey, array('fontkey' => $fontkey, 'i' => $this->numfonts, 'type' => $type, 'name' => $name, 'desc' => $desc, 'up' => $up, 'ut' => $ut, 'cw' => $cw, 'cbbox' => $cbbox, 'dw' => $dw, 'enc' => $enc, 'cidinfo' => $cidinfo, 'file' => $file, 'ctg' => $ctg, 'subset' => $subset, 'subsetchars' => $subsetchars));
|
4476 |
$this->setFontBuffer($fontkey, array('fontkey' => $fontkey, 'i' => $this->numfonts, 'type' => $type, 'name' => $name, 'desc' => $desc, 'up' => $up, 'ut' => $ut, 'cw' => $cw, 'cbbox' => $cbbox, 'dw' => $dw, 'enc' => $enc, 'cidinfo' => $cidinfo, 'file' => $file, 'ctg' => $ctg, 'subset' => $subset, 'subsetchars' => $subsetchars));
|
| 4469 |
if ($this->inxobj) {
|
4477 |
if ($this->inxobj) {
|
| 4470 |
// we are inside an XObject template
|
4478 |
// we are inside an XObject template
|
| 4471 |
$this->xobjects[$this->xobjid]['fonts'][$fontkey] = $this->numfonts;
|
4479 |
$this->xobjects[$this->xobjid]['fonts'][$fontkey] = $this->numfonts;
|
| 4472 |
}
|
4480 |
}
|
| 4473 |
if (isset($diff) AND (!empty($diff))) {
|
4481 |
if (!empty($diff)) {
|
| 4474 |
//Search existing encodings
|
4482 |
//Search existing encodings
|
| 4475 |
$d = 0;
|
4483 |
$d = 0;
|
| 4476 |
$nb = count($this->diffs);
|
4484 |
$nb = count($this->diffs);
|
| 4477 |
for ($i=1; $i <= $nb; ++$i) {
|
4485 |
for ($i=1; $i <= $nb; ++$i) {
|
| 4478 |
if ($this->diffs[$i] == $diff) {
|
4486 |
if ($this->diffs[$i] == $diff) {
|
| Línea 8155... |
Línea 8163... |
| 8155 |
* @protected
|
8163 |
* @protected
|
| 8156 |
* @author Nicola Asuni
|
8164 |
* @author Nicola Asuni
|
| 8157 |
* @since 5.0.010 (2010-05-17)
|
8165 |
* @since 5.0.010 (2010-05-17)
|
| 8158 |
*/
|
8166 |
*/
|
| 8159 |
protected function _getannotsrefs($n) {
|
8167 |
protected function _getannotsrefs($n) {
|
| 8160 |
if (!(isset($this->PageAnnots[$n]) OR ($this->sign AND isset($this->signature_data['cert_type'])))) {
|
8168 |
if (!(isset($this->PageAnnots[$n]) OR count($this->empty_signature_appearance)>0 OR ($this->sign AND isset($this->signature_data['cert_type'])))) {
|
| 8161 |
return '';
|
8169 |
return '';
|
| 8162 |
}
|
8170 |
}
|
| 8163 |
$out = ' /Annots [';
|
8171 |
$out = ' /Annots [';
|
| 8164 |
if (isset($this->PageAnnots[$n])) {
|
8172 |
if (isset($this->PageAnnots[$n])) {
|
| 8165 |
foreach ($this->PageAnnots[$n] as $key => $val) {
|
8173 |
foreach ($this->PageAnnots[$n] as $key => $val) {
|
| Línea 8301... |
Línea 8309... |
| 8301 |
case 'readonly': {
|
8309 |
case 'readonly': {
|
| 8302 |
$fval += 1 << 6;
|
8310 |
$fval += 1 << 6;
|
| 8303 |
break;
|
8311 |
break;
|
| 8304 |
}
|
8312 |
}
|
| 8305 |
case 'locked': {
|
8313 |
case 'locked': {
|
| 8306 |
$fval += 1 << 8;
|
8314 |
$fval += 1 << 7;
|
| 8307 |
break;
|
8315 |
break;
|
| 8308 |
}
|
8316 |
}
|
| 8309 |
case 'togglenoview': {
|
8317 |
case 'togglenoview': {
|
| 8310 |
$fval += 1 << 9;
|
8318 |
$fval += 1 << 8;
|
| 8311 |
break;
|
8319 |
break;
|
| 8312 |
}
|
8320 |
}
|
| 8313 |
case 'lockedcontents': {
|
8321 |
case 'lockedcontents': {
|
| 8314 |
$fval += 1 << 10;
|
8322 |
$fval += 1 << 9;
|
| 8315 |
break;
|
8323 |
break;
|
| 8316 |
}
|
8324 |
}
|
| 8317 |
default: {
|
8325 |
default: {
|
| 8318 |
break;
|
8326 |
break;
|
| 8319 |
}
|
8327 |
}
|
| Línea 8523... |
Línea 8531... |
| 8523 |
//$annots .= ' /Quadpoints ';
|
8531 |
//$annots .= ' /Quadpoints ';
|
| 8524 |
break;
|
8532 |
break;
|
| 8525 |
}
|
8533 |
}
|
| 8526 |
case 'freetext': {
|
8534 |
case 'freetext': {
|
| 8527 |
if (isset($pl['opt']['da']) AND !empty($pl['opt']['da'])) {
|
8535 |
if (isset($pl['opt']['da']) AND !empty($pl['opt']['da'])) {
|
| 8528 |
$annots .= ' /DA ('.$pl['opt']['da'].')';
|
8536 |
$annots .= ' /DA '.$this->_datastring($pl['opt']['da']);
|
| 8529 |
}
|
8537 |
}
|
| 8530 |
if (isset($pl['opt']['q']) AND ($pl['opt']['q'] >= 0) AND ($pl['opt']['q'] <= 2)) {
|
8538 |
if (isset($pl['opt']['q']) AND ($pl['opt']['q'] >= 0) AND ($pl['opt']['q'] <= 2)) {
|
| 8531 |
$annots .= ' /Q '.intval($pl['opt']['q']);
|
8539 |
$annots .= ' /Q '.intval($pl['opt']['q']);
|
| 8532 |
}
|
8540 |
}
|
| 8533 |
if (isset($pl['opt']['rc'])) {
|
8541 |
if (isset($pl['opt']['rc'])) {
|
| Línea 8780... |
Línea 8788... |
| 8780 |
}
|
8788 |
}
|
| 8781 |
if (isset($pl['opt']['aa']) AND !empty($pl['opt']['aa'])) {
|
8789 |
if (isset($pl['opt']['aa']) AND !empty($pl['opt']['aa'])) {
|
| 8782 |
$annots .= ' /AA << '.$pl['opt']['aa'].' >>';
|
8790 |
$annots .= ' /AA << '.$pl['opt']['aa'].' >>';
|
| 8783 |
}
|
8791 |
}
|
| 8784 |
if (isset($pl['opt']['da']) AND !empty($pl['opt']['da'])) {
|
8792 |
if (isset($pl['opt']['da']) AND !empty($pl['opt']['da'])) {
|
| 8785 |
$annots .= ' /DA ('.$pl['opt']['da'].')';
|
8793 |
$annots .= ' /DA '.$this->_datastring($pl['opt']['da']);
|
| 8786 |
}
|
8794 |
}
|
| 8787 |
if (isset($pl['opt']['q']) AND ($pl['opt']['q'] >= 0) AND ($pl['opt']['q'] <= 2)) {
|
8795 |
if (isset($pl['opt']['q']) AND ($pl['opt']['q'] >= 0) AND ($pl['opt']['q'] <= 2)) {
|
| 8788 |
$annots .= ' /Q '.intval($pl['opt']['q']);
|
8796 |
$annots .= ' /Q '.intval($pl['opt']['q']);
|
| 8789 |
}
|
8797 |
}
|
| 8790 |
if (isset($pl['opt']['opt']) AND (is_array($pl['opt']['opt'])) AND !empty($pl['opt']['opt'])) {
|
8798 |
if (isset($pl['opt']['opt']) AND (is_array($pl['opt']['opt'])) AND !empty($pl['opt']['opt'])) {
|
| Línea 9930... |
Línea 9938... |
| 9930 |
$out .= ' /F'.$fontid.' '.$this->font_obj_ids[$fontkey].' 0 R';
|
9938 |
$out .= ' /F'.$fontid.' '.$this->font_obj_ids[$fontkey].' 0 R';
|
| 9931 |
}
|
9939 |
}
|
| 9932 |
$out .= ' >> >>';
|
9940 |
$out .= ' >> >>';
|
| 9933 |
}
|
9941 |
}
|
| 9934 |
$font = $this->getFontBuffer((($this->pdfa_mode) ? 'pdfa' : '') .'helvetica');
|
9942 |
$font = $this->getFontBuffer((($this->pdfa_mode) ? 'pdfa' : '') .'helvetica');
|
| 9935 |
$out .= ' /DA (/F'.$font['i'].' 0 Tf 0 g)';
|
9943 |
$out .= ' /DA ' . $this->_datastring('/F'.$font['i'].' 0 Tf 0 g');
|
| 9936 |
$out .= ' /Q '.(($this->rtl)?'2':'0');
|
9944 |
$out .= ' /Q '.(($this->rtl)?'2':'0');
|
| 9937 |
//$out .= ' /XFA ';
|
9945 |
//$out .= ' /XFA ';
|
| 9938 |
$out .= ' >>';
|
9946 |
$out .= ' >>';
|
| 9939 |
// signatures
|
9947 |
// signatures
|
| 9940 |
if ($this->sign AND isset($this->signature_data['cert_type'])
|
9948 |
if ($this->sign AND isset($this->signature_data['cert_type'])
|
| Línea 11037... |
Línea 11045... |
| 11037 |
}
|
11045 |
}
|
| 11038 |
case 2: { // AES 128 bit
|
11046 |
case 2: { // AES 128 bit
|
| 11039 |
$this->encryptdata['V'] = 4;
|
11047 |
$this->encryptdata['V'] = 4;
|
| 11040 |
$this->encryptdata['Length'] = 128;
|
11048 |
$this->encryptdata['Length'] = 128;
|
| 11041 |
$this->encryptdata['CF']['CFM'] = 'AESV2';
|
11049 |
$this->encryptdata['CF']['CFM'] = 'AESV2';
|
| 11042 |
$this->encryptdata['CF']['Length'] = 128;
|
11050 |
$this->encryptdata['CF']['Length'] = 16;
|
| 11043 |
if ($this->encryptdata['pubkey']) {
|
11051 |
if ($this->encryptdata['pubkey']) {
|
| 11044 |
$this->encryptdata['SubFilter'] = 'adbe.pkcs7.s5';
|
11052 |
$this->encryptdata['SubFilter'] = 'adbe.pkcs7.s5';
|
| 11045 |
$this->encryptdata['Recipients'] = array();
|
11053 |
$this->encryptdata['Recipients'] = array();
|
| 11046 |
}
|
11054 |
}
|
| 11047 |
break;
|
11055 |
break;
|
| 11048 |
}
|
11056 |
}
|
| 11049 |
case 3: { // AES 256 bit
|
11057 |
case 3: { // AES 256 bit
|
| 11050 |
$this->encryptdata['V'] = 5;
|
11058 |
$this->encryptdata['V'] = 5;
|
| 11051 |
$this->encryptdata['Length'] = 256;
|
11059 |
$this->encryptdata['Length'] = 256;
|
| 11052 |
$this->encryptdata['CF']['CFM'] = 'AESV3';
|
11060 |
$this->encryptdata['CF']['CFM'] = 'AESV3';
|
| 11053 |
$this->encryptdata['CF']['Length'] = 256;
|
11061 |
$this->encryptdata['CF']['Length'] = 32;
|
| 11054 |
if ($this->encryptdata['pubkey']) {
|
11062 |
if ($this->encryptdata['pubkey']) {
|
| 11055 |
$this->encryptdata['SubFilter'] = 'adbe.pkcs7.s5';
|
11063 |
$this->encryptdata['SubFilter'] = 'adbe.pkcs7.s5';
|
| 11056 |
$this->encryptdata['Recipients'] = array();
|
11064 |
$this->encryptdata['Recipients'] = array();
|
| 11057 |
}
|
11065 |
}
|
| 11058 |
break;
|
11066 |
break;
|
| Línea 13927... |
Línea 13935... |
| 13927 |
* @return int|void the number of extgstates
|
13935 |
* @return int|void the number of extgstates
|
| 13928 |
* @protected
|
13936 |
* @protected
|
| 13929 |
* @since 3.0.000 (2008-03-27)
|
13937 |
* @since 3.0.000 (2008-03-27)
|
| 13930 |
*/
|
13938 |
*/
|
| 13931 |
protected function addExtGState($parms) {
|
13939 |
protected function addExtGState($parms) {
|
| 13932 |
if ($this->pdfa_mode || $this->pdfa_version >= 2) {
|
13940 |
if (($this->pdfa_mode && $this->pdfa_version < 2) || ($this->state != 2)) {
|
| 13933 |
// transparencies are not allowed in PDF/A mode
|
13941 |
// transparency is not allowed in PDF/A-1 mode
|
| 13934 |
return;
|
13942 |
return;
|
| 13935 |
}
|
13943 |
}
|
| 13936 |
// check if this ExtGState already exist
|
13944 |
// check if this ExtGState already exist
|
| 13937 |
foreach ($this->extgstates as $i => $ext) {
|
13945 |
foreach ($this->extgstates as $i => $ext) {
|
| 13938 |
if ($ext['parms'] == $parms) {
|
13946 |
if ($ext['parms'] == $parms) {
|
| Línea 16387... |
Línea 16395... |
| 16387 |
* @return array
|
16395 |
* @return array
|
| 16388 |
* @protected
|
16396 |
* @protected
|
| 16389 |
* @since 3.2.000 (2008-06-20)
|
16397 |
* @since 3.2.000 (2008-06-20)
|
| 16390 |
*/
|
16398 |
*/
|
| 16391 |
protected function getHtmlDomArray($html) {
|
16399 |
protected function getHtmlDomArray($html) {
|
| - |
|
16400 |
// set inheritable properties fot the first void element
|
| - |
|
16401 |
// possible inheritable properties are: azimuth, border-collapse, border-spacing, caption-side, color, cursor, direction, empty-cells, font, font-family, font-stretch, font-size, font-size-adjust, font-style, font-variant, font-weight, letter-spacing, line-height, list-style, list-style-image, list-style-position, list-style-type, orphans, page, page-break-inside, quotes, speak, speak-header, text-align, text-indent, text-transform, volume, white-space, widows, word-spacing
|
| - |
|
16402 |
$dom = array(
|
| - |
|
16403 |
array(
|
| - |
|
16404 |
'tag' => false,
|
| - |
|
16405 |
'block' => false,
|
| - |
|
16406 |
'value' => '',
|
| - |
|
16407 |
'parent' => 0,
|
| - |
|
16408 |
'hide' => false,
|
| - |
|
16409 |
'fontname' => $this->FontFamily,
|
| - |
|
16410 |
'fontstyle' => $this->FontStyle,
|
| - |
|
16411 |
'fontsize' => $this->FontSizePt,
|
| - |
|
16412 |
'font-stretch' => $this->font_stretching,
|
| - |
|
16413 |
'letter-spacing' => $this->font_spacing,
|
| - |
|
16414 |
'stroke' => $this->textstrokewidth,
|
| - |
|
16415 |
'fill' => (($this->textrendermode % 2) == 0),
|
| - |
|
16416 |
'clip' => ($this->textrendermode > 3),
|
| - |
|
16417 |
'line-height' => $this->cell_height_ratio,
|
| - |
|
16418 |
'bgcolor' => false,
|
| - |
|
16419 |
'fgcolor' => $this->fgcolor, // color
|
| - |
|
16420 |
'strokecolor' => $this->strokecolor,
|
| - |
|
16421 |
'align' => '',
|
| - |
|
16422 |
'listtype' => '',
|
| - |
|
16423 |
'text-indent' => 0,
|
| - |
|
16424 |
'text-transform' => '',
|
| - |
|
16425 |
'border' => array(),
|
| - |
|
16426 |
'dir' => $this->rtl?'rtl':'ltr',
|
| - |
|
16427 |
'width' => 0,
|
| - |
|
16428 |
'height' => 0,
|
| - |
|
16429 |
'x' => 0,
|
| - |
|
16430 |
'y' => 0,
|
| - |
|
16431 |
'w' => 0,
|
| - |
|
16432 |
'h' => 0,
|
| - |
|
16433 |
'l' => 0,
|
| - |
|
16434 |
't' => 0,
|
| - |
|
16435 |
'r' => 0,
|
| - |
|
16436 |
'b' => 0,
|
| - |
|
16437 |
'padding' => array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0),
|
| - |
|
16438 |
'margin' => array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0),
|
| - |
|
16439 |
'border-spacing' => array('H' => 0, 'V' => 0),
|
| - |
|
16440 |
'border-collapse' => 'separate',
|
| - |
|
16441 |
)
|
| - |
|
16442 |
);
|
| - |
|
16443 |
|
| - |
|
16444 |
if($html === '' || $html === null) {
|
| - |
|
16445 |
return $dom;
|
| - |
|
16446 |
}
|
| 16392 |
// array of CSS styles ( selector => properties).
|
16447 |
// array of CSS styles ( selector => properties).
|
| 16393 |
$css = array();
|
16448 |
$css = array();
|
| 16394 |
// get CSS array defined at previous call
|
16449 |
// get CSS array defined at previous call
|
| 16395 |
$matches = array();
|
16450 |
$matches = array();
|
| 16396 |
if (preg_match_all('/<cssarray>([^\<]*?)<\/cssarray>/is', $html, $matches) > 0) {
|
16451 |
if (preg_match_all('/<cssarray>([^\<]*?)<\/cssarray>/is', $html, $matches) > 0) {
|
| Línea 16531... |
Línea 16586... |
| 16531 |
// explodes the string
|
16586 |
// explodes the string
|
| 16532 |
$a = preg_split($tagpattern, $html, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
16587 |
$a = preg_split($tagpattern, $html, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
| 16533 |
// count elements
|
16588 |
// count elements
|
| 16534 |
$maxel = count($a);
|
16589 |
$maxel = count($a);
|
| 16535 |
$elkey = 0;
|
16590 |
$elkey = 0;
|
| 16536 |
$key = 0;
|
- |
|
| 16537 |
// create an array of elements
|
- |
|
| 16538 |
$dom = array();
|
- |
|
| 16539 |
$dom[$key] = array();
|
- |
|
| 16540 |
// set inheritable properties fot the first void element
|
- |
|
| 16541 |
// possible inheritable properties are: azimuth, border-collapse, border-spacing, caption-side, color, cursor, direction, empty-cells, font, font-family, font-stretch, font-size, font-size-adjust, font-style, font-variant, font-weight, letter-spacing, line-height, list-style, list-style-image, list-style-position, list-style-type, orphans, page, page-break-inside, quotes, speak, speak-header, text-align, text-indent, text-transform, volume, white-space, widows, word-spacing
|
- |
|
| 16542 |
$dom[$key]['tag'] = false;
|
- |
|
| 16543 |
$dom[$key]['block'] = false;
|
- |
|
| 16544 |
$dom[$key]['value'] = '';
|
- |
|
| 16545 |
$dom[$key]['parent'] = 0;
|
- |
|
| 16546 |
$dom[$key]['hide'] = false;
|
- |
|
| 16547 |
$dom[$key]['fontname'] = $this->FontFamily;
|
- |
|
| 16548 |
$dom[$key]['fontstyle'] = $this->FontStyle;
|
- |
|
| 16549 |
$dom[$key]['fontsize'] = $this->FontSizePt;
|
- |
|
| 16550 |
$dom[$key]['font-stretch'] = $this->font_stretching;
|
- |
|
| 16551 |
$dom[$key]['letter-spacing'] = $this->font_spacing;
|
- |
|
| 16552 |
$dom[$key]['stroke'] = $this->textstrokewidth;
|
- |
|
| 16553 |
$dom[$key]['fill'] = (($this->textrendermode % 2) == 0);
|
- |
|
| 16554 |
$dom[$key]['clip'] = ($this->textrendermode > 3);
|
- |
|
| 16555 |
$dom[$key]['line-height'] = $this->cell_height_ratio;
|
- |
|
| 16556 |
$dom[$key]['bgcolor'] = false;
|
- |
|
| 16557 |
$dom[$key]['fgcolor'] = $this->fgcolor; // color
|
- |
|
| 16558 |
$dom[$key]['strokecolor'] = $this->strokecolor;
|
- |
|
| 16559 |
$dom[$key]['align'] = '';
|
- |
|
| 16560 |
$dom[$key]['listtype'] = '';
|
- |
|
| 16561 |
$dom[$key]['text-indent'] = 0;
|
- |
|
| 16562 |
$dom[$key]['text-transform'] = '';
|
- |
|
| 16563 |
$dom[$key]['border'] = array();
|
- |
|
| 16564 |
$dom[$key]['dir'] = $this->rtl?'rtl':'ltr';
|
- |
|
| 16565 |
$thead = false; // true when we are inside the THEAD tag
|
16591 |
$thead = false; // true when we are inside the THEAD tag
|
| 16566 |
++$key;
|
16592 |
$key = 1;
|
| 16567 |
$level = array();
|
16593 |
$level = array();
|
| 16568 |
array_push($level, 0); // root
|
16594 |
array_push($level, 0); // root
|
| 16569 |
while ($elkey < $maxel) {
|
16595 |
while ($elkey < $maxel) {
|
| 16570 |
$dom[$key] = array();
|
16596 |
$dom[$key] = array();
|
| 16571 |
$element = $a[$elkey];
|
16597 |
$element = $a[$elkey];
|
| Línea 17198... |
Línea 17224... |
| 17198 |
}
|
17224 |
}
|
| 17199 |
return $spacestr;
|
17225 |
return $spacestr;
|
| 17200 |
}
|
17226 |
}
|
| Línea 17201... |
Línea 17227... |
| 17201 |
|
17227 |
|
| 17202 |
/**
|
17228 |
/**
|
| - |
|
17229 |
* Calculates the hash value of the given data.
|
| 17203 |
* Return an hash code used to ensure that the serialized data has been generated by this TCPDF instance.
|
17230 |
*
|
| 17204 |
* @param string $data serialized data
|
17231 |
* @param string $data The data to be hashed.
|
| 17205 |
* @return string
|
- |
|
| 17206 |
* @public static
|
17232 |
* @return string The hashed value of the data.
|
| 17207 |
*/
|
17233 |
*/
|
| 17208 |
protected function getHashForTCPDFtagParams($data) {
|
17234 |
protected function hashTCPDFtag($data) {
|
| 17209 |
return md5(strlen($data).$this->file_id.$data);
|
17235 |
return hash_hmac('sha256', $data, $this->hash_key, false);
|
| Línea 17210... |
Línea 17236... |
| 17210 |
}
|
17236 |
}
|
| 17211 |
|
17237 |
|
| - |
|
17238 |
/**
|
| 17212 |
/**
|
17239 |
* Serialize data to be used with TCPDF tag in HTML code.
|
| 17213 |
* Serialize an array of parameters to be used with TCPDF tag in HTML code.
|
17240 |
* @param string $method TCPDF method name
|
| 17214 |
* @param array $data parameters array
|
17241 |
* @param array $params Method parameters
|
| 17215 |
* @return string containing serialized data
|
17242 |
* @return string Serialized data
|
| 17216 |
* @public static
|
17243 |
* @public static
|
| - |
|
17244 |
*/
|
| 17217 |
*/
|
17245 |
public function serializeTCPDFtag($method, $params=array()) {
|
| 17218 |
public function serializeTCPDFtagParameters($data) {
|
17246 |
$data = array('m' => $method, 'p' => $params);
|
| - |
|
17247 |
$encoded = urlencode(json_encode($data));
|
| 17219 |
$encoded = urlencode(json_encode($data));
|
17248 |
$hash = $this->hashTCPDFtag($encoded);
|
| Línea 17220... |
Línea 17249... |
| 17220 |
return $this->getHashForTCPDFtagParams($encoded).$encoded;
|
17249 |
return strlen($hash).'+'.$hash.'+'.$encoded;
|
| 17221 |
}
|
17250 |
}
|
| 17222 |
|
17251 |
|
| 17223 |
/**
|
17252 |
/**
|
| 17224 |
* Unserialize parameters to be used with TCPDF tag in HTML code.
|
17253 |
* Unserialize data to be used with TCPDF tag in HTML code.
|
| 17225 |
* @param string $data serialized data
|
17254 |
* @param string $data serialized data
|
| 17226 |
* @return array containing unserialized data
|
17255 |
* @return array containing unserialized data
|
| - |
|
17256 |
* @protected static
|
| - |
|
17257 |
*/
|
| 17227 |
* @protected static
|
17258 |
protected function unserializeTCPDFtag($data) {
|
| 17228 |
*/
|
17259 |
$hpos = strpos($data, '+');
|
| 17229 |
protected function unserializeTCPDFtagParameters($data) {
|
17260 |
$hlen = intval(substr($data, 0, $hpos));
|
| 17230 |
$hash = substr($data, 0, 32);
|
17261 |
$hash = substr($data, $hpos + 1, $hlen);
|
| 17231 |
$encoded = substr($data, 32);
|
17262 |
$encoded = substr($data, $hpos + 2 + $hlen);
|
| 17232 |
if ($hash != $this->getHashForTCPDFtagParams($encoded)) {
|
17263 |
if (!hash_equals( $this->hashTCPDFtag($encoded), $hash)) {
|
| 17233 |
$this->Error('Invalid parameters');
|
17264 |
$this->Error('Invalid parameters');
|
| Línea 17234... |
Línea 17265... |
| 17234 |
}
|
17265 |
}
|
| - |
|
17266 |
return json_decode(urldecode($encoded), true);
|
| - |
|
17267 |
}
|
| - |
|
17268 |
|
| - |
|
17269 |
/**
|
| - |
|
17270 |
* Check if a TCPDF tag is allowed
|
| - |
|
17271 |
* @param string $method TCPDF method name
|
| - |
|
17272 |
* @return boolean
|
| - |
|
17273 |
* @protected
|
| - |
|
17274 |
*/
|
| - |
|
17275 |
protected function allowedTCPDFtag($method) {
|
| - |
|
17276 |
if (defined('K_ALLOWED_TCPDF_TAGS')) {
|
| - |
|
17277 |
return (strpos(K_ALLOWED_TCPDF_TAGS, '|'.$method.'|') !== false);
|
| - |
|
17278 |
}
|
| 17235 |
return json_decode(urldecode($encoded), true);
|
17279 |
return false;
|
| 17236 |
}
|
17280 |
}
|
| 17237 |
|
17281 |
|
| 17238 |
/**
|
17282 |
/**
|
| 17239 |
* Prints a cell (rectangular area) with optional borders, background color and html text string.
|
17283 |
* Prints a cell (rectangular area) with optional borders, background color and html text string.
|
| Línea 17246... |
Línea 17290... |
| 17246 |
* @param float $h Cell minimum height. The cell extends automatically if needed.
|
17290 |
* @param float $h Cell minimum height. The cell extends automatically if needed.
|
| 17247 |
* @param float|null $x upper-left corner X coordinate
|
17291 |
* @param float|null $x upper-left corner X coordinate
|
| 17248 |
* @param float|null $y upper-left corner Y coordinate
|
17292 |
* @param float|null $y upper-left corner Y coordinate
|
| 17249 |
* @param string $html html text to print. Default value: empty string.
|
17293 |
* @param string $html html text to print. Default value: empty string.
|
| 17250 |
* @param mixed $border Indicates if borders must be drawn around the cell. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul> or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
|
17294 |
* @param mixed $border Indicates if borders must be drawn around the cell. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul> or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
|
| 17251 |
* @param int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0: to the right (or left for RTL language)</li><li>1: to the beginning of the next line</li><li>2: below</li></ul>
|
17295 |
* @param int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0: to the right (or left for RTL language)</li><li>1: to the beginning of the next line</li><li>2: below</li></ul> Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: 0.
|
| 17252 |
Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: 0.
|
- |
|
| 17253 |
* @param boolean $fill Indicates if the cell background must be painted (true) or transparent (false).
|
17296 |
* @param boolean $fill Indicates if the cell background must be painted (true) or transparent (false).
|
| 17254 |
* @param boolean $reseth if true reset the last cell height (default true).
|
17297 |
* @param boolean $reseth if true reset the last cell height (default true).
|
| 17255 |
* @param string $align Allows to center or align the text. Possible values are:<ul><li>L : left align</li><li>C : center</li><li>R : right align</li><li>'' : empty string : left for LTR or right for RTL</li></ul>
|
17298 |
* @param string $align Allows to center or align the text. Possible values are:<ul><li>L : left align</li><li>C : center</li><li>R : right align</li><li>'' : empty string : left for LTR or right for RTL</li></ul>
|
| 17256 |
* @param boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
|
17299 |
* @param boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
|
| 17257 |
* @see Multicell(), writeHTML()
|
17300 |
* @see Multicell(), writeHTML()
|
| Línea 18966... |
Línea 19009... |
| 18966 |
}
|
19009 |
}
|
| 18967 |
$prevlinewidth = $this->GetLineWidth();
|
19010 |
$prevlinewidth = $this->GetLineWidth();
|
| 18968 |
$this->setLineWidth($hrHeight);
|
19011 |
$this->setLineWidth($hrHeight);
|
| Línea 18969... |
Línea 19012... |
| 18969 |
|
19012 |
|
| 18970 |
$lineStyle = array();
|
19013 |
$lineStyle = array();
|
| 18971 |
if (isset($tag['fgcolor'])) {
|
19014 |
if (isset($tag['fgcolor'])) {
|
| 18972 |
$lineStyle['color'] = $tag['fgcolor'];
|
19015 |
$lineStyle['color'] = $tag['fgcolor'];
|
| 18973 |
}
|
19016 |
}
|
| 18974 |
|
19017 |
|
| 18975 |
if (isset($tag['fgcolor'])) {
|
19018 |
if (isset($tag['fgcolor'])) {
|
| 18976 |
$lineStyle['color'] = $tag['fgcolor'];
|
19019 |
$lineStyle['color'] = $tag['fgcolor'];
|
| 18977 |
}
|
19020 |
}
|
| 18978 |
|
19021 |
|
| 18979 |
if (isset($tag['style']['cap'])) {
|
19022 |
if (isset($tag['style']['cap'])) {
|
| 18980 |
$lineStyle['cap'] = $tag['style']['cap'];
|
19023 |
$lineStyle['cap'] = $tag['style']['cap'];
|
| 18981 |
}
|
19024 |
}
|
| 18982 |
|
19025 |
|
| 18983 |
if (isset($tag['style']['join'])) {
|
19026 |
if (isset($tag['style']['join'])) {
|
| 18984 |
$lineStyle['join'] = $tag['style']['join'];
|
19027 |
$lineStyle['join'] = $tag['style']['join'];
|
| 18985 |
}
|
19028 |
}
|
| 18986 |
|
19029 |
|
| 18987 |
if (isset($tag['style']['dash'])) {
|
19030 |
if (isset($tag['style']['dash'])) {
|
| 18988 |
$lineStyle['dash'] = $tag['style']['dash'];
|
19031 |
$lineStyle['dash'] = $tag['style']['dash'];
|
| 18989 |
}
|
19032 |
}
|
| 18990 |
|
19033 |
|
| 18991 |
if (isset($tag['style']['phase'])) {
|
19034 |
if (isset($tag['style']['phase'])) {
|
| 18992 |
$lineStyle['phase'] = $tag['style']['phase'];
|
19035 |
$lineStyle['phase'] = $tag['style']['phase'];
|
| Línea 18993... |
Línea 19036... |
| 18993 |
}
|
19036 |
}
|
| Línea 18994... |
Línea 19037... |
| 18994 |
|
19037 |
|
| 18995 |
$lineStyle = array_filter($lineStyle);
|
19038 |
$lineStyle = array_filter($lineStyle);
|
| Línea 19011... |
Línea 19054... |
| 19011 |
}
|
19054 |
}
|
| 19012 |
$imgsrc = $tag['attribute']['src'];
|
19055 |
$imgsrc = $tag['attribute']['src'];
|
| 19013 |
if ($imgsrc[0] === '@') {
|
19056 |
if ($imgsrc[0] === '@') {
|
| 19014 |
// data stream
|
19057 |
// data stream
|
| 19015 |
$imgsrc = '@'.base64_decode(substr($imgsrc, 1));
|
19058 |
$imgsrc = '@'.base64_decode(substr($imgsrc, 1));
|
| 19016 |
$type = '';
|
19059 |
$type = preg_match('/<svg\s+[^>]*[^>]*>.*<\/svg>/is', $imgsrc) ? 'svg' : '';
|
| 19017 |
} else if (preg_match('@^data:image/([^;]*);base64,(.*)@', $imgsrc, $reg)) {
|
19060 |
} else if (preg_match('@^data:image/([^;]*);base64,(.*)@', $imgsrc, $reg)) {
|
| 19018 |
$imgsrc = '@'.base64_decode($reg[2]);
|
19061 |
$imgsrc = '@'.base64_decode($reg[2]);
|
| 19019 |
$type = $reg[1];
|
19062 |
$type = $reg[1];
|
| - |
|
19063 |
} elseif (strpos($imgsrc, '../') !== false) {
|
| - |
|
19064 |
// accessing parent folders is not allowed
|
| - |
|
19065 |
break;
|
| 19020 |
} elseif ( $this->allowLocalFiles && substr($imgsrc, 0, 7) === 'file://') {
|
19066 |
} elseif ( $this->allowLocalFiles && substr($imgsrc, 0, 7) === 'file://') {
|
| 19021 |
// get image type from a local file path
|
19067 |
// get image type from a local file path
|
| 19022 |
$imgsrc = substr($imgsrc, 7);
|
19068 |
$imgsrc = substr($imgsrc, 7);
|
| 19023 |
$type = TCPDF_IMAGES::getImageFileType($imgsrc);
|
19069 |
$type = TCPDF_IMAGES::getImageFileType($imgsrc);
|
| 19024 |
} else {
|
19070 |
} else {
|
| 19025 |
if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
19071 |
if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
| 19026 |
// fix image path
|
19072 |
// fix image path
|
| 19027 |
$findroot = strpos($imgsrc, $_SERVER['DOCUMENT_ROOT']);
|
19073 |
$findroot = strpos($imgsrc, $_SERVER['DOCUMENT_ROOT']);
|
| 19028 |
if (($findroot === false) OR ($findroot > 1)) {
|
19074 |
if (($findroot === false) OR ($findroot > 1)) {
|
| 19029 |
if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
|
19075 |
if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
|
| Línea 19077... |
Línea 19123... |
| 19077 |
$prevy = $this->y;
|
19123 |
$prevy = $this->y;
|
| 19078 |
$xpos = $this->x;
|
19124 |
$xpos = $this->x;
|
| 19079 |
$imglink = '';
|
19125 |
$imglink = '';
|
| 19080 |
if (isset($this->HREF['url']) AND !TCPDF_STATIC::empty_string($this->HREF['url'])) {
|
19126 |
if (isset($this->HREF['url']) AND !TCPDF_STATIC::empty_string($this->HREF['url'])) {
|
| 19081 |
$imglink = $this->HREF['url'];
|
19127 |
$imglink = $this->HREF['url'];
|
| 19082 |
if ($imglink[0] == '#') {
|
19128 |
if ($imglink[0] == '#' AND is_numeric($imglink[1])) {
|
| 19083 |
// convert url to internal link
|
19129 |
// convert url to internal link
|
| 19084 |
$lnkdata = explode(',', $imglink);
|
19130 |
$lnkdata = explode(',', $imglink);
|
| 19085 |
if (isset($lnkdata[0])) {
|
19131 |
if (isset($lnkdata[0])) {
|
| 19086 |
$page = intval(substr($lnkdata[0], 1));
|
19132 |
$page = intval(substr($lnkdata[0], 1));
|
| 19087 |
if (empty($page) OR ($page <= 0)) {
|
19133 |
if (empty($page) OR ($page <= 0)) {
|
| Línea 19508... |
Línea 19554... |
| 19508 |
break;
|
19554 |
break;
|
| 19509 |
}
|
19555 |
}
|
| 19510 |
case 'tcpdf': {
|
19556 |
case 'tcpdf': {
|
| 19511 |
if (defined('K_TCPDF_CALLS_IN_HTML') AND (K_TCPDF_CALLS_IN_HTML === true)) {
|
19557 |
if (defined('K_TCPDF_CALLS_IN_HTML') AND (K_TCPDF_CALLS_IN_HTML === true)) {
|
| 19512 |
// Special tag used to call TCPDF methods
|
19558 |
// Special tag used to call TCPDF methods
|
| 19513 |
if (isset($tag['attribute']['method'])) {
|
19559 |
// This tag is disabled by default by the K_TCPDF_CALLS_IN_HTML constant on TCPDF configuration file.
|
| 19514 |
$tcpdf_method = $tag['attribute']['method'];
|
19560 |
// Please use this feature only if you are in control of the HTML content and you are sure that it does not contain any harmful code.
|
| 19515 |
if (method_exists($this, $tcpdf_method)) {
|
19561 |
if (!empty($tag['attribute']['data'])) {
|
| 19516 |
if (isset($tag['attribute']['params']) AND (!empty($tag['attribute']['params']))) {
|
19562 |
$tcpdf_tag_data = $this->unserializeTCPDFtag($tag['attribute']['data']);
|
| 19517 |
$params = $this->unserializeTCPDFtagParameters($tag['attribute']['params']);
|
19563 |
if ($this->allowedTCPDFtag($tcpdf_tag_data['m'])) {
|
| 19518 |
call_user_func_array(array($this, $tcpdf_method), $params);
|
19564 |
call_user_func_array(array($this, $tcpdf_tag_data['m']), $tcpdf_tag_data['p']);
|
| 19519 |
} else {
|
- |
|
| 19520 |
$this->$tcpdf_method();
|
- |
|
| 19521 |
}
|
- |
|
| 19522 |
$this->newline = true;
|
- |
|
| 19523 |
}
|
19565 |
}
|
| - |
|
19566 |
$this->newline = true;
|
| 19524 |
}
|
19567 |
}
|
| 19525 |
}
|
19568 |
}
|
| 19526 |
break;
|
19569 |
break;
|
| 19527 |
}
|
19570 |
}
|
| 19528 |
default: {
|
19571 |
default: {
|
| Línea 21865... |
Línea 21908... |
| 21865 |
* @return TCPDF object.
|
21908 |
* @return TCPDF object.
|
| 21866 |
* @public
|
21909 |
* @public
|
| 21867 |
* @since 4.5.029 (2009-03-19)
|
21910 |
* @since 4.5.029 (2009-03-19)
|
| 21868 |
*/
|
21911 |
*/
|
| 21869 |
public function rollbackTransaction($self=false) {
|
21912 |
public function rollbackTransaction($self=false) {
|
| 21870 |
if (isset($this->objcopy)) {
|
21913 |
if (!isset($this->objcopy)) {
|
| 21871 |
$objcopy = $this->objcopy;
|
- |
|
| 21872 |
$this->_destroy(true, true);
|
- |
|
| 21873 |
if ($self) {
|
- |
|
| 21874 |
$objvars = get_object_vars($objcopy);
|
- |
|
| 21875 |
foreach ($objvars as $key => $value) {
|
- |
|
| 21876 |
$this->$key = $value;
|
- |
|
| 21877 |
}
|
- |
|
| 21878 |
$objcopy->_destroy(true, true);
|
- |
|
| 21879 |
/* The unique file_id should not be used during cleanup again */
|
- |
|
| 21880 |
$objcopy->file_id = NULL;
|
- |
|
| 21881 |
unset($objcopy);
|
- |
|
| 21882 |
return $this;
|
21914 |
return $this;
|
| 21883 |
}
|
- |
|
| 21884 |
/* The unique file_id should not be used during cleanup again */
|
- |
|
| 21885 |
$this->file_id = NULL;
|
- |
|
| 21886 |
return $objcopy;
|
- |
|
| 21887 |
}
|
21915 |
}
|
| - |
|
21916 |
$file_id = $this->file_id;
|
| - |
|
21917 |
$objcopy = $this->objcopy;
|
| - |
|
21918 |
$this->_destroy(true, true);
|
| - |
|
21919 |
if ($self) {
|
| - |
|
21920 |
$objvars = get_object_vars($objcopy);
|
| - |
|
21921 |
foreach ($objvars as $key => $value) {
|
| - |
|
21922 |
$this->$key = $value;
|
| - |
|
21923 |
}
|
| - |
|
21924 |
$objcopy->_destroy(true, true);
|
| - |
|
21925 |
unset($objcopy);
|
| 21888 |
return $this;
|
21926 |
return $this;
|
| - |
|
21927 |
}
|
| - |
|
21928 |
$this->file_id = $file_id;
|
| - |
|
21929 |
return $objcopy;
|
| 21889 |
}
|
21930 |
}
|
| Línea 21890... |
Línea 21931... |
| 21890 |
|
21931 |
|
| Línea 21891... |
Línea 21932... |
| 21891 |
// --- MULTI COLUMNS METHODS -----------------------
|
21932 |
// --- MULTI COLUMNS METHODS -----------------------
|
| Línea 23131... |
Línea 23172... |
| 23131 |
$e = $ox * $this->k * (1 - $svgscale_x);
|
23172 |
$e = $ox * $this->k * (1 - $svgscale_x);
|
| 23132 |
$f = ($this->h - $oy) * $this->k * (1 - $svgscale_y);
|
23173 |
$f = ($this->h - $oy) * $this->k * (1 - $svgscale_y);
|
| 23133 |
$this->_out(sprintf('%F %F %F %F %F %F cm', $svgscale_x, 0, 0, $svgscale_y, ($e + $svgoffset_x), ($f + $svgoffset_y)));
|
23174 |
$this->_out(sprintf('%F %F %F %F %F %F cm', $svgscale_x, 0, 0, $svgscale_y, ($e + $svgoffset_x), ($f + $svgoffset_y)));
|
| 23134 |
// creates a new XML parser to be used by the other XML functions
|
23175 |
// creates a new XML parser to be used by the other XML functions
|
| 23135 |
$parser = xml_parser_create('UTF-8');
|
23176 |
$parser = xml_parser_create('UTF-8');
|
| 23136 |
// the following function allows to use parser inside object
|
- |
|
| 23137 |
xml_set_object($parser, $this);
|
- |
|
| 23138 |
// disable case-folding for this XML parser
|
23177 |
// disable case-folding for this XML parser
|
| 23139 |
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
|
23178 |
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
|
| 23140 |
// sets the element handler functions for the XML parser
|
23179 |
// sets the element handler functions for the XML parser
|
| 23141 |
xml_set_element_handler($parser, 'startSVGElementHandler', 'endSVGElementHandler');
|
23180 |
xml_set_element_handler($parser, [$this, 'startSVGElementHandler'], [$this, 'endSVGElementHandler']);
|
| 23142 |
// sets the character data handler function for the XML parser
|
23181 |
// sets the character data handler function for the XML parser
|
| 23143 |
xml_set_character_data_handler($parser, 'segSVGContentHandler');
|
23182 |
xml_set_character_data_handler($parser, [$this, 'segSVGContentHandler']);
|
| 23144 |
// start parsing an XML document
|
23183 |
// start parsing an XML document
|
| 23145 |
if (!xml_parse($parser, $svgdata)) {
|
23184 |
if (!xml_parse($parser, $svgdata)) {
|
| 23146 |
$error_message = sprintf('SVG Error: %s at line %d', xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser));
|
23185 |
$error_message = sprintf('SVG Error: %s at line %d', xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser));
|
| 23147 |
$this->Error($error_message);
|
23186 |
$this->Error($error_message);
|
| 23148 |
}
|
23187 |
}
|
| Línea 23288... |
Línea 23327... |
| 23288 |
$this->setFillColorArray($fill_color);
|
23327 |
$this->setFillColorArray($fill_color);
|
| 23289 |
// text color
|
23328 |
// text color
|
| 23290 |
$text_color = TCPDF_COLORS::convertHTMLColorToDec($svgstyle['text-color'], $this->spot_colors);
|
23329 |
$text_color = TCPDF_COLORS::convertHTMLColorToDec($svgstyle['text-color'], $this->spot_colors);
|
| 23291 |
$this->setTextColorArray($text_color);
|
23330 |
$this->setTextColorArray($text_color);
|
| 23292 |
// clip
|
23331 |
// clip
|
| 23293 |
if (preg_match('/rect\(([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)\)/si', $svgstyle['clip'], $regs)) {
|
23332 |
if (preg_match('/rect\(([a-z0-9\-\.]*+)[\s]*+([a-z0-9\-\.]*+)[\s]*+([a-z0-9\-\.]*+)[\s]*+([a-z0-9\-\.]*+)\)/si', $svgstyle['clip'], $regs)) {
|
| 23294 |
$top = (isset($regs[1])?$this->getHTMLUnitToUnits($regs[1], 0, $this->svgunit, false):0);
|
23333 |
$top = (isset($regs[1])?$this->getHTMLUnitToUnits($regs[1], 0, $this->svgunit, false):0);
|
| 23295 |
$right = (isset($regs[2])?$this->getHTMLUnitToUnits($regs[2], 0, $this->svgunit, false):0);
|
23334 |
$right = (isset($regs[2])?$this->getHTMLUnitToUnits($regs[2], 0, $this->svgunit, false):0);
|
| 23296 |
$bottom = (isset($regs[3])?$this->getHTMLUnitToUnits($regs[3], 0, $this->svgunit, false):0);
|
23335 |
$bottom = (isset($regs[3])?$this->getHTMLUnitToUnits($regs[3], 0, $this->svgunit, false):0);
|
| 23297 |
$left = (isset($regs[4])?$this->getHTMLUnitToUnits($regs[4], 0, $this->svgunit, false):0);
|
23336 |
$left = (isset($regs[4])?$this->getHTMLUnitToUnits($regs[4], 0, $this->svgunit, false):0);
|
| 23298 |
$cx = $x + $left;
|
23337 |
$cx = $x + $left;
|
| Línea 23405... |
Línea 23444... |
| 23405 |
$h = $w = max($w, $h);
|
23444 |
$h = $w = max($w, $h);
|
| 23406 |
} else {
|
23445 |
} else {
|
| 23407 |
$cy -= $h;
|
23446 |
$cy -= $h;
|
| 23408 |
}
|
23447 |
}
|
| 23409 |
$this->_out(sprintf('%F 0 0 %F %F %F cm', ($w * $this->k), ($h * $this->k), ($x * $this->k), ($cy * $this->k)));
|
23448 |
$this->_out(sprintf('%F 0 0 %F %F %F cm', ($w * $this->k), ($h * $this->k), ($x * $this->k), ($cy * $this->k)));
|
| 23410 |
if (count($gradient['stops']) > 1) {
|
23449 |
if ((is_array($gradient['stops']) || $gradient['stops'] instanceof Countable) && count($gradient['stops']) > 1) {
|
| 23411 |
$this->Gradient($gradient['type'], $gradient['coords'], $gradient['stops'], array(), false);
|
23450 |
$this->Gradient($gradient['type'], $gradient['coords'], $gradient['stops']);
|
| 23412 |
}
|
23451 |
}
|
| 23413 |
} elseif ($svgstyle['fill'] != 'none') {
|
23452 |
} elseif ($svgstyle['fill'] != 'none') {
|
| 23414 |
$fill_color = TCPDF_COLORS::convertHTMLColorToDec($svgstyle['fill'], $this->spot_colors);
|
23453 |
$fill_color = TCPDF_COLORS::convertHTMLColorToDec($svgstyle['fill'], $this->spot_colors);
|
| 23415 |
if ($svgstyle['fill-opacity'] != 1) {
|
23454 |
if ($svgstyle['fill-opacity'] != 1) {
|
| 23416 |
$this->setAlpha($this->alpha['CA'], 'Normal', $svgstyle['fill-opacity'], false);
|
23455 |
$this->setAlpha($this->alpha['CA'], 'Normal', $svgstyle['fill-opacity'], false);
|
| Línea 23445... |
Línea 23484... |
| 23445 |
$regs = array();
|
23484 |
$regs = array();
|
| 23446 |
if (!empty($svgstyle['font'])) {
|
23485 |
if (!empty($svgstyle['font'])) {
|
| 23447 |
if (preg_match('/font-family[\s]*:[\s]*([^\;\"]*)/si', $svgstyle['font'], $regs)) {
|
23486 |
if (preg_match('/font-family[\s]*:[\s]*([^\;\"]*)/si', $svgstyle['font'], $regs)) {
|
| 23448 |
$font_family = $this->getFontFamilyName($regs[1]);
|
23487 |
$font_family = $this->getFontFamilyName($regs[1]);
|
| 23449 |
} else {
|
23488 |
} else {
|
| 23450 |
$font_family = $svgstyle['font-family'];
|
23489 |
$font_family = $this->getFontFamilyName($svgstyle['font-family']);
|
| 23451 |
}
|
23490 |
}
|
| 23452 |
if (preg_match('/font-size[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle['font'], $regs)) {
|
23491 |
if (preg_match('/font-size[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle['font'], $regs)) {
|
| 23453 |
$font_size = trim($regs[1]);
|
23492 |
$font_size = trim($regs[1]);
|
| 23454 |
} else {
|
23493 |
} else {
|
| 23455 |
$font_size = $svgstyle['font-size'];
|
23494 |
$font_size = $svgstyle['font-size'];
|
| Línea 23600... |
Línea 23639... |
| 23600 |
$yoffset = 0;
|
23639 |
$yoffset = 0;
|
| 23601 |
}
|
23640 |
}
|
| 23602 |
$params = array();
|
23641 |
$params = array();
|
| 23603 |
if (isset($val[2])) {
|
23642 |
if (isset($val[2])) {
|
| 23604 |
// get curve parameters
|
23643 |
// get curve parameters
|
| 23605 |
$rawparams = preg_split('/([\,\s]+)/si', trim($val[2]));
|
23644 |
preg_match_all('/-?\d*\.?\d+/', trim($val[2]), $matches);
|
| - |
|
23645 |
$rawparams = $matches[0];
|
| 23606 |
$params = array();
|
23646 |
$params = array();
|
| 23607 |
foreach ($rawparams as $ck => $cp) {
|
23647 |
foreach ($rawparams as $ck => $cp) {
|
| 23608 |
$params[$ck] = $this->getHTMLUnitToUnits($cp, 0, $this->svgunit, false);
|
23648 |
$params[$ck] = $this->getHTMLUnitToUnits($cp, 0, $this->svgunit, false);
|
| 23609 |
if (abs($params[$ck]) < $minlen) {
|
23649 |
if (abs($params[$ck]) < $minlen) {
|
| 23610 |
// approximate little values to zero
|
23650 |
// approximate little values to zero
|
| Línea 24425... |
Línea 24465... |
| 24425 |
if (preg_match('/^data:image\/[^;]+;base64,/', $img, $m) > 0) {
|
24465 |
if (preg_match('/^data:image\/[^;]+;base64,/', $img, $m) > 0) {
|
| 24426 |
// embedded image encoded as base64
|
24466 |
// embedded image encoded as base64
|
| 24427 |
$img = '@'.base64_decode(substr($img, strlen($m[0])));
|
24467 |
$img = '@'.base64_decode(substr($img, strlen($m[0])));
|
| 24428 |
} else {
|
24468 |
} else {
|
| 24429 |
// fix image path
|
24469 |
// fix image path
|
| - |
|
24470 |
if (strpos($img, '../') !== false) {
|
| - |
|
24471 |
// accessing parent folders is not allowed
|
| - |
|
24472 |
break;
|
| - |
|
24473 |
}
|
| 24430 |
if (!TCPDF_STATIC::empty_string($this->svgdir) AND (($img[0] == '.') OR (basename($img) == $img))) {
|
24474 |
if (!TCPDF_STATIC::empty_string($this->svgdir) AND (($img[0] == '.') OR (basename($img) == $img))) {
|
| 24431 |
// replace relative path with full server path
|
24475 |
// replace relative path with full server path
|
| 24432 |
$img = $this->svgdir.'/'.$img;
|
24476 |
$img = $this->svgdir.'/'.$img;
|
| 24433 |
}
|
24477 |
}
|
| 24434 |
if (($img[0] == '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
24478 |
if (($img[0] == '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|