X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Fincludes%2Ftcpdf.php;h=e30155a4fac3dc9f9020ae120475946341f9903b;hb=09d5c61846ddda0df907bb9c4e318cc7f1520653;hp=46ac9184477abd6f405f1224491c81b9deeef32a;hpb=b855efb8cb1880e44620b1a70b63bfe89110e880;p=fa-stable.git diff --git a/reporting/includes/tcpdf.php b/reporting/includes/tcpdf.php index 46ac9184..e30155a4 100644 --- a/reporting/includes/tcpdf.php +++ b/reporting/includes/tcpdf.php @@ -2,9 +2,9 @@ //============================================================+ // File name : tcpdf.php // Begin : 2002-08-03 -// Last Update : 2008-09-17 +// Last Update : 2008-09-19 // Author : Nicola Asuni - info@tecnick.com - http://www.tcpdf.org -// Version : 4.0.026_PHP4 +// Version : 4.0.027_PHP4 // License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html) // ---------------------------------------------------------------------------- // Copyright (C) 2002-2008 Nicola Asuni - Tecnick.com S.r.l. @@ -120,7 +120,7 @@ * @copyright 2004-2008 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com * @link http://www.tcpdf.org * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version 4.0.026_PHP4 + * @version 4.0.027_PHP4 */ /** @@ -141,7 +141,10 @@ * and * if (!defined("K_RE_PATTERN_ARABIC")) * 4. Parameter $unicode in constructor renamed to $uni. - * 4. Header function renamed to Header1 (due to conflict with FrontReport Header) + * 5. Header function renamed to Header1 (due to conflict with FrontReport Header) + * 6. Line 6190, SetLineWidth (cast of values to avoid problem in PHP 5.2.6 + * 7. Line 6261. ereg replaced by preg_match (with start and end delimiter) + * 8. Lines 8642,9256 and 9348. split replaced by preg_split. * ------------------------------------------------------------------------------- */ if (!defined("K_PATH_FONTS")) @@ -178,14 +181,14 @@ if (!class_exists('TCPDF')) { /** * define default PDF document producer */ - define('PDF_PRODUCER','TCPDF 4.0.026_PHP4 (http://www.tcpdf.org)'); + define('PDF_PRODUCER','TCPDF 4.0.027_PHP4 (http://www.tcpdf.org)'); /** * This is a PHP class for generating PDF documents without requiring external extensions.
* 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.
* @name TCPDF * @package com.tecnick.tcpdf - * @version 4.0.026_PHP4 + * @version 4.0.027_PHP4 * @author Nicola Asuni - info@tecnick.com * @link http://www.tcpdf.org * @license http://www.gnu.org/copyleft/lesser.html LGPL @@ -1756,7 +1759,8 @@ if (!class_exists('TCPDF')) { */ function Error($msg) { //Fatal error - die('TCPDF error: '.$msg); + display_error('TCPDF error: '.$msg); + exit; } /** @@ -2602,9 +2606,9 @@ if (!class_exists('TCPDF')) { if (isset($cw)) { unset($cw); } - include($this->_getfontpath().$file); + @include($this->_getfontpath().$file); if ((!isset($type)) OR (!isset($cw))) { - $this->Error('Could not include font definition file'); + $this->Error("Could not include font definition file: ".$file); } $i = count($this->fonts) + 1; // register CID font (all styles at once) @@ -5005,7 +5009,8 @@ if (!class_exists('TCPDF')) { * @access protected */ function _putheader() { - $this->_out('%PDF-'.$this->PDFVersion); + $this->buffer = '%PDF-'.$this->PDFVersion."\n".$this->buffer; +// $this->_out('%PDF-'.$this->PDFVersion); } /** @@ -5727,7 +5732,7 @@ if (!class_exists('TCPDF')) { */ function unhtmlentities($text_to_convert) { if (!$this->isunicode) { - return html_entity_decode($text_to_convert); + return html_entity_decode($text_to_convert, ENT_QUOTES); } return html_entity_decode_php4($text_to_convert); } @@ -6188,7 +6193,15 @@ if (!class_exists('TCPDF')) { function SetLineWidth($width) { //Set line width $this->LineWidth = $width; - $this->linestyleWidth = sprintf('%.2f w', ($width * $this->k)); + //$this->linestyleWidth = sprintf('%.2f w', ($width * $this->k)); + // FrontAccounting fix + // My PHP 5.2.6 environment gave an "Unsupported operand types" + // error for the multiplication on the next line some of the + // time when this method is called - I debugged and sometimes + // the $width parameter is some sort of weird array. I don't + // understand what's going on, but casting it to a (float) seems + // to "fix" the problem. -Jason Maas, 2009/09/25 + $this->linestyleWidth = sprintf('%.2f w', ((float) $width * (float) $this->k)); $this->_out($this->linestyleWidth); } @@ -6247,7 +6260,7 @@ if (!class_exists('TCPDF')) { if (isset($dash)) { $dash_string = ""; if ($dash) { - if (ereg("^.+,", $dash)) { + if (preg_match("/^.+,/", $dash)) { $tab = explode(",", $dash); } else { $tab = array($dash); @@ -7698,6 +7711,9 @@ if (!class_exists('TCPDF')) { if (empty($this->javascript)) { return; } + // the following two lines are uded to avoid form fields duplication after saving + $js1 = sprintf("ftcpdfdocsaved=this.addField('%s','%s',%d,[%.2f,%.2f,%.2f,%.2f]);", 'tcpdfdocsaved', 'text', 0, 0, 1, 0, 1); + $js2 = "getField('tcpdfdocsaved').value = 'saved';"; $this->_newobj(); $this->n_js = $this->n; $this->_out('<<'); @@ -7707,7 +7723,7 @@ if (!class_exists('TCPDF')) { $this->_newobj(); $this->_out('<<'); $this->_out('/S /JavaScript'); - $this->_out('/JS '.$this->_textstring($this->javascript)); + $this->_out('/JS '.$this->_textstring($js1."\n".$this->javascript."\n".$js2)); $this->_out('>>'); $this->_out('endobj'); } @@ -7744,6 +7760,8 @@ if (!class_exists('TCPDF')) { * @since 2.1.002 (2008-02-12) */ function _addfield($type, $name, $x, $y, $w, $h, $prop) { + // the followind avoid fields duplication after saving the document + $this->javascript .= "if(getField('tcpdfdocsaved').value != 'saved') {"; $k = $this->k; $this->javascript .= sprintf("f".$name."=this.addField('%s','%s',%d,[%.2f,%.2f,%.2f,%.2f]);", $name, $type, $this->PageNo()-1, $x*$k, ($this->h-$y)*$k+1, ($x+$w)*$k, ($this->h-$y-$h)*$k+1)."\n"; $this->javascript .= "f".$name.".textSize=".$this->FontSizePt.";\n"; @@ -7756,6 +7774,7 @@ if (!class_exists('TCPDF')) { $this->javascript .= "f".$name.".".$key."=".$val.";\n"; } $this->x += $w; + $this->javascript .= "}"; } /* @@ -8621,7 +8640,7 @@ if (!class_exists('TCPDF')) { $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $scale_x, 0, 0, $scale_y, $x1*(1-$scale_x), $y2*(1-$scale_y))); } // handle pc/unix/mac line endings - $lines = split("\r\n|[\r\n]", $data); + $lines = preg_split("/\r\n|[\r\n]/", $data); $u=0; $cnt = count($lines); for ($i=0; $i < $cnt; $i++) { @@ -9235,7 +9254,7 @@ if (!class_exists('TCPDF')) { if (isset($dom[$key]['style']['font-family'])) { // font family if (isset($dom[$key]['style']['font-family'])) { - $fontslist = split(",", strtolower($dom[$key]['style']['font-family'])); + $fontslist = preg_split("/,/", strtolower($dom[$key]['style']['font-family'])); foreach($fontslist as $font) { $font = trim(strtolower($font)); if (in_array($font, $this->fontlist)){ @@ -9327,7 +9346,7 @@ if (!class_exists('TCPDF')) { if ($dom[$key]['value'] == "font") { // font family if (isset($dom[$key]['attribute']['face'])) { - $fontslist = split(",", strtolower($dom[$key]['attribute']['face'])); + $fontslist = preg_split("/,/", strtolower($dom[$key]['attribute']['face'])); foreach($fontslist as $font) { $font = trim(strtolower($font)); if (in_array($font, $this->fontlist)){ @@ -9456,12 +9475,12 @@ if (!class_exists('TCPDF')) { $yshift = 0; $startlinepage = $this->page; $newline = true; - if (isset($this->footerpos[$this->page])) { + if (isset($this->footerlen[$this->page])) { $this->footerpos[$this->page] = strlen($this->pages[$this->page]) - $this->footerlen[$this->page]; - $startlinepos = $this->footerpos[$this->page]; } else { - $startlinepos = strlen($this->pages[$this->page]); + $this->footerpos[$this->page] = strlen($this->pages[$this->page]); } + $startlinepos = $this->footerpos[$this->page]; $lalign = $align; $plalign = $align; if ($this->rtl) { @@ -9547,12 +9566,12 @@ if (!class_exists('TCPDF')) { // the last line must be shifted to be aligned as requested $linew = abs($this->endlinex - $startlinex); $pstart = substr($this->pages[$startlinepage], 0, $startlinepos); - if (isset($opentagpos) AND isset($this->footerpos[$startlinepage])) { + if (isset($opentagpos) AND isset($this->footerlen[$startlinepage])) { $this->footerpos[$startlinepage] = strlen($this->pages[$startlinepage]) - $this->footerlen[$startlinepage]; $midpos = min($opentagpos, $this->footerpos[$startlinepage]); } elseif (isset($opentagpos)) { $midpos = $opentagpos; - } elseif (isset($this->footerpos[$startlinepage])) { + } elseif (isset($this->footerlen[$startlinepage])) { $this->footerpos[$startlinepage] = strlen($this->pages[$startlinepage]) - $this->footerlen[$startlinepage]; $midpos = $this->footerpos[$startlinepage]; } else { @@ -9613,12 +9632,12 @@ if (!class_exists('TCPDF')) { $startlinepos = $endlinepos; unset($endlinepos); } else { - if (isset($this->footerpos[$this->page])) { + if (isset($this->footerlen[$this->page])) { $this->footerpos[$this->page] = strlen($this->pages[$this->page]) - $this->footerlen[$this->page]; - $startlinepos = $this->footerpos[$this->page]; } else { - $startlinepos = strlen($this->pages[$this->page]); + $this->footerpos[$this->page] = strlen($this->pages[$this->page]); } + $startlinepos = $this->footerpos[$this->page]; } $plalign = $lalign; $this->newline = false; @@ -9704,12 +9723,12 @@ if (!class_exists('TCPDF')) { } // add rowspan information to table element if ($rowspan > 1) { - if (isset($this->footerpos[$this->page])) { + if (isset($this->footerlen[$this->page])) { $this->footerpos[$this->page] = strlen($this->pages[$this->page]) - $this->footerlen[$this->page]; - $trintmrkpos = $this->footerpos[$this->page]; } else { - $trintmrkpos = strlen($this->pages[$this->page]); + $this->footerpos[$this->page] = strlen($this->pages[$this->page]); } + $trintmrkpos = $this->footerpos[$this->page]; $trsid = array_push($dom[$table_el]['rowspans'], array('rowspan' => $rowspan, 'colspan' => $colspan, 'startpage' => $this->page, 'startx' => $this->x, 'starty' => $this->y, 'intmrkpos' => $trintmrkpos)); } $cellid = array_push($dom[$trid]['cellpos'], array('startx' => $this->x)); @@ -9769,12 +9788,12 @@ if (!class_exists('TCPDF')) { } else { // opening tag (or self-closing tag) if (!isset($opentagpos)) { - if (isset($this->footerpos[$this->page])) { + if (isset($this->footerlen[$this->page])) { $this->footerpos[$this->page] = strlen($this->pages[$this->page]) - $this->footerlen[$this->page]; - $opentagpos = $this->footerpos[$this->page]; } else { - $opentagpos = strlen($this->pages[$this->page]); + $this->footerpos[$this->page] = strlen($this->pages[$this->page]); } + $opentagpos = $this->footerpos[$this->page]; } $this->openHTMLTagHandler($dom, $key, $cell); } @@ -9851,12 +9870,12 @@ if (!class_exists('TCPDF')) { // the last line must be shifted to be aligned as requested $linew = abs($this->endlinex - $startlinex); $pstart = substr($this->pages[$startlinepage], 0, $startlinepos); - if (isset($opentagpos) AND isset($this->footerpos[$startlinepage])) { + if (isset($opentagpos) AND isset($this->footerlen[$startlinepage])) { $this->footerpos[$startlinepage] = strlen($this->pages[$startlinepage]) - $this->footerlen[$startlinepage]; $midpos = min($opentagpos, $this->footerpos[$startlinepage]); } elseif (isset($opentagpos)) { $midpos = $opentagpos; - } elseif (isset($this->footerpos[$startlinepage])) { + } elseif (isset($this->footerlen[$startlinepage])) { $this->footerpos[$startlinepage] = strlen($this->pages[$startlinepage]) - $this->footerlen[$startlinepage]; $midpos = $this->footerpos[$startlinepage]; } else {