update tcpdf
This commit is contained in:
@@ -27,11 +27,6 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
/************************************************************************
|
||||
* This file contains code parts copied from TCPDF software library
|
||||
* that is published under GNU Lesser General Public License.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Pdf;
|
||||
|
||||
define('K_TCPDF_EXTERNAL_CONFIG', true);
|
||||
@@ -69,6 +64,8 @@ require "vendor/tecnickcom/tcpdf/tcpdf.php";
|
||||
use \TCPDF_STATIC;
|
||||
use \TCPDF_FONTS;
|
||||
|
||||
use Espo\Core\Utils\Util;
|
||||
|
||||
class Tcpdf extends \TCPDF
|
||||
{
|
||||
protected $footerHtml = '';
|
||||
@@ -169,167 +166,6 @@ class Tcpdf extends \TCPDF
|
||||
$this->SetAutoPageBreak($autoPageBreak, $breakMargin);
|
||||
}
|
||||
|
||||
protected function _putpages()
|
||||
{
|
||||
$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
|
||||
// get internal aliases for page numbers
|
||||
$pnalias = $this->getAllInternalPageNumberAliases();
|
||||
$num_pages = $this->numpages;
|
||||
$ptpa = TCPDF_STATIC::formatPageNumber(($this->starting_page_number + $num_pages - 1));
|
||||
$ptpu = TCPDF_FONTS::UTF8ToUTF16BE($ptpa, false, $this->isunicode, $this->CurrentFont);
|
||||
$ptp_num_chars = $this->GetNumChars($ptpa);
|
||||
$pagegroupnum = 0;
|
||||
$groupnum = 0;
|
||||
$ptgu = 1;
|
||||
$ptga = 1;
|
||||
$ptg_num_chars = 1;
|
||||
for ($n = 1; $n <= $num_pages; ++$n) {
|
||||
// get current page
|
||||
$temppage = $this->getPageBuffer($n);
|
||||
$pagelen = strlen($temppage);
|
||||
// set replacements for total pages number
|
||||
$pnpa = TCPDF_STATIC::formatPageNumber(($this->starting_page_number + $n - 1));
|
||||
$pnpu = TCPDF_FONTS::UTF8ToUTF16BE($pnpa, false, $this->isunicode, $this->CurrentFont);
|
||||
$pnp_num_chars = $this->GetNumChars($pnpa);
|
||||
$pdiff = 0; // difference used for right shift alignment of page numbers
|
||||
$gdiff = 0; // difference used for right shift alignment of page group numbers
|
||||
if (!empty($this->pagegroups)) {
|
||||
if (isset($this->newpagegroup[$n])) {
|
||||
$pagegroupnum = 0;
|
||||
++$groupnum;
|
||||
$ptga = TCPDF_STATIC::formatPageNumber($this->pagegroups[$groupnum]);
|
||||
$ptgu = TCPDF_FONTS::UTF8ToUTF16BE($ptga, false, $this->isunicode, $this->CurrentFont);
|
||||
$ptg_num_chars = $this->GetNumChars($ptga);
|
||||
}
|
||||
++$pagegroupnum;
|
||||
$pnga = TCPDF_STATIC::formatPageNumber($pagegroupnum);
|
||||
$pngu = TCPDF_FONTS::UTF8ToUTF16BE($pnga, false, $this->isunicode, $this->CurrentFont);
|
||||
|
||||
$pnga = $pngu;
|
||||
|
||||
$png_num_chars = $this->GetNumChars($pnga);
|
||||
// replace page numbers
|
||||
$replace = array();
|
||||
$replace[] = array($ptgu, $ptg_num_chars, 9, $pnalias[2]['u']);
|
||||
$replace[] = array($ptga, $ptg_num_chars, 7, $pnalias[2]['a']);
|
||||
$replace[] = array($pngu, $png_num_chars, 9, $pnalias[3]['u']);
|
||||
$replace[] = array($pnga, $png_num_chars, 7, $pnalias[3]['a']);
|
||||
list($temppage, $gdiff) = TCPDF_STATIC::replacePageNumAliases($temppage, $replace, $gdiff);
|
||||
}
|
||||
// replace page numbers
|
||||
$replace = array();
|
||||
$replace[] = array($ptpu, $ptp_num_chars, 9, $pnalias[0]['u']);
|
||||
$replace[] = array($ptpa, $ptp_num_chars, 7, $pnalias[0]['a']);
|
||||
$replace[] = array($pnpu, $pnp_num_chars, 9, $pnalias[1]['u']);
|
||||
|
||||
$pnpa = $pnpu;
|
||||
|
||||
$replace[] = array($pnpa, $pnp_num_chars, 7, $pnalias[1]['a']);
|
||||
list($temppage, $pdiff) = TCPDF_STATIC::replacePageNumAliases($temppage, $replace, $pdiff);
|
||||
// replace right shift alias
|
||||
$temppage = $this->replaceRightShiftPageNumAliases($temppage, $pnalias[4], max($pdiff, $gdiff));
|
||||
// replace EPS marker
|
||||
$temppage = str_replace($this->epsmarker, '', $temppage);
|
||||
//Page
|
||||
$this->page_obj_id[$n] = $this->_newobj();
|
||||
$out = '<<';
|
||||
$out .= ' /Type /Page';
|
||||
$out .= ' /Parent 1 0 R';
|
||||
if (empty($this->signature_data['approval']) OR ($this->signature_data['approval'] != 'A')) {
|
||||
$out .= ' /LastModified '.$this->_datestring(0, $this->doc_modification_timestamp);
|
||||
}
|
||||
$out .= ' /Resources 2 0 R';
|
||||
foreach ($this->page_boxes as $box) {
|
||||
$out .= ' /'.$box;
|
||||
$out .= sprintf(' [%F %F %F %F]', $this->pagedim[$n][$box]['llx'], $this->pagedim[$n][$box]['lly'], $this->pagedim[$n][$box]['urx'], $this->pagedim[$n][$box]['ury']);
|
||||
}
|
||||
if (isset($this->pagedim[$n]['BoxColorInfo']) AND !empty($this->pagedim[$n]['BoxColorInfo'])) {
|
||||
$out .= ' /BoxColorInfo <<';
|
||||
foreach ($this->page_boxes as $box) {
|
||||
if (isset($this->pagedim[$n]['BoxColorInfo'][$box])) {
|
||||
$out .= ' /'.$box.' <<';
|
||||
if (isset($this->pagedim[$n]['BoxColorInfo'][$box]['C'])) {
|
||||
$color = $this->pagedim[$n]['BoxColorInfo'][$box]['C'];
|
||||
$out .= ' /C [';
|
||||
$out .= sprintf(' %F %F %F', ($color[0] / 255), ($color[1] / 255), ($color[2] / 255));
|
||||
$out .= ' ]';
|
||||
}
|
||||
if (isset($this->pagedim[$n]['BoxColorInfo'][$box]['W'])) {
|
||||
$out .= ' /W '.($this->pagedim[$n]['BoxColorInfo'][$box]['W'] * $this->k);
|
||||
}
|
||||
if (isset($this->pagedim[$n]['BoxColorInfo'][$box]['S'])) {
|
||||
$out .= ' /S /'.$this->pagedim[$n]['BoxColorInfo'][$box]['S'];
|
||||
}
|
||||
if (isset($this->pagedim[$n]['BoxColorInfo'][$box]['D'])) {
|
||||
$dashes = $this->pagedim[$n]['BoxColorInfo'][$box]['D'];
|
||||
$out .= ' /D [';
|
||||
foreach ($dashes as $dash) {
|
||||
$out .= sprintf(' %F', ($dash * $this->k));
|
||||
}
|
||||
$out .= ' ]';
|
||||
}
|
||||
$out .= ' >>';
|
||||
}
|
||||
}
|
||||
$out .= ' >>';
|
||||
}
|
||||
$out .= ' /Contents '.($this->n + 1).' 0 R';
|
||||
$out .= ' /Rotate '.$this->pagedim[$n]['Rotate'];
|
||||
if (!$this->pdfa_mode) {
|
||||
$out .= ' /Group << /Type /Group /S /Transparency /CS /DeviceRGB >>';
|
||||
}
|
||||
if (isset($this->pagedim[$n]['trans']) AND !empty($this->pagedim[$n]['trans'])) {
|
||||
// page transitions
|
||||
if (isset($this->pagedim[$n]['trans']['Dur'])) {
|
||||
$out .= ' /Dur '.$this->pagedim[$n]['trans']['Dur'];
|
||||
}
|
||||
$out .= ' /Trans <<';
|
||||
$out .= ' /Type /Trans';
|
||||
if (isset($this->pagedim[$n]['trans']['S'])) {
|
||||
$out .= ' /S /'.$this->pagedim[$n]['trans']['S'];
|
||||
}
|
||||
if (isset($this->pagedim[$n]['trans']['D'])) {
|
||||
$out .= ' /D '.$this->pagedim[$n]['trans']['D'];
|
||||
}
|
||||
if (isset($this->pagedim[$n]['trans']['Dm'])) {
|
||||
$out .= ' /Dm /'.$this->pagedim[$n]['trans']['Dm'];
|
||||
}
|
||||
if (isset($this->pagedim[$n]['trans']['M'])) {
|
||||
$out .= ' /M /'.$this->pagedim[$n]['trans']['M'];
|
||||
}
|
||||
if (isset($this->pagedim[$n]['trans']['Di'])) {
|
||||
$out .= ' /Di '.$this->pagedim[$n]['trans']['Di'];
|
||||
}
|
||||
if (isset($this->pagedim[$n]['trans']['SS'])) {
|
||||
$out .= ' /SS '.$this->pagedim[$n]['trans']['SS'];
|
||||
}
|
||||
if (isset($this->pagedim[$n]['trans']['B'])) {
|
||||
$out .= ' /B '.$this->pagedim[$n]['trans']['B'];
|
||||
}
|
||||
$out .= ' >>';
|
||||
}
|
||||
$out .= $this->_getannotsrefs($n);
|
||||
$out .= ' /PZ '.$this->pagedim[$n]['PZ'];
|
||||
$out .= ' >>';
|
||||
$out .= "\n".'endobj';
|
||||
$this->_out($out);
|
||||
//Page content
|
||||
$p = ($this->compress) ? gzcompress($temppage) : $temppage;
|
||||
$this->_newobj();
|
||||
$p = $this->_getrawstream($p);
|
||||
$this->_out('<<'.$filter.'/Length '.strlen($p).'>> stream'."\n".$p."\n".'endstream'."\n".'endobj');
|
||||
}
|
||||
//Pages root
|
||||
$out = $this->_getobj(1)."\n";
|
||||
$out .= '<< /Type /Pages /Kids [';
|
||||
foreach($this->page_obj_id as $page_obj) {
|
||||
$out .= ' '.$page_obj.' 0 R';
|
||||
}
|
||||
$out .= ' ] /Count '.$num_pages.' >>';
|
||||
$out .= "\n".'endobj';
|
||||
$this->_out($out);
|
||||
}
|
||||
|
||||
public function Output($name = 'doc.pdf', $dest = 'I')
|
||||
{
|
||||
if ($dest === 'I' && !$this->sign && php_sapi_name() != 'cli') {
|
||||
@@ -337,7 +173,7 @@ class Tcpdf extends \TCPDF
|
||||
$this->Close();
|
||||
}
|
||||
$name = preg_replace('/[\s]+/', '_', $name);
|
||||
$name = \Espo\Core\Utils\Util::sanitizeFileName($name);
|
||||
$name = Util::sanitizeFileName($name);
|
||||
|
||||
if (ob_get_contents()) {
|
||||
$this->Error('Some data has already been output, can\'t send PDF file');
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
"yzalis/identicon": "*",
|
||||
"zordius/lightncandy": "1.*",
|
||||
"composer/semver": "^1.4",
|
||||
"tecnickcom/tcpdf": "^6.2",
|
||||
"tecnickcom/tcpdf": "^6.3",
|
||||
"zbateson/mail-mime-parser": "1.2.*",
|
||||
"phpoffice/phpspreadsheet": "^1.10",
|
||||
"spatie/async": "dev-for-espocrm",
|
||||
|
||||
Generated
+7
-7
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c581826c89ac8f6b8d1c708cf83f77f1",
|
||||
"content-hash": "7df8ab50657d690174bf26a67aa0afdf",
|
||||
"packages": [
|
||||
{
|
||||
"name": "cboden/ratchet",
|
||||
@@ -3582,16 +3582,16 @@
|
||||
},
|
||||
{
|
||||
"name": "tecnickcom/tcpdf",
|
||||
"version": "6.2.17",
|
||||
"version": "6.3.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tecnickcom/TCPDF.git",
|
||||
"reference": "64fc19439863e1b1314487a72a74d9bfd0b55a53"
|
||||
"reference": "19a535eaa7fb1c1cac499109deeb1a7a201b4549"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/64fc19439863e1b1314487a72a74d9bfd0b55a53",
|
||||
"reference": "64fc19439863e1b1314487a72a74d9bfd0b55a53",
|
||||
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/19a535eaa7fb1c1cac499109deeb1a7a201b4549",
|
||||
"reference": "19a535eaa7fb1c1cac499109deeb1a7a201b4549",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3620,7 +3620,7 @@
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-3.0"
|
||||
"LGPL-3.0-only"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
@@ -3640,7 +3640,7 @@
|
||||
"pdf417",
|
||||
"qrcode"
|
||||
],
|
||||
"time": "2018-02-24T11:48:20+00:00"
|
||||
"time": "2020-02-14T14:20:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "true/punycode",
|
||||
|
||||
Reference in New Issue
Block a user