From df413784f7455c324ae46deeb19dcf39b987063a Mon Sep 17 00:00:00 2001 From: KRav Date: Tue, 22 Apr 2014 12:24:51 +0200 Subject: [PATCH] The define of TCPDF constants was causing an error (Constant PDF_PAGE_FORMAT etc. already defined), if you use TCPDF within own plugins and use the print PDF feature of LS. The if-statement, avoid the error, if the constant is tried to define again. --- application/libraries/admin/pdf.php | 904 ++++++++++++++-------------- 1 file changed, 452 insertions(+), 452 deletions(-) diff --git a/application/libraries/admin/pdf.php b/application/libraries/admin/pdf.php index 80efd50992b..2676091b667 100644 --- a/application/libraries/admin/pdf.php +++ b/application/libraries/admin/pdf.php @@ -13,7 +13,7 @@ */ # override the default TCPDF config file if(!defined('K_TCPDF_EXTERNAL_CONFIG')) { - define('K_TCPDF_EXTERNAL_CONFIG', TRUE); + define('K_TCPDF_EXTERNAL_CONFIG', TRUE); } # include TCPDF @@ -25,138 +25,138 @@ /** * page format */ -define ('PDF_PAGE_FORMAT', 'A4'); +(!defined ('PDF_PAGE_FORMAT')) ? (define ('PDF_PAGE_FORMAT', 'A4')):''; /** * page orientation (P=portrait, L=landscape) */ -define ('PDF_PAGE_ORIENTATION', 'P'); +(!defined ('PDF_PAGE_ORIENTATION')) ? (define('PDF_PAGE_ORIENTATION', 'P')):''; /** * document creator */ -define ('PDF_CREATOR', 'TCPDF'); +(!defined ('PDF_CREATOR'))?(define ('PDF_CREATOR', 'TCPDF')):''; /** * document author */ -define ('PDF_AUTHOR', 'TCPDF'); +(!defined ('PDF_AUTHOR'))? (define ('PDF_AUTHOR', 'TCPDF')):''; /** * header title */ -define ('PDF_HEADER_TITLE', 'TCPDF Example'); +(!defined ('PDF_HEADER_TITLE'))? (define ('PDF_HEADER_TITLE', 'TCPDF Example')):''; /** * header description string */ -define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); +(!defined ('PDF_HEADER_STRING'))? (define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org")):''; /** * image logo */ -define ('PDF_HEADER_LOGO', 'tcpdf_logo.jpg'); +(!defined ('PDF_HEADER_LOGO'))? (define ('PDF_HEADER_LOGO', 'tcpdf_logo.jpg')):''; /** * header logo image width [mm] */ -define ('PDF_HEADER_LOGO_WIDTH', 30); +(!defined ('PDF_HEADER_LOGO_WIDTH'))? (define ('PDF_HEADER_LOGO_WIDTH', 30)):''; /** * document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch] */ -define ('PDF_UNIT', 'mm'); +(!defined ('PDF_UNIT'))? (define ('PDF_UNIT', 'mm')):''; /** * header margin */ -define ('PDF_MARGIN_HEADER', 5); +(!defined ('PDF_MARGIN_HEADER'))? (define ('PDF_MARGIN_HEADER', 5)):''; /** * footer margin */ -define ('PDF_MARGIN_FOOTER', 10); +(!defined ('PDF_MARGIN_FOOTER'))? (define ('PDF_MARGIN_FOOTER', 10)):''; /** * top margin */ -define ('PDF_MARGIN_TOP', 27); +(!defined ('PDF_MARGIN_TOP'))? (define ('PDF_MARGIN_TOP', 27)):''; /** * bottom margin */ -define ('PDF_MARGIN_BOTTOM', 25); +(!defined ('PDF_MARGIN_BOTTOM'))? (define ('PDF_MARGIN_BOTTOM', 25)):''; /** * left margin */ -define ('PDF_MARGIN_LEFT', 15); +(!defined ('PDF_MARGIN_LEFT'))? (define ('PDF_MARGIN_LEFT', 15)):''; /** * right margin */ -define ('PDF_MARGIN_RIGHT', 15); +(!defined ('PDF_MARGIN_RIGHT'))? (define ('PDF_MARGIN_RIGHT', 15)):''; /** * default main font name */ -define ('PDF_FONT_NAME_MAIN', 'helvetica'); +(!defined ('PDF_FONT_NAME_MAIN'))? (define ('PDF_FONT_NAME_MAIN', 'helvetica')):''; /** * default main font size */ -define ('PDF_FONT_SIZE_MAIN', 10); +(!defined ('PDF_FONT_SIZE_MAIN'))? (define ('PDF_FONT_SIZE_MAIN', 10)):''; /** * default data font name */ -define ('PDF_FONT_NAME_DATA', 'helvetica'); +(!defined ('PDF_FONT_NAME_DATA'))? (define ('PDF_FONT_NAME_DATA', 'helvetica')):''; /** * default data font size */ -define ('PDF_FONT_SIZE_DATA', 8); +(!defined ('PDF_FONT_SIZE_DATA'))? (define ('PDF_FONT_SIZE_DATA', 8)):''; /** * default monospaced font name */ -define ('PDF_FONT_MONOSPACED', 'courier'); +(!defined ('PDF_FONT_MONOSPACED'))? (define ('PDF_FONT_MONOSPACED', 'courier')):''; /** * ratio used to adjust the conversion of pixels to user units */ -define ('PDF_IMAGE_SCALE_RATIO', 1.25); +(!defined ('PDF_IMAGE_SCALE_RATIO'))? (define ('PDF_IMAGE_SCALE_RATIO', 1.25)):''; /** * magnification factor for titles */ -define('HEAD_MAGNIFICATION', 1.1); +(!defined('HEAD_MAGNIFICATION'))? (define('HEAD_MAGNIFICATION', 1.1)):''; /** * height of cell repect font height */ -define('K_CELL_HEIGHT_RATIO', 1.25); +(!defined('K_CELL_HEIGHT_RATIO'))? (define('K_CELL_HEIGHT_RATIO', 1.25)):''; /** * title magnification respect main font size */ -define('K_TITLE_MAGNIFICATION', 1.3); +(!defined('K_TITLE_MAGNIFICATION'))? (define('K_TITLE_MAGNIFICATION', 1.3)):''; /** * reduction factor for small font */ -define('K_SMALL_RATIO', 2/3); +(!defined('K_SMALL_RATIO'))? (define('K_SMALL_RATIO', 2/3)):''; /** * set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language */ -define('K_THAI_TOPCHARS', true); +(!defined('K_THAI_TOPCHARS'))? (define('K_THAI_TOPCHARS', true)):''; /** * if true allows to call TCPDF methods using HTML syntax * IMPORTANT: For security reason, disable this feature if you are printing user HTML content. */ -define('K_TCPDF_CALLS_IN_HTML', true); +(!defined('K_TCPDF_CALLS_IN_HTML'))? (define('K_TCPDF_CALLS_IN_HTML', true)):''; /************************************************************ * TCPDF - CodeIgniter Integration @@ -169,444 +169,444 @@ class pdf extends TCPDF { - /** - * TCPDF system constants that map to settings in our config file - * - * @var array - * @access private - */ - private $cfg_constant_map = array( - 'K_PATH_MAIN' => 'base_directory', - 'K_PATH_URL' => 'base_url', - 'K_PATH_FONTS' => 'fonts_directory', - 'K_PATH_CACHE' => 'cache_directory', - 'K_PATH_IMAGES' => 'image_directory', - 'K_BLANK_IMAGE' => 'blank_image', - 'K_SMALL_RATIO' => 'small_font_ratio', - ); - - - /** - * Settings from our APPPATH/config/tcpdf.php file - * - * @var array - * @access private - */ - private $_config = array(); - - /** - * Set _config for pdf - * @access public - * @param mixed $tcpdf - * @return - */ - public function setConfig($tcpdf) { - $this->_config=$tcpdf; - } - - - /** - * Initialize and configure TCPDF with the settings in our config file - * - */ - function __construct() { - - # load the config file - require(APPPATH.'config/tcpdf'.EXT); - $this->_config = $tcpdf; - unset($tcpdf); - - - - # set the TCPDF system constants - foreach($this->cfg_constant_map as $const => $cfgkey) { - if(!defined($const)) { - define($const, $this->_config[$cfgkey]); - #echo sprintf("Defining: %s = %s\n
", $const, $this->_config[$cfgkey]); - } - } - - # initialize TCPDF - parent::__construct( - $this->_config['page_orientation'], - $this->_config['page_unit'], - $this->_config['page_format'], - $this->_config['unicode'], - $this->_config['encoding'], - $this->_config['enable_disk_cache'] - ); - - - # language settings - if(is_file($this->_config['language_file'])) { - include($this->_config['language_file']); - $this->setLanguageArray($l); - unset($l); - } - - # margin settings - $this->SetMargins($this->_config['margin_left'], $this->_config['margin_top'], $this->_config['margin_right']); - - # header settings - $this->print_header = $this->_config['header_on']; - #$this->print_header = FALSE; - $this->setHeaderFont(array($this->_config['header_font'], '', $this->_config['header_font_size'])); - $this->setHeaderMargin($this->_config['header_margin']); - $this->SetHeaderData(); - //$this->SetHeaderData( - // $this->_config['header_logo'], - // $this->_config['header_logo_width'], - // $this->_config['header_title'], - // $this->_config['header_string'] - //); - - # footer settings - $this->print_footer = $this->_config['footer_on']; - $this->setFooterFont(array($this->_config['footer_font'], '', $this->_config['footer_font_size'])); - $this->setFooterMargin($this->_config['footer_margin']); - - # page break - $this->SetAutoPageBreak($this->_config['page_break_auto'], $this->_config['footer_margin']); - - # cell settings - $this->cMargin = $this->_config['cell_padding']; - $this->setCellHeightRatio($this->_config['cell_height_ratio']); - - # document properties - $this->author = $this->_config['author']; - $this->creator = $this->_config['creator']; - - # font settings - #$this->SetFont($this->_config['page_font'], '', $this->_config['page_font_size']); - - # image settings - $this->setImageScale($this->_config['image_scale']); - - } - - /** - * - * obsolete - * @param $text - * @param $format - * @return unknown_type - */ - function intopdf($text,$format='') + /** + * TCPDF system constants that map to settings in our config file + * + * @var array + * @access private + */ + private $cfg_constant_map = array( + 'K_PATH_MAIN' => 'base_directory', + 'K_PATH_URL' => 'base_url', + 'K_PATH_FONTS' => 'fonts_directory', + 'K_PATH_CACHE' => 'cache_directory', + 'K_PATH_IMAGES' => 'image_directory', + 'K_BLANK_IMAGE' => 'blank_image', + 'K_SMALL_RATIO' => 'small_font_ratio', + ); + + + /** + * Settings from our APPPATH/config/tcpdf.php file + * + * @var array + * @access private + */ + private $_config = array(); + + /** + * Set _config for pdf + * @access public + * @param mixed $tcpdf + * @return + */ + public function setConfig($tcpdf) { + $this->_config=$tcpdf; + } + + + /** + * Initialize and configure TCPDF with the settings in our config file + * + */ + function __construct() { + + # load the config file + require(APPPATH.'config/tcpdf'.EXT); + $this->_config = $tcpdf; + unset($tcpdf); + + + + # set the TCPDF system constants + foreach($this->cfg_constant_map as $const => $cfgkey) { + if(!defined($const)) { + define($const, $this->_config[$cfgkey]); + #echo sprintf("Defining: %s = %s\n
", $const, $this->_config[$cfgkey]); + } + } + + # initialize TCPDF + parent::__construct( + $this->_config['page_orientation'], + $this->_config['page_unit'], + $this->_config['page_format'], + $this->_config['unicode'], + $this->_config['encoding'], + $this->_config['enable_disk_cache'] + ); + + + # language settings + if(is_file($this->_config['language_file'])) { + include($this->_config['language_file']); + $this->setLanguageArray($l); + unset($l); + } + + # margin settings + $this->SetMargins($this->_config['margin_left'], $this->_config['margin_top'], $this->_config['margin_right']); + + # header settings + $this->print_header = $this->_config['header_on']; + #$this->print_header = FALSE; + $this->setHeaderFont(array($this->_config['header_font'], '', $this->_config['header_font_size'])); + $this->setHeaderMargin($this->_config['header_margin']); + $this->SetHeaderData(); + //$this->SetHeaderData( + // $this->_config['header_logo'], + // $this->_config['header_logo_width'], + // $this->_config['header_title'], + // $this->_config['header_string'] + //); + + # footer settings + $this->print_footer = $this->_config['footer_on']; + $this->setFooterFont(array($this->_config['footer_font'], '', $this->_config['footer_font_size'])); + $this->setFooterMargin($this->_config['footer_margin']); + + # page break + $this->SetAutoPageBreak($this->_config['page_break_auto'], $this->_config['footer_margin']); + + # cell settings + $this->cMargin = $this->_config['cell_padding']; + $this->setCellHeightRatio($this->_config['cell_height_ratio']); + + # document properties + $this->author = $this->_config['author']; + $this->creator = $this->_config['creator']; + + # font settings + #$this->SetFont($this->_config['page_font'], '', $this->_config['page_font_size']); + + # image settings + $this->setImageScale($this->_config['image_scale']); + + } + + /** + * + * obsolete + * @param $text + * @param $format + * @return unknown_type + */ + function intopdf($text,$format='') + { + $text = $this->delete_html($text); + $oldformat = $this->FontStyle; + $this->SetFont('',$format,$this->FontSizePt); + $this->Write(5,$text); + $this->ln(5); + $this->SetFont('',$oldformat,$this->FontSizePt); + } + /** + * + * obsolete + * @param $text + * @return unknown_type + */ + function helptextintopdf($text) + { + $oldsize = $this->FontSizePt; + $this->SetFontSize($oldsize-2); + $this->Write(5,$this->delete_html($text)); + $this->ln(5); + $this->SetFontSize($oldsize); + } + /** + * + * writes a big title in the page + description + * @param $title + * @param $description + * @return unknown_type + */ + function titleintopdf($title,$description='') + { + if(!empty($title)) + { + $title = $this->delete_html($title); + $oldsize = $this->FontSizePt; + $this->SetFontSize($oldsize+4); + $this->Line(5,$this->y,($this->w-5),$this->y); + $this->ln(3); + $this->MultiCell('','',$title,'','C',0); + if(!empty($description) && isset($description)) + { + $description = $this->delete_html($description); + $this->ln(7); + $this->SetFontSize($oldsize+2); + $this->MultiCell('','',$description,'','C',0); + $this->ln(2); + } + else + { + $this->ln(4); + } + $this->Line(5,$this->y,($this->w-5),$this->y); + $this->ln(5); + $this->SetFontSize($oldsize); + } + } + /** + * + * Creates a Table with equal cell width and Bold text. Used as Head for equalTable() + * @param $array(0=>) + * @return unknown_type + */ + function tablehead($array) + { + //$maxwidth = array(); + $maxwidth = $this->getEqualWidth($array); + $oldStyle = $this->FontStyle; + $this->SetFont($this->FontFamily, 'B', $this->FontSizePt); + for($a=0;$aCell($maxwidth,4,$this->delete_html($array[$a][$b]),0,0,'L'); + } + $this->ln(); + } + $this->ln(5); + $this->SetFont($this->FontFamily, $oldStyle, $this->FontSizePt); + } + /** + * + * Creates a Table with equal cell width. + * @param $array - table array( 0=> array("td", "td", "td"), + * 1=> array("td", "td", "td")) + * @param $modulo - fills each second row with a light-grey for better visibility. Default is on turn off with 0 + * @return unknown_type + */ + function equalTable($array, $modulo=1) + { + //$maxwidth = array(); + $maxwidth = $this->getEqualWidth($array); + $this->SetFillColor(220, 220, 220); + for($a=0;$aCell($maxwidth,4,$this->delete_html($array[$a][$b]),0,0,'L',$fill); + + } + $this->ln(); + } + $this->ln(5); + } + /** + * + * creates a table using the full width of page + * @param $array - table array( 0=> array("td", "td", "td"), + * 1=> array("td", "td", "td")) + * @param $modulo - fills each second row with a light-grey for better visibility. Default is off, turn on with 1 + * @return unknown_type + */ + function tableintopdf($array, $modulo=1 ) + { + $maxwidth = array(); + $maxwidth = $this->getFullWidth($array); + + $this->SetFillColor(220, 220, 220); + for($a=0;$a"; + $this->Cell($maxwidth[$b],4,$this->delete_html($array[$a][$b]),0,0,'L',$fill); + } + $this->ln(); + } + $this->ln(5); + } + /** + * + * creates a table with a bold head using the full width of page + * @param $head - head array( 0=> array("th", "th", "th")) + * @param $table - table array( 0=> array("td", "td", "td"), + * 1=> array("td", "td", "td")) + * @param $modulo - fills each second row with a light-grey for better visibility. Default is on, turn off with 0 + * @return unknown_type + */ + function headTable($head, $table, $modulo=1 ) + { + $array = array_merge_recursive($head, $table); + //print_r($array); + $maxwidth = array(); + $maxwidth = $this->getFullWidth($array); + + $this->SetFillColor(220, 220, 220); + for($a=0;$adelete_html($text); - $oldformat = $this->FontStyle; - $this->SetFont('',$format,$this->FontSizePt); - $this->Write(5,$text); - $this->ln(5); - $this->SetFont('',$oldformat,$this->FontSizePt); + $bEndOfCell=1; } - /** - * - * obsolete - * @param $text - * @return unknown_type - */ - function helptextintopdf($text) - { - $oldsize = $this->FontSizePt; - $this->SetFontSize($oldsize-2); - $this->Write(5,$this->delete_html($text)); - $this->ln(5); - $this->SetFontSize($oldsize); - } - /** - * - * writes a big title in the page + description - * @param $title - * @param $description - * @return unknown_type - */ - function titleintopdf($title,$description='') - { - if(!empty($title)) - { - $title = $this->delete_html($title); - $oldsize = $this->FontSizePt; - $this->SetFontSize($oldsize+4); - $this->Line(5,$this->y,($this->w-5),$this->y); - $this->ln(3); - $this->MultiCell('','',$title,'','C',0); - if(!empty($description) && isset($description)) - { - $description = $this->delete_html($description); - $this->ln(7); - $this->SetFontSize($oldsize+2); - $this->MultiCell('','',$description,'','C',0); - $this->ln(2); - } - else - { - $this->ln(4); - } - $this->Line(5,$this->y,($this->w-5),$this->y); - $this->ln(5); - $this->SetFontSize($oldsize); - } - } - /** - * - * Creates a Table with equal cell width and Bold text. Used as Head for equalTable() - * @param $array(0=>) - * @return unknown_type - */ - function tablehead($array) - { - //$maxwidth = array(); - $maxwidth = $this->getEqualWidth($array); - $oldStyle = $this->FontStyle; - $this->SetFont($this->FontFamily, 'B', $this->FontSizePt); - for($a=0;$aCell($maxwidth,4,$this->delete_html($array[$a][$b]),0,0,'L'); - } - $this->ln(); - } - $this->ln(5); - $this->SetFont($this->FontFamily, $oldStyle, $this->FontSizePt); - } - /** - * - * Creates a Table with equal cell width. - * @param $array - table array( 0=> array("td", "td", "td"), - * 1=> array("td", "td", "td")) - * @param $modulo - fills each second row with a light-grey for better visibility. Default is on turn off with 0 - * @return unknown_type - */ - function equalTable($array, $modulo=1) - { - //$maxwidth = array(); - $maxwidth = $this->getEqualWidth($array); - $this->SetFillColor(220, 220, 220); - for($a=0;$aCell($maxwidth,4,$this->delete_html($array[$a][$b]),0,0,'L',$fill); - - } - $this->ln(); - } - $this->ln(5); - } - /** - * - * creates a table using the full width of page - * @param $array - table array( 0=> array("td", "td", "td"), - * 1=> array("td", "td", "td")) - * @param $modulo - fills each second row with a light-grey for better visibility. Default is off, turn on with 1 - * @return unknown_type - */ - function tableintopdf($array, $modulo=1 ) - { - $maxwidth = array(); - $maxwidth = $this->getFullWidth($array); - - $this->SetFillColor(220, 220, 220); - for($a=0;$a"; - $this->Cell($maxwidth[$b],4,$this->delete_html($array[$a][$b]),0,0,'L',$fill); - } - $this->ln(); - } - $this->ln(5); - } - /** - * - * creates a table with a bold head using the full width of page - * @param $head - head array( 0=> array("th", "th", "th")) - * @param $table - table array( 0=> array("td", "td", "td"), - * 1=> array("td", "td", "td")) - * @param $modulo - fills each second row with a light-grey for better visibility. Default is on, turn off with 0 - * @return unknown_type - */ - function headTable($head, $table, $modulo=1 ) + + if($a==0) { - $array = array_merge_recursive($head, $table); - //print_r($array); - $maxwidth = array(); - $maxwidth = $this->getFullWidth($array); - - $this->SetFillColor(220, 220, 220); - for($a=0;$aFontStyle; - $this->SetFont($this->FontFamily, 'B', $this->FontSizePt); - - if ($maxwidth[$b] > 140) $maxwidth[$b]=130; - if ($maxwidth[$b] < 25) $maxwidth[$b]=25; - $this->MultiCell($maxwidth[$b],6,$this->delete_html($array[$a][$b]),0,'L',1,$bEndOfCell); - - $this->SetFont($this->FontFamily, $oldStyle, $this->FontSizePt); - } - else - { - if ($a==1) - { - $this->SetFillColor(240, 240, 240); - } - //echo $maxwidth[$b]." max $b.Spalte
"; - - if ($maxwidth[$b] > 140) $maxwidth[$b]=130; - if ($b==0) - { - $iHeight=$this->getStringHeight($maxwidth[$b],$this->delete_html($array[$a][$b])); - $this->MultiCell($maxwidth[$b],$iHeight,$this->delete_html($array[$a][$b]),0,'L',$fill,$bEndOfCell); - } - else - { - $iLines=$this->getStringHeight($maxwidth[$b],$this->delete_html($array[$a][$b])); - if ($iLines>$iHeight) $iHeight=$iLines; - $this->MultiCell($maxwidth[$b],$iHeight,$this->delete_html($array[$a][$b]),0,'L',$fill,$bEndOfCell); - } - } - } - } - $this->ln(5); + $oldStyle = $this->FontStyle; + $this->SetFont($this->FontFamily, 'B', $this->FontSizePt); + + if ($maxwidth[$b] > 140) $maxwidth[$b]=130; + if ($maxwidth[$b] < 25) $maxwidth[$b]=25; + $this->MultiCell($maxwidth[$b],6,$this->delete_html($array[$a][$b]),0,'L',1,$bEndOfCell); + + $this->SetFont($this->FontFamily, $oldStyle, $this->FontSizePt); } - function getminwidth($array) + else { - $width = array(); - for($i=0;$idelete_html($array[$i][$j]),1); - foreach($chars as $char) - { - $stringWidth = $stringWidth+$this->GetCharWidth($char); - - //echo $stringWidth.": ".$char."
"; - } - if($stringWidth!=0 && $stringWidth<8) - $stringWidth = $stringWidth*3; - if(!isset($width[$j])|| $stringWidth>$width[$j]) - { - $width[$j] = $stringWidth; - } - } - } - return $width; + if ($a==1) + { + $this->SetFillColor(240, 240, 240); + } + //echo $maxwidth[$b]." max $b.Spalte
"; + + if ($maxwidth[$b] > 140) $maxwidth[$b]=130; + if ($b==0) + { + $iHeight=$this->getStringHeight($maxwidth[$b],$this->delete_html($array[$a][$b])); + $this->MultiCell($maxwidth[$b],$iHeight,$this->delete_html($array[$a][$b]),0,'L',$fill,$bEndOfCell); + } + else + { + $iLines=$this->getStringHeight($maxwidth[$b],$this->delete_html($array[$a][$b])); + if ($iLines>$iHeight) $iHeight=$iLines; + $this->MultiCell($maxwidth[$b],$iHeight,$this->delete_html($array[$a][$b]),0,'L',$fill,$bEndOfCell); + } } - function getmaxwidth($array) + } + } + $this->ln(5); + } + function getminwidth($array) + { + $width = array(); + for($i=0;$idelete_html($array[$i][$j]),1); + foreach($chars as $char) { - for($i=0;$i=0) - { - if(strlen($this->delete_html($array[($i-1)][$j])) < strlen($this->delete_html($array[$i][$j]))) - { - $width[$j] = strlen($this->delete_html($array[$i][$j])); - } - } - else - { - $width[$j]=strlen($this->delete_html($array[$i][$j])); - } - } - } - return ($width); + $stringWidth = $stringWidth+$this->GetCharWidth($char); + + //echo $stringWidth.": ".$char."
"; } - /** - * - * Gets the width for columns in a table based on their Stringlength and the width of the page... - * @param $array - * @return array with column width - */ - function getFullWidth($array) + if($stringWidth!=0 && $stringWidth<8) + $stringWidth = $stringWidth*3; + if(!isset($width[$j])|| $stringWidth>$width[$j]) { - $maxlength = array(); - $width = array(); - $width = $this->getminwidth($array); - - $margins = $this->getMargins(); - $deadSpace = $margins['left']+$margins['right']; - $fullWidth = ($this->GetLineWidth()*1000)-$deadSpace; - $faktor = $fullWidth/array_sum($width); - - for($i=0;$i=0) { - $margins = $this->getMargins(); - $deadSpace = $margins['left']+$margins['right']; - - $width = ($this->GetLineWidth()*1000)-$deadSpace; - $count = 0; - for($i=0;$i$count) - { - $count = sizeof($array[$i]); - } - } - } - - if($count!=0) - return ($width/$count); - else - return FALSE; + if(strlen($this->delete_html($array[($i-1)][$j])) < strlen($this->delete_html($array[$i][$j]))) + { + $width[$j] = strlen($this->delete_html($array[$i][$j])); + } } - function write_out($name) + else { - $this->Output($name,"D"); + $width[$j]=strlen($this->delete_html($array[$i][$j])); } - - function delete_html($text) + } + } + return ($width); + } + /** + * + * Gets the width for columns in a table based on their Stringlength and the width of the page... + * @param $array + * @return array with column width + */ + function getFullWidth($array) + { + $maxlength = array(); + $width = array(); + $width = $this->getminwidth($array); + + $margins = $this->getMargins(); + $deadSpace = $margins['left']+$margins['right']; + $fullWidth = ($this->GetLineWidth()*1000)-$deadSpace; + $faktor = $fullWidth/array_sum($width); + + for($i=0;$igetMargins(); + $deadSpace = $margins['left']+$margins['right']; + + $width = ($this->GetLineWidth()*1000)-$deadSpace; + $count = 0; + for($i=0;$i$count) { - $text = html_entity_decode($text,null,'UTF-8'); - $text = str_replace("\t",' ',$text); - return strip_tags($text); + $count = sizeof($array[$i]); } + } + } + + if($count!=0) + return ($width/$count); + else + return FALSE; + } + function write_out($name) + { + $this->Output($name,"D"); + } + + function delete_html($text) + { + $text = html_entity_decode($text,null,'UTF-8'); + $text = str_replace("\t",' ',$text); + return strip_tags($text); + } } \ No newline at end of file