@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | final public function __construct($err = 0, $other = null, $html = '') |
| 28 | 28 | { |
| 29 | 29 | // read the error |
| 30 | - switch($err) |
|
| 30 | + switch ($err) |
|
| 31 | 31 | { |
| 32 | 32 | case 1: // Unsupported tag |
| 33 | 33 | $msg = (HTML2PDF_locale::get('err01')); |
@@ -89,19 +89,19 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | // create the HTML message |
| 91 | 91 | $this->_messageHtml = '<span style="color: #AA0000; font-weight: bold;">'.HTML2PDF_locale::get('txt01', 'error: ').$err.'</span><br>'; |
| 92 | - $this->_messageHtml.= HTML2PDF_locale::get('txt02', 'file:').' '.$this->file.'<br>'; |
|
| 93 | - $this->_messageHtml.= HTML2PDF_locale::get('txt03', 'line:').' '.$this->line.'<br>'; |
|
| 94 | - $this->_messageHtml.= '<br>'; |
|
| 95 | - $this->_messageHtml.= $msg; |
|
| 92 | + $this->_messageHtml .= HTML2PDF_locale::get('txt02', 'file:').' '.$this->file.'<br>'; |
|
| 93 | + $this->_messageHtml .= HTML2PDF_locale::get('txt03', 'line:').' '.$this->line.'<br>'; |
|
| 94 | + $this->_messageHtml .= '<br>'; |
|
| 95 | + $this->_messageHtml .= $msg; |
|
| 96 | 96 | |
| 97 | 97 | // create the text message |
| 98 | 98 | $msg = HTML2PDF_locale::get('txt01', 'error: ').$err.' : '.strip_tags($msg); |
| 99 | 99 | |
| 100 | 100 | // add the optionnal html content |
| 101 | 101 | if ($html) { |
| 102 | - $this->_messageHtml.= "<br><br>HTML : ...".trim(htmlentities($html)).'...'; |
|
| 102 | + $this->_messageHtml .= "<br><br>HTML : ...".trim(htmlentities($html)).'...'; |
|
| 103 | 103 | $this->_html = $html; |
| 104 | - $msg.= ' HTML : ...'.trim($html).'...'; |
|
| 104 | + $msg .= ' HTML : ...'.trim($html).'...'; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // save the other informations |
@@ -32,23 +32,23 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // If you define the constant K_TCPDF_EXTERNAL_CONFIG, the following settings will be ignored. |
| 34 | 34 | |
| 35 | -if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { |
|
| 35 | +if ( ! defined('K_TCPDF_EXTERNAL_CONFIG')) { |
|
| 36 | 36 | |
| 37 | 37 | define('K_TCPDF_EXTERNAL_CONFIG', true); |
| 38 | 38 | |
| 39 | 39 | // DOCUMENT_ROOT fix for IIS Webserver |
| 40 | - if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) { |
|
| 40 | + if (( ! isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) { |
|
| 41 | 41 | if (isset($_SERVER['SCRIPT_FILENAME'])) { |
| 42 | 42 | $_SERVER['DOCUMENT_ROOT'] = str_replace( |
| 43 | 43 | '\\', |
| 44 | 44 | '/', |
| 45 | - substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])) |
|
| 45 | + substr($_SERVER['SCRIPT_FILENAME'], 0, 0 - strlen($_SERVER['PHP_SELF'])) |
|
| 46 | 46 | ); |
| 47 | 47 | } elseif (isset($_SERVER['PATH_TRANSLATED'])) { |
| 48 | 48 | $_SERVER['DOCUMENT_ROOT'] = str_replace( |
| 49 | 49 | '\\', |
| 50 | 50 | '/', |
| 51 | - substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])) |
|
| 51 | + substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0 - strlen($_SERVER['PHP_SELF'])) |
|
| 52 | 52 | ); |
| 53 | 53 | } else { |
| 54 | 54 | // define here your DOCUMENT_ROOT path if the previous fails |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | // Automatic calculation for the following K_PATH_MAIN constant |
| 60 | 60 | $kPathMain = str_replace('\\', '/', dirname(__FILE__)); |
| 61 | 61 | $kPathMain = dirname($kPathMain).'/'; // remove the current directory |
| 62 | - $kPathMain.= '_tcpdf_'.HTML2PDF_USED_TCPDF_VERSION.'/'; |
|
| 62 | + $kPathMain .= '_tcpdf_'.HTML2PDF_USED_TCPDF_VERSION.'/'; |
|
| 63 | 63 | define('K_PATH_MAIN', $kPathMain); |
| 64 | 64 | |
| 65 | 65 | // Automatic calculation for the following K_PATH_URL constant |
| 66 | - if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) { |
|
| 67 | - if (isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS'])!='off') { |
|
| 66 | + if (isset($_SERVER['HTTP_HOST']) AND ( ! empty($_SERVER['HTTP_HOST']))) { |
|
| 67 | + if (isset($_SERVER['HTTPS']) AND ( ! empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS']) != 'off') { |
|
| 68 | 68 | $kPathUrl = 'https://'; |
| 69 | 69 | } else { |
| 70 | 70 | $kPathUrl = 'http://'; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | /** |
| 229 | 229 | * reduction factor for small font |
| 230 | 230 | */ |
| 231 | - define('K_SMALL_RATIO', 2/3); |
|
| 231 | + define('K_SMALL_RATIO', 2 / 3); |
|
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | 234 | * set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language |
@@ -11,488 +11,487 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | if ( ! defined('__CLASS_HTML2PDF__')) { |
| 13 | 13 | |
| 14 | - define('__CLASS_HTML2PDF__', '4.03'); |
|
| 15 | - define('HTML2PDF_USED_TCPDF_VERSION', '5.0.002'); |
|
| 16 | - |
|
| 17 | - require_once('_class/exception.class.php'); |
|
| 18 | - require_once('_class/locale.class.php'); |
|
| 19 | - require_once('_class/myPdf.class.php'); |
|
| 20 | - require_once('_class/parsingHtml.class.php'); |
|
| 21 | - require_once('_class/parsingCss.class.php'); |
|
| 22 | - |
|
| 23 | - class HTML2PDF |
|
| 24 | - { |
|
| 25 | - /** |
|
| 26 | - * HTML2PDF_myPdf object, extends from TCPDF |
|
| 27 | - * @var HTML2PDF_myPdf |
|
| 28 | - */ |
|
| 29 | - public $pdf = null; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * CSS parsing |
|
| 33 | - * @var HTML2PDF_parsingCss |
|
| 34 | - */ |
|
| 35 | - public $parsingCss = null; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * HTML parsing |
|
| 39 | - * @var HTML2PDF_parsingHtml |
|
| 40 | - */ |
|
| 41 | - public $parsingHtml = null; |
|
| 42 | - |
|
| 43 | - protected $_langue = 'fr'; // locale of the messages |
|
| 44 | - protected $_orientation = 'P'; // page orientation : Portrait ou Landscape |
|
| 45 | - protected $_format = 'A4'; // page format : A4, A3, ... |
|
| 46 | - protected $_encoding = ''; // charset encoding |
|
| 47 | - protected $_unicode = true; // means that the input text is unicode (default = true) |
|
| 48 | - |
|
| 49 | - protected $_testTdInOnepage = true; // test of TD that can not take more than one page |
|
| 50 | - protected $_testIsImage = true; // test if the images exist or not |
|
| 51 | - protected $_testIsDeprecated = false; // test the deprecated functions |
|
| 52 | - |
|
| 53 | - protected $_parsePos = 0; // position in the parsing |
|
| 54 | - protected $_tempPos = 0; // temporary position for complex table |
|
| 55 | - protected $_page = 0; // current page number |
|
| 56 | - |
|
| 57 | - protected $_subHtml = null; // sub html |
|
| 58 | - protected $_subPart = false; // sub HTML2PDF |
|
| 59 | - protected $_subHEADER = array(); // sub action to make the header |
|
| 60 | - protected $_subFOOTER = array(); // sub action to make the footer |
|
| 61 | - protected $_subSTATES = array(); // array to save some parameters |
|
| 62 | - |
|
| 63 | - protected $_isSubPart = false; // flag : in a sub html2pdf |
|
| 64 | - protected $_isInThead = false; // flag : in a thead |
|
| 65 | - protected $_isInTfoot = false; // flag : in a tfoot |
|
| 66 | - protected $_isInOverflow = false; // flag : in a overflow |
|
| 67 | - protected $_isInFooter = false; // flag : in a footer |
|
| 68 | - protected $_isInDraw = null; // flag : in a draw (svg) |
|
| 69 | - protected $_isAfterFloat = false; // flag : is just after a float |
|
| 70 | - protected $_isInForm = false; // flag : is in a float. false / action of the form |
|
| 71 | - protected $_isInLink = ''; // flag : is in a link. empty / href of the link |
|
| 72 | - protected $_isInParagraph = false; // flag : is in a paragraph |
|
| 73 | - protected $_isForOneLine = false; // flag : in a specific sub html2pdf to have the height of the next line |
|
| 74 | - |
|
| 75 | - protected $_maxX = 0; // maximum X of the current zone |
|
| 76 | - protected $_maxY = 0; // maximum Y of the current zone |
|
| 77 | - protected $_maxE = 0; // number of elements in the current zone |
|
| 78 | - protected $_maxH = 0; // maximum height of the line in the current zone |
|
| 79 | - protected $_maxSave = array(); // save the maximums of the current zone |
|
| 80 | - protected $_currentH = 0; // height of the current line |
|
| 81 | - |
|
| 82 | - protected $_defaultLeft = 0; // default marges of the page |
|
| 83 | - protected $_defaultTop = 0; |
|
| 84 | - protected $_defaultRight = 0; |
|
| 85 | - protected $_defaultBottom = 0; |
|
| 86 | - protected $_defaultFont = null; // default font to use, is the asked font does not exist |
|
| 87 | - |
|
| 88 | - protected $_margeLeft = 0; // current marges of the page |
|
| 89 | - protected $_margeTop = 0; |
|
| 90 | - protected $_margeRight = 0; |
|
| 91 | - protected $_margeBottom = 0; |
|
| 92 | - protected $_marges = array(); // save the different marges of the current page |
|
| 93 | - protected $_pageMarges = array(); // float marges of the current page |
|
| 94 | - protected $_background = array(); // background informations |
|
| 95 | - |
|
| 96 | - |
|
| 97 | - protected $_firstPage = true; // flag : first page |
|
| 98 | - protected $_defList = array(); // table to save the stats of the tags UL and OL |
|
| 99 | - |
|
| 100 | - protected $_lstAnchor = array(); // list of the anchors |
|
| 101 | - protected $_lstField = array(); // list of the fields |
|
| 102 | - protected $_lstSelect = array(); // list of the options of the current select |
|
| 103 | - protected $_previousCall = null; // last action called |
|
| 104 | - |
|
| 105 | - protected $_debugActif = false; // flag : mode debug is active |
|
| 106 | - protected $_debugOkUsage = false; // flag : the function memory_get_usage exist |
|
| 107 | - protected $_debugOkPeak = false; // flag : the function memory_get_peak_usage exist |
|
| 108 | - protected $_debugLevel = 0; // level in the debug |
|
| 109 | - protected $_debugStartTime = 0; // debug start time |
|
| 110 | - protected $_debugLastTime = 0; // debug stop time |
|
| 111 | - |
|
| 112 | - static protected $_subobj = null; // object html2pdf prepared in order to accelerate the creation of sub html2pdf |
|
| 113 | - static protected $_tables = array(); // static table to prepare the nested html tables |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * class constructor |
|
| 117 | - * |
|
| 118 | - * @access public |
|
| 119 | - * @param string $orientation page orientation, same as TCPDF |
|
| 120 | - * @param string $format The format used for pages, same as TCPDF |
|
| 121 | - * @param $tring $langue Langue : fr, en, it... |
|
| 122 | - * @param boolean $unicode TRUE means that the input text is unicode (default = true) |
|
| 123 | - * @param String $encoding charset encoding; default is UTF-8 |
|
| 124 | - * @param integer[] $marges Default marges (left, top, right, bottom) |
|
| 125 | - * @return HTML2PDF $this |
|
| 126 | - */ |
|
| 127 | - public function __construct($orientation = 'P', $format = 'A4', $langue = 'en', $unicode = true, $encoding = 'UTF-8', $marges = array(5, 5, 5, 8)) |
|
| 128 | - { |
|
| 129 | - // init the page number |
|
| 130 | - $this->_page = 0; |
|
| 131 | - $this->_firstPage = true; |
|
| 132 | - |
|
| 133 | - // save the parameters |
|
| 134 | - $this->_orientation = $orientation; |
|
| 135 | - $this->_format = $format; |
|
| 136 | - $this->_langue = strtolower($langue); |
|
| 137 | - $this->_unicode = $unicode; |
|
| 138 | - $this->_encoding = $encoding; |
|
| 139 | - |
|
| 140 | - // load the Local |
|
| 141 | - HTML2PDF_locale::load($this->_langue); |
|
| 142 | - |
|
| 143 | - // create the HTML2PDF_myPdf object |
|
| 144 | - $this->pdf = new HTML2PDF_myPdf($orientation, 'mm', $format, $unicode, $encoding); |
|
| 145 | - |
|
| 146 | - // init the CSS parsing object |
|
| 147 | - $this->parsingCss = new HTML2PDF_parsingCss($this->pdf); |
|
| 148 | - $this->parsingCss->fontSet(); |
|
| 149 | - $this->_defList = array(); |
|
| 150 | - |
|
| 151 | - // init some tests |
|
| 152 | - $this->setTestTdInOnePage(true); |
|
| 153 | - $this->setTestIsImage(true); |
|
| 154 | - $this->setTestIsDeprecated(true); |
|
| 155 | - |
|
| 156 | - // init the default font |
|
| 157 | - $this->setDefaultFont(null); |
|
| 158 | - |
|
| 159 | - // init the HTML parsing object |
|
| 160 | - $this->parsingHtml = new HTML2PDF_parsingHtml($this->_encoding); |
|
| 161 | - $this->_subHtml = null; |
|
| 162 | - $this->_subPart = false; |
|
| 163 | - |
|
| 164 | - // init the marges of the page |
|
| 165 | - if ( ! is_array($marges)) $marges = array($marges, $marges, $marges, $marges); |
|
| 166 | - $this->_setDefaultMargins($marges[0], $marges[1], $marges[2], $marges[3]); |
|
| 167 | - $this->_setMargins(); |
|
| 168 | - $this->_marges = array(); |
|
| 169 | - |
|
| 170 | - // init the form's fields |
|
| 171 | - $this->_lstField = array(); |
|
| 172 | - |
|
| 173 | - return $this; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * Destructor |
|
| 178 | - * |
|
| 179 | - * @access public |
|
| 180 | - * @return null |
|
| 181 | - */ |
|
| 182 | - public function __destruct() |
|
| 183 | - { |
|
| 184 | - |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Clone to create a sub HTML2PDF from HTML2PDF::$_subobj |
|
| 189 | - * |
|
| 190 | - * @access public |
|
| 191 | - */ |
|
| 192 | - public function __clone() |
|
| 193 | - { |
|
| 194 | - $this->pdf = clone $this->pdf; |
|
| 195 | - $this->parsingHtml = clone $this->parsingHtml; |
|
| 196 | - $this->parsingCss = clone $this->parsingCss; |
|
| 197 | - $this->parsingCss->setPdfParent($this->pdf); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * set the debug mode to On |
|
| 202 | - * |
|
| 203 | - * @access public |
|
| 204 | - * @return HTML2PDF $this |
|
| 205 | - */ |
|
| 206 | - public function setModeDebug() |
|
| 207 | - { |
|
| 208 | - $time = microtime(true); |
|
| 209 | - |
|
| 210 | - $this->_debugActif = true; |
|
| 211 | - $this->_debugOkUsage = function_exists('memory_get_usage'); |
|
| 212 | - $this->_debugOkPeak = function_exists('memory_get_peak_usage'); |
|
| 213 | - $this->_debugStartTime = $time; |
|
| 214 | - $this->_debugLastTime = $time; |
|
| 215 | - |
|
| 216 | - $this->_DEBUG_stepline('step', 'time', 'delta', 'memory', 'peak'); |
|
| 217 | - $this->_DEBUG_add('Init debug'); |
|
| 218 | - |
|
| 219 | - return $this; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * Set the test of TD thdat can not take more than one page |
|
| 224 | - * |
|
| 225 | - * @access public |
|
| 226 | - * @param boolean $mode |
|
| 227 | - * @return HTML2PDF $this |
|
| 228 | - */ |
|
| 229 | - public function setTestTdInOnePage($mode = true) |
|
| 230 | - { |
|
| 231 | - $this->_testTdInOnepage = $mode ? true : false; |
|
| 232 | - |
|
| 233 | - return $this; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * Set the test if the images exist or not |
|
| 238 | - * |
|
| 239 | - * @access public |
|
| 240 | - * @param boolean $mode |
|
| 241 | - * @return HTML2PDF $this |
|
| 242 | - */ |
|
| 243 | - public function setTestIsImage($mode = true) |
|
| 244 | - { |
|
| 245 | - $this->_testIsImage = $mode ? true : false; |
|
| 246 | - |
|
| 247 | - return $this; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * Set the test on deprecated functions |
|
| 252 | - * |
|
| 253 | - * @access public |
|
| 254 | - * @param boolean $mode |
|
| 255 | - * @return HTML2PDF $this |
|
| 256 | - */ |
|
| 257 | - public function setTestIsDeprecated($mode = true) |
|
| 258 | - { |
|
| 259 | - $this->_testIsDeprecated = $mode ? true : false; |
|
| 260 | - |
|
| 261 | - return $this; |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * Set the default font to use, if no font is specify, or if the asked font does not exist |
|
| 266 | - * |
|
| 267 | - * @access public |
|
| 268 | - * @param string $default name of the default font to use. If null : Arial is no font is specify, and error if the asked font does not exist |
|
| 269 | - * @return HTML2PDF $this |
|
| 270 | - */ |
|
| 271 | - public function setDefaultFont($default = null) |
|
| 272 | - { |
|
| 273 | - $this->_defaultFont = $default; |
|
| 274 | - $this->parsingCss->setDefaultFont($default); |
|
| 275 | - |
|
| 276 | - return $this; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * add a font, see TCPDF function addFont |
|
| 281 | - * |
|
| 282 | - * @access public |
|
| 283 | - * @param string $family Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font. |
|
| 284 | - * @param string $style Font style. Possible values are (case insensitive):<ul><li>empty string: regular (default)</li><li>B: bold</li><li>I: italic</li><li>BI or IB: bold italic</li></ul> |
|
| 285 | - * @return HTML2PDF $this |
|
| 286 | - * @see TCPDF::addFont |
|
| 287 | - */ |
|
| 288 | - public function addFont($family, $style = '', $file = '') |
|
| 289 | - { |
|
| 290 | - $this->pdf->AddFont($family, $style, $file); |
|
| 291 | - |
|
| 292 | - return $this; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * display a automatic index, from the bookmarks |
|
| 297 | - * |
|
| 298 | - * @access public |
|
| 299 | - * @param string $titre index title |
|
| 300 | - * @param int $sizeTitle font size of the index title, in mm |
|
| 301 | - * @param int $sizeBookmark font size of the index, in mm |
|
| 302 | - * @param boolean $bookmarkTitle add a bookmark for the index, at his beginning |
|
| 303 | - * @param boolean $displayPage display the page numbers |
|
| 304 | - * @param int $onPage if null : at the end of the document on a new page, else on the $onPage page |
|
| 305 | - * @param string $fontName font name to use |
|
| 306 | - * @return null |
|
| 307 | - */ |
|
| 308 | - public function createIndex($titre = 'Index', $sizeTitle = 20, $sizeBookmark = 15, $bookmarkTitle = true, $displayPage = true, $onPage = null, $fontName = 'helvetica') |
|
| 309 | - { |
|
| 310 | - $oldPage = $this->_INDEX_NewPage($onPage); |
|
| 311 | - $this->pdf->createIndex($this, $titre, $sizeTitle, $sizeBookmark, $bookmarkTitle, $displayPage, $onPage, $fontName); |
|
| 312 | - if ($oldPage) { |
|
| 313 | - $this->pdf->setPage($oldPage); |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * clean up the objects |
|
| 319 | - * |
|
| 320 | - * @access protected |
|
| 321 | - */ |
|
| 322 | - protected function _cleanUp() |
|
| 323 | - { |
|
| 324 | - HTML2PDF::$_subobj = null; |
|
| 325 | - HTML2PDF::$_tables = array(); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * Send the document to a given destination: string, local file or browser. |
|
| 330 | - * Dest can be : |
|
| 331 | - * I : send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF. |
|
| 332 | - * D : send to the browser and force a file download with the name given by name. |
|
| 333 | - * F : save to a local server file with the name given by name. |
|
| 334 | - * S : return the document as a string. name is ignored. |
|
| 335 | - * FI: equivalent to F + I option |
|
| 336 | - * FD: equivalent to F + D option |
|
| 337 | - * true => I |
|
| 338 | - * false => S |
|
| 339 | - * |
|
| 340 | - * @param string $name The name of the file when saved. |
|
| 341 | - * @param string $dest Destination where to send the document. |
|
| 342 | - * @return string content of the PDF, if $dest=S |
|
| 343 | - * @see TCPDF::close |
|
| 344 | - * @access public |
|
| 345 | - |
|
| 346 | - */ |
|
| 347 | - public function Output($name = '', $dest = false) |
|
| 348 | - { |
|
| 349 | - // close the pdf and clean up |
|
| 350 | - $this->_cleanUp(); |
|
| 351 | - |
|
| 352 | - // if on debug mode |
|
| 353 | - if ($this->_debugActif) { |
|
| 354 | - $this->_DEBUG_add('Before output'); |
|
| 355 | - $this->pdf->Close(); |
|
| 356 | - exit; |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - // complete parameters |
|
| 360 | - if ($dest === false) $dest = 'I'; |
|
| 361 | - if ($dest === true) $dest = 'S'; |
|
| 362 | - if ($dest === '') $dest = 'I'; |
|
| 363 | - if ($name == '') $name = 'document.pdf'; |
|
| 364 | - |
|
| 365 | - // clean up the destination |
|
| 366 | - $dest = strtoupper($dest); |
|
| 367 | - if ( ! in_array($dest, array('I', 'D', 'F', 'S', 'FI', 'FD'))) $dest = 'I'; |
|
| 368 | - |
|
| 369 | - // the name must be a PDF name |
|
| 370 | - if (strtolower(substr($name, -4)) != '.pdf') { |
|
| 371 | - throw new HTML2PDF_exception(0, 'The output document name "'.$name.'" is not a PDF name'); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - // call the output of TCPDF |
|
| 375 | - return $this->pdf->Output($name, $dest); |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * convert HTML to PDF |
|
| 380 | - * |
|
| 381 | - * @access public |
|
| 382 | - * @param string $html |
|
| 383 | - * @param boolean $debugVue enable the HTML debug vue |
|
| 384 | - * @return null |
|
| 385 | - */ |
|
| 386 | - public function writeHTML($html, $debugVue = false) |
|
| 387 | - { |
|
| 388 | - // if it is a real html page, we have to convert it |
|
| 389 | - if (preg_match('/<body/isU', $html)) { |
|
| 390 | - $html = $this->getHtmlFromPage($html); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - $html = str_replace('[[date_y]]', date('Y'), $html); |
|
| 394 | - $html = str_replace('[[date_m]]', date('m'), $html); |
|
| 395 | - $html = str_replace('[[date_d]]', date('d'), $html); |
|
| 396 | - |
|
| 397 | - $html = str_replace('[[date_h]]', date('H'), $html); |
|
| 398 | - $html = str_replace('[[date_i]]', date('i'), $html); |
|
| 399 | - $html = str_replace('[[date_s]]', date('s'), $html); |
|
| 400 | - |
|
| 401 | - // If we are in HTML debug vue : display the HTML |
|
| 402 | - if ($debugVue) { |
|
| 403 | - return $this->_vueHTML($html); |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - // convert HTMl to PDF |
|
| 407 | - $this->parsingCss->readStyle($html); |
|
| 408 | - $this->parsingHtml->setHTML($html); |
|
| 409 | - $this->parsingHtml->parse(); |
|
| 410 | - $this->_makeHTMLcode(); |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * convert the HTML of a real page, to a code adapted to HTML2PDF |
|
| 415 | - * |
|
| 416 | - * @access public |
|
| 417 | - * @param string HTML of a real page |
|
| 418 | - * @param string $html |
|
| 419 | - * @return string HTML adapted to HTML2PDF |
|
| 420 | - */ |
|
| 421 | - public function getHtmlFromPage($html) |
|
| 422 | - { |
|
| 423 | - $html = str_replace('<BODY', '<body', $html); |
|
| 424 | - $html = str_replace('</BODY', '</body', $html); |
|
| 425 | - |
|
| 426 | - // extract the content |
|
| 427 | - $res = explode('<body', $html); |
|
| 428 | - if (count($res) < 2) return $html; |
|
| 429 | - $content = '<page'.$res[1]; |
|
| 430 | - $content = explode('</body', $content); |
|
| 431 | - $content = $content[0].'</page>'; |
|
| 432 | - |
|
| 433 | - // extract the link tags |
|
| 434 | - preg_match_all('/<link([^>]*)>/isU', $html, $match); |
|
| 435 | - foreach ($match[0] as $src) |
|
| 436 | - $content = $src.'</link>'.$content; |
|
| 437 | - |
|
| 438 | - // extract the css style tags |
|
| 439 | - preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match); |
|
| 440 | - foreach ($match[0] as $src) |
|
| 441 | - $content = $src.$content; |
|
| 442 | - |
|
| 443 | - return $content; |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - /** |
|
| 447 | - * init a sub HTML2PDF. does not use it directly. Only the method createSubHTML must use it |
|
| 448 | - * |
|
| 449 | - * @access public |
|
| 450 | - * @param string $format |
|
| 451 | - * @param string $orientation |
|
| 452 | - * @param array $marge |
|
| 453 | - * @param integer $page |
|
| 454 | - * @param array $defLIST |
|
| 455 | - * @param integer $myLastPageGroup |
|
| 456 | - * @param integer $myLastPageGroupNb |
|
| 457 | - */ |
|
| 458 | - public function initSubHtml($format, $orientation, $marge, $page, $defLIST, $myLastPageGroup, $myLastPageGroupNb) |
|
| 459 | - { |
|
| 460 | - $this->_isSubPart = true; |
|
| 461 | - |
|
| 462 | - $this->parsingCss->setOnlyLeft(); |
|
| 463 | - |
|
| 464 | - $this->_setNewPage($format, $orientation, null, null, ($myLastPageGroup !== null)); |
|
| 465 | - |
|
| 466 | - $this->_saveMargin(0, 0, $marge); |
|
| 467 | - $this->_defList = $defLIST; |
|
| 468 | - |
|
| 469 | - $this->_page = $page; |
|
| 470 | - $this->pdf->setMyLastPageGroup($myLastPageGroup); |
|
| 471 | - $this->pdf->setMyLastPageGroupNb($myLastPageGroupNb); |
|
| 472 | - $this->pdf->setXY(0, 0); |
|
| 473 | - $this->parsingCss->fontSet(); |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * display the content in HTML moden for debug |
|
| 478 | - * |
|
| 479 | - * @access protected |
|
| 480 | - * @param string $content |
|
| 481 | - */ |
|
| 482 | - protected function _vueHTML($content) |
|
| 483 | - { |
|
| 484 | - $content = preg_replace('/<page_header([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue01').' : $1<hr><div$1>', $content); |
|
| 485 | - $content = preg_replace('/<page_footer([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue02').' : $1<hr><div$1>', $content); |
|
| 486 | - $content = preg_replace('/<page([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue03').' : $1<hr><div$1>', $content); |
|
| 487 | - $content = preg_replace('/<\/page([^>]*)>/isU', '</div><hr>', $content); |
|
| 488 | - $content = preg_replace('/<bookmark([^>]*)>/isU', '<hr>bookmark : $1<hr>', $content); |
|
| 489 | - $content = preg_replace('/<\/bookmark([^>]*)>/isU', '', $content); |
|
| 490 | - $content = preg_replace('/<barcode([^>]*)>/isU', '<hr>barcode : $1<hr>', $content); |
|
| 491 | - $content = preg_replace('/<\/barcode([^>]*)>/isU', '', $content); |
|
| 492 | - $content = preg_replace('/<qrcode([^>]*)>/isU', '<hr>qrcode : $1<hr>', $content); |
|
| 493 | - $content = preg_replace('/<\/qrcode([^>]*)>/isU', '', $content); |
|
| 494 | - |
|
| 495 | - echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
|
| 14 | + define('__CLASS_HTML2PDF__', '4.03'); |
|
| 15 | + define('HTML2PDF_USED_TCPDF_VERSION', '5.0.002'); |
|
| 16 | + |
|
| 17 | + require_once('_class/exception.class.php'); |
|
| 18 | + require_once('_class/locale.class.php'); |
|
| 19 | + require_once('_class/myPdf.class.php'); |
|
| 20 | + require_once('_class/parsingHtml.class.php'); |
|
| 21 | + require_once('_class/parsingCss.class.php'); |
|
| 22 | + |
|
| 23 | + class HTML2PDF |
|
| 24 | + { |
|
| 25 | + /** |
|
| 26 | + * HTML2PDF_myPdf object, extends from TCPDF |
|
| 27 | + * @var HTML2PDF_myPdf |
|
| 28 | + */ |
|
| 29 | + public $pdf = null; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * CSS parsing |
|
| 33 | + * @var HTML2PDF_parsingCss |
|
| 34 | + */ |
|
| 35 | + public $parsingCss = null; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * HTML parsing |
|
| 39 | + * @var HTML2PDF_parsingHtml |
|
| 40 | + */ |
|
| 41 | + public $parsingHtml = null; |
|
| 42 | + |
|
| 43 | + protected $_langue = 'fr'; // locale of the messages |
|
| 44 | + protected $_orientation = 'P'; // page orientation : Portrait ou Landscape |
|
| 45 | + protected $_format = 'A4'; // page format : A4, A3, ... |
|
| 46 | + protected $_encoding = ''; // charset encoding |
|
| 47 | + protected $_unicode = true; // means that the input text is unicode (default = true) |
|
| 48 | + |
|
| 49 | + protected $_testTdInOnepage = true; // test of TD that can not take more than one page |
|
| 50 | + protected $_testIsImage = true; // test if the images exist or not |
|
| 51 | + protected $_testIsDeprecated = false; // test the deprecated functions |
|
| 52 | + |
|
| 53 | + protected $_parsePos = 0; // position in the parsing |
|
| 54 | + protected $_tempPos = 0; // temporary position for complex table |
|
| 55 | + protected $_page = 0; // current page number |
|
| 56 | + |
|
| 57 | + protected $_subHtml = null; // sub html |
|
| 58 | + protected $_subPart = false; // sub HTML2PDF |
|
| 59 | + protected $_subHEADER = array(); // sub action to make the header |
|
| 60 | + protected $_subFOOTER = array(); // sub action to make the footer |
|
| 61 | + protected $_subSTATES = array(); // array to save some parameters |
|
| 62 | + |
|
| 63 | + protected $_isSubPart = false; // flag : in a sub html2pdf |
|
| 64 | + protected $_isInThead = false; // flag : in a thead |
|
| 65 | + protected $_isInTfoot = false; // flag : in a tfoot |
|
| 66 | + protected $_isInOverflow = false; // flag : in a overflow |
|
| 67 | + protected $_isInFooter = false; // flag : in a footer |
|
| 68 | + protected $_isInDraw = null; // flag : in a draw (svg) |
|
| 69 | + protected $_isAfterFloat = false; // flag : is just after a float |
|
| 70 | + protected $_isInForm = false; // flag : is in a float. false / action of the form |
|
| 71 | + protected $_isInLink = ''; // flag : is in a link. empty / href of the link |
|
| 72 | + protected $_isInParagraph = false; // flag : is in a paragraph |
|
| 73 | + protected $_isForOneLine = false; // flag : in a specific sub html2pdf to have the height of the next line |
|
| 74 | + |
|
| 75 | + protected $_maxX = 0; // maximum X of the current zone |
|
| 76 | + protected $_maxY = 0; // maximum Y of the current zone |
|
| 77 | + protected $_maxE = 0; // number of elements in the current zone |
|
| 78 | + protected $_maxH = 0; // maximum height of the line in the current zone |
|
| 79 | + protected $_maxSave = array(); // save the maximums of the current zone |
|
| 80 | + protected $_currentH = 0; // height of the current line |
|
| 81 | + |
|
| 82 | + protected $_defaultLeft = 0; // default marges of the page |
|
| 83 | + protected $_defaultTop = 0; |
|
| 84 | + protected $_defaultRight = 0; |
|
| 85 | + protected $_defaultBottom = 0; |
|
| 86 | + protected $_defaultFont = null; // default font to use, is the asked font does not exist |
|
| 87 | + |
|
| 88 | + protected $_margeLeft = 0; // current marges of the page |
|
| 89 | + protected $_margeTop = 0; |
|
| 90 | + protected $_margeRight = 0; |
|
| 91 | + protected $_margeBottom = 0; |
|
| 92 | + protected $_marges = array(); // save the different marges of the current page |
|
| 93 | + protected $_pageMarges = array(); // float marges of the current page |
|
| 94 | + protected $_background = array(); // background informations |
|
| 95 | + |
|
| 96 | + |
|
| 97 | + protected $_firstPage = true; // flag : first page |
|
| 98 | + protected $_defList = array(); // table to save the stats of the tags UL and OL |
|
| 99 | + |
|
| 100 | + protected $_lstAnchor = array(); // list of the anchors |
|
| 101 | + protected $_lstField = array(); // list of the fields |
|
| 102 | + protected $_lstSelect = array(); // list of the options of the current select |
|
| 103 | + protected $_previousCall = null; // last action called |
|
| 104 | + |
|
| 105 | + protected $_debugActif = false; // flag : mode debug is active |
|
| 106 | + protected $_debugOkUsage = false; // flag : the function memory_get_usage exist |
|
| 107 | + protected $_debugOkPeak = false; // flag : the function memory_get_peak_usage exist |
|
| 108 | + protected $_debugLevel = 0; // level in the debug |
|
| 109 | + protected $_debugStartTime = 0; // debug start time |
|
| 110 | + protected $_debugLastTime = 0; // debug stop time |
|
| 111 | + |
|
| 112 | + static protected $_subobj = null; // object html2pdf prepared in order to accelerate the creation of sub html2pdf |
|
| 113 | + static protected $_tables = array(); // static table to prepare the nested html tables |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * class constructor |
|
| 117 | + * |
|
| 118 | + * @access public |
|
| 119 | + * @param string $orientation page orientation, same as TCPDF |
|
| 120 | + * @param string $format The format used for pages, same as TCPDF |
|
| 121 | + * @param $tring $langue Langue : fr, en, it... |
|
| 122 | + * @param boolean $unicode TRUE means that the input text is unicode (default = true) |
|
| 123 | + * @param String $encoding charset encoding; default is UTF-8 |
|
| 124 | + * @param integer[] $marges Default marges (left, top, right, bottom) |
|
| 125 | + * @return HTML2PDF $this |
|
| 126 | + */ |
|
| 127 | + public function __construct($orientation = 'P', $format = 'A4', $langue = 'en', $unicode = true, $encoding = 'UTF-8', $marges = array(5, 5, 5, 8)) |
|
| 128 | + { |
|
| 129 | + // init the page number |
|
| 130 | + $this->_page = 0; |
|
| 131 | + $this->_firstPage = true; |
|
| 132 | + |
|
| 133 | + // save the parameters |
|
| 134 | + $this->_orientation = $orientation; |
|
| 135 | + $this->_format = $format; |
|
| 136 | + $this->_langue = strtolower($langue); |
|
| 137 | + $this->_unicode = $unicode; |
|
| 138 | + $this->_encoding = $encoding; |
|
| 139 | + |
|
| 140 | + // load the Local |
|
| 141 | + HTML2PDF_locale::load($this->_langue); |
|
| 142 | + |
|
| 143 | + // create the HTML2PDF_myPdf object |
|
| 144 | + $this->pdf = new HTML2PDF_myPdf($orientation, 'mm', $format, $unicode, $encoding); |
|
| 145 | + |
|
| 146 | + // init the CSS parsing object |
|
| 147 | + $this->parsingCss = new HTML2PDF_parsingCss($this->pdf); |
|
| 148 | + $this->parsingCss->fontSet(); |
|
| 149 | + $this->_defList = array(); |
|
| 150 | + |
|
| 151 | + // init some tests |
|
| 152 | + $this->setTestTdInOnePage(true); |
|
| 153 | + $this->setTestIsImage(true); |
|
| 154 | + $this->setTestIsDeprecated(true); |
|
| 155 | + |
|
| 156 | + // init the default font |
|
| 157 | + $this->setDefaultFont(null); |
|
| 158 | + |
|
| 159 | + // init the HTML parsing object |
|
| 160 | + $this->parsingHtml = new HTML2PDF_parsingHtml($this->_encoding); |
|
| 161 | + $this->_subHtml = null; |
|
| 162 | + $this->_subPart = false; |
|
| 163 | + |
|
| 164 | + // init the marges of the page |
|
| 165 | + if ( ! is_array($marges)) $marges = array($marges, $marges, $marges, $marges); |
|
| 166 | + $this->_setDefaultMargins($marges[0], $marges[1], $marges[2], $marges[3]); |
|
| 167 | + $this->_setMargins(); |
|
| 168 | + $this->_marges = array(); |
|
| 169 | + |
|
| 170 | + // init the form's fields |
|
| 171 | + $this->_lstField = array(); |
|
| 172 | + |
|
| 173 | + return $this; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Destructor |
|
| 178 | + * |
|
| 179 | + * @access public |
|
| 180 | + * @return null |
|
| 181 | + */ |
|
| 182 | + public function __destruct() |
|
| 183 | + { |
|
| 184 | + |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Clone to create a sub HTML2PDF from HTML2PDF::$_subobj |
|
| 189 | + * |
|
| 190 | + * @access public |
|
| 191 | + */ |
|
| 192 | + public function __clone() |
|
| 193 | + { |
|
| 194 | + $this->pdf = clone $this->pdf; |
|
| 195 | + $this->parsingHtml = clone $this->parsingHtml; |
|
| 196 | + $this->parsingCss = clone $this->parsingCss; |
|
| 197 | + $this->parsingCss->setPdfParent($this->pdf); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * set the debug mode to On |
|
| 202 | + * |
|
| 203 | + * @access public |
|
| 204 | + * @return HTML2PDF $this |
|
| 205 | + */ |
|
| 206 | + public function setModeDebug() |
|
| 207 | + { |
|
| 208 | + $time = microtime(true); |
|
| 209 | + |
|
| 210 | + $this->_debugActif = true; |
|
| 211 | + $this->_debugOkUsage = function_exists('memory_get_usage'); |
|
| 212 | + $this->_debugOkPeak = function_exists('memory_get_peak_usage'); |
|
| 213 | + $this->_debugStartTime = $time; |
|
| 214 | + $this->_debugLastTime = $time; |
|
| 215 | + |
|
| 216 | + $this->_DEBUG_stepline('step', 'time', 'delta', 'memory', 'peak'); |
|
| 217 | + $this->_DEBUG_add('Init debug'); |
|
| 218 | + |
|
| 219 | + return $this; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * Set the test of TD thdat can not take more than one page |
|
| 224 | + * |
|
| 225 | + * @access public |
|
| 226 | + * @param boolean $mode |
|
| 227 | + * @return HTML2PDF $this |
|
| 228 | + */ |
|
| 229 | + public function setTestTdInOnePage($mode = true) |
|
| 230 | + { |
|
| 231 | + $this->_testTdInOnepage = $mode ? true : false; |
|
| 232 | + |
|
| 233 | + return $this; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * Set the test if the images exist or not |
|
| 238 | + * |
|
| 239 | + * @access public |
|
| 240 | + * @param boolean $mode |
|
| 241 | + * @return HTML2PDF $this |
|
| 242 | + */ |
|
| 243 | + public function setTestIsImage($mode = true) |
|
| 244 | + { |
|
| 245 | + $this->_testIsImage = $mode ? true : false; |
|
| 246 | + |
|
| 247 | + return $this; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Set the test on deprecated functions |
|
| 252 | + * |
|
| 253 | + * @access public |
|
| 254 | + * @param boolean $mode |
|
| 255 | + * @return HTML2PDF $this |
|
| 256 | + */ |
|
| 257 | + public function setTestIsDeprecated($mode = true) |
|
| 258 | + { |
|
| 259 | + $this->_testIsDeprecated = $mode ? true : false; |
|
| 260 | + |
|
| 261 | + return $this; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * Set the default font to use, if no font is specify, or if the asked font does not exist |
|
| 266 | + * |
|
| 267 | + * @access public |
|
| 268 | + * @param string $default name of the default font to use. If null : Arial is no font is specify, and error if the asked font does not exist |
|
| 269 | + * @return HTML2PDF $this |
|
| 270 | + */ |
|
| 271 | + public function setDefaultFont($default = null) |
|
| 272 | + { |
|
| 273 | + $this->_defaultFont = $default; |
|
| 274 | + $this->parsingCss->setDefaultFont($default); |
|
| 275 | + |
|
| 276 | + return $this; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * add a font, see TCPDF function addFont |
|
| 281 | + * |
|
| 282 | + * @access public |
|
| 283 | + * @param string $family Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font. |
|
| 284 | + * @param string $style Font style. Possible values are (case insensitive):<ul><li>empty string: regular (default)</li><li>B: bold</li><li>I: italic</li><li>BI or IB: bold italic</li></ul> |
|
| 285 | + * @return HTML2PDF $this |
|
| 286 | + * @see TCPDF::addFont |
|
| 287 | + */ |
|
| 288 | + public function addFont($family, $style = '', $file = '') |
|
| 289 | + { |
|
| 290 | + $this->pdf->AddFont($family, $style, $file); |
|
| 291 | + |
|
| 292 | + return $this; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * display a automatic index, from the bookmarks |
|
| 297 | + * |
|
| 298 | + * @access public |
|
| 299 | + * @param string $titre index title |
|
| 300 | + * @param int $sizeTitle font size of the index title, in mm |
|
| 301 | + * @param int $sizeBookmark font size of the index, in mm |
|
| 302 | + * @param boolean $bookmarkTitle add a bookmark for the index, at his beginning |
|
| 303 | + * @param boolean $displayPage display the page numbers |
|
| 304 | + * @param int $onPage if null : at the end of the document on a new page, else on the $onPage page |
|
| 305 | + * @param string $fontName font name to use |
|
| 306 | + * @return null |
|
| 307 | + */ |
|
| 308 | + public function createIndex($titre = 'Index', $sizeTitle = 20, $sizeBookmark = 15, $bookmarkTitle = true, $displayPage = true, $onPage = null, $fontName = 'helvetica') |
|
| 309 | + { |
|
| 310 | + $oldPage = $this->_INDEX_NewPage($onPage); |
|
| 311 | + $this->pdf->createIndex($this, $titre, $sizeTitle, $sizeBookmark, $bookmarkTitle, $displayPage, $onPage, $fontName); |
|
| 312 | + if ($oldPage) { |
|
| 313 | + $this->pdf->setPage($oldPage); |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * clean up the objects |
|
| 319 | + * |
|
| 320 | + * @access protected |
|
| 321 | + */ |
|
| 322 | + protected function _cleanUp() |
|
| 323 | + { |
|
| 324 | + HTML2PDF::$_subobj = null; |
|
| 325 | + HTML2PDF::$_tables = array(); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * Send the document to a given destination: string, local file or browser. |
|
| 330 | + * Dest can be : |
|
| 331 | + * I : send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF. |
|
| 332 | + * D : send to the browser and force a file download with the name given by name. |
|
| 333 | + * F : save to a local server file with the name given by name. |
|
| 334 | + * S : return the document as a string. name is ignored. |
|
| 335 | + * FI: equivalent to F + I option |
|
| 336 | + * FD: equivalent to F + D option |
|
| 337 | + * true => I |
|
| 338 | + * false => S |
|
| 339 | + * |
|
| 340 | + * @param string $name The name of the file when saved. |
|
| 341 | + * @param string $dest Destination where to send the document. |
|
| 342 | + * @return string content of the PDF, if $dest=S |
|
| 343 | + * @see TCPDF::close |
|
| 344 | + * @access public |
|
| 345 | + */ |
|
| 346 | + public function Output($name = '', $dest = false) |
|
| 347 | + { |
|
| 348 | + // close the pdf and clean up |
|
| 349 | + $this->_cleanUp(); |
|
| 350 | + |
|
| 351 | + // if on debug mode |
|
| 352 | + if ($this->_debugActif) { |
|
| 353 | + $this->_DEBUG_add('Before output'); |
|
| 354 | + $this->pdf->Close(); |
|
| 355 | + exit; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + // complete parameters |
|
| 359 | + if ($dest === false) $dest = 'I'; |
|
| 360 | + if ($dest === true) $dest = 'S'; |
|
| 361 | + if ($dest === '') $dest = 'I'; |
|
| 362 | + if ($name == '') $name = 'document.pdf'; |
|
| 363 | + |
|
| 364 | + // clean up the destination |
|
| 365 | + $dest = strtoupper($dest); |
|
| 366 | + if ( ! in_array($dest, array('I', 'D', 'F', 'S', 'FI', 'FD'))) $dest = 'I'; |
|
| 367 | + |
|
| 368 | + // the name must be a PDF name |
|
| 369 | + if (strtolower(substr($name, -4)) != '.pdf') { |
|
| 370 | + throw new HTML2PDF_exception(0, 'The output document name "'.$name.'" is not a PDF name'); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + // call the output of TCPDF |
|
| 374 | + return $this->pdf->Output($name, $dest); |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * convert HTML to PDF |
|
| 379 | + * |
|
| 380 | + * @access public |
|
| 381 | + * @param string $html |
|
| 382 | + * @param boolean $debugVue enable the HTML debug vue |
|
| 383 | + * @return null |
|
| 384 | + */ |
|
| 385 | + public function writeHTML($html, $debugVue = false) |
|
| 386 | + { |
|
| 387 | + // if it is a real html page, we have to convert it |
|
| 388 | + if (preg_match('/<body/isU', $html)) { |
|
| 389 | + $html = $this->getHtmlFromPage($html); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + $html = str_replace('[[date_y]]', date('Y'), $html); |
|
| 393 | + $html = str_replace('[[date_m]]', date('m'), $html); |
|
| 394 | + $html = str_replace('[[date_d]]', date('d'), $html); |
|
| 395 | + |
|
| 396 | + $html = str_replace('[[date_h]]', date('H'), $html); |
|
| 397 | + $html = str_replace('[[date_i]]', date('i'), $html); |
|
| 398 | + $html = str_replace('[[date_s]]', date('s'), $html); |
|
| 399 | + |
|
| 400 | + // If we are in HTML debug vue : display the HTML |
|
| 401 | + if ($debugVue) { |
|
| 402 | + return $this->_vueHTML($html); |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + // convert HTMl to PDF |
|
| 406 | + $this->parsingCss->readStyle($html); |
|
| 407 | + $this->parsingHtml->setHTML($html); |
|
| 408 | + $this->parsingHtml->parse(); |
|
| 409 | + $this->_makeHTMLcode(); |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + /** |
|
| 413 | + * convert the HTML of a real page, to a code adapted to HTML2PDF |
|
| 414 | + * |
|
| 415 | + * @access public |
|
| 416 | + * @param string HTML of a real page |
|
| 417 | + * @param string $html |
|
| 418 | + * @return string HTML adapted to HTML2PDF |
|
| 419 | + */ |
|
| 420 | + public function getHtmlFromPage($html) |
|
| 421 | + { |
|
| 422 | + $html = str_replace('<BODY', '<body', $html); |
|
| 423 | + $html = str_replace('</BODY', '</body', $html); |
|
| 424 | + |
|
| 425 | + // extract the content |
|
| 426 | + $res = explode('<body', $html); |
|
| 427 | + if (count($res) < 2) return $html; |
|
| 428 | + $content = '<page'.$res[1]; |
|
| 429 | + $content = explode('</body', $content); |
|
| 430 | + $content = $content[0].'</page>'; |
|
| 431 | + |
|
| 432 | + // extract the link tags |
|
| 433 | + preg_match_all('/<link([^>]*)>/isU', $html, $match); |
|
| 434 | + foreach ($match[0] as $src) |
|
| 435 | + $content = $src.'</link>'.$content; |
|
| 436 | + |
|
| 437 | + // extract the css style tags |
|
| 438 | + preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match); |
|
| 439 | + foreach ($match[0] as $src) |
|
| 440 | + $content = $src.$content; |
|
| 441 | + |
|
| 442 | + return $content; |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * init a sub HTML2PDF. does not use it directly. Only the method createSubHTML must use it |
|
| 447 | + * |
|
| 448 | + * @access public |
|
| 449 | + * @param string $format |
|
| 450 | + * @param string $orientation |
|
| 451 | + * @param array $marge |
|
| 452 | + * @param integer $page |
|
| 453 | + * @param array $defLIST |
|
| 454 | + * @param integer $myLastPageGroup |
|
| 455 | + * @param integer $myLastPageGroupNb |
|
| 456 | + */ |
|
| 457 | + public function initSubHtml($format, $orientation, $marge, $page, $defLIST, $myLastPageGroup, $myLastPageGroupNb) |
|
| 458 | + { |
|
| 459 | + $this->_isSubPart = true; |
|
| 460 | + |
|
| 461 | + $this->parsingCss->setOnlyLeft(); |
|
| 462 | + |
|
| 463 | + $this->_setNewPage($format, $orientation, null, null, ($myLastPageGroup !== null)); |
|
| 464 | + |
|
| 465 | + $this->_saveMargin(0, 0, $marge); |
|
| 466 | + $this->_defList = $defLIST; |
|
| 467 | + |
|
| 468 | + $this->_page = $page; |
|
| 469 | + $this->pdf->setMyLastPageGroup($myLastPageGroup); |
|
| 470 | + $this->pdf->setMyLastPageGroupNb($myLastPageGroupNb); |
|
| 471 | + $this->pdf->setXY(0, 0); |
|
| 472 | + $this->parsingCss->fontSet(); |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + /** |
|
| 476 | + * display the content in HTML moden for debug |
|
| 477 | + * |
|
| 478 | + * @access protected |
|
| 479 | + * @param string $content |
|
| 480 | + */ |
|
| 481 | + protected function _vueHTML($content) |
|
| 482 | + { |
|
| 483 | + $content = preg_replace('/<page_header([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue01').' : $1<hr><div$1>', $content); |
|
| 484 | + $content = preg_replace('/<page_footer([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue02').' : $1<hr><div$1>', $content); |
|
| 485 | + $content = preg_replace('/<page([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue03').' : $1<hr><div$1>', $content); |
|
| 486 | + $content = preg_replace('/<\/page([^>]*)>/isU', '</div><hr>', $content); |
|
| 487 | + $content = preg_replace('/<bookmark([^>]*)>/isU', '<hr>bookmark : $1<hr>', $content); |
|
| 488 | + $content = preg_replace('/<\/bookmark([^>]*)>/isU', '', $content); |
|
| 489 | + $content = preg_replace('/<barcode([^>]*)>/isU', '<hr>barcode : $1<hr>', $content); |
|
| 490 | + $content = preg_replace('/<\/barcode([^>]*)>/isU', '', $content); |
|
| 491 | + $content = preg_replace('/<qrcode([^>]*)>/isU', '<hr>qrcode : $1<hr>', $content); |
|
| 492 | + $content = preg_replace('/<\/qrcode([^>]*)>/isU', '', $content); |
|
| 493 | + |
|
| 494 | + echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
|
| 496 | 495 | <html> |
| 497 | 496 | <head> |
| 498 | 497 | <title>'.HTML2PDF_locale::get('vue04').' HTML</title> |
@@ -502,6113 +501,6113 @@ discard block |
||
| 502 | 501 | '.$content.' |
| 503 | 502 | </body> |
| 504 | 503 | </html>'; |
| 505 | - exit; |
|
| 506 | - } |
|
| 507 | - |
|
| 508 | - /** |
|
| 509 | - * set the default margins of the page |
|
| 510 | - * |
|
| 511 | - * @access protected |
|
| 512 | - * @param int $left (mm, left margin) |
|
| 513 | - * @param int $top (mm, top margin) |
|
| 514 | - * @param int $right (mm, right margin, if null => left=right) |
|
| 515 | - * @param int $bottom (mm, bottom margin, if null => bottom=8mm) |
|
| 516 | - */ |
|
| 517 | - protected function _setDefaultMargins($left, $top, $right = null, $bottom = null) |
|
| 518 | - { |
|
| 519 | - if ($right === null) $right = $left; |
|
| 520 | - if ($bottom === null) $bottom = 8; |
|
| 521 | - |
|
| 522 | - $this->_defaultLeft = $this->parsingCss->ConvertToMM($left.'mm'); |
|
| 523 | - $this->_defaultTop = $this->parsingCss->ConvertToMM($top.'mm'); |
|
| 524 | - $this->_defaultRight = $this->parsingCss->ConvertToMM($right.'mm'); |
|
| 525 | - $this->_defaultBottom = $this->parsingCss->ConvertToMM($bottom.'mm'); |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * create a new page |
|
| 530 | - * |
|
| 531 | - * @access protected |
|
| 532 | - * @param mixed $format |
|
| 533 | - * @param string $orientation |
|
| 534 | - * @param array $background background information |
|
| 535 | - * @param integer $curr real position in the html parseur (if break line in the write of a text) |
|
| 536 | - * @param boolean $resetPageNumber |
|
| 537 | - */ |
|
| 538 | - protected function _setNewPage($format = null, $orientation = '', $background = null, $curr = null, $resetPageNumber = false) |
|
| 539 | - { |
|
| 540 | - $this->_firstPage = false; |
|
| 541 | - |
|
| 542 | - $this->_format = $format ? $format : $this->_format; |
|
| 543 | - $this->_orientation = $orientation ? $orientation : $this->_orientation; |
|
| 544 | - $this->_background = $background !== null ? $background : $this->_background; |
|
| 545 | - $this->_maxY = 0; |
|
| 546 | - $this->_maxX = 0; |
|
| 547 | - $this->_maxH = 0; |
|
| 548 | - $this->_maxE = 0; |
|
| 549 | - |
|
| 550 | - $this->pdf->SetMargins($this->_defaultLeft, $this->_defaultTop, $this->_defaultRight); |
|
| 551 | - |
|
| 552 | - if ($resetPageNumber) { |
|
| 553 | - $this->pdf->startPageGroup(); |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - $this->pdf->AddPage($this->_orientation, $this->_format); |
|
| 557 | - |
|
| 558 | - if ($resetPageNumber) { |
|
| 559 | - $this->pdf->myStartPageGroup(); |
|
| 560 | - } |
|
| 561 | - |
|
| 562 | - $this->_page++; |
|
| 563 | - |
|
| 564 | - if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 565 | - if (is_array($this->_background)) { |
|
| 566 | - if (isset($this->_background['color']) && $this->_background['color']) { |
|
| 567 | - $this->pdf->setFillColorArray($this->_background['color']); |
|
| 568 | - $this->pdf->Rect(0, 0, $this->pdf->getW(), $this->pdf->getH(), 'F'); |
|
| 569 | - } |
|
| 570 | - |
|
| 571 | - if (isset($this->_background['img']) && $this->_background['img']) { |
|
| 572 | - $this->pdf->Image($this->_background['img'], $this->_background['posX'], $this->_background['posY'], $this->_background['width']); |
|
| 573 | - } |
|
| 574 | - } |
|
| 575 | - |
|
| 576 | - $this->_setPageHeader(); |
|
| 577 | - $this->_setPageFooter(); |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - $this->_setMargins(); |
|
| 581 | - $this->pdf->setY($this->_margeTop); |
|
| 582 | - |
|
| 583 | - $this->_setNewPositionForNewLine($curr); |
|
| 584 | - $this->_maxH = 0; |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - /** |
|
| 588 | - * set the real margin, using the default margins and the page margins |
|
| 589 | - * |
|
| 590 | - * @access protected |
|
| 591 | - */ |
|
| 592 | - protected function _setMargins() |
|
| 593 | - { |
|
| 594 | - // prepare the margins |
|
| 595 | - $this->_margeLeft = $this->_defaultLeft + (isset($this->_background['left']) ? $this->_background['left'] : 0); |
|
| 596 | - $this->_margeRight = $this->_defaultRight + (isset($this->_background['right']) ? $this->_background['right'] : 0); |
|
| 597 | - $this->_margeTop = $this->_defaultTop + (isset($this->_background['top']) ? $this->_background['top'] : 0); |
|
| 598 | - $this->_margeBottom = $this->_defaultBottom + (isset($this->_background['bottom']) ? $this->_background['bottom'] : 0); |
|
| 599 | - |
|
| 600 | - // set the PDF margins |
|
| 601 | - $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 602 | - $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 603 | - |
|
| 604 | - // set the float Margins |
|
| 605 | - $this->_pageMarges = array(); |
|
| 606 | - if ($this->_isInParagraph !== false) { |
|
| 607 | - $this->_pageMarges[floor($this->_margeTop * 100)] = array($this->_isInParagraph[0], $this->pdf->getW() - $this->_isInParagraph[1]); |
|
| 608 | - } else { |
|
| 609 | - $this->_pageMarges[floor($this->_margeTop * 100)] = array($this->_margeLeft, $this->pdf->getW() - $this->_margeRight); |
|
| 610 | - } |
|
| 611 | - } |
|
| 612 | - |
|
| 613 | - /** |
|
| 614 | - * add a debug step |
|
| 615 | - * |
|
| 616 | - * @access protected |
|
| 617 | - * @param string $name step name |
|
| 618 | - * @param boolean $level (true=up, false=down, null=nothing to do) |
|
| 619 | - * @return $this |
|
| 620 | - */ |
|
| 621 | - protected function _DEBUG_add($name, $level = null) |
|
| 622 | - { |
|
| 623 | - // if true : UP |
|
| 624 | - if ($level === true) $this->_debugLevel++; |
|
| 625 | - |
|
| 626 | - $name = str_repeat(' ', $this->_debugLevel).$name.($level === true ? ' Begin' : ($level === false ? ' End' : '')); |
|
| 627 | - $time = microtime(true); |
|
| 628 | - $usage = ($this->_debugOkUsage ? memory_get_usage() : 0); |
|
| 629 | - $peak = ($this->_debugOkPeak ? memory_get_peak_usage() : 0); |
|
| 630 | - |
|
| 631 | - $this->_DEBUG_stepline( |
|
| 632 | - $name, |
|
| 633 | - number_format(($time - $this->_debugStartTime) * 1000, 1, '.', ' ').' ms', |
|
| 634 | - number_format(($time - $this->_debugLastTime) * 1000, 1, '.', ' ').' ms', |
|
| 635 | - number_format($usage / 1024, 1, '.', ' ').' Ko', |
|
| 636 | - number_format($peak / 1024, 1, '.', ' ').' Ko' |
|
| 637 | - ); |
|
| 638 | - |
|
| 639 | - $this->_debugLastTime = $time; |
|
| 640 | - |
|
| 641 | - // it false : DOWN |
|
| 642 | - if ($level === false) $this->_debugLevel--; |
|
| 643 | - |
|
| 644 | - return $this; |
|
| 645 | - } |
|
| 646 | - |
|
| 647 | - /** |
|
| 648 | - * display a debug line |
|
| 649 | - * |
|
| 650 | - * |
|
| 651 | - * @access protected |
|
| 652 | - * @param string $name |
|
| 653 | - * @param string $timeTotal |
|
| 654 | - * @param string $timeStep |
|
| 655 | - * @param string $memoryUsage |
|
| 656 | - * @param string $memoryPeak |
|
| 657 | - */ |
|
| 658 | - protected function _DEBUG_stepline($name, $timeTotal, $timeStep, $memoryUsage, $memoryPeak) |
|
| 659 | - { |
|
| 660 | - $txt = str_pad($name, 30, ' ', STR_PAD_RIGHT). |
|
| 661 | - str_pad($timeTotal, 12, ' ', STR_PAD_LEFT). |
|
| 662 | - str_pad($timeStep, 12, ' ', STR_PAD_LEFT). |
|
| 663 | - str_pad($memoryUsage, 15, ' ', STR_PAD_LEFT). |
|
| 664 | - str_pad($memoryPeak, 15, ' ', STR_PAD_LEFT); |
|
| 665 | - |
|
| 666 | - echo '<pre style="padding:0; margin:0">'.$txt.'</pre>'; |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - /** |
|
| 670 | - * get the Min and Max X, for Y (use the float margins) |
|
| 671 | - * |
|
| 672 | - * @access protected |
|
| 673 | - * @param float $y |
|
| 674 | - * @return array(float, float) |
|
| 675 | - */ |
|
| 676 | - protected function _getMargins($y) |
|
| 677 | - { |
|
| 678 | - $y = floor($y * 100); |
|
| 679 | - $x = array($this->pdf->getlMargin(), $this->pdf->getW() - $this->pdf->getrMargin()); |
|
| 680 | - |
|
| 681 | - foreach ($this->_pageMarges as $mY => $mX) |
|
| 682 | - if ($mY <= $y) $x = $mX; |
|
| 683 | - |
|
| 684 | - return $x; |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - /** |
|
| 688 | - * Add margins, for a float |
|
| 689 | - * |
|
| 690 | - * @access protected |
|
| 691 | - * @param string $float (left / right) |
|
| 692 | - * @param float $xLeft |
|
| 693 | - * @param float $yTop |
|
| 694 | - * @param float $xRight |
|
| 695 | - * @param float $yBottom |
|
| 696 | - */ |
|
| 697 | - protected function _addMargins($float, $xLeft, $yTop, $xRight, $yBottom) |
|
| 698 | - { |
|
| 699 | - // get the current float margins, for top and bottom |
|
| 700 | - $oldTop = $this->_getMargins($yTop); |
|
| 701 | - $oldBottom = $this->_getMargins($yBottom); |
|
| 702 | - |
|
| 703 | - // update the top float margin |
|
| 704 | - if ($float == 'left' && $oldTop[0] < $xRight) $oldTop[0] = $xRight; |
|
| 705 | - if ($float == 'right' && $oldTop[1] > $xLeft) $oldTop[1] = $xLeft; |
|
| 706 | - |
|
| 707 | - $yTop = floor($yTop * 100); |
|
| 708 | - $yBottom = floor($yBottom * 100); |
|
| 709 | - |
|
| 710 | - // erase all the float margins that are smaller than the new one |
|
| 711 | - foreach ($this->_pageMarges as $mY => $mX) { |
|
| 712 | - if ($mY < $yTop) continue; |
|
| 713 | - if ($mY > $yBottom) break; |
|
| 714 | - if ($float == 'left' && $this->_pageMarges[$mY][0] < $xRight) unset($this->_pageMarges[$mY]); |
|
| 715 | - if ($float == 'right' && $this->_pageMarges[$mY][1] > $xLeft) unset($this->_pageMarges[$mY]); |
|
| 716 | - } |
|
| 717 | - |
|
| 718 | - // save the new Top and Bottom margins |
|
| 719 | - $this->_pageMarges[$yTop] = $oldTop; |
|
| 720 | - $this->_pageMarges[$yBottom] = $oldBottom; |
|
| 721 | - |
|
| 722 | - // sort the margins |
|
| 723 | - ksort($this->_pageMarges); |
|
| 724 | - |
|
| 725 | - // we are just after float |
|
| 726 | - $this->_isAfterFloat = true; |
|
| 727 | - } |
|
| 728 | - |
|
| 729 | - /** |
|
| 730 | - * Save old margins (push), and set new ones |
|
| 731 | - * |
|
| 732 | - * @access protected |
|
| 733 | - * @param float $ml left margin |
|
| 734 | - * @param float $mt top margin |
|
| 735 | - * @param float $mr right margin |
|
| 736 | - */ |
|
| 737 | - protected function _saveMargin($ml, $mt, $mr) |
|
| 738 | - { |
|
| 739 | - // save old margins |
|
| 740 | - $this->_marges[] = array('l' => $this->pdf->getlMargin(), 't' => $this->pdf->gettMargin(), 'r' => $this->pdf->getrMargin(), 'page' => $this->_pageMarges); |
|
| 741 | - |
|
| 742 | - // set new ones |
|
| 743 | - $this->pdf->SetMargins($ml, $mt, $mr); |
|
| 744 | - |
|
| 745 | - // prepare for float margins |
|
| 746 | - $this->_pageMarges = array(); |
|
| 747 | - $this->_pageMarges[floor($mt * 100)] = array($ml, $this->pdf->getW() - $mr); |
|
| 748 | - } |
|
| 749 | - |
|
| 750 | - /** |
|
| 751 | - * load the last saved margins (pop) |
|
| 752 | - * |
|
| 753 | - * @access protected |
|
| 754 | - */ |
|
| 755 | - protected function _loadMargin() |
|
| 756 | - { |
|
| 757 | - $old = array_pop($this->_marges); |
|
| 758 | - if ($old) { |
|
| 759 | - $ml = $old['l']; |
|
| 760 | - $mt = $old['t']; |
|
| 761 | - $mr = $old['r']; |
|
| 762 | - $mP = $old['page']; |
|
| 763 | - } else { |
|
| 764 | - $ml = $this->_margeLeft; |
|
| 765 | - $mt = 0; |
|
| 766 | - $mr = $this->_margeRight; |
|
| 767 | - $mP = array($mt => array($ml, $this->pdf->getW() - $mr)); |
|
| 768 | - } |
|
| 769 | - |
|
| 770 | - $this->pdf->SetMargins($ml, $mt, $mr); |
|
| 771 | - $this->_pageMarges = $mP; |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - /** |
|
| 775 | - * save the current maxs (push) |
|
| 776 | - * |
|
| 777 | - * @access protected |
|
| 778 | - */ |
|
| 779 | - protected function _saveMax() |
|
| 780 | - { |
|
| 781 | - $this->_maxSave[] = array($this->_maxX, $this->_maxY, $this->_maxH, $this->_maxE); |
|
| 782 | - } |
|
| 783 | - |
|
| 784 | - /** |
|
| 785 | - * load the last saved current maxs (pop) |
|
| 786 | - * |
|
| 787 | - * @access protected |
|
| 788 | - */ |
|
| 789 | - protected function _loadMax() |
|
| 790 | - { |
|
| 791 | - $old = array_pop($this->_maxSave); |
|
| 792 | - |
|
| 793 | - if ($old) { |
|
| 794 | - $this->_maxX = $old[0]; |
|
| 795 | - $this->_maxY = $old[1]; |
|
| 796 | - $this->_maxH = $old[2]; |
|
| 797 | - $this->_maxE = $old[3]; |
|
| 798 | - } else { |
|
| 799 | - $this->_maxX = 0; |
|
| 800 | - $this->_maxY = 0; |
|
| 801 | - $this->_maxH = 0; |
|
| 802 | - $this->_maxE = 0; |
|
| 803 | - } |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - /** |
|
| 807 | - * draw the PDF header with the HTML in page_header |
|
| 808 | - * |
|
| 809 | - * @access protected |
|
| 810 | - */ |
|
| 811 | - protected function _setPageHeader() |
|
| 812 | - { |
|
| 813 | - if ( ! count($this->_subHEADER)) return false; |
|
| 814 | - |
|
| 815 | - $oldParsePos = $this->_parsePos; |
|
| 816 | - $oldParseCode = $this->parsingHtml->code; |
|
| 817 | - |
|
| 818 | - $this->_parsePos = 0; |
|
| 819 | - $this->parsingHtml->code = $this->_subHEADER; |
|
| 820 | - $this->_makeHTMLcode(); |
|
| 821 | - |
|
| 822 | - $this->_parsePos = $oldParsePos; |
|
| 823 | - $this->parsingHtml->code = $oldParseCode; |
|
| 824 | - } |
|
| 825 | - |
|
| 826 | - /** |
|
| 827 | - * draw the PDF footer with the HTML in page_footer |
|
| 828 | - * |
|
| 829 | - * @access protected |
|
| 830 | - */ |
|
| 831 | - protected function _setPageFooter() |
|
| 832 | - { |
|
| 833 | - if ( ! count($this->_subFOOTER)) return false; |
|
| 834 | - |
|
| 835 | - $oldParsePos = $this->_parsePos; |
|
| 836 | - $oldParseCode = $this->parsingHtml->code; |
|
| 837 | - |
|
| 838 | - $this->_parsePos = 0; |
|
| 839 | - $this->parsingHtml->code = $this->_subFOOTER; |
|
| 840 | - $this->_isInFooter = true; |
|
| 841 | - $this->_makeHTMLcode(); |
|
| 842 | - $this->_isInFooter = false; |
|
| 843 | - |
|
| 844 | - $this->_parsePos = $oldParsePos; |
|
| 845 | - $this->parsingHtml->code = $oldParseCode; |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - /** |
|
| 849 | - * new line, with a specific height |
|
| 850 | - * |
|
| 851 | - * @access protected |
|
| 852 | - * @param float $h |
|
| 853 | - * @param integer $curr real current position in the text, if new line in the write of a text |
|
| 854 | - */ |
|
| 855 | - protected function _setNewLine($h, $curr = null) |
|
| 856 | - { |
|
| 857 | - $this->pdf->Ln($h); |
|
| 858 | - $this->_setNewPositionForNewLine($curr); |
|
| 859 | - } |
|
| 860 | - |
|
| 861 | - /** |
|
| 862 | - * calculate the start position of the next line, depending on the text-align |
|
| 863 | - * |
|
| 864 | - * @access protected |
|
| 865 | - * @param integer $curr real current position in the text, if new line in the write of a text |
|
| 866 | - */ |
|
| 867 | - protected function _setNewPositionForNewLine($curr = null) |
|
| 868 | - { |
|
| 869 | - // get the margins for the current line |
|
| 870 | - list($lx, $rx) = $this->_getMargins($this->pdf->getY()); |
|
| 871 | - $this->pdf->setX($lx); |
|
| 872 | - $wMax = $rx - $lx; |
|
| 873 | - $this->_currentH = 0; |
|
| 874 | - |
|
| 875 | - // if subPart => return because align left |
|
| 876 | - if ($this->_subPart || $this->_isSubPart || $this->_isForOneLine) { |
|
| 877 | - $this->pdf->setWordSpacing(0); |
|
| 878 | - return null; |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - // create the sub object |
|
| 882 | - $sub = null; |
|
| 883 | - $this->_createSubHTML($sub); |
|
| 884 | - $sub->_saveMargin(0, 0, $sub->pdf->getW() - $wMax); |
|
| 885 | - $sub->_isForOneLine = true; |
|
| 886 | - $sub->_parsePos = $this->_parsePos; |
|
| 887 | - $sub->parsingHtml->code = $this->parsingHtml->code; |
|
| 888 | - |
|
| 889 | - // if $curr => adapt the current position of the parsing |
|
| 890 | - if ($curr !== null && $sub->parsingHtml->code[$this->_parsePos]['name'] == 'write') { |
|
| 891 | - $txt = $sub->parsingHtml->code[$this->_parsePos]['param']['txt']; |
|
| 892 | - $txt = str_replace('[[page_cu]]', $sub->pdf->getMyNumPage($this->_page), $txt); |
|
| 893 | - $sub->parsingHtml->code[$this->_parsePos]['param']['txt'] = substr($txt, $curr + 1); |
|
| 894 | - } else |
|
| 895 | - $sub->_parsePos++; |
|
| 896 | - |
|
| 897 | - // for each element of the parsing => load the action |
|
| 898 | - $res = null; |
|
| 899 | - for ($sub->_parsePos; $sub->_parsePos < count($sub->parsingHtml->code); $sub->_parsePos++) { |
|
| 900 | - $action = $sub->parsingHtml->code[$sub->_parsePos]; |
|
| 901 | - $res = $sub->_executeAction($action); |
|
| 902 | - if ( ! $res) break; |
|
| 903 | - } |
|
| 904 | - |
|
| 905 | - $w = $sub->_maxX; // max width |
|
| 906 | - $h = $sub->_maxH; // max height |
|
| 907 | - $e = ($res === null ? $sub->_maxE : 0); // maxnumber of elemets on the line |
|
| 908 | - |
|
| 909 | - // destroy the sub HTML |
|
| 910 | - $this->_destroySubHTML($sub); |
|
| 911 | - |
|
| 912 | - // adapt the start of the line, depending on the text-align |
|
| 913 | - if ($this->parsingCss->value['text-align'] == 'center') |
|
| 914 | - $this->pdf->setX(($rx + $this->pdf->getX() - $w) * 0.5 - 0.01); |
|
| 915 | - else if ($this->parsingCss->value['text-align'] == 'right') |
|
| 916 | - $this->pdf->setX($rx - $w - 0.01); |
|
| 917 | - else |
|
| 918 | - $this->pdf->setX($lx); |
|
| 919 | - |
|
| 920 | - // set the height of the line |
|
| 921 | - $this->_currentH = $h; |
|
| 922 | - |
|
| 923 | - // if justify => set the word spacing |
|
| 924 | - if ($this->parsingCss->value['text-align'] == 'justify' && $e > 1) { |
|
| 925 | - $this->pdf->setWordSpacing(($wMax - $w) / ($e - 1)); |
|
| 926 | - } else { |
|
| 927 | - $this->pdf->setWordSpacing(0); |
|
| 928 | - } |
|
| 929 | - } |
|
| 930 | - |
|
| 931 | - /** |
|
| 932 | - * prepare HTML2PDF::$_subobj (used for create the sub HTML2PDF objects |
|
| 933 | - * |
|
| 934 | - * @access protected |
|
| 935 | - */ |
|
| 936 | - protected function _prepareSubObj() |
|
| 937 | - { |
|
| 938 | - $pdf = null; |
|
| 939 | - |
|
| 940 | - // create the sub object |
|
| 941 | - HTML2PDF::$_subobj = new HTML2PDF( |
|
| 942 | - $this->_orientation, |
|
| 943 | - $this->_format, |
|
| 944 | - $this->_langue, |
|
| 945 | - $this->_unicode, |
|
| 946 | - $this->_encoding, |
|
| 947 | - array($this->_defaultLeft, $this->_defaultTop, $this->_defaultRight, $this->_defaultBottom) |
|
| 948 | - ); |
|
| 949 | - |
|
| 950 | - // init |
|
| 951 | - HTML2PDF::$_subobj->setTestTdInOnePage($this->_testTdInOnepage); |
|
| 952 | - HTML2PDF::$_subobj->setTestIsImage($this->_testIsImage); |
|
| 953 | - HTML2PDF::$_subobj->setTestIsDeprecated($this->_testIsDeprecated); |
|
| 954 | - HTML2PDF::$_subobj->setDefaultFont($this->_defaultFont); |
|
| 955 | - HTML2PDF::$_subobj->parsingCss->css = &$this->parsingCss->css; |
|
| 956 | - HTML2PDF::$_subobj->parsingCss->cssKeys = &$this->parsingCss->cssKeys; |
|
| 957 | - |
|
| 958 | - // clone font from the original PDF |
|
| 959 | - HTML2PDF::$_subobj->pdf->cloneFontFrom($this->pdf); |
|
| 960 | - |
|
| 961 | - // remove the link to the parent |
|
| 962 | - HTML2PDF::$_subobj->parsingCss->setPdfParent($pdf); |
|
| 963 | - } |
|
| 964 | - |
|
| 965 | - /** |
|
| 966 | - * create a sub HTML2PDF, to calculate the multi-tables |
|
| 967 | - * |
|
| 968 | - * @access protected |
|
| 969 | - * @param &HTML2PDF $subHtml sub HTML2PDF to create |
|
| 970 | - * @param integer $cellmargin if in a TD : cellmargin of this td |
|
| 971 | - */ |
|
| 972 | - protected function _createSubHTML(&$subHtml, $cellmargin = 0) |
|
| 973 | - { |
|
| 974 | - // prepare the subObject, if never prepare before |
|
| 975 | - if (HTML2PDF::$_subobj === null) { |
|
| 976 | - $this->_prepareSubObj(); |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - // calculate the width to use |
|
| 980 | - if ($this->parsingCss->value['width']) { |
|
| 981 | - $marge = $cellmargin * 2; |
|
| 982 | - $marge += $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['padding']['r']; |
|
| 983 | - $marge += $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['border']['r']['width']; |
|
| 984 | - $marge = $this->pdf->getW() - $this->parsingCss->value['width'] + $marge; |
|
| 985 | - } else { |
|
| 986 | - $marge = $this->_margeLeft + $this->_margeRight; |
|
| 987 | - } |
|
| 988 | - |
|
| 989 | - // BUGFIX : we have to call the method, because of a bug in php 5.1.6 |
|
| 990 | - HTML2PDF::$_subobj->pdf->getPage(); |
|
| 991 | - |
|
| 992 | - // clone the sub oject |
|
| 993 | - $subHtml = clone HTML2PDF::$_subobj; |
|
| 994 | - $subHtml->parsingCss->table = $this->parsingCss->table; |
|
| 995 | - $subHtml->parsingCss->value = $this->parsingCss->value; |
|
| 996 | - $subHtml->initSubHtml( |
|
| 997 | - $this->_format, |
|
| 998 | - $this->_orientation, |
|
| 999 | - $marge, |
|
| 1000 | - $this->_page, |
|
| 1001 | - $this->_defList, |
|
| 1002 | - $this->pdf->getMyLastPageGroup(), |
|
| 1003 | - $this->pdf->getMyLastPageGroupNb() |
|
| 1004 | - ); |
|
| 1005 | - } |
|
| 1006 | - |
|
| 1007 | - /** |
|
| 1008 | - * destroy a subHTML2PDF |
|
| 1009 | - * |
|
| 1010 | - * @access protected |
|
| 1011 | - */ |
|
| 1012 | - protected function _destroySubHTML(&$subHtml) |
|
| 1013 | - { |
|
| 1014 | - unset($subHtml); |
|
| 1015 | - $subHtml = null; |
|
| 1016 | - } |
|
| 1017 | - |
|
| 1018 | - /** |
|
| 1019 | - * Convert a arabic number in roman number |
|
| 1020 | - * |
|
| 1021 | - * @access protected |
|
| 1022 | - * @param integer $nbArabic |
|
| 1023 | - * @return string $nbRoman |
|
| 1024 | - */ |
|
| 1025 | - protected function _listeArab2Rom($nbArabic) |
|
| 1026 | - { |
|
| 1027 | - $nbBaseTen = array('I', 'X', 'C', 'M'); |
|
| 1028 | - $nbBaseFive = array('V', 'L', 'D'); |
|
| 1029 | - $nbRoman = ''; |
|
| 1030 | - |
|
| 1031 | - if ($nbArabic < 1) return $nbArabic; |
|
| 1032 | - if ($nbArabic > 3999) return $nbArabic; |
|
| 1033 | - |
|
| 1034 | - for ($i = 3; $i >= 0; $i--) { |
|
| 1035 | - $chiffre = floor($nbArabic / pow(10, $i)); |
|
| 1036 | - if ($chiffre >= 1) { |
|
| 1037 | - $nbArabic = $nbArabic - $chiffre * pow(10, $i); |
|
| 1038 | - if ($chiffre <= 3) { |
|
| 1039 | - for ($j = $chiffre; $j >= 1; $j--) { |
|
| 1040 | - $nbRoman = $nbRoman.$nbBaseTen[$i]; |
|
| 1041 | - } |
|
| 1042 | - } else if ($chiffre == 9) { |
|
| 1043 | - $nbRoman = $nbRoman.$nbBaseTen[$i].$nbBaseTen[$i + 1]; |
|
| 1044 | - } else if ($chiffre == 4) { |
|
| 1045 | - $nbRoman = $nbRoman.$nbBaseTen[$i].$nbBaseFive[$i]; |
|
| 1046 | - } else { |
|
| 1047 | - $nbRoman = $nbRoman.$nbBaseFive[$i]; |
|
| 1048 | - for ($j = $chiffre - 5; $j >= 1; $j--) { |
|
| 1049 | - $nbRoman = $nbRoman.$nbBaseTen[$i]; |
|
| 1050 | - } |
|
| 1051 | - } |
|
| 1052 | - } |
|
| 1053 | - } |
|
| 1054 | - return $nbRoman; |
|
| 1055 | - } |
|
| 1056 | - |
|
| 1057 | - /** |
|
| 1058 | - * add a LI to the current level |
|
| 1059 | - * |
|
| 1060 | - * @access protected |
|
| 1061 | - */ |
|
| 1062 | - protected function _listeAddLi() |
|
| 1063 | - { |
|
| 1064 | - $this->_defList[count($this->_defList) - 1]['nb']++; |
|
| 1065 | - } |
|
| 1066 | - |
|
| 1067 | - /** |
|
| 1068 | - * get the width to use for the column of the list |
|
| 1069 | - * |
|
| 1070 | - * @access protected |
|
| 1071 | - * @return string $width |
|
| 1072 | - */ |
|
| 1073 | - protected function _listeGetWidth() |
|
| 1074 | - { |
|
| 1075 | - return '7mm'; |
|
| 1076 | - } |
|
| 1077 | - |
|
| 1078 | - /** |
|
| 1079 | - * get the padding to use for the column of the list |
|
| 1080 | - * |
|
| 1081 | - * @access protected |
|
| 1082 | - * @return string $padding |
|
| 1083 | - */ |
|
| 1084 | - protected function _listeGetPadding() |
|
| 1085 | - { |
|
| 1086 | - return '1mm'; |
|
| 1087 | - } |
|
| 1088 | - |
|
| 1089 | - /** |
|
| 1090 | - * get the information of the li on the current level |
|
| 1091 | - * |
|
| 1092 | - * @access protected |
|
| 1093 | - * @return array(fontName, small size, string) |
|
| 1094 | - */ |
|
| 1095 | - protected function _listeGetLi() |
|
| 1096 | - { |
|
| 1097 | - $im = $this->_defList[count($this->_defList) - 1]['img']; |
|
| 1098 | - $st = $this->_defList[count($this->_defList) - 1]['style']; |
|
| 1099 | - $nb = $this->_defList[count($this->_defList) - 1]['nb']; |
|
| 1100 | - $up = (substr($st, 0, 6) == 'upper-'); |
|
| 1101 | - |
|
| 1102 | - if ($im) { |
|
| 1103 | - return array(false, false, $im); |
|
| 1104 | - } |
|
| 1105 | - |
|
| 1106 | - switch ($st) |
|
| 1107 | - { |
|
| 1108 | - case 'none': |
|
| 1109 | - return array('helvetica', true, ' '); |
|
| 1110 | - |
|
| 1111 | - case 'upper-alpha': |
|
| 1112 | - case 'lower-alpha': |
|
| 1113 | - $str = ''; |
|
| 1114 | - while ($nb > 26) { |
|
| 1115 | - $str = chr(96 + $nb % 26).$str; |
|
| 1116 | - $nb = floor($nb / 26); |
|
| 1117 | - } |
|
| 1118 | - $str = chr(96 + $nb).$str; |
|
| 1119 | - |
|
| 1120 | - return array('helvetica', false, ($up ? strtoupper($str) : $str).'.'); |
|
| 1121 | - |
|
| 1122 | - case 'upper-roman': |
|
| 1123 | - case 'lower-roman': |
|
| 1124 | - $str = $this->_listeArab2Rom($nb); |
|
| 1125 | - |
|
| 1126 | - return array('helvetica', false, ($up ? strtoupper($str) : $str).'.'); |
|
| 1127 | - |
|
| 1128 | - case 'decimal': |
|
| 1129 | - return array('helvetica', false, $nb.'.'); |
|
| 1130 | - |
|
| 1131 | - case 'square': |
|
| 1132 | - return array('zapfdingbats', true, chr(110)); |
|
| 1133 | - |
|
| 1134 | - case 'circle': |
|
| 1135 | - return array('zapfdingbats', true, chr(109)); |
|
| 1136 | - |
|
| 1137 | - case 'disc': |
|
| 1138 | - default: |
|
| 1139 | - return array('zapfdingbats', true, chr(108)); |
|
| 1140 | - } |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - /** |
|
| 1144 | - * add a level to the list |
|
| 1145 | - * |
|
| 1146 | - * @access protected |
|
| 1147 | - * @param string $type : ul, ol |
|
| 1148 | - * @param string $style : lower-alpha, ... |
|
| 1149 | - * @param string $img |
|
| 1150 | - */ |
|
| 1151 | - protected function _listeAddLevel($type = 'ul', $style = '', $img = null) |
|
| 1152 | - { |
|
| 1153 | - // get the url of the image, if we want to use a image |
|
| 1154 | - if ($img) { |
|
| 1155 | - if (preg_match('/^url\(([^)]+)\)$/isU', trim($img), $match)) { |
|
| 1156 | - $img = $match[1]; |
|
| 1157 | - } else { |
|
| 1158 | - $img = null; |
|
| 1159 | - } |
|
| 1160 | - } else { |
|
| 1161 | - $img = null; |
|
| 1162 | - } |
|
| 1163 | - |
|
| 1164 | - // prepare the datas |
|
| 1165 | - if ( ! in_array($type, array('ul', 'ol'))) $type = 'ul'; |
|
| 1166 | - if ( ! in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) $style = ''; |
|
| 1167 | - |
|
| 1168 | - if ( ! $style) { |
|
| 1169 | - if ($type == 'ul') $style = 'disc'; |
|
| 1170 | - else $style = 'decimal'; |
|
| 1171 | - } |
|
| 1172 | - |
|
| 1173 | - // add the new level |
|
| 1174 | - $this->_defList[count($this->_defList)] = array('style' => $style, 'nb' => 0, 'img' => $img); |
|
| 1175 | - } |
|
| 1176 | - |
|
| 1177 | - /** |
|
| 1178 | - * remove a level to the list |
|
| 1179 | - * |
|
| 1180 | - * @access protected |
|
| 1181 | - */ |
|
| 1182 | - protected function _listeDelLevel() |
|
| 1183 | - { |
|
| 1184 | - if (count($this->_defList)) { |
|
| 1185 | - unset($this->_defList[count($this->_defList) - 1]); |
|
| 1186 | - $this->_defList = array_values($this->_defList); |
|
| 1187 | - } |
|
| 1188 | - } |
|
| 1189 | - |
|
| 1190 | - /** |
|
| 1191 | - * execute the actions to convert the html |
|
| 1192 | - * |
|
| 1193 | - * @access protected |
|
| 1194 | - */ |
|
| 1195 | - protected function _makeHTMLcode() |
|
| 1196 | - { |
|
| 1197 | - // foreach elements of the parsing |
|
| 1198 | - for ($this->_parsePos = 0; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 1199 | - |
|
| 1200 | - // get the action to do |
|
| 1201 | - $action = $this->parsingHtml->code[$this->_parsePos]; |
|
| 1202 | - |
|
| 1203 | - // if it is a opening of table / ul / ol |
|
| 1204 | - if (in_array($action['name'], array('table', 'ul', 'ol')) && ! $action['close']) { |
|
| 1205 | - |
|
| 1206 | - // we will work as a sub HTML to calculate the size of the element |
|
| 1207 | - $this->_subPart = true; |
|
| 1208 | - |
|
| 1209 | - // get the name of the opening tag |
|
| 1210 | - $tagOpen = $action['name']; |
|
| 1211 | - |
|
| 1212 | - // save the actual pos on the parsing |
|
| 1213 | - $this->_tempPos = $this->_parsePos; |
|
| 1214 | - |
|
| 1215 | - // foreach elements, while we are in the opened tag |
|
| 1216 | - while (isset($this->parsingHtml->code[$this->_tempPos]) && ! ($this->parsingHtml->code[$this->_tempPos]['name'] == $tagOpen && $this->parsingHtml->code[$this->_tempPos]['close'])) { |
|
| 1217 | - // make the action |
|
| 1218 | - $this->_executeAction($this->parsingHtml->code[$this->_tempPos]); |
|
| 1219 | - $this->_tempPos++; |
|
| 1220 | - } |
|
| 1221 | - |
|
| 1222 | - // execute the closure of the tag |
|
| 1223 | - if (isset($this->parsingHtml->code[$this->_tempPos])) { |
|
| 1224 | - $this->_executeAction($this->parsingHtml->code[$this->_tempPos]); |
|
| 1225 | - } |
|
| 1226 | - |
|
| 1227 | - // end of the sub part |
|
| 1228 | - $this->_subPart = false; |
|
| 1229 | - } |
|
| 1230 | - |
|
| 1231 | - // execute the action |
|
| 1232 | - $this->_executeAction($action); |
|
| 1233 | - } |
|
| 1234 | - } |
|
| 1235 | - |
|
| 1236 | - /** |
|
| 1237 | - * execute the action from the parsing |
|
| 1238 | - * |
|
| 1239 | - * @access protected |
|
| 1240 | - * @param array $action |
|
| 1241 | - */ |
|
| 1242 | - protected function _executeAction($action) |
|
| 1243 | - { |
|
| 1244 | - // name of the action |
|
| 1245 | - $fnc = ($action['close'] ? '_tag_close_' : '_tag_open_').strtoupper($action['name']); |
|
| 1246 | - |
|
| 1247 | - // parameters of the action |
|
| 1248 | - $param = $action['param']; |
|
| 1249 | - |
|
| 1250 | - // if it the first action of the first page, and if it is not a open tag of PAGE => create the new page |
|
| 1251 | - if ($fnc != '_tag_open_PAGE' && $this->_firstPage) { |
|
| 1252 | - $this->_setNewPage(); |
|
| 1253 | - } |
|
| 1254 | - |
|
| 1255 | - // the action must exist |
|
| 1256 | - if ( ! is_callable(array(&$this, $fnc))) { |
|
| 1257 | - throw new HTML2PDF_exception(1, strtoupper($action['name']), $this->parsingHtml->getHtmlErrorCode($action['html_pos'])); |
|
| 1258 | - } |
|
| 1259 | - |
|
| 1260 | - // lauch the action |
|
| 1261 | - $res = $this->{$fnc}($param); |
|
| 1262 | - |
|
| 1263 | - // save the name of the action |
|
| 1264 | - $this->_previousCall = $fnc; |
|
| 1265 | - |
|
| 1266 | - // return the result |
|
| 1267 | - return $res; |
|
| 1268 | - } |
|
| 1269 | - |
|
| 1270 | - /** |
|
| 1271 | - * get the position of the element on the current line, depending on his height |
|
| 1272 | - * |
|
| 1273 | - * @access protected |
|
| 1274 | - * @param float $h |
|
| 1275 | - * @return float |
|
| 1276 | - */ |
|
| 1277 | - protected function _getElementY($h) |
|
| 1278 | - { |
|
| 1279 | - if ($this->_subPart || $this->_isSubPart || ! $this->_currentH || $this->_currentH < $h) |
|
| 1280 | - return 0; |
|
| 1281 | - |
|
| 1282 | - return ($this->_currentH - $h) * 0.8; |
|
| 1283 | - } |
|
| 1284 | - |
|
| 1285 | - /** |
|
| 1286 | - * make a break line |
|
| 1287 | - * |
|
| 1288 | - * @access protected |
|
| 1289 | - * @param float $h current line height |
|
| 1290 | - * @param integer $curr real current position in the text, if new line in the write of a text |
|
| 1291 | - */ |
|
| 1292 | - protected function _makeBreakLine($h, $curr = null) |
|
| 1293 | - { |
|
| 1294 | - if ($h) { |
|
| 1295 | - if (($this->pdf->getY() + $h < $this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter) |
|
| 1296 | - $this->_setNewLine($h, $curr); |
|
| 1297 | - else |
|
| 1298 | - $this->_setNewPage(null, '', null, $curr); |
|
| 1299 | - } else { |
|
| 1300 | - $this->_setNewPositionForNewLine($curr); |
|
| 1301 | - } |
|
| 1302 | - |
|
| 1303 | - $this->_maxH = 0; |
|
| 1304 | - $this->_maxE = 0; |
|
| 1305 | - } |
|
| 1306 | - |
|
| 1307 | - /** |
|
| 1308 | - * display a image |
|
| 1309 | - * |
|
| 1310 | - * @access protected |
|
| 1311 | - * @param string $src |
|
| 1312 | - * @param boolean $subLi if true=image of a list |
|
| 1313 | - * @return boolean depending on "isForOneLine" |
|
| 1314 | - */ |
|
| 1315 | - protected function _drawImage($src, $subLi = false) |
|
| 1316 | - { |
|
| 1317 | - // get the size of the image |
|
| 1318 | - // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini |
|
| 1319 | - |
|
| 1320 | - $infos = @getimagesize($src); |
|
| 1321 | - |
|
| 1322 | - // if the image does not exist, or can not be loaded |
|
| 1323 | - if (count($infos) < 2) { |
|
| 1324 | - // if the test is activ => exception |
|
| 1325 | - if ($this->_testIsImage) { |
|
| 1326 | - throw new HTML2PDF_exception(6, $src); |
|
| 1327 | - } |
|
| 1328 | - |
|
| 1329 | - // else, display a gray rectangle |
|
| 1330 | - $src = null; |
|
| 1331 | - $infos = array(16, 16); |
|
| 1332 | - } |
|
| 1333 | - |
|
| 1334 | - // convert the size of the image in the unit of the PDF |
|
| 1335 | - $imageWidth = $infos[0] / $this->pdf->getK(); |
|
| 1336 | - $imageHeight = $infos[1] / $this->pdf->getK(); |
|
| 1337 | - |
|
| 1338 | - // calculate the size from the css style |
|
| 1339 | - if ($this->parsingCss->value['width'] && $this->parsingCss->value['height']) { |
|
| 1340 | - $w = $this->parsingCss->value['width']; |
|
| 1341 | - $h = $this->parsingCss->value['height']; |
|
| 1342 | - } else if ($this->parsingCss->value['width']) { |
|
| 1343 | - $w = $this->parsingCss->value['width']; |
|
| 1344 | - $h = $imageHeight * $w / $imageWidth; |
|
| 1345 | - } else if ($this->parsingCss->value['height']) { |
|
| 1346 | - $h = $this->parsingCss->value['height']; |
|
| 1347 | - $w = $imageWidth * $h / $imageHeight; |
|
| 1348 | - } else { |
|
| 1349 | - // convert px to pt |
|
| 1350 | - $w = 72. / 96. * $imageWidth; |
|
| 1351 | - $h = 72. / 96. * $imageHeight; |
|
| 1352 | - } |
|
| 1353 | - |
|
| 1354 | - // are we in a float |
|
| 1355 | - $float = $this->parsingCss->getFloat(); |
|
| 1356 | - |
|
| 1357 | - // if we are in a float, but if something else if on the line => Break Line |
|
| 1358 | - if ($float && $this->_maxH) { |
|
| 1359 | - // make the break line (false if we are in "_isForOneLine" mode) |
|
| 1360 | - if ( ! $this->_tag_open_BR(array())) { |
|
| 1361 | - return false; |
|
| 1362 | - } |
|
| 1363 | - } |
|
| 1364 | - |
|
| 1365 | - // position of the image |
|
| 1366 | - $x = $this->pdf->getX(); |
|
| 1367 | - $y = $this->pdf->getY(); |
|
| 1368 | - |
|
| 1369 | - // if the image can not be put on the current line => new line |
|
| 1370 | - if ( ! $float && ($x + $w > $this->pdf->getW() - $this->pdf->getrMargin()) && $this->_maxH) { |
|
| 1371 | - if ($this->_isForOneLine) { |
|
| 1372 | - return false; |
|
| 1373 | - } |
|
| 1374 | - |
|
| 1375 | - // set the new line |
|
| 1376 | - $hnl = max($this->_maxH, $this->parsingCss->getLineHeight()); |
|
| 1377 | - $this->_setNewLine($hnl); |
|
| 1378 | - |
|
| 1379 | - // get the new position |
|
| 1380 | - $x = $this->pdf->getX(); |
|
| 1381 | - $y = $this->pdf->getY(); |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - // if the image can not be put on the current page |
|
| 1385 | - if (($y + $h > $this->pdf->getH() - $this->pdf->getbMargin()) && ! $this->_isInOverflow) { |
|
| 1386 | - // new page |
|
| 1387 | - $this->_setNewPage(); |
|
| 1388 | - |
|
| 1389 | - // get the new position |
|
| 1390 | - $x = $this->pdf->getX(); |
|
| 1391 | - $y = $this->pdf->getY(); |
|
| 1392 | - } |
|
| 1393 | - |
|
| 1394 | - // correction for display the image of a list |
|
| 1395 | - $hT = 0.80 * $this->parsingCss->value['font-size']; |
|
| 1396 | - if ($subLi && $h < $hT) { |
|
| 1397 | - $y += ($hT - $h); |
|
| 1398 | - } |
|
| 1399 | - |
|
| 1400 | - // add the margin top |
|
| 1401 | - $yc = $y - $this->parsingCss->value['margin']['t']; |
|
| 1402 | - |
|
| 1403 | - // get the width and the position of the parent |
|
| 1404 | - $old = $this->parsingCss->getOldValues(); |
|
| 1405 | - if ($old['width']) { |
|
| 1406 | - $parentWidth = $old['width']; |
|
| 1407 | - $parentX = $x; |
|
| 1408 | - } else { |
|
| 1409 | - $parentWidth = $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 1410 | - $parentX = $this->pdf->getlMargin(); |
|
| 1411 | - } |
|
| 1412 | - |
|
| 1413 | - // if we are in a gloat => adapt the parent position and width |
|
| 1414 | - if ($float) { |
|
| 1415 | - list($lx, $rx) = $this->_getMargins($yc); |
|
| 1416 | - $parentX = $lx; |
|
| 1417 | - $parentWidth = $rx - $lx; |
|
| 1418 | - } |
|
| 1419 | - |
|
| 1420 | - // calculate the position of the image, if align to the right |
|
| 1421 | - if ($parentWidth > $w && $float != 'left') { |
|
| 1422 | - if ($float == 'right' || $this->parsingCss->value['text-align'] == 'li_right') $x = $parentX + $parentWidth - $w - $this->parsingCss->value['margin']['r'] - $this->parsingCss->value['margin']['l']; |
|
| 1423 | - } |
|
| 1424 | - |
|
| 1425 | - // display the image |
|
| 1426 | - if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 1427 | - if ($src) { |
|
| 1428 | - $this->pdf->Image($src, $x, $y, $w, $h, '', $this->_isInLink); |
|
| 1429 | - } else { |
|
| 1430 | - // rectangle if the image can not be loaded |
|
| 1431 | - $this->pdf->setFillColorArray(array(240, 220, 220)); |
|
| 1432 | - $this->pdf->Rect($x, $y, $w, $h, 'F'); |
|
| 1433 | - } |
|
| 1434 | - } |
|
| 1435 | - |
|
| 1436 | - // apply the margins |
|
| 1437 | - $x -= $this->parsingCss->value['margin']['l']; |
|
| 1438 | - $y -= $this->parsingCss->value['margin']['t']; |
|
| 1439 | - $w += $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['margin']['r']; |
|
| 1440 | - $h += $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['margin']['b']; |
|
| 1441 | - |
|
| 1442 | - if ($float == 'left') { |
|
| 1443 | - // save the current max |
|
| 1444 | - $this->_maxX = max($this->_maxX, $x + $w); |
|
| 1445 | - $this->_maxY = max($this->_maxY, $y + $h); |
|
| 1446 | - |
|
| 1447 | - // add the image to the margins |
|
| 1448 | - $this->_addMargins($float, $x, $y, $x + $w, $y + $h); |
|
| 1449 | - |
|
| 1450 | - // get the new position |
|
| 1451 | - list($lx, $rx) = $this->_getMargins($yc); |
|
| 1452 | - $this->pdf->setXY($lx, $yc); |
|
| 1453 | - } else if ($float == 'right') { |
|
| 1454 | - // save the current max. We don't save the X because it is not the real max of the line |
|
| 1455 | - $this->_maxY = max($this->_maxY, $y + $h); |
|
| 1456 | - |
|
| 1457 | - // add the image to the margins |
|
| 1458 | - $this->_addMargins($float, $x, $y, $x + $w, $y + $h); |
|
| 1459 | - |
|
| 1460 | - // get the new position |
|
| 1461 | - list($lx, $rx) = $this->_getMargins($yc); |
|
| 1462 | - $this->pdf->setXY($lx, $yc); |
|
| 1463 | - } else { |
|
| 1464 | - // set the new position at the end of the image |
|
| 1465 | - $this->pdf->setX($x + $w); |
|
| 1466 | - |
|
| 1467 | - // save the current max |
|
| 1468 | - $this->_maxX = max($this->_maxX, $x + $w); |
|
| 1469 | - $this->_maxY = max($this->_maxY, $y + $h); |
|
| 1470 | - $this->_maxH = max($this->_maxH, $h); |
|
| 1471 | - } |
|
| 1472 | - |
|
| 1473 | - return true; |
|
| 1474 | - } |
|
| 1475 | - |
|
| 1476 | - /** |
|
| 1477 | - * draw a rectangle |
|
| 1478 | - * |
|
| 1479 | - * @access protected |
|
| 1480 | - * @param float $x |
|
| 1481 | - * @param float $y |
|
| 1482 | - * @param float $w |
|
| 1483 | - * @param float $h |
|
| 1484 | - * @param array $border |
|
| 1485 | - * @param float $padding - internal marge of the rectanble => not used, but... |
|
| 1486 | - * @param float $margin - external marge of the rectanble |
|
| 1487 | - * @param array $background |
|
| 1488 | - * @return boolean |
|
| 1489 | - */ |
|
| 1490 | - protected function _drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background) |
|
| 1491 | - { |
|
| 1492 | - // if we are in a subpart or if height is null => return false |
|
| 1493 | - if ($this->_subPart || $this->_isSubPart || $h === null) return false; |
|
| 1494 | - |
|
| 1495 | - // add the margin |
|
| 1496 | - $x += $margin; |
|
| 1497 | - $y += $margin; |
|
| 1498 | - $w -= $margin * 2; |
|
| 1499 | - $h -= $margin * 2; |
|
| 1500 | - |
|
| 1501 | - // get the radius of the border |
|
| 1502 | - $outTL = $border['radius']['tl']; |
|
| 1503 | - $outTR = $border['radius']['tr']; |
|
| 1504 | - $outBR = $border['radius']['br']; |
|
| 1505 | - $outBL = $border['radius']['bl']; |
|
| 1506 | - |
|
| 1507 | - // prepare the out radius |
|
| 1508 | - $outTL = ($outTL[0] && $outTL[1]) ? $outTL : null; |
|
| 1509 | - $outTR = ($outTR[0] && $outTR[1]) ? $outTR : null; |
|
| 1510 | - $outBR = ($outBR[0] && $outBR[1]) ? $outBR : null; |
|
| 1511 | - $outBL = ($outBL[0] && $outBL[1]) ? $outBL : null; |
|
| 1512 | - |
|
| 1513 | - // prepare the in radius |
|
| 1514 | - $inTL = $outTL; |
|
| 1515 | - $inTR = $outTR; |
|
| 1516 | - $inBR = $outBR; |
|
| 1517 | - $inBL = $outBL; |
|
| 1518 | - |
|
| 1519 | - if (is_array($inTL)) { |
|
| 1520 | - $inTL[0] -= $border['l']['width']; |
|
| 1521 | - $inTL[1] -= $border['t']['width']; |
|
| 1522 | - } |
|
| 1523 | - if (is_array($inTR)) { |
|
| 1524 | - $inTR[0] -= $border['r']['width']; |
|
| 1525 | - $inTR[1] -= $border['t']['width']; |
|
| 1526 | - } |
|
| 1527 | - if (is_array($inBR)) { |
|
| 1528 | - $inBR[0] -= $border['r']['width']; |
|
| 1529 | - $inBR[1] -= $border['b']['width']; |
|
| 1530 | - } |
|
| 1531 | - if (is_array($inBL)) { |
|
| 1532 | - $inBL[0] -= $border['l']['width']; |
|
| 1533 | - $inBL[1] -= $border['b']['width']; |
|
| 1534 | - } |
|
| 1535 | - |
|
| 1536 | - if ($inTL[0] <= 0 || $inTL[1] <= 0) $inTL = null; |
|
| 1537 | - if ($inTR[0] <= 0 || $inTR[1] <= 0) $inTR = null; |
|
| 1538 | - if ($inBR[0] <= 0 || $inBR[1] <= 0) $inBR = null; |
|
| 1539 | - if ($inBL[0] <= 0 || $inBL[1] <= 0) $inBL = null; |
|
| 1540 | - |
|
| 1541 | - // prepare the background color |
|
| 1542 | - $pdfStyle = ''; |
|
| 1543 | - if ($background['color']) { |
|
| 1544 | - $this->pdf->setFillColorArray($background['color']); |
|
| 1545 | - $pdfStyle .= 'F'; |
|
| 1546 | - } |
|
| 1547 | - |
|
| 1548 | - // if we have a background to fill => fill it with a path (because of the radius) |
|
| 1549 | - if ($pdfStyle) { |
|
| 1550 | - $this->pdf->clippingPathStart($x, $y, $w, $h, $outTL, $outTR, $outBL, $outBR); |
|
| 1551 | - $this->pdf->Rect($x, $y, $w, $h, $pdfStyle); |
|
| 1552 | - $this->pdf->clippingPathStop(); |
|
| 1553 | - } |
|
| 1554 | - |
|
| 1555 | - // prepare the background image |
|
| 1556 | - if ($background['image']) { |
|
| 1557 | - $iName = $background['image']; |
|
| 1558 | - $iPosition = $background['position'] !== null ? $background['position'] : array(0, 0); |
|
| 1559 | - $iRepeat = $background['repeat'] !== null ? $background['repeat'] : array(true, true); |
|
| 1560 | - |
|
| 1561 | - // size of the background without the borders |
|
| 1562 | - $bX = $x; |
|
| 1563 | - $bY = $y; |
|
| 1564 | - $bW = $w; |
|
| 1565 | - $bH = $h; |
|
| 1566 | - |
|
| 1567 | - if ($border['b']['width']) { |
|
| 1568 | - $bH -= $border['b']['width']; |
|
| 1569 | - } |
|
| 1570 | - if ($border['l']['width']) { |
|
| 1571 | - $bW -= $border['l']['width']; |
|
| 1572 | - $bX += $border['l']['width']; |
|
| 1573 | - } |
|
| 1574 | - if ($border['t']['width']) { |
|
| 1575 | - $bH -= $border['t']['width']; |
|
| 1576 | - $bY += $border['t']['width']; |
|
| 1577 | - } |
|
| 1578 | - if ($border['r']['width']) { |
|
| 1579 | - $bW -= $border['r']['width']; |
|
| 1580 | - } |
|
| 1581 | - |
|
| 1582 | - // get the size of the image |
|
| 1583 | - // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini |
|
| 1584 | - $imageInfos = @getimagesize($iName); |
|
| 1585 | - |
|
| 1586 | - // if the image can not be loaded |
|
| 1587 | - if (count($imageInfos) < 2) { |
|
| 1588 | - if ($this->_testIsImage) { |
|
| 1589 | - throw new HTML2PDF_exception(6, $iName); |
|
| 1590 | - } |
|
| 1591 | - } else { |
|
| 1592 | - // convert the size of the image from pixel to the unit of the PDF |
|
| 1593 | - $imageWidth = 72. / 96. * $imageInfos[0] / $this->pdf->getK(); |
|
| 1594 | - $imageHeight = 72. / 96. * $imageInfos[1] / $this->pdf->getK(); |
|
| 1595 | - |
|
| 1596 | - // prepare the position of the backgroung |
|
| 1597 | - if ($iRepeat[0]) $iPosition[0] = $bX; |
|
| 1598 | - else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1] * ($bW - $imageWidth) / 100; |
|
| 1599 | - else $iPosition[0] = $bX + $iPosition[0]; |
|
| 1600 | - |
|
| 1601 | - if ($iRepeat[1]) $iPosition[1] = $bY; |
|
| 1602 | - else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1] * ($bH - $imageHeight) / 100; |
|
| 1603 | - else $iPosition[1] = $bY + $iPosition[1]; |
|
| 1604 | - |
|
| 1605 | - $imageXmin = $bX; |
|
| 1606 | - $imageXmax = $bX + $bW; |
|
| 1607 | - $imageYmin = $bY; |
|
| 1608 | - $imageYmax = $bY + $bH; |
|
| 1609 | - |
|
| 1610 | - if ( ! $iRepeat[0] && ! $iRepeat[1]) { |
|
| 1611 | - $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0] + $imageWidth; |
|
| 1612 | - $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1] + $imageHeight; |
|
| 1613 | - } else if ($iRepeat[0] && ! $iRepeat[1]) { |
|
| 1614 | - $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1] + $imageHeight; |
|
| 1615 | - } else if ( ! $iRepeat[0] && $iRepeat[1]) { |
|
| 1616 | - $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0] + $imageWidth; |
|
| 1617 | - } |
|
| 1618 | - |
|
| 1619 | - // build the path to display the image (because of radius) |
|
| 1620 | - $this->pdf->clippingPathStart($bX, $bY, $bW, $bH, $inTL, $inTR, $inBL, $inBR); |
|
| 1621 | - |
|
| 1622 | - // repeat the image |
|
| 1623 | - for ($iY = $imageYmin; $iY < $imageYmax; $iY += $imageHeight) { |
|
| 1624 | - for ($iX = $imageXmin; $iX < $imageXmax; $iX += $imageWidth) { |
|
| 1625 | - $cX = null; |
|
| 1626 | - $cY = null; |
|
| 1627 | - $cW = $imageWidth; |
|
| 1628 | - $cH = $imageHeight; |
|
| 1629 | - if ($imageYmax - $iY < $imageHeight) { |
|
| 1630 | - $cX = $iX; |
|
| 1631 | - $cY = $iY; |
|
| 1632 | - $cH = $imageYmax - $iY; |
|
| 1633 | - } |
|
| 1634 | - if ($imageXmax - $iX < $imageWidth) { |
|
| 1635 | - $cX = $iX; |
|
| 1636 | - $cY = $iY; |
|
| 1637 | - $cW = $imageXmax - $iX; |
|
| 1638 | - } |
|
| 1639 | - |
|
| 1640 | - $this->pdf->Image($iName, $iX, $iY, $imageWidth, $imageHeight, '', ''); |
|
| 1641 | - } |
|
| 1642 | - } |
|
| 1643 | - |
|
| 1644 | - // end of the path |
|
| 1645 | - $this->pdf->clippingPathStop(); |
|
| 1646 | - } |
|
| 1647 | - } |
|
| 1648 | - |
|
| 1649 | - // adding some loose (0.01mm) |
|
| 1650 | - $loose = 0.01; |
|
| 1651 | - $x -= $loose; |
|
| 1652 | - $y -= $loose; |
|
| 1653 | - $w += 2. * $loose; |
|
| 1654 | - $h += 2. * $loose; |
|
| 1655 | - if ($border['l']['width']) $border['l']['width'] += 2. * $loose; |
|
| 1656 | - if ($border['t']['width']) $border['t']['width'] += 2. * $loose; |
|
| 1657 | - if ($border['r']['width']) $border['r']['width'] += 2. * $loose; |
|
| 1658 | - if ($border['b']['width']) $border['b']['width'] += 2. * $loose; |
|
| 1659 | - |
|
| 1660 | - // prepare the test on borders |
|
| 1661 | - $testBl = ($border['l']['width'] && $border['l']['color'][0] !== null); |
|
| 1662 | - $testBt = ($border['t']['width'] && $border['t']['color'][0] !== null); |
|
| 1663 | - $testBr = ($border['r']['width'] && $border['r']['color'][0] !== null); |
|
| 1664 | - $testBb = ($border['b']['width'] && $border['b']['color'][0] !== null); |
|
| 1665 | - |
|
| 1666 | - // draw the radius bottom-left |
|
| 1667 | - if (is_array($outBL) && ($testBb || $testBl)) { |
|
| 1668 | - if ($inBL) { |
|
| 1669 | - $courbe = array(); |
|
| 1670 | - $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h; |
|
| 1671 | - $courbe[] = $x; $courbe[] = $y + $h - $outBL[1]; |
|
| 1672 | - $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1673 | - $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $h - $outBL[1]; |
|
| 1674 | - $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $outBL[1]; |
|
| 1675 | - } else { |
|
| 1676 | - $courbe = array(); |
|
| 1677 | - $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h; |
|
| 1678 | - $courbe[] = $x; $courbe[] = $y + $h - $outBL[1]; |
|
| 1679 | - $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1680 | - $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $outBL[1]; |
|
| 1681 | - } |
|
| 1682 | - $this->_drawCurve($courbe, $border['l']['color']); |
|
| 1683 | - } |
|
| 1684 | - |
|
| 1685 | - // draw the radius left-top |
|
| 1686 | - if (is_array($outTL) && ($testBt || $testBl)) { |
|
| 1687 | - if ($inTL) { |
|
| 1688 | - $courbe = array(); |
|
| 1689 | - $courbe[] = $x; $courbe[] = $y + $outTL[1]; |
|
| 1690 | - $courbe[] = $x + $outTL[0]; $courbe[] = $y; |
|
| 1691 | - $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $outTL[1]; |
|
| 1692 | - $courbe[] = $x + $outTL[0]; $courbe[] = $y + $border['t']['width']; |
|
| 1693 | - $courbe[] = $x + $outTL[0]; $courbe[] = $y + $outTL[1]; |
|
| 1694 | - } else { |
|
| 1695 | - $courbe = array(); |
|
| 1696 | - $courbe[] = $x; $courbe[] = $y + $outTL[1]; |
|
| 1697 | - $courbe[] = $x + $outTL[0]; $courbe[] = $y; |
|
| 1698 | - $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $border['t']['width']; |
|
| 1699 | - $courbe[] = $x + $outTL[0]; $courbe[] = $y + $outTL[1]; |
|
| 1700 | - } |
|
| 1701 | - $this->_drawCurve($courbe, $border['t']['color']); |
|
| 1702 | - } |
|
| 1703 | - |
|
| 1704 | - // draw the radius top-right |
|
| 1705 | - if (is_array($outTR) && ($testBt || $testBr)) { |
|
| 1706 | - if ($inTR) { |
|
| 1707 | - $courbe = array(); |
|
| 1708 | - $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y; |
|
| 1709 | - $courbe[] = $x + $w; $courbe[] = $y + $outTR[1]; |
|
| 1710 | - $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $border['t']['width']; |
|
| 1711 | - $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $outTR[1]; |
|
| 1712 | - $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $outTR[1]; |
|
| 1713 | - } else { |
|
| 1714 | - $courbe = array(); |
|
| 1715 | - $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y; |
|
| 1716 | - $courbe[] = $x + $w; $courbe[] = $y + $outTR[1]; |
|
| 1717 | - $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $border['t']['width']; |
|
| 1718 | - $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $outTR[1]; |
|
| 1719 | - } |
|
| 1720 | - $this->_drawCurve($courbe, $border['r']['color']); |
|
| 1721 | - } |
|
| 1722 | - |
|
| 1723 | - // draw the radius right-bottom |
|
| 1724 | - if (is_array($outBR) && ($testBb || $testBr)) { |
|
| 1725 | - if ($inBR) { |
|
| 1726 | - $courbe = array(); |
|
| 1727 | - $courbe[] = $x + $w; $courbe[] = $y + $h - $outBR[1]; |
|
| 1728 | - $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h; |
|
| 1729 | - $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $h - $outBR[1]; |
|
| 1730 | - $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1731 | - $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $outBR[1]; |
|
| 1732 | - } else { |
|
| 1733 | - $courbe = array(); |
|
| 1734 | - $courbe[] = $x + $w; $courbe[] = $y + $h - $outBR[1]; |
|
| 1735 | - $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h; |
|
| 1736 | - $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1737 | - $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $outBR[1]; |
|
| 1738 | - } |
|
| 1739 | - $this->_drawCurve($courbe, $border['b']['color']); |
|
| 1740 | - } |
|
| 1741 | - |
|
| 1742 | - // draw the left border |
|
| 1743 | - if ($testBl) { |
|
| 1744 | - $pt = array(); |
|
| 1745 | - $pt[] = $x; $pt[] = $y + $h; |
|
| 1746 | - $pt[] = $x; $pt[] = $y + $h - $border['b']['width']; |
|
| 1747 | - $pt[] = $x; $pt[] = $y + $border['t']['width']; |
|
| 1748 | - $pt[] = $x; $pt[] = $y; |
|
| 1749 | - $pt[] = $x + $border['l']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1750 | - $pt[] = $x + $border['l']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1751 | - |
|
| 1752 | - $bord = 3; |
|
| 1753 | - if (is_array($outBL)) { |
|
| 1754 | - $bord -= 1; |
|
| 1755 | - $pt[3] -= $outBL[1] - $border['b']['width']; |
|
| 1756 | - if ($inBL) $pt[11] -= $inBL[1]; |
|
| 1757 | - unset($pt[0]); unset($pt[1]); |
|
| 1758 | - } |
|
| 1759 | - if (is_array($outTL)) { |
|
| 1760 | - $bord -= 2; |
|
| 1761 | - $pt[5] += $outTL[1] - $border['t']['width']; |
|
| 1762 | - if ($inTL) $pt[9] += $inTL[1]; |
|
| 1763 | - unset($pt[6]); unset($pt[7]); |
|
| 1764 | - } |
|
| 1765 | - |
|
| 1766 | - $pt = array_values($pt); |
|
| 1767 | - $this->_drawLine($pt, $border['l']['color'], $border['l']['type'], $border['l']['width'], $bord); |
|
| 1768 | - } |
|
| 1769 | - |
|
| 1770 | - // draw the top border |
|
| 1771 | - if ($testBt) { |
|
| 1772 | - $pt = array(); |
|
| 1773 | - $pt[] = $x; $pt[] = $y; |
|
| 1774 | - $pt[] = $x + $border['l']['width']; $pt[] = $y; |
|
| 1775 | - $pt[] = $x + $w - $border['r']['width']; $pt[] = $y; |
|
| 1776 | - $pt[] = $x + $w; $pt[] = $y; |
|
| 1777 | - $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1778 | - $pt[] = $x + $border['l']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1779 | - |
|
| 1780 | - $bord = 3; |
|
| 1781 | - if (is_array($outTL)) { |
|
| 1782 | - $bord -= 1; |
|
| 1783 | - $pt[2] += $outTL[0] - $border['l']['width']; |
|
| 1784 | - if ($inTL) $pt[10] += $inTL[0]; |
|
| 1785 | - unset($pt[0]); unset($pt[1]); |
|
| 1786 | - } |
|
| 1787 | - if (is_array($outTR)) { |
|
| 1788 | - $bord -= 2; |
|
| 1789 | - $pt[4] -= $outTR[0] - $border['r']['width']; |
|
| 1790 | - if ($inTR) $pt[8] -= $inTR[0]; |
|
| 1791 | - unset($pt[6]); unset($pt[7]); |
|
| 1792 | - } |
|
| 1793 | - |
|
| 1794 | - $pt = array_values($pt); |
|
| 1795 | - $this->_drawLine($pt, $border['t']['color'], $border['t']['type'], $border['t']['width'], $bord); |
|
| 1796 | - } |
|
| 1797 | - |
|
| 1798 | - // draw the right border |
|
| 1799 | - if ($testBr) { |
|
| 1800 | - $pt = array(); |
|
| 1801 | - $pt[] = $x + $w; $pt[] = $y; |
|
| 1802 | - $pt[] = $x + $w; $pt[] = $y + $border['t']['width']; |
|
| 1803 | - $pt[] = $x + $w; $pt[] = $y + $h - $border['b']['width']; |
|
| 1804 | - $pt[] = $x + $w; $pt[] = $y + $h; |
|
| 1805 | - $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1806 | - $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1807 | - |
|
| 1808 | - $bord = 3; |
|
| 1809 | - if (is_array($outTR)) { |
|
| 1810 | - $bord -= 1; |
|
| 1811 | - $pt[3] += $outTR[1] - $border['t']['width']; |
|
| 1812 | - if ($inTR) $pt[11] += $inTR[1]; |
|
| 1813 | - unset($pt[0]); unset($pt[1]); |
|
| 1814 | - } |
|
| 1815 | - if (is_array($outBR)) { |
|
| 1816 | - $bord -= 2; |
|
| 1817 | - $pt[5] -= $outBR[1] - $border['b']['width']; |
|
| 1818 | - if ($inBR) $pt[9] -= $inBR[1]; |
|
| 1819 | - unset($pt[6]); unset($pt[7]); |
|
| 1820 | - } |
|
| 1821 | - |
|
| 1822 | - $pt = array_values($pt); |
|
| 1823 | - $this->_drawLine($pt, $border['r']['color'], $border['r']['type'], $border['r']['width'], $bord); |
|
| 1824 | - } |
|
| 1825 | - |
|
| 1826 | - // draw the bottom border |
|
| 1827 | - if ($testBb) { |
|
| 1828 | - $pt = array(); |
|
| 1829 | - $pt[] = $x + $w; $pt[] = $y + $h; |
|
| 1830 | - $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h; |
|
| 1831 | - $pt[] = $x + $border['l']['width']; $pt[] = $y + $h; |
|
| 1832 | - $pt[] = $x; $pt[] = $y + $h; |
|
| 1833 | - $pt[] = $x + $border['l']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1834 | - $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1835 | - |
|
| 1836 | - $bord = 3; |
|
| 1837 | - if (is_array($outBL)) { |
|
| 1838 | - $bord -= 2; |
|
| 1839 | - $pt[4] += $outBL[0] - $border['l']['width']; |
|
| 1840 | - if ($inBL) $pt[8] += $inBL[0]; |
|
| 1841 | - unset($pt[6]); unset($pt[7]); |
|
| 1842 | - } |
|
| 1843 | - if (is_array($outBR)) { |
|
| 1844 | - $bord -= 1; |
|
| 1845 | - $pt[2] -= $outBR[0] - $border['r']['width']; |
|
| 1846 | - if ($inBR) $pt[10] -= $inBR[0]; |
|
| 1847 | - unset($pt[0]); unset($pt[1]); |
|
| 1848 | - |
|
| 1849 | - } |
|
| 1850 | - |
|
| 1851 | - $pt = array_values($pt); |
|
| 1852 | - $this->_drawLine($pt, $border['b']['color'], $border['b']['type'], $border['b']['width'], $bord); |
|
| 1853 | - } |
|
| 1854 | - |
|
| 1855 | - if ($background['color']) { |
|
| 1856 | - $this->pdf->setFillColorArray($background['color']); |
|
| 1857 | - } |
|
| 1858 | - |
|
| 1859 | - return true; |
|
| 1860 | - } |
|
| 1861 | - |
|
| 1862 | - /** |
|
| 1863 | - * draw a curve (for border radius) |
|
| 1864 | - * |
|
| 1865 | - * @access protected |
|
| 1866 | - * @param double[] $pt |
|
| 1867 | - * @param array $color |
|
| 1868 | - */ |
|
| 1869 | - protected function _drawCurve($pt, $color) |
|
| 1870 | - { |
|
| 1871 | - $this->pdf->setFillColorArray($color); |
|
| 1872 | - |
|
| 1873 | - if (count($pt) == 10) |
|
| 1874 | - $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]); |
|
| 1875 | - else |
|
| 1876 | - $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]); |
|
| 1877 | - } |
|
| 1878 | - |
|
| 1879 | - /** |
|
| 1880 | - * draw a ligne with a specific type, and specific start and end for radius |
|
| 1881 | - * |
|
| 1882 | - * @access protected |
|
| 1883 | - * @param array $pt |
|
| 1884 | - * @param float $color |
|
| 1885 | - * @param string $type (dashed, dotted, double, solid) |
|
| 1886 | - * @param float $width |
|
| 1887 | - * @param integer $radius (binary from 0 to 3 with 1=>start with a radius, 2=>end with a radius) |
|
| 1888 | - */ |
|
| 1889 | - protected function _drawLine($pt, $color, $type, $width, $radius = 3) |
|
| 1890 | - { |
|
| 1891 | - // set the fill color |
|
| 1892 | - $this->pdf->setFillColorArray($color); |
|
| 1893 | - |
|
| 1894 | - // if dashed or dotted |
|
| 1895 | - if ($type == 'dashed' || $type == 'dotted') { |
|
| 1896 | - |
|
| 1897 | - // clean the end of the line, if radius |
|
| 1898 | - if ($radius == 1) { |
|
| 1899 | - $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; |
|
| 1900 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1901 | - |
|
| 1902 | - $tmp = array(); $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; |
|
| 1903 | - $pt = $tmp; |
|
| 1904 | - } else if ($radius == 2) { |
|
| 1905 | - $tmp = array(); $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; |
|
| 1906 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1907 | - |
|
| 1908 | - $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; |
|
| 1909 | - $pt = $tmp; |
|
| 1910 | - } else if ($radius == 3) { |
|
| 1911 | - $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[10]; $tmp[] = $pt[11]; |
|
| 1912 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1913 | - |
|
| 1914 | - $tmp = array(); $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; |
|
| 1915 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1916 | - |
|
| 1917 | - $tmp = array(); $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; $tmp[] = $pt[10]; $tmp[] = $pt[11]; |
|
| 1918 | - $pt = $tmp; |
|
| 1919 | - } |
|
| 1920 | - |
|
| 1921 | - // horisontal or vertical line |
|
| 1922 | - if ($pt[2] == $pt[0]) { |
|
| 1923 | - $l = abs(($pt[3] - $pt[1]) * 0.5); |
|
| 1924 | - $px = 0; |
|
| 1925 | - $py = $width; |
|
| 1926 | - $x1 = $pt[0]; $y1 = ($pt[3] + $pt[1]) * 0.5; |
|
| 1927 | - $x2 = $pt[6]; $y2 = ($pt[7] + $pt[5]) * 0.5; |
|
| 1928 | - } else { |
|
| 1929 | - $l = abs(($pt[2] - $pt[0]) * 0.5); |
|
| 1930 | - $px = $width; |
|
| 1931 | - $py = 0; |
|
| 1932 | - $x1 = ($pt[2] + $pt[0]) * 0.5; $y1 = $pt[1]; |
|
| 1933 | - $x2 = ($pt[6] + $pt[4]) * 0.5; $y2 = $pt[7]; |
|
| 1934 | - } |
|
| 1935 | - |
|
| 1936 | - // if dashed : 3x bigger than dotted |
|
| 1937 | - if ($type == 'dashed') { |
|
| 1938 | - $px = $px * 3.; |
|
| 1939 | - $py = $py * 3.; |
|
| 1940 | - } |
|
| 1941 | - $mode = ($l / ($px + $py) < .5); |
|
| 1942 | - |
|
| 1943 | - // display the dotted/dashed line |
|
| 1944 | - for ($i = 0; $l - ($px + $py) * ($i - 0.5) > 0; $i++) { |
|
| 1945 | - if (($i % 2) == $mode) { |
|
| 1946 | - $j = $i - 0.5; |
|
| 1947 | - $lx1 = $px * ($j); if ($lx1 < -$l) $lx1 = -$l; |
|
| 1948 | - $ly1 = $py * ($j); if ($ly1 < -$l) $ly1 = -$l; |
|
| 1949 | - $lx2 = $px * ($j + 1); if ($lx2 > $l) $lx2 = $l; |
|
| 1950 | - $ly2 = $py * ($j + 1); if ($ly2 > $l) $ly2 = $l; |
|
| 1951 | - |
|
| 1952 | - $tmp = array(); |
|
| 1953 | - $tmp[] = $x1 + $lx1; $tmp[] = $y1 + $ly1; |
|
| 1954 | - $tmp[] = $x1 + $lx2; $tmp[] = $y1 + $ly2; |
|
| 1955 | - $tmp[] = $x2 + $lx2; $tmp[] = $y2 + $ly2; |
|
| 1956 | - $tmp[] = $x2 + $lx1; $tmp[] = $y2 + $ly1; |
|
| 1957 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1958 | - |
|
| 1959 | - if ($j > 0) { |
|
| 1960 | - $tmp = array(); |
|
| 1961 | - $tmp[] = $x1 - $lx1; $tmp[] = $y1 - $ly1; |
|
| 1962 | - $tmp[] = $x1 - $lx2; $tmp[] = $y1 - $ly2; |
|
| 1963 | - $tmp[] = $x2 - $lx2; $tmp[] = $y2 - $ly2; |
|
| 1964 | - $tmp[] = $x2 - $lx1; $tmp[] = $y2 - $ly1; |
|
| 1965 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1966 | - } |
|
| 1967 | - } |
|
| 1968 | - } |
|
| 1969 | - } else if ($type == 'double') { |
|
| 1970 | - |
|
| 1971 | - // if double, 2 lines : 0=>1/3 and 2/3=>1 |
|
| 1972 | - $pt1 = $pt; |
|
| 1973 | - $pt2 = $pt; |
|
| 1974 | - |
|
| 1975 | - if (count($pt) == 12) { |
|
| 1976 | - // line 1 |
|
| 1977 | - $pt1[0] = ($pt[0] - $pt[10]) * 0.33 + $pt[10]; |
|
| 1978 | - $pt1[1] = ($pt[1] - $pt[11]) * 0.33 + $pt[11]; |
|
| 1979 | - $pt1[2] = ($pt[2] - $pt[10]) * 0.33 + $pt[10]; |
|
| 1980 | - $pt1[3] = ($pt[3] - $pt[11]) * 0.33 + $pt[11]; |
|
| 1981 | - $pt1[4] = ($pt[4] - $pt[8]) * 0.33 + $pt[8]; |
|
| 1982 | - $pt1[5] = ($pt[5] - $pt[9]) * 0.33 + $pt[9]; |
|
| 1983 | - $pt1[6] = ($pt[6] - $pt[8]) * 0.33 + $pt[8]; |
|
| 1984 | - $pt1[7] = ($pt[7] - $pt[9]) * 0.33 + $pt[9]; |
|
| 1985 | - $pt2[10] = ($pt[10] - $pt[0]) * 0.33 + $pt[0]; |
|
| 1986 | - $pt2[11] = ($pt[11] - $pt[1]) * 0.33 + $pt[1]; |
|
| 1987 | - |
|
| 1988 | - // line 2 |
|
| 1989 | - $pt2[2] = ($pt[2] - $pt[0]) * 0.33 + $pt[0]; |
|
| 1990 | - $pt2[3] = ($pt[3] - $pt[1]) * 0.33 + $pt[1]; |
|
| 1991 | - $pt2[4] = ($pt[4] - $pt[6]) * 0.33 + $pt[6]; |
|
| 1992 | - $pt2[5] = ($pt[5] - $pt[7]) * 0.33 + $pt[7]; |
|
| 1993 | - $pt2[8] = ($pt[8] - $pt[6]) * 0.33 + $pt[6]; |
|
| 1994 | - $pt2[9] = ($pt[9] - $pt[7]) * 0.33 + $pt[7]; |
|
| 1995 | - } else { |
|
| 1996 | - // line 1 |
|
| 1997 | - $pt1[0] = ($pt[0] - $pt[6]) * 0.33 + $pt[6]; |
|
| 1998 | - $pt1[1] = ($pt[1] - $pt[7]) * 0.33 + $pt[7]; |
|
| 1999 | - $pt1[2] = ($pt[2] - $pt[4]) * 0.33 + $pt[4]; |
|
| 2000 | - $pt1[3] = ($pt[3] - $pt[5]) * 0.33 + $pt[5]; |
|
| 2001 | - |
|
| 2002 | - // line 2 |
|
| 2003 | - $pt2[6] = ($pt[6] - $pt[0]) * 0.33 + $pt[0]; |
|
| 2004 | - $pt2[7] = ($pt[7] - $pt[1]) * 0.33 + $pt[1]; |
|
| 2005 | - $pt2[4] = ($pt[4] - $pt[2]) * 0.33 + $pt[2]; |
|
| 2006 | - $pt2[5] = ($pt[5] - $pt[3]) * 0.33 + $pt[3]; |
|
| 2007 | - } |
|
| 2008 | - $this->pdf->Polygon($pt1, 'F'); |
|
| 2009 | - $this->pdf->Polygon($pt2, 'F'); |
|
| 2010 | - } else if ($type == 'solid') { |
|
| 2011 | - // solid line : draw directly the polygon |
|
| 2012 | - $this->pdf->Polygon($pt, 'F'); |
|
| 2013 | - } |
|
| 2014 | - } |
|
| 2015 | - |
|
| 2016 | - /** |
|
| 2017 | - * prepare a transform matrix, only for drawing a SVG graphic |
|
| 2018 | - * |
|
| 2019 | - * @access protected |
|
| 2020 | - * @param string $transform |
|
| 2021 | - * @return array $matrix |
|
| 2022 | - */ |
|
| 2023 | - protected function _prepareTransform($transform) |
|
| 2024 | - { |
|
| 2025 | - // it can not be empty |
|
| 2026 | - if ( ! $transform) return null; |
|
| 2027 | - |
|
| 2028 | - // sctions must be like scale(...) |
|
| 2029 | - if ( ! preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null; |
|
| 2030 | - |
|
| 2031 | - // prepare the list of the actions |
|
| 2032 | - $actions = array(); |
|
| 2033 | - |
|
| 2034 | - // for actions |
|
| 2035 | - for ($k = 0; $k < count($match[0]); $k++) { |
|
| 2036 | - |
|
| 2037 | - // get the name of the action |
|
| 2038 | - $name = strtolower($match[1][$k]); |
|
| 2039 | - |
|
| 2040 | - // get the parameters of the action |
|
| 2041 | - $val = explode(',', trim($match[2][$k])); |
|
| 2042 | - foreach ($val as $i => $j) { |
|
| 2043 | - $val[$i] = trim($j); |
|
| 2044 | - } |
|
| 2045 | - |
|
| 2046 | - // prepare the matrix, depending on the action |
|
| 2047 | - switch ($name) |
|
| 2048 | - { |
|
| 2049 | - case 'scale': |
|
| 2050 | - if ( ! isset($val[0])) $val[0] = 1.; else $val[0] = 1. * $val[0]; |
|
| 2051 | - if ( ! isset($val[1])) $val[1] = $val[0]; else $val[1] = 1. * $val[1]; |
|
| 2052 | - $actions[] = array($val[0], 0, 0, $val[1], 0, 0); |
|
| 2053 | - break; |
|
| 2054 | - |
|
| 2055 | - case 'translate': |
|
| 2056 | - if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']); |
|
| 2057 | - if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']); |
|
| 2058 | - $actions[] = array(1, 0, 0, 1, $val[0], $val[1]); |
|
| 2059 | - break; |
|
| 2060 | - |
|
| 2061 | - case 'rotate': |
|
| 2062 | - if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2063 | - if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']); |
|
| 2064 | - if ( ! isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']); |
|
| 2065 | - if ($val[1] || $val[2]) $actions[] = array(1, 0, 0, 1, -$val[1], -$val[2]); |
|
| 2066 | - $actions[] = array(cos($val[0]), sin($val[0]), -sin($val[0]), cos($val[0]), 0, 0); |
|
| 2067 | - if ($val[1] || $val[2]) $actions[] = array(1, 0, 0, 1, $val[1], $val[2]); |
|
| 2068 | - break; |
|
| 2069 | - |
|
| 2070 | - case 'skewx': |
|
| 2071 | - if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2072 | - $actions[] = array(1, 0, tan($val[0]), 1, 0, 0); |
|
| 2073 | - break; |
|
| 2074 | - |
|
| 2075 | - case 'skewy': |
|
| 2076 | - if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2077 | - $actions[] = array(1, tan($val[0]), 0, 1, 0, 0); |
|
| 2078 | - break; |
|
| 2079 | - case 'matrix': |
|
| 2080 | - if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * 1.; |
|
| 2081 | - if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $val[1] * 1.; |
|
| 2082 | - if ( ! isset($val[2])) $val[2] = 0.; else $val[2] = $val[2] * 1.; |
|
| 2083 | - if ( ! isset($val[3])) $val[3] = 0.; else $val[3] = $val[3] * 1.; |
|
| 2084 | - if ( ! isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']); |
|
| 2085 | - if ( ! isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']); |
|
| 2086 | - $actions[] = $val; |
|
| 2087 | - break; |
|
| 2088 | - } |
|
| 2089 | - } |
|
| 2090 | - |
|
| 2091 | - // if ther is no actions => return |
|
| 2092 | - if ( ! $actions) return null; |
|
| 2093 | - |
|
| 2094 | - // get the first matrix |
|
| 2095 | - $m = $actions[0]; unset($actions[0]); |
|
| 2096 | - |
|
| 2097 | - // foreach matrix => multiply to the last matrix |
|
| 2098 | - foreach ($actions as $n) { |
|
| 2099 | - $m = array( |
|
| 2100 | - $m[0] * $n[0] + $m[2] * $n[1], |
|
| 2101 | - $m[1] * $n[0] + $m[3] * $n[1], |
|
| 2102 | - $m[0] * $n[2] + $m[2] * $n[3], |
|
| 2103 | - $m[1] * $n[2] + $m[3] * $n[3], |
|
| 2104 | - $m[0] * $n[4] + $m[2] * $n[5] + $m[4], |
|
| 2105 | - $m[1] * $n[4] + $m[3] * $n[5] + $m[5] |
|
| 2106 | - ); |
|
| 2107 | - } |
|
| 2108 | - |
|
| 2109 | - // return the matrix |
|
| 2110 | - return $m; |
|
| 2111 | - } |
|
| 2112 | - |
|
| 2113 | - /** |
|
| 2114 | - * @access protected |
|
| 2115 | - * @param &array $cases |
|
| 2116 | - * @param &array $corr |
|
| 2117 | - */ |
|
| 2118 | - protected function _calculateTableCellSize(&$cases, &$corr) |
|
| 2119 | - { |
|
| 2120 | - if ( ! isset($corr[0])) return true; |
|
| 2121 | - |
|
| 2122 | - // for each cell without colspan, we get the max width for each column |
|
| 2123 | - $sw = array(); |
|
| 2124 | - for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2125 | - $m = 0; |
|
| 2126 | - for ($y = 0; $y < count($corr); $y++) { |
|
| 2127 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2] == 1) { |
|
| 2128 | - $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']); |
|
| 2129 | - } |
|
| 2130 | - } |
|
| 2131 | - $sw[$x] = $m; |
|
| 2132 | - } |
|
| 2133 | - |
|
| 2134 | - // for each cell with colspan, we adapt the width of each column |
|
| 2135 | - for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2136 | - for ($y = 0; $y < count($corr); $y++) { |
|
| 2137 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2] > 1) { |
|
| 2138 | - |
|
| 2139 | - // sum the max width of each column in colspan |
|
| 2140 | - $s = 0; for ($i = 0; $i < $corr[$y][$x][2]; $i++) $s += $sw[$x + $i]; |
|
| 2141 | - |
|
| 2142 | - // if the max width is < the width of the cell with colspan => we adapt the width of each max width |
|
| 2143 | - if ($s > 0 && $s < $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) { |
|
| 2144 | - for ($i = 0; $i < $corr[$y][$x][2]; $i++) { |
|
| 2145 | - $sw[$x + $i] = $sw[$x + $i] / $s * $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']; |
|
| 2146 | - } |
|
| 2147 | - } |
|
| 2148 | - } |
|
| 2149 | - } |
|
| 2150 | - } |
|
| 2151 | - |
|
| 2152 | - // set the new width, for each cell |
|
| 2153 | - for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2154 | - for ($y = 0; $y < count($corr); $y++) { |
|
| 2155 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) { |
|
| 2156 | - // without colspan |
|
| 2157 | - if ($corr[$y][$x][2] == 1) { |
|
| 2158 | - $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $sw[$x]; |
|
| 2159 | - // with colspan |
|
| 2160 | - } else { |
|
| 2161 | - $s = 0; |
|
| 2162 | - for ($i = 0; $i < $corr[$y][$x][2]; $i++) { |
|
| 2163 | - $s += $sw[$x + $i]; |
|
| 2164 | - } |
|
| 2165 | - $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $s; |
|
| 2166 | - } |
|
| 2167 | - } |
|
| 2168 | - } |
|
| 2169 | - } |
|
| 2170 | - |
|
| 2171 | - // for each cell without rowspan, we get the max height for each line |
|
| 2172 | - $sh = array(); |
|
| 2173 | - for ($y = 0; $y < count($corr); $y++) { |
|
| 2174 | - $m = 0; |
|
| 2175 | - for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2176 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3] == 1) { |
|
| 2177 | - $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']); |
|
| 2178 | - } |
|
| 2179 | - } |
|
| 2180 | - $sh[$y] = $m; |
|
| 2181 | - } |
|
| 2182 | - |
|
| 2183 | - // for each cell with rowspan, we adapt the height of each line |
|
| 2184 | - for ($y = 0; $y < count($corr); $y++) { |
|
| 2185 | - for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2186 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3] > 1) { |
|
| 2187 | - |
|
| 2188 | - // sum the max height of each line in rowspan |
|
| 2189 | - $s = 0; for ($i = 0; $i < $corr[$y][$x][3]; $i++) $s += $sh[$y + $i]; |
|
| 2190 | - |
|
| 2191 | - // if the max height is < the height of the cell with rowspan => we adapt the height of each max height |
|
| 2192 | - if ($s > 0 && $s < $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) { |
|
| 2193 | - for ($i = 0; $i < $corr[$y][$x][3]; $i++) { |
|
| 2194 | - $sh[$y + $i] = $sh[$y + $i] / $s * $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']; |
|
| 2195 | - } |
|
| 2196 | - } |
|
| 2197 | - } |
|
| 2198 | - } |
|
| 2199 | - } |
|
| 2200 | - |
|
| 2201 | - // set the new height, for each cell |
|
| 2202 | - for ($y = 0; $y < count($corr); $y++) { |
|
| 2203 | - for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2204 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) { |
|
| 2205 | - // without rowspan |
|
| 2206 | - if ($corr[$y][$x][3] == 1) { |
|
| 2207 | - $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $sh[$y]; |
|
| 2208 | - // with rowspan |
|
| 2209 | - } else { |
|
| 2210 | - $s = 0; |
|
| 2211 | - for ($i = 0; $i < $corr[$y][$x][3]; $i++) { |
|
| 2212 | - $s += $sh[$y + $i]; |
|
| 2213 | - } |
|
| 2214 | - $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $s; |
|
| 2215 | - |
|
| 2216 | - for ($j = 1; $j < $corr[$y][$x][3]; $j++) { |
|
| 2217 | - $tx = $x + 1; |
|
| 2218 | - $ty = $y + $j; |
|
| 2219 | - for (true; isset($corr[$ty][$tx]) && ! is_array($corr[$ty][$tx]); $tx++); |
|
| 2220 | - if (isset($corr[$ty][$tx])) { |
|
| 2221 | - $cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw'] += $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']; |
|
| 2222 | - } |
|
| 2223 | - } |
|
| 2224 | - } |
|
| 2225 | - } |
|
| 2226 | - } |
|
| 2227 | - } |
|
| 2228 | - } |
|
| 2229 | - |
|
| 2230 | - /** |
|
| 2231 | - * tag : PAGE |
|
| 2232 | - * mode : OPEN |
|
| 2233 | - * |
|
| 2234 | - * @param array $param |
|
| 2235 | - * @return boolean |
|
| 2236 | - */ |
|
| 2237 | - protected function _tag_open_PAGE($param) |
|
| 2238 | - { |
|
| 2239 | - if ($this->_isForOneLine) return false; |
|
| 2240 | - if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page + 1), true); |
|
| 2241 | - |
|
| 2242 | - $newPageSet = ( ! isset($param['pageset']) || $param['pageset'] != 'old'); |
|
| 2243 | - |
|
| 2244 | - $resetPageNumber = (isset($param['pagegroup']) && $param['pagegroup'] == 'new'); |
|
| 2245 | - |
|
| 2246 | - $this->_maxH = 0; |
|
| 2247 | - |
|
| 2248 | - // if new page set asked |
|
| 2249 | - if ($newPageSet) { |
|
| 2250 | - $this->_subHEADER = array(); |
|
| 2251 | - $this->_subFOOTER = array(); |
|
| 2252 | - |
|
| 2253 | - // orientation |
|
| 2254 | - $orientation = ''; |
|
| 2255 | - if (isset($param['orientation'])) { |
|
| 2256 | - $param['orientation'] = strtolower($param['orientation']); |
|
| 2257 | - if ($param['orientation'] == 'p') $orientation = 'P'; |
|
| 2258 | - if ($param['orientation'] == 'portrait') $orientation = 'P'; |
|
| 2259 | - |
|
| 2260 | - if ($param['orientation'] == 'l') $orientation = 'L'; |
|
| 2261 | - if ($param['orientation'] == 'paysage') $orientation = 'L'; |
|
| 2262 | - if ($param['orientation'] == 'landscape') $orientation = 'L'; |
|
| 2263 | - } |
|
| 2264 | - |
|
| 2265 | - // format |
|
| 2266 | - $format = null; |
|
| 2267 | - if (isset($param['format'])) { |
|
| 2268 | - $format = strtolower($param['format']); |
|
| 2269 | - if (preg_match('/^([0-9]+)x([0-9]+)$/isU', $format, $match)) { |
|
| 2270 | - $format = array(intval($match[1]), intval($match[2])); |
|
| 2271 | - } |
|
| 2272 | - } |
|
| 2273 | - |
|
| 2274 | - // background |
|
| 2275 | - $background = array(); |
|
| 2276 | - if (isset($param['backimg'])) { |
|
| 2277 | - $background['img'] = isset($param['backimg']) ? $param['backimg'] : ''; // src of the image |
|
| 2278 | - $background['posX'] = isset($param['backimgx']) ? $param['backimgx'] : 'center'; // horizontale position of the image |
|
| 2279 | - $background['posY'] = isset($param['backimgy']) ? $param['backimgy'] : 'middle'; // vertical position of the image |
|
| 2280 | - $background['width'] = isset($param['backimgw']) ? $param['backimgw'] : '100%'; // width of the image (100% = page width) |
|
| 2281 | - |
|
| 2282 | - // convert the src of the image, if parameters |
|
| 2283 | - $background['img'] = str_replace('&', '&', $background['img']); |
|
| 2284 | - |
|
| 2285 | - // convert the positions |
|
| 2286 | - if ($background['posX'] == 'left') $background['posX'] = '0%'; |
|
| 2287 | - if ($background['posX'] == 'center') $background['posX'] = '50%'; |
|
| 2288 | - if ($background['posX'] == 'right') $background['posX'] = '100%'; |
|
| 2289 | - if ($background['posY'] == 'top') $background['posY'] = '0%'; |
|
| 2290 | - if ($background['posY'] == 'middle') $background['posY'] = '50%'; |
|
| 2291 | - if ($background['posY'] == 'bottom') $background['posY'] = '100%'; |
|
| 2292 | - |
|
| 2293 | - if ($background['img']) { |
|
| 2294 | - // get the size of the image |
|
| 2295 | - // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini |
|
| 2296 | - $infos = @getimagesize($background['img']); |
|
| 2297 | - if (count($infos) > 1) { |
|
| 2298 | - $imageWidth = $this->parsingCss->ConvertToMM($background['width'], $this->pdf->getW()); |
|
| 2299 | - $imageHeight = $imageWidth * $infos[1] / $infos[0]; |
|
| 2300 | - |
|
| 2301 | - $background['width'] = $imageWidth; |
|
| 2302 | - $background['posX'] = $this->parsingCss->ConvertToMM($background['posX'], $this->pdf->getW() - $imageWidth); |
|
| 2303 | - $background['posY'] = $this->parsingCss->ConvertToMM($background['posY'], $this->pdf->getH() - $imageHeight); |
|
| 2304 | - } else { |
|
| 2305 | - $background = array(); |
|
| 2306 | - } |
|
| 2307 | - } else { |
|
| 2308 | - $background = array(); |
|
| 2309 | - } |
|
| 2310 | - } |
|
| 2311 | - |
|
| 2312 | - // margins of the page |
|
| 2313 | - $background['top'] = isset($param['backtop']) ? $param['backtop'] : '0'; |
|
| 2314 | - $background['bottom'] = isset($param['backbottom']) ? $param['backbottom'] : '0'; |
|
| 2315 | - $background['left'] = isset($param['backleft']) ? $param['backleft'] : '0'; |
|
| 2316 | - $background['right'] = isset($param['backright']) ? $param['backright'] : '0'; |
|
| 2317 | - |
|
| 2318 | - // if no unit => mm |
|
| 2319 | - if (preg_match('/^([0-9]*)$/isU', $background['top'])) { |
|
| 2320 | - $background['top'] .= 'mm'; |
|
| 2321 | - } |
|
| 2322 | - if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) { |
|
| 2323 | - $background['bottom'] .= 'mm'; |
|
| 2324 | - } |
|
| 2325 | - if (preg_match('/^([0-9]*)$/isU', $background['left'])) { |
|
| 2326 | - $background['left'] .= 'mm'; |
|
| 2327 | - } |
|
| 2328 | - if (preg_match('/^([0-9]*)$/isU', $background['right'])) { |
|
| 2329 | - $background['right'] .= 'mm'; |
|
| 2330 | - } |
|
| 2331 | - |
|
| 2332 | - // convert to mm |
|
| 2333 | - $background['top'] = $this->parsingCss->ConvertToMM($background['top'], $this->pdf->getH()); |
|
| 2334 | - $background['bottom'] = $this->parsingCss->ConvertToMM($background['bottom'], $this->pdf->getH()); |
|
| 2335 | - $background['left'] = $this->parsingCss->ConvertToMM($background['left'], $this->pdf->getW()); |
|
| 2336 | - $background['right'] = $this->parsingCss->ConvertToMM($background['right'], $this->pdf->getW()); |
|
| 2337 | - |
|
| 2338 | - // get the background color |
|
| 2339 | - $res = false; |
|
| 2340 | - $background['color'] = isset($param['backcolor']) ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null; |
|
| 2341 | - if ( ! $res) $background['color'] = null; |
|
| 2342 | - |
|
| 2343 | - $this->parsingCss->save(); |
|
| 2344 | - $this->parsingCss->analyse('PAGE', $param); |
|
| 2345 | - $this->parsingCss->setPosition(); |
|
| 2346 | - $this->parsingCss->fontSet(); |
|
| 2347 | - |
|
| 2348 | - // new page |
|
| 2349 | - $this->_setNewPage($format, $orientation, $background, null, $resetPageNumber); |
|
| 2350 | - |
|
| 2351 | - // automatic footer |
|
| 2352 | - if (isset($param['footer'])) { |
|
| 2353 | - $lst = explode(';', $param['footer']); |
|
| 2354 | - foreach ($lst as $key => $val) { |
|
| 2355 | - $lst[$key] = trim(strtolower($val)); |
|
| 2356 | - } |
|
| 2357 | - $page = in_array('page', $lst); |
|
| 2358 | - $date = in_array('date', $lst); |
|
| 2359 | - $hour = in_array('heure', $lst); |
|
| 2360 | - $form = in_array('form', $lst); |
|
| 2361 | - } else { |
|
| 2362 | - $page = null; |
|
| 2363 | - $date = null; |
|
| 2364 | - $hour = null; |
|
| 2365 | - $form = null; |
|
| 2366 | - } |
|
| 2367 | - $this->pdf->SetMyFooter($page, $date, $hour, $form); |
|
| 2368 | - // else => we use the last page set used |
|
| 2369 | - } else { |
|
| 2370 | - $this->parsingCss->save(); |
|
| 2371 | - $this->parsingCss->analyse('PAGE', $param); |
|
| 2372 | - $this->parsingCss->setPosition(); |
|
| 2373 | - $this->parsingCss->fontSet(); |
|
| 2374 | - |
|
| 2375 | - $this->_setNewPage(null, null, null, null, $resetPageNumber); |
|
| 2376 | - } |
|
| 2377 | - |
|
| 2378 | - return true; |
|
| 2379 | - } |
|
| 2380 | - |
|
| 2381 | - /** |
|
| 2382 | - * tag : PAGE |
|
| 2383 | - * mode : CLOSE |
|
| 2384 | - * |
|
| 2385 | - * @param array $param |
|
| 2386 | - * @return boolean |
|
| 2387 | - */ |
|
| 2388 | - protected function _tag_close_PAGE($param) |
|
| 2389 | - { |
|
| 2390 | - if ($this->_isForOneLine) { |
|
| 2391 | - return false; |
|
| 2392 | - } |
|
| 2393 | - |
|
| 2394 | - $this->_maxH = 0; |
|
| 2395 | - |
|
| 2396 | - $this->parsingCss->load(); |
|
| 2397 | - $this->parsingCss->fontSet(); |
|
| 2398 | - |
|
| 2399 | - if ($this->_debugActif) { |
|
| 2400 | - $this->_DEBUG_add('PAGE '.$this->_page, false); |
|
| 2401 | - } |
|
| 2402 | - |
|
| 2403 | - return true; |
|
| 2404 | - } |
|
| 2405 | - |
|
| 2406 | - /** |
|
| 2407 | - * tag : PAGE_HEADER |
|
| 2408 | - * mode : OPEN |
|
| 2409 | - * |
|
| 2410 | - * @param array $param |
|
| 2411 | - * @return boolean |
|
| 2412 | - */ |
|
| 2413 | - protected function _tag_open_PAGE_HEADER($param) |
|
| 2414 | - { |
|
| 2415 | - if ($this->_isForOneLine) return false; |
|
| 2416 | - |
|
| 2417 | - $this->_subHEADER = array(); |
|
| 2418 | - for ($this->_parsePos; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 2419 | - $action = $this->parsingHtml->code[$this->_parsePos]; |
|
| 2420 | - if ($action['name'] == 'page_header') $action['name'] = 'page_header_sub'; |
|
| 2421 | - $this->_subHEADER[] = $action; |
|
| 2422 | - if (strtolower($action['name']) == 'page_header_sub' && $action['close']) break; |
|
| 2423 | - } |
|
| 2424 | - |
|
| 2425 | - $this->_setPageHeader(); |
|
| 2426 | - |
|
| 2427 | - return true; |
|
| 2428 | - } |
|
| 2429 | - |
|
| 2430 | - /** |
|
| 2431 | - * tag : PAGE_FOOTER |
|
| 2432 | - * mode : OPEN |
|
| 2433 | - * |
|
| 2434 | - * @param array $param |
|
| 2435 | - * @return boolean |
|
| 2436 | - */ |
|
| 2437 | - protected function _tag_open_PAGE_FOOTER($param) |
|
| 2438 | - { |
|
| 2439 | - if ($this->_isForOneLine) return false; |
|
| 2440 | - |
|
| 2441 | - $this->_subFOOTER = array(); |
|
| 2442 | - for ($this->_parsePos; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 2443 | - $action = $this->parsingHtml->code[$this->_parsePos]; |
|
| 2444 | - if ($action['name'] == 'page_footer') $action['name'] = 'page_footer_sub'; |
|
| 2445 | - $this->_subFOOTER[] = $action; |
|
| 2446 | - if (strtolower($action['name']) == 'page_footer_sub' && $action['close']) break; |
|
| 2447 | - } |
|
| 2448 | - |
|
| 2449 | - $this->_setPageFooter(); |
|
| 2450 | - |
|
| 2451 | - return true; |
|
| 2452 | - } |
|
| 2453 | - |
|
| 2454 | - /** |
|
| 2455 | - * It is not a real tag. Does not use it directly |
|
| 2456 | - * |
|
| 2457 | - * @param array $param |
|
| 2458 | - * @return boolean |
|
| 2459 | - */ |
|
| 2460 | - protected function _tag_open_PAGE_HEADER_SUB($param) |
|
| 2461 | - { |
|
| 2462 | - if ($this->_isForOneLine) { |
|
| 2463 | - return false; |
|
| 2464 | - } |
|
| 2465 | - |
|
| 2466 | - // save the current stat |
|
| 2467 | - $this->_subSTATES = array(); |
|
| 2468 | - $this->_subSTATES['x'] = $this->pdf->getX(); |
|
| 2469 | - $this->_subSTATES['y'] = $this->pdf->getY(); |
|
| 2470 | - $this->_subSTATES['s'] = $this->parsingCss->value; |
|
| 2471 | - $this->_subSTATES['t'] = $this->parsingCss->table; |
|
| 2472 | - $this->_subSTATES['ml'] = $this->_margeLeft; |
|
| 2473 | - $this->_subSTATES['mr'] = $this->_margeRight; |
|
| 2474 | - $this->_subSTATES['mt'] = $this->_margeTop; |
|
| 2475 | - $this->_subSTATES['mb'] = $this->_margeBottom; |
|
| 2476 | - $this->_subSTATES['mp'] = $this->_pageMarges; |
|
| 2477 | - |
|
| 2478 | - // new stat for the header |
|
| 2479 | - $this->_pageMarges = array(); |
|
| 2480 | - $this->_margeLeft = $this->_defaultLeft; |
|
| 2481 | - $this->_margeRight = $this->_defaultRight; |
|
| 2482 | - $this->_margeTop = $this->_defaultTop; |
|
| 2483 | - $this->_margeBottom = $this->_defaultBottom; |
|
| 2484 | - $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2485 | - $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2486 | - $this->pdf->setXY($this->_defaultLeft, $this->_defaultTop); |
|
| 2487 | - |
|
| 2488 | - $this->parsingCss->initStyle(); |
|
| 2489 | - $this->parsingCss->resetStyle(); |
|
| 2490 | - $this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight; |
|
| 2491 | - $this->parsingCss->table = array(); |
|
| 2492 | - |
|
| 2493 | - $this->parsingCss->save(); |
|
| 2494 | - $this->parsingCss->analyse('page_header_sub', $param); |
|
| 2495 | - $this->parsingCss->setPosition(); |
|
| 2496 | - $this->parsingCss->fontSet(); |
|
| 2497 | - $this->_setNewPositionForNewLine(); |
|
| 2498 | - return true; |
|
| 2499 | - } |
|
| 2500 | - |
|
| 2501 | - /** |
|
| 2502 | - * It is not a real tag. Does not use it directly |
|
| 2503 | - * |
|
| 2504 | - * @param array $param |
|
| 2505 | - * @return boolean |
|
| 2506 | - */ |
|
| 2507 | - protected function _tag_close_PAGE_HEADER_SUB($param) |
|
| 2508 | - { |
|
| 2509 | - if ($this->_isForOneLine) { |
|
| 2510 | - return false; |
|
| 2511 | - } |
|
| 2512 | - |
|
| 2513 | - $this->parsingCss->load(); |
|
| 2514 | - |
|
| 2515 | - // restore the stat |
|
| 2516 | - $this->parsingCss->value = $this->_subSTATES['s']; |
|
| 2517 | - $this->parsingCss->table = $this->_subSTATES['t']; |
|
| 2518 | - $this->_pageMarges = $this->_subSTATES['mp']; |
|
| 2519 | - $this->_margeLeft = $this->_subSTATES['ml']; |
|
| 2520 | - $this->_margeRight = $this->_subSTATES['mr']; |
|
| 2521 | - $this->_margeTop = $this->_subSTATES['mt']; |
|
| 2522 | - $this->_margeBottom = $this->_subSTATES['mb']; |
|
| 2523 | - $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2524 | - $this->pdf->setbMargin($this->_margeBottom); |
|
| 2525 | - $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2526 | - $this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']); |
|
| 2527 | - |
|
| 2528 | - $this->parsingCss->fontSet(); |
|
| 2529 | - $this->_maxH = 0; |
|
| 2530 | - |
|
| 2531 | - return true; |
|
| 2532 | - } |
|
| 2533 | - |
|
| 2534 | - /** |
|
| 2535 | - * It is not a real tag. Does not use it directly |
|
| 2536 | - * |
|
| 2537 | - * @param array $param |
|
| 2538 | - * @return boolean |
|
| 2539 | - */ |
|
| 2540 | - protected function _tag_open_PAGE_FOOTER_SUB($param) |
|
| 2541 | - { |
|
| 2542 | - if ($this->_isForOneLine) { |
|
| 2543 | - return false; |
|
| 2544 | - } |
|
| 2545 | - |
|
| 2546 | - // save the current stat |
|
| 2547 | - $this->_subSTATES = array(); |
|
| 2548 | - $this->_subSTATES['x'] = $this->pdf->getX(); |
|
| 2549 | - $this->_subSTATES['y'] = $this->pdf->getY(); |
|
| 2550 | - $this->_subSTATES['s'] = $this->parsingCss->value; |
|
| 2551 | - $this->_subSTATES['t'] = $this->parsingCss->table; |
|
| 2552 | - $this->_subSTATES['ml'] = $this->_margeLeft; |
|
| 2553 | - $this->_subSTATES['mr'] = $this->_margeRight; |
|
| 2554 | - $this->_subSTATES['mt'] = $this->_margeTop; |
|
| 2555 | - $this->_subSTATES['mb'] = $this->_margeBottom; |
|
| 2556 | - $this->_subSTATES['mp'] = $this->_pageMarges; |
|
| 2557 | - |
|
| 2558 | - // new stat for the footer |
|
| 2559 | - $this->_pageMarges = array(); |
|
| 2560 | - $this->_margeLeft = $this->_defaultLeft; |
|
| 2561 | - $this->_margeRight = $this->_defaultRight; |
|
| 2562 | - $this->_margeTop = $this->_defaultTop; |
|
| 2563 | - $this->_margeBottom = $this->_defaultBottom; |
|
| 2564 | - $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2565 | - $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2566 | - $this->pdf->setXY($this->_defaultLeft, $this->_defaultTop); |
|
| 2567 | - |
|
| 2568 | - $this->parsingCss->initStyle(); |
|
| 2569 | - $this->parsingCss->resetStyle(); |
|
| 2570 | - $this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight; |
|
| 2571 | - $this->parsingCss->table = array(); |
|
| 2572 | - |
|
| 2573 | - // we create a sub HTML2PFDF, and we execute on it the content of the footer, to get the height of it |
|
| 2574 | - $sub = null; |
|
| 2575 | - $this->_createSubHTML($sub); |
|
| 2576 | - $sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 2577 | - $sub->_makeHTMLcode(); |
|
| 2578 | - $this->pdf->setY($this->pdf->getH() - $sub->_maxY - $this->_defaultBottom - 0.01); |
|
| 2579 | - $this->_destroySubHTML($sub); |
|
| 2580 | - |
|
| 2581 | - $this->parsingCss->save(); |
|
| 2582 | - $this->parsingCss->analyse('page_footer_sub', $param); |
|
| 2583 | - $this->parsingCss->setPosition(); |
|
| 2584 | - $this->parsingCss->fontSet(); |
|
| 2585 | - $this->_setNewPositionForNewLine(); |
|
| 2586 | - |
|
| 2587 | - return true; |
|
| 2588 | - } |
|
| 2589 | - |
|
| 2590 | - /** |
|
| 2591 | - * It is not a real tag. Does not use it directly |
|
| 2592 | - * |
|
| 2593 | - * @param array $param |
|
| 2594 | - * @return boolean |
|
| 2595 | - */ |
|
| 2596 | - protected function _tag_close_PAGE_FOOTER_SUB($param) |
|
| 2597 | - { |
|
| 2598 | - if ($this->_isForOneLine) { |
|
| 2599 | - return false; |
|
| 2600 | - } |
|
| 2601 | - |
|
| 2602 | - $this->parsingCss->load(); |
|
| 2603 | - |
|
| 2604 | - $this->parsingCss->value = $this->_subSTATES['s']; |
|
| 2605 | - $this->parsingCss->table = $this->_subSTATES['t']; |
|
| 2606 | - $this->_pageMarges = $this->_subSTATES['mp']; |
|
| 2607 | - $this->_margeLeft = $this->_subSTATES['ml']; |
|
| 2608 | - $this->_margeRight = $this->_subSTATES['mr']; |
|
| 2609 | - $this->_margeTop = $this->_subSTATES['mt']; |
|
| 2610 | - $this->_margeBottom = $this->_subSTATES['mb']; |
|
| 2611 | - $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2612 | - $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2613 | - $this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']); |
|
| 2614 | - |
|
| 2615 | - $this->parsingCss->fontSet(); |
|
| 2616 | - $this->_maxH = 0; |
|
| 2617 | - |
|
| 2618 | - return true; |
|
| 2619 | - } |
|
| 2620 | - |
|
| 2621 | - /** |
|
| 2622 | - * tag : NOBREAK |
|
| 2623 | - * mode : OPEN |
|
| 2624 | - * |
|
| 2625 | - * @param array $param |
|
| 2626 | - * @return boolean |
|
| 2627 | - */ |
|
| 2628 | - protected function _tag_open_NOBREAK($param) |
|
| 2629 | - { |
|
| 2630 | - if ($this->_isForOneLine) { |
|
| 2631 | - return false; |
|
| 2632 | - } |
|
| 2633 | - |
|
| 2634 | - $this->_maxH = 0; |
|
| 2635 | - |
|
| 2636 | - // create a sub HTML2PDF to execute the content of the tag, to get the dimensions |
|
| 2637 | - $sub = null; |
|
| 2638 | - $this->_createSubHTML($sub); |
|
| 2639 | - $sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 2640 | - $sub->_makeHTMLcode(); |
|
| 2641 | - $y = $this->pdf->getY(); |
|
| 2642 | - |
|
| 2643 | - // if the content does not fit on the page => new page |
|
| 2644 | - if ( |
|
| 2645 | - $sub->_maxY < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin()) && |
|
| 2646 | - $y + $sub->_maxY >= ($this->pdf->getH() - $this->pdf->getbMargin()) |
|
| 2647 | - ) { |
|
| 2648 | - $this->_setNewPage(); |
|
| 2649 | - } |
|
| 2650 | - |
|
| 2651 | - // destroy the sub HTML2PDF |
|
| 2652 | - $this->_destroySubHTML($sub); |
|
| 2653 | - |
|
| 2654 | - return true; |
|
| 2655 | - } |
|
| 2656 | - |
|
| 2657 | - |
|
| 2658 | - /** |
|
| 2659 | - * tag : NOBREAK |
|
| 2660 | - * mode : CLOSE |
|
| 2661 | - * |
|
| 2662 | - * @param array $param |
|
| 2663 | - * @return boolean |
|
| 2664 | - */ |
|
| 2665 | - protected function _tag_close_NOBREAK($param) |
|
| 2666 | - { |
|
| 2667 | - if ($this->_isForOneLine) { |
|
| 2668 | - return false; |
|
| 2669 | - } |
|
| 2670 | - |
|
| 2671 | - $this->_maxH = 0; |
|
| 2672 | - |
|
| 2673 | - return true; |
|
| 2674 | - } |
|
| 2675 | - |
|
| 2676 | - /** |
|
| 2677 | - * tag : DIV |
|
| 2678 | - * mode : OPEN |
|
| 2679 | - * |
|
| 2680 | - * @param array $param |
|
| 2681 | - * @param string $other name of tag that used the div tag |
|
| 2682 | - * @return boolean |
|
| 2683 | - */ |
|
| 2684 | - protected function _tag_open_DIV($param, $other = 'div') |
|
| 2685 | - { |
|
| 2686 | - if ($this->_isForOneLine) { |
|
| 2687 | - return false; |
|
| 2688 | - } |
|
| 2689 | - if ($this->_debugActif) { |
|
| 2690 | - $this->_DEBUG_add(strtoupper($other), true); |
|
| 2691 | - } |
|
| 2692 | - |
|
| 2693 | - $this->parsingCss->save(); |
|
| 2694 | - $this->parsingCss->analyse($other, $param); |
|
| 2695 | - $this->parsingCss->fontSet(); |
|
| 2696 | - |
|
| 2697 | - // for fieldset and legend |
|
| 2698 | - if (in_array($other, array('fieldset', 'legend'))) { |
|
| 2699 | - if (isset($param['moveTop'])) { |
|
| 2700 | - $this->parsingCss->value['margin']['t'] += $param['moveTop']; |
|
| 2701 | - } |
|
| 2702 | - if (isset($param['moveLeft'])) { |
|
| 2703 | - $this->parsingCss->value['margin']['l'] += $param['moveLeft']; |
|
| 2704 | - } |
|
| 2705 | - if (isset($param['moveDown'])) { |
|
| 2706 | - $this->parsingCss->value['margin']['b'] += $param['moveDown']; |
|
| 2707 | - } |
|
| 2708 | - } |
|
| 2709 | - |
|
| 2710 | - $alignObject = null; |
|
| 2711 | - if ($this->parsingCss->value['margin-auto']) { |
|
| 2712 | - $alignObject = 'center'; |
|
| 2713 | - } |
|
| 2714 | - |
|
| 2715 | - $marge = array(); |
|
| 2716 | - $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03; |
|
| 2717 | - $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03; |
|
| 2718 | - $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03; |
|
| 2719 | - $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03; |
|
| 2720 | - |
|
| 2721 | - // extract the content of the div |
|
| 2722 | - $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 2723 | - |
|
| 2724 | - // create a sub HTML2PDF to get the dimensions of the content of the div |
|
| 2725 | - $w = 0; $h = 0; |
|
| 2726 | - if (count($level)) { |
|
| 2727 | - $sub = null; |
|
| 2728 | - $this->_createSubHTML($sub); |
|
| 2729 | - $sub->parsingHtml->code = $level; |
|
| 2730 | - $sub->_makeHTMLcode(); |
|
| 2731 | - $w = $sub->_maxX; |
|
| 2732 | - $h = $sub->_maxY; |
|
| 2733 | - $this->_destroySubHTML($sub); |
|
| 2734 | - } |
|
| 2735 | - $wReel = $w; |
|
| 2736 | - $hReel = $h; |
|
| 2737 | - |
|
| 2738 | - $w += $marge['l'] + $marge['r'] + 0.001; |
|
| 2739 | - $h += $marge['t'] + $marge['b'] + 0.001; |
|
| 2740 | - |
|
| 2741 | - if ($this->parsingCss->value['overflow'] == 'hidden') { |
|
| 2742 | - $overW = max($w, $this->parsingCss->value['width']); |
|
| 2743 | - $overH = max($h, $this->parsingCss->value['height']); |
|
| 2744 | - $overflow = true; |
|
| 2745 | - $this->parsingCss->value['old_maxX'] = $this->_maxX; |
|
| 2746 | - $this->parsingCss->value['old_maxY'] = $this->_maxY; |
|
| 2747 | - $this->parsingCss->value['old_maxH'] = $this->_maxH; |
|
| 2748 | - $this->parsingCss->value['old_overflow'] = $this->_isInOverflow; |
|
| 2749 | - $this->_isInOverflow = true; |
|
| 2750 | - } else { |
|
| 2751 | - $overW = null; |
|
| 2752 | - $overH = null; |
|
| 2753 | - $overflow = false; |
|
| 2754 | - $this->parsingCss->value['width'] = max($w, $this->parsingCss->value['width']); |
|
| 2755 | - $this->parsingCss->value['height'] = max($h, $this->parsingCss->value['height']); |
|
| 2756 | - } |
|
| 2757 | - |
|
| 2758 | - switch ($this->parsingCss->value['rotate']) |
|
| 2759 | - { |
|
| 2760 | - case 90: |
|
| 2761 | - $tmp = $overH; $overH = $overW; $overW = $tmp; |
|
| 2762 | - $tmp = $hReel; $hReel = $wReel; $wReel = $tmp; |
|
| 2763 | - unset($tmp); |
|
| 2764 | - $w = $this->parsingCss->value['height']; |
|
| 2765 | - $h = $this->parsingCss->value['width']; |
|
| 2766 | - $tX = -$h; |
|
| 2767 | - $tY = 0; |
|
| 2768 | - break; |
|
| 2769 | - |
|
| 2770 | - case 180: |
|
| 2771 | - $w = $this->parsingCss->value['width']; |
|
| 2772 | - $h = $this->parsingCss->value['height']; |
|
| 2773 | - $tX = -$w; |
|
| 2774 | - $tY = -$h; |
|
| 2775 | - break; |
|
| 2776 | - |
|
| 2777 | - case 270: |
|
| 2778 | - $tmp = $overH; $overH = $overW; $overW = $tmp; |
|
| 2779 | - $tmp = $hReel; $hReel = $wReel; $wReel = $tmp; |
|
| 2780 | - unset($tmp); |
|
| 2781 | - $w = $this->parsingCss->value['height']; |
|
| 2782 | - $h = $this->parsingCss->value['width']; |
|
| 2783 | - $tX = 0; |
|
| 2784 | - $tY = -$w; |
|
| 2785 | - break; |
|
| 2786 | - |
|
| 2787 | - default: |
|
| 2788 | - $w = $this->parsingCss->value['width']; |
|
| 2789 | - $h = $this->parsingCss->value['height']; |
|
| 2790 | - $tX = 0; |
|
| 2791 | - $tY = 0; |
|
| 2792 | - break; |
|
| 2793 | - } |
|
| 2794 | - |
|
| 2795 | - if ( ! $this->parsingCss->value['position']) { |
|
| 2796 | - if ( |
|
| 2797 | - $w < ($this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin()) && |
|
| 2798 | - $this->pdf->getX() + $w >= ($this->pdf->getW() - $this->pdf->getrMargin()) |
|
| 2799 | - ) |
|
| 2800 | - $this->_tag_open_BR(array()); |
|
| 2801 | - |
|
| 2802 | - if ( |
|
| 2803 | - ($h < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin())) && |
|
| 2804 | - ($this->pdf->getY() + $h >= ($this->pdf->getH() - $this->pdf->getbMargin())) && |
|
| 2805 | - ! $this->_isInOverflow |
|
| 2806 | - ) |
|
| 2807 | - $this->_setNewPage(); |
|
| 2808 | - |
|
| 2809 | - $old = $this->parsingCss->getOldValues(); |
|
| 2810 | - $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 2811 | - |
|
| 2812 | - if ($parentWidth > $w) { |
|
| 2813 | - if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 2814 | - else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 2815 | - } |
|
| 2816 | - |
|
| 2817 | - $this->parsingCss->setPosition(); |
|
| 2818 | - } else { |
|
| 2819 | - $old = $this->parsingCss->getOldValues(); |
|
| 2820 | - $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 2821 | - |
|
| 2822 | - if ($parentWidth > $w) { |
|
| 2823 | - if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 2824 | - else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 2825 | - } |
|
| 2826 | - |
|
| 2827 | - $this->parsingCss->setPosition(); |
|
| 2828 | - $this->_saveMax(); |
|
| 2829 | - $this->_maxX = 0; |
|
| 2830 | - $this->_maxY = 0; |
|
| 2831 | - $this->_maxH = 0; |
|
| 2832 | - $this->_maxE = 0; |
|
| 2833 | - } |
|
| 2834 | - |
|
| 2835 | - if ($this->parsingCss->value['rotate']) { |
|
| 2836 | - $this->pdf->startTransform(); |
|
| 2837 | - $this->pdf->setRotation($this->parsingCss->value['rotate']); |
|
| 2838 | - $this->pdf->setTranslate($tX, $tY); |
|
| 2839 | - } |
|
| 2840 | - |
|
| 2841 | - $this->_drawRectangle( |
|
| 2842 | - $this->parsingCss->value['x'], |
|
| 2843 | - $this->parsingCss->value['y'], |
|
| 2844 | - $this->parsingCss->value['width'], |
|
| 2845 | - $this->parsingCss->value['height'], |
|
| 2846 | - $this->parsingCss->value['border'], |
|
| 2847 | - $this->parsingCss->value['padding'], |
|
| 2848 | - 0, |
|
| 2849 | - $this->parsingCss->value['background'] |
|
| 2850 | - ); |
|
| 2851 | - |
|
| 2852 | - $marge = array(); |
|
| 2853 | - $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03; |
|
| 2854 | - $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03; |
|
| 2855 | - $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03; |
|
| 2856 | - $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03; |
|
| 2857 | - |
|
| 2858 | - $this->parsingCss->value['width'] -= $marge['l'] + $marge['r']; |
|
| 2859 | - $this->parsingCss->value['height'] -= $marge['t'] + $marge['b']; |
|
| 2860 | - |
|
| 2861 | - $xCorr = 0; |
|
| 2862 | - $yCorr = 0; |
|
| 2863 | - if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 2864 | - switch ($this->parsingCss->value['text-align']) |
|
| 2865 | - { |
|
| 2866 | - case 'right': |
|
| 2867 | - $xCorr = ($this->parsingCss->value['width'] - $wReel); |
|
| 2868 | - break; |
|
| 2869 | - case 'center': |
|
| 2870 | - $xCorr = ($this->parsingCss->value['width'] - $wReel) * 0.5; |
|
| 2871 | - break; |
|
| 2872 | - } |
|
| 2873 | - if ($xCorr > 0) $xCorr = 0; |
|
| 2874 | - switch ($this->parsingCss->value['vertical-align']) |
|
| 2875 | - { |
|
| 2876 | - case 'bottom': |
|
| 2877 | - $yCorr = ($this->parsingCss->value['height'] - $hReel); |
|
| 2878 | - break; |
|
| 2879 | - case 'middle': |
|
| 2880 | - $yCorr = ($this->parsingCss->value['height'] - $hReel) * 0.5; |
|
| 2881 | - break; |
|
| 2882 | - } |
|
| 2883 | - } |
|
| 2884 | - |
|
| 2885 | - if ($overflow) { |
|
| 2886 | - $overW -= $marge['l'] + $marge['r']; |
|
| 2887 | - $overH -= $marge['t'] + $marge['b']; |
|
| 2888 | - $this->pdf->clippingPathStart( |
|
| 2889 | - $this->parsingCss->value['x'] + $marge['l'], |
|
| 2890 | - $this->parsingCss->value['y'] + $marge['t'], |
|
| 2891 | - $this->parsingCss->value['width'], |
|
| 2892 | - $this->parsingCss->value['height'] |
|
| 2893 | - ); |
|
| 2894 | - |
|
| 2895 | - $this->parsingCss->value['x'] += $xCorr; |
|
| 2896 | - |
|
| 2897 | - // marges from the dimension of the content |
|
| 2898 | - $mL = $this->parsingCss->value['x'] + $marge['l']; |
|
| 2899 | - $mR = $this->pdf->getW() - $mL - $overW; |
|
| 2900 | - } else { |
|
| 2901 | - // marges from the dimension of the div |
|
| 2902 | - $mL = $this->parsingCss->value['x'] + $marge['l']; |
|
| 2903 | - $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width']; |
|
| 2904 | - } |
|
| 2905 | - |
|
| 2906 | - $x = $this->parsingCss->value['x'] + $marge['l']; |
|
| 2907 | - $y = $this->parsingCss->value['y'] + $marge['t'] + $yCorr; |
|
| 2908 | - $this->_saveMargin($mL, 0, $mR); |
|
| 2909 | - $this->pdf->setXY($x, $y); |
|
| 2910 | - |
|
| 2911 | - $this->_setNewPositionForNewLine(); |
|
| 2912 | - |
|
| 2913 | - return true; |
|
| 2914 | - } |
|
| 2915 | - |
|
| 2916 | - /** |
|
| 2917 | - * tag : BLOCKQUOTE |
|
| 2918 | - * mode : OPEN |
|
| 2919 | - * |
|
| 2920 | - * @param array $param |
|
| 2921 | - * @return boolean |
|
| 2922 | - */ |
|
| 2923 | - protected function _tag_open_BLOCKQUOTE($param) |
|
| 2924 | - { |
|
| 2925 | - return $this->_tag_open_DIV($param, 'blockquote'); |
|
| 2926 | - } |
|
| 2927 | - |
|
| 2928 | - /** |
|
| 2929 | - * tag : LEGEND |
|
| 2930 | - * mode : OPEN |
|
| 2931 | - * |
|
| 2932 | - * @param array $param |
|
| 2933 | - * @return boolean |
|
| 2934 | - */ |
|
| 2935 | - protected function _tag_open_LEGEND($param) |
|
| 2936 | - { |
|
| 2937 | - return $this->_tag_open_DIV($param, 'legend'); |
|
| 2938 | - } |
|
| 2939 | - |
|
| 2940 | - /** |
|
| 2941 | - * tag : FIELDSET |
|
| 2942 | - * mode : OPEN |
|
| 2943 | - * |
|
| 2944 | - * @author Pavel Kochman |
|
| 2945 | - * @param array $param |
|
| 2946 | - * @return boolean |
|
| 2947 | - */ |
|
| 2948 | - protected function _tag_open_FIELDSET($param) |
|
| 2949 | - { |
|
| 2950 | - |
|
| 2951 | - $this->parsingCss->save(); |
|
| 2952 | - $this->parsingCss->analyse('fieldset', $param); |
|
| 2953 | - |
|
| 2954 | - // get height of LEGEND element and make fieldset corrections |
|
| 2955 | - for ($tempPos = $this->_parsePos + 1; $tempPos < count($this->parsingHtml->code); $tempPos++) { |
|
| 2956 | - $action = $this->parsingHtml->code[$tempPos]; |
|
| 2957 | - if ($action['name'] == 'fieldset') break; |
|
| 2958 | - if ($action['name'] == 'legend' && ! $action['close']) { |
|
| 2959 | - $legendOpenPos = $tempPos; |
|
| 2960 | - |
|
| 2961 | - $sub = null; |
|
| 2962 | - $this->_createSubHTML($sub); |
|
| 2963 | - $sub->parsingHtml->code = $this->parsingHtml->getLevel($tempPos - 1); |
|
| 2964 | - |
|
| 2965 | - $res = null; |
|
| 2966 | - for ($sub->_parsePos = 0; $sub->_parsePos < count($sub->parsingHtml->code); $sub->_parsePos++) { |
|
| 2967 | - $action = $sub->parsingHtml->code[$sub->_parsePos]; |
|
| 2968 | - $sub->_executeAction($action); |
|
| 2969 | - |
|
| 2970 | - if ($action['name'] == 'legend' && $action['close']) { |
|
| 2971 | - break; |
|
| 2972 | - } |
|
| 2973 | - } |
|
| 2974 | - |
|
| 2975 | - $legendH = $sub->_maxY; |
|
| 2976 | - $this->_destroySubHTML($sub); |
|
| 2977 | - |
|
| 2978 | - $move = $this->parsingCss->value['padding']['t'] + $this->parsingCss->value['border']['t']['width'] + 0.03; |
|
| 2979 | - |
|
| 2980 | - $param['moveTop'] = $legendH / 2; |
|
| 2981 | - |
|
| 2982 | - $this->parsingHtml->code[$legendOpenPos]['param']['moveTop'] = - ($legendH / 2 + $move); |
|
| 2983 | - $this->parsingHtml->code[$legendOpenPos]['param']['moveLeft'] = 2 - $this->parsingCss->value['border']['l']['width'] - $this->parsingCss->value['padding']['l']; |
|
| 2984 | - $this->parsingHtml->code[$legendOpenPos]['param']['moveDown'] = $move; |
|
| 2985 | - break; |
|
| 2986 | - } |
|
| 2987 | - } |
|
| 2988 | - $this->parsingCss->load(); |
|
| 2989 | - |
|
| 2990 | - return $this->_tag_open_DIV($param, 'fieldset'); |
|
| 2991 | - } |
|
| 2992 | - |
|
| 2993 | - /** |
|
| 2994 | - * tag : DIV |
|
| 2995 | - * mode : CLOSE |
|
| 2996 | - * |
|
| 2997 | - * @param array $param |
|
| 2998 | - * @param string $other name of tag that used the div tag |
|
| 2999 | - * @return boolean |
|
| 3000 | - */ |
|
| 3001 | - protected function _tag_close_DIV($param, $other = 'div') |
|
| 3002 | - { |
|
| 3003 | - if ($this->_isForOneLine) { |
|
| 3004 | - return false; |
|
| 3005 | - } |
|
| 3006 | - |
|
| 3007 | - if ($this->parsingCss->value['overflow'] == 'hidden') { |
|
| 3008 | - $this->_maxX = $this->parsingCss->value['old_maxX']; |
|
| 3009 | - $this->_maxY = $this->parsingCss->value['old_maxY']; |
|
| 3010 | - $this->_maxH = $this->parsingCss->value['old_maxH']; |
|
| 3011 | - $this->_isInOverflow = $this->parsingCss->value['old_overflow']; |
|
| 3012 | - $this->pdf->clippingPathStop(); |
|
| 3013 | - } |
|
| 3014 | - |
|
| 3015 | - if ($this->parsingCss->value['rotate']) { |
|
| 3016 | - $this->pdf->stopTransform(); |
|
| 3017 | - } |
|
| 3018 | - |
|
| 3019 | - $marge = array(); |
|
| 3020 | - $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03; |
|
| 3021 | - $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03; |
|
| 3022 | - $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03; |
|
| 3023 | - $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03; |
|
| 3024 | - |
|
| 3025 | - $x = $this->parsingCss->value['x']; |
|
| 3026 | - $y = $this->parsingCss->value['y']; |
|
| 3027 | - $w = $this->parsingCss->value['width'] + $marge['l'] + $marge['r'] + $this->parsingCss->value['margin']['r']; |
|
| 3028 | - $h = $this->parsingCss->value['height'] + $marge['t'] + $marge['b'] + $this->parsingCss->value['margin']['b']; |
|
| 3029 | - |
|
| 3030 | - switch ($this->parsingCss->value['rotate']) |
|
| 3031 | - { |
|
| 3032 | - case 90: |
|
| 3033 | - $t = $w; $w = $h; $h = $t; |
|
| 3034 | - break; |
|
| 3035 | - |
|
| 3036 | - case 270: |
|
| 3037 | - $t = $w; $w = $h; $h = $t; |
|
| 3038 | - break; |
|
| 3039 | - |
|
| 3040 | - default: |
|
| 3041 | - break; |
|
| 3042 | - } |
|
| 3043 | - |
|
| 3044 | - |
|
| 3045 | - if ($this->parsingCss->value['position'] != 'absolute') { |
|
| 3046 | - $this->pdf->setXY($x + $w, $y); |
|
| 3047 | - |
|
| 3048 | - $this->_maxX = max($this->_maxX, $x + $w); |
|
| 3049 | - $this->_maxY = max($this->_maxY, $y + $h); |
|
| 3050 | - $this->_maxH = max($this->_maxH, $h); |
|
| 3051 | - } else { |
|
| 3052 | - $this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']); |
|
| 3053 | - |
|
| 3054 | - $this->_loadMax(); |
|
| 3055 | - } |
|
| 3056 | - |
|
| 3057 | - $block = ($this->parsingCss->value['display'] != 'inline' && $this->parsingCss->value['position'] != 'absolute'); |
|
| 3058 | - |
|
| 3059 | - $this->parsingCss->load(); |
|
| 3060 | - $this->parsingCss->fontSet(); |
|
| 3061 | - $this->_loadMargin(); |
|
| 3062 | - |
|
| 3063 | - if ($block) { |
|
| 3064 | - $this->_tag_open_BR(array()); |
|
| 3065 | - } |
|
| 3066 | - if ($this->_debugActif) { |
|
| 3067 | - $this->_DEBUG_add(strtoupper($other), false); |
|
| 3068 | - } |
|
| 3069 | - |
|
| 3070 | - return true; |
|
| 3071 | - } |
|
| 3072 | - |
|
| 3073 | - /** |
|
| 3074 | - * tag : BLOCKQUOTE |
|
| 3075 | - * mode : CLOSE |
|
| 3076 | - * |
|
| 3077 | - * @param array $param |
|
| 3078 | - * @return boolean |
|
| 3079 | - */ |
|
| 3080 | - protected function _tag_close_BLOCKQUOTE($param) |
|
| 3081 | - { |
|
| 3082 | - return $this->_tag_close_DIV($param, 'blockquote'); |
|
| 3083 | - } |
|
| 3084 | - |
|
| 3085 | - /** |
|
| 3086 | - * tag : FIELDSET |
|
| 3087 | - * mode : CLOSE |
|
| 3088 | - * |
|
| 3089 | - * @param array $param |
|
| 3090 | - * @return boolean |
|
| 3091 | - */ |
|
| 3092 | - protected function _tag_close_FIELDSET($param) |
|
| 3093 | - { |
|
| 3094 | - return $this->_tag_close_DIV($param, 'fieldset'); |
|
| 3095 | - } |
|
| 3096 | - |
|
| 3097 | - /** |
|
| 3098 | - * tag : LEGEND |
|
| 3099 | - * mode : CLOSE |
|
| 3100 | - * |
|
| 3101 | - * @param array $param |
|
| 3102 | - * @return boolean |
|
| 3103 | - */ |
|
| 3104 | - protected function _tag_close_LEGEND($param) |
|
| 3105 | - { |
|
| 3106 | - return $this->_tag_close_DIV($param, 'legend'); |
|
| 3107 | - } |
|
| 3108 | - |
|
| 3109 | - /** |
|
| 3110 | - * tag : BARCODE |
|
| 3111 | - * mode : OPEN |
|
| 3112 | - * |
|
| 3113 | - * @param array $param |
|
| 3114 | - * @return boolean |
|
| 3115 | - */ |
|
| 3116 | - protected function _tag_open_BARCODE($param) |
|
| 3117 | - { |
|
| 3118 | - // for compatibility with old versions < 3.29 |
|
| 3119 | - $lstBarcode = array(); |
|
| 3120 | - $lstBarcode['UPC_A'] = 'UPCA'; |
|
| 3121 | - $lstBarcode['CODE39'] = 'C39'; |
|
| 3122 | - |
|
| 3123 | - if ( ! isset($param['type'])) $param['type'] = 'C39'; |
|
| 3124 | - if ( ! isset($param['value'])) $param['value'] = 0; |
|
| 3125 | - if ( ! isset($param['label'])) $param['label'] = 'label'; |
|
| 3126 | - if ( ! isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3127 | - |
|
| 3128 | - if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w']))) |
|
| 3129 | - throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w')); |
|
| 3130 | - |
|
| 3131 | - $param['type'] = strtoupper($param['type']); |
|
| 3132 | - if (isset($lstBarcode[$param['type']])) $param['type'] = $lstBarcode[$param['type']]; |
|
| 3133 | - |
|
| 3134 | - $this->parsingCss->save(); |
|
| 3135 | - $this->parsingCss->analyse('barcode', $param); |
|
| 3136 | - $this->parsingCss->setPosition(); |
|
| 3137 | - $this->parsingCss->fontSet(); |
|
| 3138 | - |
|
| 3139 | - $x = $this->pdf->getX(); |
|
| 3140 | - $y = $this->pdf->getY(); |
|
| 3141 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3142 | - $h = $this->parsingCss->value['height']; if ( ! $h) $h = $this->parsingCss->ConvertToMM('10mm'); |
|
| 3143 | - $txt = ($param['label'] !== 'none' ? $this->parsingCss->value['font-size'] : false); |
|
| 3144 | - $c = $this->parsingCss->value['color']; |
|
| 3145 | - $infos = $this->pdf->myBarcode($param['value'], $param['type'], $x, $y, $w, $h, $txt, $c); |
|
| 3146 | - |
|
| 3147 | - $this->_maxX = max($this->_maxX, $x + $infos[0]); |
|
| 3148 | - $this->_maxY = max($this->_maxY, $y + $infos[1]); |
|
| 3149 | - $this->_maxH = max($this->_maxH, $infos[1]); |
|
| 3150 | - $this->_maxE++; |
|
| 3151 | - |
|
| 3152 | - $this->pdf->setXY($x + $infos[0], $y); |
|
| 3153 | - |
|
| 3154 | - $this->parsingCss->load(); |
|
| 3155 | - $this->parsingCss->fontSet(); |
|
| 3156 | - |
|
| 3157 | - return true; |
|
| 3158 | - } |
|
| 3159 | - |
|
| 3160 | - /** |
|
| 3161 | - * tag : BARCODE |
|
| 3162 | - * mode : CLOSE |
|
| 3163 | - * |
|
| 3164 | - * @param array $param |
|
| 3165 | - * @return boolean |
|
| 3166 | - */ |
|
| 3167 | - protected function _tag_close_BARCODE($param) |
|
| 3168 | - { |
|
| 3169 | - // there is nothing to do here |
|
| 3170 | - |
|
| 3171 | - return true; |
|
| 3172 | - } |
|
| 3173 | - |
|
| 3174 | - /** |
|
| 3175 | - * tag : QRCODE |
|
| 3176 | - * mode : OPEN |
|
| 3177 | - * |
|
| 3178 | - * @param array $param |
|
| 3179 | - * @return boolean |
|
| 3180 | - */ |
|
| 3181 | - protected function _tag_open_QRCODE($param) |
|
| 3182 | - { |
|
| 3183 | - if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder']))) |
|
| 3184 | - throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder')); |
|
| 3185 | - |
|
| 3186 | - if ($this->_debugActif) $this->_DEBUG_add('QRCODE'); |
|
| 3187 | - |
|
| 3188 | - if ( ! isset($param['value'])) $param['value'] = ''; |
|
| 3189 | - if ( ! isset($param['ec'])) $param['ec'] = 'H'; |
|
| 3190 | - if ( ! isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3191 | - if ( ! isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF'; |
|
| 3192 | - if (isset($param['style']['border'])) { |
|
| 3193 | - $borders = $param['style']['border'] != 'none'; |
|
| 3194 | - unset($param['style']['border']); |
|
| 3195 | - } else { |
|
| 3196 | - $borders = true; |
|
| 3197 | - } |
|
| 3198 | - |
|
| 3199 | - if ($param['value'] === '') return true; |
|
| 3200 | - if ( ! in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H'; |
|
| 3201 | - |
|
| 3202 | - $this->parsingCss->save(); |
|
| 3203 | - $this->parsingCss->analyse('qrcode', $param); |
|
| 3204 | - $this->parsingCss->setPosition(); |
|
| 3205 | - $this->parsingCss->fontSet(); |
|
| 3206 | - |
|
| 3207 | - $x = $this->pdf->getX(); |
|
| 3208 | - $y = $this->pdf->getY(); |
|
| 3209 | - $w = $this->parsingCss->value['width']; |
|
| 3210 | - $h = $this->parsingCss->value['height']; |
|
| 3211 | - $size = max($w, $h); if ( ! $size) $size = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3212 | - |
|
| 3213 | - $style = array( |
|
| 3214 | - 'fgcolor' => $this->parsingCss->value['color'], |
|
| 3215 | - 'bgcolor' => $this->parsingCss->value['background']['color'], |
|
| 3216 | - ); |
|
| 3217 | - |
|
| 3218 | - if ($borders) { |
|
| 3219 | - $style['border'] = true; |
|
| 3220 | - $style['padding'] = 'auto'; |
|
| 3221 | - } else { |
|
| 3222 | - $style['border'] = false; |
|
| 3223 | - $style['padding'] = 0; |
|
| 3224 | - } |
|
| 3225 | - |
|
| 3226 | - if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 3227 | - $this->pdf->write2DBarcode($param['value'], 'QRCODE,'.$param['ec'], $x, $y, $size, $size, $style); |
|
| 3228 | - } |
|
| 3229 | - |
|
| 3230 | - $this->_maxX = max($this->_maxX, $x + $size); |
|
| 3231 | - $this->_maxY = max($this->_maxY, $y + $size); |
|
| 3232 | - $this->_maxH = max($this->_maxH, $size); |
|
| 3233 | - $this->_maxE++; |
|
| 3234 | - |
|
| 3235 | - $this->pdf->setX($x + $size); |
|
| 3236 | - |
|
| 3237 | - $this->parsingCss->load(); |
|
| 3238 | - $this->parsingCss->fontSet(); |
|
| 3239 | - |
|
| 3240 | - return true; |
|
| 3241 | - } |
|
| 3242 | - |
|
| 3243 | - /** |
|
| 3244 | - * tag : QRCODE |
|
| 3245 | - * mode : CLOSE |
|
| 3246 | - * |
|
| 3247 | - * @param array $param |
|
| 3248 | - * @return boolean |
|
| 3249 | - */ |
|
| 3250 | - protected function _tag_close_QRCODE($param) |
|
| 3251 | - { |
|
| 3252 | - // there is nothing to do here |
|
| 3253 | - |
|
| 3254 | - return true; |
|
| 3255 | - } |
|
| 3256 | - |
|
| 3257 | - /** |
|
| 3258 | - * tag : BOOKMARK |
|
| 3259 | - * mode : OPEN |
|
| 3260 | - * |
|
| 3261 | - * @param array $param |
|
| 3262 | - * @return boolean |
|
| 3263 | - */ |
|
| 3264 | - protected function _tag_open_BOOKMARK($param) |
|
| 3265 | - { |
|
| 3266 | - $titre = isset($param['title']) ? trim($param['title']) : ''; |
|
| 3267 | - $level = isset($param['level']) ? floor($param['level']) : 0; |
|
| 3268 | - |
|
| 3269 | - if ($level < 0) $level = 0; |
|
| 3270 | - if ($titre) $this->pdf->Bookmark($titre, $level, -1); |
|
| 3271 | - |
|
| 3272 | - return true; |
|
| 3273 | - } |
|
| 3274 | - |
|
| 3275 | - /** |
|
| 3276 | - * tag : BOOKMARK |
|
| 3277 | - * mode : CLOSE |
|
| 3278 | - * |
|
| 3279 | - * @param array $param |
|
| 3280 | - * @return boolean |
|
| 3281 | - */ |
|
| 3282 | - protected function _tag_close_BOOKMARK($param) |
|
| 3283 | - { |
|
| 3284 | - // there is nothing to do here |
|
| 3285 | - |
|
| 3286 | - return true; |
|
| 3287 | - } |
|
| 3288 | - |
|
| 3289 | - /** |
|
| 3290 | - * this is not a real TAG, it is just to write texts |
|
| 3291 | - * |
|
| 3292 | - * @param array $param |
|
| 3293 | - * @return null|boolean |
|
| 3294 | - */ |
|
| 3295 | - protected function _tag_open_WRITE($param) |
|
| 3296 | - { |
|
| 3297 | - $fill = ($this->parsingCss->value['background']['color'] !== null && $this->parsingCss->value['background']['image'] === null); |
|
| 3298 | - if (in_array($this->parsingCss->value['id_tag'], array('fieldset', 'legend', 'div', 'table', 'tr', 'td', 'th'))) { |
|
| 3299 | - $fill = false; |
|
| 3300 | - } |
|
| 3301 | - |
|
| 3302 | - // get the text to write |
|
| 3303 | - $txt = $param['txt']; |
|
| 3304 | - |
|
| 3305 | - if ($this->_isAfterFloat) { |
|
| 3306 | - $txt = ltrim($txt); |
|
| 3307 | - $this->_isAfterFloat = false; |
|
| 3308 | - } |
|
| 3309 | - |
|
| 3310 | - $txt = str_replace('[[page_nb]]', $this->pdf->getMyAliasNbPages(), $txt); |
|
| 3311 | - $txt = str_replace('[[page_cu]]', $this->pdf->getMyNumPage($this->_page), $txt); |
|
| 3312 | - |
|
| 3313 | - if ($this->parsingCss->value['text-transform'] != 'none') { |
|
| 3314 | - if ($this->parsingCss->value['text-transform'] == 'capitalize') |
|
| 3315 | - $txt = ucwords($txt); |
|
| 3316 | - else if ($this->parsingCss->value['text-transform'] == 'uppercase') |
|
| 3317 | - $txt = strtoupper($txt); |
|
| 3318 | - else if ($this->parsingCss->value['text-transform'] == 'lowercase') |
|
| 3319 | - $txt = strtolower($txt); |
|
| 3320 | - } |
|
| 3321 | - |
|
| 3322 | - // size of the text |
|
| 3323 | - $h = 1.08 * $this->parsingCss->value['font-size']; |
|
| 3324 | - $dh = $h * $this->parsingCss->value['mini-decal']; |
|
| 3325 | - $lh = $this->parsingCss->getLineHeight(); |
|
| 3326 | - |
|
| 3327 | - // identify the align |
|
| 3328 | - $align = 'L'; |
|
| 3329 | - if ($this->parsingCss->value['text-align'] == 'li_right') { |
|
| 3330 | - $w = $this->parsingCss->value['width']; |
|
| 3331 | - $align = 'R'; |
|
| 3332 | - } |
|
| 3333 | - |
|
| 3334 | - // calculate the width of each words, and of all the sentence |
|
| 3335 | - $w = 0; |
|
| 3336 | - $words = explode(' ', $txt); |
|
| 3337 | - foreach ($words as $k => $word) { |
|
| 3338 | - $words[$k] = array($word, $this->pdf->GetStringWidth($word)); |
|
| 3339 | - $w += $words[$k][1]; |
|
| 3340 | - } |
|
| 3341 | - $space = $this->pdf->GetStringWidth(' '); |
|
| 3342 | - $w += $space * (count($words) - 1); |
|
| 3343 | - |
|
| 3344 | - // position in the text |
|
| 3345 | - $currPos = 0; |
|
| 3346 | - |
|
| 3347 | - // the bigger width of the text, after automatic break line |
|
| 3348 | - $maxX = 0; |
|
| 3349 | - |
|
| 3350 | - // position of the text |
|
| 3351 | - $x = $this->pdf->getX(); |
|
| 3352 | - $y = $this->pdf->getY(); |
|
| 3353 | - $dy = $this->_getElementY($lh); |
|
| 3354 | - |
|
| 3355 | - // margins |
|
| 3356 | - list($left, $right) = $this->_getMargins($y); |
|
| 3357 | - |
|
| 3358 | - // number of lines after automatic break line |
|
| 3359 | - $nb = 0; |
|
| 3360 | - |
|
| 3361 | - // while we have words, and the text does not fit on the line => we cut the sentence |
|
| 3362 | - while ($x + $w > $right && $x < $right + $space && count($words)) { |
|
| 3363 | - // adding words 1 by 1 to fit on the line |
|
| 3364 | - $i = 0; |
|
| 3365 | - $old = array('', 0); |
|
| 3366 | - $str = $words[0]; |
|
| 3367 | - $add = false; |
|
| 3368 | - while (($x + $str[1]) < $right) { |
|
| 3369 | - $i++; |
|
| 3370 | - $add = true; |
|
| 3371 | - |
|
| 3372 | - array_shift($words); |
|
| 3373 | - $old = $str; |
|
| 3374 | - |
|
| 3375 | - if ( ! count($words)) break; |
|
| 3376 | - $str[0] .= ' '.$words[0][0]; |
|
| 3377 | - $str[1] += $space + $words[0][1]; |
|
| 3378 | - } |
|
| 3379 | - $str = $old; |
|
| 3380 | - |
|
| 3381 | - // if nothing fit on the line, and if the first word does not fit on the line => the word is too long, we put it |
|
| 3382 | - if ($i == 0 && (($left + $words[0][1]) >= $right)) { |
|
| 3383 | - $str = $words[0]; |
|
| 3384 | - array_shift($words); |
|
| 3385 | - $i++; |
|
| 3386 | - $add = true; |
|
| 3387 | - } |
|
| 3388 | - $currPos += ($currPos ? 1 : 0) + strlen($str[0]); |
|
| 3389 | - |
|
| 3390 | - // write the extract sentence that fit on the page |
|
| 3391 | - $wc = ($align == 'L' ? $str[1] : $this->parsingCss->value['width']); |
|
| 3392 | - if ($right - $left < $wc) $wc = $right - $left; |
|
| 3393 | - |
|
| 3394 | - if (strlen($str[0])) { |
|
| 3395 | - $this->pdf->setXY($this->pdf->getX(), $y + $dh + $dy); |
|
| 3396 | - $this->pdf->Cell($wc, $h, $str[0], 0, 0, $align, $fill, $this->_isInLink); |
|
| 3397 | - $this->pdf->setXY($this->pdf->getX(), $y); |
|
| 3398 | - } |
|
| 3399 | - $this->_maxH = max($this->_maxH, $lh); |
|
| 3400 | - |
|
| 3401 | - // max width |
|
| 3402 | - $maxX = max($maxX, $this->pdf->getX()); |
|
| 3403 | - |
|
| 3404 | - // new position and new width for the "while" |
|
| 3405 | - $w -= $str[1]; |
|
| 3406 | - $y = $this->pdf->getY(); |
|
| 3407 | - $x = $this->pdf->getX(); |
|
| 3408 | - $dy = $this->_getElementY($lh); |
|
| 3409 | - |
|
| 3410 | - // if we have again words to write |
|
| 3411 | - if (count($words)) { |
|
| 3412 | - // remove the space at the end |
|
| 3413 | - if ($add) $w -= $space; |
|
| 3414 | - |
|
| 3415 | - // if we don't add any word, and if the first word is empty => useless space to skip |
|
| 3416 | - if ( ! $add && $words[0][0] === '') { |
|
| 3417 | - array_shift($words); |
|
| 3418 | - } |
|
| 3419 | - |
|
| 3420 | - // if it is just to calculate for one line => adding the number of words |
|
| 3421 | - if ($this->_isForOneLine) { |
|
| 3422 | - $this->_maxE += $i; |
|
| 3423 | - $this->_maxX = max($this->_maxX, $maxX); |
|
| 3424 | - return null; |
|
| 3425 | - } |
|
| 3426 | - |
|
| 3427 | - // automatic line break |
|
| 3428 | - $this->_tag_open_BR(array('style' => ''), $currPos); |
|
| 3429 | - |
|
| 3430 | - // new position |
|
| 3431 | - $y = $this->pdf->getY(); |
|
| 3432 | - $x = $this->pdf->getX(); |
|
| 3433 | - $dy = $this->_getElementY($lh); |
|
| 3434 | - |
|
| 3435 | - // if the next line does not fit on the page => new page |
|
| 3436 | - if ($y + $h >= $this->pdf->getH() - $this->pdf->getbMargin()) { |
|
| 3437 | - if ( ! $this->_isInOverflow && ! $this->_isInFooter) { |
|
| 3438 | - $this->_setNewPage(null, '', null, $currPos); |
|
| 3439 | - $y = $this->pdf->getY(); |
|
| 3440 | - $x = $this->pdf->getX(); |
|
| 3441 | - $dy = $this->_getElementY($lh); |
|
| 3442 | - } |
|
| 3443 | - } |
|
| 3444 | - |
|
| 3445 | - // if more than 10000 line => error |
|
| 3446 | - $nb++; |
|
| 3447 | - if ($nb > 10000) { |
|
| 3448 | - $txt = ''; foreach ($words as $k => $word) $txt .= ($k ? ' ' : '').$word[0]; |
|
| 3449 | - throw new HTML2PDF_exception(2, array($txt, $right - $left, $w)); |
|
| 3450 | - } |
|
| 3451 | - |
|
| 3452 | - // new margins for the new line |
|
| 3453 | - list($left, $right) = $this->_getMargins($y); |
|
| 3454 | - } |
|
| 3455 | - } |
|
| 3456 | - |
|
| 3457 | - // if we have words after automatic cut, it is because they fit on the line => we write the text |
|
| 3458 | - if (count($words)) { |
|
| 3459 | - $txt = ''; foreach ($words as $k => $word) $txt .= ($k ? ' ' : '').$word[0]; |
|
| 3460 | - $w += $this->pdf->getWordSpacing() * (count($words)); |
|
| 3461 | - $this->pdf->setXY($this->pdf->getX(), $y + $dh + $dy); |
|
| 3462 | - $this->pdf->Cell(($align == 'L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink); |
|
| 3463 | - $this->pdf->setXY($this->pdf->getX(), $y); |
|
| 3464 | - $this->_maxH = max($this->_maxH, $lh); |
|
| 3465 | - $this->_maxE += count($words); |
|
| 3466 | - } |
|
| 3467 | - |
|
| 3468 | - $maxX = max($maxX, $this->pdf->getX()); |
|
| 3469 | - $maxY = $this->pdf->getY() + $h; |
|
| 3470 | - |
|
| 3471 | - $this->_maxX = max($this->_maxX, $maxX); |
|
| 3472 | - $this->_maxY = max($this->_maxY, $maxY); |
|
| 3473 | - |
|
| 3474 | - return true; |
|
| 3475 | - } |
|
| 3476 | - |
|
| 3477 | - /** |
|
| 3478 | - * tag : BR |
|
| 3479 | - * mode : OPEN |
|
| 3480 | - * |
|
| 3481 | - * @param array $param |
|
| 3482 | - * @param integer $curr real position in the html parseur (if break line in the write of a text) |
|
| 3483 | - * @return boolean |
|
| 3484 | - */ |
|
| 3485 | - protected function _tag_open_BR($param, $curr = null) |
|
| 3486 | - { |
|
| 3487 | - if ($this->_isForOneLine) return false; |
|
| 3488 | - |
|
| 3489 | - $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
|
| 3490 | - |
|
| 3491 | - if ($this->_maxH == 0) $this->_maxY = max($this->_maxY, $this->pdf->getY() + $h); |
|
| 3492 | - |
|
| 3493 | - $this->_makeBreakLine($h, $curr); |
|
| 3494 | - |
|
| 3495 | - $this->_maxH = 0; |
|
| 3496 | - $this->_maxE = 0; |
|
| 3497 | - |
|
| 3498 | - return true; |
|
| 3499 | - } |
|
| 3500 | - |
|
| 3501 | - /** |
|
| 3502 | - * tag : HR |
|
| 3503 | - * mode : OPEN |
|
| 3504 | - * |
|
| 3505 | - * @param array $param |
|
| 3506 | - * @return boolean |
|
| 3507 | - */ |
|
| 3508 | - protected function _tag_open_HR($param) |
|
| 3509 | - { |
|
| 3510 | - if ($this->_isForOneLine) { |
|
| 3511 | - return false; |
|
| 3512 | - } |
|
| 3513 | - $oldAlign = $this->parsingCss->value['text-align']; |
|
| 3514 | - $this->parsingCss->value['text-align'] = 'left'; |
|
| 3515 | - |
|
| 3516 | - if ($this->_maxH) { |
|
| 3517 | - $this->_tag_open_BR($param); |
|
| 3518 | - } |
|
| 3519 | - |
|
| 3520 | - $fontSize = $this->parsingCss->value['font-size']; |
|
| 3521 | - $this->parsingCss->value['font-size'] = $fontSize * 0.5; $this->_tag_open_BR($param); |
|
| 3522 | - $this->parsingCss->value['font-size'] = 0; |
|
| 3523 | - |
|
| 3524 | - $param['style']['width'] = '100%'; |
|
| 3525 | - |
|
| 3526 | - $this->parsingCss->save(); |
|
| 3527 | - $this->parsingCss->value['height'] = $this->parsingCss->ConvertToMM('1mm'); |
|
| 3528 | - |
|
| 3529 | - $this->parsingCss->analyse('hr', $param); |
|
| 3530 | - $this->parsingCss->setPosition(); |
|
| 3531 | - $this->parsingCss->fontSet(); |
|
| 3532 | - |
|
| 3533 | - $h = $this->parsingCss->value['height']; |
|
| 3534 | - if ($h) $h -= $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width']; |
|
| 3535 | - if ($h <= 0) $h = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width']; |
|
| 3536 | - |
|
| 3537 | - $this->_drawRectangle($this->pdf->getX(), $this->pdf->getY(), $this->parsingCss->value['width'], $h, $this->parsingCss->value['border'], 0, 0, $this->parsingCss->value['background']); |
|
| 3538 | - $this->_maxH = $h; |
|
| 3539 | - |
|
| 3540 | - $this->parsingCss->load(); |
|
| 3541 | - $this->parsingCss->fontSet(); |
|
| 3542 | - |
|
| 3543 | - $this->_tag_open_BR($param); |
|
| 3544 | - |
|
| 3545 | - $this->parsingCss->value['font-size'] = $fontSize * 0.5; $this->_tag_open_BR($param); |
|
| 3546 | - $this->parsingCss->value['font-size'] = $fontSize; |
|
| 3547 | - |
|
| 3548 | - $this->parsingCss->value['text-align'] = $oldAlign; |
|
| 3549 | - $this->_setNewPositionForNewLine(); |
|
| 3550 | - |
|
| 3551 | - return true; |
|
| 3552 | - } |
|
| 3553 | - |
|
| 3554 | - /** |
|
| 3555 | - * tag : B |
|
| 3556 | - * mode : OPEN |
|
| 3557 | - * |
|
| 3558 | - * @param array $param |
|
| 3559 | - * @param string $other |
|
| 3560 | - * @return boolean |
|
| 3561 | - */ |
|
| 3562 | - protected function _tag_open_B($param, $other = 'b') |
|
| 3563 | - { |
|
| 3564 | - $this->parsingCss->save(); |
|
| 3565 | - $this->parsingCss->value['font-bold'] = true; |
|
| 3566 | - $this->parsingCss->analyse($other, $param); |
|
| 3567 | - $this->parsingCss->setPosition(); |
|
| 3568 | - $this->parsingCss->fontSet(); |
|
| 3569 | - |
|
| 3570 | - return true; |
|
| 3571 | - } |
|
| 3572 | - |
|
| 3573 | - /** |
|
| 3574 | - * tag : STRONG |
|
| 3575 | - * mode : OPEN |
|
| 3576 | - * |
|
| 3577 | - * @param array $param |
|
| 3578 | - * @return boolean |
|
| 3579 | - */ |
|
| 3580 | - protected function _tag_open_STRONG($param) |
|
| 3581 | - { |
|
| 3582 | - return $this->_tag_open_B($param, 'strong'); |
|
| 3583 | - } |
|
| 3584 | - |
|
| 3585 | - /** |
|
| 3586 | - * tag : B |
|
| 3587 | - * mode : CLOSE |
|
| 3588 | - * |
|
| 3589 | - * @param array $param |
|
| 3590 | - * @return boolean |
|
| 3591 | - */ |
|
| 3592 | - protected function _tag_close_B($param) |
|
| 3593 | - { |
|
| 3594 | - $this->parsingCss->load(); |
|
| 3595 | - $this->parsingCss->fontSet(); |
|
| 3596 | - |
|
| 3597 | - return true; |
|
| 3598 | - } |
|
| 3599 | - |
|
| 3600 | - /** |
|
| 3601 | - * tag : STRONG |
|
| 3602 | - * mode : CLOSE |
|
| 3603 | - * |
|
| 3604 | - * @param array $param |
|
| 3605 | - * @return boolean |
|
| 3606 | - */ |
|
| 3607 | - protected function _tag_close_STRONG($param) |
|
| 3608 | - { |
|
| 3609 | - return $this->_tag_close_B($param); |
|
| 3610 | - } |
|
| 3611 | - |
|
| 3612 | - /** |
|
| 3613 | - * tag : I |
|
| 3614 | - * mode : OPEN |
|
| 3615 | - * |
|
| 3616 | - * @param array $param |
|
| 3617 | - * @param string $other |
|
| 3618 | - * @return boolean |
|
| 3619 | - */ |
|
| 3620 | - protected function _tag_open_I($param, $other = 'i') |
|
| 3621 | - { |
|
| 3622 | - $this->parsingCss->save(); |
|
| 3623 | - $this->parsingCss->value['font-italic'] = true; |
|
| 3624 | - $this->parsingCss->analyse($other, $param); |
|
| 3625 | - $this->parsingCss->setPosition(); |
|
| 3626 | - $this->parsingCss->fontSet(); |
|
| 3627 | - |
|
| 3628 | - return true; |
|
| 3629 | - } |
|
| 3630 | - |
|
| 3631 | - /** |
|
| 3632 | - * tag : ADDRESS |
|
| 3633 | - * mode : OPEN |
|
| 3634 | - * |
|
| 3635 | - * @param array $param |
|
| 3636 | - * @return boolean |
|
| 3637 | - */ |
|
| 3638 | - protected function _tag_open_ADDRESS($param) |
|
| 3639 | - { |
|
| 3640 | - return $this->_tag_open_I($param, 'address'); |
|
| 3641 | - } |
|
| 3642 | - |
|
| 3643 | - /** |
|
| 3644 | - * tag : CITE |
|
| 3645 | - * mode : OPEN |
|
| 3646 | - * |
|
| 3647 | - * @param array $param |
|
| 3648 | - * @return boolean |
|
| 3649 | - */ |
|
| 3650 | - protected function _tag_open_CITE($param) |
|
| 3651 | - { |
|
| 3652 | - return $this->_tag_open_I($param, 'cite'); |
|
| 3653 | - } |
|
| 3654 | - |
|
| 3655 | - /** |
|
| 3656 | - * tag : EM |
|
| 3657 | - * mode : OPEN |
|
| 3658 | - * |
|
| 3659 | - * @param array $param |
|
| 3660 | - * @return boolean |
|
| 3661 | - */ |
|
| 3662 | - protected function _tag_open_EM($param) |
|
| 3663 | - { |
|
| 3664 | - return $this->_tag_open_I($param, 'em'); |
|
| 3665 | - } |
|
| 3666 | - |
|
| 3667 | - /** |
|
| 3668 | - * tag : SAMP |
|
| 3669 | - * mode : OPEN |
|
| 3670 | - * |
|
| 3671 | - * @param array $param |
|
| 3672 | - * @return boolean |
|
| 3673 | - */ |
|
| 3674 | - protected function _tag_open_SAMP($param) |
|
| 3675 | - { |
|
| 3676 | - return $this->_tag_open_I($param, 'samp'); |
|
| 3677 | - } |
|
| 3678 | - |
|
| 3679 | - /** |
|
| 3680 | - * tag : I |
|
| 3681 | - * mode : CLOSE |
|
| 3682 | - * |
|
| 3683 | - * @param array $param |
|
| 3684 | - * @return boolean |
|
| 3685 | - */ |
|
| 3686 | - protected function _tag_close_I($param) |
|
| 3687 | - { |
|
| 3688 | - $this->parsingCss->load(); |
|
| 3689 | - $this->parsingCss->fontSet(); |
|
| 3690 | - |
|
| 3691 | - return true; |
|
| 3692 | - } |
|
| 3693 | - |
|
| 3694 | - /** |
|
| 3695 | - * tag : ADDRESS |
|
| 3696 | - * mode : CLOSE |
|
| 3697 | - * |
|
| 3698 | - * @param array $param |
|
| 3699 | - * @return boolean |
|
| 3700 | - */ |
|
| 3701 | - protected function _tag_close_ADDRESS($param) |
|
| 3702 | - { |
|
| 3703 | - return $this->_tag_close_I($param); |
|
| 3704 | - } |
|
| 3705 | - |
|
| 3706 | - /** |
|
| 3707 | - * tag : CITE |
|
| 3708 | - * mode : CLOSE |
|
| 3709 | - * |
|
| 3710 | - * @param array $param |
|
| 3711 | - * @return boolean |
|
| 3712 | - */ |
|
| 3713 | - protected function _tag_close_CITE($param) |
|
| 3714 | - { |
|
| 3715 | - return $this->_tag_close_I($param); |
|
| 3716 | - } |
|
| 3717 | - |
|
| 3718 | - /** |
|
| 3719 | - * tag : EM |
|
| 3720 | - * mode : CLOSE |
|
| 3721 | - * |
|
| 3722 | - * @param array $param |
|
| 3723 | - * @return boolean |
|
| 3724 | - */ |
|
| 3725 | - protected function _tag_close_EM($param) |
|
| 3726 | - { |
|
| 3727 | - return $this->_tag_close_I($param); |
|
| 3728 | - } |
|
| 3729 | - |
|
| 3730 | - /** |
|
| 3731 | - * tag : SAMP |
|
| 3732 | - * mode : CLOSE |
|
| 3733 | - * |
|
| 3734 | - * @param array $param |
|
| 3735 | - * @return boolean |
|
| 3736 | - */ |
|
| 3737 | - protected function _tag_close_SAMP($param) |
|
| 3738 | - { |
|
| 3739 | - return $this->_tag_close_I($param); |
|
| 3740 | - } |
|
| 3741 | - |
|
| 3742 | - /** |
|
| 3743 | - * tag : S |
|
| 3744 | - * mode : OPEN |
|
| 3745 | - * |
|
| 3746 | - * @param array $param |
|
| 3747 | - * @param string $other |
|
| 3748 | - * @return boolean |
|
| 3749 | - */ |
|
| 3750 | - protected function _tag_open_S($param, $other = 's') |
|
| 3751 | - { |
|
| 3752 | - $this->parsingCss->save(); |
|
| 3753 | - $this->parsingCss->value['font-linethrough'] = true; |
|
| 3754 | - $this->parsingCss->analyse($other, $param); |
|
| 3755 | - $this->parsingCss->setPosition(); |
|
| 3756 | - $this->parsingCss->fontSet(); |
|
| 3757 | - |
|
| 3758 | - return true; |
|
| 3759 | - } |
|
| 3760 | - |
|
| 3761 | - /** |
|
| 3762 | - * tag : DEL |
|
| 3763 | - * mode : OPEN |
|
| 3764 | - * |
|
| 3765 | - * @param array $param |
|
| 3766 | - * @return boolean |
|
| 3767 | - */ |
|
| 3768 | - protected function _tag_open_DEL($param) |
|
| 3769 | - { |
|
| 3770 | - return $this->_tag_open_S($param, 'del'); |
|
| 3771 | - } |
|
| 3772 | - |
|
| 3773 | - /** |
|
| 3774 | - * tag : S |
|
| 3775 | - * mode : CLOSE |
|
| 3776 | - * |
|
| 3777 | - * @param array $param |
|
| 3778 | - * @return boolean |
|
| 3779 | - */ |
|
| 3780 | - protected function _tag_close_S($param) |
|
| 3781 | - { |
|
| 3782 | - $this->parsingCss->load(); |
|
| 3783 | - $this->parsingCss->fontSet(); |
|
| 3784 | - |
|
| 3785 | - return true; |
|
| 3786 | - } |
|
| 3787 | - |
|
| 3788 | - /** |
|
| 3789 | - * tag : DEL |
|
| 3790 | - * mode : CLOSE |
|
| 3791 | - * |
|
| 3792 | - * @param array $param |
|
| 3793 | - * @return boolean |
|
| 3794 | - */ |
|
| 3795 | - protected function _tag_close_DEL($param) |
|
| 3796 | - { |
|
| 3797 | - return $this->_tag_close_S($param); |
|
| 3798 | - } |
|
| 3799 | - |
|
| 3800 | - /** |
|
| 3801 | - * tag : U |
|
| 3802 | - * mode : OPEN |
|
| 3803 | - * |
|
| 3804 | - * @param array $param |
|
| 3805 | - * @param string $other |
|
| 3806 | - * @return boolean |
|
| 3807 | - */ |
|
| 3808 | - protected function _tag_open_U($param, $other = 'u') |
|
| 3809 | - { |
|
| 3810 | - $this->parsingCss->save(); |
|
| 3811 | - $this->parsingCss->value['font-underline'] = true; |
|
| 3812 | - $this->parsingCss->analyse($other, $param); |
|
| 3813 | - $this->parsingCss->setPosition(); |
|
| 3814 | - $this->parsingCss->fontSet(); |
|
| 3815 | - |
|
| 3816 | - return true; |
|
| 3817 | - } |
|
| 3818 | - |
|
| 3819 | - /** |
|
| 3820 | - * tag : INS |
|
| 3821 | - * mode : OPEN |
|
| 3822 | - * |
|
| 3823 | - * @param array $param |
|
| 3824 | - * @return boolean |
|
| 3825 | - */ |
|
| 3826 | - protected function _tag_open_INS($param) |
|
| 3827 | - { |
|
| 3828 | - return $this->_tag_open_U($param, 'ins'); |
|
| 3829 | - } |
|
| 3830 | - |
|
| 3831 | - /** |
|
| 3832 | - * tag : U |
|
| 3833 | - * mode : CLOSE |
|
| 3834 | - * |
|
| 3835 | - * @param array $param |
|
| 3836 | - * @return boolean |
|
| 3837 | - */ |
|
| 3838 | - protected function _tag_close_U($param) |
|
| 3839 | - { |
|
| 3840 | - $this->parsingCss->load(); |
|
| 3841 | - $this->parsingCss->fontSet(); |
|
| 3842 | - |
|
| 3843 | - return true; |
|
| 3844 | - } |
|
| 3845 | - |
|
| 3846 | - /** |
|
| 3847 | - * tag : INS |
|
| 3848 | - * mode : CLOSE |
|
| 3849 | - * |
|
| 3850 | - * @param array $param |
|
| 3851 | - * @return boolean |
|
| 3852 | - */ |
|
| 3853 | - protected function _tag_close_INS($param) |
|
| 3854 | - { |
|
| 3855 | - return $this->_tag_close_U($param); |
|
| 3856 | - } |
|
| 3857 | - |
|
| 3858 | - /** |
|
| 3859 | - * tag : A |
|
| 3860 | - * mode : OPEN |
|
| 3861 | - * |
|
| 3862 | - * @param array $param |
|
| 3863 | - * @return boolean |
|
| 3864 | - */ |
|
| 3865 | - protected function _tag_open_A($param) |
|
| 3866 | - { |
|
| 3867 | - $this->_isInLink = str_replace('&', '&', isset($param['href']) ? $param['href'] : ''); |
|
| 3868 | - |
|
| 3869 | - if (isset($param['name'])) { |
|
| 3870 | - $name = $param['name']; |
|
| 3871 | - if ( ! isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 3872 | - |
|
| 3873 | - if ( ! $this->_lstAnchor[$name][1]) { |
|
| 3874 | - $this->_lstAnchor[$name][1] = true; |
|
| 3875 | - $this->pdf->SetLink($this->_lstAnchor[$name][0], -1, -1); |
|
| 3876 | - } |
|
| 3877 | - } |
|
| 3878 | - |
|
| 3879 | - if (preg_match('/^#([^#]+)$/isU', $this->_isInLink, $match)) { |
|
| 3880 | - $name = $match[1]; |
|
| 3881 | - if ( ! isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 3882 | - |
|
| 3883 | - $this->_isInLink = $this->_lstAnchor[$name][0]; |
|
| 3884 | - } |
|
| 3885 | - |
|
| 3886 | - $this->parsingCss->save(); |
|
| 3887 | - $this->parsingCss->value['font-underline'] = true; |
|
| 3888 | - $this->parsingCss->value['color'] = array(20, 20, 250); |
|
| 3889 | - $this->parsingCss->analyse('a', $param); |
|
| 3890 | - $this->parsingCss->setPosition(); |
|
| 3891 | - $this->parsingCss->fontSet(); |
|
| 3892 | - |
|
| 3893 | - return true; |
|
| 3894 | - } |
|
| 3895 | - |
|
| 3896 | - /** |
|
| 3897 | - * tag : A |
|
| 3898 | - * mode : CLOSE |
|
| 3899 | - * |
|
| 3900 | - * @param array $param |
|
| 3901 | - * @return boolean |
|
| 3902 | - */ |
|
| 3903 | - protected function _tag_close_A($param) |
|
| 3904 | - { |
|
| 3905 | - $this->_isInLink = ''; |
|
| 3906 | - $this->parsingCss->load(); |
|
| 3907 | - $this->parsingCss->fontSet(); |
|
| 3908 | - |
|
| 3909 | - return true; |
|
| 3910 | - } |
|
| 3911 | - |
|
| 3912 | - /** |
|
| 3913 | - * tag : H1 |
|
| 3914 | - * mode : OPEN |
|
| 3915 | - * |
|
| 3916 | - * @param array $param |
|
| 3917 | - * @param string $other |
|
| 3918 | - * @return boolean |
|
| 3919 | - */ |
|
| 3920 | - protected function _tag_open_H1($param, $other = 'h1') |
|
| 3921 | - { |
|
| 3922 | - if ($this->_isForOneLine) { |
|
| 3923 | - return false; |
|
| 3924 | - } |
|
| 3925 | - |
|
| 3926 | - if ($this->_maxH) { |
|
| 3927 | - $this->_tag_open_BR(array()); |
|
| 3928 | - } |
|
| 3929 | - $this->parsingCss->save(); |
|
| 3930 | - $this->parsingCss->value['font-bold'] = true; |
|
| 3931 | - |
|
| 3932 | - $size = array('h1' => '28px', 'h2' => '24px', 'h3' => '20px', 'h4' => '16px', 'h5' => '12px', 'h6' => '9px'); |
|
| 3933 | - $this->parsingCss->value['margin']['l'] = 0; |
|
| 3934 | - $this->parsingCss->value['margin']['r'] = 0; |
|
| 3935 | - $this->parsingCss->value['margin']['t'] = $this->parsingCss->ConvertToMM('16px'); |
|
| 3936 | - $this->parsingCss->value['margin']['b'] = $this->parsingCss->ConvertToMM('16px'); |
|
| 3937 | - $this->parsingCss->value['font-size'] = $this->parsingCss->ConvertToMM($size[$other]); |
|
| 3938 | - |
|
| 3939 | - $this->parsingCss->analyse($other, $param); |
|
| 3940 | - $this->parsingCss->setPosition(); |
|
| 3941 | - $this->parsingCss->fontSet(); |
|
| 3942 | - $this->_setNewPositionForNewLine(); |
|
| 3943 | - |
|
| 3944 | - return true; |
|
| 3945 | - } |
|
| 3946 | - |
|
| 3947 | - /** |
|
| 3948 | - * tag : H2 |
|
| 3949 | - * mode : OPEN |
|
| 3950 | - * |
|
| 3951 | - * @param array $param |
|
| 3952 | - * @return boolean |
|
| 3953 | - */ |
|
| 3954 | - protected function _tag_open_H2($param) |
|
| 3955 | - { |
|
| 3956 | - return $this->_tag_open_H1($param, 'h2'); |
|
| 3957 | - } |
|
| 3958 | - |
|
| 3959 | - /** |
|
| 3960 | - * tag : H3 |
|
| 3961 | - * mode : OPEN |
|
| 3962 | - * |
|
| 3963 | - * @param array $param |
|
| 3964 | - * @return boolean |
|
| 3965 | - */ |
|
| 3966 | - protected function _tag_open_H3($param) |
|
| 3967 | - { |
|
| 3968 | - return $this->_tag_open_H1($param, 'h3'); |
|
| 3969 | - } |
|
| 3970 | - |
|
| 3971 | - /** |
|
| 3972 | - * tag : H4 |
|
| 3973 | - * mode : OPEN |
|
| 3974 | - * |
|
| 3975 | - * @param array $param |
|
| 3976 | - * @return boolean |
|
| 3977 | - */ |
|
| 3978 | - protected function _tag_open_H4($param) |
|
| 3979 | - { |
|
| 3980 | - return $this->_tag_open_H1($param, 'h4'); |
|
| 3981 | - } |
|
| 3982 | - |
|
| 3983 | - /** |
|
| 3984 | - * tag : H5 |
|
| 3985 | - * mode : OPEN |
|
| 3986 | - * |
|
| 3987 | - * @param array $param |
|
| 3988 | - * @return boolean |
|
| 3989 | - */ |
|
| 3990 | - protected function _tag_open_H5($param) |
|
| 3991 | - { |
|
| 3992 | - return $this->_tag_open_H1($param, 'h5'); |
|
| 3993 | - } |
|
| 3994 | - |
|
| 3995 | - /** |
|
| 3996 | - * tag : H6 |
|
| 3997 | - * mode : OPEN |
|
| 3998 | - * |
|
| 3999 | - * @param array $param |
|
| 4000 | - * @return boolean |
|
| 4001 | - */ |
|
| 4002 | - protected function _tag_open_H6($param) |
|
| 4003 | - { |
|
| 4004 | - return $this->_tag_open_H1($param, 'h6'); |
|
| 4005 | - } |
|
| 4006 | - |
|
| 4007 | - /** |
|
| 4008 | - * tag : H1 |
|
| 4009 | - * mode : CLOSE |
|
| 4010 | - * |
|
| 4011 | - * @param array $param |
|
| 4012 | - * @return boolean |
|
| 4013 | - */ |
|
| 4014 | - protected function _tag_close_H1($param) |
|
| 4015 | - { |
|
| 4016 | - if ($this->_isForOneLine) { |
|
| 4017 | - return false; |
|
| 4018 | - } |
|
| 4019 | - |
|
| 4020 | - $this->_maxH += $this->parsingCss->value['margin']['b']; |
|
| 4021 | - $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
|
| 4022 | - |
|
| 4023 | - $this->parsingCss->load(); |
|
| 4024 | - $this->parsingCss->fontSet(); |
|
| 4025 | - |
|
| 4026 | - $this->_makeBreakLine($h); |
|
| 4027 | - $this->_maxH = 0; |
|
| 4028 | - |
|
| 4029 | - $this->_maxY = max($this->_maxY, $this->pdf->getY()); |
|
| 4030 | - |
|
| 4031 | - return true; |
|
| 4032 | - } |
|
| 4033 | - |
|
| 4034 | - /** |
|
| 4035 | - * tag : H2 |
|
| 4036 | - * mode : CLOSE |
|
| 4037 | - * |
|
| 4038 | - * @param array $param |
|
| 4039 | - * @return boolean |
|
| 4040 | - */ |
|
| 4041 | - protected function _tag_close_H2($param) |
|
| 4042 | - { |
|
| 4043 | - return $this->_tag_close_H1($param); |
|
| 4044 | - } |
|
| 4045 | - |
|
| 4046 | - /** |
|
| 4047 | - * tag : H3 |
|
| 4048 | - * mode : CLOSE |
|
| 4049 | - * |
|
| 4050 | - * @param array $param |
|
| 4051 | - * @return boolean |
|
| 4052 | - */ |
|
| 4053 | - protected function _tag_close_H3($param) |
|
| 4054 | - { |
|
| 4055 | - return $this->_tag_close_H1($param); |
|
| 4056 | - } |
|
| 4057 | - |
|
| 4058 | - /** |
|
| 4059 | - * tag : H4 |
|
| 4060 | - * mode : CLOSE |
|
| 4061 | - * |
|
| 4062 | - * @param array $param |
|
| 4063 | - * @return boolean |
|
| 4064 | - */ |
|
| 4065 | - protected function _tag_close_H4($param) |
|
| 4066 | - { |
|
| 4067 | - return $this->_tag_close_H1($param); |
|
| 4068 | - } |
|
| 4069 | - |
|
| 4070 | - /** |
|
| 4071 | - * tag : H5 |
|
| 4072 | - * mode : CLOSE |
|
| 4073 | - * |
|
| 4074 | - * @param array $param |
|
| 4075 | - * @return boolean |
|
| 4076 | - */ |
|
| 4077 | - protected function _tag_close_H5($param) |
|
| 4078 | - { |
|
| 4079 | - return $this->_tag_close_H1($param); |
|
| 4080 | - } |
|
| 4081 | - |
|
| 4082 | - /** |
|
| 4083 | - * tag : H6 |
|
| 4084 | - * mode : CLOSE |
|
| 4085 | - * |
|
| 4086 | - * @param array $param |
|
| 4087 | - * @return boolean |
|
| 4088 | - */ |
|
| 4089 | - protected function _tag_close_H6($param) |
|
| 4090 | - { |
|
| 4091 | - return $this->_tag_close_H1($param); |
|
| 4092 | - } |
|
| 4093 | - |
|
| 4094 | - /** |
|
| 4095 | - * tag : SPAN |
|
| 4096 | - * mode : OPEN |
|
| 4097 | - * |
|
| 4098 | - * @param array $param |
|
| 4099 | - * @param string $other |
|
| 4100 | - * @return boolean |
|
| 4101 | - */ |
|
| 4102 | - protected function _tag_open_SPAN($param, $other = 'span') |
|
| 4103 | - { |
|
| 4104 | - $this->parsingCss->save(); |
|
| 4105 | - $this->parsingCss->analyse($other, $param); |
|
| 4106 | - $this->parsingCss->setPosition(); |
|
| 4107 | - $this->parsingCss->fontSet(); |
|
| 4108 | - |
|
| 4109 | - return true; |
|
| 4110 | - } |
|
| 4111 | - |
|
| 4112 | - /** |
|
| 4113 | - * tag : FONT |
|
| 4114 | - * mode : OPEN |
|
| 4115 | - * |
|
| 4116 | - * @param array $param |
|
| 4117 | - * @return boolean |
|
| 4118 | - */ |
|
| 4119 | - protected function _tag_open_FONT($param) |
|
| 4120 | - { |
|
| 4121 | - return $this->_tag_open_SPAN($param, 'font'); |
|
| 4122 | - } |
|
| 4123 | - |
|
| 4124 | - /** |
|
| 4125 | - * tag : LABEL |
|
| 4126 | - * mode : OPEN |
|
| 4127 | - * |
|
| 4128 | - * @param array $param |
|
| 4129 | - * @return boolean |
|
| 4130 | - */ |
|
| 4131 | - protected function _tag_open_LABEL($param) |
|
| 4132 | - { |
|
| 4133 | - return $this->_tag_open_SPAN($param, 'label'); |
|
| 4134 | - } |
|
| 4135 | - |
|
| 4136 | - /** |
|
| 4137 | - * tag : SPAN |
|
| 4138 | - * mode : CLOSE |
|
| 4139 | - * |
|
| 4140 | - * @param array $param |
|
| 4141 | - * @return boolean |
|
| 4142 | - */ |
|
| 4143 | - protected function _tag_close_SPAN($param) |
|
| 4144 | - { |
|
| 4145 | - $this->parsingCss->restorePosition(); |
|
| 4146 | - $this->parsingCss->load(); |
|
| 4147 | - $this->parsingCss->fontSet(); |
|
| 4148 | - |
|
| 4149 | - return true; |
|
| 4150 | - } |
|
| 4151 | - |
|
| 4152 | - /** |
|
| 4153 | - * tag : FONT |
|
| 4154 | - * mode : CLOSE |
|
| 4155 | - * |
|
| 4156 | - * @param array $param |
|
| 4157 | - * @return boolean |
|
| 4158 | - */ |
|
| 4159 | - protected function _tag_close_FONT($param) |
|
| 4160 | - { |
|
| 4161 | - return $this->_tag_close_SPAN($param); |
|
| 4162 | - } |
|
| 4163 | - |
|
| 4164 | - /** |
|
| 4165 | - * tag : LABEL |
|
| 4166 | - * mode : CLOSE |
|
| 4167 | - * |
|
| 4168 | - * @param array $param |
|
| 4169 | - * @return boolean |
|
| 4170 | - */ |
|
| 4171 | - protected function _tag_close_LABEL($param) |
|
| 4172 | - { |
|
| 4173 | - return $this->_tag_close_SPAN($param); |
|
| 4174 | - } |
|
| 4175 | - |
|
| 4176 | - /** |
|
| 4177 | - * tag : P |
|
| 4178 | - * mode : OPEN |
|
| 4179 | - * |
|
| 4180 | - * @param array $param |
|
| 4181 | - * @return boolean |
|
| 4182 | - */ |
|
| 4183 | - protected function _tag_open_P($param) |
|
| 4184 | - { |
|
| 4185 | - if ($this->_isForOneLine) return false; |
|
| 4186 | - |
|
| 4187 | - if ( ! in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
|
| 4188 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4189 | - } |
|
| 4190 | - |
|
| 4191 | - $this->parsingCss->save(); |
|
| 4192 | - $this->parsingCss->analyse('p', $param); |
|
| 4193 | - $this->parsingCss->setPosition(); |
|
| 4194 | - $this->parsingCss->fontSet(); |
|
| 4195 | - |
|
| 4196 | - // cancel the effects of the setPosition |
|
| 4197 | - $this->pdf->setXY($this->pdf->getX() - $this->parsingCss->value['margin']['l'], $this->pdf->getY() - $this->parsingCss->value['margin']['t']); |
|
| 4198 | - |
|
| 4199 | - list($mL, $mR) = $this->_getMargins($this->pdf->getY()); |
|
| 4200 | - $mR = $this->pdf->getW() - $mR; |
|
| 4201 | - $mL += $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['padding']['l']; |
|
| 4202 | - $mR += $this->parsingCss->value['margin']['r'] + $this->parsingCss->value['padding']['r']; |
|
| 4203 | - $this->_saveMargin($mL, 0, $mR); |
|
| 4204 | - |
|
| 4205 | - if ($this->parsingCss->value['text-indent'] > 0) { |
|
| 4206 | - $y = $this->pdf->getY() + $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['padding']['t']; |
|
| 4207 | - $this->_pageMarges[floor($y * 100)] = array($mL + $this->parsingCss->value['text-indent'], $this->pdf->getW() - $mR); |
|
| 4208 | - $y += $this->parsingCss->getLineHeight() * 0.1; |
|
| 4209 | - $this->_pageMarges[floor($y * 100)] = array($mL, $this->pdf->getW() - $mR); |
|
| 4210 | - } |
|
| 4211 | - $this->_makeBreakLine($this->parsingCss->value['margin']['t'] + $this->parsingCss->value['padding']['t']); |
|
| 4212 | - $this->_isInParagraph = array($mL, $mR); |
|
| 4213 | - return true; |
|
| 4214 | - } |
|
| 4215 | - |
|
| 4216 | - /** |
|
| 4217 | - * tag : P |
|
| 4218 | - * mode : CLOSE |
|
| 4219 | - * |
|
| 4220 | - * @param array $param |
|
| 4221 | - * @return boolean |
|
| 4222 | - */ |
|
| 4223 | - protected function _tag_close_P($param) |
|
| 4224 | - { |
|
| 4225 | - if ($this->_isForOneLine) { |
|
| 4226 | - return false; |
|
| 4227 | - } |
|
| 4228 | - |
|
| 4229 | - if ($this->_maxH) { |
|
| 4230 | - $this->_tag_open_BR(array()); |
|
| 4231 | - } |
|
| 4232 | - $this->_isInParagraph = false; |
|
| 4233 | - $this->_loadMargin(); |
|
| 4234 | - $h = $this->parsingCss->value['margin']['b'] + $this->parsingCss->value['padding']['b']; |
|
| 4235 | - |
|
| 4236 | - $this->parsingCss->load(); |
|
| 4237 | - $this->parsingCss->fontSet(); |
|
| 4238 | - $this->_makeBreakLine($h); |
|
| 4239 | - |
|
| 4240 | - return true; |
|
| 4241 | - } |
|
| 4242 | - |
|
| 4243 | - /** |
|
| 4244 | - * tag : PRE |
|
| 4245 | - * mode : OPEN |
|
| 4246 | - * |
|
| 4247 | - * @param array $param |
|
| 4248 | - * @param string $other |
|
| 4249 | - * @return boolean |
|
| 4250 | - */ |
|
| 4251 | - protected function _tag_open_PRE($param, $other = 'pre') |
|
| 4252 | - { |
|
| 4253 | - if ($other == 'pre' && $this->_maxH) $this->_tag_open_BR(array()); |
|
| 4254 | - |
|
| 4255 | - $this->parsingCss->save(); |
|
| 4256 | - $this->parsingCss->value['font-family'] = 'courier'; |
|
| 4257 | - $this->parsingCss->analyse($other, $param); |
|
| 4258 | - $this->parsingCss->setPosition(); |
|
| 4259 | - $this->parsingCss->fontSet(); |
|
| 4260 | - |
|
| 4261 | - if ($other == 'pre') return $this->_tag_open_DIV($param, $other); |
|
| 4262 | - |
|
| 4263 | - return true; |
|
| 4264 | - } |
|
| 4265 | - |
|
| 4266 | - /** |
|
| 4267 | - * tag : CODE |
|
| 4268 | - * mode : OPEN |
|
| 4269 | - * |
|
| 4270 | - * @param array $param |
|
| 4271 | - * @return boolean |
|
| 4272 | - */ |
|
| 4273 | - protected function _tag_open_CODE($param) |
|
| 4274 | - { |
|
| 4275 | - return $this->_tag_open_PRE($param, 'code'); |
|
| 4276 | - } |
|
| 4277 | - |
|
| 4278 | - /** |
|
| 4279 | - * tag : PRE |
|
| 4280 | - * mode : CLOSE |
|
| 4281 | - * |
|
| 4282 | - * @param array $param |
|
| 4283 | - * @param string $other |
|
| 4284 | - * @return boolean |
|
| 4285 | - */ |
|
| 4286 | - protected function _tag_close_PRE($param, $other = 'pre') |
|
| 4287 | - { |
|
| 4288 | - if ($other == 'pre') { |
|
| 4289 | - if ($this->_isForOneLine) return false; |
|
| 4290 | - |
|
| 4291 | - $this->_tag_close_DIV($param, $other); |
|
| 4292 | - $this->_tag_open_BR(array()); |
|
| 4293 | - } |
|
| 4294 | - $this->parsingCss->load(); |
|
| 4295 | - $this->parsingCss->fontSet(); |
|
| 4296 | - |
|
| 4297 | - return true; |
|
| 4298 | - } |
|
| 4299 | - |
|
| 4300 | - /** |
|
| 4301 | - * tag : CODE |
|
| 4302 | - * mode : CLOSE |
|
| 4303 | - * |
|
| 4304 | - * @param array $param |
|
| 4305 | - * @return boolean |
|
| 4306 | - */ |
|
| 4307 | - protected function _tag_close_CODE($param) |
|
| 4308 | - { |
|
| 4309 | - return $this->_tag_close_PRE($param, 'code'); |
|
| 4310 | - } |
|
| 4311 | - |
|
| 4312 | - /** |
|
| 4313 | - * tag : BIG |
|
| 4314 | - * mode : OPEN |
|
| 4315 | - * |
|
| 4316 | - * @param array $param |
|
| 4317 | - * @return boolean |
|
| 4318 | - */ |
|
| 4319 | - protected function _tag_open_BIG($param) |
|
| 4320 | - { |
|
| 4321 | - $this->parsingCss->save(); |
|
| 4322 | - $this->parsingCss->value['mini-decal'] -= $this->parsingCss->value['mini-size'] * 0.12; |
|
| 4323 | - $this->parsingCss->value['mini-size'] *= 1.2; |
|
| 4324 | - $this->parsingCss->analyse('big', $param); |
|
| 4325 | - $this->parsingCss->setPosition(); |
|
| 4326 | - $this->parsingCss->fontSet(); |
|
| 4327 | - return true; |
|
| 4328 | - } |
|
| 4329 | - |
|
| 4330 | - /** |
|
| 4331 | - * tag : BIG |
|
| 4332 | - * mode : CLOSE |
|
| 4333 | - * |
|
| 4334 | - * @param array $param |
|
| 4335 | - * @return boolean |
|
| 4336 | - */ |
|
| 4337 | - protected function _tag_close_BIG($param) |
|
| 4338 | - { |
|
| 4339 | - $this->parsingCss->load(); |
|
| 4340 | - $this->parsingCss->fontSet(); |
|
| 4341 | - |
|
| 4342 | - return true; |
|
| 4343 | - } |
|
| 4344 | - |
|
| 4345 | - /** |
|
| 4346 | - * tag : SMALL |
|
| 4347 | - * mode : OPEN |
|
| 4348 | - * |
|
| 4349 | - * @param array $param |
|
| 4350 | - * @return boolean |
|
| 4351 | - */ |
|
| 4352 | - protected function _tag_open_SMALL($param) |
|
| 4353 | - { |
|
| 4354 | - $this->parsingCss->save(); |
|
| 4355 | - $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.05; |
|
| 4356 | - $this->parsingCss->value['mini-size'] *= 0.82; |
|
| 4357 | - $this->parsingCss->analyse('small', $param); |
|
| 4358 | - $this->parsingCss->setPosition(); |
|
| 4359 | - $this->parsingCss->fontSet(); |
|
| 4360 | - return true; |
|
| 4361 | - } |
|
| 4362 | - |
|
| 4363 | - /** |
|
| 4364 | - * tag : SMALL |
|
| 4365 | - * mode : CLOSE |
|
| 4366 | - * |
|
| 4367 | - * @param array $param |
|
| 4368 | - * @return boolean |
|
| 4369 | - */ |
|
| 4370 | - protected function _tag_close_SMALL($param) |
|
| 4371 | - { |
|
| 4372 | - $this->parsingCss->load(); |
|
| 4373 | - $this->parsingCss->fontSet(); |
|
| 4374 | - |
|
| 4375 | - return true; |
|
| 4376 | - } |
|
| 4377 | - |
|
| 4378 | - /** |
|
| 4379 | - * tag : SUP |
|
| 4380 | - * mode : OPEN |
|
| 4381 | - * |
|
| 4382 | - * @param array $param |
|
| 4383 | - * @return boolean |
|
| 4384 | - */ |
|
| 4385 | - protected function _tag_open_SUP($param) |
|
| 4386 | - { |
|
| 4387 | - $this->parsingCss->save(); |
|
| 4388 | - $this->parsingCss->value['mini-decal'] -= $this->parsingCss->value['mini-size'] * 0.15; |
|
| 4389 | - $this->parsingCss->value['mini-size'] *= 0.75; |
|
| 4390 | - $this->parsingCss->analyse('sup', $param); |
|
| 4391 | - $this->parsingCss->setPosition(); |
|
| 4392 | - $this->parsingCss->fontSet(); |
|
| 4393 | - |
|
| 4394 | - return true; |
|
| 4395 | - } |
|
| 4396 | - |
|
| 4397 | - /** |
|
| 4398 | - * tag : SUP |
|
| 4399 | - * mode : CLOSE |
|
| 4400 | - * |
|
| 4401 | - * @param array $param |
|
| 4402 | - * @return boolean |
|
| 4403 | - */ |
|
| 4404 | - protected function _tag_close_SUP($param) |
|
| 4405 | - { |
|
| 4406 | - $this->parsingCss->load(); |
|
| 4407 | - $this->parsingCss->fontSet(); |
|
| 4408 | - |
|
| 4409 | - return true; |
|
| 4410 | - } |
|
| 4411 | - |
|
| 4412 | - /** |
|
| 4413 | - * tag : SUB |
|
| 4414 | - * mode : OPEN |
|
| 4415 | - * |
|
| 4416 | - * @param array $param |
|
| 4417 | - * @return boolean |
|
| 4418 | - */ |
|
| 4419 | - protected function _tag_open_SUB($param) |
|
| 4420 | - { |
|
| 4421 | - $this->parsingCss->save(); |
|
| 4422 | - $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.15; |
|
| 4423 | - $this->parsingCss->value['mini-size'] *= 0.75; |
|
| 4424 | - $this->parsingCss->analyse('sub', $param); |
|
| 4425 | - $this->parsingCss->setPosition(); |
|
| 4426 | - $this->parsingCss->fontSet(); |
|
| 4427 | - return true; |
|
| 4428 | - } |
|
| 4429 | - |
|
| 4430 | - /** |
|
| 4431 | - * tag : SUB |
|
| 4432 | - * mode : CLOSE |
|
| 4433 | - * |
|
| 4434 | - * @param array $param |
|
| 4435 | - * @return boolean |
|
| 4436 | - */ |
|
| 4437 | - protected function _tag_close_SUB($param) |
|
| 4438 | - { |
|
| 4439 | - $this->parsingCss->load(); |
|
| 4440 | - $this->parsingCss->fontSet(); |
|
| 4441 | - |
|
| 4442 | - return true; |
|
| 4443 | - } |
|
| 4444 | - |
|
| 4445 | - /** |
|
| 4446 | - * tag : UL |
|
| 4447 | - * mode : OPEN |
|
| 4448 | - * |
|
| 4449 | - * @param array $param |
|
| 4450 | - * @param string $other |
|
| 4451 | - * @return boolean |
|
| 4452 | - */ |
|
| 4453 | - protected function _tag_open_UL($param, $other = 'ul') |
|
| 4454 | - { |
|
| 4455 | - if ($this->_isForOneLine) return false; |
|
| 4456 | - |
|
| 4457 | - if ( ! in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
|
| 4458 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4459 | - if ( ! count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4460 | - } |
|
| 4461 | - |
|
| 4462 | - if ( ! isset($param['style']['width'])) $param['allwidth'] = true; |
|
| 4463 | - $param['cellspacing'] = 0; |
|
| 4464 | - |
|
| 4465 | - // a list is like a table |
|
| 4466 | - $this->_tag_open_TABLE($param, $other); |
|
| 4467 | - |
|
| 4468 | - // add a level of list |
|
| 4469 | - $this->_listeAddLevel($other, $this->parsingCss->value['list-style-type'], $this->parsingCss->value['list-style-image']); |
|
| 4470 | - |
|
| 4471 | - return true; |
|
| 4472 | - } |
|
| 4473 | - |
|
| 4474 | - /** |
|
| 4475 | - * tag : OL |
|
| 4476 | - * mode : OPEN |
|
| 4477 | - * |
|
| 4478 | - * @param array $param |
|
| 4479 | - * @return boolean |
|
| 4480 | - */ |
|
| 4481 | - protected function _tag_open_OL($param) |
|
| 4482 | - { |
|
| 4483 | - return $this->_tag_open_UL($param, 'ol'); |
|
| 4484 | - } |
|
| 4485 | - |
|
| 4486 | - /** |
|
| 4487 | - * tag : UL |
|
| 4488 | - * mode : CLOSE |
|
| 4489 | - * |
|
| 4490 | - * @param array $param |
|
| 4491 | - * @return boolean |
|
| 4492 | - */ |
|
| 4493 | - protected function _tag_close_UL($param) |
|
| 4494 | - { |
|
| 4495 | - if ($this->_isForOneLine) return false; |
|
| 4496 | - |
|
| 4497 | - $this->_tag_close_TABLE($param); |
|
| 4498 | - |
|
| 4499 | - $this->_listeDelLevel(); |
|
| 4500 | - |
|
| 4501 | - if ( ! $this->_subPart) { |
|
| 4502 | - if ( ! count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4503 | - } |
|
| 4504 | - |
|
| 4505 | - return true; |
|
| 4506 | - } |
|
| 4507 | - |
|
| 4508 | - /** |
|
| 4509 | - * tag : OL |
|
| 4510 | - * mode : CLOSE |
|
| 4511 | - * |
|
| 4512 | - * @param array $param |
|
| 4513 | - * @return boolean |
|
| 4514 | - */ |
|
| 4515 | - protected function _tag_close_OL($param) |
|
| 4516 | - { |
|
| 4517 | - return $this->_tag_close_UL($param); |
|
| 4518 | - } |
|
| 4519 | - |
|
| 4520 | - /** |
|
| 4521 | - * tag : LI |
|
| 4522 | - * mode : OPEN |
|
| 4523 | - * |
|
| 4524 | - * @param array $param |
|
| 4525 | - * @return boolean |
|
| 4526 | - */ |
|
| 4527 | - protected function _tag_open_LI($param) |
|
| 4528 | - { |
|
| 4529 | - if ($this->_isForOneLine) return false; |
|
| 4530 | - |
|
| 4531 | - $this->_listeAddLi(); |
|
| 4532 | - |
|
| 4533 | - if ( ! isset($param['style']['width'])) $param['style']['width'] = '100%'; |
|
| 4534 | - |
|
| 4535 | - $paramPUCE = $param; |
|
| 4536 | - |
|
| 4537 | - $inf = $this->_listeGetLi(); |
|
| 4538 | - if ($inf[0]) { |
|
| 4539 | - $paramPUCE['style']['font-family'] = $inf[0]; |
|
| 4540 | - $paramPUCE['style']['text-align'] = 'li_right'; |
|
| 4541 | - $paramPUCE['style']['vertical-align'] = 'top'; |
|
| 4542 | - $paramPUCE['style']['width'] = $this->_listeGetWidth(); |
|
| 4543 | - $paramPUCE['style']['padding-right'] = $this->_listeGetPadding(); |
|
| 4544 | - $paramPUCE['txt'] = $inf[2]; |
|
| 4545 | - } else { |
|
| 4546 | - $paramPUCE['style']['text-align'] = 'li_right'; |
|
| 4547 | - $paramPUCE['style']['vertical-align'] = 'top'; |
|
| 4548 | - $paramPUCE['style']['width'] = $this->_listeGetWidth(); |
|
| 4549 | - $paramPUCE['style']['padding-right'] = $this->_listeGetPadding(); |
|
| 4550 | - $paramPUCE['src'] = $inf[2]; |
|
| 4551 | - $paramPUCE['sub_li'] = true; |
|
| 4552 | - } |
|
| 4553 | - |
|
| 4554 | - $this->_tag_open_TR($param, 'li'); |
|
| 4555 | - |
|
| 4556 | - $this->parsingCss->save(); |
|
| 4557 | - |
|
| 4558 | - // if small LI |
|
| 4559 | - if ($inf[1]) { |
|
| 4560 | - $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.045; |
|
| 4561 | - $this->parsingCss->value['mini-size'] *= 0.75; |
|
| 4562 | - } |
|
| 4563 | - |
|
| 4564 | - // if we are in a sub html => prepare. Else : display |
|
| 4565 | - if ($this->_subPart) { |
|
| 4566 | - // TD for the puce |
|
| 4567 | - $tmpPos = $this->_tempPos; |
|
| 4568 | - $tmpLst1 = $this->parsingHtml->code[$tmpPos + 1]; |
|
| 4569 | - $tmpLst2 = $this->parsingHtml->code[$tmpPos + 2]; |
|
| 4570 | - $this->parsingHtml->code[$tmpPos + 1] = array(); |
|
| 4571 | - $this->parsingHtml->code[$tmpPos + 1]['name'] = (isset($paramPUCE['src'])) ? 'img' : 'write'; |
|
| 4572 | - $this->parsingHtml->code[$tmpPos + 1]['param'] = $paramPUCE; unset($this->parsingHtml->code[$tmpPos + 1]['param']['style']['width']); |
|
| 4573 | - $this->parsingHtml->code[$tmpPos + 1]['close'] = 0; |
|
| 4574 | - $this->parsingHtml->code[$tmpPos + 2] = array(); |
|
| 4575 | - $this->parsingHtml->code[$tmpPos + 2]['name'] = 'li'; |
|
| 4576 | - $this->parsingHtml->code[$tmpPos + 2]['param'] = $paramPUCE; |
|
| 4577 | - $this->parsingHtml->code[$tmpPos + 2]['close'] = 1; |
|
| 4578 | - $this->_tag_open_TD($paramPUCE, 'li_sub'); |
|
| 4579 | - $this->_tag_close_TD($param); |
|
| 4580 | - $this->_tempPos = $tmpPos; |
|
| 4581 | - $this->parsingHtml->code[$tmpPos + 1] = $tmpLst1; |
|
| 4582 | - $this->parsingHtml->code[$tmpPos + 2] = $tmpLst2; |
|
| 4583 | - } else { |
|
| 4584 | - // TD for the puce |
|
| 4585 | - $this->_tag_open_TD($paramPUCE, 'li_sub'); |
|
| 4586 | - unset($paramPUCE['style']['width']); |
|
| 4587 | - if (isset($paramPUCE['src'])) { |
|
| 4588 | - $this->_tag_open_IMG($paramPUCE); |
|
| 4589 | - } else { |
|
| 4590 | - $this->_tag_open_WRITE($paramPUCE); |
|
| 4591 | - } |
|
| 4592 | - $this->_tag_close_TD($paramPUCE); |
|
| 4593 | - } |
|
| 4594 | - $this->parsingCss->load(); |
|
| 4595 | - |
|
| 4596 | - |
|
| 4597 | - // TD for the content |
|
| 4598 | - $this->_tag_open_TD($param, 'li'); |
|
| 4599 | - |
|
| 4600 | - return true; |
|
| 4601 | - } |
|
| 4602 | - |
|
| 4603 | - /** |
|
| 4604 | - * tag : LI |
|
| 4605 | - * mode : CLOSE |
|
| 4606 | - * |
|
| 4607 | - * @param array $param |
|
| 4608 | - * @return boolean |
|
| 4609 | - */ |
|
| 4610 | - protected function _tag_close_LI($param) |
|
| 4611 | - { |
|
| 4612 | - if ($this->_isForOneLine) { |
|
| 4613 | - return false; |
|
| 4614 | - } |
|
| 4615 | - |
|
| 4616 | - $this->_tag_close_TD($param); |
|
| 4617 | - |
|
| 4618 | - $this->_tag_close_TR($param); |
|
| 4619 | - |
|
| 4620 | - return true; |
|
| 4621 | - } |
|
| 4622 | - |
|
| 4623 | - /** |
|
| 4624 | - * tag : TBODY |
|
| 4625 | - * mode : OPEN |
|
| 4626 | - * |
|
| 4627 | - * @param array $param |
|
| 4628 | - * @return boolean |
|
| 4629 | - */ |
|
| 4630 | - protected function _tag_open_TBODY($param) |
|
| 4631 | - { |
|
| 4632 | - if ($this->_isForOneLine) { |
|
| 4633 | - return false; |
|
| 4634 | - } |
|
| 4635 | - |
|
| 4636 | - $this->parsingCss->save(); |
|
| 4637 | - $this->parsingCss->analyse('tbody', $param); |
|
| 4638 | - $this->parsingCss->setPosition(); |
|
| 4639 | - $this->parsingCss->fontSet(); |
|
| 4640 | - |
|
| 4641 | - return true; |
|
| 4642 | - } |
|
| 4643 | - |
|
| 4644 | - /** |
|
| 4645 | - * tag : TBODY |
|
| 4646 | - * mode : CLOSE |
|
| 4647 | - * |
|
| 4648 | - * @param array $param |
|
| 4649 | - * @return boolean |
|
| 4650 | - */ |
|
| 4651 | - protected function _tag_close_TBODY($param) |
|
| 4652 | - { |
|
| 4653 | - if ($this->_isForOneLine) { |
|
| 4654 | - return false; |
|
| 4655 | - } |
|
| 4656 | - |
|
| 4657 | - $this->parsingCss->load(); |
|
| 4658 | - $this->parsingCss->fontSet(); |
|
| 4659 | - |
|
| 4660 | - return true; |
|
| 4661 | - } |
|
| 4662 | - |
|
| 4663 | - /** |
|
| 4664 | - * tag : THEAD |
|
| 4665 | - * mode : OPEN |
|
| 4666 | - * |
|
| 4667 | - * @param array $param |
|
| 4668 | - * @return boolean |
|
| 4669 | - */ |
|
| 4670 | - protected function _tag_open_THEAD($param) |
|
| 4671 | - { |
|
| 4672 | - if ($this->_isForOneLine) { |
|
| 4673 | - return false; |
|
| 4674 | - } |
|
| 4675 | - |
|
| 4676 | - $this->parsingCss->save(); |
|
| 4677 | - $this->parsingCss->analyse('thead', $param); |
|
| 4678 | - $this->parsingCss->setPosition(); |
|
| 4679 | - $this->parsingCss->fontSet(); |
|
| 4680 | - |
|
| 4681 | - // if we are in a sub part, save the number of the first TR in the thead |
|
| 4682 | - if ($this->_subPart) { |
|
| 4683 | - HTML2PDF::$_tables[$param['num']]['thead']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 4684 | - HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); |
|
| 4685 | - for ($pos = $this->_tempPos; $pos < count($this->parsingHtml->code); $pos++) { |
|
| 4686 | - $action = $this->parsingHtml->code[$pos]; |
|
| 4687 | - if (strtolower($action['name']) == 'thead') $action['name'] = 'thead_sub'; |
|
| 4688 | - HTML2PDF::$_tables[$param['num']]['thead']['code'][] = $action; |
|
| 4689 | - if (strtolower($action['name']) == 'thead_sub' && $action['close']) break; |
|
| 4690 | - } |
|
| 4691 | - } else { |
|
| 4692 | - $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 4693 | - $this->_parsePos += count($level); |
|
| 4694 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] += count(HTML2PDF::$_tables[$param['num']]['thead']['tr']); |
|
| 4695 | - } |
|
| 4696 | - |
|
| 4697 | - return true; |
|
| 4698 | - } |
|
| 4699 | - |
|
| 4700 | - /** |
|
| 4701 | - * tag : THEAD |
|
| 4702 | - * mode : CLOSE |
|
| 4703 | - * |
|
| 4704 | - * @param array $param |
|
| 4705 | - * @return boolean |
|
| 4706 | - */ |
|
| 4707 | - protected function _tag_close_THEAD($param) |
|
| 4708 | - { |
|
| 4709 | - if ($this->_isForOneLine) { |
|
| 4710 | - return false; |
|
| 4711 | - } |
|
| 4712 | - |
|
| 4713 | - $this->parsingCss->load(); |
|
| 4714 | - $this->parsingCss->fontSet(); |
|
| 4715 | - |
|
| 4716 | - // if we are in a sub HTM, construct the list of the TR in the thead |
|
| 4717 | - if ($this->_subPart) { |
|
| 4718 | - $min = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0]; |
|
| 4719 | - $max = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1; |
|
| 4720 | - HTML2PDF::$_tables[$param['num']]['thead']['tr'] = range($min, $max); |
|
| 4721 | - } |
|
| 4722 | - |
|
| 4723 | - return true; |
|
| 4724 | - } |
|
| 4725 | - |
|
| 4726 | - /** |
|
| 4727 | - * tag : TFOOT |
|
| 4728 | - * mode : OPEN |
|
| 4729 | - * |
|
| 4730 | - * @param array $param |
|
| 4731 | - * @return boolean |
|
| 4732 | - */ |
|
| 4733 | - protected function _tag_open_TFOOT($param) |
|
| 4734 | - { |
|
| 4735 | - if ($this->_isForOneLine) { |
|
| 4736 | - return false; |
|
| 4737 | - } |
|
| 4738 | - |
|
| 4739 | - $this->parsingCss->save(); |
|
| 4740 | - $this->parsingCss->analyse('tfoot', $param); |
|
| 4741 | - $this->parsingCss->setPosition(); |
|
| 4742 | - $this->parsingCss->fontSet(); |
|
| 4743 | - |
|
| 4744 | - // if we are in a sub part, save the number of the first TR in the tfoot |
|
| 4745 | - if ($this->_subPart) { |
|
| 4746 | - HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 4747 | - HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); |
|
| 4748 | - for ($pos = $this->_tempPos; $pos < count($this->parsingHtml->code); $pos++) { |
|
| 4749 | - $action = $this->parsingHtml->code[$pos]; |
|
| 4750 | - if (strtolower($action['name']) == 'tfoot') $action['name'] = 'tfoot_sub'; |
|
| 4751 | - HTML2PDF::$_tables[$param['num']]['tfoot']['code'][] = $action; |
|
| 4752 | - if (strtolower($action['name']) == 'tfoot_sub' && $action['close']) break; |
|
| 4753 | - } |
|
| 4754 | - } else { |
|
| 4755 | - $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 4756 | - $this->_parsePos += count($level); |
|
| 4757 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] += count(HTML2PDF::$_tables[$param['num']]['tfoot']['tr']); |
|
| 4758 | - } |
|
| 4759 | - |
|
| 4760 | - return true; |
|
| 4761 | - } |
|
| 4762 | - |
|
| 4763 | - /** |
|
| 4764 | - * tag : TFOOT |
|
| 4765 | - * mode : CLOSE |
|
| 4766 | - * |
|
| 4767 | - * @param array $param |
|
| 4768 | - * @return boolean |
|
| 4769 | - */ |
|
| 4770 | - protected function _tag_close_TFOOT($param) |
|
| 4771 | - { |
|
| 4772 | - if ($this->_isForOneLine) { |
|
| 4773 | - return false; |
|
| 4774 | - } |
|
| 4775 | - |
|
| 4776 | - $this->parsingCss->load(); |
|
| 4777 | - $this->parsingCss->fontSet(); |
|
| 4778 | - |
|
| 4779 | - // if we are in a sub HTM, construct the list of the TR in the tfoot |
|
| 4780 | - if ($this->_subPart) { |
|
| 4781 | - $min = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0]; |
|
| 4782 | - $max = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1; |
|
| 4783 | - HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = range($min, $max); |
|
| 4784 | - } |
|
| 4785 | - |
|
| 4786 | - return true; |
|
| 4787 | - } |
|
| 4788 | - |
|
| 4789 | - /** |
|
| 4790 | - * It is not a real TAG, does not use it ! |
|
| 4791 | - * |
|
| 4792 | - * @param array $param |
|
| 4793 | - * @return boolean |
|
| 4794 | - */ |
|
| 4795 | - protected function _tag_open_THEAD_SUB($param) |
|
| 4796 | - { |
|
| 4797 | - if ($this->_isForOneLine) { |
|
| 4798 | - return false; |
|
| 4799 | - } |
|
| 4800 | - |
|
| 4801 | - $this->parsingCss->save(); |
|
| 4802 | - $this->parsingCss->analyse('thead', $param); |
|
| 4803 | - $this->parsingCss->setPosition(); |
|
| 4804 | - $this->parsingCss->fontSet(); |
|
| 4805 | - |
|
| 4806 | - return true; |
|
| 4807 | - } |
|
| 4808 | - |
|
| 4809 | - /** |
|
| 4810 | - * It is not a real TAG, does not use it ! |
|
| 4811 | - * |
|
| 4812 | - * @param array $param |
|
| 4813 | - * @return boolean |
|
| 4814 | - */ |
|
| 4815 | - protected function _tag_close_THEAD_SUB($param) |
|
| 4816 | - { |
|
| 4817 | - if ($this->_isForOneLine) { |
|
| 4818 | - return false; |
|
| 4819 | - } |
|
| 4820 | - |
|
| 4821 | - $this->parsingCss->load(); |
|
| 4822 | - $this->parsingCss->fontSet(); |
|
| 4823 | - |
|
| 4824 | - return true; |
|
| 4825 | - } |
|
| 4826 | - |
|
| 4827 | - /** |
|
| 4828 | - * It is not a real TAG, does not use it ! |
|
| 4829 | - * |
|
| 4830 | - * @param array $param |
|
| 4831 | - * @return boolean |
|
| 4832 | - */ |
|
| 4833 | - protected function _tag_open_TFOOT_SUB($param) |
|
| 4834 | - { |
|
| 4835 | - if ($this->_isForOneLine) { |
|
| 4836 | - return false; |
|
| 4837 | - } |
|
| 4838 | - |
|
| 4839 | - $this->parsingCss->save(); |
|
| 4840 | - $this->parsingCss->analyse('tfoot', $param); |
|
| 4841 | - $this->parsingCss->setPosition(); |
|
| 4842 | - $this->parsingCss->fontSet(); |
|
| 4843 | - |
|
| 4844 | - return true; |
|
| 4845 | - } |
|
| 4846 | - |
|
| 4847 | - /** |
|
| 4848 | - * It is not a real TAG, does not use it ! |
|
| 4849 | - * |
|
| 4850 | - * @param array $param |
|
| 4851 | - * @return boolean |
|
| 4852 | - */ |
|
| 4853 | - protected function _tag_close_TFOOT_SUB($param) |
|
| 4854 | - { |
|
| 4855 | - if ($this->_isForOneLine) { |
|
| 4856 | - return false; |
|
| 4857 | - } |
|
| 4858 | - |
|
| 4859 | - $this->parsingCss->load(); |
|
| 4860 | - $this->parsingCss->fontSet(); |
|
| 4861 | - |
|
| 4862 | - return true; |
|
| 4863 | - } |
|
| 4864 | - |
|
| 4865 | - /** |
|
| 4866 | - * tag : FORM |
|
| 4867 | - * mode : OPEN |
|
| 4868 | - * |
|
| 4869 | - * @param array $param |
|
| 4870 | - * @return boolean |
|
| 4871 | - */ |
|
| 4872 | - protected function _tag_open_FORM($param) |
|
| 4873 | - { |
|
| 4874 | - $this->parsingCss->save(); |
|
| 4875 | - $this->parsingCss->analyse('form', $param); |
|
| 4876 | - $this->parsingCss->setPosition(); |
|
| 4877 | - $this->parsingCss->fontSet(); |
|
| 4878 | - |
|
| 4879 | - $this->pdf->setFormDefaultProp( |
|
| 4880 | - array( |
|
| 4881 | - 'lineWidth'=>1, |
|
| 4882 | - 'borderStyle'=>'solid', |
|
| 4883 | - 'fillColor'=>array(220, 220, 255), |
|
| 4884 | - 'strokeColor'=>array(128, 128, 200) |
|
| 4885 | - ) |
|
| 4886 | - ); |
|
| 4887 | - |
|
| 4888 | - $this->_isInForm = isset($param['action']) ? $param['action'] : ''; |
|
| 4889 | - |
|
| 4890 | - return true; |
|
| 4891 | - } |
|
| 4892 | - |
|
| 4893 | - /** |
|
| 4894 | - * tag : FORM |
|
| 4895 | - * mode : CLOSE |
|
| 4896 | - * |
|
| 4897 | - * @param array $param |
|
| 4898 | - * @return boolean |
|
| 4899 | - */ |
|
| 4900 | - protected function _tag_close_FORM($param) |
|
| 4901 | - { |
|
| 4902 | - $this->_isInForm = false; |
|
| 4903 | - $this->parsingCss->load(); |
|
| 4904 | - $this->parsingCss->fontSet(); |
|
| 4905 | - |
|
| 4906 | - return true; |
|
| 4907 | - } |
|
| 4908 | - |
|
| 4909 | - /** |
|
| 4910 | - * tag : TABLE |
|
| 4911 | - * mode : OPEN |
|
| 4912 | - * |
|
| 4913 | - * @param array $param |
|
| 4914 | - * @return boolean |
|
| 4915 | - */ |
|
| 4916 | - protected function _tag_open_TABLE($param, $other = 'table') |
|
| 4917 | - { |
|
| 4918 | - if ($this->_maxH) { |
|
| 4919 | - if ($this->_isForOneLine) { |
|
| 4920 | - return false; |
|
| 4921 | - } |
|
| 4922 | - $this->_tag_open_BR(array()); |
|
| 4923 | - } |
|
| 4924 | - |
|
| 4925 | - if ($this->_isForOneLine) { |
|
| 4926 | - $this->_maxX = $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 4927 | - return false; |
|
| 4928 | - } |
|
| 4929 | - |
|
| 4930 | - $this->_maxH = 0; |
|
| 4931 | - |
|
| 4932 | - $alignObject = isset($param['align']) ? strtolower($param['align']) : 'left'; |
|
| 4933 | - if (isset($param['align'])) unset($param['align']); |
|
| 4934 | - if ( ! in_array($alignObject, array('left', 'center', 'right'))) $alignObject = 'left'; |
|
| 4935 | - |
|
| 4936 | - $this->parsingCss->save(); |
|
| 4937 | - $this->parsingCss->analyse($other, $param); |
|
| 4938 | - $this->parsingCss->setPosition(); |
|
| 4939 | - $this->parsingCss->fontSet(); |
|
| 4940 | - |
|
| 4941 | - if ($this->parsingCss->value['margin-auto']) $alignObject = 'center'; |
|
| 4942 | - |
|
| 4943 | - // collapse table ? |
|
| 4944 | - $collapse = false; |
|
| 4945 | - if ($other == 'table') { |
|
| 4946 | - $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false; |
|
| 4947 | - } |
|
| 4948 | - |
|
| 4949 | - // if collapse => no borders for the table, only for TD |
|
| 4950 | - if ($collapse) { |
|
| 4951 | - $param['style']['border'] = 'none'; |
|
| 4952 | - $param['cellspacing'] = 0; |
|
| 4953 | - $none = $this->parsingCss->readBorder('none'); |
|
| 4954 | - $this->parsingCss->value['border']['t'] = $none; |
|
| 4955 | - $this->parsingCss->value['border']['r'] = $none; |
|
| 4956 | - $this->parsingCss->value['border']['b'] = $none; |
|
| 4957 | - $this->parsingCss->value['border']['l'] = $none; |
|
| 4958 | - } |
|
| 4959 | - |
|
| 4960 | - // if we are in a SUB html => prepare the properties of the table |
|
| 4961 | - if ($this->_subPart) { |
|
| 4962 | - if ($this->_debugActif) { |
|
| 4963 | - $this->_DEBUG_add('Table n'.$param['num'], true); |
|
| 4964 | - } |
|
| 4965 | - HTML2PDF::$_tables[$param['num']] = array(); |
|
| 4966 | - HTML2PDF::$_tables[$param['num']]['border'] = isset($param['border']) ? $this->parsingCss->readBorder($param['border']) : null; |
|
| 4967 | - HTML2PDF::$_tables[$param['num']]['cellpadding'] = $this->parsingCss->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px'); |
|
| 4968 | - HTML2PDF::$_tables[$param['num']]['cellspacing'] = $this->parsingCss->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); |
|
| 4969 | - HTML2PDF::$_tables[$param['num']]['cases'] = array(); // properties of each TR/TD |
|
| 4970 | - HTML2PDF::$_tables[$param['num']]['corr'] = array(); // link between TR/TD and colspan/rowspan |
|
| 4971 | - HTML2PDF::$_tables[$param['num']]['corr_x'] = 0; // position in 'cases' |
|
| 4972 | - HTML2PDF::$_tables[$param['num']]['corr_y'] = 0; // position in 'cases' |
|
| 4973 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; // current column |
|
| 4974 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = 0; // current row |
|
| 4975 | - HTML2PDF::$_tables[$param['num']]['curr_x'] = $this->pdf->getX(); |
|
| 4976 | - HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY(); |
|
| 4977 | - HTML2PDF::$_tables[$param['num']]['width'] = 0; // global width |
|
| 4978 | - HTML2PDF::$_tables[$param['num']]['height'] = 0; // global height |
|
| 4979 | - HTML2PDF::$_tables[$param['num']]['align'] = $alignObject; |
|
| 4980 | - HTML2PDF::$_tables[$param['num']]['marge'] = array(); |
|
| 4981 | - HTML2PDF::$_tables[$param['num']]['marge']['t'] = $this->parsingCss->value['padding']['t'] + $this->parsingCss->value['border']['t']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4982 | - HTML2PDF::$_tables[$param['num']]['marge']['r'] = $this->parsingCss->value['padding']['r'] + $this->parsingCss->value['border']['r']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4983 | - HTML2PDF::$_tables[$param['num']]['marge']['b'] = $this->parsingCss->value['padding']['b'] + $this->parsingCss->value['border']['b']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4984 | - HTML2PDF::$_tables[$param['num']]['marge']['l'] = $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['border']['l']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4985 | - HTML2PDF::$_tables[$param['num']]['page'] = 0; // number of pages |
|
| 4986 | - HTML2PDF::$_tables[$param['num']]['new_page'] = true; // flag : new page for the current TR |
|
| 4987 | - HTML2PDF::$_tables[$param['num']]['style_value'] = null; // CSS style of the table |
|
| 4988 | - HTML2PDF::$_tables[$param['num']]['thead'] = array(); // properties on the thead |
|
| 4989 | - HTML2PDF::$_tables[$param['num']]['tfoot'] = array(); // properties on the tfoot |
|
| 4990 | - HTML2PDF::$_tables[$param['num']]['thead']['tr'] = array(); // list of the TRs in the thead |
|
| 4991 | - HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = array(); // list of the TRs in the tfoot |
|
| 4992 | - HTML2PDF::$_tables[$param['num']]['thead']['height'] = 0; // thead height |
|
| 4993 | - HTML2PDF::$_tables[$param['num']]['tfoot']['height'] = 0; // tfoot height |
|
| 4994 | - HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); // HTML content of the thead |
|
| 4995 | - HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); // HTML content of the tfoot |
|
| 4996 | - HTML2PDF::$_tables[$param['num']]['cols'] = array(); // properties of the COLs |
|
| 4997 | - |
|
| 4998 | - $this->_saveMargin($this->pdf->getlMargin(), $this->pdf->gettMargin(), $this->pdf->getrMargin()); |
|
| 4999 | - |
|
| 5000 | - $this->parsingCss->value['width'] -= HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r']; |
|
| 5001 | - } else { |
|
| 5002 | - // we start from the first page and the first page of the table |
|
| 5003 | - HTML2PDF::$_tables[$param['num']]['page'] = 0; |
|
| 5004 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5005 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = 0; |
|
| 5006 | - HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['curr_x']; |
|
| 5007 | - HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5008 | - |
|
| 5009 | - // draw the borders/background of the first page/part of the table |
|
| 5010 | - $this->_drawRectangle( |
|
| 5011 | - HTML2PDF::$_tables[$param['num']]['curr_x'], |
|
| 5012 | - HTML2PDF::$_tables[$param['num']]['curr_y'], |
|
| 5013 | - HTML2PDF::$_tables[$param['num']]['width'], |
|
| 5014 | - isset(HTML2PDF::$_tables[$param['num']]['height'][0]) ? HTML2PDF::$_tables[$param['num']]['height'][0] : null, |
|
| 5015 | - $this->parsingCss->value['border'], |
|
| 5016 | - $this->parsingCss->value['padding'], |
|
| 5017 | - 0, |
|
| 5018 | - $this->parsingCss->value['background'] |
|
| 5019 | - ); |
|
| 5020 | - |
|
| 5021 | - HTML2PDF::$_tables[$param['num']]['style_value'] = $this->parsingCss->value; |
|
| 5022 | - } |
|
| 5023 | - |
|
| 5024 | - return true; |
|
| 5025 | - } |
|
| 5026 | - |
|
| 5027 | - /** |
|
| 5028 | - * tag : TABLE |
|
| 5029 | - * mode : CLOSE |
|
| 5030 | - * |
|
| 5031 | - * @param array $param |
|
| 5032 | - * @return boolean |
|
| 5033 | - */ |
|
| 5034 | - protected function _tag_close_TABLE($param) |
|
| 5035 | - { |
|
| 5036 | - if ($this->_isForOneLine) { |
|
| 5037 | - return false; |
|
| 5038 | - } |
|
| 5039 | - |
|
| 5040 | - $this->_maxH = 0; |
|
| 5041 | - |
|
| 5042 | - // if we are in a sub HTML |
|
| 5043 | - if ($this->_subPart) { |
|
| 5044 | - // calculate the size of each case |
|
| 5045 | - $this->_calculateTableCellSize(HTML2PDF::$_tables[$param['num']]['cases'], HTML2PDF::$_tables[$param['num']]['corr']); |
|
| 5046 | - |
|
| 5047 | - // calculate the height of the thead and the tfoot |
|
| 5048 | - $lst = array('thead', 'tfoot'); |
|
| 5049 | - foreach ($lst as $mode) { |
|
| 5050 | - HTML2PDF::$_tables[$param['num']][$mode]['height'] = 0; |
|
| 5051 | - foreach (HTML2PDF::$_tables[$param['num']][$mode]['tr'] as $tr) { |
|
| 5052 | - // hauteur de la ligne tr |
|
| 5053 | - $h = 0; |
|
| 5054 | - for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++) |
|
| 5055 | - if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan'] == 1) |
|
| 5056 | - $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['h']); |
|
| 5057 | - HTML2PDF::$_tables[$param['num']][$mode]['height'] += $h; |
|
| 5058 | - } |
|
| 5059 | - } |
|
| 5060 | - |
|
| 5061 | - // calculate the width of the table |
|
| 5062 | - HTML2PDF::$_tables[$param['num']]['width'] = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r']; |
|
| 5063 | - if (isset(HTML2PDF::$_tables[$param['num']]['cases'][0])) { |
|
| 5064 | - foreach (HTML2PDF::$_tables[$param['num']]['cases'][0] as $case) { |
|
| 5065 | - HTML2PDF::$_tables[$param['num']]['width'] += $case['w']; |
|
| 5066 | - } |
|
| 5067 | - } |
|
| 5068 | - |
|
| 5069 | - // X position of the table |
|
| 5070 | - $old = $this->parsingCss->getOldValues(); |
|
| 5071 | - $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 5072 | - $x = HTML2PDF::$_tables[$param['num']]['curr_x']; |
|
| 5073 | - $w = HTML2PDF::$_tables[$param['num']]['width']; |
|
| 5074 | - if ($parentWidth > $w) { |
|
| 5075 | - if (HTML2PDF::$_tables[$param['num']]['align'] == 'center') |
|
| 5076 | - $x = $x + ($parentWidth - $w) * 0.5; |
|
| 5077 | - else if (HTML2PDF::$_tables[$param['num']]['align'] == 'right') |
|
| 5078 | - $x = $x + $parentWidth - $w; |
|
| 5079 | - |
|
| 5080 | - HTML2PDF::$_tables[$param['num']]['curr_x'] = $x; |
|
| 5081 | - } |
|
| 5082 | - |
|
| 5083 | - // calculate the height of the table |
|
| 5084 | - HTML2PDF::$_tables[$param['num']]['height'] = array(); |
|
| 5085 | - |
|
| 5086 | - // minimum of the height because of margins, and of the thead and tfoot height |
|
| 5087 | - $h0 = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['marge']['b']; |
|
| 5088 | - $h0 += HTML2PDF::$_tables[$param['num']]['thead']['height'] + HTML2PDF::$_tables[$param['num']]['tfoot']['height']; |
|
| 5089 | - |
|
| 5090 | - // max height of the page |
|
| 5091 | - $max = $this->pdf->getH() - $this->pdf->getbMargin(); |
|
| 5092 | - |
|
| 5093 | - // current position on the page |
|
| 5094 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5095 | - $height = $h0; |
|
| 5096 | - |
|
| 5097 | - // we get the height of each line |
|
| 5098 | - for ($k = 0; $k < count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) { |
|
| 5099 | - |
|
| 5100 | - // if it is a TR of the thead or of the tfoot => skip |
|
| 5101 | - if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) { |
|
| 5102 | - continue; |
|
| 5103 | - } |
|
| 5104 | - if (in_array($k, HTML2PDF::$_tables[$param['num']]['tfoot']['tr'])) { |
|
| 5105 | - continue; |
|
| 5106 | - } |
|
| 5107 | - |
|
| 5108 | - // height of the line |
|
| 5109 | - $th = 0; |
|
| 5110 | - $h = 0; |
|
| 5111 | - for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) { |
|
| 5112 | - $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
|
| 5113 | - |
|
| 5114 | - if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan'] == 1) |
|
| 5115 | - $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
|
| 5116 | - } |
|
| 5117 | - |
|
| 5118 | - // if the row does not fit on the page => new page |
|
| 5119 | - if ($y + $h + $height > $max) { |
|
| 5120 | - if ($height == $h0) $height = null; |
|
| 5121 | - HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5122 | - $height = $h0; |
|
| 5123 | - $y = $this->_margeTop; |
|
| 5124 | - } |
|
| 5125 | - $height += $th; |
|
| 5126 | - } |
|
| 5127 | - |
|
| 5128 | - // if ther is a height at the end, add it |
|
| 5129 | - if ($height != $h0 || $k == 0) HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5130 | - } else { |
|
| 5131 | - // if we have tfoor, draw it |
|
| 5132 | - if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) { |
|
| 5133 | - $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 5134 | - $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5135 | - $oldParsePos = $this->_parsePos; |
|
| 5136 | - $oldParseCode = $this->parsingHtml->code; |
|
| 5137 | - |
|
| 5138 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0]; |
|
| 5139 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5140 | - $this->_parsePos = 0; |
|
| 5141 | - $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['tfoot']['code']; |
|
| 5142 | - $this->_isInTfoot = true; |
|
| 5143 | - $this->_makeHTMLcode(); |
|
| 5144 | - $this->_isInTfoot = false; |
|
| 5145 | - |
|
| 5146 | - $this->_parsePos = $oldParsePos; |
|
| 5147 | - $this->parsingHtml->code = $oldParseCode; |
|
| 5148 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
|
| 5149 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
|
| 5150 | - } |
|
| 5151 | - |
|
| 5152 | - // get the positions of the end of the table |
|
| 5153 | - $x = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['width']; |
|
| 5154 | - if (count(HTML2PDF::$_tables[$param['num']]['height']) > 1) |
|
| 5155 | - $y = $this->_margeTop + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1]; |
|
| 5156 | - else if (count(HTML2PDF::$_tables[$param['num']]['height']) == 1) |
|
| 5157 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y'] + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1]; |
|
| 5158 | - else |
|
| 5159 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5160 | - |
|
| 5161 | - $this->_maxX = max($this->_maxX, $x); |
|
| 5162 | - $this->_maxY = max($this->_maxY, $y); |
|
| 5163 | - |
|
| 5164 | - $this->pdf->setXY($this->pdf->getlMargin(), $y); |
|
| 5165 | - |
|
| 5166 | - $this->_loadMargin(); |
|
| 5167 | - |
|
| 5168 | - if ($this->_debugActif) { |
|
| 5169 | - $this->_DEBUG_add('Table '.$param['num'], false); |
|
| 5170 | - } |
|
| 5171 | - } |
|
| 5172 | - |
|
| 5173 | - $this->parsingCss->load(); |
|
| 5174 | - $this->parsingCss->fontSet(); |
|
| 5175 | - |
|
| 5176 | - |
|
| 5177 | - return true; |
|
| 5178 | - } |
|
| 5179 | - |
|
| 5180 | - /** |
|
| 5181 | - * tag : COL |
|
| 5182 | - * mode : OPEN |
|
| 5183 | - * |
|
| 5184 | - * @param array $param |
|
| 5185 | - * @return boolean|null |
|
| 5186 | - */ |
|
| 5187 | - protected function _tag_open_COL($param) |
|
| 5188 | - { |
|
| 5189 | - $span = isset($param['span']) ? $param['span'] : 1; |
|
| 5190 | - for ($k = 0; $k < $span; $k++) |
|
| 5191 | - HTML2PDF::$_tables[$param['num']]['cols'][] = $param; |
|
| 5192 | - } |
|
| 5193 | - |
|
| 5194 | - /** |
|
| 5195 | - * tag : COL |
|
| 5196 | - * mode : CLOSE |
|
| 5197 | - * |
|
| 5198 | - * @param array $param |
|
| 5199 | - * @return boolean |
|
| 5200 | - */ |
|
| 5201 | - protected function _tag_close_COL($param) |
|
| 5202 | - { |
|
| 5203 | - // there is nothing to do here |
|
| 5204 | - |
|
| 5205 | - return true; |
|
| 5206 | - } |
|
| 5207 | - |
|
| 5208 | - /** |
|
| 5209 | - * tag : TR |
|
| 5210 | - * mode : OPEN |
|
| 5211 | - * |
|
| 5212 | - * @param array $param |
|
| 5213 | - * @return boolean |
|
| 5214 | - */ |
|
| 5215 | - protected function _tag_open_TR($param, $other = 'tr') |
|
| 5216 | - { |
|
| 5217 | - if ($this->_isForOneLine) { |
|
| 5218 | - return false; |
|
| 5219 | - } |
|
| 5220 | - |
|
| 5221 | - $this->_maxH = 0; |
|
| 5222 | - |
|
| 5223 | - $this->parsingCss->save(); |
|
| 5224 | - $this->parsingCss->analyse($other, $param); |
|
| 5225 | - $this->parsingCss->setPosition(); |
|
| 5226 | - $this->parsingCss->fontSet(); |
|
| 5227 | - |
|
| 5228 | - // position in the table |
|
| 5229 | - HTML2PDF::$_tables[$param['num']]['tr_curr']++; |
|
| 5230 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5231 | - |
|
| 5232 | - // if we are not in a sub html |
|
| 5233 | - if ( ! $this->_subPart) { |
|
| 5234 | - |
|
| 5235 | - // Y after the row |
|
| 5236 | - $ty = null; |
|
| 5237 | - for ($ii = 0; $ii < count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1]); $ii++) { |
|
| 5238 | - $ty = max($ty, HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['h']); |
|
| 5239 | - } |
|
| 5240 | - |
|
| 5241 | - // height of the tfoot |
|
| 5242 | - $hfoot = HTML2PDF::$_tables[$param['num']]['tfoot']['height']; |
|
| 5243 | - |
|
| 5244 | - // if the line does not fit on the page => new page |
|
| 5245 | - if ( ! $this->_isInTfoot && HTML2PDF::$_tables[$param['num']]['td_y'] + HTML2PDF::$_tables[$param['num']]['marge']['b'] + $ty + $hfoot > $this->pdf->getH() - $this->pdf->getbMargin()) { |
|
| 5246 | - |
|
| 5247 | - // fi ther is a tfoot => draw it |
|
| 5248 | - if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) { |
|
| 5249 | - $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 5250 | - $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5251 | - $oldParsePos = $this->_parsePos; |
|
| 5252 | - $oldParseCode = $this->parsingHtml->code; |
|
| 5253 | - |
|
| 5254 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0]; |
|
| 5255 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5256 | - $this->_parsePos = 0; |
|
| 5257 | - $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['tfoot']['code']; |
|
| 5258 | - $this->_isInTfoot = true; |
|
| 5259 | - $this->_makeHTMLcode(); |
|
| 5260 | - $this->_isInTfoot = false; |
|
| 5261 | - |
|
| 5262 | - $this->_parsePos = $oldParsePos; |
|
| 5263 | - $this->parsingHtml->code = $oldParseCode; |
|
| 5264 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
|
| 5265 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
|
| 5266 | - } |
|
| 5267 | - |
|
| 5268 | - // new page |
|
| 5269 | - HTML2PDF::$_tables[$param['num']]['new_page'] = true; |
|
| 5270 | - $this->_setNewPage(); |
|
| 5271 | - |
|
| 5272 | - // new position |
|
| 5273 | - HTML2PDF::$_tables[$param['num']]['page']++; |
|
| 5274 | - HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY(); |
|
| 5275 | - HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['curr_y'] + HTML2PDF::$_tables[$param['num']]['marge']['t']; |
|
| 5276 | - |
|
| 5277 | - // if we have the height of the tbale on the page => draw borders and background |
|
| 5278 | - if (isset(HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']])) { |
|
| 5279 | - $old = $this->parsingCss->value; |
|
| 5280 | - $this->parsingCss->value = HTML2PDF::$_tables[$param['num']]['style_value']; |
|
| 5281 | - |
|
| 5282 | - $this->_drawRectangle( |
|
| 5283 | - HTML2PDF::$_tables[$param['num']]['curr_x'], |
|
| 5284 | - HTML2PDF::$_tables[$param['num']]['curr_y'], |
|
| 5285 | - HTML2PDF::$_tables[$param['num']]['width'], |
|
| 5286 | - HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']], |
|
| 5287 | - $this->parsingCss->value['border'], |
|
| 5288 | - $this->parsingCss->value['padding'], |
|
| 5289 | - HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5, |
|
| 5290 | - $this->parsingCss->value['background'] |
|
| 5291 | - ); |
|
| 5292 | - |
|
| 5293 | - $this->parsingCss->value = $old; |
|
| 5294 | - } |
|
| 5295 | - } |
|
| 5296 | - |
|
| 5297 | - // if we are in a new page, and if we have a thead => draw it |
|
| 5298 | - if (HTML2PDF::$_tables[$param['num']]['new_page'] && count(HTML2PDF::$_tables[$param['num']]['thead']['code'])) { |
|
| 5299 | - HTML2PDF::$_tables[$param['num']]['new_page'] = false; |
|
| 5300 | - $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 5301 | - $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5302 | - $oldParsePos = $this->_parsePos; |
|
| 5303 | - $oldParseCode = $this->parsingHtml->code; |
|
| 5304 | - |
|
| 5305 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0]; |
|
| 5306 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5307 | - $this->_parsePos = 0; |
|
| 5308 | - $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['thead']['code']; |
|
| 5309 | - $this->_isInThead = true; |
|
| 5310 | - $this->_makeHTMLcode(); |
|
| 5311 | - $this->_isInThead = false; |
|
| 5312 | - |
|
| 5313 | - $this->_parsePos = $oldParsePos; |
|
| 5314 | - $this->parsingHtml->code = $oldParseCode; |
|
| 5315 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
|
| 5316 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
|
| 5317 | - HTML2PDF::$_tables[$param['num']]['new_page'] = true; |
|
| 5318 | - } |
|
| 5319 | - // else (in a sub HTML) |
|
| 5320 | - } else { |
|
| 5321 | - // prepare it |
|
| 5322 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1] = array(); |
|
| 5323 | - if ( ! isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']])) |
|
| 5324 | - HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array(); |
|
| 5325 | - |
|
| 5326 | - HTML2PDF::$_tables[$param['num']]['corr_x'] = 0; |
|
| 5327 | - while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) |
|
| 5328 | - HTML2PDF::$_tables[$param['num']]['corr_x']++; |
|
| 5329 | - } |
|
| 5330 | - |
|
| 5331 | - return true; |
|
| 5332 | - } |
|
| 5333 | - |
|
| 5334 | - /** |
|
| 5335 | - * tag : TR |
|
| 5336 | - * mode : CLOSE |
|
| 5337 | - * |
|
| 5338 | - * @param array $param |
|
| 5339 | - * @return boolean |
|
| 5340 | - */ |
|
| 5341 | - protected function _tag_close_TR($param) |
|
| 5342 | - { |
|
| 5343 | - if ($this->_isForOneLine) { |
|
| 5344 | - return false; |
|
| 5345 | - } |
|
| 5346 | - |
|
| 5347 | - $this->_maxH = 0; |
|
| 5348 | - |
|
| 5349 | - $this->parsingCss->load(); |
|
| 5350 | - $this->parsingCss->fontSet(); |
|
| 5351 | - |
|
| 5352 | - // if we are not in a sub HTML |
|
| 5353 | - if ( ! $this->_subPart) { |
|
| 5354 | - |
|
| 5355 | - // Y of the current line |
|
| 5356 | - $ty = null; |
|
| 5357 | - for ($ii = 0; $ii < count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1]); $ii++) { |
|
| 5358 | - if (HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['rowspan'] == 1) { |
|
| 5359 | - $ty = HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['h']; |
|
| 5360 | - } |
|
| 5361 | - } |
|
| 5362 | - |
|
| 5363 | - // new position |
|
| 5364 | - HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['marge']['l']; |
|
| 5365 | - HTML2PDF::$_tables[$param['num']]['td_y'] += $ty; |
|
| 5366 | - HTML2PDF::$_tables[$param['num']]['new_page'] = false; |
|
| 5367 | - } else { |
|
| 5368 | - HTML2PDF::$_tables[$param['num']]['corr_y']++; |
|
| 5369 | - } |
|
| 5370 | - |
|
| 5371 | - return true; |
|
| 5372 | - } |
|
| 5373 | - |
|
| 5374 | - /** |
|
| 5375 | - * tag : TD |
|
| 5376 | - * mode : OPEN |
|
| 5377 | - * |
|
| 5378 | - * @param array $param |
|
| 5379 | - * @return boolean |
|
| 5380 | - */ |
|
| 5381 | - protected function _tag_open_TD($param, $other = 'td') |
|
| 5382 | - { |
|
| 5383 | - if ($this->_isForOneLine) { |
|
| 5384 | - return false; |
|
| 5385 | - } |
|
| 5386 | - |
|
| 5387 | - $this->_maxH = 0; |
|
| 5388 | - |
|
| 5389 | - $param['cellpadding'] = HTML2PDF::$_tables[$param['num']]['cellpadding'].'mm'; |
|
| 5390 | - $param['cellspacing'] = HTML2PDF::$_tables[$param['num']]['cellspacing'].'mm'; |
|
| 5391 | - |
|
| 5392 | - // specific style for LI |
|
| 5393 | - if ($other == 'li') { |
|
| 5394 | - $specialLi = true; |
|
| 5395 | - } else { |
|
| 5396 | - $specialLi = false; |
|
| 5397 | - if ($other == 'li_sub') { |
|
| 5398 | - $param['style']['border'] = 'none'; |
|
| 5399 | - $param['style']['background-color'] = 'transparent'; |
|
| 5400 | - $param['style']['background-image'] = 'none'; |
|
| 5401 | - $param['style']['background-position'] = ''; |
|
| 5402 | - $param['style']['background-repeat'] = ''; |
|
| 5403 | - $other = 'li'; |
|
| 5404 | - } |
|
| 5405 | - } |
|
| 5406 | - |
|
| 5407 | - // get the properties of the TD |
|
| 5408 | - $x = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5409 | - $y = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1; |
|
| 5410 | - $colspan = isset($param['colspan']) ? $param['colspan'] : 1; |
|
| 5411 | - $rowspan = isset($param['rowspan']) ? $param['rowspan'] : 1; |
|
| 5412 | - |
|
| 5413 | - // flag for collapse table |
|
| 5414 | - $collapse = false; |
|
| 5415 | - |
|
| 5416 | - // specific traitment for TD and TH |
|
| 5417 | - if (in_array($other, array('td', 'th'))) { |
|
| 5418 | - // id of the column |
|
| 5419 | - $numCol = isset(HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr']) ? HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr'] : HTML2PDF::$_tables[$param['num']]['corr_x']; |
|
| 5420 | - |
|
| 5421 | - // we get the properties of the COL tag, if exist |
|
| 5422 | - if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol])) { |
|
| 5423 | - |
|
| 5424 | - $colParam = HTML2PDF::$_tables[$param['num']]['cols'][$numCol]; |
|
| 5425 | - |
|
| 5426 | - // for colspans => we get all the neede widths |
|
| 5427 | - $colParam['style']['width'] = array(); |
|
| 5428 | - for ($k = 0; $k < $colspan; $k++) { |
|
| 5429 | - if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol + $k]['style']['width'])) { |
|
| 5430 | - $colParam['style']['width'][] = HTML2PDF::$_tables[$param['num']]['cols'][$numCol + $k]['style']['width']; |
|
| 5431 | - } |
|
| 5432 | - } |
|
| 5433 | - |
|
| 5434 | - // calculate the total width of the column |
|
| 5435 | - $total = ''; |
|
| 5436 | - $last = $this->parsingCss->getLastWidth(); |
|
| 5437 | - if (count($colParam['style']['width'])) { |
|
| 5438 | - $total = $colParam['style']['width'][0]; unset($colParam['style']['width'][0]); |
|
| 5439 | - foreach ($colParam['style']['width'] as $width) { |
|
| 5440 | - if (substr($total, -1) == '%' && substr($width, -1) == '%') |
|
| 5441 | - $total = (str_replace('%', '', $total) + str_replace('%', '', $width)).'%'; |
|
| 5442 | - else |
|
| 5443 | - $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm'; |
|
| 5444 | - } |
|
| 5445 | - } |
|
| 5446 | - |
|
| 5447 | - // get the final width |
|
| 5448 | - if ($total) { |
|
| 5449 | - $colParam['style']['width'] = $total; |
|
| 5450 | - } else { |
|
| 5451 | - unset($colParam['style']['width']); |
|
| 5452 | - } |
|
| 5453 | - |
|
| 5454 | - |
|
| 5455 | - // merge the styles of the COL and the TD |
|
| 5456 | - $param['style'] = array_merge($colParam['style'], $param['style']); |
|
| 5457 | - |
|
| 5458 | - // merge the class of the COL and the TD |
|
| 5459 | - if (isset($colParam['class'])) { |
|
| 5460 | - $param['class'] = $colParam['class'].(isset($param['class']) ? ' '.$param['class'] : ''); |
|
| 5461 | - } |
|
| 5462 | - } |
|
| 5463 | - |
|
| 5464 | - $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false; |
|
| 5465 | - } |
|
| 5466 | - |
|
| 5467 | - $this->parsingCss->save(); |
|
| 5468 | - |
|
| 5469 | - // legacy for TD and TH |
|
| 5470 | - $legacy = null; |
|
| 5471 | - if (in_array($other, array('td', 'th'))) { |
|
| 5472 | - $legacy = array(); |
|
| 5473 | - |
|
| 5474 | - $old = $this->parsingCss->getLastValue('background'); |
|
| 5475 | - if ($old && ($old['color'] || $old['image'])) { |
|
| 5476 | - $legacy['background'] = $old; |
|
| 5477 | - } |
|
| 5478 | - |
|
| 5479 | - if (HTML2PDF::$_tables[$param['num']]['border']) { |
|
| 5480 | - $legacy['border'] = array(); |
|
| 5481 | - $legacy['border']['l'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5482 | - $legacy['border']['t'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5483 | - $legacy['border']['r'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5484 | - $legacy['border']['b'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5485 | - } |
|
| 5486 | - } |
|
| 5487 | - $return = $this->parsingCss->analyse($other, $param, $legacy); |
|
| 5488 | - |
|
| 5489 | - if ($specialLi) { |
|
| 5490 | - $this->parsingCss->value['width'] -= $this->parsingCss->ConvertToMM($this->_listeGetWidth()); |
|
| 5491 | - $this->parsingCss->value['width'] -= $this->parsingCss->ConvertToMM($this->_listeGetPadding()); |
|
| 5492 | - } |
|
| 5493 | - $this->parsingCss->setPosition(); |
|
| 5494 | - $this->parsingCss->fontSet(); |
|
| 5495 | - |
|
| 5496 | - // if tale collapse => modify the borders |
|
| 5497 | - if ($collapse) { |
|
| 5498 | - if ( ! $this->_subPart) { |
|
| 5499 | - if ( |
|
| 5500 | - (HTML2PDF::$_tables[$param['num']]['tr_curr'] > 1 && ! HTML2PDF::$_tables[$param['num']]['new_page']) || |
|
| 5501 | - ( ! $this->_isInThead && count(HTML2PDF::$_tables[$param['num']]['thead']['code'])) |
|
| 5502 | - ) { |
|
| 5503 | - $this->parsingCss->value['border']['t'] = $this->parsingCss->readBorder('none'); |
|
| 5504 | - } |
|
| 5505 | - } |
|
| 5506 | - |
|
| 5507 | - if (HTML2PDF::$_tables[$param['num']]['td_curr'] > 0) { |
|
| 5508 | - if ( ! $return) $this->parsingCss->value['width'] += $this->parsingCss->value['border']['l']['width']; |
|
| 5509 | - $this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none'); |
|
| 5510 | - } |
|
| 5511 | - } |
|
| 5512 | - |
|
| 5513 | - // margins of the table |
|
| 5514 | - $marge = array(); |
|
| 5515 | - $marge['t'] = $this->parsingCss->value['padding']['t'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['t']['width']; |
|
| 5516 | - $marge['r'] = $this->parsingCss->value['padding']['r'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['r']['width']; |
|
| 5517 | - $marge['b'] = $this->parsingCss->value['padding']['b'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['b']['width']; |
|
| 5518 | - $marge['l'] = $this->parsingCss->value['padding']['l'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['l']['width']; |
|
| 5519 | - |
|
| 5520 | - // if we are in a sub HTML |
|
| 5521 | - if ($this->_subPart) { |
|
| 5522 | - // new position in the table |
|
| 5523 | - HTML2PDF::$_tables[$param['num']]['td_curr']++; |
|
| 5524 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x] = array(); |
|
| 5525 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] = 0; |
|
| 5526 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'] = 0; |
|
| 5527 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw'] = 0; |
|
| 5528 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['colspan'] = $colspan; |
|
| 5529 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['rowspan'] = $rowspan; |
|
| 5530 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr'] = HTML2PDF::$_tables[$param['num']]['corr_x']; |
|
| 5531 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Yr'] = HTML2PDF::$_tables[$param['num']]['corr_y']; |
|
| 5532 | - |
|
| 5533 | - // prepare the mapping for rowspan and colspan |
|
| 5534 | - for ($j = 0; $j < $rowspan; $j++) { |
|
| 5535 | - for ($i = 0; $i < $colspan; $i++) { |
|
| 5536 | - HTML2PDF::$_tables[$param['num']]['corr'] |
|
| 5537 | - [HTML2PDF::$_tables[$param['num']]['corr_y'] + $j] |
|
| 5538 | - [HTML2PDF::$_tables[$param['num']]['corr_x'] + $i] = ($i + $j > 0) ? '' : array($x, $y, $colspan, $rowspan); |
|
| 5539 | - } |
|
| 5540 | - } |
|
| 5541 | - HTML2PDF::$_tables[$param['num']]['corr_x'] += $colspan; |
|
| 5542 | - while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) { |
|
| 5543 | - HTML2PDF::$_tables[$param['num']]['corr_x']++; |
|
| 5544 | - } |
|
| 5545 | - |
|
| 5546 | - // extract the content of the TD, and calculate his size |
|
| 5547 | - $level = $this->parsingHtml->getLevel($this->_tempPos); |
|
| 5548 | - $this->_createSubHTML($this->_subHtml); |
|
| 5549 | - $this->_subHtml->parsingHtml->code = $level; |
|
| 5550 | - $this->_subHtml->_makeHTMLcode(); |
|
| 5551 | - $this->_tempPos += count($level); |
|
| 5552 | - } else { |
|
| 5553 | - // new position in the table |
|
| 5554 | - HTML2PDF::$_tables[$param['num']]['td_curr']++; |
|
| 5555 | - HTML2PDF::$_tables[$param['num']]['td_x'] += HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw']; |
|
| 5556 | - |
|
| 5557 | - // borders and background of the TD |
|
| 5558 | - $this->_drawRectangle( |
|
| 5559 | - HTML2PDF::$_tables[$param['num']]['td_x'], |
|
| 5560 | - HTML2PDF::$_tables[$param['num']]['td_y'], |
|
| 5561 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'], |
|
| 5562 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'], |
|
| 5563 | - $this->parsingCss->value['border'], |
|
| 5564 | - $this->parsingCss->value['padding'], |
|
| 5565 | - HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5, |
|
| 5566 | - $this->parsingCss->value['background'] |
|
| 5567 | - ); |
|
| 5568 | - |
|
| 5569 | - $this->parsingCss->value['width'] = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] - $marge['l'] - $marge['r']; |
|
| 5570 | - |
|
| 5571 | - // marges = size of the TD |
|
| 5572 | - $mL = HTML2PDF::$_tables[$param['num']]['td_x'] + $marge['l']; |
|
| 5573 | - $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width']; |
|
| 5574 | - $this->_saveMargin($mL, 0, $mR); |
|
| 5575 | - |
|
| 5576 | - // position of the content, from vertical-align |
|
| 5577 | - $hCorr = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h']; |
|
| 5578 | - $hReel = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['real_h']; |
|
| 5579 | - switch ($this->parsingCss->value['vertical-align']) |
|
| 5580 | - { |
|
| 5581 | - case 'bottom': |
|
| 5582 | - $yCorr = $hCorr - $hReel; |
|
| 5583 | - break; |
|
| 5584 | - |
|
| 5585 | - case 'middle': |
|
| 5586 | - $yCorr = ($hCorr - $hReel) * 0.5; |
|
| 5587 | - break; |
|
| 5588 | - |
|
| 5589 | - case 'top': |
|
| 5590 | - default: |
|
| 5591 | - $yCorr = 0; |
|
| 5592 | - break; |
|
| 5593 | - } |
|
| 5594 | - |
|
| 5595 | - // position of the content |
|
| 5596 | - $x = HTML2PDF::$_tables[$param['num']]['td_x'] + $marge['l']; |
|
| 5597 | - $y = HTML2PDF::$_tables[$param['num']]['td_y'] + $marge['t'] + $yCorr; |
|
| 5598 | - $this->pdf->setXY($x, $y); |
|
| 5599 | - $this->_setNewPositionForNewLine(); |
|
| 5600 | - } |
|
| 5601 | - |
|
| 5602 | - return true; |
|
| 5603 | - } |
|
| 5604 | - |
|
| 5605 | - /** |
|
| 5606 | - * tag : TD |
|
| 5607 | - * mode : CLOSE |
|
| 5608 | - * |
|
| 5609 | - * @param array $param |
|
| 5610 | - * @return boolean |
|
| 5611 | - */ |
|
| 5612 | - protected function _tag_close_TD($param) |
|
| 5613 | - { |
|
| 5614 | - if ($this->_isForOneLine) { |
|
| 5615 | - return false; |
|
| 5616 | - } |
|
| 5617 | - |
|
| 5618 | - $this->_maxH = 0; |
|
| 5619 | - |
|
| 5620 | - // get the margins |
|
| 5621 | - $marge = array(); |
|
| 5622 | - $marge['t'] = $this->parsingCss->value['padding']['t'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['t']['width']; |
|
| 5623 | - $marge['r'] = $this->parsingCss->value['padding']['r'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['r']['width']; |
|
| 5624 | - $marge['b'] = $this->parsingCss->value['padding']['b'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['b']['width']; |
|
| 5625 | - $marge['l'] = $this->parsingCss->value['padding']['l'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['l']['width']; |
|
| 5626 | - $marge['t'] += 0.001; |
|
| 5627 | - $marge['r'] += 0.001; |
|
| 5628 | - $marge['b'] += 0.001; |
|
| 5629 | - $marge['l'] += 0.001; |
|
| 5630 | - |
|
| 5631 | - // if we are in a sub HTML |
|
| 5632 | - if ($this->_subPart) { |
|
| 5633 | - |
|
| 5634 | - // it msut take only one page |
|
| 5635 | - if ($this->_testTdInOnepage && $this->_subHtml->pdf->getPage() > 1) { |
|
| 5636 | - throw new HTML2PDF_exception(7); |
|
| 5637 | - } |
|
| 5638 | - |
|
| 5639 | - // size of the content of the TD |
|
| 5640 | - $w0 = $this->_subHtml->_maxX + $marge['l'] + $marge['r']; |
|
| 5641 | - $h0 = $this->_subHtml->_maxY + $marge['t'] + $marge['b']; |
|
| 5642 | - |
|
| 5643 | - // size from the CSS style |
|
| 5644 | - $w2 = $this->parsingCss->value['width'] + $marge['l'] + $marge['r']; |
|
| 5645 | - $h2 = $this->parsingCss->value['height'] + $marge['t'] + $marge['b']; |
|
| 5646 | - |
|
| 5647 | - // final size of the TD |
|
| 5648 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['w'] = max(array($w0, $w2)); |
|
| 5649 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['h'] = max(array($h0, $h2)); |
|
| 5650 | - |
|
| 5651 | - // real position of the content |
|
| 5652 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['real_w'] = $w0; |
|
| 5653 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['real_h'] = $h0; |
|
| 5654 | - |
|
| 5655 | - // destroy the sub HTML |
|
| 5656 | - $this->_destroySubHTML($this->_subHtml); |
|
| 5657 | - } else { |
|
| 5658 | - $this->_loadMargin(); |
|
| 5659 | - |
|
| 5660 | - HTML2PDF::$_tables[$param['num']]['td_x'] += HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['w']; |
|
| 5661 | - } |
|
| 5662 | - |
|
| 5663 | - $this->parsingCss->load(); |
|
| 5664 | - $this->parsingCss->fontSet(); |
|
| 5665 | - |
|
| 5666 | - return true; |
|
| 5667 | - } |
|
| 5668 | - |
|
| 5669 | - |
|
| 5670 | - /** |
|
| 5671 | - * tag : TH |
|
| 5672 | - * mode : OPEN |
|
| 5673 | - * |
|
| 5674 | - * @param array $param |
|
| 5675 | - * @return boolean |
|
| 5676 | - */ |
|
| 5677 | - protected function _tag_open_TH($param) |
|
| 5678 | - { |
|
| 5679 | - if ($this->_isForOneLine) { |
|
| 5680 | - return false; |
|
| 5681 | - } |
|
| 5682 | - |
|
| 5683 | - $this->parsingCss->save(); |
|
| 5684 | - $this->parsingCss->value['font-bold'] = true; |
|
| 5685 | - |
|
| 5686 | - $this->_tag_open_TD($param, 'th'); |
|
| 5687 | - |
|
| 5688 | - return true; |
|
| 5689 | - } |
|
| 5690 | - |
|
| 5691 | - /** |
|
| 5692 | - * tag : TH |
|
| 5693 | - * mode : CLOSE |
|
| 5694 | - * |
|
| 5695 | - * @param array $param |
|
| 5696 | - * @return boolean |
|
| 5697 | - */ |
|
| 5698 | - protected function _tag_close_TH($param) |
|
| 5699 | - { |
|
| 5700 | - if ($this->_isForOneLine) { |
|
| 5701 | - return false; |
|
| 5702 | - } |
|
| 5703 | - |
|
| 5704 | - $this->_tag_close_TD($param); |
|
| 5705 | - |
|
| 5706 | - $this->parsingCss->load(); |
|
| 5707 | - |
|
| 5708 | - return true; |
|
| 5709 | - } |
|
| 5710 | - |
|
| 5711 | - /** |
|
| 5712 | - * tag : IMG |
|
| 5713 | - * mode : OPEN |
|
| 5714 | - * |
|
| 5715 | - * @param array $param |
|
| 5716 | - * @return boolean |
|
| 5717 | - */ |
|
| 5718 | - protected function _tag_open_IMG($param) |
|
| 5719 | - { |
|
| 5720 | - $src = str_replace('&', '&', $param['src']); |
|
| 5721 | - |
|
| 5722 | - $this->parsingCss->save(); |
|
| 5723 | - $this->parsingCss->value['width'] = 0; |
|
| 5724 | - $this->parsingCss->value['height'] = 0; |
|
| 5725 | - $this->parsingCss->value['border'] = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0)); |
|
| 5726 | - $this->parsingCss->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null); |
|
| 5727 | - $this->parsingCss->analyse('img', $param); |
|
| 5728 | - $this->parsingCss->setPosition(); |
|
| 5729 | - $this->parsingCss->fontSet(); |
|
| 5730 | - |
|
| 5731 | - $res = $this->_drawImage($src, isset($param['sub_li'])); |
|
| 5732 | - if ( ! $res) return $res; |
|
| 5733 | - |
|
| 5734 | - $this->parsingCss->load(); |
|
| 5735 | - $this->parsingCss->fontSet(); |
|
| 5736 | - $this->_maxE++; |
|
| 5737 | - |
|
| 5738 | - return true; |
|
| 5739 | - } |
|
| 5740 | - |
|
| 5741 | - /** |
|
| 5742 | - * tag : SELECT |
|
| 5743 | - * mode : OPEN |
|
| 5744 | - * |
|
| 5745 | - * @param array $param |
|
| 5746 | - * @return boolean |
|
| 5747 | - */ |
|
| 5748 | - protected function _tag_open_SELECT($param) |
|
| 5749 | - { |
|
| 5750 | - if ( ! isset($param['name'])) { |
|
| 5751 | - $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 5752 | - } |
|
| 5753 | - |
|
| 5754 | - $param['name'] = strtolower($param['name']); |
|
| 5755 | - |
|
| 5756 | - if (isset($this->_lstField[$param['name']])) { |
|
| 5757 | - $this->_lstField[$param['name']]++; |
|
| 5758 | - } else { |
|
| 5759 | - $this->_lstField[$param['name']] = 1; |
|
| 5760 | - } |
|
| 5761 | - |
|
| 5762 | - $this->parsingCss->save(); |
|
| 5763 | - $this->parsingCss->analyse('select', $param); |
|
| 5764 | - $this->parsingCss->setPosition(); |
|
| 5765 | - $this->parsingCss->fontSet(); |
|
| 5766 | - |
|
| 5767 | - $this->_lstSelect = array(); |
|
| 5768 | - $this->_lstSelect['name'] = $param['name']; |
|
| 5769 | - $this->_lstSelect['multi'] = isset($param['multiple']) ? true : false; |
|
| 5770 | - $this->_lstSelect['size'] = isset($param['size']) ? $param['size'] : 1; |
|
| 5771 | - $this->_lstSelect['options'] = array(); |
|
| 5772 | - |
|
| 5773 | - if ($this->_lstSelect['multi'] && $this->_lstSelect['size'] < 3) $this->_lstSelect['size'] = 3; |
|
| 5774 | - |
|
| 5775 | - return true; |
|
| 5776 | - } |
|
| 5777 | - |
|
| 5778 | - /** |
|
| 5779 | - * tag : OPTION |
|
| 5780 | - * mode : OPEN |
|
| 5781 | - * |
|
| 5782 | - * @param array $param |
|
| 5783 | - * @return boolean |
|
| 5784 | - */ |
|
| 5785 | - protected function _tag_open_OPTION($param) |
|
| 5786 | - { |
|
| 5787 | - // get the content of the option : it is the text of the option |
|
| 5788 | - $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 5789 | - $this->_parsePos += count($level); |
|
| 5790 | - $value = isset($param['value']) ? $param['value'] : 'aut_tag_open_opt_'.(count($this->_lstSelect) + 1); |
|
| 5791 | - |
|
| 5792 | - $this->_lstSelect['options'][$value] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : ''; |
|
| 5793 | - |
|
| 5794 | - return true; |
|
| 5795 | - } |
|
| 5796 | - |
|
| 5797 | - /** |
|
| 5798 | - * tag : OPTION |
|
| 5799 | - * mode : CLOSE |
|
| 5800 | - * |
|
| 5801 | - * @param array $param |
|
| 5802 | - * @return boolean |
|
| 5803 | - */ |
|
| 5804 | - protected function _tag_close_OPTION($param) |
|
| 5805 | - { |
|
| 5806 | - // nothing to do here |
|
| 5807 | - |
|
| 5808 | - return true; |
|
| 5809 | - } |
|
| 5810 | - |
|
| 5811 | - /** |
|
| 5812 | - * tag : SELECT |
|
| 5813 | - * mode : CLOSE |
|
| 5814 | - * |
|
| 5815 | - * @return boolean |
|
| 5816 | - */ |
|
| 5817 | - protected function _tag_close_SELECT() |
|
| 5818 | - { |
|
| 5819 | - // position of the select |
|
| 5820 | - $x = $this->pdf->getX(); |
|
| 5821 | - $y = $this->pdf->getY(); |
|
| 5822 | - $f = 1.08 * $this->parsingCss->value['font-size']; |
|
| 5823 | - |
|
| 5824 | - // width |
|
| 5825 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = 50; |
|
| 5826 | - |
|
| 5827 | - // height (automatic) |
|
| 5828 | - $h = ($f * 1.07 * $this->_lstSelect['size'] + 1); |
|
| 5829 | - |
|
| 5830 | - $prop = $this->parsingCss->getFormStyle(); |
|
| 5831 | - |
|
| 5832 | - // multy select |
|
| 5833 | - if ($this->_lstSelect['multi']) { |
|
| 5834 | - $prop['multipleSelection'] = 'true'; |
|
| 5835 | - } |
|
| 5836 | - |
|
| 5837 | - |
|
| 5838 | - // single or multi select |
|
| 5839 | - if ($this->_lstSelect['size'] > 1) { |
|
| 5840 | - $this->pdf->ListBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop); |
|
| 5841 | - } else { |
|
| 5842 | - $this->pdf->ComboBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop); |
|
| 5843 | - } |
|
| 5844 | - |
|
| 5845 | - $this->_maxX = max($this->_maxX, $x + $w); |
|
| 5846 | - $this->_maxY = max($this->_maxY, $y + $h); |
|
| 5847 | - $this->_maxH = max($this->_maxH, $h); |
|
| 5848 | - $this->_maxE++; |
|
| 5849 | - $this->pdf->setX($x + $w); |
|
| 5850 | - |
|
| 5851 | - $this->parsingCss->load(); |
|
| 5852 | - $this->parsingCss->fontSet(); |
|
| 5853 | - |
|
| 5854 | - $this->_lstSelect = array(); |
|
| 5855 | - |
|
| 5856 | - return true; |
|
| 5857 | - } |
|
| 5858 | - |
|
| 5859 | - /** |
|
| 5860 | - * tag : TEXTAREA |
|
| 5861 | - * mode : OPEN |
|
| 5862 | - * |
|
| 5863 | - * @param array $param |
|
| 5864 | - * @return boolean |
|
| 5865 | - */ |
|
| 5866 | - protected function _tag_open_TEXTAREA($param) |
|
| 5867 | - { |
|
| 5868 | - if ( ! isset($param['name'])) { |
|
| 5869 | - $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 5870 | - } |
|
| 5871 | - |
|
| 5872 | - $param['name'] = strtolower($param['name']); |
|
| 5873 | - |
|
| 5874 | - if (isset($this->_lstField[$param['name']])) { |
|
| 5875 | - $this->_lstField[$param['name']]++; |
|
| 5876 | - } else { |
|
| 5877 | - $this->_lstField[$param['name']] = 1; |
|
| 5878 | - } |
|
| 5879 | - |
|
| 5880 | - $this->parsingCss->save(); |
|
| 5881 | - $this->parsingCss->analyse('textarea', $param); |
|
| 5882 | - $this->parsingCss->setPosition(); |
|
| 5883 | - $this->parsingCss->fontSet(); |
|
| 5884 | - |
|
| 5885 | - $x = $this->pdf->getX(); |
|
| 5886 | - $y = $this->pdf->getY(); |
|
| 5887 | - $fx = 0.65 * $this->parsingCss->value['font-size']; |
|
| 5888 | - $fy = 1.08 * $this->parsingCss->value['font-size']; |
|
| 5889 | - |
|
| 5890 | - // extract the content the textarea : value |
|
| 5891 | - $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 5892 | - $this->_parsePos += count($level); |
|
| 5893 | - |
|
| 5894 | - // automatic size, from cols and rows properties |
|
| 5895 | - $w = $fx * (isset($param['cols']) ? $param['cols'] : 22) + 1; |
|
| 5896 | - $h = $fy * 1.07 * (isset($param['rows']) ? $param['rows'] : 3) + 3; |
|
| 5897 | - |
|
| 5898 | - $prop = $this->parsingCss->getFormStyle(); |
|
| 5899 | - |
|
| 5900 | - $prop['multiline'] = true; |
|
| 5901 | - $prop['value'] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : ''; |
|
| 5902 | - |
|
| 5903 | - $this->pdf->TextField($param['name'], $w, $h, $prop, array(), $x, $y); |
|
| 5904 | - |
|
| 5905 | - $this->_maxX = max($this->_maxX, $x + $w); |
|
| 5906 | - $this->_maxY = max($this->_maxY, $y + $h); |
|
| 5907 | - $this->_maxH = max($this->_maxH, $h); |
|
| 5908 | - $this->_maxE++; |
|
| 5909 | - $this->pdf->setX($x + $w); |
|
| 5910 | - |
|
| 5911 | - return true; |
|
| 5912 | - } |
|
| 5913 | - |
|
| 5914 | - /** |
|
| 5915 | - * tag : TEXTAREA |
|
| 5916 | - * mode : CLOSE |
|
| 5917 | - * |
|
| 5918 | - * @return boolean |
|
| 5919 | - */ |
|
| 5920 | - protected function _tag_close_TEXTAREA() |
|
| 5921 | - { |
|
| 5922 | - $this->parsingCss->load(); |
|
| 5923 | - $this->parsingCss->fontSet(); |
|
| 5924 | - |
|
| 5925 | - return true; |
|
| 5926 | - } |
|
| 5927 | - |
|
| 5928 | - /** |
|
| 5929 | - * tag : INPUT |
|
| 5930 | - * mode : OPEN |
|
| 5931 | - * |
|
| 5932 | - * @param array $param |
|
| 5933 | - * @return boolean |
|
| 5934 | - */ |
|
| 5935 | - protected function _tag_open_INPUT($param) |
|
| 5936 | - { |
|
| 5937 | - if ( ! isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 5938 | - if ( ! isset($param['value'])) $param['value'] = ''; |
|
| 5939 | - if ( ! isset($param['type'])) $param['type'] = 'text'; |
|
| 5940 | - |
|
| 5941 | - $param['name'] = strtolower($param['name']); |
|
| 5942 | - $param['type'] = strtolower($param['type']); |
|
| 5943 | - |
|
| 5944 | - // the type must be valid |
|
| 5945 | - if ( ! in_array($param['type'], array('text', 'checkbox', 'radio', 'hidden', 'submit', 'reset', 'button'))) { |
|
| 5946 | - $param['type'] = 'text'; |
|
| 5947 | - } |
|
| 5948 | - |
|
| 5949 | - if (isset($this->_lstField[$param['name']])) { |
|
| 5950 | - $this->_lstField[$param['name']]++; |
|
| 5951 | - } else { |
|
| 5952 | - $this->_lstField[$param['name']] = 1; |
|
| 5953 | - } |
|
| 5954 | - |
|
| 5955 | - $this->parsingCss->save(); |
|
| 5956 | - $this->parsingCss->analyse('input', $param); |
|
| 5957 | - $this->parsingCss->setPosition(); |
|
| 5958 | - $this->parsingCss->fontSet(); |
|
| 5959 | - |
|
| 5960 | - $name = $param['name']; |
|
| 5961 | - |
|
| 5962 | - $x = $this->pdf->getX(); |
|
| 5963 | - $y = $this->pdf->getY(); |
|
| 5964 | - $f = 1.08 * $this->parsingCss->value['font-size']; |
|
| 5965 | - |
|
| 5966 | - $prop = $this->parsingCss->getFormStyle(); |
|
| 5967 | - |
|
| 5968 | - switch ($param['type']) |
|
| 5969 | - { |
|
| 5970 | - case 'checkbox': |
|
| 5971 | - $w = 3; |
|
| 5972 | - $h = $w; |
|
| 5973 | - if ($h < $f) $y += ($f - $h) * 0.5; |
|
| 5974 | - $checked = (isset($param['checked']) && $param['checked'] == 'checked'); |
|
| 5975 | - $this->pdf->CheckBox($name, $w, $checked, $prop, array(), ($param['value'] ? $param['value'] : 'Yes'), $x, $y); |
|
| 5976 | - break; |
|
| 5977 | - |
|
| 5978 | - case 'radio': |
|
| 5979 | - $w = 3; |
|
| 5980 | - $h = $w; |
|
| 5981 | - if ($h < $f) $y += ($f - $h) * 0.5; |
|
| 5982 | - $checked = (isset($param['checked']) && $param['checked'] == 'checked'); |
|
| 5983 | - $this->pdf->RadioButton($name, $w, $prop, array(), ($param['value'] ? $param['value'] : 'On'), $checked, $x, $y); |
|
| 5984 | - break; |
|
| 5985 | - |
|
| 5986 | - case 'hidden': |
|
| 5987 | - $w = 0; |
|
| 5988 | - $h = 0; |
|
| 5989 | - $prop['value'] = $param['value']; |
|
| 5990 | - $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y); |
|
| 5991 | - break; |
|
| 5992 | - |
|
| 5993 | - case 'text': |
|
| 5994 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 5995 | - $h = $f * 1.3; |
|
| 5996 | - $prop['value'] = $param['value']; |
|
| 5997 | - $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y); |
|
| 5998 | - break; |
|
| 5999 | - |
|
| 6000 | - case 'submit': |
|
| 6001 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 6002 | - $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 6003 | - $action = array('S'=>'SubmitForm', 'F'=>$this->_isInForm, 'Flags'=>array('ExportFormat')); |
|
| 6004 | - $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
|
| 6005 | - break; |
|
| 6006 | - |
|
| 6007 | - case 'reset': |
|
| 6008 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 6009 | - $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 6010 | - $action = array('S'=>'ResetForm'); |
|
| 6011 | - $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
|
| 6012 | - break; |
|
| 6013 | - |
|
| 6014 | - case 'button': |
|
| 6015 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 6016 | - $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 6017 | - $action = isset($param['onclick']) ? $param['onclick'] : ''; |
|
| 6018 | - $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
|
| 6019 | - break; |
|
| 6020 | - |
|
| 6021 | - default: |
|
| 6022 | - $w = 0; |
|
| 6023 | - $h = 0; |
|
| 6024 | - break; |
|
| 6025 | - } |
|
| 6026 | - |
|
| 6027 | - $this->_maxX = max($this->_maxX, $x + $w); |
|
| 6028 | - $this->_maxY = max($this->_maxY, $y + $h); |
|
| 6029 | - $this->_maxH = max($this->_maxH, $h); |
|
| 6030 | - $this->_maxE++; |
|
| 6031 | - $this->pdf->setX($x + $w); |
|
| 6032 | - |
|
| 6033 | - $this->parsingCss->load(); |
|
| 6034 | - $this->parsingCss->fontSet(); |
|
| 6035 | - |
|
| 6036 | - return true; |
|
| 6037 | - } |
|
| 6038 | - |
|
| 6039 | - /** |
|
| 6040 | - * tag : DRAW |
|
| 6041 | - * mode : OPEN |
|
| 6042 | - * |
|
| 6043 | - * @param array $param |
|
| 6044 | - * @return boolean |
|
| 6045 | - */ |
|
| 6046 | - protected function _tag_open_DRAW($param) |
|
| 6047 | - { |
|
| 6048 | - if ($this->_isForOneLine) { |
|
| 6049 | - return false; |
|
| 6050 | - } |
|
| 6051 | - if ($this->_debugActif) { |
|
| 6052 | - $this->_DEBUG_add('DRAW', true); |
|
| 6053 | - } |
|
| 6054 | - |
|
| 6055 | - $this->parsingCss->save(); |
|
| 6056 | - $this->parsingCss->analyse('draw', $param); |
|
| 6057 | - $this->parsingCss->fontSet(); |
|
| 6058 | - |
|
| 6059 | - $alignObject = null; |
|
| 6060 | - if ($this->parsingCss->value['margin-auto']) { |
|
| 6061 | - $alignObject = 'center'; |
|
| 6062 | - } |
|
| 6063 | - |
|
| 6064 | - $overW = $this->parsingCss->value['width']; |
|
| 6065 | - $overH = $this->parsingCss->value['height']; |
|
| 6066 | - $this->parsingCss->value['old_maxX'] = $this->_maxX; |
|
| 6067 | - $this->parsingCss->value['old_maxY'] = $this->_maxY; |
|
| 6068 | - $this->parsingCss->value['old_maxH'] = $this->_maxH; |
|
| 6069 | - |
|
| 6070 | - $w = $this->parsingCss->value['width']; |
|
| 6071 | - $h = $this->parsingCss->value['height']; |
|
| 6072 | - |
|
| 6073 | - if ( ! $this->parsingCss->value['position']) { |
|
| 6074 | - if ( |
|
| 6075 | - $w < ($this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin()) && |
|
| 6076 | - $this->pdf->getX() + $w >= ($this->pdf->getW() - $this->pdf->getrMargin()) |
|
| 6077 | - ) |
|
| 6078 | - $this->_tag_open_BR(array()); |
|
| 6079 | - |
|
| 6080 | - if ( |
|
| 6081 | - ($h < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin())) && |
|
| 6082 | - ($this->pdf->getY() + $h >= ($this->pdf->getH() - $this->pdf->getbMargin())) && |
|
| 6083 | - ! $this->_isInOverflow |
|
| 6084 | - ) |
|
| 6085 | - $this->_setNewPage(); |
|
| 6086 | - |
|
| 6087 | - $old = $this->parsingCss->getOldValues(); |
|
| 6088 | - $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 6089 | - |
|
| 6090 | - if ($parentWidth > $w) { |
|
| 6091 | - if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 6092 | - else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 6093 | - } |
|
| 6094 | - |
|
| 6095 | - $this->parsingCss->setPosition(); |
|
| 6096 | - } else { |
|
| 6097 | - $old = $this->parsingCss->getOldValues(); |
|
| 6098 | - $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 6099 | - |
|
| 6100 | - if ($parentWidth > $w) { |
|
| 6101 | - if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 6102 | - else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 6103 | - } |
|
| 6104 | - |
|
| 6105 | - $this->parsingCss->setPosition(); |
|
| 6106 | - $this->_saveMax(); |
|
| 6107 | - $this->_maxX = 0; |
|
| 6108 | - $this->_maxY = 0; |
|
| 6109 | - $this->_maxH = 0; |
|
| 6110 | - $this->_maxE = 0; |
|
| 6111 | - } |
|
| 6112 | - |
|
| 6113 | - $this->_drawRectangle( |
|
| 6114 | - $this->parsingCss->value['x'], |
|
| 6115 | - $this->parsingCss->value['y'], |
|
| 6116 | - $this->parsingCss->value['width'], |
|
| 6117 | - $this->parsingCss->value['height'], |
|
| 6118 | - $this->parsingCss->value['border'], |
|
| 6119 | - $this->parsingCss->value['padding'], |
|
| 6120 | - 0, |
|
| 6121 | - $this->parsingCss->value['background'] |
|
| 6122 | - ); |
|
| 6123 | - |
|
| 6124 | - $marge = array(); |
|
| 6125 | - $marge['l'] = $this->parsingCss->value['border']['l']['width']; |
|
| 6126 | - $marge['r'] = $this->parsingCss->value['border']['r']['width']; |
|
| 6127 | - $marge['t'] = $this->parsingCss->value['border']['t']['width']; |
|
| 6128 | - $marge['b'] = $this->parsingCss->value['border']['b']['width']; |
|
| 6129 | - |
|
| 6130 | - $this->parsingCss->value['width'] -= $marge['l'] + $marge['r']; |
|
| 6131 | - $this->parsingCss->value['height'] -= $marge['t'] + $marge['b']; |
|
| 6132 | - |
|
| 6133 | - $overW -= $marge['l'] + $marge['r']; |
|
| 6134 | - $overH -= $marge['t'] + $marge['b']; |
|
| 6135 | - |
|
| 6136 | - // clipping to draw only in the size opf the DRAW tag |
|
| 6137 | - $this->pdf->clippingPathStart( |
|
| 6138 | - $this->parsingCss->value['x'] + $marge['l'], |
|
| 6139 | - $this->parsingCss->value['y'] + $marge['t'], |
|
| 6140 | - $this->parsingCss->value['width'], |
|
| 6141 | - $this->parsingCss->value['height'] |
|
| 6142 | - ); |
|
| 6143 | - |
|
| 6144 | - // left and right of the DRAW tag |
|
| 6145 | - $mL = $this->parsingCss->value['x'] + $marge['l']; |
|
| 6146 | - $mR = $this->pdf->getW() - $mL - $overW; |
|
| 6147 | - |
|
| 6148 | - // position of the DRAW tag |
|
| 6149 | - $x = $this->parsingCss->value['x'] + $marge['l']; |
|
| 6150 | - $y = $this->parsingCss->value['y'] + $marge['t']; |
|
| 6151 | - |
|
| 6152 | - // prepare the drawing area |
|
| 6153 | - $this->_saveMargin($mL, 0, $mR); |
|
| 6154 | - $this->pdf->setXY($x, $y); |
|
| 6155 | - |
|
| 6156 | - // we are in a draw tag |
|
| 6157 | - $this->_isInDraw = array( |
|
| 6158 | - 'x' => $x, |
|
| 6159 | - 'y' => $y, |
|
| 6160 | - 'w' => $overW, |
|
| 6161 | - 'h' => $overH, |
|
| 6162 | - ); |
|
| 6163 | - |
|
| 6164 | - // init the translate matrix : (0,0) => ($x, $y) |
|
| 6165 | - $this->pdf->doTransform(array(1, 0, 0, 1, $x, $y)); |
|
| 6166 | - $this->pdf->SetAlpha(1.); |
|
| 6167 | - return true; |
|
| 6168 | - } |
|
| 6169 | - |
|
| 6170 | - /** |
|
| 6171 | - * tag : DRAW |
|
| 6172 | - * mode : CLOSE |
|
| 6173 | - * |
|
| 6174 | - * @param array $param |
|
| 6175 | - * @return boolean |
|
| 6176 | - */ |
|
| 6177 | - protected function _tag_close_DRAW($param) |
|
| 6178 | - { |
|
| 6179 | - if ($this->_isForOneLine) { |
|
| 6180 | - return false; |
|
| 6181 | - } |
|
| 6182 | - |
|
| 6183 | - $this->pdf->SetAlpha(1.); |
|
| 6184 | - $this->pdf->undoTransform(); |
|
| 6185 | - $this->pdf->clippingPathStop(); |
|
| 6186 | - |
|
| 6187 | - $this->_maxX = $this->parsingCss->value['old_maxX']; |
|
| 6188 | - $this->_maxY = $this->parsingCss->value['old_maxY']; |
|
| 6189 | - $this->_maxH = $this->parsingCss->value['old_maxH']; |
|
| 6190 | - |
|
| 6191 | - $marge = array(); |
|
| 6192 | - $marge['l'] = $this->parsingCss->value['border']['l']['width']; |
|
| 6193 | - $marge['r'] = $this->parsingCss->value['border']['r']['width']; |
|
| 6194 | - $marge['t'] = $this->parsingCss->value['border']['t']['width']; |
|
| 6195 | - $marge['b'] = $this->parsingCss->value['border']['b']['width']; |
|
| 6196 | - |
|
| 6197 | - $x = $this->parsingCss->value['x']; |
|
| 6198 | - $y = $this->parsingCss->value['y']; |
|
| 6199 | - $w = $this->parsingCss->value['width'] + $marge['l'] + $marge['r']; |
|
| 6200 | - $h = $this->parsingCss->value['height'] + $marge['t'] + $marge['b']; |
|
| 6201 | - |
|
| 6202 | - if ($this->parsingCss->value['position'] != 'absolute') { |
|
| 6203 | - $this->pdf->setXY($x + $w, $y); |
|
| 6204 | - |
|
| 6205 | - $this->_maxX = max($this->_maxX, $x + $w); |
|
| 6206 | - $this->_maxY = max($this->_maxY, $y + $h); |
|
| 6207 | - $this->_maxH = max($this->_maxH, $h); |
|
| 6208 | - $this->_maxE++; |
|
| 6209 | - } else { |
|
| 6210 | - // position |
|
| 6211 | - $this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']); |
|
| 6212 | - |
|
| 6213 | - $this->_loadMax(); |
|
| 6214 | - } |
|
| 6215 | - |
|
| 6216 | - $block = ($this->parsingCss->value['display'] != 'inline' && $this->parsingCss->value['position'] != 'absolute'); |
|
| 6217 | - |
|
| 6218 | - $this->parsingCss->load(); |
|
| 6219 | - $this->parsingCss->fontSet(); |
|
| 6220 | - $this->_loadMargin(); |
|
| 6221 | - |
|
| 6222 | - if ($block) { |
|
| 6223 | - $this->_tag_open_BR(array()); |
|
| 6224 | - } |
|
| 6225 | - if ($this->_debugActif) { |
|
| 6226 | - $this->_DEBUG_add('DRAW', false); |
|
| 6227 | - } |
|
| 6228 | - |
|
| 6229 | - $this->_isInDraw = null; |
|
| 6230 | - |
|
| 6231 | - return true; |
|
| 6232 | - } |
|
| 6233 | - |
|
| 6234 | - /** |
|
| 6235 | - * tag : LINE |
|
| 6236 | - * mode : OPEN |
|
| 6237 | - * |
|
| 6238 | - * @param array $param |
|
| 6239 | - * @return boolean|null |
|
| 6240 | - */ |
|
| 6241 | - protected function _tag_open_LINE($param) |
|
| 6242 | - { |
|
| 6243 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'LINE'); |
|
| 6244 | - |
|
| 6245 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6246 | - $this->parsingCss->save(); |
|
| 6247 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6248 | - $styles['fill'] = null; |
|
| 6249 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6250 | - |
|
| 6251 | - $x1 = isset($param['x1']) ? $this->parsingCss->ConvertToMM($param['x1'], $this->_isInDraw['w']) : 0.; |
|
| 6252 | - $y1 = isset($param['y1']) ? $this->parsingCss->ConvertToMM($param['y1'], $this->_isInDraw['h']) : 0.; |
|
| 6253 | - $x2 = isset($param['x2']) ? $this->parsingCss->ConvertToMM($param['x2'], $this->_isInDraw['w']) : 0.; |
|
| 6254 | - $y2 = isset($param['y2']) ? $this->parsingCss->ConvertToMM($param['y2'], $this->_isInDraw['h']) : 0.; |
|
| 6255 | - $this->pdf->svgLine($x1, $y1, $x2, $y2); |
|
| 6256 | - |
|
| 6257 | - $this->pdf->undoTransform(); |
|
| 6258 | - $this->parsingCss->load(); |
|
| 6259 | - } |
|
| 6260 | - |
|
| 6261 | - /** |
|
| 6262 | - * tag : RECT |
|
| 6263 | - * mode : OPEN |
|
| 6264 | - * |
|
| 6265 | - * @param array $param |
|
| 6266 | - * @return boolean|null |
|
| 6267 | - */ |
|
| 6268 | - protected function _tag_open_RECT($param) |
|
| 6269 | - { |
|
| 6270 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'RECT'); |
|
| 6271 | - |
|
| 6272 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6273 | - $this->parsingCss->save(); |
|
| 6274 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6275 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6276 | - |
|
| 6277 | - $x = isset($param['x']) ? $this->parsingCss->ConvertToMM($param['x'], $this->_isInDraw['w']) : 0.; |
|
| 6278 | - $y = isset($param['y']) ? $this->parsingCss->ConvertToMM($param['y'], $this->_isInDraw['h']) : 0.; |
|
| 6279 | - $w = isset($param['w']) ? $this->parsingCss->ConvertToMM($param['w'], $this->_isInDraw['w']) : 0.; |
|
| 6280 | - $h = isset($param['h']) ? $this->parsingCss->ConvertToMM($param['h'], $this->_isInDraw['h']) : 0.; |
|
| 6281 | - |
|
| 6282 | - $this->pdf->svgRect($x, $y, $w, $h, $style); |
|
| 6283 | - |
|
| 6284 | - $this->pdf->undoTransform(); |
|
| 6285 | - $this->parsingCss->load(); |
|
| 6286 | - } |
|
| 6287 | - |
|
| 6288 | - /** |
|
| 6289 | - * tag : CIRCLE |
|
| 6290 | - * mode : OPEN |
|
| 6291 | - * |
|
| 6292 | - * @param array $param |
|
| 6293 | - * @return boolean|null |
|
| 6294 | - */ |
|
| 6295 | - protected function _tag_open_CIRCLE($param) |
|
| 6296 | - { |
|
| 6297 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'CIRCLE'); |
|
| 6298 | - |
|
| 6299 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6300 | - $this->parsingCss->save(); |
|
| 6301 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6302 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6303 | - |
|
| 6304 | - $cx = isset($param['cx']) ? $this->parsingCss->ConvertToMM($param['cx'], $this->_isInDraw['w']) : 0.; |
|
| 6305 | - $cy = isset($param['cy']) ? $this->parsingCss->ConvertToMM($param['cy'], $this->_isInDraw['h']) : 0.; |
|
| 6306 | - $r = isset($param['r']) ? $this->parsingCss->ConvertToMM($param['r'], $this->_isInDraw['w']) : 0.; |
|
| 6307 | - $this->pdf->svgEllipse($cx, $cy, $r, $r, $style); |
|
| 6308 | - |
|
| 6309 | - $this->pdf->undoTransform(); |
|
| 6310 | - $this->parsingCss->load(); |
|
| 6311 | - } |
|
| 6312 | - |
|
| 6313 | - /** |
|
| 6314 | - * tag : ELLIPSE |
|
| 6315 | - * mode : OPEN |
|
| 6316 | - * |
|
| 6317 | - * @param array $param |
|
| 6318 | - * @return boolean|null |
|
| 6319 | - */ |
|
| 6320 | - protected function _tag_open_ELLIPSE($param) |
|
| 6321 | - { |
|
| 6322 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'ELLIPSE'); |
|
| 6323 | - |
|
| 6324 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6325 | - $this->parsingCss->save(); |
|
| 6326 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6327 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6328 | - |
|
| 6329 | - $cx = isset($param['cx']) ? $this->parsingCss->ConvertToMM($param['cx'], $this->_isInDraw['w']) : 0.; |
|
| 6330 | - $cy = isset($param['cy']) ? $this->parsingCss->ConvertToMM($param['cy'], $this->_isInDraw['h']) : 0.; |
|
| 6331 | - $rx = isset($param['ry']) ? $this->parsingCss->ConvertToMM($param['rx'], $this->_isInDraw['w']) : 0.; |
|
| 6332 | - $ry = isset($param['rx']) ? $this->parsingCss->ConvertToMM($param['ry'], $this->_isInDraw['h']) : 0.; |
|
| 6333 | - $this->pdf->svgEllipse($cx, $cy, $rx, $ry, $style); |
|
| 6334 | - |
|
| 6335 | - $this->pdf->undoTransform(); |
|
| 6336 | - $this->parsingCss->load(); |
|
| 6337 | - } |
|
| 6338 | - |
|
| 6339 | - |
|
| 6340 | - /** |
|
| 6341 | - * tag : POLYLINE |
|
| 6342 | - * mode : OPEN |
|
| 6343 | - * |
|
| 6344 | - * @param array $param |
|
| 6345 | - * @return boolean|null |
|
| 6346 | - */ |
|
| 6347 | - protected function _tag_open_POLYLINE($param) |
|
| 6348 | - { |
|
| 6349 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6350 | - |
|
| 6351 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6352 | - $this->parsingCss->save(); |
|
| 6353 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6354 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6355 | - |
|
| 6356 | - $path = isset($param['points']) ? $param['points'] : null; |
|
| 6357 | - if ($path) { |
|
| 6358 | - $path = str_replace(',', ' ', $path); |
|
| 6359 | - $path = preg_replace('/[\s]+/', ' ', trim($path)); |
|
| 6360 | - |
|
| 6361 | - // prepare the path |
|
| 6362 | - $path = explode(' ', $path); |
|
| 6363 | - foreach ($path as $k => $v) { |
|
| 6364 | - $path[$k] = trim($v); |
|
| 6365 | - if ($path[$k] === '') unset($path[$k]); |
|
| 6366 | - } |
|
| 6367 | - $path = array_values($path); |
|
| 6368 | - |
|
| 6369 | - $actions = array(); |
|
| 6370 | - for ($k = 0; $k < count($path); $k += 2) { |
|
| 6371 | - $actions[] = array( |
|
| 6372 | - ($k ? 'L' : 'M'), |
|
| 6373 | - $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']), |
|
| 6374 | - $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']) |
|
| 6375 | - ); |
|
| 6376 | - } |
|
| 6377 | - |
|
| 6378 | - // drawing |
|
| 6379 | - $this->pdf->svgPolygone($actions, $style); |
|
| 6380 | - } |
|
| 6381 | - |
|
| 6382 | - $this->pdf->undoTransform(); |
|
| 6383 | - $this->parsingCss->load(); |
|
| 6384 | - } |
|
| 6385 | - |
|
| 6386 | - /** |
|
| 6387 | - * tag : POLYGON |
|
| 6388 | - * mode : OPEN |
|
| 6389 | - * |
|
| 6390 | - * @param array $param |
|
| 6391 | - * @return boolean|null |
|
| 6392 | - */ |
|
| 6393 | - protected function _tag_open_POLYGON($param) |
|
| 6394 | - { |
|
| 6395 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6396 | - |
|
| 6397 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6398 | - $this->parsingCss->save(); |
|
| 6399 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6400 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6401 | - |
|
| 6402 | - $path = (isset($param['points']) ? $param['points'] : null); |
|
| 6403 | - if ($path) { |
|
| 6404 | - $path = str_replace(',', ' ', $path); |
|
| 6405 | - $path = preg_replace('/[\s]+/', ' ', trim($path)); |
|
| 6406 | - |
|
| 6407 | - // prepare the path |
|
| 6408 | - $path = explode(' ', $path); |
|
| 6409 | - foreach ($path as $k => $v) { |
|
| 6410 | - $path[$k] = trim($v); |
|
| 6411 | - if ($path[$k] === '') unset($path[$k]); |
|
| 6412 | - } |
|
| 6413 | - $path = array_values($path); |
|
| 6414 | - |
|
| 6415 | - $actions = array(); |
|
| 6416 | - for ($k = 0; $k < count($path); $k += 2) { |
|
| 6417 | - $actions[] = array( |
|
| 6418 | - ($k ? 'L' : 'M'), |
|
| 6419 | - $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']), |
|
| 6420 | - $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']) |
|
| 6421 | - ); |
|
| 6422 | - } |
|
| 6423 | - $actions[] = array('z'); |
|
| 6424 | - |
|
| 6425 | - // drawing |
|
| 6426 | - $this->pdf->svgPolygone($actions, $style); |
|
| 6427 | - } |
|
| 6428 | - |
|
| 6429 | - $this->pdf->undoTransform(); |
|
| 6430 | - $this->parsingCss->load(); |
|
| 6431 | - } |
|
| 6432 | - |
|
| 6433 | - /** |
|
| 6434 | - * tag : PATH |
|
| 6435 | - * mode : OPEN |
|
| 6436 | - * |
|
| 6437 | - * @param array $param |
|
| 6438 | - * @return boolean|null |
|
| 6439 | - */ |
|
| 6440 | - protected function _tag_open_PATH($param) |
|
| 6441 | - { |
|
| 6442 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'PATH'); |
|
| 6443 | - |
|
| 6444 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6445 | - $this->parsingCss->save(); |
|
| 6446 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6447 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6448 | - |
|
| 6449 | - $path = isset($param['d']) ? $param['d'] : null; |
|
| 6450 | - |
|
| 6451 | - if ($path) { |
|
| 6452 | - // prepare the path |
|
| 6453 | - $path = str_replace(',', ' ', $path); |
|
| 6454 | - $path = preg_replace('/([a-zA-Z])([0-9\.\-])/', '$1 $2', $path); |
|
| 6455 | - $path = preg_replace('/([0-9\.])([a-zA-Z])/', '$1 $2', $path); |
|
| 6456 | - $path = preg_replace('/[\s]+/', ' ', trim($path)); |
|
| 6457 | - $path = preg_replace('/ ([a-z]{2})/', '$1', $path); |
|
| 6458 | - |
|
| 6459 | - $path = explode(' ', $path); |
|
| 6460 | - foreach ($path as $k => $v) { |
|
| 6461 | - $path[$k] = trim($v); |
|
| 6462 | - if ($path[$k] === '') unset($path[$k]); |
|
| 6463 | - } |
|
| 6464 | - $path = array_values($path); |
|
| 6465 | - |
|
| 6466 | - // read each actions in the path |
|
| 6467 | - $actions = array(); |
|
| 6468 | - $action = array(); |
|
| 6469 | - $lastAction = null; // last action found |
|
| 6470 | - for ($k = 0; $k < count($path); true) { |
|
| 6471 | - |
|
| 6472 | - // for this actions, we can not have multi coordonate |
|
| 6473 | - if (in_array($lastAction, array('z', 'Z'))) { |
|
| 6474 | - $lastAction = null; |
|
| 6475 | - } |
|
| 6476 | - |
|
| 6477 | - // read the new action (forcing if no action before) |
|
| 6478 | - if (preg_match('/^[a-z]+$/i', $path[$k]) || $lastAction === null) { |
|
| 6479 | - $lastAction = $path[$k]; |
|
| 6480 | - $k++; |
|
| 6481 | - } |
|
| 6482 | - |
|
| 6483 | - // current action |
|
| 6484 | - $action = array(); |
|
| 6485 | - $action[] = $lastAction; |
|
| 6486 | - switch ($lastAction) |
|
| 6487 | - { |
|
| 6488 | - case 'C': |
|
| 6489 | - case 'c': |
|
| 6490 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x1 |
|
| 6491 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y1 |
|
| 6492 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 2], $this->_isInDraw['w']); // x2 |
|
| 6493 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 3], $this->_isInDraw['h']); // y2 |
|
| 6494 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 4], $this->_isInDraw['w']); // x |
|
| 6495 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 5], $this->_isInDraw['h']); // y |
|
| 6496 | - $k += 6; |
|
| 6497 | - break; |
|
| 6498 | - |
|
| 6499 | - case 'Q': |
|
| 6500 | - case 'S': |
|
| 6501 | - case 'q': |
|
| 6502 | - case 's': |
|
| 6503 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x2 |
|
| 6504 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y2 |
|
| 6505 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 2], $this->_isInDraw['w']); // x |
|
| 6506 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 3], $this->_isInDraw['h']); // y |
|
| 6507 | - $k += 4; |
|
| 6508 | - break; |
|
| 6509 | - |
|
| 6510 | - case 'A': |
|
| 6511 | - case 'a': |
|
| 6512 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // rx |
|
| 6513 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // ry |
|
| 6514 | - $action[] = 1. * $path[$k + 2]; // angle de deviation de l'axe X |
|
| 6515 | - $action[] = ($path[$k + 3] == '1') ? 1 : 0; // large-arc-flag |
|
| 6516 | - $action[] = ($path[$k + 4] == '1') ? 1 : 0; // sweep-flag |
|
| 6517 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 5], $this->_isInDraw['w']); // x |
|
| 6518 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 6], $this->_isInDraw['h']); // y |
|
| 6519 | - $k += 7; |
|
| 6520 | - break; |
|
| 6521 | - |
|
| 6522 | - case 'M': |
|
| 6523 | - case 'L': |
|
| 6524 | - case 'T': |
|
| 6525 | - case 'm': |
|
| 6526 | - case 'l': |
|
| 6527 | - case 't': |
|
| 6528 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x |
|
| 6529 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y |
|
| 6530 | - $k += 2; |
|
| 6531 | - break; |
|
| 6532 | - |
|
| 6533 | - case 'H': |
|
| 6534 | - case 'h': |
|
| 6535 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x |
|
| 6536 | - $k += 1; |
|
| 6537 | - break; |
|
| 6538 | - |
|
| 6539 | - case 'V': |
|
| 6540 | - case 'v': |
|
| 6541 | - $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['h']); // y |
|
| 6542 | - $k += 1; |
|
| 6543 | - break; |
|
| 6544 | - |
|
| 6545 | - case 'z': |
|
| 6546 | - case 'Z': |
|
| 6547 | - default: |
|
| 6548 | - break; |
|
| 6549 | - } |
|
| 6550 | - // add the action |
|
| 6551 | - $actions[] = $action; |
|
| 6552 | - } |
|
| 6553 | - |
|
| 6554 | - // drawing |
|
| 6555 | - $this->pdf->svgPolygone($actions, $style); |
|
| 6556 | - } |
|
| 6557 | - |
|
| 6558 | - $this->pdf->undoTransform(); |
|
| 6559 | - $this->parsingCss->load(); |
|
| 6560 | - } |
|
| 6561 | - |
|
| 6562 | - /** |
|
| 6563 | - * tag : G |
|
| 6564 | - * mode : OPEN |
|
| 6565 | - * |
|
| 6566 | - * @param array $param |
|
| 6567 | - * @return boolean|null |
|
| 6568 | - */ |
|
| 6569 | - protected function _tag_open_G($param) |
|
| 6570 | - { |
|
| 6571 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'G'); |
|
| 6572 | - |
|
| 6573 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6574 | - $this->parsingCss->save(); |
|
| 6575 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6576 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6577 | - } |
|
| 6578 | - |
|
| 6579 | - /** |
|
| 6580 | - * tag : G |
|
| 6581 | - * mode : CLOSE |
|
| 6582 | - * |
|
| 6583 | - * @param array $param |
|
| 6584 | - * @return boolean|null |
|
| 6585 | - */ |
|
| 6586 | - protected function _tag_close_G($param) |
|
| 6587 | - { |
|
| 6588 | - $this->pdf->undoTransform(); |
|
| 6589 | - $this->parsingCss->load(); |
|
| 6590 | - } |
|
| 6591 | - |
|
| 6592 | - /** |
|
| 6593 | - * new page for the automatic Index, does not use thie method. Only HTML2PDF_myPdf could use it !!!! |
|
| 6594 | - * |
|
| 6595 | - * @param &int $page |
|
| 6596 | - * @return integer $oldPage |
|
| 6597 | - */ |
|
| 6598 | - public function _INDEX_NewPage(&$page) |
|
| 6599 | - { |
|
| 6600 | - if ($page) { |
|
| 6601 | - $oldPage = $this->pdf->getPage(); |
|
| 6602 | - $this->pdf->setPage($page); |
|
| 6603 | - $this->pdf->setXY($this->_margeLeft, $this->_margeTop); |
|
| 6604 | - $this->_maxH = 0; |
|
| 6605 | - $page++; |
|
| 6606 | - return $oldPage; |
|
| 6607 | - } else { |
|
| 6608 | - $this->_setNewPage(); |
|
| 6609 | - return null; |
|
| 6610 | - } |
|
| 6611 | - } |
|
| 6612 | - |
|
| 6613 | - } |
|
| 504 | + exit; |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + /** |
|
| 508 | + * set the default margins of the page |
|
| 509 | + * |
|
| 510 | + * @access protected |
|
| 511 | + * @param int $left (mm, left margin) |
|
| 512 | + * @param int $top (mm, top margin) |
|
| 513 | + * @param int $right (mm, right margin, if null => left=right) |
|
| 514 | + * @param int $bottom (mm, bottom margin, if null => bottom=8mm) |
|
| 515 | + */ |
|
| 516 | + protected function _setDefaultMargins($left, $top, $right = null, $bottom = null) |
|
| 517 | + { |
|
| 518 | + if ($right === null) $right = $left; |
|
| 519 | + if ($bottom === null) $bottom = 8; |
|
| 520 | + |
|
| 521 | + $this->_defaultLeft = $this->parsingCss->ConvertToMM($left.'mm'); |
|
| 522 | + $this->_defaultTop = $this->parsingCss->ConvertToMM($top.'mm'); |
|
| 523 | + $this->_defaultRight = $this->parsingCss->ConvertToMM($right.'mm'); |
|
| 524 | + $this->_defaultBottom = $this->parsingCss->ConvertToMM($bottom.'mm'); |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + /** |
|
| 528 | + * create a new page |
|
| 529 | + * |
|
| 530 | + * @access protected |
|
| 531 | + * @param mixed $format |
|
| 532 | + * @param string $orientation |
|
| 533 | + * @param array $background background information |
|
| 534 | + * @param integer $curr real position in the html parseur (if break line in the write of a text) |
|
| 535 | + * @param boolean $resetPageNumber |
|
| 536 | + */ |
|
| 537 | + protected function _setNewPage($format = null, $orientation = '', $background = null, $curr = null, $resetPageNumber = false) |
|
| 538 | + { |
|
| 539 | + $this->_firstPage = false; |
|
| 540 | + |
|
| 541 | + $this->_format = $format ? $format : $this->_format; |
|
| 542 | + $this->_orientation = $orientation ? $orientation : $this->_orientation; |
|
| 543 | + $this->_background = $background !== null ? $background : $this->_background; |
|
| 544 | + $this->_maxY = 0; |
|
| 545 | + $this->_maxX = 0; |
|
| 546 | + $this->_maxH = 0; |
|
| 547 | + $this->_maxE = 0; |
|
| 548 | + |
|
| 549 | + $this->pdf->SetMargins($this->_defaultLeft, $this->_defaultTop, $this->_defaultRight); |
|
| 550 | + |
|
| 551 | + if ($resetPageNumber) { |
|
| 552 | + $this->pdf->startPageGroup(); |
|
| 553 | + } |
|
| 554 | + |
|
| 555 | + $this->pdf->AddPage($this->_orientation, $this->_format); |
|
| 556 | + |
|
| 557 | + if ($resetPageNumber) { |
|
| 558 | + $this->pdf->myStartPageGroup(); |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + $this->_page++; |
|
| 562 | + |
|
| 563 | + if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 564 | + if (is_array($this->_background)) { |
|
| 565 | + if (isset($this->_background['color']) && $this->_background['color']) { |
|
| 566 | + $this->pdf->setFillColorArray($this->_background['color']); |
|
| 567 | + $this->pdf->Rect(0, 0, $this->pdf->getW(), $this->pdf->getH(), 'F'); |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + if (isset($this->_background['img']) && $this->_background['img']) { |
|
| 571 | + $this->pdf->Image($this->_background['img'], $this->_background['posX'], $this->_background['posY'], $this->_background['width']); |
|
| 572 | + } |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + $this->_setPageHeader(); |
|
| 576 | + $this->_setPageFooter(); |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + $this->_setMargins(); |
|
| 580 | + $this->pdf->setY($this->_margeTop); |
|
| 581 | + |
|
| 582 | + $this->_setNewPositionForNewLine($curr); |
|
| 583 | + $this->_maxH = 0; |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + /** |
|
| 587 | + * set the real margin, using the default margins and the page margins |
|
| 588 | + * |
|
| 589 | + * @access protected |
|
| 590 | + */ |
|
| 591 | + protected function _setMargins() |
|
| 592 | + { |
|
| 593 | + // prepare the margins |
|
| 594 | + $this->_margeLeft = $this->_defaultLeft + (isset($this->_background['left']) ? $this->_background['left'] : 0); |
|
| 595 | + $this->_margeRight = $this->_defaultRight + (isset($this->_background['right']) ? $this->_background['right'] : 0); |
|
| 596 | + $this->_margeTop = $this->_defaultTop + (isset($this->_background['top']) ? $this->_background['top'] : 0); |
|
| 597 | + $this->_margeBottom = $this->_defaultBottom + (isset($this->_background['bottom']) ? $this->_background['bottom'] : 0); |
|
| 598 | + |
|
| 599 | + // set the PDF margins |
|
| 600 | + $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 601 | + $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 602 | + |
|
| 603 | + // set the float Margins |
|
| 604 | + $this->_pageMarges = array(); |
|
| 605 | + if ($this->_isInParagraph !== false) { |
|
| 606 | + $this->_pageMarges[floor($this->_margeTop * 100)] = array($this->_isInParagraph[0], $this->pdf->getW() - $this->_isInParagraph[1]); |
|
| 607 | + } else { |
|
| 608 | + $this->_pageMarges[floor($this->_margeTop * 100)] = array($this->_margeLeft, $this->pdf->getW() - $this->_margeRight); |
|
| 609 | + } |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + /** |
|
| 613 | + * add a debug step |
|
| 614 | + * |
|
| 615 | + * @access protected |
|
| 616 | + * @param string $name step name |
|
| 617 | + * @param boolean $level (true=up, false=down, null=nothing to do) |
|
| 618 | + * @return $this |
|
| 619 | + */ |
|
| 620 | + protected function _DEBUG_add($name, $level = null) |
|
| 621 | + { |
|
| 622 | + // if true : UP |
|
| 623 | + if ($level === true) $this->_debugLevel++; |
|
| 624 | + |
|
| 625 | + $name = str_repeat(' ', $this->_debugLevel).$name.($level === true ? ' Begin' : ($level === false ? ' End' : '')); |
|
| 626 | + $time = microtime(true); |
|
| 627 | + $usage = ($this->_debugOkUsage ? memory_get_usage() : 0); |
|
| 628 | + $peak = ($this->_debugOkPeak ? memory_get_peak_usage() : 0); |
|
| 629 | + |
|
| 630 | + $this->_DEBUG_stepline( |
|
| 631 | + $name, |
|
| 632 | + number_format(($time - $this->_debugStartTime) * 1000, 1, '.', ' ').' ms', |
|
| 633 | + number_format(($time - $this->_debugLastTime) * 1000, 1, '.', ' ').' ms', |
|
| 634 | + number_format($usage / 1024, 1, '.', ' ').' Ko', |
|
| 635 | + number_format($peak / 1024, 1, '.', ' ').' Ko' |
|
| 636 | + ); |
|
| 637 | + |
|
| 638 | + $this->_debugLastTime = $time; |
|
| 639 | + |
|
| 640 | + // it false : DOWN |
|
| 641 | + if ($level === false) $this->_debugLevel--; |
|
| 642 | + |
|
| 643 | + return $this; |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + /** |
|
| 647 | + * display a debug line |
|
| 648 | + * |
|
| 649 | + * |
|
| 650 | + * @access protected |
|
| 651 | + * @param string $name |
|
| 652 | + * @param string $timeTotal |
|
| 653 | + * @param string $timeStep |
|
| 654 | + * @param string $memoryUsage |
|
| 655 | + * @param string $memoryPeak |
|
| 656 | + */ |
|
| 657 | + protected function _DEBUG_stepline($name, $timeTotal, $timeStep, $memoryUsage, $memoryPeak) |
|
| 658 | + { |
|
| 659 | + $txt = str_pad($name, 30, ' ', STR_PAD_RIGHT). |
|
| 660 | + str_pad($timeTotal, 12, ' ', STR_PAD_LEFT). |
|
| 661 | + str_pad($timeStep, 12, ' ', STR_PAD_LEFT). |
|
| 662 | + str_pad($memoryUsage, 15, ' ', STR_PAD_LEFT). |
|
| 663 | + str_pad($memoryPeak, 15, ' ', STR_PAD_LEFT); |
|
| 664 | + |
|
| 665 | + echo '<pre style="padding:0; margin:0">'.$txt.'</pre>'; |
|
| 666 | + } |
|
| 667 | + |
|
| 668 | + /** |
|
| 669 | + * get the Min and Max X, for Y (use the float margins) |
|
| 670 | + * |
|
| 671 | + * @access protected |
|
| 672 | + * @param float $y |
|
| 673 | + * @return array(float, float) |
|
| 674 | + */ |
|
| 675 | + protected function _getMargins($y) |
|
| 676 | + { |
|
| 677 | + $y = floor($y * 100); |
|
| 678 | + $x = array($this->pdf->getlMargin(), $this->pdf->getW() - $this->pdf->getrMargin()); |
|
| 679 | + |
|
| 680 | + foreach ($this->_pageMarges as $mY => $mX) |
|
| 681 | + if ($mY <= $y) $x = $mX; |
|
| 682 | + |
|
| 683 | + return $x; |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + /** |
|
| 687 | + * Add margins, for a float |
|
| 688 | + * |
|
| 689 | + * @access protected |
|
| 690 | + * @param string $float (left / right) |
|
| 691 | + * @param float $xLeft |
|
| 692 | + * @param float $yTop |
|
| 693 | + * @param float $xRight |
|
| 694 | + * @param float $yBottom |
|
| 695 | + */ |
|
| 696 | + protected function _addMargins($float, $xLeft, $yTop, $xRight, $yBottom) |
|
| 697 | + { |
|
| 698 | + // get the current float margins, for top and bottom |
|
| 699 | + $oldTop = $this->_getMargins($yTop); |
|
| 700 | + $oldBottom = $this->_getMargins($yBottom); |
|
| 701 | + |
|
| 702 | + // update the top float margin |
|
| 703 | + if ($float == 'left' && $oldTop[0] < $xRight) $oldTop[0] = $xRight; |
|
| 704 | + if ($float == 'right' && $oldTop[1] > $xLeft) $oldTop[1] = $xLeft; |
|
| 705 | + |
|
| 706 | + $yTop = floor($yTop * 100); |
|
| 707 | + $yBottom = floor($yBottom * 100); |
|
| 708 | + |
|
| 709 | + // erase all the float margins that are smaller than the new one |
|
| 710 | + foreach ($this->_pageMarges as $mY => $mX) { |
|
| 711 | + if ($mY < $yTop) continue; |
|
| 712 | + if ($mY > $yBottom) break; |
|
| 713 | + if ($float == 'left' && $this->_pageMarges[$mY][0] < $xRight) unset($this->_pageMarges[$mY]); |
|
| 714 | + if ($float == 'right' && $this->_pageMarges[$mY][1] > $xLeft) unset($this->_pageMarges[$mY]); |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + // save the new Top and Bottom margins |
|
| 718 | + $this->_pageMarges[$yTop] = $oldTop; |
|
| 719 | + $this->_pageMarges[$yBottom] = $oldBottom; |
|
| 720 | + |
|
| 721 | + // sort the margins |
|
| 722 | + ksort($this->_pageMarges); |
|
| 723 | + |
|
| 724 | + // we are just after float |
|
| 725 | + $this->_isAfterFloat = true; |
|
| 726 | + } |
|
| 727 | + |
|
| 728 | + /** |
|
| 729 | + * Save old margins (push), and set new ones |
|
| 730 | + * |
|
| 731 | + * @access protected |
|
| 732 | + * @param float $ml left margin |
|
| 733 | + * @param float $mt top margin |
|
| 734 | + * @param float $mr right margin |
|
| 735 | + */ |
|
| 736 | + protected function _saveMargin($ml, $mt, $mr) |
|
| 737 | + { |
|
| 738 | + // save old margins |
|
| 739 | + $this->_marges[] = array('l' => $this->pdf->getlMargin(), 't' => $this->pdf->gettMargin(), 'r' => $this->pdf->getrMargin(), 'page' => $this->_pageMarges); |
|
| 740 | + |
|
| 741 | + // set new ones |
|
| 742 | + $this->pdf->SetMargins($ml, $mt, $mr); |
|
| 743 | + |
|
| 744 | + // prepare for float margins |
|
| 745 | + $this->_pageMarges = array(); |
|
| 746 | + $this->_pageMarges[floor($mt * 100)] = array($ml, $this->pdf->getW() - $mr); |
|
| 747 | + } |
|
| 748 | + |
|
| 749 | + /** |
|
| 750 | + * load the last saved margins (pop) |
|
| 751 | + * |
|
| 752 | + * @access protected |
|
| 753 | + */ |
|
| 754 | + protected function _loadMargin() |
|
| 755 | + { |
|
| 756 | + $old = array_pop($this->_marges); |
|
| 757 | + if ($old) { |
|
| 758 | + $ml = $old['l']; |
|
| 759 | + $mt = $old['t']; |
|
| 760 | + $mr = $old['r']; |
|
| 761 | + $mP = $old['page']; |
|
| 762 | + } else { |
|
| 763 | + $ml = $this->_margeLeft; |
|
| 764 | + $mt = 0; |
|
| 765 | + $mr = $this->_margeRight; |
|
| 766 | + $mP = array($mt => array($ml, $this->pdf->getW() - $mr)); |
|
| 767 | + } |
|
| 768 | + |
|
| 769 | + $this->pdf->SetMargins($ml, $mt, $mr); |
|
| 770 | + $this->_pageMarges = $mP; |
|
| 771 | + } |
|
| 772 | + |
|
| 773 | + /** |
|
| 774 | + * save the current maxs (push) |
|
| 775 | + * |
|
| 776 | + * @access protected |
|
| 777 | + */ |
|
| 778 | + protected function _saveMax() |
|
| 779 | + { |
|
| 780 | + $this->_maxSave[] = array($this->_maxX, $this->_maxY, $this->_maxH, $this->_maxE); |
|
| 781 | + } |
|
| 782 | + |
|
| 783 | + /** |
|
| 784 | + * load the last saved current maxs (pop) |
|
| 785 | + * |
|
| 786 | + * @access protected |
|
| 787 | + */ |
|
| 788 | + protected function _loadMax() |
|
| 789 | + { |
|
| 790 | + $old = array_pop($this->_maxSave); |
|
| 791 | + |
|
| 792 | + if ($old) { |
|
| 793 | + $this->_maxX = $old[0]; |
|
| 794 | + $this->_maxY = $old[1]; |
|
| 795 | + $this->_maxH = $old[2]; |
|
| 796 | + $this->_maxE = $old[3]; |
|
| 797 | + } else { |
|
| 798 | + $this->_maxX = 0; |
|
| 799 | + $this->_maxY = 0; |
|
| 800 | + $this->_maxH = 0; |
|
| 801 | + $this->_maxE = 0; |
|
| 802 | + } |
|
| 803 | + } |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * draw the PDF header with the HTML in page_header |
|
| 807 | + * |
|
| 808 | + * @access protected |
|
| 809 | + */ |
|
| 810 | + protected function _setPageHeader() |
|
| 811 | + { |
|
| 812 | + if ( ! count($this->_subHEADER)) return false; |
|
| 813 | + |
|
| 814 | + $oldParsePos = $this->_parsePos; |
|
| 815 | + $oldParseCode = $this->parsingHtml->code; |
|
| 816 | + |
|
| 817 | + $this->_parsePos = 0; |
|
| 818 | + $this->parsingHtml->code = $this->_subHEADER; |
|
| 819 | + $this->_makeHTMLcode(); |
|
| 820 | + |
|
| 821 | + $this->_parsePos = $oldParsePos; |
|
| 822 | + $this->parsingHtml->code = $oldParseCode; |
|
| 823 | + } |
|
| 824 | + |
|
| 825 | + /** |
|
| 826 | + * draw the PDF footer with the HTML in page_footer |
|
| 827 | + * |
|
| 828 | + * @access protected |
|
| 829 | + */ |
|
| 830 | + protected function _setPageFooter() |
|
| 831 | + { |
|
| 832 | + if ( ! count($this->_subFOOTER)) return false; |
|
| 833 | + |
|
| 834 | + $oldParsePos = $this->_parsePos; |
|
| 835 | + $oldParseCode = $this->parsingHtml->code; |
|
| 836 | + |
|
| 837 | + $this->_parsePos = 0; |
|
| 838 | + $this->parsingHtml->code = $this->_subFOOTER; |
|
| 839 | + $this->_isInFooter = true; |
|
| 840 | + $this->_makeHTMLcode(); |
|
| 841 | + $this->_isInFooter = false; |
|
| 842 | + |
|
| 843 | + $this->_parsePos = $oldParsePos; |
|
| 844 | + $this->parsingHtml->code = $oldParseCode; |
|
| 845 | + } |
|
| 846 | + |
|
| 847 | + /** |
|
| 848 | + * new line, with a specific height |
|
| 849 | + * |
|
| 850 | + * @access protected |
|
| 851 | + * @param float $h |
|
| 852 | + * @param integer $curr real current position in the text, if new line in the write of a text |
|
| 853 | + */ |
|
| 854 | + protected function _setNewLine($h, $curr = null) |
|
| 855 | + { |
|
| 856 | + $this->pdf->Ln($h); |
|
| 857 | + $this->_setNewPositionForNewLine($curr); |
|
| 858 | + } |
|
| 859 | + |
|
| 860 | + /** |
|
| 861 | + * calculate the start position of the next line, depending on the text-align |
|
| 862 | + * |
|
| 863 | + * @access protected |
|
| 864 | + * @param integer $curr real current position in the text, if new line in the write of a text |
|
| 865 | + */ |
|
| 866 | + protected function _setNewPositionForNewLine($curr = null) |
|
| 867 | + { |
|
| 868 | + // get the margins for the current line |
|
| 869 | + list($lx, $rx) = $this->_getMargins($this->pdf->getY()); |
|
| 870 | + $this->pdf->setX($lx); |
|
| 871 | + $wMax = $rx - $lx; |
|
| 872 | + $this->_currentH = 0; |
|
| 873 | + |
|
| 874 | + // if subPart => return because align left |
|
| 875 | + if ($this->_subPart || $this->_isSubPart || $this->_isForOneLine) { |
|
| 876 | + $this->pdf->setWordSpacing(0); |
|
| 877 | + return null; |
|
| 878 | + } |
|
| 879 | + |
|
| 880 | + // create the sub object |
|
| 881 | + $sub = null; |
|
| 882 | + $this->_createSubHTML($sub); |
|
| 883 | + $sub->_saveMargin(0, 0, $sub->pdf->getW() - $wMax); |
|
| 884 | + $sub->_isForOneLine = true; |
|
| 885 | + $sub->_parsePos = $this->_parsePos; |
|
| 886 | + $sub->parsingHtml->code = $this->parsingHtml->code; |
|
| 887 | + |
|
| 888 | + // if $curr => adapt the current position of the parsing |
|
| 889 | + if ($curr !== null && $sub->parsingHtml->code[$this->_parsePos]['name'] == 'write') { |
|
| 890 | + $txt = $sub->parsingHtml->code[$this->_parsePos]['param']['txt']; |
|
| 891 | + $txt = str_replace('[[page_cu]]', $sub->pdf->getMyNumPage($this->_page), $txt); |
|
| 892 | + $sub->parsingHtml->code[$this->_parsePos]['param']['txt'] = substr($txt, $curr + 1); |
|
| 893 | + } else |
|
| 894 | + $sub->_parsePos++; |
|
| 895 | + |
|
| 896 | + // for each element of the parsing => load the action |
|
| 897 | + $res = null; |
|
| 898 | + for ($sub->_parsePos; $sub->_parsePos < count($sub->parsingHtml->code); $sub->_parsePos++) { |
|
| 899 | + $action = $sub->parsingHtml->code[$sub->_parsePos]; |
|
| 900 | + $res = $sub->_executeAction($action); |
|
| 901 | + if ( ! $res) break; |
|
| 902 | + } |
|
| 903 | + |
|
| 904 | + $w = $sub->_maxX; // max width |
|
| 905 | + $h = $sub->_maxH; // max height |
|
| 906 | + $e = ($res === null ? $sub->_maxE : 0); // maxnumber of elemets on the line |
|
| 907 | + |
|
| 908 | + // destroy the sub HTML |
|
| 909 | + $this->_destroySubHTML($sub); |
|
| 910 | + |
|
| 911 | + // adapt the start of the line, depending on the text-align |
|
| 912 | + if ($this->parsingCss->value['text-align'] == 'center') |
|
| 913 | + $this->pdf->setX(($rx + $this->pdf->getX() - $w) * 0.5 - 0.01); |
|
| 914 | + else if ($this->parsingCss->value['text-align'] == 'right') |
|
| 915 | + $this->pdf->setX($rx - $w - 0.01); |
|
| 916 | + else |
|
| 917 | + $this->pdf->setX($lx); |
|
| 918 | + |
|
| 919 | + // set the height of the line |
|
| 920 | + $this->_currentH = $h; |
|
| 921 | + |
|
| 922 | + // if justify => set the word spacing |
|
| 923 | + if ($this->parsingCss->value['text-align'] == 'justify' && $e > 1) { |
|
| 924 | + $this->pdf->setWordSpacing(($wMax - $w) / ($e - 1)); |
|
| 925 | + } else { |
|
| 926 | + $this->pdf->setWordSpacing(0); |
|
| 927 | + } |
|
| 928 | + } |
|
| 929 | + |
|
| 930 | + /** |
|
| 931 | + * prepare HTML2PDF::$_subobj (used for create the sub HTML2PDF objects |
|
| 932 | + * |
|
| 933 | + * @access protected |
|
| 934 | + */ |
|
| 935 | + protected function _prepareSubObj() |
|
| 936 | + { |
|
| 937 | + $pdf = null; |
|
| 938 | + |
|
| 939 | + // create the sub object |
|
| 940 | + HTML2PDF::$_subobj = new HTML2PDF( |
|
| 941 | + $this->_orientation, |
|
| 942 | + $this->_format, |
|
| 943 | + $this->_langue, |
|
| 944 | + $this->_unicode, |
|
| 945 | + $this->_encoding, |
|
| 946 | + array($this->_defaultLeft, $this->_defaultTop, $this->_defaultRight, $this->_defaultBottom) |
|
| 947 | + ); |
|
| 948 | + |
|
| 949 | + // init |
|
| 950 | + HTML2PDF::$_subobj->setTestTdInOnePage($this->_testTdInOnepage); |
|
| 951 | + HTML2PDF::$_subobj->setTestIsImage($this->_testIsImage); |
|
| 952 | + HTML2PDF::$_subobj->setTestIsDeprecated($this->_testIsDeprecated); |
|
| 953 | + HTML2PDF::$_subobj->setDefaultFont($this->_defaultFont); |
|
| 954 | + HTML2PDF::$_subobj->parsingCss->css = &$this->parsingCss->css; |
|
| 955 | + HTML2PDF::$_subobj->parsingCss->cssKeys = &$this->parsingCss->cssKeys; |
|
| 956 | + |
|
| 957 | + // clone font from the original PDF |
|
| 958 | + HTML2PDF::$_subobj->pdf->cloneFontFrom($this->pdf); |
|
| 959 | + |
|
| 960 | + // remove the link to the parent |
|
| 961 | + HTML2PDF::$_subobj->parsingCss->setPdfParent($pdf); |
|
| 962 | + } |
|
| 963 | + |
|
| 964 | + /** |
|
| 965 | + * create a sub HTML2PDF, to calculate the multi-tables |
|
| 966 | + * |
|
| 967 | + * @access protected |
|
| 968 | + * @param &HTML2PDF $subHtml sub HTML2PDF to create |
|
| 969 | + * @param integer $cellmargin if in a TD : cellmargin of this td |
|
| 970 | + */ |
|
| 971 | + protected function _createSubHTML(&$subHtml, $cellmargin = 0) |
|
| 972 | + { |
|
| 973 | + // prepare the subObject, if never prepare before |
|
| 974 | + if (HTML2PDF::$_subobj === null) { |
|
| 975 | + $this->_prepareSubObj(); |
|
| 976 | + } |
|
| 977 | + |
|
| 978 | + // calculate the width to use |
|
| 979 | + if ($this->parsingCss->value['width']) { |
|
| 980 | + $marge = $cellmargin * 2; |
|
| 981 | + $marge += $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['padding']['r']; |
|
| 982 | + $marge += $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['border']['r']['width']; |
|
| 983 | + $marge = $this->pdf->getW() - $this->parsingCss->value['width'] + $marge; |
|
| 984 | + } else { |
|
| 985 | + $marge = $this->_margeLeft + $this->_margeRight; |
|
| 986 | + } |
|
| 987 | + |
|
| 988 | + // BUGFIX : we have to call the method, because of a bug in php 5.1.6 |
|
| 989 | + HTML2PDF::$_subobj->pdf->getPage(); |
|
| 990 | + |
|
| 991 | + // clone the sub oject |
|
| 992 | + $subHtml = clone HTML2PDF::$_subobj; |
|
| 993 | + $subHtml->parsingCss->table = $this->parsingCss->table; |
|
| 994 | + $subHtml->parsingCss->value = $this->parsingCss->value; |
|
| 995 | + $subHtml->initSubHtml( |
|
| 996 | + $this->_format, |
|
| 997 | + $this->_orientation, |
|
| 998 | + $marge, |
|
| 999 | + $this->_page, |
|
| 1000 | + $this->_defList, |
|
| 1001 | + $this->pdf->getMyLastPageGroup(), |
|
| 1002 | + $this->pdf->getMyLastPageGroupNb() |
|
| 1003 | + ); |
|
| 1004 | + } |
|
| 1005 | + |
|
| 1006 | + /** |
|
| 1007 | + * destroy a subHTML2PDF |
|
| 1008 | + * |
|
| 1009 | + * @access protected |
|
| 1010 | + */ |
|
| 1011 | + protected function _destroySubHTML(&$subHtml) |
|
| 1012 | + { |
|
| 1013 | + unset($subHtml); |
|
| 1014 | + $subHtml = null; |
|
| 1015 | + } |
|
| 1016 | + |
|
| 1017 | + /** |
|
| 1018 | + * Convert a arabic number in roman number |
|
| 1019 | + * |
|
| 1020 | + * @access protected |
|
| 1021 | + * @param integer $nbArabic |
|
| 1022 | + * @return string $nbRoman |
|
| 1023 | + */ |
|
| 1024 | + protected function _listeArab2Rom($nbArabic) |
|
| 1025 | + { |
|
| 1026 | + $nbBaseTen = array('I', 'X', 'C', 'M'); |
|
| 1027 | + $nbBaseFive = array('V', 'L', 'D'); |
|
| 1028 | + $nbRoman = ''; |
|
| 1029 | + |
|
| 1030 | + if ($nbArabic < 1) return $nbArabic; |
|
| 1031 | + if ($nbArabic > 3999) return $nbArabic; |
|
| 1032 | + |
|
| 1033 | + for ($i = 3; $i >= 0; $i--) { |
|
| 1034 | + $chiffre = floor($nbArabic / pow(10, $i)); |
|
| 1035 | + if ($chiffre >= 1) { |
|
| 1036 | + $nbArabic = $nbArabic - $chiffre * pow(10, $i); |
|
| 1037 | + if ($chiffre <= 3) { |
|
| 1038 | + for ($j = $chiffre; $j >= 1; $j--) { |
|
| 1039 | + $nbRoman = $nbRoman.$nbBaseTen[$i]; |
|
| 1040 | + } |
|
| 1041 | + } else if ($chiffre == 9) { |
|
| 1042 | + $nbRoman = $nbRoman.$nbBaseTen[$i].$nbBaseTen[$i + 1]; |
|
| 1043 | + } else if ($chiffre == 4) { |
|
| 1044 | + $nbRoman = $nbRoman.$nbBaseTen[$i].$nbBaseFive[$i]; |
|
| 1045 | + } else { |
|
| 1046 | + $nbRoman = $nbRoman.$nbBaseFive[$i]; |
|
| 1047 | + for ($j = $chiffre - 5; $j >= 1; $j--) { |
|
| 1048 | + $nbRoman = $nbRoman.$nbBaseTen[$i]; |
|
| 1049 | + } |
|
| 1050 | + } |
|
| 1051 | + } |
|
| 1052 | + } |
|
| 1053 | + return $nbRoman; |
|
| 1054 | + } |
|
| 1055 | + |
|
| 1056 | + /** |
|
| 1057 | + * add a LI to the current level |
|
| 1058 | + * |
|
| 1059 | + * @access protected |
|
| 1060 | + */ |
|
| 1061 | + protected function _listeAddLi() |
|
| 1062 | + { |
|
| 1063 | + $this->_defList[count($this->_defList) - 1]['nb']++; |
|
| 1064 | + } |
|
| 1065 | + |
|
| 1066 | + /** |
|
| 1067 | + * get the width to use for the column of the list |
|
| 1068 | + * |
|
| 1069 | + * @access protected |
|
| 1070 | + * @return string $width |
|
| 1071 | + */ |
|
| 1072 | + protected function _listeGetWidth() |
|
| 1073 | + { |
|
| 1074 | + return '7mm'; |
|
| 1075 | + } |
|
| 1076 | + |
|
| 1077 | + /** |
|
| 1078 | + * get the padding to use for the column of the list |
|
| 1079 | + * |
|
| 1080 | + * @access protected |
|
| 1081 | + * @return string $padding |
|
| 1082 | + */ |
|
| 1083 | + protected function _listeGetPadding() |
|
| 1084 | + { |
|
| 1085 | + return '1mm'; |
|
| 1086 | + } |
|
| 1087 | + |
|
| 1088 | + /** |
|
| 1089 | + * get the information of the li on the current level |
|
| 1090 | + * |
|
| 1091 | + * @access protected |
|
| 1092 | + * @return array(fontName, small size, string) |
|
| 1093 | + */ |
|
| 1094 | + protected function _listeGetLi() |
|
| 1095 | + { |
|
| 1096 | + $im = $this->_defList[count($this->_defList) - 1]['img']; |
|
| 1097 | + $st = $this->_defList[count($this->_defList) - 1]['style']; |
|
| 1098 | + $nb = $this->_defList[count($this->_defList) - 1]['nb']; |
|
| 1099 | + $up = (substr($st, 0, 6) == 'upper-'); |
|
| 1100 | + |
|
| 1101 | + if ($im) { |
|
| 1102 | + return array(false, false, $im); |
|
| 1103 | + } |
|
| 1104 | + |
|
| 1105 | + switch ($st) |
|
| 1106 | + { |
|
| 1107 | + case 'none': |
|
| 1108 | + return array('helvetica', true, ' '); |
|
| 1109 | + |
|
| 1110 | + case 'upper-alpha': |
|
| 1111 | + case 'lower-alpha': |
|
| 1112 | + $str = ''; |
|
| 1113 | + while ($nb > 26) { |
|
| 1114 | + $str = chr(96 + $nb % 26).$str; |
|
| 1115 | + $nb = floor($nb / 26); |
|
| 1116 | + } |
|
| 1117 | + $str = chr(96 + $nb).$str; |
|
| 1118 | + |
|
| 1119 | + return array('helvetica', false, ($up ? strtoupper($str) : $str).'.'); |
|
| 1120 | + |
|
| 1121 | + case 'upper-roman': |
|
| 1122 | + case 'lower-roman': |
|
| 1123 | + $str = $this->_listeArab2Rom($nb); |
|
| 1124 | + |
|
| 1125 | + return array('helvetica', false, ($up ? strtoupper($str) : $str).'.'); |
|
| 1126 | + |
|
| 1127 | + case 'decimal': |
|
| 1128 | + return array('helvetica', false, $nb.'.'); |
|
| 1129 | + |
|
| 1130 | + case 'square': |
|
| 1131 | + return array('zapfdingbats', true, chr(110)); |
|
| 1132 | + |
|
| 1133 | + case 'circle': |
|
| 1134 | + return array('zapfdingbats', true, chr(109)); |
|
| 1135 | + |
|
| 1136 | + case 'disc': |
|
| 1137 | + default: |
|
| 1138 | + return array('zapfdingbats', true, chr(108)); |
|
| 1139 | + } |
|
| 1140 | + } |
|
| 1141 | + |
|
| 1142 | + /** |
|
| 1143 | + * add a level to the list |
|
| 1144 | + * |
|
| 1145 | + * @access protected |
|
| 1146 | + * @param string $type : ul, ol |
|
| 1147 | + * @param string $style : lower-alpha, ... |
|
| 1148 | + * @param string $img |
|
| 1149 | + */ |
|
| 1150 | + protected function _listeAddLevel($type = 'ul', $style = '', $img = null) |
|
| 1151 | + { |
|
| 1152 | + // get the url of the image, if we want to use a image |
|
| 1153 | + if ($img) { |
|
| 1154 | + if (preg_match('/^url\(([^)]+)\)$/isU', trim($img), $match)) { |
|
| 1155 | + $img = $match[1]; |
|
| 1156 | + } else { |
|
| 1157 | + $img = null; |
|
| 1158 | + } |
|
| 1159 | + } else { |
|
| 1160 | + $img = null; |
|
| 1161 | + } |
|
| 1162 | + |
|
| 1163 | + // prepare the datas |
|
| 1164 | + if ( ! in_array($type, array('ul', 'ol'))) $type = 'ul'; |
|
| 1165 | + if ( ! in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) $style = ''; |
|
| 1166 | + |
|
| 1167 | + if ( ! $style) { |
|
| 1168 | + if ($type == 'ul') $style = 'disc'; |
|
| 1169 | + else $style = 'decimal'; |
|
| 1170 | + } |
|
| 1171 | + |
|
| 1172 | + // add the new level |
|
| 1173 | + $this->_defList[count($this->_defList)] = array('style' => $style, 'nb' => 0, 'img' => $img); |
|
| 1174 | + } |
|
| 1175 | + |
|
| 1176 | + /** |
|
| 1177 | + * remove a level to the list |
|
| 1178 | + * |
|
| 1179 | + * @access protected |
|
| 1180 | + */ |
|
| 1181 | + protected function _listeDelLevel() |
|
| 1182 | + { |
|
| 1183 | + if (count($this->_defList)) { |
|
| 1184 | + unset($this->_defList[count($this->_defList) - 1]); |
|
| 1185 | + $this->_defList = array_values($this->_defList); |
|
| 1186 | + } |
|
| 1187 | + } |
|
| 1188 | + |
|
| 1189 | + /** |
|
| 1190 | + * execute the actions to convert the html |
|
| 1191 | + * |
|
| 1192 | + * @access protected |
|
| 1193 | + */ |
|
| 1194 | + protected function _makeHTMLcode() |
|
| 1195 | + { |
|
| 1196 | + // foreach elements of the parsing |
|
| 1197 | + for ($this->_parsePos = 0; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 1198 | + |
|
| 1199 | + // get the action to do |
|
| 1200 | + $action = $this->parsingHtml->code[$this->_parsePos]; |
|
| 1201 | + |
|
| 1202 | + // if it is a opening of table / ul / ol |
|
| 1203 | + if (in_array($action['name'], array('table', 'ul', 'ol')) && ! $action['close']) { |
|
| 1204 | + |
|
| 1205 | + // we will work as a sub HTML to calculate the size of the element |
|
| 1206 | + $this->_subPart = true; |
|
| 1207 | + |
|
| 1208 | + // get the name of the opening tag |
|
| 1209 | + $tagOpen = $action['name']; |
|
| 1210 | + |
|
| 1211 | + // save the actual pos on the parsing |
|
| 1212 | + $this->_tempPos = $this->_parsePos; |
|
| 1213 | + |
|
| 1214 | + // foreach elements, while we are in the opened tag |
|
| 1215 | + while (isset($this->parsingHtml->code[$this->_tempPos]) && ! ($this->parsingHtml->code[$this->_tempPos]['name'] == $tagOpen && $this->parsingHtml->code[$this->_tempPos]['close'])) { |
|
| 1216 | + // make the action |
|
| 1217 | + $this->_executeAction($this->parsingHtml->code[$this->_tempPos]); |
|
| 1218 | + $this->_tempPos++; |
|
| 1219 | + } |
|
| 1220 | + |
|
| 1221 | + // execute the closure of the tag |
|
| 1222 | + if (isset($this->parsingHtml->code[$this->_tempPos])) { |
|
| 1223 | + $this->_executeAction($this->parsingHtml->code[$this->_tempPos]); |
|
| 1224 | + } |
|
| 1225 | + |
|
| 1226 | + // end of the sub part |
|
| 1227 | + $this->_subPart = false; |
|
| 1228 | + } |
|
| 1229 | + |
|
| 1230 | + // execute the action |
|
| 1231 | + $this->_executeAction($action); |
|
| 1232 | + } |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + /** |
|
| 1236 | + * execute the action from the parsing |
|
| 1237 | + * |
|
| 1238 | + * @access protected |
|
| 1239 | + * @param array $action |
|
| 1240 | + */ |
|
| 1241 | + protected function _executeAction($action) |
|
| 1242 | + { |
|
| 1243 | + // name of the action |
|
| 1244 | + $fnc = ($action['close'] ? '_tag_close_' : '_tag_open_').strtoupper($action['name']); |
|
| 1245 | + |
|
| 1246 | + // parameters of the action |
|
| 1247 | + $param = $action['param']; |
|
| 1248 | + |
|
| 1249 | + // if it the first action of the first page, and if it is not a open tag of PAGE => create the new page |
|
| 1250 | + if ($fnc != '_tag_open_PAGE' && $this->_firstPage) { |
|
| 1251 | + $this->_setNewPage(); |
|
| 1252 | + } |
|
| 1253 | + |
|
| 1254 | + // the action must exist |
|
| 1255 | + if ( ! is_callable(array(&$this, $fnc))) { |
|
| 1256 | + throw new HTML2PDF_exception(1, strtoupper($action['name']), $this->parsingHtml->getHtmlErrorCode($action['html_pos'])); |
|
| 1257 | + } |
|
| 1258 | + |
|
| 1259 | + // lauch the action |
|
| 1260 | + $res = $this->{$fnc}($param); |
|
| 1261 | + |
|
| 1262 | + // save the name of the action |
|
| 1263 | + $this->_previousCall = $fnc; |
|
| 1264 | + |
|
| 1265 | + // return the result |
|
| 1266 | + return $res; |
|
| 1267 | + } |
|
| 1268 | + |
|
| 1269 | + /** |
|
| 1270 | + * get the position of the element on the current line, depending on his height |
|
| 1271 | + * |
|
| 1272 | + * @access protected |
|
| 1273 | + * @param float $h |
|
| 1274 | + * @return float |
|
| 1275 | + */ |
|
| 1276 | + protected function _getElementY($h) |
|
| 1277 | + { |
|
| 1278 | + if ($this->_subPart || $this->_isSubPart || ! $this->_currentH || $this->_currentH < $h) |
|
| 1279 | + return 0; |
|
| 1280 | + |
|
| 1281 | + return ($this->_currentH - $h) * 0.8; |
|
| 1282 | + } |
|
| 1283 | + |
|
| 1284 | + /** |
|
| 1285 | + * make a break line |
|
| 1286 | + * |
|
| 1287 | + * @access protected |
|
| 1288 | + * @param float $h current line height |
|
| 1289 | + * @param integer $curr real current position in the text, if new line in the write of a text |
|
| 1290 | + */ |
|
| 1291 | + protected function _makeBreakLine($h, $curr = null) |
|
| 1292 | + { |
|
| 1293 | + if ($h) { |
|
| 1294 | + if (($this->pdf->getY() + $h < $this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter) |
|
| 1295 | + $this->_setNewLine($h, $curr); |
|
| 1296 | + else |
|
| 1297 | + $this->_setNewPage(null, '', null, $curr); |
|
| 1298 | + } else { |
|
| 1299 | + $this->_setNewPositionForNewLine($curr); |
|
| 1300 | + } |
|
| 1301 | + |
|
| 1302 | + $this->_maxH = 0; |
|
| 1303 | + $this->_maxE = 0; |
|
| 1304 | + } |
|
| 1305 | + |
|
| 1306 | + /** |
|
| 1307 | + * display a image |
|
| 1308 | + * |
|
| 1309 | + * @access protected |
|
| 1310 | + * @param string $src |
|
| 1311 | + * @param boolean $subLi if true=image of a list |
|
| 1312 | + * @return boolean depending on "isForOneLine" |
|
| 1313 | + */ |
|
| 1314 | + protected function _drawImage($src, $subLi = false) |
|
| 1315 | + { |
|
| 1316 | + // get the size of the image |
|
| 1317 | + // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini |
|
| 1318 | + |
|
| 1319 | + $infos = @getimagesize($src); |
|
| 1320 | + |
|
| 1321 | + // if the image does not exist, or can not be loaded |
|
| 1322 | + if (count($infos) < 2) { |
|
| 1323 | + // if the test is activ => exception |
|
| 1324 | + if ($this->_testIsImage) { |
|
| 1325 | + throw new HTML2PDF_exception(6, $src); |
|
| 1326 | + } |
|
| 1327 | + |
|
| 1328 | + // else, display a gray rectangle |
|
| 1329 | + $src = null; |
|
| 1330 | + $infos = array(16, 16); |
|
| 1331 | + } |
|
| 1332 | + |
|
| 1333 | + // convert the size of the image in the unit of the PDF |
|
| 1334 | + $imageWidth = $infos[0] / $this->pdf->getK(); |
|
| 1335 | + $imageHeight = $infos[1] / $this->pdf->getK(); |
|
| 1336 | + |
|
| 1337 | + // calculate the size from the css style |
|
| 1338 | + if ($this->parsingCss->value['width'] && $this->parsingCss->value['height']) { |
|
| 1339 | + $w = $this->parsingCss->value['width']; |
|
| 1340 | + $h = $this->parsingCss->value['height']; |
|
| 1341 | + } else if ($this->parsingCss->value['width']) { |
|
| 1342 | + $w = $this->parsingCss->value['width']; |
|
| 1343 | + $h = $imageHeight * $w / $imageWidth; |
|
| 1344 | + } else if ($this->parsingCss->value['height']) { |
|
| 1345 | + $h = $this->parsingCss->value['height']; |
|
| 1346 | + $w = $imageWidth * $h / $imageHeight; |
|
| 1347 | + } else { |
|
| 1348 | + // convert px to pt |
|
| 1349 | + $w = 72. / 96. * $imageWidth; |
|
| 1350 | + $h = 72. / 96. * $imageHeight; |
|
| 1351 | + } |
|
| 1352 | + |
|
| 1353 | + // are we in a float |
|
| 1354 | + $float = $this->parsingCss->getFloat(); |
|
| 1355 | + |
|
| 1356 | + // if we are in a float, but if something else if on the line => Break Line |
|
| 1357 | + if ($float && $this->_maxH) { |
|
| 1358 | + // make the break line (false if we are in "_isForOneLine" mode) |
|
| 1359 | + if ( ! $this->_tag_open_BR(array())) { |
|
| 1360 | + return false; |
|
| 1361 | + } |
|
| 1362 | + } |
|
| 1363 | + |
|
| 1364 | + // position of the image |
|
| 1365 | + $x = $this->pdf->getX(); |
|
| 1366 | + $y = $this->pdf->getY(); |
|
| 1367 | + |
|
| 1368 | + // if the image can not be put on the current line => new line |
|
| 1369 | + if ( ! $float && ($x + $w > $this->pdf->getW() - $this->pdf->getrMargin()) && $this->_maxH) { |
|
| 1370 | + if ($this->_isForOneLine) { |
|
| 1371 | + return false; |
|
| 1372 | + } |
|
| 1373 | + |
|
| 1374 | + // set the new line |
|
| 1375 | + $hnl = max($this->_maxH, $this->parsingCss->getLineHeight()); |
|
| 1376 | + $this->_setNewLine($hnl); |
|
| 1377 | + |
|
| 1378 | + // get the new position |
|
| 1379 | + $x = $this->pdf->getX(); |
|
| 1380 | + $y = $this->pdf->getY(); |
|
| 1381 | + } |
|
| 1382 | + |
|
| 1383 | + // if the image can not be put on the current page |
|
| 1384 | + if (($y + $h > $this->pdf->getH() - $this->pdf->getbMargin()) && ! $this->_isInOverflow) { |
|
| 1385 | + // new page |
|
| 1386 | + $this->_setNewPage(); |
|
| 1387 | + |
|
| 1388 | + // get the new position |
|
| 1389 | + $x = $this->pdf->getX(); |
|
| 1390 | + $y = $this->pdf->getY(); |
|
| 1391 | + } |
|
| 1392 | + |
|
| 1393 | + // correction for display the image of a list |
|
| 1394 | + $hT = 0.80 * $this->parsingCss->value['font-size']; |
|
| 1395 | + if ($subLi && $h < $hT) { |
|
| 1396 | + $y += ($hT - $h); |
|
| 1397 | + } |
|
| 1398 | + |
|
| 1399 | + // add the margin top |
|
| 1400 | + $yc = $y - $this->parsingCss->value['margin']['t']; |
|
| 1401 | + |
|
| 1402 | + // get the width and the position of the parent |
|
| 1403 | + $old = $this->parsingCss->getOldValues(); |
|
| 1404 | + if ($old['width']) { |
|
| 1405 | + $parentWidth = $old['width']; |
|
| 1406 | + $parentX = $x; |
|
| 1407 | + } else { |
|
| 1408 | + $parentWidth = $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 1409 | + $parentX = $this->pdf->getlMargin(); |
|
| 1410 | + } |
|
| 1411 | + |
|
| 1412 | + // if we are in a gloat => adapt the parent position and width |
|
| 1413 | + if ($float) { |
|
| 1414 | + list($lx, $rx) = $this->_getMargins($yc); |
|
| 1415 | + $parentX = $lx; |
|
| 1416 | + $parentWidth = $rx - $lx; |
|
| 1417 | + } |
|
| 1418 | + |
|
| 1419 | + // calculate the position of the image, if align to the right |
|
| 1420 | + if ($parentWidth > $w && $float != 'left') { |
|
| 1421 | + if ($float == 'right' || $this->parsingCss->value['text-align'] == 'li_right') $x = $parentX + $parentWidth - $w - $this->parsingCss->value['margin']['r'] - $this->parsingCss->value['margin']['l']; |
|
| 1422 | + } |
|
| 1423 | + |
|
| 1424 | + // display the image |
|
| 1425 | + if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 1426 | + if ($src) { |
|
| 1427 | + $this->pdf->Image($src, $x, $y, $w, $h, '', $this->_isInLink); |
|
| 1428 | + } else { |
|
| 1429 | + // rectangle if the image can not be loaded |
|
| 1430 | + $this->pdf->setFillColorArray(array(240, 220, 220)); |
|
| 1431 | + $this->pdf->Rect($x, $y, $w, $h, 'F'); |
|
| 1432 | + } |
|
| 1433 | + } |
|
| 1434 | + |
|
| 1435 | + // apply the margins |
|
| 1436 | + $x -= $this->parsingCss->value['margin']['l']; |
|
| 1437 | + $y -= $this->parsingCss->value['margin']['t']; |
|
| 1438 | + $w += $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['margin']['r']; |
|
| 1439 | + $h += $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['margin']['b']; |
|
| 1440 | + |
|
| 1441 | + if ($float == 'left') { |
|
| 1442 | + // save the current max |
|
| 1443 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 1444 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 1445 | + |
|
| 1446 | + // add the image to the margins |
|
| 1447 | + $this->_addMargins($float, $x, $y, $x + $w, $y + $h); |
|
| 1448 | + |
|
| 1449 | + // get the new position |
|
| 1450 | + list($lx, $rx) = $this->_getMargins($yc); |
|
| 1451 | + $this->pdf->setXY($lx, $yc); |
|
| 1452 | + } else if ($float == 'right') { |
|
| 1453 | + // save the current max. We don't save the X because it is not the real max of the line |
|
| 1454 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 1455 | + |
|
| 1456 | + // add the image to the margins |
|
| 1457 | + $this->_addMargins($float, $x, $y, $x + $w, $y + $h); |
|
| 1458 | + |
|
| 1459 | + // get the new position |
|
| 1460 | + list($lx, $rx) = $this->_getMargins($yc); |
|
| 1461 | + $this->pdf->setXY($lx, $yc); |
|
| 1462 | + } else { |
|
| 1463 | + // set the new position at the end of the image |
|
| 1464 | + $this->pdf->setX($x + $w); |
|
| 1465 | + |
|
| 1466 | + // save the current max |
|
| 1467 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 1468 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 1469 | + $this->_maxH = max($this->_maxH, $h); |
|
| 1470 | + } |
|
| 1471 | + |
|
| 1472 | + return true; |
|
| 1473 | + } |
|
| 1474 | + |
|
| 1475 | + /** |
|
| 1476 | + * draw a rectangle |
|
| 1477 | + * |
|
| 1478 | + * @access protected |
|
| 1479 | + * @param float $x |
|
| 1480 | + * @param float $y |
|
| 1481 | + * @param float $w |
|
| 1482 | + * @param float $h |
|
| 1483 | + * @param array $border |
|
| 1484 | + * @param float $padding - internal marge of the rectanble => not used, but... |
|
| 1485 | + * @param float $margin - external marge of the rectanble |
|
| 1486 | + * @param array $background |
|
| 1487 | + * @return boolean |
|
| 1488 | + */ |
|
| 1489 | + protected function _drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background) |
|
| 1490 | + { |
|
| 1491 | + // if we are in a subpart or if height is null => return false |
|
| 1492 | + if ($this->_subPart || $this->_isSubPart || $h === null) return false; |
|
| 1493 | + |
|
| 1494 | + // add the margin |
|
| 1495 | + $x += $margin; |
|
| 1496 | + $y += $margin; |
|
| 1497 | + $w -= $margin * 2; |
|
| 1498 | + $h -= $margin * 2; |
|
| 1499 | + |
|
| 1500 | + // get the radius of the border |
|
| 1501 | + $outTL = $border['radius']['tl']; |
|
| 1502 | + $outTR = $border['radius']['tr']; |
|
| 1503 | + $outBR = $border['radius']['br']; |
|
| 1504 | + $outBL = $border['radius']['bl']; |
|
| 1505 | + |
|
| 1506 | + // prepare the out radius |
|
| 1507 | + $outTL = ($outTL[0] && $outTL[1]) ? $outTL : null; |
|
| 1508 | + $outTR = ($outTR[0] && $outTR[1]) ? $outTR : null; |
|
| 1509 | + $outBR = ($outBR[0] && $outBR[1]) ? $outBR : null; |
|
| 1510 | + $outBL = ($outBL[0] && $outBL[1]) ? $outBL : null; |
|
| 1511 | + |
|
| 1512 | + // prepare the in radius |
|
| 1513 | + $inTL = $outTL; |
|
| 1514 | + $inTR = $outTR; |
|
| 1515 | + $inBR = $outBR; |
|
| 1516 | + $inBL = $outBL; |
|
| 1517 | + |
|
| 1518 | + if (is_array($inTL)) { |
|
| 1519 | + $inTL[0] -= $border['l']['width']; |
|
| 1520 | + $inTL[1] -= $border['t']['width']; |
|
| 1521 | + } |
|
| 1522 | + if (is_array($inTR)) { |
|
| 1523 | + $inTR[0] -= $border['r']['width']; |
|
| 1524 | + $inTR[1] -= $border['t']['width']; |
|
| 1525 | + } |
|
| 1526 | + if (is_array($inBR)) { |
|
| 1527 | + $inBR[0] -= $border['r']['width']; |
|
| 1528 | + $inBR[1] -= $border['b']['width']; |
|
| 1529 | + } |
|
| 1530 | + if (is_array($inBL)) { |
|
| 1531 | + $inBL[0] -= $border['l']['width']; |
|
| 1532 | + $inBL[1] -= $border['b']['width']; |
|
| 1533 | + } |
|
| 1534 | + |
|
| 1535 | + if ($inTL[0] <= 0 || $inTL[1] <= 0) $inTL = null; |
|
| 1536 | + if ($inTR[0] <= 0 || $inTR[1] <= 0) $inTR = null; |
|
| 1537 | + if ($inBR[0] <= 0 || $inBR[1] <= 0) $inBR = null; |
|
| 1538 | + if ($inBL[0] <= 0 || $inBL[1] <= 0) $inBL = null; |
|
| 1539 | + |
|
| 1540 | + // prepare the background color |
|
| 1541 | + $pdfStyle = ''; |
|
| 1542 | + if ($background['color']) { |
|
| 1543 | + $this->pdf->setFillColorArray($background['color']); |
|
| 1544 | + $pdfStyle .= 'F'; |
|
| 1545 | + } |
|
| 1546 | + |
|
| 1547 | + // if we have a background to fill => fill it with a path (because of the radius) |
|
| 1548 | + if ($pdfStyle) { |
|
| 1549 | + $this->pdf->clippingPathStart($x, $y, $w, $h, $outTL, $outTR, $outBL, $outBR); |
|
| 1550 | + $this->pdf->Rect($x, $y, $w, $h, $pdfStyle); |
|
| 1551 | + $this->pdf->clippingPathStop(); |
|
| 1552 | + } |
|
| 1553 | + |
|
| 1554 | + // prepare the background image |
|
| 1555 | + if ($background['image']) { |
|
| 1556 | + $iName = $background['image']; |
|
| 1557 | + $iPosition = $background['position'] !== null ? $background['position'] : array(0, 0); |
|
| 1558 | + $iRepeat = $background['repeat'] !== null ? $background['repeat'] : array(true, true); |
|
| 1559 | + |
|
| 1560 | + // size of the background without the borders |
|
| 1561 | + $bX = $x; |
|
| 1562 | + $bY = $y; |
|
| 1563 | + $bW = $w; |
|
| 1564 | + $bH = $h; |
|
| 1565 | + |
|
| 1566 | + if ($border['b']['width']) { |
|
| 1567 | + $bH -= $border['b']['width']; |
|
| 1568 | + } |
|
| 1569 | + if ($border['l']['width']) { |
|
| 1570 | + $bW -= $border['l']['width']; |
|
| 1571 | + $bX += $border['l']['width']; |
|
| 1572 | + } |
|
| 1573 | + if ($border['t']['width']) { |
|
| 1574 | + $bH -= $border['t']['width']; |
|
| 1575 | + $bY += $border['t']['width']; |
|
| 1576 | + } |
|
| 1577 | + if ($border['r']['width']) { |
|
| 1578 | + $bW -= $border['r']['width']; |
|
| 1579 | + } |
|
| 1580 | + |
|
| 1581 | + // get the size of the image |
|
| 1582 | + // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini |
|
| 1583 | + $imageInfos = @getimagesize($iName); |
|
| 1584 | + |
|
| 1585 | + // if the image can not be loaded |
|
| 1586 | + if (count($imageInfos) < 2) { |
|
| 1587 | + if ($this->_testIsImage) { |
|
| 1588 | + throw new HTML2PDF_exception(6, $iName); |
|
| 1589 | + } |
|
| 1590 | + } else { |
|
| 1591 | + // convert the size of the image from pixel to the unit of the PDF |
|
| 1592 | + $imageWidth = 72. / 96. * $imageInfos[0] / $this->pdf->getK(); |
|
| 1593 | + $imageHeight = 72. / 96. * $imageInfos[1] / $this->pdf->getK(); |
|
| 1594 | + |
|
| 1595 | + // prepare the position of the backgroung |
|
| 1596 | + if ($iRepeat[0]) $iPosition[0] = $bX; |
|
| 1597 | + else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1] * ($bW - $imageWidth) / 100; |
|
| 1598 | + else $iPosition[0] = $bX + $iPosition[0]; |
|
| 1599 | + |
|
| 1600 | + if ($iRepeat[1]) $iPosition[1] = $bY; |
|
| 1601 | + else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1] * ($bH - $imageHeight) / 100; |
|
| 1602 | + else $iPosition[1] = $bY + $iPosition[1]; |
|
| 1603 | + |
|
| 1604 | + $imageXmin = $bX; |
|
| 1605 | + $imageXmax = $bX + $bW; |
|
| 1606 | + $imageYmin = $bY; |
|
| 1607 | + $imageYmax = $bY + $bH; |
|
| 1608 | + |
|
| 1609 | + if ( ! $iRepeat[0] && ! $iRepeat[1]) { |
|
| 1610 | + $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0] + $imageWidth; |
|
| 1611 | + $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1] + $imageHeight; |
|
| 1612 | + } else if ($iRepeat[0] && ! $iRepeat[1]) { |
|
| 1613 | + $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1] + $imageHeight; |
|
| 1614 | + } else if ( ! $iRepeat[0] && $iRepeat[1]) { |
|
| 1615 | + $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0] + $imageWidth; |
|
| 1616 | + } |
|
| 1617 | + |
|
| 1618 | + // build the path to display the image (because of radius) |
|
| 1619 | + $this->pdf->clippingPathStart($bX, $bY, $bW, $bH, $inTL, $inTR, $inBL, $inBR); |
|
| 1620 | + |
|
| 1621 | + // repeat the image |
|
| 1622 | + for ($iY = $imageYmin; $iY < $imageYmax; $iY += $imageHeight) { |
|
| 1623 | + for ($iX = $imageXmin; $iX < $imageXmax; $iX += $imageWidth) { |
|
| 1624 | + $cX = null; |
|
| 1625 | + $cY = null; |
|
| 1626 | + $cW = $imageWidth; |
|
| 1627 | + $cH = $imageHeight; |
|
| 1628 | + if ($imageYmax - $iY < $imageHeight) { |
|
| 1629 | + $cX = $iX; |
|
| 1630 | + $cY = $iY; |
|
| 1631 | + $cH = $imageYmax - $iY; |
|
| 1632 | + } |
|
| 1633 | + if ($imageXmax - $iX < $imageWidth) { |
|
| 1634 | + $cX = $iX; |
|
| 1635 | + $cY = $iY; |
|
| 1636 | + $cW = $imageXmax - $iX; |
|
| 1637 | + } |
|
| 1638 | + |
|
| 1639 | + $this->pdf->Image($iName, $iX, $iY, $imageWidth, $imageHeight, '', ''); |
|
| 1640 | + } |
|
| 1641 | + } |
|
| 1642 | + |
|
| 1643 | + // end of the path |
|
| 1644 | + $this->pdf->clippingPathStop(); |
|
| 1645 | + } |
|
| 1646 | + } |
|
| 1647 | + |
|
| 1648 | + // adding some loose (0.01mm) |
|
| 1649 | + $loose = 0.01; |
|
| 1650 | + $x -= $loose; |
|
| 1651 | + $y -= $loose; |
|
| 1652 | + $w += 2. * $loose; |
|
| 1653 | + $h += 2. * $loose; |
|
| 1654 | + if ($border['l']['width']) $border['l']['width'] += 2. * $loose; |
|
| 1655 | + if ($border['t']['width']) $border['t']['width'] += 2. * $loose; |
|
| 1656 | + if ($border['r']['width']) $border['r']['width'] += 2. * $loose; |
|
| 1657 | + if ($border['b']['width']) $border['b']['width'] += 2. * $loose; |
|
| 1658 | + |
|
| 1659 | + // prepare the test on borders |
|
| 1660 | + $testBl = ($border['l']['width'] && $border['l']['color'][0] !== null); |
|
| 1661 | + $testBt = ($border['t']['width'] && $border['t']['color'][0] !== null); |
|
| 1662 | + $testBr = ($border['r']['width'] && $border['r']['color'][0] !== null); |
|
| 1663 | + $testBb = ($border['b']['width'] && $border['b']['color'][0] !== null); |
|
| 1664 | + |
|
| 1665 | + // draw the radius bottom-left |
|
| 1666 | + if (is_array($outBL) && ($testBb || $testBl)) { |
|
| 1667 | + if ($inBL) { |
|
| 1668 | + $courbe = array(); |
|
| 1669 | + $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h; |
|
| 1670 | + $courbe[] = $x; $courbe[] = $y + $h - $outBL[1]; |
|
| 1671 | + $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1672 | + $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $h - $outBL[1]; |
|
| 1673 | + $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $outBL[1]; |
|
| 1674 | + } else { |
|
| 1675 | + $courbe = array(); |
|
| 1676 | + $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h; |
|
| 1677 | + $courbe[] = $x; $courbe[] = $y + $h - $outBL[1]; |
|
| 1678 | + $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1679 | + $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $outBL[1]; |
|
| 1680 | + } |
|
| 1681 | + $this->_drawCurve($courbe, $border['l']['color']); |
|
| 1682 | + } |
|
| 1683 | + |
|
| 1684 | + // draw the radius left-top |
|
| 1685 | + if (is_array($outTL) && ($testBt || $testBl)) { |
|
| 1686 | + if ($inTL) { |
|
| 1687 | + $courbe = array(); |
|
| 1688 | + $courbe[] = $x; $courbe[] = $y + $outTL[1]; |
|
| 1689 | + $courbe[] = $x + $outTL[0]; $courbe[] = $y; |
|
| 1690 | + $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $outTL[1]; |
|
| 1691 | + $courbe[] = $x + $outTL[0]; $courbe[] = $y + $border['t']['width']; |
|
| 1692 | + $courbe[] = $x + $outTL[0]; $courbe[] = $y + $outTL[1]; |
|
| 1693 | + } else { |
|
| 1694 | + $courbe = array(); |
|
| 1695 | + $courbe[] = $x; $courbe[] = $y + $outTL[1]; |
|
| 1696 | + $courbe[] = $x + $outTL[0]; $courbe[] = $y; |
|
| 1697 | + $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $border['t']['width']; |
|
| 1698 | + $courbe[] = $x + $outTL[0]; $courbe[] = $y + $outTL[1]; |
|
| 1699 | + } |
|
| 1700 | + $this->_drawCurve($courbe, $border['t']['color']); |
|
| 1701 | + } |
|
| 1702 | + |
|
| 1703 | + // draw the radius top-right |
|
| 1704 | + if (is_array($outTR) && ($testBt || $testBr)) { |
|
| 1705 | + if ($inTR) { |
|
| 1706 | + $courbe = array(); |
|
| 1707 | + $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y; |
|
| 1708 | + $courbe[] = $x + $w; $courbe[] = $y + $outTR[1]; |
|
| 1709 | + $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $border['t']['width']; |
|
| 1710 | + $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $outTR[1]; |
|
| 1711 | + $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $outTR[1]; |
|
| 1712 | + } else { |
|
| 1713 | + $courbe = array(); |
|
| 1714 | + $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y; |
|
| 1715 | + $courbe[] = $x + $w; $courbe[] = $y + $outTR[1]; |
|
| 1716 | + $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $border['t']['width']; |
|
| 1717 | + $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $outTR[1]; |
|
| 1718 | + } |
|
| 1719 | + $this->_drawCurve($courbe, $border['r']['color']); |
|
| 1720 | + } |
|
| 1721 | + |
|
| 1722 | + // draw the radius right-bottom |
|
| 1723 | + if (is_array($outBR) && ($testBb || $testBr)) { |
|
| 1724 | + if ($inBR) { |
|
| 1725 | + $courbe = array(); |
|
| 1726 | + $courbe[] = $x + $w; $courbe[] = $y + $h - $outBR[1]; |
|
| 1727 | + $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h; |
|
| 1728 | + $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $h - $outBR[1]; |
|
| 1729 | + $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1730 | + $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $outBR[1]; |
|
| 1731 | + } else { |
|
| 1732 | + $courbe = array(); |
|
| 1733 | + $courbe[] = $x + $w; $courbe[] = $y + $h - $outBR[1]; |
|
| 1734 | + $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h; |
|
| 1735 | + $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1736 | + $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $outBR[1]; |
|
| 1737 | + } |
|
| 1738 | + $this->_drawCurve($courbe, $border['b']['color']); |
|
| 1739 | + } |
|
| 1740 | + |
|
| 1741 | + // draw the left border |
|
| 1742 | + if ($testBl) { |
|
| 1743 | + $pt = array(); |
|
| 1744 | + $pt[] = $x; $pt[] = $y + $h; |
|
| 1745 | + $pt[] = $x; $pt[] = $y + $h - $border['b']['width']; |
|
| 1746 | + $pt[] = $x; $pt[] = $y + $border['t']['width']; |
|
| 1747 | + $pt[] = $x; $pt[] = $y; |
|
| 1748 | + $pt[] = $x + $border['l']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1749 | + $pt[] = $x + $border['l']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1750 | + |
|
| 1751 | + $bord = 3; |
|
| 1752 | + if (is_array($outBL)) { |
|
| 1753 | + $bord -= 1; |
|
| 1754 | + $pt[3] -= $outBL[1] - $border['b']['width']; |
|
| 1755 | + if ($inBL) $pt[11] -= $inBL[1]; |
|
| 1756 | + unset($pt[0]); unset($pt[1]); |
|
| 1757 | + } |
|
| 1758 | + if (is_array($outTL)) { |
|
| 1759 | + $bord -= 2; |
|
| 1760 | + $pt[5] += $outTL[1] - $border['t']['width']; |
|
| 1761 | + if ($inTL) $pt[9] += $inTL[1]; |
|
| 1762 | + unset($pt[6]); unset($pt[7]); |
|
| 1763 | + } |
|
| 1764 | + |
|
| 1765 | + $pt = array_values($pt); |
|
| 1766 | + $this->_drawLine($pt, $border['l']['color'], $border['l']['type'], $border['l']['width'], $bord); |
|
| 1767 | + } |
|
| 1768 | + |
|
| 1769 | + // draw the top border |
|
| 1770 | + if ($testBt) { |
|
| 1771 | + $pt = array(); |
|
| 1772 | + $pt[] = $x; $pt[] = $y; |
|
| 1773 | + $pt[] = $x + $border['l']['width']; $pt[] = $y; |
|
| 1774 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y; |
|
| 1775 | + $pt[] = $x + $w; $pt[] = $y; |
|
| 1776 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1777 | + $pt[] = $x + $border['l']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1778 | + |
|
| 1779 | + $bord = 3; |
|
| 1780 | + if (is_array($outTL)) { |
|
| 1781 | + $bord -= 1; |
|
| 1782 | + $pt[2] += $outTL[0] - $border['l']['width']; |
|
| 1783 | + if ($inTL) $pt[10] += $inTL[0]; |
|
| 1784 | + unset($pt[0]); unset($pt[1]); |
|
| 1785 | + } |
|
| 1786 | + if (is_array($outTR)) { |
|
| 1787 | + $bord -= 2; |
|
| 1788 | + $pt[4] -= $outTR[0] - $border['r']['width']; |
|
| 1789 | + if ($inTR) $pt[8] -= $inTR[0]; |
|
| 1790 | + unset($pt[6]); unset($pt[7]); |
|
| 1791 | + } |
|
| 1792 | + |
|
| 1793 | + $pt = array_values($pt); |
|
| 1794 | + $this->_drawLine($pt, $border['t']['color'], $border['t']['type'], $border['t']['width'], $bord); |
|
| 1795 | + } |
|
| 1796 | + |
|
| 1797 | + // draw the right border |
|
| 1798 | + if ($testBr) { |
|
| 1799 | + $pt = array(); |
|
| 1800 | + $pt[] = $x + $w; $pt[] = $y; |
|
| 1801 | + $pt[] = $x + $w; $pt[] = $y + $border['t']['width']; |
|
| 1802 | + $pt[] = $x + $w; $pt[] = $y + $h - $border['b']['width']; |
|
| 1803 | + $pt[] = $x + $w; $pt[] = $y + $h; |
|
| 1804 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1805 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1806 | + |
|
| 1807 | + $bord = 3; |
|
| 1808 | + if (is_array($outTR)) { |
|
| 1809 | + $bord -= 1; |
|
| 1810 | + $pt[3] += $outTR[1] - $border['t']['width']; |
|
| 1811 | + if ($inTR) $pt[11] += $inTR[1]; |
|
| 1812 | + unset($pt[0]); unset($pt[1]); |
|
| 1813 | + } |
|
| 1814 | + if (is_array($outBR)) { |
|
| 1815 | + $bord -= 2; |
|
| 1816 | + $pt[5] -= $outBR[1] - $border['b']['width']; |
|
| 1817 | + if ($inBR) $pt[9] -= $inBR[1]; |
|
| 1818 | + unset($pt[6]); unset($pt[7]); |
|
| 1819 | + } |
|
| 1820 | + |
|
| 1821 | + $pt = array_values($pt); |
|
| 1822 | + $this->_drawLine($pt, $border['r']['color'], $border['r']['type'], $border['r']['width'], $bord); |
|
| 1823 | + } |
|
| 1824 | + |
|
| 1825 | + // draw the bottom border |
|
| 1826 | + if ($testBb) { |
|
| 1827 | + $pt = array(); |
|
| 1828 | + $pt[] = $x + $w; $pt[] = $y + $h; |
|
| 1829 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h; |
|
| 1830 | + $pt[] = $x + $border['l']['width']; $pt[] = $y + $h; |
|
| 1831 | + $pt[] = $x; $pt[] = $y + $h; |
|
| 1832 | + $pt[] = $x + $border['l']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1833 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1834 | + |
|
| 1835 | + $bord = 3; |
|
| 1836 | + if (is_array($outBL)) { |
|
| 1837 | + $bord -= 2; |
|
| 1838 | + $pt[4] += $outBL[0] - $border['l']['width']; |
|
| 1839 | + if ($inBL) $pt[8] += $inBL[0]; |
|
| 1840 | + unset($pt[6]); unset($pt[7]); |
|
| 1841 | + } |
|
| 1842 | + if (is_array($outBR)) { |
|
| 1843 | + $bord -= 1; |
|
| 1844 | + $pt[2] -= $outBR[0] - $border['r']['width']; |
|
| 1845 | + if ($inBR) $pt[10] -= $inBR[0]; |
|
| 1846 | + unset($pt[0]); unset($pt[1]); |
|
| 1847 | + |
|
| 1848 | + } |
|
| 1849 | + |
|
| 1850 | + $pt = array_values($pt); |
|
| 1851 | + $this->_drawLine($pt, $border['b']['color'], $border['b']['type'], $border['b']['width'], $bord); |
|
| 1852 | + } |
|
| 1853 | + |
|
| 1854 | + if ($background['color']) { |
|
| 1855 | + $this->pdf->setFillColorArray($background['color']); |
|
| 1856 | + } |
|
| 1857 | + |
|
| 1858 | + return true; |
|
| 1859 | + } |
|
| 1860 | + |
|
| 1861 | + /** |
|
| 1862 | + * draw a curve (for border radius) |
|
| 1863 | + * |
|
| 1864 | + * @access protected |
|
| 1865 | + * @param double[] $pt |
|
| 1866 | + * @param array $color |
|
| 1867 | + */ |
|
| 1868 | + protected function _drawCurve($pt, $color) |
|
| 1869 | + { |
|
| 1870 | + $this->pdf->setFillColorArray($color); |
|
| 1871 | + |
|
| 1872 | + if (count($pt) == 10) |
|
| 1873 | + $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]); |
|
| 1874 | + else |
|
| 1875 | + $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]); |
|
| 1876 | + } |
|
| 1877 | + |
|
| 1878 | + /** |
|
| 1879 | + * draw a ligne with a specific type, and specific start and end for radius |
|
| 1880 | + * |
|
| 1881 | + * @access protected |
|
| 1882 | + * @param array $pt |
|
| 1883 | + * @param float $color |
|
| 1884 | + * @param string $type (dashed, dotted, double, solid) |
|
| 1885 | + * @param float $width |
|
| 1886 | + * @param integer $radius (binary from 0 to 3 with 1=>start with a radius, 2=>end with a radius) |
|
| 1887 | + */ |
|
| 1888 | + protected function _drawLine($pt, $color, $type, $width, $radius = 3) |
|
| 1889 | + { |
|
| 1890 | + // set the fill color |
|
| 1891 | + $this->pdf->setFillColorArray($color); |
|
| 1892 | + |
|
| 1893 | + // if dashed or dotted |
|
| 1894 | + if ($type == 'dashed' || $type == 'dotted') { |
|
| 1895 | + |
|
| 1896 | + // clean the end of the line, if radius |
|
| 1897 | + if ($radius == 1) { |
|
| 1898 | + $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; |
|
| 1899 | + $this->pdf->Polygon($tmp, 'F'); |
|
| 1900 | + |
|
| 1901 | + $tmp = array(); $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; |
|
| 1902 | + $pt = $tmp; |
|
| 1903 | + } else if ($radius == 2) { |
|
| 1904 | + $tmp = array(); $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; |
|
| 1905 | + $this->pdf->Polygon($tmp, 'F'); |
|
| 1906 | + |
|
| 1907 | + $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; |
|
| 1908 | + $pt = $tmp; |
|
| 1909 | + } else if ($radius == 3) { |
|
| 1910 | + $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[10]; $tmp[] = $pt[11]; |
|
| 1911 | + $this->pdf->Polygon($tmp, 'F'); |
|
| 1912 | + |
|
| 1913 | + $tmp = array(); $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; |
|
| 1914 | + $this->pdf->Polygon($tmp, 'F'); |
|
| 1915 | + |
|
| 1916 | + $tmp = array(); $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; $tmp[] = $pt[10]; $tmp[] = $pt[11]; |
|
| 1917 | + $pt = $tmp; |
|
| 1918 | + } |
|
| 1919 | + |
|
| 1920 | + // horisontal or vertical line |
|
| 1921 | + if ($pt[2] == $pt[0]) { |
|
| 1922 | + $l = abs(($pt[3] - $pt[1]) * 0.5); |
|
| 1923 | + $px = 0; |
|
| 1924 | + $py = $width; |
|
| 1925 | + $x1 = $pt[0]; $y1 = ($pt[3] + $pt[1]) * 0.5; |
|
| 1926 | + $x2 = $pt[6]; $y2 = ($pt[7] + $pt[5]) * 0.5; |
|
| 1927 | + } else { |
|
| 1928 | + $l = abs(($pt[2] - $pt[0]) * 0.5); |
|
| 1929 | + $px = $width; |
|
| 1930 | + $py = 0; |
|
| 1931 | + $x1 = ($pt[2] + $pt[0]) * 0.5; $y1 = $pt[1]; |
|
| 1932 | + $x2 = ($pt[6] + $pt[4]) * 0.5; $y2 = $pt[7]; |
|
| 1933 | + } |
|
| 1934 | + |
|
| 1935 | + // if dashed : 3x bigger than dotted |
|
| 1936 | + if ($type == 'dashed') { |
|
| 1937 | + $px = $px * 3.; |
|
| 1938 | + $py = $py * 3.; |
|
| 1939 | + } |
|
| 1940 | + $mode = ($l / ($px + $py) < .5); |
|
| 1941 | + |
|
| 1942 | + // display the dotted/dashed line |
|
| 1943 | + for ($i = 0; $l - ($px + $py) * ($i - 0.5) > 0; $i++) { |
|
| 1944 | + if (($i % 2) == $mode) { |
|
| 1945 | + $j = $i - 0.5; |
|
| 1946 | + $lx1 = $px * ($j); if ($lx1 < -$l) $lx1 = -$l; |
|
| 1947 | + $ly1 = $py * ($j); if ($ly1 < -$l) $ly1 = -$l; |
|
| 1948 | + $lx2 = $px * ($j + 1); if ($lx2 > $l) $lx2 = $l; |
|
| 1949 | + $ly2 = $py * ($j + 1); if ($ly2 > $l) $ly2 = $l; |
|
| 1950 | + |
|
| 1951 | + $tmp = array(); |
|
| 1952 | + $tmp[] = $x1 + $lx1; $tmp[] = $y1 + $ly1; |
|
| 1953 | + $tmp[] = $x1 + $lx2; $tmp[] = $y1 + $ly2; |
|
| 1954 | + $tmp[] = $x2 + $lx2; $tmp[] = $y2 + $ly2; |
|
| 1955 | + $tmp[] = $x2 + $lx1; $tmp[] = $y2 + $ly1; |
|
| 1956 | + $this->pdf->Polygon($tmp, 'F'); |
|
| 1957 | + |
|
| 1958 | + if ($j > 0) { |
|
| 1959 | + $tmp = array(); |
|
| 1960 | + $tmp[] = $x1 - $lx1; $tmp[] = $y1 - $ly1; |
|
| 1961 | + $tmp[] = $x1 - $lx2; $tmp[] = $y1 - $ly2; |
|
| 1962 | + $tmp[] = $x2 - $lx2; $tmp[] = $y2 - $ly2; |
|
| 1963 | + $tmp[] = $x2 - $lx1; $tmp[] = $y2 - $ly1; |
|
| 1964 | + $this->pdf->Polygon($tmp, 'F'); |
|
| 1965 | + } |
|
| 1966 | + } |
|
| 1967 | + } |
|
| 1968 | + } else if ($type == 'double') { |
|
| 1969 | + |
|
| 1970 | + // if double, 2 lines : 0=>1/3 and 2/3=>1 |
|
| 1971 | + $pt1 = $pt; |
|
| 1972 | + $pt2 = $pt; |
|
| 1973 | + |
|
| 1974 | + if (count($pt) == 12) { |
|
| 1975 | + // line 1 |
|
| 1976 | + $pt1[0] = ($pt[0] - $pt[10]) * 0.33 + $pt[10]; |
|
| 1977 | + $pt1[1] = ($pt[1] - $pt[11]) * 0.33 + $pt[11]; |
|
| 1978 | + $pt1[2] = ($pt[2] - $pt[10]) * 0.33 + $pt[10]; |
|
| 1979 | + $pt1[3] = ($pt[3] - $pt[11]) * 0.33 + $pt[11]; |
|
| 1980 | + $pt1[4] = ($pt[4] - $pt[8]) * 0.33 + $pt[8]; |
|
| 1981 | + $pt1[5] = ($pt[5] - $pt[9]) * 0.33 + $pt[9]; |
|
| 1982 | + $pt1[6] = ($pt[6] - $pt[8]) * 0.33 + $pt[8]; |
|
| 1983 | + $pt1[7] = ($pt[7] - $pt[9]) * 0.33 + $pt[9]; |
|
| 1984 | + $pt2[10] = ($pt[10] - $pt[0]) * 0.33 + $pt[0]; |
|
| 1985 | + $pt2[11] = ($pt[11] - $pt[1]) * 0.33 + $pt[1]; |
|
| 1986 | + |
|
| 1987 | + // line 2 |
|
| 1988 | + $pt2[2] = ($pt[2] - $pt[0]) * 0.33 + $pt[0]; |
|
| 1989 | + $pt2[3] = ($pt[3] - $pt[1]) * 0.33 + $pt[1]; |
|
| 1990 | + $pt2[4] = ($pt[4] - $pt[6]) * 0.33 + $pt[6]; |
|
| 1991 | + $pt2[5] = ($pt[5] - $pt[7]) * 0.33 + $pt[7]; |
|
| 1992 | + $pt2[8] = ($pt[8] - $pt[6]) * 0.33 + $pt[6]; |
|
| 1993 | + $pt2[9] = ($pt[9] - $pt[7]) * 0.33 + $pt[7]; |
|
| 1994 | + } else { |
|
| 1995 | + // line 1 |
|
| 1996 | + $pt1[0] = ($pt[0] - $pt[6]) * 0.33 + $pt[6]; |
|
| 1997 | + $pt1[1] = ($pt[1] - $pt[7]) * 0.33 + $pt[7]; |
|
| 1998 | + $pt1[2] = ($pt[2] - $pt[4]) * 0.33 + $pt[4]; |
|
| 1999 | + $pt1[3] = ($pt[3] - $pt[5]) * 0.33 + $pt[5]; |
|
| 2000 | + |
|
| 2001 | + // line 2 |
|
| 2002 | + $pt2[6] = ($pt[6] - $pt[0]) * 0.33 + $pt[0]; |
|
| 2003 | + $pt2[7] = ($pt[7] - $pt[1]) * 0.33 + $pt[1]; |
|
| 2004 | + $pt2[4] = ($pt[4] - $pt[2]) * 0.33 + $pt[2]; |
|
| 2005 | + $pt2[5] = ($pt[5] - $pt[3]) * 0.33 + $pt[3]; |
|
| 2006 | + } |
|
| 2007 | + $this->pdf->Polygon($pt1, 'F'); |
|
| 2008 | + $this->pdf->Polygon($pt2, 'F'); |
|
| 2009 | + } else if ($type == 'solid') { |
|
| 2010 | + // solid line : draw directly the polygon |
|
| 2011 | + $this->pdf->Polygon($pt, 'F'); |
|
| 2012 | + } |
|
| 2013 | + } |
|
| 2014 | + |
|
| 2015 | + /** |
|
| 2016 | + * prepare a transform matrix, only for drawing a SVG graphic |
|
| 2017 | + * |
|
| 2018 | + * @access protected |
|
| 2019 | + * @param string $transform |
|
| 2020 | + * @return array $matrix |
|
| 2021 | + */ |
|
| 2022 | + protected function _prepareTransform($transform) |
|
| 2023 | + { |
|
| 2024 | + // it can not be empty |
|
| 2025 | + if ( ! $transform) return null; |
|
| 2026 | + |
|
| 2027 | + // sctions must be like scale(...) |
|
| 2028 | + if ( ! preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null; |
|
| 2029 | + |
|
| 2030 | + // prepare the list of the actions |
|
| 2031 | + $actions = array(); |
|
| 2032 | + |
|
| 2033 | + // for actions |
|
| 2034 | + for ($k = 0; $k < count($match[0]); $k++) { |
|
| 2035 | + |
|
| 2036 | + // get the name of the action |
|
| 2037 | + $name = strtolower($match[1][$k]); |
|
| 2038 | + |
|
| 2039 | + // get the parameters of the action |
|
| 2040 | + $val = explode(',', trim($match[2][$k])); |
|
| 2041 | + foreach ($val as $i => $j) { |
|
| 2042 | + $val[$i] = trim($j); |
|
| 2043 | + } |
|
| 2044 | + |
|
| 2045 | + // prepare the matrix, depending on the action |
|
| 2046 | + switch ($name) |
|
| 2047 | + { |
|
| 2048 | + case 'scale': |
|
| 2049 | + if ( ! isset($val[0])) $val[0] = 1.; else $val[0] = 1. * $val[0]; |
|
| 2050 | + if ( ! isset($val[1])) $val[1] = $val[0]; else $val[1] = 1. * $val[1]; |
|
| 2051 | + $actions[] = array($val[0], 0, 0, $val[1], 0, 0); |
|
| 2052 | + break; |
|
| 2053 | + |
|
| 2054 | + case 'translate': |
|
| 2055 | + if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']); |
|
| 2056 | + if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']); |
|
| 2057 | + $actions[] = array(1, 0, 0, 1, $val[0], $val[1]); |
|
| 2058 | + break; |
|
| 2059 | + |
|
| 2060 | + case 'rotate': |
|
| 2061 | + if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2062 | + if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']); |
|
| 2063 | + if ( ! isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']); |
|
| 2064 | + if ($val[1] || $val[2]) $actions[] = array(1, 0, 0, 1, -$val[1], -$val[2]); |
|
| 2065 | + $actions[] = array(cos($val[0]), sin($val[0]), -sin($val[0]), cos($val[0]), 0, 0); |
|
| 2066 | + if ($val[1] || $val[2]) $actions[] = array(1, 0, 0, 1, $val[1], $val[2]); |
|
| 2067 | + break; |
|
| 2068 | + |
|
| 2069 | + case 'skewx': |
|
| 2070 | + if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2071 | + $actions[] = array(1, 0, tan($val[0]), 1, 0, 0); |
|
| 2072 | + break; |
|
| 2073 | + |
|
| 2074 | + case 'skewy': |
|
| 2075 | + if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2076 | + $actions[] = array(1, tan($val[0]), 0, 1, 0, 0); |
|
| 2077 | + break; |
|
| 2078 | + case 'matrix': |
|
| 2079 | + if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * 1.; |
|
| 2080 | + if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $val[1] * 1.; |
|
| 2081 | + if ( ! isset($val[2])) $val[2] = 0.; else $val[2] = $val[2] * 1.; |
|
| 2082 | + if ( ! isset($val[3])) $val[3] = 0.; else $val[3] = $val[3] * 1.; |
|
| 2083 | + if ( ! isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']); |
|
| 2084 | + if ( ! isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']); |
|
| 2085 | + $actions[] = $val; |
|
| 2086 | + break; |
|
| 2087 | + } |
|
| 2088 | + } |
|
| 2089 | + |
|
| 2090 | + // if ther is no actions => return |
|
| 2091 | + if ( ! $actions) return null; |
|
| 2092 | + |
|
| 2093 | + // get the first matrix |
|
| 2094 | + $m = $actions[0]; unset($actions[0]); |
|
| 2095 | + |
|
| 2096 | + // foreach matrix => multiply to the last matrix |
|
| 2097 | + foreach ($actions as $n) { |
|
| 2098 | + $m = array( |
|
| 2099 | + $m[0] * $n[0] + $m[2] * $n[1], |
|
| 2100 | + $m[1] * $n[0] + $m[3] * $n[1], |
|
| 2101 | + $m[0] * $n[2] + $m[2] * $n[3], |
|
| 2102 | + $m[1] * $n[2] + $m[3] * $n[3], |
|
| 2103 | + $m[0] * $n[4] + $m[2] * $n[5] + $m[4], |
|
| 2104 | + $m[1] * $n[4] + $m[3] * $n[5] + $m[5] |
|
| 2105 | + ); |
|
| 2106 | + } |
|
| 2107 | + |
|
| 2108 | + // return the matrix |
|
| 2109 | + return $m; |
|
| 2110 | + } |
|
| 2111 | + |
|
| 2112 | + /** |
|
| 2113 | + * @access protected |
|
| 2114 | + * @param &array $cases |
|
| 2115 | + * @param &array $corr |
|
| 2116 | + */ |
|
| 2117 | + protected function _calculateTableCellSize(&$cases, &$corr) |
|
| 2118 | + { |
|
| 2119 | + if ( ! isset($corr[0])) return true; |
|
| 2120 | + |
|
| 2121 | + // for each cell without colspan, we get the max width for each column |
|
| 2122 | + $sw = array(); |
|
| 2123 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2124 | + $m = 0; |
|
| 2125 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2126 | + if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2] == 1) { |
|
| 2127 | + $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']); |
|
| 2128 | + } |
|
| 2129 | + } |
|
| 2130 | + $sw[$x] = $m; |
|
| 2131 | + } |
|
| 2132 | + |
|
| 2133 | + // for each cell with colspan, we adapt the width of each column |
|
| 2134 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2135 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2136 | + if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2] > 1) { |
|
| 2137 | + |
|
| 2138 | + // sum the max width of each column in colspan |
|
| 2139 | + $s = 0; for ($i = 0; $i < $corr[$y][$x][2]; $i++) $s += $sw[$x + $i]; |
|
| 2140 | + |
|
| 2141 | + // if the max width is < the width of the cell with colspan => we adapt the width of each max width |
|
| 2142 | + if ($s > 0 && $s < $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) { |
|
| 2143 | + for ($i = 0; $i < $corr[$y][$x][2]; $i++) { |
|
| 2144 | + $sw[$x + $i] = $sw[$x + $i] / $s * $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']; |
|
| 2145 | + } |
|
| 2146 | + } |
|
| 2147 | + } |
|
| 2148 | + } |
|
| 2149 | + } |
|
| 2150 | + |
|
| 2151 | + // set the new width, for each cell |
|
| 2152 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2153 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2154 | + if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) { |
|
| 2155 | + // without colspan |
|
| 2156 | + if ($corr[$y][$x][2] == 1) { |
|
| 2157 | + $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $sw[$x]; |
|
| 2158 | + // with colspan |
|
| 2159 | + } else { |
|
| 2160 | + $s = 0; |
|
| 2161 | + for ($i = 0; $i < $corr[$y][$x][2]; $i++) { |
|
| 2162 | + $s += $sw[$x + $i]; |
|
| 2163 | + } |
|
| 2164 | + $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $s; |
|
| 2165 | + } |
|
| 2166 | + } |
|
| 2167 | + } |
|
| 2168 | + } |
|
| 2169 | + |
|
| 2170 | + // for each cell without rowspan, we get the max height for each line |
|
| 2171 | + $sh = array(); |
|
| 2172 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2173 | + $m = 0; |
|
| 2174 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2175 | + if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3] == 1) { |
|
| 2176 | + $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']); |
|
| 2177 | + } |
|
| 2178 | + } |
|
| 2179 | + $sh[$y] = $m; |
|
| 2180 | + } |
|
| 2181 | + |
|
| 2182 | + // for each cell with rowspan, we adapt the height of each line |
|
| 2183 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2184 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2185 | + if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3] > 1) { |
|
| 2186 | + |
|
| 2187 | + // sum the max height of each line in rowspan |
|
| 2188 | + $s = 0; for ($i = 0; $i < $corr[$y][$x][3]; $i++) $s += $sh[$y + $i]; |
|
| 2189 | + |
|
| 2190 | + // if the max height is < the height of the cell with rowspan => we adapt the height of each max height |
|
| 2191 | + if ($s > 0 && $s < $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) { |
|
| 2192 | + for ($i = 0; $i < $corr[$y][$x][3]; $i++) { |
|
| 2193 | + $sh[$y + $i] = $sh[$y + $i] / $s * $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']; |
|
| 2194 | + } |
|
| 2195 | + } |
|
| 2196 | + } |
|
| 2197 | + } |
|
| 2198 | + } |
|
| 2199 | + |
|
| 2200 | + // set the new height, for each cell |
|
| 2201 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2202 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2203 | + if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) { |
|
| 2204 | + // without rowspan |
|
| 2205 | + if ($corr[$y][$x][3] == 1) { |
|
| 2206 | + $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $sh[$y]; |
|
| 2207 | + // with rowspan |
|
| 2208 | + } else { |
|
| 2209 | + $s = 0; |
|
| 2210 | + for ($i = 0; $i < $corr[$y][$x][3]; $i++) { |
|
| 2211 | + $s += $sh[$y + $i]; |
|
| 2212 | + } |
|
| 2213 | + $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $s; |
|
| 2214 | + |
|
| 2215 | + for ($j = 1; $j < $corr[$y][$x][3]; $j++) { |
|
| 2216 | + $tx = $x + 1; |
|
| 2217 | + $ty = $y + $j; |
|
| 2218 | + for (true; isset($corr[$ty][$tx]) && ! is_array($corr[$ty][$tx]); $tx++); |
|
| 2219 | + if (isset($corr[$ty][$tx])) { |
|
| 2220 | + $cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw'] += $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']; |
|
| 2221 | + } |
|
| 2222 | + } |
|
| 2223 | + } |
|
| 2224 | + } |
|
| 2225 | + } |
|
| 2226 | + } |
|
| 2227 | + } |
|
| 2228 | + |
|
| 2229 | + /** |
|
| 2230 | + * tag : PAGE |
|
| 2231 | + * mode : OPEN |
|
| 2232 | + * |
|
| 2233 | + * @param array $param |
|
| 2234 | + * @return boolean |
|
| 2235 | + */ |
|
| 2236 | + protected function _tag_open_PAGE($param) |
|
| 2237 | + { |
|
| 2238 | + if ($this->_isForOneLine) return false; |
|
| 2239 | + if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page + 1), true); |
|
| 2240 | + |
|
| 2241 | + $newPageSet = ( ! isset($param['pageset']) || $param['pageset'] != 'old'); |
|
| 2242 | + |
|
| 2243 | + $resetPageNumber = (isset($param['pagegroup']) && $param['pagegroup'] == 'new'); |
|
| 2244 | + |
|
| 2245 | + $this->_maxH = 0; |
|
| 2246 | + |
|
| 2247 | + // if new page set asked |
|
| 2248 | + if ($newPageSet) { |
|
| 2249 | + $this->_subHEADER = array(); |
|
| 2250 | + $this->_subFOOTER = array(); |
|
| 2251 | + |
|
| 2252 | + // orientation |
|
| 2253 | + $orientation = ''; |
|
| 2254 | + if (isset($param['orientation'])) { |
|
| 2255 | + $param['orientation'] = strtolower($param['orientation']); |
|
| 2256 | + if ($param['orientation'] == 'p') $orientation = 'P'; |
|
| 2257 | + if ($param['orientation'] == 'portrait') $orientation = 'P'; |
|
| 2258 | + |
|
| 2259 | + if ($param['orientation'] == 'l') $orientation = 'L'; |
|
| 2260 | + if ($param['orientation'] == 'paysage') $orientation = 'L'; |
|
| 2261 | + if ($param['orientation'] == 'landscape') $orientation = 'L'; |
|
| 2262 | + } |
|
| 2263 | + |
|
| 2264 | + // format |
|
| 2265 | + $format = null; |
|
| 2266 | + if (isset($param['format'])) { |
|
| 2267 | + $format = strtolower($param['format']); |
|
| 2268 | + if (preg_match('/^([0-9]+)x([0-9]+)$/isU', $format, $match)) { |
|
| 2269 | + $format = array(intval($match[1]), intval($match[2])); |
|
| 2270 | + } |
|
| 2271 | + } |
|
| 2272 | + |
|
| 2273 | + // background |
|
| 2274 | + $background = array(); |
|
| 2275 | + if (isset($param['backimg'])) { |
|
| 2276 | + $background['img'] = isset($param['backimg']) ? $param['backimg'] : ''; // src of the image |
|
| 2277 | + $background['posX'] = isset($param['backimgx']) ? $param['backimgx'] : 'center'; // horizontale position of the image |
|
| 2278 | + $background['posY'] = isset($param['backimgy']) ? $param['backimgy'] : 'middle'; // vertical position of the image |
|
| 2279 | + $background['width'] = isset($param['backimgw']) ? $param['backimgw'] : '100%'; // width of the image (100% = page width) |
|
| 2280 | + |
|
| 2281 | + // convert the src of the image, if parameters |
|
| 2282 | + $background['img'] = str_replace('&', '&', $background['img']); |
|
| 2283 | + |
|
| 2284 | + // convert the positions |
|
| 2285 | + if ($background['posX'] == 'left') $background['posX'] = '0%'; |
|
| 2286 | + if ($background['posX'] == 'center') $background['posX'] = '50%'; |
|
| 2287 | + if ($background['posX'] == 'right') $background['posX'] = '100%'; |
|
| 2288 | + if ($background['posY'] == 'top') $background['posY'] = '0%'; |
|
| 2289 | + if ($background['posY'] == 'middle') $background['posY'] = '50%'; |
|
| 2290 | + if ($background['posY'] == 'bottom') $background['posY'] = '100%'; |
|
| 2291 | + |
|
| 2292 | + if ($background['img']) { |
|
| 2293 | + // get the size of the image |
|
| 2294 | + // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini |
|
| 2295 | + $infos = @getimagesize($background['img']); |
|
| 2296 | + if (count($infos) > 1) { |
|
| 2297 | + $imageWidth = $this->parsingCss->ConvertToMM($background['width'], $this->pdf->getW()); |
|
| 2298 | + $imageHeight = $imageWidth * $infos[1] / $infos[0]; |
|
| 2299 | + |
|
| 2300 | + $background['width'] = $imageWidth; |
|
| 2301 | + $background['posX'] = $this->parsingCss->ConvertToMM($background['posX'], $this->pdf->getW() - $imageWidth); |
|
| 2302 | + $background['posY'] = $this->parsingCss->ConvertToMM($background['posY'], $this->pdf->getH() - $imageHeight); |
|
| 2303 | + } else { |
|
| 2304 | + $background = array(); |
|
| 2305 | + } |
|
| 2306 | + } else { |
|
| 2307 | + $background = array(); |
|
| 2308 | + } |
|
| 2309 | + } |
|
| 2310 | + |
|
| 2311 | + // margins of the page |
|
| 2312 | + $background['top'] = isset($param['backtop']) ? $param['backtop'] : '0'; |
|
| 2313 | + $background['bottom'] = isset($param['backbottom']) ? $param['backbottom'] : '0'; |
|
| 2314 | + $background['left'] = isset($param['backleft']) ? $param['backleft'] : '0'; |
|
| 2315 | + $background['right'] = isset($param['backright']) ? $param['backright'] : '0'; |
|
| 2316 | + |
|
| 2317 | + // if no unit => mm |
|
| 2318 | + if (preg_match('/^([0-9]*)$/isU', $background['top'])) { |
|
| 2319 | + $background['top'] .= 'mm'; |
|
| 2320 | + } |
|
| 2321 | + if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) { |
|
| 2322 | + $background['bottom'] .= 'mm'; |
|
| 2323 | + } |
|
| 2324 | + if (preg_match('/^([0-9]*)$/isU', $background['left'])) { |
|
| 2325 | + $background['left'] .= 'mm'; |
|
| 2326 | + } |
|
| 2327 | + if (preg_match('/^([0-9]*)$/isU', $background['right'])) { |
|
| 2328 | + $background['right'] .= 'mm'; |
|
| 2329 | + } |
|
| 2330 | + |
|
| 2331 | + // convert to mm |
|
| 2332 | + $background['top'] = $this->parsingCss->ConvertToMM($background['top'], $this->pdf->getH()); |
|
| 2333 | + $background['bottom'] = $this->parsingCss->ConvertToMM($background['bottom'], $this->pdf->getH()); |
|
| 2334 | + $background['left'] = $this->parsingCss->ConvertToMM($background['left'], $this->pdf->getW()); |
|
| 2335 | + $background['right'] = $this->parsingCss->ConvertToMM($background['right'], $this->pdf->getW()); |
|
| 2336 | + |
|
| 2337 | + // get the background color |
|
| 2338 | + $res = false; |
|
| 2339 | + $background['color'] = isset($param['backcolor']) ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null; |
|
| 2340 | + if ( ! $res) $background['color'] = null; |
|
| 2341 | + |
|
| 2342 | + $this->parsingCss->save(); |
|
| 2343 | + $this->parsingCss->analyse('PAGE', $param); |
|
| 2344 | + $this->parsingCss->setPosition(); |
|
| 2345 | + $this->parsingCss->fontSet(); |
|
| 2346 | + |
|
| 2347 | + // new page |
|
| 2348 | + $this->_setNewPage($format, $orientation, $background, null, $resetPageNumber); |
|
| 2349 | + |
|
| 2350 | + // automatic footer |
|
| 2351 | + if (isset($param['footer'])) { |
|
| 2352 | + $lst = explode(';', $param['footer']); |
|
| 2353 | + foreach ($lst as $key => $val) { |
|
| 2354 | + $lst[$key] = trim(strtolower($val)); |
|
| 2355 | + } |
|
| 2356 | + $page = in_array('page', $lst); |
|
| 2357 | + $date = in_array('date', $lst); |
|
| 2358 | + $hour = in_array('heure', $lst); |
|
| 2359 | + $form = in_array('form', $lst); |
|
| 2360 | + } else { |
|
| 2361 | + $page = null; |
|
| 2362 | + $date = null; |
|
| 2363 | + $hour = null; |
|
| 2364 | + $form = null; |
|
| 2365 | + } |
|
| 2366 | + $this->pdf->SetMyFooter($page, $date, $hour, $form); |
|
| 2367 | + // else => we use the last page set used |
|
| 2368 | + } else { |
|
| 2369 | + $this->parsingCss->save(); |
|
| 2370 | + $this->parsingCss->analyse('PAGE', $param); |
|
| 2371 | + $this->parsingCss->setPosition(); |
|
| 2372 | + $this->parsingCss->fontSet(); |
|
| 2373 | + |
|
| 2374 | + $this->_setNewPage(null, null, null, null, $resetPageNumber); |
|
| 2375 | + } |
|
| 2376 | + |
|
| 2377 | + return true; |
|
| 2378 | + } |
|
| 2379 | + |
|
| 2380 | + /** |
|
| 2381 | + * tag : PAGE |
|
| 2382 | + * mode : CLOSE |
|
| 2383 | + * |
|
| 2384 | + * @param array $param |
|
| 2385 | + * @return boolean |
|
| 2386 | + */ |
|
| 2387 | + protected function _tag_close_PAGE($param) |
|
| 2388 | + { |
|
| 2389 | + if ($this->_isForOneLine) { |
|
| 2390 | + return false; |
|
| 2391 | + } |
|
| 2392 | + |
|
| 2393 | + $this->_maxH = 0; |
|
| 2394 | + |
|
| 2395 | + $this->parsingCss->load(); |
|
| 2396 | + $this->parsingCss->fontSet(); |
|
| 2397 | + |
|
| 2398 | + if ($this->_debugActif) { |
|
| 2399 | + $this->_DEBUG_add('PAGE '.$this->_page, false); |
|
| 2400 | + } |
|
| 2401 | + |
|
| 2402 | + return true; |
|
| 2403 | + } |
|
| 2404 | + |
|
| 2405 | + /** |
|
| 2406 | + * tag : PAGE_HEADER |
|
| 2407 | + * mode : OPEN |
|
| 2408 | + * |
|
| 2409 | + * @param array $param |
|
| 2410 | + * @return boolean |
|
| 2411 | + */ |
|
| 2412 | + protected function _tag_open_PAGE_HEADER($param) |
|
| 2413 | + { |
|
| 2414 | + if ($this->_isForOneLine) return false; |
|
| 2415 | + |
|
| 2416 | + $this->_subHEADER = array(); |
|
| 2417 | + for ($this->_parsePos; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 2418 | + $action = $this->parsingHtml->code[$this->_parsePos]; |
|
| 2419 | + if ($action['name'] == 'page_header') $action['name'] = 'page_header_sub'; |
|
| 2420 | + $this->_subHEADER[] = $action; |
|
| 2421 | + if (strtolower($action['name']) == 'page_header_sub' && $action['close']) break; |
|
| 2422 | + } |
|
| 2423 | + |
|
| 2424 | + $this->_setPageHeader(); |
|
| 2425 | + |
|
| 2426 | + return true; |
|
| 2427 | + } |
|
| 2428 | + |
|
| 2429 | + /** |
|
| 2430 | + * tag : PAGE_FOOTER |
|
| 2431 | + * mode : OPEN |
|
| 2432 | + * |
|
| 2433 | + * @param array $param |
|
| 2434 | + * @return boolean |
|
| 2435 | + */ |
|
| 2436 | + protected function _tag_open_PAGE_FOOTER($param) |
|
| 2437 | + { |
|
| 2438 | + if ($this->_isForOneLine) return false; |
|
| 2439 | + |
|
| 2440 | + $this->_subFOOTER = array(); |
|
| 2441 | + for ($this->_parsePos; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 2442 | + $action = $this->parsingHtml->code[$this->_parsePos]; |
|
| 2443 | + if ($action['name'] == 'page_footer') $action['name'] = 'page_footer_sub'; |
|
| 2444 | + $this->_subFOOTER[] = $action; |
|
| 2445 | + if (strtolower($action['name']) == 'page_footer_sub' && $action['close']) break; |
|
| 2446 | + } |
|
| 2447 | + |
|
| 2448 | + $this->_setPageFooter(); |
|
| 2449 | + |
|
| 2450 | + return true; |
|
| 2451 | + } |
|
| 2452 | + |
|
| 2453 | + /** |
|
| 2454 | + * It is not a real tag. Does not use it directly |
|
| 2455 | + * |
|
| 2456 | + * @param array $param |
|
| 2457 | + * @return boolean |
|
| 2458 | + */ |
|
| 2459 | + protected function _tag_open_PAGE_HEADER_SUB($param) |
|
| 2460 | + { |
|
| 2461 | + if ($this->_isForOneLine) { |
|
| 2462 | + return false; |
|
| 2463 | + } |
|
| 2464 | + |
|
| 2465 | + // save the current stat |
|
| 2466 | + $this->_subSTATES = array(); |
|
| 2467 | + $this->_subSTATES['x'] = $this->pdf->getX(); |
|
| 2468 | + $this->_subSTATES['y'] = $this->pdf->getY(); |
|
| 2469 | + $this->_subSTATES['s'] = $this->parsingCss->value; |
|
| 2470 | + $this->_subSTATES['t'] = $this->parsingCss->table; |
|
| 2471 | + $this->_subSTATES['ml'] = $this->_margeLeft; |
|
| 2472 | + $this->_subSTATES['mr'] = $this->_margeRight; |
|
| 2473 | + $this->_subSTATES['mt'] = $this->_margeTop; |
|
| 2474 | + $this->_subSTATES['mb'] = $this->_margeBottom; |
|
| 2475 | + $this->_subSTATES['mp'] = $this->_pageMarges; |
|
| 2476 | + |
|
| 2477 | + // new stat for the header |
|
| 2478 | + $this->_pageMarges = array(); |
|
| 2479 | + $this->_margeLeft = $this->_defaultLeft; |
|
| 2480 | + $this->_margeRight = $this->_defaultRight; |
|
| 2481 | + $this->_margeTop = $this->_defaultTop; |
|
| 2482 | + $this->_margeBottom = $this->_defaultBottom; |
|
| 2483 | + $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2484 | + $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2485 | + $this->pdf->setXY($this->_defaultLeft, $this->_defaultTop); |
|
| 2486 | + |
|
| 2487 | + $this->parsingCss->initStyle(); |
|
| 2488 | + $this->parsingCss->resetStyle(); |
|
| 2489 | + $this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight; |
|
| 2490 | + $this->parsingCss->table = array(); |
|
| 2491 | + |
|
| 2492 | + $this->parsingCss->save(); |
|
| 2493 | + $this->parsingCss->analyse('page_header_sub', $param); |
|
| 2494 | + $this->parsingCss->setPosition(); |
|
| 2495 | + $this->parsingCss->fontSet(); |
|
| 2496 | + $this->_setNewPositionForNewLine(); |
|
| 2497 | + return true; |
|
| 2498 | + } |
|
| 2499 | + |
|
| 2500 | + /** |
|
| 2501 | + * It is not a real tag. Does not use it directly |
|
| 2502 | + * |
|
| 2503 | + * @param array $param |
|
| 2504 | + * @return boolean |
|
| 2505 | + */ |
|
| 2506 | + protected function _tag_close_PAGE_HEADER_SUB($param) |
|
| 2507 | + { |
|
| 2508 | + if ($this->_isForOneLine) { |
|
| 2509 | + return false; |
|
| 2510 | + } |
|
| 2511 | + |
|
| 2512 | + $this->parsingCss->load(); |
|
| 2513 | + |
|
| 2514 | + // restore the stat |
|
| 2515 | + $this->parsingCss->value = $this->_subSTATES['s']; |
|
| 2516 | + $this->parsingCss->table = $this->_subSTATES['t']; |
|
| 2517 | + $this->_pageMarges = $this->_subSTATES['mp']; |
|
| 2518 | + $this->_margeLeft = $this->_subSTATES['ml']; |
|
| 2519 | + $this->_margeRight = $this->_subSTATES['mr']; |
|
| 2520 | + $this->_margeTop = $this->_subSTATES['mt']; |
|
| 2521 | + $this->_margeBottom = $this->_subSTATES['mb']; |
|
| 2522 | + $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2523 | + $this->pdf->setbMargin($this->_margeBottom); |
|
| 2524 | + $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2525 | + $this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']); |
|
| 2526 | + |
|
| 2527 | + $this->parsingCss->fontSet(); |
|
| 2528 | + $this->_maxH = 0; |
|
| 2529 | + |
|
| 2530 | + return true; |
|
| 2531 | + } |
|
| 2532 | + |
|
| 2533 | + /** |
|
| 2534 | + * It is not a real tag. Does not use it directly |
|
| 2535 | + * |
|
| 2536 | + * @param array $param |
|
| 2537 | + * @return boolean |
|
| 2538 | + */ |
|
| 2539 | + protected function _tag_open_PAGE_FOOTER_SUB($param) |
|
| 2540 | + { |
|
| 2541 | + if ($this->_isForOneLine) { |
|
| 2542 | + return false; |
|
| 2543 | + } |
|
| 2544 | + |
|
| 2545 | + // save the current stat |
|
| 2546 | + $this->_subSTATES = array(); |
|
| 2547 | + $this->_subSTATES['x'] = $this->pdf->getX(); |
|
| 2548 | + $this->_subSTATES['y'] = $this->pdf->getY(); |
|
| 2549 | + $this->_subSTATES['s'] = $this->parsingCss->value; |
|
| 2550 | + $this->_subSTATES['t'] = $this->parsingCss->table; |
|
| 2551 | + $this->_subSTATES['ml'] = $this->_margeLeft; |
|
| 2552 | + $this->_subSTATES['mr'] = $this->_margeRight; |
|
| 2553 | + $this->_subSTATES['mt'] = $this->_margeTop; |
|
| 2554 | + $this->_subSTATES['mb'] = $this->_margeBottom; |
|
| 2555 | + $this->_subSTATES['mp'] = $this->_pageMarges; |
|
| 2556 | + |
|
| 2557 | + // new stat for the footer |
|
| 2558 | + $this->_pageMarges = array(); |
|
| 2559 | + $this->_margeLeft = $this->_defaultLeft; |
|
| 2560 | + $this->_margeRight = $this->_defaultRight; |
|
| 2561 | + $this->_margeTop = $this->_defaultTop; |
|
| 2562 | + $this->_margeBottom = $this->_defaultBottom; |
|
| 2563 | + $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2564 | + $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2565 | + $this->pdf->setXY($this->_defaultLeft, $this->_defaultTop); |
|
| 2566 | + |
|
| 2567 | + $this->parsingCss->initStyle(); |
|
| 2568 | + $this->parsingCss->resetStyle(); |
|
| 2569 | + $this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight; |
|
| 2570 | + $this->parsingCss->table = array(); |
|
| 2571 | + |
|
| 2572 | + // we create a sub HTML2PFDF, and we execute on it the content of the footer, to get the height of it |
|
| 2573 | + $sub = null; |
|
| 2574 | + $this->_createSubHTML($sub); |
|
| 2575 | + $sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 2576 | + $sub->_makeHTMLcode(); |
|
| 2577 | + $this->pdf->setY($this->pdf->getH() - $sub->_maxY - $this->_defaultBottom - 0.01); |
|
| 2578 | + $this->_destroySubHTML($sub); |
|
| 2579 | + |
|
| 2580 | + $this->parsingCss->save(); |
|
| 2581 | + $this->parsingCss->analyse('page_footer_sub', $param); |
|
| 2582 | + $this->parsingCss->setPosition(); |
|
| 2583 | + $this->parsingCss->fontSet(); |
|
| 2584 | + $this->_setNewPositionForNewLine(); |
|
| 2585 | + |
|
| 2586 | + return true; |
|
| 2587 | + } |
|
| 2588 | + |
|
| 2589 | + /** |
|
| 2590 | + * It is not a real tag. Does not use it directly |
|
| 2591 | + * |
|
| 2592 | + * @param array $param |
|
| 2593 | + * @return boolean |
|
| 2594 | + */ |
|
| 2595 | + protected function _tag_close_PAGE_FOOTER_SUB($param) |
|
| 2596 | + { |
|
| 2597 | + if ($this->_isForOneLine) { |
|
| 2598 | + return false; |
|
| 2599 | + } |
|
| 2600 | + |
|
| 2601 | + $this->parsingCss->load(); |
|
| 2602 | + |
|
| 2603 | + $this->parsingCss->value = $this->_subSTATES['s']; |
|
| 2604 | + $this->parsingCss->table = $this->_subSTATES['t']; |
|
| 2605 | + $this->_pageMarges = $this->_subSTATES['mp']; |
|
| 2606 | + $this->_margeLeft = $this->_subSTATES['ml']; |
|
| 2607 | + $this->_margeRight = $this->_subSTATES['mr']; |
|
| 2608 | + $this->_margeTop = $this->_subSTATES['mt']; |
|
| 2609 | + $this->_margeBottom = $this->_subSTATES['mb']; |
|
| 2610 | + $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2611 | + $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2612 | + $this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']); |
|
| 2613 | + |
|
| 2614 | + $this->parsingCss->fontSet(); |
|
| 2615 | + $this->_maxH = 0; |
|
| 2616 | + |
|
| 2617 | + return true; |
|
| 2618 | + } |
|
| 2619 | + |
|
| 2620 | + /** |
|
| 2621 | + * tag : NOBREAK |
|
| 2622 | + * mode : OPEN |
|
| 2623 | + * |
|
| 2624 | + * @param array $param |
|
| 2625 | + * @return boolean |
|
| 2626 | + */ |
|
| 2627 | + protected function _tag_open_NOBREAK($param) |
|
| 2628 | + { |
|
| 2629 | + if ($this->_isForOneLine) { |
|
| 2630 | + return false; |
|
| 2631 | + } |
|
| 2632 | + |
|
| 2633 | + $this->_maxH = 0; |
|
| 2634 | + |
|
| 2635 | + // create a sub HTML2PDF to execute the content of the tag, to get the dimensions |
|
| 2636 | + $sub = null; |
|
| 2637 | + $this->_createSubHTML($sub); |
|
| 2638 | + $sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 2639 | + $sub->_makeHTMLcode(); |
|
| 2640 | + $y = $this->pdf->getY(); |
|
| 2641 | + |
|
| 2642 | + // if the content does not fit on the page => new page |
|
| 2643 | + if ( |
|
| 2644 | + $sub->_maxY < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin()) && |
|
| 2645 | + $y + $sub->_maxY >= ($this->pdf->getH() - $this->pdf->getbMargin()) |
|
| 2646 | + ) { |
|
| 2647 | + $this->_setNewPage(); |
|
| 2648 | + } |
|
| 2649 | + |
|
| 2650 | + // destroy the sub HTML2PDF |
|
| 2651 | + $this->_destroySubHTML($sub); |
|
| 2652 | + |
|
| 2653 | + return true; |
|
| 2654 | + } |
|
| 2655 | + |
|
| 2656 | + |
|
| 2657 | + /** |
|
| 2658 | + * tag : NOBREAK |
|
| 2659 | + * mode : CLOSE |
|
| 2660 | + * |
|
| 2661 | + * @param array $param |
|
| 2662 | + * @return boolean |
|
| 2663 | + */ |
|
| 2664 | + protected function _tag_close_NOBREAK($param) |
|
| 2665 | + { |
|
| 2666 | + if ($this->_isForOneLine) { |
|
| 2667 | + return false; |
|
| 2668 | + } |
|
| 2669 | + |
|
| 2670 | + $this->_maxH = 0; |
|
| 2671 | + |
|
| 2672 | + return true; |
|
| 2673 | + } |
|
| 2674 | + |
|
| 2675 | + /** |
|
| 2676 | + * tag : DIV |
|
| 2677 | + * mode : OPEN |
|
| 2678 | + * |
|
| 2679 | + * @param array $param |
|
| 2680 | + * @param string $other name of tag that used the div tag |
|
| 2681 | + * @return boolean |
|
| 2682 | + */ |
|
| 2683 | + protected function _tag_open_DIV($param, $other = 'div') |
|
| 2684 | + { |
|
| 2685 | + if ($this->_isForOneLine) { |
|
| 2686 | + return false; |
|
| 2687 | + } |
|
| 2688 | + if ($this->_debugActif) { |
|
| 2689 | + $this->_DEBUG_add(strtoupper($other), true); |
|
| 2690 | + } |
|
| 2691 | + |
|
| 2692 | + $this->parsingCss->save(); |
|
| 2693 | + $this->parsingCss->analyse($other, $param); |
|
| 2694 | + $this->parsingCss->fontSet(); |
|
| 2695 | + |
|
| 2696 | + // for fieldset and legend |
|
| 2697 | + if (in_array($other, array('fieldset', 'legend'))) { |
|
| 2698 | + if (isset($param['moveTop'])) { |
|
| 2699 | + $this->parsingCss->value['margin']['t'] += $param['moveTop']; |
|
| 2700 | + } |
|
| 2701 | + if (isset($param['moveLeft'])) { |
|
| 2702 | + $this->parsingCss->value['margin']['l'] += $param['moveLeft']; |
|
| 2703 | + } |
|
| 2704 | + if (isset($param['moveDown'])) { |
|
| 2705 | + $this->parsingCss->value['margin']['b'] += $param['moveDown']; |
|
| 2706 | + } |
|
| 2707 | + } |
|
| 2708 | + |
|
| 2709 | + $alignObject = null; |
|
| 2710 | + if ($this->parsingCss->value['margin-auto']) { |
|
| 2711 | + $alignObject = 'center'; |
|
| 2712 | + } |
|
| 2713 | + |
|
| 2714 | + $marge = array(); |
|
| 2715 | + $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03; |
|
| 2716 | + $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03; |
|
| 2717 | + $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03; |
|
| 2718 | + $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03; |
|
| 2719 | + |
|
| 2720 | + // extract the content of the div |
|
| 2721 | + $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 2722 | + |
|
| 2723 | + // create a sub HTML2PDF to get the dimensions of the content of the div |
|
| 2724 | + $w = 0; $h = 0; |
|
| 2725 | + if (count($level)) { |
|
| 2726 | + $sub = null; |
|
| 2727 | + $this->_createSubHTML($sub); |
|
| 2728 | + $sub->parsingHtml->code = $level; |
|
| 2729 | + $sub->_makeHTMLcode(); |
|
| 2730 | + $w = $sub->_maxX; |
|
| 2731 | + $h = $sub->_maxY; |
|
| 2732 | + $this->_destroySubHTML($sub); |
|
| 2733 | + } |
|
| 2734 | + $wReel = $w; |
|
| 2735 | + $hReel = $h; |
|
| 2736 | + |
|
| 2737 | + $w += $marge['l'] + $marge['r'] + 0.001; |
|
| 2738 | + $h += $marge['t'] + $marge['b'] + 0.001; |
|
| 2739 | + |
|
| 2740 | + if ($this->parsingCss->value['overflow'] == 'hidden') { |
|
| 2741 | + $overW = max($w, $this->parsingCss->value['width']); |
|
| 2742 | + $overH = max($h, $this->parsingCss->value['height']); |
|
| 2743 | + $overflow = true; |
|
| 2744 | + $this->parsingCss->value['old_maxX'] = $this->_maxX; |
|
| 2745 | + $this->parsingCss->value['old_maxY'] = $this->_maxY; |
|
| 2746 | + $this->parsingCss->value['old_maxH'] = $this->_maxH; |
|
| 2747 | + $this->parsingCss->value['old_overflow'] = $this->_isInOverflow; |
|
| 2748 | + $this->_isInOverflow = true; |
|
| 2749 | + } else { |
|
| 2750 | + $overW = null; |
|
| 2751 | + $overH = null; |
|
| 2752 | + $overflow = false; |
|
| 2753 | + $this->parsingCss->value['width'] = max($w, $this->parsingCss->value['width']); |
|
| 2754 | + $this->parsingCss->value['height'] = max($h, $this->parsingCss->value['height']); |
|
| 2755 | + } |
|
| 2756 | + |
|
| 2757 | + switch ($this->parsingCss->value['rotate']) |
|
| 2758 | + { |
|
| 2759 | + case 90: |
|
| 2760 | + $tmp = $overH; $overH = $overW; $overW = $tmp; |
|
| 2761 | + $tmp = $hReel; $hReel = $wReel; $wReel = $tmp; |
|
| 2762 | + unset($tmp); |
|
| 2763 | + $w = $this->parsingCss->value['height']; |
|
| 2764 | + $h = $this->parsingCss->value['width']; |
|
| 2765 | + $tX = -$h; |
|
| 2766 | + $tY = 0; |
|
| 2767 | + break; |
|
| 2768 | + |
|
| 2769 | + case 180: |
|
| 2770 | + $w = $this->parsingCss->value['width']; |
|
| 2771 | + $h = $this->parsingCss->value['height']; |
|
| 2772 | + $tX = -$w; |
|
| 2773 | + $tY = -$h; |
|
| 2774 | + break; |
|
| 2775 | + |
|
| 2776 | + case 270: |
|
| 2777 | + $tmp = $overH; $overH = $overW; $overW = $tmp; |
|
| 2778 | + $tmp = $hReel; $hReel = $wReel; $wReel = $tmp; |
|
| 2779 | + unset($tmp); |
|
| 2780 | + $w = $this->parsingCss->value['height']; |
|
| 2781 | + $h = $this->parsingCss->value['width']; |
|
| 2782 | + $tX = 0; |
|
| 2783 | + $tY = -$w; |
|
| 2784 | + break; |
|
| 2785 | + |
|
| 2786 | + default: |
|
| 2787 | + $w = $this->parsingCss->value['width']; |
|
| 2788 | + $h = $this->parsingCss->value['height']; |
|
| 2789 | + $tX = 0; |
|
| 2790 | + $tY = 0; |
|
| 2791 | + break; |
|
| 2792 | + } |
|
| 2793 | + |
|
| 2794 | + if ( ! $this->parsingCss->value['position']) { |
|
| 2795 | + if ( |
|
| 2796 | + $w < ($this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin()) && |
|
| 2797 | + $this->pdf->getX() + $w >= ($this->pdf->getW() - $this->pdf->getrMargin()) |
|
| 2798 | + ) |
|
| 2799 | + $this->_tag_open_BR(array()); |
|
| 2800 | + |
|
| 2801 | + if ( |
|
| 2802 | + ($h < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin())) && |
|
| 2803 | + ($this->pdf->getY() + $h >= ($this->pdf->getH() - $this->pdf->getbMargin())) && |
|
| 2804 | + ! $this->_isInOverflow |
|
| 2805 | + ) |
|
| 2806 | + $this->_setNewPage(); |
|
| 2807 | + |
|
| 2808 | + $old = $this->parsingCss->getOldValues(); |
|
| 2809 | + $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 2810 | + |
|
| 2811 | + if ($parentWidth > $w) { |
|
| 2812 | + if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 2813 | + else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 2814 | + } |
|
| 2815 | + |
|
| 2816 | + $this->parsingCss->setPosition(); |
|
| 2817 | + } else { |
|
| 2818 | + $old = $this->parsingCss->getOldValues(); |
|
| 2819 | + $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 2820 | + |
|
| 2821 | + if ($parentWidth > $w) { |
|
| 2822 | + if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 2823 | + else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 2824 | + } |
|
| 2825 | + |
|
| 2826 | + $this->parsingCss->setPosition(); |
|
| 2827 | + $this->_saveMax(); |
|
| 2828 | + $this->_maxX = 0; |
|
| 2829 | + $this->_maxY = 0; |
|
| 2830 | + $this->_maxH = 0; |
|
| 2831 | + $this->_maxE = 0; |
|
| 2832 | + } |
|
| 2833 | + |
|
| 2834 | + if ($this->parsingCss->value['rotate']) { |
|
| 2835 | + $this->pdf->startTransform(); |
|
| 2836 | + $this->pdf->setRotation($this->parsingCss->value['rotate']); |
|
| 2837 | + $this->pdf->setTranslate($tX, $tY); |
|
| 2838 | + } |
|
| 2839 | + |
|
| 2840 | + $this->_drawRectangle( |
|
| 2841 | + $this->parsingCss->value['x'], |
|
| 2842 | + $this->parsingCss->value['y'], |
|
| 2843 | + $this->parsingCss->value['width'], |
|
| 2844 | + $this->parsingCss->value['height'], |
|
| 2845 | + $this->parsingCss->value['border'], |
|
| 2846 | + $this->parsingCss->value['padding'], |
|
| 2847 | + 0, |
|
| 2848 | + $this->parsingCss->value['background'] |
|
| 2849 | + ); |
|
| 2850 | + |
|
| 2851 | + $marge = array(); |
|
| 2852 | + $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03; |
|
| 2853 | + $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03; |
|
| 2854 | + $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03; |
|
| 2855 | + $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03; |
|
| 2856 | + |
|
| 2857 | + $this->parsingCss->value['width'] -= $marge['l'] + $marge['r']; |
|
| 2858 | + $this->parsingCss->value['height'] -= $marge['t'] + $marge['b']; |
|
| 2859 | + |
|
| 2860 | + $xCorr = 0; |
|
| 2861 | + $yCorr = 0; |
|
| 2862 | + if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 2863 | + switch ($this->parsingCss->value['text-align']) |
|
| 2864 | + { |
|
| 2865 | + case 'right': |
|
| 2866 | + $xCorr = ($this->parsingCss->value['width'] - $wReel); |
|
| 2867 | + break; |
|
| 2868 | + case 'center': |
|
| 2869 | + $xCorr = ($this->parsingCss->value['width'] - $wReel) * 0.5; |
|
| 2870 | + break; |
|
| 2871 | + } |
|
| 2872 | + if ($xCorr > 0) $xCorr = 0; |
|
| 2873 | + switch ($this->parsingCss->value['vertical-align']) |
|
| 2874 | + { |
|
| 2875 | + case 'bottom': |
|
| 2876 | + $yCorr = ($this->parsingCss->value['height'] - $hReel); |
|
| 2877 | + break; |
|
| 2878 | + case 'middle': |
|
| 2879 | + $yCorr = ($this->parsingCss->value['height'] - $hReel) * 0.5; |
|
| 2880 | + break; |
|
| 2881 | + } |
|
| 2882 | + } |
|
| 2883 | + |
|
| 2884 | + if ($overflow) { |
|
| 2885 | + $overW -= $marge['l'] + $marge['r']; |
|
| 2886 | + $overH -= $marge['t'] + $marge['b']; |
|
| 2887 | + $this->pdf->clippingPathStart( |
|
| 2888 | + $this->parsingCss->value['x'] + $marge['l'], |
|
| 2889 | + $this->parsingCss->value['y'] + $marge['t'], |
|
| 2890 | + $this->parsingCss->value['width'], |
|
| 2891 | + $this->parsingCss->value['height'] |
|
| 2892 | + ); |
|
| 2893 | + |
|
| 2894 | + $this->parsingCss->value['x'] += $xCorr; |
|
| 2895 | + |
|
| 2896 | + // marges from the dimension of the content |
|
| 2897 | + $mL = $this->parsingCss->value['x'] + $marge['l']; |
|
| 2898 | + $mR = $this->pdf->getW() - $mL - $overW; |
|
| 2899 | + } else { |
|
| 2900 | + // marges from the dimension of the div |
|
| 2901 | + $mL = $this->parsingCss->value['x'] + $marge['l']; |
|
| 2902 | + $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width']; |
|
| 2903 | + } |
|
| 2904 | + |
|
| 2905 | + $x = $this->parsingCss->value['x'] + $marge['l']; |
|
| 2906 | + $y = $this->parsingCss->value['y'] + $marge['t'] + $yCorr; |
|
| 2907 | + $this->_saveMargin($mL, 0, $mR); |
|
| 2908 | + $this->pdf->setXY($x, $y); |
|
| 2909 | + |
|
| 2910 | + $this->_setNewPositionForNewLine(); |
|
| 2911 | + |
|
| 2912 | + return true; |
|
| 2913 | + } |
|
| 2914 | + |
|
| 2915 | + /** |
|
| 2916 | + * tag : BLOCKQUOTE |
|
| 2917 | + * mode : OPEN |
|
| 2918 | + * |
|
| 2919 | + * @param array $param |
|
| 2920 | + * @return boolean |
|
| 2921 | + */ |
|
| 2922 | + protected function _tag_open_BLOCKQUOTE($param) |
|
| 2923 | + { |
|
| 2924 | + return $this->_tag_open_DIV($param, 'blockquote'); |
|
| 2925 | + } |
|
| 2926 | + |
|
| 2927 | + /** |
|
| 2928 | + * tag : LEGEND |
|
| 2929 | + * mode : OPEN |
|
| 2930 | + * |
|
| 2931 | + * @param array $param |
|
| 2932 | + * @return boolean |
|
| 2933 | + */ |
|
| 2934 | + protected function _tag_open_LEGEND($param) |
|
| 2935 | + { |
|
| 2936 | + return $this->_tag_open_DIV($param, 'legend'); |
|
| 2937 | + } |
|
| 2938 | + |
|
| 2939 | + /** |
|
| 2940 | + * tag : FIELDSET |
|
| 2941 | + * mode : OPEN |
|
| 2942 | + * |
|
| 2943 | + * @author Pavel Kochman |
|
| 2944 | + * @param array $param |
|
| 2945 | + * @return boolean |
|
| 2946 | + */ |
|
| 2947 | + protected function _tag_open_FIELDSET($param) |
|
| 2948 | + { |
|
| 2949 | + |
|
| 2950 | + $this->parsingCss->save(); |
|
| 2951 | + $this->parsingCss->analyse('fieldset', $param); |
|
| 2952 | + |
|
| 2953 | + // get height of LEGEND element and make fieldset corrections |
|
| 2954 | + for ($tempPos = $this->_parsePos + 1; $tempPos < count($this->parsingHtml->code); $tempPos++) { |
|
| 2955 | + $action = $this->parsingHtml->code[$tempPos]; |
|
| 2956 | + if ($action['name'] == 'fieldset') break; |
|
| 2957 | + if ($action['name'] == 'legend' && ! $action['close']) { |
|
| 2958 | + $legendOpenPos = $tempPos; |
|
| 2959 | + |
|
| 2960 | + $sub = null; |
|
| 2961 | + $this->_createSubHTML($sub); |
|
| 2962 | + $sub->parsingHtml->code = $this->parsingHtml->getLevel($tempPos - 1); |
|
| 2963 | + |
|
| 2964 | + $res = null; |
|
| 2965 | + for ($sub->_parsePos = 0; $sub->_parsePos < count($sub->parsingHtml->code); $sub->_parsePos++) { |
|
| 2966 | + $action = $sub->parsingHtml->code[$sub->_parsePos]; |
|
| 2967 | + $sub->_executeAction($action); |
|
| 2968 | + |
|
| 2969 | + if ($action['name'] == 'legend' && $action['close']) { |
|
| 2970 | + break; |
|
| 2971 | + } |
|
| 2972 | + } |
|
| 2973 | + |
|
| 2974 | + $legendH = $sub->_maxY; |
|
| 2975 | + $this->_destroySubHTML($sub); |
|
| 2976 | + |
|
| 2977 | + $move = $this->parsingCss->value['padding']['t'] + $this->parsingCss->value['border']['t']['width'] + 0.03; |
|
| 2978 | + |
|
| 2979 | + $param['moveTop'] = $legendH / 2; |
|
| 2980 | + |
|
| 2981 | + $this->parsingHtml->code[$legendOpenPos]['param']['moveTop'] = - ($legendH / 2 + $move); |
|
| 2982 | + $this->parsingHtml->code[$legendOpenPos]['param']['moveLeft'] = 2 - $this->parsingCss->value['border']['l']['width'] - $this->parsingCss->value['padding']['l']; |
|
| 2983 | + $this->parsingHtml->code[$legendOpenPos]['param']['moveDown'] = $move; |
|
| 2984 | + break; |
|
| 2985 | + } |
|
| 2986 | + } |
|
| 2987 | + $this->parsingCss->load(); |
|
| 2988 | + |
|
| 2989 | + return $this->_tag_open_DIV($param, 'fieldset'); |
|
| 2990 | + } |
|
| 2991 | + |
|
| 2992 | + /** |
|
| 2993 | + * tag : DIV |
|
| 2994 | + * mode : CLOSE |
|
| 2995 | + * |
|
| 2996 | + * @param array $param |
|
| 2997 | + * @param string $other name of tag that used the div tag |
|
| 2998 | + * @return boolean |
|
| 2999 | + */ |
|
| 3000 | + protected function _tag_close_DIV($param, $other = 'div') |
|
| 3001 | + { |
|
| 3002 | + if ($this->_isForOneLine) { |
|
| 3003 | + return false; |
|
| 3004 | + } |
|
| 3005 | + |
|
| 3006 | + if ($this->parsingCss->value['overflow'] == 'hidden') { |
|
| 3007 | + $this->_maxX = $this->parsingCss->value['old_maxX']; |
|
| 3008 | + $this->_maxY = $this->parsingCss->value['old_maxY']; |
|
| 3009 | + $this->_maxH = $this->parsingCss->value['old_maxH']; |
|
| 3010 | + $this->_isInOverflow = $this->parsingCss->value['old_overflow']; |
|
| 3011 | + $this->pdf->clippingPathStop(); |
|
| 3012 | + } |
|
| 3013 | + |
|
| 3014 | + if ($this->parsingCss->value['rotate']) { |
|
| 3015 | + $this->pdf->stopTransform(); |
|
| 3016 | + } |
|
| 3017 | + |
|
| 3018 | + $marge = array(); |
|
| 3019 | + $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03; |
|
| 3020 | + $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03; |
|
| 3021 | + $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03; |
|
| 3022 | + $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03; |
|
| 3023 | + |
|
| 3024 | + $x = $this->parsingCss->value['x']; |
|
| 3025 | + $y = $this->parsingCss->value['y']; |
|
| 3026 | + $w = $this->parsingCss->value['width'] + $marge['l'] + $marge['r'] + $this->parsingCss->value['margin']['r']; |
|
| 3027 | + $h = $this->parsingCss->value['height'] + $marge['t'] + $marge['b'] + $this->parsingCss->value['margin']['b']; |
|
| 3028 | + |
|
| 3029 | + switch ($this->parsingCss->value['rotate']) |
|
| 3030 | + { |
|
| 3031 | + case 90: |
|
| 3032 | + $t = $w; $w = $h; $h = $t; |
|
| 3033 | + break; |
|
| 3034 | + |
|
| 3035 | + case 270: |
|
| 3036 | + $t = $w; $w = $h; $h = $t; |
|
| 3037 | + break; |
|
| 3038 | + |
|
| 3039 | + default: |
|
| 3040 | + break; |
|
| 3041 | + } |
|
| 3042 | + |
|
| 3043 | + |
|
| 3044 | + if ($this->parsingCss->value['position'] != 'absolute') { |
|
| 3045 | + $this->pdf->setXY($x + $w, $y); |
|
| 3046 | + |
|
| 3047 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 3048 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 3049 | + $this->_maxH = max($this->_maxH, $h); |
|
| 3050 | + } else { |
|
| 3051 | + $this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']); |
|
| 3052 | + |
|
| 3053 | + $this->_loadMax(); |
|
| 3054 | + } |
|
| 3055 | + |
|
| 3056 | + $block = ($this->parsingCss->value['display'] != 'inline' && $this->parsingCss->value['position'] != 'absolute'); |
|
| 3057 | + |
|
| 3058 | + $this->parsingCss->load(); |
|
| 3059 | + $this->parsingCss->fontSet(); |
|
| 3060 | + $this->_loadMargin(); |
|
| 3061 | + |
|
| 3062 | + if ($block) { |
|
| 3063 | + $this->_tag_open_BR(array()); |
|
| 3064 | + } |
|
| 3065 | + if ($this->_debugActif) { |
|
| 3066 | + $this->_DEBUG_add(strtoupper($other), false); |
|
| 3067 | + } |
|
| 3068 | + |
|
| 3069 | + return true; |
|
| 3070 | + } |
|
| 3071 | + |
|
| 3072 | + /** |
|
| 3073 | + * tag : BLOCKQUOTE |
|
| 3074 | + * mode : CLOSE |
|
| 3075 | + * |
|
| 3076 | + * @param array $param |
|
| 3077 | + * @return boolean |
|
| 3078 | + */ |
|
| 3079 | + protected function _tag_close_BLOCKQUOTE($param) |
|
| 3080 | + { |
|
| 3081 | + return $this->_tag_close_DIV($param, 'blockquote'); |
|
| 3082 | + } |
|
| 3083 | + |
|
| 3084 | + /** |
|
| 3085 | + * tag : FIELDSET |
|
| 3086 | + * mode : CLOSE |
|
| 3087 | + * |
|
| 3088 | + * @param array $param |
|
| 3089 | + * @return boolean |
|
| 3090 | + */ |
|
| 3091 | + protected function _tag_close_FIELDSET($param) |
|
| 3092 | + { |
|
| 3093 | + return $this->_tag_close_DIV($param, 'fieldset'); |
|
| 3094 | + } |
|
| 3095 | + |
|
| 3096 | + /** |
|
| 3097 | + * tag : LEGEND |
|
| 3098 | + * mode : CLOSE |
|
| 3099 | + * |
|
| 3100 | + * @param array $param |
|
| 3101 | + * @return boolean |
|
| 3102 | + */ |
|
| 3103 | + protected function _tag_close_LEGEND($param) |
|
| 3104 | + { |
|
| 3105 | + return $this->_tag_close_DIV($param, 'legend'); |
|
| 3106 | + } |
|
| 3107 | + |
|
| 3108 | + /** |
|
| 3109 | + * tag : BARCODE |
|
| 3110 | + * mode : OPEN |
|
| 3111 | + * |
|
| 3112 | + * @param array $param |
|
| 3113 | + * @return boolean |
|
| 3114 | + */ |
|
| 3115 | + protected function _tag_open_BARCODE($param) |
|
| 3116 | + { |
|
| 3117 | + // for compatibility with old versions < 3.29 |
|
| 3118 | + $lstBarcode = array(); |
|
| 3119 | + $lstBarcode['UPC_A'] = 'UPCA'; |
|
| 3120 | + $lstBarcode['CODE39'] = 'C39'; |
|
| 3121 | + |
|
| 3122 | + if ( ! isset($param['type'])) $param['type'] = 'C39'; |
|
| 3123 | + if ( ! isset($param['value'])) $param['value'] = 0; |
|
| 3124 | + if ( ! isset($param['label'])) $param['label'] = 'label'; |
|
| 3125 | + if ( ! isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3126 | + |
|
| 3127 | + if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w']))) |
|
| 3128 | + throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w')); |
|
| 3129 | + |
|
| 3130 | + $param['type'] = strtoupper($param['type']); |
|
| 3131 | + if (isset($lstBarcode[$param['type']])) $param['type'] = $lstBarcode[$param['type']]; |
|
| 3132 | + |
|
| 3133 | + $this->parsingCss->save(); |
|
| 3134 | + $this->parsingCss->analyse('barcode', $param); |
|
| 3135 | + $this->parsingCss->setPosition(); |
|
| 3136 | + $this->parsingCss->fontSet(); |
|
| 3137 | + |
|
| 3138 | + $x = $this->pdf->getX(); |
|
| 3139 | + $y = $this->pdf->getY(); |
|
| 3140 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3141 | + $h = $this->parsingCss->value['height']; if ( ! $h) $h = $this->parsingCss->ConvertToMM('10mm'); |
|
| 3142 | + $txt = ($param['label'] !== 'none' ? $this->parsingCss->value['font-size'] : false); |
|
| 3143 | + $c = $this->parsingCss->value['color']; |
|
| 3144 | + $infos = $this->pdf->myBarcode($param['value'], $param['type'], $x, $y, $w, $h, $txt, $c); |
|
| 3145 | + |
|
| 3146 | + $this->_maxX = max($this->_maxX, $x + $infos[0]); |
|
| 3147 | + $this->_maxY = max($this->_maxY, $y + $infos[1]); |
|
| 3148 | + $this->_maxH = max($this->_maxH, $infos[1]); |
|
| 3149 | + $this->_maxE++; |
|
| 3150 | + |
|
| 3151 | + $this->pdf->setXY($x + $infos[0], $y); |
|
| 3152 | + |
|
| 3153 | + $this->parsingCss->load(); |
|
| 3154 | + $this->parsingCss->fontSet(); |
|
| 3155 | + |
|
| 3156 | + return true; |
|
| 3157 | + } |
|
| 3158 | + |
|
| 3159 | + /** |
|
| 3160 | + * tag : BARCODE |
|
| 3161 | + * mode : CLOSE |
|
| 3162 | + * |
|
| 3163 | + * @param array $param |
|
| 3164 | + * @return boolean |
|
| 3165 | + */ |
|
| 3166 | + protected function _tag_close_BARCODE($param) |
|
| 3167 | + { |
|
| 3168 | + // there is nothing to do here |
|
| 3169 | + |
|
| 3170 | + return true; |
|
| 3171 | + } |
|
| 3172 | + |
|
| 3173 | + /** |
|
| 3174 | + * tag : QRCODE |
|
| 3175 | + * mode : OPEN |
|
| 3176 | + * |
|
| 3177 | + * @param array $param |
|
| 3178 | + * @return boolean |
|
| 3179 | + */ |
|
| 3180 | + protected function _tag_open_QRCODE($param) |
|
| 3181 | + { |
|
| 3182 | + if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder']))) |
|
| 3183 | + throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder')); |
|
| 3184 | + |
|
| 3185 | + if ($this->_debugActif) $this->_DEBUG_add('QRCODE'); |
|
| 3186 | + |
|
| 3187 | + if ( ! isset($param['value'])) $param['value'] = ''; |
|
| 3188 | + if ( ! isset($param['ec'])) $param['ec'] = 'H'; |
|
| 3189 | + if ( ! isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3190 | + if ( ! isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF'; |
|
| 3191 | + if (isset($param['style']['border'])) { |
|
| 3192 | + $borders = $param['style']['border'] != 'none'; |
|
| 3193 | + unset($param['style']['border']); |
|
| 3194 | + } else { |
|
| 3195 | + $borders = true; |
|
| 3196 | + } |
|
| 3197 | + |
|
| 3198 | + if ($param['value'] === '') return true; |
|
| 3199 | + if ( ! in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H'; |
|
| 3200 | + |
|
| 3201 | + $this->parsingCss->save(); |
|
| 3202 | + $this->parsingCss->analyse('qrcode', $param); |
|
| 3203 | + $this->parsingCss->setPosition(); |
|
| 3204 | + $this->parsingCss->fontSet(); |
|
| 3205 | + |
|
| 3206 | + $x = $this->pdf->getX(); |
|
| 3207 | + $y = $this->pdf->getY(); |
|
| 3208 | + $w = $this->parsingCss->value['width']; |
|
| 3209 | + $h = $this->parsingCss->value['height']; |
|
| 3210 | + $size = max($w, $h); if ( ! $size) $size = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3211 | + |
|
| 3212 | + $style = array( |
|
| 3213 | + 'fgcolor' => $this->parsingCss->value['color'], |
|
| 3214 | + 'bgcolor' => $this->parsingCss->value['background']['color'], |
|
| 3215 | + ); |
|
| 3216 | + |
|
| 3217 | + if ($borders) { |
|
| 3218 | + $style['border'] = true; |
|
| 3219 | + $style['padding'] = 'auto'; |
|
| 3220 | + } else { |
|
| 3221 | + $style['border'] = false; |
|
| 3222 | + $style['padding'] = 0; |
|
| 3223 | + } |
|
| 3224 | + |
|
| 3225 | + if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 3226 | + $this->pdf->write2DBarcode($param['value'], 'QRCODE,'.$param['ec'], $x, $y, $size, $size, $style); |
|
| 3227 | + } |
|
| 3228 | + |
|
| 3229 | + $this->_maxX = max($this->_maxX, $x + $size); |
|
| 3230 | + $this->_maxY = max($this->_maxY, $y + $size); |
|
| 3231 | + $this->_maxH = max($this->_maxH, $size); |
|
| 3232 | + $this->_maxE++; |
|
| 3233 | + |
|
| 3234 | + $this->pdf->setX($x + $size); |
|
| 3235 | + |
|
| 3236 | + $this->parsingCss->load(); |
|
| 3237 | + $this->parsingCss->fontSet(); |
|
| 3238 | + |
|
| 3239 | + return true; |
|
| 3240 | + } |
|
| 3241 | + |
|
| 3242 | + /** |
|
| 3243 | + * tag : QRCODE |
|
| 3244 | + * mode : CLOSE |
|
| 3245 | + * |
|
| 3246 | + * @param array $param |
|
| 3247 | + * @return boolean |
|
| 3248 | + */ |
|
| 3249 | + protected function _tag_close_QRCODE($param) |
|
| 3250 | + { |
|
| 3251 | + // there is nothing to do here |
|
| 3252 | + |
|
| 3253 | + return true; |
|
| 3254 | + } |
|
| 3255 | + |
|
| 3256 | + /** |
|
| 3257 | + * tag : BOOKMARK |
|
| 3258 | + * mode : OPEN |
|
| 3259 | + * |
|
| 3260 | + * @param array $param |
|
| 3261 | + * @return boolean |
|
| 3262 | + */ |
|
| 3263 | + protected function _tag_open_BOOKMARK($param) |
|
| 3264 | + { |
|
| 3265 | + $titre = isset($param['title']) ? trim($param['title']) : ''; |
|
| 3266 | + $level = isset($param['level']) ? floor($param['level']) : 0; |
|
| 3267 | + |
|
| 3268 | + if ($level < 0) $level = 0; |
|
| 3269 | + if ($titre) $this->pdf->Bookmark($titre, $level, -1); |
|
| 3270 | + |
|
| 3271 | + return true; |
|
| 3272 | + } |
|
| 3273 | + |
|
| 3274 | + /** |
|
| 3275 | + * tag : BOOKMARK |
|
| 3276 | + * mode : CLOSE |
|
| 3277 | + * |
|
| 3278 | + * @param array $param |
|
| 3279 | + * @return boolean |
|
| 3280 | + */ |
|
| 3281 | + protected function _tag_close_BOOKMARK($param) |
|
| 3282 | + { |
|
| 3283 | + // there is nothing to do here |
|
| 3284 | + |
|
| 3285 | + return true; |
|
| 3286 | + } |
|
| 3287 | + |
|
| 3288 | + /** |
|
| 3289 | + * this is not a real TAG, it is just to write texts |
|
| 3290 | + * |
|
| 3291 | + * @param array $param |
|
| 3292 | + * @return null|boolean |
|
| 3293 | + */ |
|
| 3294 | + protected function _tag_open_WRITE($param) |
|
| 3295 | + { |
|
| 3296 | + $fill = ($this->parsingCss->value['background']['color'] !== null && $this->parsingCss->value['background']['image'] === null); |
|
| 3297 | + if (in_array($this->parsingCss->value['id_tag'], array('fieldset', 'legend', 'div', 'table', 'tr', 'td', 'th'))) { |
|
| 3298 | + $fill = false; |
|
| 3299 | + } |
|
| 3300 | + |
|
| 3301 | + // get the text to write |
|
| 3302 | + $txt = $param['txt']; |
|
| 3303 | + |
|
| 3304 | + if ($this->_isAfterFloat) { |
|
| 3305 | + $txt = ltrim($txt); |
|
| 3306 | + $this->_isAfterFloat = false; |
|
| 3307 | + } |
|
| 3308 | + |
|
| 3309 | + $txt = str_replace('[[page_nb]]', $this->pdf->getMyAliasNbPages(), $txt); |
|
| 3310 | + $txt = str_replace('[[page_cu]]', $this->pdf->getMyNumPage($this->_page), $txt); |
|
| 3311 | + |
|
| 3312 | + if ($this->parsingCss->value['text-transform'] != 'none') { |
|
| 3313 | + if ($this->parsingCss->value['text-transform'] == 'capitalize') |
|
| 3314 | + $txt = ucwords($txt); |
|
| 3315 | + else if ($this->parsingCss->value['text-transform'] == 'uppercase') |
|
| 3316 | + $txt = strtoupper($txt); |
|
| 3317 | + else if ($this->parsingCss->value['text-transform'] == 'lowercase') |
|
| 3318 | + $txt = strtolower($txt); |
|
| 3319 | + } |
|
| 3320 | + |
|
| 3321 | + // size of the text |
|
| 3322 | + $h = 1.08 * $this->parsingCss->value['font-size']; |
|
| 3323 | + $dh = $h * $this->parsingCss->value['mini-decal']; |
|
| 3324 | + $lh = $this->parsingCss->getLineHeight(); |
|
| 3325 | + |
|
| 3326 | + // identify the align |
|
| 3327 | + $align = 'L'; |
|
| 3328 | + if ($this->parsingCss->value['text-align'] == 'li_right') { |
|
| 3329 | + $w = $this->parsingCss->value['width']; |
|
| 3330 | + $align = 'R'; |
|
| 3331 | + } |
|
| 3332 | + |
|
| 3333 | + // calculate the width of each words, and of all the sentence |
|
| 3334 | + $w = 0; |
|
| 3335 | + $words = explode(' ', $txt); |
|
| 3336 | + foreach ($words as $k => $word) { |
|
| 3337 | + $words[$k] = array($word, $this->pdf->GetStringWidth($word)); |
|
| 3338 | + $w += $words[$k][1]; |
|
| 3339 | + } |
|
| 3340 | + $space = $this->pdf->GetStringWidth(' '); |
|
| 3341 | + $w += $space * (count($words) - 1); |
|
| 3342 | + |
|
| 3343 | + // position in the text |
|
| 3344 | + $currPos = 0; |
|
| 3345 | + |
|
| 3346 | + // the bigger width of the text, after automatic break line |
|
| 3347 | + $maxX = 0; |
|
| 3348 | + |
|
| 3349 | + // position of the text |
|
| 3350 | + $x = $this->pdf->getX(); |
|
| 3351 | + $y = $this->pdf->getY(); |
|
| 3352 | + $dy = $this->_getElementY($lh); |
|
| 3353 | + |
|
| 3354 | + // margins |
|
| 3355 | + list($left, $right) = $this->_getMargins($y); |
|
| 3356 | + |
|
| 3357 | + // number of lines after automatic break line |
|
| 3358 | + $nb = 0; |
|
| 3359 | + |
|
| 3360 | + // while we have words, and the text does not fit on the line => we cut the sentence |
|
| 3361 | + while ($x + $w > $right && $x < $right + $space && count($words)) { |
|
| 3362 | + // adding words 1 by 1 to fit on the line |
|
| 3363 | + $i = 0; |
|
| 3364 | + $old = array('', 0); |
|
| 3365 | + $str = $words[0]; |
|
| 3366 | + $add = false; |
|
| 3367 | + while (($x + $str[1]) < $right) { |
|
| 3368 | + $i++; |
|
| 3369 | + $add = true; |
|
| 3370 | + |
|
| 3371 | + array_shift($words); |
|
| 3372 | + $old = $str; |
|
| 3373 | + |
|
| 3374 | + if ( ! count($words)) break; |
|
| 3375 | + $str[0] .= ' '.$words[0][0]; |
|
| 3376 | + $str[1] += $space + $words[0][1]; |
|
| 3377 | + } |
|
| 3378 | + $str = $old; |
|
| 3379 | + |
|
| 3380 | + // if nothing fit on the line, and if the first word does not fit on the line => the word is too long, we put it |
|
| 3381 | + if ($i == 0 && (($left + $words[0][1]) >= $right)) { |
|
| 3382 | + $str = $words[0]; |
|
| 3383 | + array_shift($words); |
|
| 3384 | + $i++; |
|
| 3385 | + $add = true; |
|
| 3386 | + } |
|
| 3387 | + $currPos += ($currPos ? 1 : 0) + strlen($str[0]); |
|
| 3388 | + |
|
| 3389 | + // write the extract sentence that fit on the page |
|
| 3390 | + $wc = ($align == 'L' ? $str[1] : $this->parsingCss->value['width']); |
|
| 3391 | + if ($right - $left < $wc) $wc = $right - $left; |
|
| 3392 | + |
|
| 3393 | + if (strlen($str[0])) { |
|
| 3394 | + $this->pdf->setXY($this->pdf->getX(), $y + $dh + $dy); |
|
| 3395 | + $this->pdf->Cell($wc, $h, $str[0], 0, 0, $align, $fill, $this->_isInLink); |
|
| 3396 | + $this->pdf->setXY($this->pdf->getX(), $y); |
|
| 3397 | + } |
|
| 3398 | + $this->_maxH = max($this->_maxH, $lh); |
|
| 3399 | + |
|
| 3400 | + // max width |
|
| 3401 | + $maxX = max($maxX, $this->pdf->getX()); |
|
| 3402 | + |
|
| 3403 | + // new position and new width for the "while" |
|
| 3404 | + $w -= $str[1]; |
|
| 3405 | + $y = $this->pdf->getY(); |
|
| 3406 | + $x = $this->pdf->getX(); |
|
| 3407 | + $dy = $this->_getElementY($lh); |
|
| 3408 | + |
|
| 3409 | + // if we have again words to write |
|
| 3410 | + if (count($words)) { |
|
| 3411 | + // remove the space at the end |
|
| 3412 | + if ($add) $w -= $space; |
|
| 3413 | + |
|
| 3414 | + // if we don't add any word, and if the first word is empty => useless space to skip |
|
| 3415 | + if ( ! $add && $words[0][0] === '') { |
|
| 3416 | + array_shift($words); |
|
| 3417 | + } |
|
| 3418 | + |
|
| 3419 | + // if it is just to calculate for one line => adding the number of words |
|
| 3420 | + if ($this->_isForOneLine) { |
|
| 3421 | + $this->_maxE += $i; |
|
| 3422 | + $this->_maxX = max($this->_maxX, $maxX); |
|
| 3423 | + return null; |
|
| 3424 | + } |
|
| 3425 | + |
|
| 3426 | + // automatic line break |
|
| 3427 | + $this->_tag_open_BR(array('style' => ''), $currPos); |
|
| 3428 | + |
|
| 3429 | + // new position |
|
| 3430 | + $y = $this->pdf->getY(); |
|
| 3431 | + $x = $this->pdf->getX(); |
|
| 3432 | + $dy = $this->_getElementY($lh); |
|
| 3433 | + |
|
| 3434 | + // if the next line does not fit on the page => new page |
|
| 3435 | + if ($y + $h >= $this->pdf->getH() - $this->pdf->getbMargin()) { |
|
| 3436 | + if ( ! $this->_isInOverflow && ! $this->_isInFooter) { |
|
| 3437 | + $this->_setNewPage(null, '', null, $currPos); |
|
| 3438 | + $y = $this->pdf->getY(); |
|
| 3439 | + $x = $this->pdf->getX(); |
|
| 3440 | + $dy = $this->_getElementY($lh); |
|
| 3441 | + } |
|
| 3442 | + } |
|
| 3443 | + |
|
| 3444 | + // if more than 10000 line => error |
|
| 3445 | + $nb++; |
|
| 3446 | + if ($nb > 10000) { |
|
| 3447 | + $txt = ''; foreach ($words as $k => $word) $txt .= ($k ? ' ' : '').$word[0]; |
|
| 3448 | + throw new HTML2PDF_exception(2, array($txt, $right - $left, $w)); |
|
| 3449 | + } |
|
| 3450 | + |
|
| 3451 | + // new margins for the new line |
|
| 3452 | + list($left, $right) = $this->_getMargins($y); |
|
| 3453 | + } |
|
| 3454 | + } |
|
| 3455 | + |
|
| 3456 | + // if we have words after automatic cut, it is because they fit on the line => we write the text |
|
| 3457 | + if (count($words)) { |
|
| 3458 | + $txt = ''; foreach ($words as $k => $word) $txt .= ($k ? ' ' : '').$word[0]; |
|
| 3459 | + $w += $this->pdf->getWordSpacing() * (count($words)); |
|
| 3460 | + $this->pdf->setXY($this->pdf->getX(), $y + $dh + $dy); |
|
| 3461 | + $this->pdf->Cell(($align == 'L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink); |
|
| 3462 | + $this->pdf->setXY($this->pdf->getX(), $y); |
|
| 3463 | + $this->_maxH = max($this->_maxH, $lh); |
|
| 3464 | + $this->_maxE += count($words); |
|
| 3465 | + } |
|
| 3466 | + |
|
| 3467 | + $maxX = max($maxX, $this->pdf->getX()); |
|
| 3468 | + $maxY = $this->pdf->getY() + $h; |
|
| 3469 | + |
|
| 3470 | + $this->_maxX = max($this->_maxX, $maxX); |
|
| 3471 | + $this->_maxY = max($this->_maxY, $maxY); |
|
| 3472 | + |
|
| 3473 | + return true; |
|
| 3474 | + } |
|
| 3475 | + |
|
| 3476 | + /** |
|
| 3477 | + * tag : BR |
|
| 3478 | + * mode : OPEN |
|
| 3479 | + * |
|
| 3480 | + * @param array $param |
|
| 3481 | + * @param integer $curr real position in the html parseur (if break line in the write of a text) |
|
| 3482 | + * @return boolean |
|
| 3483 | + */ |
|
| 3484 | + protected function _tag_open_BR($param, $curr = null) |
|
| 3485 | + { |
|
| 3486 | + if ($this->_isForOneLine) return false; |
|
| 3487 | + |
|
| 3488 | + $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
|
| 3489 | + |
|
| 3490 | + if ($this->_maxH == 0) $this->_maxY = max($this->_maxY, $this->pdf->getY() + $h); |
|
| 3491 | + |
|
| 3492 | + $this->_makeBreakLine($h, $curr); |
|
| 3493 | + |
|
| 3494 | + $this->_maxH = 0; |
|
| 3495 | + $this->_maxE = 0; |
|
| 3496 | + |
|
| 3497 | + return true; |
|
| 3498 | + } |
|
| 3499 | + |
|
| 3500 | + /** |
|
| 3501 | + * tag : HR |
|
| 3502 | + * mode : OPEN |
|
| 3503 | + * |
|
| 3504 | + * @param array $param |
|
| 3505 | + * @return boolean |
|
| 3506 | + */ |
|
| 3507 | + protected function _tag_open_HR($param) |
|
| 3508 | + { |
|
| 3509 | + if ($this->_isForOneLine) { |
|
| 3510 | + return false; |
|
| 3511 | + } |
|
| 3512 | + $oldAlign = $this->parsingCss->value['text-align']; |
|
| 3513 | + $this->parsingCss->value['text-align'] = 'left'; |
|
| 3514 | + |
|
| 3515 | + if ($this->_maxH) { |
|
| 3516 | + $this->_tag_open_BR($param); |
|
| 3517 | + } |
|
| 3518 | + |
|
| 3519 | + $fontSize = $this->parsingCss->value['font-size']; |
|
| 3520 | + $this->parsingCss->value['font-size'] = $fontSize * 0.5; $this->_tag_open_BR($param); |
|
| 3521 | + $this->parsingCss->value['font-size'] = 0; |
|
| 3522 | + |
|
| 3523 | + $param['style']['width'] = '100%'; |
|
| 3524 | + |
|
| 3525 | + $this->parsingCss->save(); |
|
| 3526 | + $this->parsingCss->value['height'] = $this->parsingCss->ConvertToMM('1mm'); |
|
| 3527 | + |
|
| 3528 | + $this->parsingCss->analyse('hr', $param); |
|
| 3529 | + $this->parsingCss->setPosition(); |
|
| 3530 | + $this->parsingCss->fontSet(); |
|
| 3531 | + |
|
| 3532 | + $h = $this->parsingCss->value['height']; |
|
| 3533 | + if ($h) $h -= $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width']; |
|
| 3534 | + if ($h <= 0) $h = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width']; |
|
| 3535 | + |
|
| 3536 | + $this->_drawRectangle($this->pdf->getX(), $this->pdf->getY(), $this->parsingCss->value['width'], $h, $this->parsingCss->value['border'], 0, 0, $this->parsingCss->value['background']); |
|
| 3537 | + $this->_maxH = $h; |
|
| 3538 | + |
|
| 3539 | + $this->parsingCss->load(); |
|
| 3540 | + $this->parsingCss->fontSet(); |
|
| 3541 | + |
|
| 3542 | + $this->_tag_open_BR($param); |
|
| 3543 | + |
|
| 3544 | + $this->parsingCss->value['font-size'] = $fontSize * 0.5; $this->_tag_open_BR($param); |
|
| 3545 | + $this->parsingCss->value['font-size'] = $fontSize; |
|
| 3546 | + |
|
| 3547 | + $this->parsingCss->value['text-align'] = $oldAlign; |
|
| 3548 | + $this->_setNewPositionForNewLine(); |
|
| 3549 | + |
|
| 3550 | + return true; |
|
| 3551 | + } |
|
| 3552 | + |
|
| 3553 | + /** |
|
| 3554 | + * tag : B |
|
| 3555 | + * mode : OPEN |
|
| 3556 | + * |
|
| 3557 | + * @param array $param |
|
| 3558 | + * @param string $other |
|
| 3559 | + * @return boolean |
|
| 3560 | + */ |
|
| 3561 | + protected function _tag_open_B($param, $other = 'b') |
|
| 3562 | + { |
|
| 3563 | + $this->parsingCss->save(); |
|
| 3564 | + $this->parsingCss->value['font-bold'] = true; |
|
| 3565 | + $this->parsingCss->analyse($other, $param); |
|
| 3566 | + $this->parsingCss->setPosition(); |
|
| 3567 | + $this->parsingCss->fontSet(); |
|
| 3568 | + |
|
| 3569 | + return true; |
|
| 3570 | + } |
|
| 3571 | + |
|
| 3572 | + /** |
|
| 3573 | + * tag : STRONG |
|
| 3574 | + * mode : OPEN |
|
| 3575 | + * |
|
| 3576 | + * @param array $param |
|
| 3577 | + * @return boolean |
|
| 3578 | + */ |
|
| 3579 | + protected function _tag_open_STRONG($param) |
|
| 3580 | + { |
|
| 3581 | + return $this->_tag_open_B($param, 'strong'); |
|
| 3582 | + } |
|
| 3583 | + |
|
| 3584 | + /** |
|
| 3585 | + * tag : B |
|
| 3586 | + * mode : CLOSE |
|
| 3587 | + * |
|
| 3588 | + * @param array $param |
|
| 3589 | + * @return boolean |
|
| 3590 | + */ |
|
| 3591 | + protected function _tag_close_B($param) |
|
| 3592 | + { |
|
| 3593 | + $this->parsingCss->load(); |
|
| 3594 | + $this->parsingCss->fontSet(); |
|
| 3595 | + |
|
| 3596 | + return true; |
|
| 3597 | + } |
|
| 3598 | + |
|
| 3599 | + /** |
|
| 3600 | + * tag : STRONG |
|
| 3601 | + * mode : CLOSE |
|
| 3602 | + * |
|
| 3603 | + * @param array $param |
|
| 3604 | + * @return boolean |
|
| 3605 | + */ |
|
| 3606 | + protected function _tag_close_STRONG($param) |
|
| 3607 | + { |
|
| 3608 | + return $this->_tag_close_B($param); |
|
| 3609 | + } |
|
| 3610 | + |
|
| 3611 | + /** |
|
| 3612 | + * tag : I |
|
| 3613 | + * mode : OPEN |
|
| 3614 | + * |
|
| 3615 | + * @param array $param |
|
| 3616 | + * @param string $other |
|
| 3617 | + * @return boolean |
|
| 3618 | + */ |
|
| 3619 | + protected function _tag_open_I($param, $other = 'i') |
|
| 3620 | + { |
|
| 3621 | + $this->parsingCss->save(); |
|
| 3622 | + $this->parsingCss->value['font-italic'] = true; |
|
| 3623 | + $this->parsingCss->analyse($other, $param); |
|
| 3624 | + $this->parsingCss->setPosition(); |
|
| 3625 | + $this->parsingCss->fontSet(); |
|
| 3626 | + |
|
| 3627 | + return true; |
|
| 3628 | + } |
|
| 3629 | + |
|
| 3630 | + /** |
|
| 3631 | + * tag : ADDRESS |
|
| 3632 | + * mode : OPEN |
|
| 3633 | + * |
|
| 3634 | + * @param array $param |
|
| 3635 | + * @return boolean |
|
| 3636 | + */ |
|
| 3637 | + protected function _tag_open_ADDRESS($param) |
|
| 3638 | + { |
|
| 3639 | + return $this->_tag_open_I($param, 'address'); |
|
| 3640 | + } |
|
| 3641 | + |
|
| 3642 | + /** |
|
| 3643 | + * tag : CITE |
|
| 3644 | + * mode : OPEN |
|
| 3645 | + * |
|
| 3646 | + * @param array $param |
|
| 3647 | + * @return boolean |
|
| 3648 | + */ |
|
| 3649 | + protected function _tag_open_CITE($param) |
|
| 3650 | + { |
|
| 3651 | + return $this->_tag_open_I($param, 'cite'); |
|
| 3652 | + } |
|
| 3653 | + |
|
| 3654 | + /** |
|
| 3655 | + * tag : EM |
|
| 3656 | + * mode : OPEN |
|
| 3657 | + * |
|
| 3658 | + * @param array $param |
|
| 3659 | + * @return boolean |
|
| 3660 | + */ |
|
| 3661 | + protected function _tag_open_EM($param) |
|
| 3662 | + { |
|
| 3663 | + return $this->_tag_open_I($param, 'em'); |
|
| 3664 | + } |
|
| 3665 | + |
|
| 3666 | + /** |
|
| 3667 | + * tag : SAMP |
|
| 3668 | + * mode : OPEN |
|
| 3669 | + * |
|
| 3670 | + * @param array $param |
|
| 3671 | + * @return boolean |
|
| 3672 | + */ |
|
| 3673 | + protected function _tag_open_SAMP($param) |
|
| 3674 | + { |
|
| 3675 | + return $this->_tag_open_I($param, 'samp'); |
|
| 3676 | + } |
|
| 3677 | + |
|
| 3678 | + /** |
|
| 3679 | + * tag : I |
|
| 3680 | + * mode : CLOSE |
|
| 3681 | + * |
|
| 3682 | + * @param array $param |
|
| 3683 | + * @return boolean |
|
| 3684 | + */ |
|
| 3685 | + protected function _tag_close_I($param) |
|
| 3686 | + { |
|
| 3687 | + $this->parsingCss->load(); |
|
| 3688 | + $this->parsingCss->fontSet(); |
|
| 3689 | + |
|
| 3690 | + return true; |
|
| 3691 | + } |
|
| 3692 | + |
|
| 3693 | + /** |
|
| 3694 | + * tag : ADDRESS |
|
| 3695 | + * mode : CLOSE |
|
| 3696 | + * |
|
| 3697 | + * @param array $param |
|
| 3698 | + * @return boolean |
|
| 3699 | + */ |
|
| 3700 | + protected function _tag_close_ADDRESS($param) |
|
| 3701 | + { |
|
| 3702 | + return $this->_tag_close_I($param); |
|
| 3703 | + } |
|
| 3704 | + |
|
| 3705 | + /** |
|
| 3706 | + * tag : CITE |
|
| 3707 | + * mode : CLOSE |
|
| 3708 | + * |
|
| 3709 | + * @param array $param |
|
| 3710 | + * @return boolean |
|
| 3711 | + */ |
|
| 3712 | + protected function _tag_close_CITE($param) |
|
| 3713 | + { |
|
| 3714 | + return $this->_tag_close_I($param); |
|
| 3715 | + } |
|
| 3716 | + |
|
| 3717 | + /** |
|
| 3718 | + * tag : EM |
|
| 3719 | + * mode : CLOSE |
|
| 3720 | + * |
|
| 3721 | + * @param array $param |
|
| 3722 | + * @return boolean |
|
| 3723 | + */ |
|
| 3724 | + protected function _tag_close_EM($param) |
|
| 3725 | + { |
|
| 3726 | + return $this->_tag_close_I($param); |
|
| 3727 | + } |
|
| 3728 | + |
|
| 3729 | + /** |
|
| 3730 | + * tag : SAMP |
|
| 3731 | + * mode : CLOSE |
|
| 3732 | + * |
|
| 3733 | + * @param array $param |
|
| 3734 | + * @return boolean |
|
| 3735 | + */ |
|
| 3736 | + protected function _tag_close_SAMP($param) |
|
| 3737 | + { |
|
| 3738 | + return $this->_tag_close_I($param); |
|
| 3739 | + } |
|
| 3740 | + |
|
| 3741 | + /** |
|
| 3742 | + * tag : S |
|
| 3743 | + * mode : OPEN |
|
| 3744 | + * |
|
| 3745 | + * @param array $param |
|
| 3746 | + * @param string $other |
|
| 3747 | + * @return boolean |
|
| 3748 | + */ |
|
| 3749 | + protected function _tag_open_S($param, $other = 's') |
|
| 3750 | + { |
|
| 3751 | + $this->parsingCss->save(); |
|
| 3752 | + $this->parsingCss->value['font-linethrough'] = true; |
|
| 3753 | + $this->parsingCss->analyse($other, $param); |
|
| 3754 | + $this->parsingCss->setPosition(); |
|
| 3755 | + $this->parsingCss->fontSet(); |
|
| 3756 | + |
|
| 3757 | + return true; |
|
| 3758 | + } |
|
| 3759 | + |
|
| 3760 | + /** |
|
| 3761 | + * tag : DEL |
|
| 3762 | + * mode : OPEN |
|
| 3763 | + * |
|
| 3764 | + * @param array $param |
|
| 3765 | + * @return boolean |
|
| 3766 | + */ |
|
| 3767 | + protected function _tag_open_DEL($param) |
|
| 3768 | + { |
|
| 3769 | + return $this->_tag_open_S($param, 'del'); |
|
| 3770 | + } |
|
| 3771 | + |
|
| 3772 | + /** |
|
| 3773 | + * tag : S |
|
| 3774 | + * mode : CLOSE |
|
| 3775 | + * |
|
| 3776 | + * @param array $param |
|
| 3777 | + * @return boolean |
|
| 3778 | + */ |
|
| 3779 | + protected function _tag_close_S($param) |
|
| 3780 | + { |
|
| 3781 | + $this->parsingCss->load(); |
|
| 3782 | + $this->parsingCss->fontSet(); |
|
| 3783 | + |
|
| 3784 | + return true; |
|
| 3785 | + } |
|
| 3786 | + |
|
| 3787 | + /** |
|
| 3788 | + * tag : DEL |
|
| 3789 | + * mode : CLOSE |
|
| 3790 | + * |
|
| 3791 | + * @param array $param |
|
| 3792 | + * @return boolean |
|
| 3793 | + */ |
|
| 3794 | + protected function _tag_close_DEL($param) |
|
| 3795 | + { |
|
| 3796 | + return $this->_tag_close_S($param); |
|
| 3797 | + } |
|
| 3798 | + |
|
| 3799 | + /** |
|
| 3800 | + * tag : U |
|
| 3801 | + * mode : OPEN |
|
| 3802 | + * |
|
| 3803 | + * @param array $param |
|
| 3804 | + * @param string $other |
|
| 3805 | + * @return boolean |
|
| 3806 | + */ |
|
| 3807 | + protected function _tag_open_U($param, $other = 'u') |
|
| 3808 | + { |
|
| 3809 | + $this->parsingCss->save(); |
|
| 3810 | + $this->parsingCss->value['font-underline'] = true; |
|
| 3811 | + $this->parsingCss->analyse($other, $param); |
|
| 3812 | + $this->parsingCss->setPosition(); |
|
| 3813 | + $this->parsingCss->fontSet(); |
|
| 3814 | + |
|
| 3815 | + return true; |
|
| 3816 | + } |
|
| 3817 | + |
|
| 3818 | + /** |
|
| 3819 | + * tag : INS |
|
| 3820 | + * mode : OPEN |
|
| 3821 | + * |
|
| 3822 | + * @param array $param |
|
| 3823 | + * @return boolean |
|
| 3824 | + */ |
|
| 3825 | + protected function _tag_open_INS($param) |
|
| 3826 | + { |
|
| 3827 | + return $this->_tag_open_U($param, 'ins'); |
|
| 3828 | + } |
|
| 3829 | + |
|
| 3830 | + /** |
|
| 3831 | + * tag : U |
|
| 3832 | + * mode : CLOSE |
|
| 3833 | + * |
|
| 3834 | + * @param array $param |
|
| 3835 | + * @return boolean |
|
| 3836 | + */ |
|
| 3837 | + protected function _tag_close_U($param) |
|
| 3838 | + { |
|
| 3839 | + $this->parsingCss->load(); |
|
| 3840 | + $this->parsingCss->fontSet(); |
|
| 3841 | + |
|
| 3842 | + return true; |
|
| 3843 | + } |
|
| 3844 | + |
|
| 3845 | + /** |
|
| 3846 | + * tag : INS |
|
| 3847 | + * mode : CLOSE |
|
| 3848 | + * |
|
| 3849 | + * @param array $param |
|
| 3850 | + * @return boolean |
|
| 3851 | + */ |
|
| 3852 | + protected function _tag_close_INS($param) |
|
| 3853 | + { |
|
| 3854 | + return $this->_tag_close_U($param); |
|
| 3855 | + } |
|
| 3856 | + |
|
| 3857 | + /** |
|
| 3858 | + * tag : A |
|
| 3859 | + * mode : OPEN |
|
| 3860 | + * |
|
| 3861 | + * @param array $param |
|
| 3862 | + * @return boolean |
|
| 3863 | + */ |
|
| 3864 | + protected function _tag_open_A($param) |
|
| 3865 | + { |
|
| 3866 | + $this->_isInLink = str_replace('&', '&', isset($param['href']) ? $param['href'] : ''); |
|
| 3867 | + |
|
| 3868 | + if (isset($param['name'])) { |
|
| 3869 | + $name = $param['name']; |
|
| 3870 | + if ( ! isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 3871 | + |
|
| 3872 | + if ( ! $this->_lstAnchor[$name][1]) { |
|
| 3873 | + $this->_lstAnchor[$name][1] = true; |
|
| 3874 | + $this->pdf->SetLink($this->_lstAnchor[$name][0], -1, -1); |
|
| 3875 | + } |
|
| 3876 | + } |
|
| 3877 | + |
|
| 3878 | + if (preg_match('/^#([^#]+)$/isU', $this->_isInLink, $match)) { |
|
| 3879 | + $name = $match[1]; |
|
| 3880 | + if ( ! isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 3881 | + |
|
| 3882 | + $this->_isInLink = $this->_lstAnchor[$name][0]; |
|
| 3883 | + } |
|
| 3884 | + |
|
| 3885 | + $this->parsingCss->save(); |
|
| 3886 | + $this->parsingCss->value['font-underline'] = true; |
|
| 3887 | + $this->parsingCss->value['color'] = array(20, 20, 250); |
|
| 3888 | + $this->parsingCss->analyse('a', $param); |
|
| 3889 | + $this->parsingCss->setPosition(); |
|
| 3890 | + $this->parsingCss->fontSet(); |
|
| 3891 | + |
|
| 3892 | + return true; |
|
| 3893 | + } |
|
| 3894 | + |
|
| 3895 | + /** |
|
| 3896 | + * tag : A |
|
| 3897 | + * mode : CLOSE |
|
| 3898 | + * |
|
| 3899 | + * @param array $param |
|
| 3900 | + * @return boolean |
|
| 3901 | + */ |
|
| 3902 | + protected function _tag_close_A($param) |
|
| 3903 | + { |
|
| 3904 | + $this->_isInLink = ''; |
|
| 3905 | + $this->parsingCss->load(); |
|
| 3906 | + $this->parsingCss->fontSet(); |
|
| 3907 | + |
|
| 3908 | + return true; |
|
| 3909 | + } |
|
| 3910 | + |
|
| 3911 | + /** |
|
| 3912 | + * tag : H1 |
|
| 3913 | + * mode : OPEN |
|
| 3914 | + * |
|
| 3915 | + * @param array $param |
|
| 3916 | + * @param string $other |
|
| 3917 | + * @return boolean |
|
| 3918 | + */ |
|
| 3919 | + protected function _tag_open_H1($param, $other = 'h1') |
|
| 3920 | + { |
|
| 3921 | + if ($this->_isForOneLine) { |
|
| 3922 | + return false; |
|
| 3923 | + } |
|
| 3924 | + |
|
| 3925 | + if ($this->_maxH) { |
|
| 3926 | + $this->_tag_open_BR(array()); |
|
| 3927 | + } |
|
| 3928 | + $this->parsingCss->save(); |
|
| 3929 | + $this->parsingCss->value['font-bold'] = true; |
|
| 3930 | + |
|
| 3931 | + $size = array('h1' => '28px', 'h2' => '24px', 'h3' => '20px', 'h4' => '16px', 'h5' => '12px', 'h6' => '9px'); |
|
| 3932 | + $this->parsingCss->value['margin']['l'] = 0; |
|
| 3933 | + $this->parsingCss->value['margin']['r'] = 0; |
|
| 3934 | + $this->parsingCss->value['margin']['t'] = $this->parsingCss->ConvertToMM('16px'); |
|
| 3935 | + $this->parsingCss->value['margin']['b'] = $this->parsingCss->ConvertToMM('16px'); |
|
| 3936 | + $this->parsingCss->value['font-size'] = $this->parsingCss->ConvertToMM($size[$other]); |
|
| 3937 | + |
|
| 3938 | + $this->parsingCss->analyse($other, $param); |
|
| 3939 | + $this->parsingCss->setPosition(); |
|
| 3940 | + $this->parsingCss->fontSet(); |
|
| 3941 | + $this->_setNewPositionForNewLine(); |
|
| 3942 | + |
|
| 3943 | + return true; |
|
| 3944 | + } |
|
| 3945 | + |
|
| 3946 | + /** |
|
| 3947 | + * tag : H2 |
|
| 3948 | + * mode : OPEN |
|
| 3949 | + * |
|
| 3950 | + * @param array $param |
|
| 3951 | + * @return boolean |
|
| 3952 | + */ |
|
| 3953 | + protected function _tag_open_H2($param) |
|
| 3954 | + { |
|
| 3955 | + return $this->_tag_open_H1($param, 'h2'); |
|
| 3956 | + } |
|
| 3957 | + |
|
| 3958 | + /** |
|
| 3959 | + * tag : H3 |
|
| 3960 | + * mode : OPEN |
|
| 3961 | + * |
|
| 3962 | + * @param array $param |
|
| 3963 | + * @return boolean |
|
| 3964 | + */ |
|
| 3965 | + protected function _tag_open_H3($param) |
|
| 3966 | + { |
|
| 3967 | + return $this->_tag_open_H1($param, 'h3'); |
|
| 3968 | + } |
|
| 3969 | + |
|
| 3970 | + /** |
|
| 3971 | + * tag : H4 |
|
| 3972 | + * mode : OPEN |
|
| 3973 | + * |
|
| 3974 | + * @param array $param |
|
| 3975 | + * @return boolean |
|
| 3976 | + */ |
|
| 3977 | + protected function _tag_open_H4($param) |
|
| 3978 | + { |
|
| 3979 | + return $this->_tag_open_H1($param, 'h4'); |
|
| 3980 | + } |
|
| 3981 | + |
|
| 3982 | + /** |
|
| 3983 | + * tag : H5 |
|
| 3984 | + * mode : OPEN |
|
| 3985 | + * |
|
| 3986 | + * @param array $param |
|
| 3987 | + * @return boolean |
|
| 3988 | + */ |
|
| 3989 | + protected function _tag_open_H5($param) |
|
| 3990 | + { |
|
| 3991 | + return $this->_tag_open_H1($param, 'h5'); |
|
| 3992 | + } |
|
| 3993 | + |
|
| 3994 | + /** |
|
| 3995 | + * tag : H6 |
|
| 3996 | + * mode : OPEN |
|
| 3997 | + * |
|
| 3998 | + * @param array $param |
|
| 3999 | + * @return boolean |
|
| 4000 | + */ |
|
| 4001 | + protected function _tag_open_H6($param) |
|
| 4002 | + { |
|
| 4003 | + return $this->_tag_open_H1($param, 'h6'); |
|
| 4004 | + } |
|
| 4005 | + |
|
| 4006 | + /** |
|
| 4007 | + * tag : H1 |
|
| 4008 | + * mode : CLOSE |
|
| 4009 | + * |
|
| 4010 | + * @param array $param |
|
| 4011 | + * @return boolean |
|
| 4012 | + */ |
|
| 4013 | + protected function _tag_close_H1($param) |
|
| 4014 | + { |
|
| 4015 | + if ($this->_isForOneLine) { |
|
| 4016 | + return false; |
|
| 4017 | + } |
|
| 4018 | + |
|
| 4019 | + $this->_maxH += $this->parsingCss->value['margin']['b']; |
|
| 4020 | + $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
|
| 4021 | + |
|
| 4022 | + $this->parsingCss->load(); |
|
| 4023 | + $this->parsingCss->fontSet(); |
|
| 4024 | + |
|
| 4025 | + $this->_makeBreakLine($h); |
|
| 4026 | + $this->_maxH = 0; |
|
| 4027 | + |
|
| 4028 | + $this->_maxY = max($this->_maxY, $this->pdf->getY()); |
|
| 4029 | + |
|
| 4030 | + return true; |
|
| 4031 | + } |
|
| 4032 | + |
|
| 4033 | + /** |
|
| 4034 | + * tag : H2 |
|
| 4035 | + * mode : CLOSE |
|
| 4036 | + * |
|
| 4037 | + * @param array $param |
|
| 4038 | + * @return boolean |
|
| 4039 | + */ |
|
| 4040 | + protected function _tag_close_H2($param) |
|
| 4041 | + { |
|
| 4042 | + return $this->_tag_close_H1($param); |
|
| 4043 | + } |
|
| 4044 | + |
|
| 4045 | + /** |
|
| 4046 | + * tag : H3 |
|
| 4047 | + * mode : CLOSE |
|
| 4048 | + * |
|
| 4049 | + * @param array $param |
|
| 4050 | + * @return boolean |
|
| 4051 | + */ |
|
| 4052 | + protected function _tag_close_H3($param) |
|
| 4053 | + { |
|
| 4054 | + return $this->_tag_close_H1($param); |
|
| 4055 | + } |
|
| 4056 | + |
|
| 4057 | + /** |
|
| 4058 | + * tag : H4 |
|
| 4059 | + * mode : CLOSE |
|
| 4060 | + * |
|
| 4061 | + * @param array $param |
|
| 4062 | + * @return boolean |
|
| 4063 | + */ |
|
| 4064 | + protected function _tag_close_H4($param) |
|
| 4065 | + { |
|
| 4066 | + return $this->_tag_close_H1($param); |
|
| 4067 | + } |
|
| 4068 | + |
|
| 4069 | + /** |
|
| 4070 | + * tag : H5 |
|
| 4071 | + * mode : CLOSE |
|
| 4072 | + * |
|
| 4073 | + * @param array $param |
|
| 4074 | + * @return boolean |
|
| 4075 | + */ |
|
| 4076 | + protected function _tag_close_H5($param) |
|
| 4077 | + { |
|
| 4078 | + return $this->_tag_close_H1($param); |
|
| 4079 | + } |
|
| 4080 | + |
|
| 4081 | + /** |
|
| 4082 | + * tag : H6 |
|
| 4083 | + * mode : CLOSE |
|
| 4084 | + * |
|
| 4085 | + * @param array $param |
|
| 4086 | + * @return boolean |
|
| 4087 | + */ |
|
| 4088 | + protected function _tag_close_H6($param) |
|
| 4089 | + { |
|
| 4090 | + return $this->_tag_close_H1($param); |
|
| 4091 | + } |
|
| 4092 | + |
|
| 4093 | + /** |
|
| 4094 | + * tag : SPAN |
|
| 4095 | + * mode : OPEN |
|
| 4096 | + * |
|
| 4097 | + * @param array $param |
|
| 4098 | + * @param string $other |
|
| 4099 | + * @return boolean |
|
| 4100 | + */ |
|
| 4101 | + protected function _tag_open_SPAN($param, $other = 'span') |
|
| 4102 | + { |
|
| 4103 | + $this->parsingCss->save(); |
|
| 4104 | + $this->parsingCss->analyse($other, $param); |
|
| 4105 | + $this->parsingCss->setPosition(); |
|
| 4106 | + $this->parsingCss->fontSet(); |
|
| 4107 | + |
|
| 4108 | + return true; |
|
| 4109 | + } |
|
| 4110 | + |
|
| 4111 | + /** |
|
| 4112 | + * tag : FONT |
|
| 4113 | + * mode : OPEN |
|
| 4114 | + * |
|
| 4115 | + * @param array $param |
|
| 4116 | + * @return boolean |
|
| 4117 | + */ |
|
| 4118 | + protected function _tag_open_FONT($param) |
|
| 4119 | + { |
|
| 4120 | + return $this->_tag_open_SPAN($param, 'font'); |
|
| 4121 | + } |
|
| 4122 | + |
|
| 4123 | + /** |
|
| 4124 | + * tag : LABEL |
|
| 4125 | + * mode : OPEN |
|
| 4126 | + * |
|
| 4127 | + * @param array $param |
|
| 4128 | + * @return boolean |
|
| 4129 | + */ |
|
| 4130 | + protected function _tag_open_LABEL($param) |
|
| 4131 | + { |
|
| 4132 | + return $this->_tag_open_SPAN($param, 'label'); |
|
| 4133 | + } |
|
| 4134 | + |
|
| 4135 | + /** |
|
| 4136 | + * tag : SPAN |
|
| 4137 | + * mode : CLOSE |
|
| 4138 | + * |
|
| 4139 | + * @param array $param |
|
| 4140 | + * @return boolean |
|
| 4141 | + */ |
|
| 4142 | + protected function _tag_close_SPAN($param) |
|
| 4143 | + { |
|
| 4144 | + $this->parsingCss->restorePosition(); |
|
| 4145 | + $this->parsingCss->load(); |
|
| 4146 | + $this->parsingCss->fontSet(); |
|
| 4147 | + |
|
| 4148 | + return true; |
|
| 4149 | + } |
|
| 4150 | + |
|
| 4151 | + /** |
|
| 4152 | + * tag : FONT |
|
| 4153 | + * mode : CLOSE |
|
| 4154 | + * |
|
| 4155 | + * @param array $param |
|
| 4156 | + * @return boolean |
|
| 4157 | + */ |
|
| 4158 | + protected function _tag_close_FONT($param) |
|
| 4159 | + { |
|
| 4160 | + return $this->_tag_close_SPAN($param); |
|
| 4161 | + } |
|
| 4162 | + |
|
| 4163 | + /** |
|
| 4164 | + * tag : LABEL |
|
| 4165 | + * mode : CLOSE |
|
| 4166 | + * |
|
| 4167 | + * @param array $param |
|
| 4168 | + * @return boolean |
|
| 4169 | + */ |
|
| 4170 | + protected function _tag_close_LABEL($param) |
|
| 4171 | + { |
|
| 4172 | + return $this->_tag_close_SPAN($param); |
|
| 4173 | + } |
|
| 4174 | + |
|
| 4175 | + /** |
|
| 4176 | + * tag : P |
|
| 4177 | + * mode : OPEN |
|
| 4178 | + * |
|
| 4179 | + * @param array $param |
|
| 4180 | + * @return boolean |
|
| 4181 | + */ |
|
| 4182 | + protected function _tag_open_P($param) |
|
| 4183 | + { |
|
| 4184 | + if ($this->_isForOneLine) return false; |
|
| 4185 | + |
|
| 4186 | + if ( ! in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
|
| 4187 | + if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4188 | + } |
|
| 4189 | + |
|
| 4190 | + $this->parsingCss->save(); |
|
| 4191 | + $this->parsingCss->analyse('p', $param); |
|
| 4192 | + $this->parsingCss->setPosition(); |
|
| 4193 | + $this->parsingCss->fontSet(); |
|
| 4194 | + |
|
| 4195 | + // cancel the effects of the setPosition |
|
| 4196 | + $this->pdf->setXY($this->pdf->getX() - $this->parsingCss->value['margin']['l'], $this->pdf->getY() - $this->parsingCss->value['margin']['t']); |
|
| 4197 | + |
|
| 4198 | + list($mL, $mR) = $this->_getMargins($this->pdf->getY()); |
|
| 4199 | + $mR = $this->pdf->getW() - $mR; |
|
| 4200 | + $mL += $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['padding']['l']; |
|
| 4201 | + $mR += $this->parsingCss->value['margin']['r'] + $this->parsingCss->value['padding']['r']; |
|
| 4202 | + $this->_saveMargin($mL, 0, $mR); |
|
| 4203 | + |
|
| 4204 | + if ($this->parsingCss->value['text-indent'] > 0) { |
|
| 4205 | + $y = $this->pdf->getY() + $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['padding']['t']; |
|
| 4206 | + $this->_pageMarges[floor($y * 100)] = array($mL + $this->parsingCss->value['text-indent'], $this->pdf->getW() - $mR); |
|
| 4207 | + $y += $this->parsingCss->getLineHeight() * 0.1; |
|
| 4208 | + $this->_pageMarges[floor($y * 100)] = array($mL, $this->pdf->getW() - $mR); |
|
| 4209 | + } |
|
| 4210 | + $this->_makeBreakLine($this->parsingCss->value['margin']['t'] + $this->parsingCss->value['padding']['t']); |
|
| 4211 | + $this->_isInParagraph = array($mL, $mR); |
|
| 4212 | + return true; |
|
| 4213 | + } |
|
| 4214 | + |
|
| 4215 | + /** |
|
| 4216 | + * tag : P |
|
| 4217 | + * mode : CLOSE |
|
| 4218 | + * |
|
| 4219 | + * @param array $param |
|
| 4220 | + * @return boolean |
|
| 4221 | + */ |
|
| 4222 | + protected function _tag_close_P($param) |
|
| 4223 | + { |
|
| 4224 | + if ($this->_isForOneLine) { |
|
| 4225 | + return false; |
|
| 4226 | + } |
|
| 4227 | + |
|
| 4228 | + if ($this->_maxH) { |
|
| 4229 | + $this->_tag_open_BR(array()); |
|
| 4230 | + } |
|
| 4231 | + $this->_isInParagraph = false; |
|
| 4232 | + $this->_loadMargin(); |
|
| 4233 | + $h = $this->parsingCss->value['margin']['b'] + $this->parsingCss->value['padding']['b']; |
|
| 4234 | + |
|
| 4235 | + $this->parsingCss->load(); |
|
| 4236 | + $this->parsingCss->fontSet(); |
|
| 4237 | + $this->_makeBreakLine($h); |
|
| 4238 | + |
|
| 4239 | + return true; |
|
| 4240 | + } |
|
| 4241 | + |
|
| 4242 | + /** |
|
| 4243 | + * tag : PRE |
|
| 4244 | + * mode : OPEN |
|
| 4245 | + * |
|
| 4246 | + * @param array $param |
|
| 4247 | + * @param string $other |
|
| 4248 | + * @return boolean |
|
| 4249 | + */ |
|
| 4250 | + protected function _tag_open_PRE($param, $other = 'pre') |
|
| 4251 | + { |
|
| 4252 | + if ($other == 'pre' && $this->_maxH) $this->_tag_open_BR(array()); |
|
| 4253 | + |
|
| 4254 | + $this->parsingCss->save(); |
|
| 4255 | + $this->parsingCss->value['font-family'] = 'courier'; |
|
| 4256 | + $this->parsingCss->analyse($other, $param); |
|
| 4257 | + $this->parsingCss->setPosition(); |
|
| 4258 | + $this->parsingCss->fontSet(); |
|
| 4259 | + |
|
| 4260 | + if ($other == 'pre') return $this->_tag_open_DIV($param, $other); |
|
| 4261 | + |
|
| 4262 | + return true; |
|
| 4263 | + } |
|
| 4264 | + |
|
| 4265 | + /** |
|
| 4266 | + * tag : CODE |
|
| 4267 | + * mode : OPEN |
|
| 4268 | + * |
|
| 4269 | + * @param array $param |
|
| 4270 | + * @return boolean |
|
| 4271 | + */ |
|
| 4272 | + protected function _tag_open_CODE($param) |
|
| 4273 | + { |
|
| 4274 | + return $this->_tag_open_PRE($param, 'code'); |
|
| 4275 | + } |
|
| 4276 | + |
|
| 4277 | + /** |
|
| 4278 | + * tag : PRE |
|
| 4279 | + * mode : CLOSE |
|
| 4280 | + * |
|
| 4281 | + * @param array $param |
|
| 4282 | + * @param string $other |
|
| 4283 | + * @return boolean |
|
| 4284 | + */ |
|
| 4285 | + protected function _tag_close_PRE($param, $other = 'pre') |
|
| 4286 | + { |
|
| 4287 | + if ($other == 'pre') { |
|
| 4288 | + if ($this->_isForOneLine) return false; |
|
| 4289 | + |
|
| 4290 | + $this->_tag_close_DIV($param, $other); |
|
| 4291 | + $this->_tag_open_BR(array()); |
|
| 4292 | + } |
|
| 4293 | + $this->parsingCss->load(); |
|
| 4294 | + $this->parsingCss->fontSet(); |
|
| 4295 | + |
|
| 4296 | + return true; |
|
| 4297 | + } |
|
| 4298 | + |
|
| 4299 | + /** |
|
| 4300 | + * tag : CODE |
|
| 4301 | + * mode : CLOSE |
|
| 4302 | + * |
|
| 4303 | + * @param array $param |
|
| 4304 | + * @return boolean |
|
| 4305 | + */ |
|
| 4306 | + protected function _tag_close_CODE($param) |
|
| 4307 | + { |
|
| 4308 | + return $this->_tag_close_PRE($param, 'code'); |
|
| 4309 | + } |
|
| 4310 | + |
|
| 4311 | + /** |
|
| 4312 | + * tag : BIG |
|
| 4313 | + * mode : OPEN |
|
| 4314 | + * |
|
| 4315 | + * @param array $param |
|
| 4316 | + * @return boolean |
|
| 4317 | + */ |
|
| 4318 | + protected function _tag_open_BIG($param) |
|
| 4319 | + { |
|
| 4320 | + $this->parsingCss->save(); |
|
| 4321 | + $this->parsingCss->value['mini-decal'] -= $this->parsingCss->value['mini-size'] * 0.12; |
|
| 4322 | + $this->parsingCss->value['mini-size'] *= 1.2; |
|
| 4323 | + $this->parsingCss->analyse('big', $param); |
|
| 4324 | + $this->parsingCss->setPosition(); |
|
| 4325 | + $this->parsingCss->fontSet(); |
|
| 4326 | + return true; |
|
| 4327 | + } |
|
| 4328 | + |
|
| 4329 | + /** |
|
| 4330 | + * tag : BIG |
|
| 4331 | + * mode : CLOSE |
|
| 4332 | + * |
|
| 4333 | + * @param array $param |
|
| 4334 | + * @return boolean |
|
| 4335 | + */ |
|
| 4336 | + protected function _tag_close_BIG($param) |
|
| 4337 | + { |
|
| 4338 | + $this->parsingCss->load(); |
|
| 4339 | + $this->parsingCss->fontSet(); |
|
| 4340 | + |
|
| 4341 | + return true; |
|
| 4342 | + } |
|
| 4343 | + |
|
| 4344 | + /** |
|
| 4345 | + * tag : SMALL |
|
| 4346 | + * mode : OPEN |
|
| 4347 | + * |
|
| 4348 | + * @param array $param |
|
| 4349 | + * @return boolean |
|
| 4350 | + */ |
|
| 4351 | + protected function _tag_open_SMALL($param) |
|
| 4352 | + { |
|
| 4353 | + $this->parsingCss->save(); |
|
| 4354 | + $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.05; |
|
| 4355 | + $this->parsingCss->value['mini-size'] *= 0.82; |
|
| 4356 | + $this->parsingCss->analyse('small', $param); |
|
| 4357 | + $this->parsingCss->setPosition(); |
|
| 4358 | + $this->parsingCss->fontSet(); |
|
| 4359 | + return true; |
|
| 4360 | + } |
|
| 4361 | + |
|
| 4362 | + /** |
|
| 4363 | + * tag : SMALL |
|
| 4364 | + * mode : CLOSE |
|
| 4365 | + * |
|
| 4366 | + * @param array $param |
|
| 4367 | + * @return boolean |
|
| 4368 | + */ |
|
| 4369 | + protected function _tag_close_SMALL($param) |
|
| 4370 | + { |
|
| 4371 | + $this->parsingCss->load(); |
|
| 4372 | + $this->parsingCss->fontSet(); |
|
| 4373 | + |
|
| 4374 | + return true; |
|
| 4375 | + } |
|
| 4376 | + |
|
| 4377 | + /** |
|
| 4378 | + * tag : SUP |
|
| 4379 | + * mode : OPEN |
|
| 4380 | + * |
|
| 4381 | + * @param array $param |
|
| 4382 | + * @return boolean |
|
| 4383 | + */ |
|
| 4384 | + protected function _tag_open_SUP($param) |
|
| 4385 | + { |
|
| 4386 | + $this->parsingCss->save(); |
|
| 4387 | + $this->parsingCss->value['mini-decal'] -= $this->parsingCss->value['mini-size'] * 0.15; |
|
| 4388 | + $this->parsingCss->value['mini-size'] *= 0.75; |
|
| 4389 | + $this->parsingCss->analyse('sup', $param); |
|
| 4390 | + $this->parsingCss->setPosition(); |
|
| 4391 | + $this->parsingCss->fontSet(); |
|
| 4392 | + |
|
| 4393 | + return true; |
|
| 4394 | + } |
|
| 4395 | + |
|
| 4396 | + /** |
|
| 4397 | + * tag : SUP |
|
| 4398 | + * mode : CLOSE |
|
| 4399 | + * |
|
| 4400 | + * @param array $param |
|
| 4401 | + * @return boolean |
|
| 4402 | + */ |
|
| 4403 | + protected function _tag_close_SUP($param) |
|
| 4404 | + { |
|
| 4405 | + $this->parsingCss->load(); |
|
| 4406 | + $this->parsingCss->fontSet(); |
|
| 4407 | + |
|
| 4408 | + return true; |
|
| 4409 | + } |
|
| 4410 | + |
|
| 4411 | + /** |
|
| 4412 | + * tag : SUB |
|
| 4413 | + * mode : OPEN |
|
| 4414 | + * |
|
| 4415 | + * @param array $param |
|
| 4416 | + * @return boolean |
|
| 4417 | + */ |
|
| 4418 | + protected function _tag_open_SUB($param) |
|
| 4419 | + { |
|
| 4420 | + $this->parsingCss->save(); |
|
| 4421 | + $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.15; |
|
| 4422 | + $this->parsingCss->value['mini-size'] *= 0.75; |
|
| 4423 | + $this->parsingCss->analyse('sub', $param); |
|
| 4424 | + $this->parsingCss->setPosition(); |
|
| 4425 | + $this->parsingCss->fontSet(); |
|
| 4426 | + return true; |
|
| 4427 | + } |
|
| 4428 | + |
|
| 4429 | + /** |
|
| 4430 | + * tag : SUB |
|
| 4431 | + * mode : CLOSE |
|
| 4432 | + * |
|
| 4433 | + * @param array $param |
|
| 4434 | + * @return boolean |
|
| 4435 | + */ |
|
| 4436 | + protected function _tag_close_SUB($param) |
|
| 4437 | + { |
|
| 4438 | + $this->parsingCss->load(); |
|
| 4439 | + $this->parsingCss->fontSet(); |
|
| 4440 | + |
|
| 4441 | + return true; |
|
| 4442 | + } |
|
| 4443 | + |
|
| 4444 | + /** |
|
| 4445 | + * tag : UL |
|
| 4446 | + * mode : OPEN |
|
| 4447 | + * |
|
| 4448 | + * @param array $param |
|
| 4449 | + * @param string $other |
|
| 4450 | + * @return boolean |
|
| 4451 | + */ |
|
| 4452 | + protected function _tag_open_UL($param, $other = 'ul') |
|
| 4453 | + { |
|
| 4454 | + if ($this->_isForOneLine) return false; |
|
| 4455 | + |
|
| 4456 | + if ( ! in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
|
| 4457 | + if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4458 | + if ( ! count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4459 | + } |
|
| 4460 | + |
|
| 4461 | + if ( ! isset($param['style']['width'])) $param['allwidth'] = true; |
|
| 4462 | + $param['cellspacing'] = 0; |
|
| 4463 | + |
|
| 4464 | + // a list is like a table |
|
| 4465 | + $this->_tag_open_TABLE($param, $other); |
|
| 4466 | + |
|
| 4467 | + // add a level of list |
|
| 4468 | + $this->_listeAddLevel($other, $this->parsingCss->value['list-style-type'], $this->parsingCss->value['list-style-image']); |
|
| 4469 | + |
|
| 4470 | + return true; |
|
| 4471 | + } |
|
| 4472 | + |
|
| 4473 | + /** |
|
| 4474 | + * tag : OL |
|
| 4475 | + * mode : OPEN |
|
| 4476 | + * |
|
| 4477 | + * @param array $param |
|
| 4478 | + * @return boolean |
|
| 4479 | + */ |
|
| 4480 | + protected function _tag_open_OL($param) |
|
| 4481 | + { |
|
| 4482 | + return $this->_tag_open_UL($param, 'ol'); |
|
| 4483 | + } |
|
| 4484 | + |
|
| 4485 | + /** |
|
| 4486 | + * tag : UL |
|
| 4487 | + * mode : CLOSE |
|
| 4488 | + * |
|
| 4489 | + * @param array $param |
|
| 4490 | + * @return boolean |
|
| 4491 | + */ |
|
| 4492 | + protected function _tag_close_UL($param) |
|
| 4493 | + { |
|
| 4494 | + if ($this->_isForOneLine) return false; |
|
| 4495 | + |
|
| 4496 | + $this->_tag_close_TABLE($param); |
|
| 4497 | + |
|
| 4498 | + $this->_listeDelLevel(); |
|
| 4499 | + |
|
| 4500 | + if ( ! $this->_subPart) { |
|
| 4501 | + if ( ! count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4502 | + } |
|
| 4503 | + |
|
| 4504 | + return true; |
|
| 4505 | + } |
|
| 4506 | + |
|
| 4507 | + /** |
|
| 4508 | + * tag : OL |
|
| 4509 | + * mode : CLOSE |
|
| 4510 | + * |
|
| 4511 | + * @param array $param |
|
| 4512 | + * @return boolean |
|
| 4513 | + */ |
|
| 4514 | + protected function _tag_close_OL($param) |
|
| 4515 | + { |
|
| 4516 | + return $this->_tag_close_UL($param); |
|
| 4517 | + } |
|
| 4518 | + |
|
| 4519 | + /** |
|
| 4520 | + * tag : LI |
|
| 4521 | + * mode : OPEN |
|
| 4522 | + * |
|
| 4523 | + * @param array $param |
|
| 4524 | + * @return boolean |
|
| 4525 | + */ |
|
| 4526 | + protected function _tag_open_LI($param) |
|
| 4527 | + { |
|
| 4528 | + if ($this->_isForOneLine) return false; |
|
| 4529 | + |
|
| 4530 | + $this->_listeAddLi(); |
|
| 4531 | + |
|
| 4532 | + if ( ! isset($param['style']['width'])) $param['style']['width'] = '100%'; |
|
| 4533 | + |
|
| 4534 | + $paramPUCE = $param; |
|
| 4535 | + |
|
| 4536 | + $inf = $this->_listeGetLi(); |
|
| 4537 | + if ($inf[0]) { |
|
| 4538 | + $paramPUCE['style']['font-family'] = $inf[0]; |
|
| 4539 | + $paramPUCE['style']['text-align'] = 'li_right'; |
|
| 4540 | + $paramPUCE['style']['vertical-align'] = 'top'; |
|
| 4541 | + $paramPUCE['style']['width'] = $this->_listeGetWidth(); |
|
| 4542 | + $paramPUCE['style']['padding-right'] = $this->_listeGetPadding(); |
|
| 4543 | + $paramPUCE['txt'] = $inf[2]; |
|
| 4544 | + } else { |
|
| 4545 | + $paramPUCE['style']['text-align'] = 'li_right'; |
|
| 4546 | + $paramPUCE['style']['vertical-align'] = 'top'; |
|
| 4547 | + $paramPUCE['style']['width'] = $this->_listeGetWidth(); |
|
| 4548 | + $paramPUCE['style']['padding-right'] = $this->_listeGetPadding(); |
|
| 4549 | + $paramPUCE['src'] = $inf[2]; |
|
| 4550 | + $paramPUCE['sub_li'] = true; |
|
| 4551 | + } |
|
| 4552 | + |
|
| 4553 | + $this->_tag_open_TR($param, 'li'); |
|
| 4554 | + |
|
| 4555 | + $this->parsingCss->save(); |
|
| 4556 | + |
|
| 4557 | + // if small LI |
|
| 4558 | + if ($inf[1]) { |
|
| 4559 | + $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.045; |
|
| 4560 | + $this->parsingCss->value['mini-size'] *= 0.75; |
|
| 4561 | + } |
|
| 4562 | + |
|
| 4563 | + // if we are in a sub html => prepare. Else : display |
|
| 4564 | + if ($this->_subPart) { |
|
| 4565 | + // TD for the puce |
|
| 4566 | + $tmpPos = $this->_tempPos; |
|
| 4567 | + $tmpLst1 = $this->parsingHtml->code[$tmpPos + 1]; |
|
| 4568 | + $tmpLst2 = $this->parsingHtml->code[$tmpPos + 2]; |
|
| 4569 | + $this->parsingHtml->code[$tmpPos + 1] = array(); |
|
| 4570 | + $this->parsingHtml->code[$tmpPos + 1]['name'] = (isset($paramPUCE['src'])) ? 'img' : 'write'; |
|
| 4571 | + $this->parsingHtml->code[$tmpPos + 1]['param'] = $paramPUCE; unset($this->parsingHtml->code[$tmpPos + 1]['param']['style']['width']); |
|
| 4572 | + $this->parsingHtml->code[$tmpPos + 1]['close'] = 0; |
|
| 4573 | + $this->parsingHtml->code[$tmpPos + 2] = array(); |
|
| 4574 | + $this->parsingHtml->code[$tmpPos + 2]['name'] = 'li'; |
|
| 4575 | + $this->parsingHtml->code[$tmpPos + 2]['param'] = $paramPUCE; |
|
| 4576 | + $this->parsingHtml->code[$tmpPos + 2]['close'] = 1; |
|
| 4577 | + $this->_tag_open_TD($paramPUCE, 'li_sub'); |
|
| 4578 | + $this->_tag_close_TD($param); |
|
| 4579 | + $this->_tempPos = $tmpPos; |
|
| 4580 | + $this->parsingHtml->code[$tmpPos + 1] = $tmpLst1; |
|
| 4581 | + $this->parsingHtml->code[$tmpPos + 2] = $tmpLst2; |
|
| 4582 | + } else { |
|
| 4583 | + // TD for the puce |
|
| 4584 | + $this->_tag_open_TD($paramPUCE, 'li_sub'); |
|
| 4585 | + unset($paramPUCE['style']['width']); |
|
| 4586 | + if (isset($paramPUCE['src'])) { |
|
| 4587 | + $this->_tag_open_IMG($paramPUCE); |
|
| 4588 | + } else { |
|
| 4589 | + $this->_tag_open_WRITE($paramPUCE); |
|
| 4590 | + } |
|
| 4591 | + $this->_tag_close_TD($paramPUCE); |
|
| 4592 | + } |
|
| 4593 | + $this->parsingCss->load(); |
|
| 4594 | + |
|
| 4595 | + |
|
| 4596 | + // TD for the content |
|
| 4597 | + $this->_tag_open_TD($param, 'li'); |
|
| 4598 | + |
|
| 4599 | + return true; |
|
| 4600 | + } |
|
| 4601 | + |
|
| 4602 | + /** |
|
| 4603 | + * tag : LI |
|
| 4604 | + * mode : CLOSE |
|
| 4605 | + * |
|
| 4606 | + * @param array $param |
|
| 4607 | + * @return boolean |
|
| 4608 | + */ |
|
| 4609 | + protected function _tag_close_LI($param) |
|
| 4610 | + { |
|
| 4611 | + if ($this->_isForOneLine) { |
|
| 4612 | + return false; |
|
| 4613 | + } |
|
| 4614 | + |
|
| 4615 | + $this->_tag_close_TD($param); |
|
| 4616 | + |
|
| 4617 | + $this->_tag_close_TR($param); |
|
| 4618 | + |
|
| 4619 | + return true; |
|
| 4620 | + } |
|
| 4621 | + |
|
| 4622 | + /** |
|
| 4623 | + * tag : TBODY |
|
| 4624 | + * mode : OPEN |
|
| 4625 | + * |
|
| 4626 | + * @param array $param |
|
| 4627 | + * @return boolean |
|
| 4628 | + */ |
|
| 4629 | + protected function _tag_open_TBODY($param) |
|
| 4630 | + { |
|
| 4631 | + if ($this->_isForOneLine) { |
|
| 4632 | + return false; |
|
| 4633 | + } |
|
| 4634 | + |
|
| 4635 | + $this->parsingCss->save(); |
|
| 4636 | + $this->parsingCss->analyse('tbody', $param); |
|
| 4637 | + $this->parsingCss->setPosition(); |
|
| 4638 | + $this->parsingCss->fontSet(); |
|
| 4639 | + |
|
| 4640 | + return true; |
|
| 4641 | + } |
|
| 4642 | + |
|
| 4643 | + /** |
|
| 4644 | + * tag : TBODY |
|
| 4645 | + * mode : CLOSE |
|
| 4646 | + * |
|
| 4647 | + * @param array $param |
|
| 4648 | + * @return boolean |
|
| 4649 | + */ |
|
| 4650 | + protected function _tag_close_TBODY($param) |
|
| 4651 | + { |
|
| 4652 | + if ($this->_isForOneLine) { |
|
| 4653 | + return false; |
|
| 4654 | + } |
|
| 4655 | + |
|
| 4656 | + $this->parsingCss->load(); |
|
| 4657 | + $this->parsingCss->fontSet(); |
|
| 4658 | + |
|
| 4659 | + return true; |
|
| 4660 | + } |
|
| 4661 | + |
|
| 4662 | + /** |
|
| 4663 | + * tag : THEAD |
|
| 4664 | + * mode : OPEN |
|
| 4665 | + * |
|
| 4666 | + * @param array $param |
|
| 4667 | + * @return boolean |
|
| 4668 | + */ |
|
| 4669 | + protected function _tag_open_THEAD($param) |
|
| 4670 | + { |
|
| 4671 | + if ($this->_isForOneLine) { |
|
| 4672 | + return false; |
|
| 4673 | + } |
|
| 4674 | + |
|
| 4675 | + $this->parsingCss->save(); |
|
| 4676 | + $this->parsingCss->analyse('thead', $param); |
|
| 4677 | + $this->parsingCss->setPosition(); |
|
| 4678 | + $this->parsingCss->fontSet(); |
|
| 4679 | + |
|
| 4680 | + // if we are in a sub part, save the number of the first TR in the thead |
|
| 4681 | + if ($this->_subPart) { |
|
| 4682 | + HTML2PDF::$_tables[$param['num']]['thead']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 4683 | + HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); |
|
| 4684 | + for ($pos = $this->_tempPos; $pos < count($this->parsingHtml->code); $pos++) { |
|
| 4685 | + $action = $this->parsingHtml->code[$pos]; |
|
| 4686 | + if (strtolower($action['name']) == 'thead') $action['name'] = 'thead_sub'; |
|
| 4687 | + HTML2PDF::$_tables[$param['num']]['thead']['code'][] = $action; |
|
| 4688 | + if (strtolower($action['name']) == 'thead_sub' && $action['close']) break; |
|
| 4689 | + } |
|
| 4690 | + } else { |
|
| 4691 | + $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 4692 | + $this->_parsePos += count($level); |
|
| 4693 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] += count(HTML2PDF::$_tables[$param['num']]['thead']['tr']); |
|
| 4694 | + } |
|
| 4695 | + |
|
| 4696 | + return true; |
|
| 4697 | + } |
|
| 4698 | + |
|
| 4699 | + /** |
|
| 4700 | + * tag : THEAD |
|
| 4701 | + * mode : CLOSE |
|
| 4702 | + * |
|
| 4703 | + * @param array $param |
|
| 4704 | + * @return boolean |
|
| 4705 | + */ |
|
| 4706 | + protected function _tag_close_THEAD($param) |
|
| 4707 | + { |
|
| 4708 | + if ($this->_isForOneLine) { |
|
| 4709 | + return false; |
|
| 4710 | + } |
|
| 4711 | + |
|
| 4712 | + $this->parsingCss->load(); |
|
| 4713 | + $this->parsingCss->fontSet(); |
|
| 4714 | + |
|
| 4715 | + // if we are in a sub HTM, construct the list of the TR in the thead |
|
| 4716 | + if ($this->_subPart) { |
|
| 4717 | + $min = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0]; |
|
| 4718 | + $max = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1; |
|
| 4719 | + HTML2PDF::$_tables[$param['num']]['thead']['tr'] = range($min, $max); |
|
| 4720 | + } |
|
| 4721 | + |
|
| 4722 | + return true; |
|
| 4723 | + } |
|
| 4724 | + |
|
| 4725 | + /** |
|
| 4726 | + * tag : TFOOT |
|
| 4727 | + * mode : OPEN |
|
| 4728 | + * |
|
| 4729 | + * @param array $param |
|
| 4730 | + * @return boolean |
|
| 4731 | + */ |
|
| 4732 | + protected function _tag_open_TFOOT($param) |
|
| 4733 | + { |
|
| 4734 | + if ($this->_isForOneLine) { |
|
| 4735 | + return false; |
|
| 4736 | + } |
|
| 4737 | + |
|
| 4738 | + $this->parsingCss->save(); |
|
| 4739 | + $this->parsingCss->analyse('tfoot', $param); |
|
| 4740 | + $this->parsingCss->setPosition(); |
|
| 4741 | + $this->parsingCss->fontSet(); |
|
| 4742 | + |
|
| 4743 | + // if we are in a sub part, save the number of the first TR in the tfoot |
|
| 4744 | + if ($this->_subPart) { |
|
| 4745 | + HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 4746 | + HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); |
|
| 4747 | + for ($pos = $this->_tempPos; $pos < count($this->parsingHtml->code); $pos++) { |
|
| 4748 | + $action = $this->parsingHtml->code[$pos]; |
|
| 4749 | + if (strtolower($action['name']) == 'tfoot') $action['name'] = 'tfoot_sub'; |
|
| 4750 | + HTML2PDF::$_tables[$param['num']]['tfoot']['code'][] = $action; |
|
| 4751 | + if (strtolower($action['name']) == 'tfoot_sub' && $action['close']) break; |
|
| 4752 | + } |
|
| 4753 | + } else { |
|
| 4754 | + $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 4755 | + $this->_parsePos += count($level); |
|
| 4756 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] += count(HTML2PDF::$_tables[$param['num']]['tfoot']['tr']); |
|
| 4757 | + } |
|
| 4758 | + |
|
| 4759 | + return true; |
|
| 4760 | + } |
|
| 4761 | + |
|
| 4762 | + /** |
|
| 4763 | + * tag : TFOOT |
|
| 4764 | + * mode : CLOSE |
|
| 4765 | + * |
|
| 4766 | + * @param array $param |
|
| 4767 | + * @return boolean |
|
| 4768 | + */ |
|
| 4769 | + protected function _tag_close_TFOOT($param) |
|
| 4770 | + { |
|
| 4771 | + if ($this->_isForOneLine) { |
|
| 4772 | + return false; |
|
| 4773 | + } |
|
| 4774 | + |
|
| 4775 | + $this->parsingCss->load(); |
|
| 4776 | + $this->parsingCss->fontSet(); |
|
| 4777 | + |
|
| 4778 | + // if we are in a sub HTM, construct the list of the TR in the tfoot |
|
| 4779 | + if ($this->_subPart) { |
|
| 4780 | + $min = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0]; |
|
| 4781 | + $max = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1; |
|
| 4782 | + HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = range($min, $max); |
|
| 4783 | + } |
|
| 4784 | + |
|
| 4785 | + return true; |
|
| 4786 | + } |
|
| 4787 | + |
|
| 4788 | + /** |
|
| 4789 | + * It is not a real TAG, does not use it ! |
|
| 4790 | + * |
|
| 4791 | + * @param array $param |
|
| 4792 | + * @return boolean |
|
| 4793 | + */ |
|
| 4794 | + protected function _tag_open_THEAD_SUB($param) |
|
| 4795 | + { |
|
| 4796 | + if ($this->_isForOneLine) { |
|
| 4797 | + return false; |
|
| 4798 | + } |
|
| 4799 | + |
|
| 4800 | + $this->parsingCss->save(); |
|
| 4801 | + $this->parsingCss->analyse('thead', $param); |
|
| 4802 | + $this->parsingCss->setPosition(); |
|
| 4803 | + $this->parsingCss->fontSet(); |
|
| 4804 | + |
|
| 4805 | + return true; |
|
| 4806 | + } |
|
| 4807 | + |
|
| 4808 | + /** |
|
| 4809 | + * It is not a real TAG, does not use it ! |
|
| 4810 | + * |
|
| 4811 | + * @param array $param |
|
| 4812 | + * @return boolean |
|
| 4813 | + */ |
|
| 4814 | + protected function _tag_close_THEAD_SUB($param) |
|
| 4815 | + { |
|
| 4816 | + if ($this->_isForOneLine) { |
|
| 4817 | + return false; |
|
| 4818 | + } |
|
| 4819 | + |
|
| 4820 | + $this->parsingCss->load(); |
|
| 4821 | + $this->parsingCss->fontSet(); |
|
| 4822 | + |
|
| 4823 | + return true; |
|
| 4824 | + } |
|
| 4825 | + |
|
| 4826 | + /** |
|
| 4827 | + * It is not a real TAG, does not use it ! |
|
| 4828 | + * |
|
| 4829 | + * @param array $param |
|
| 4830 | + * @return boolean |
|
| 4831 | + */ |
|
| 4832 | + protected function _tag_open_TFOOT_SUB($param) |
|
| 4833 | + { |
|
| 4834 | + if ($this->_isForOneLine) { |
|
| 4835 | + return false; |
|
| 4836 | + } |
|
| 4837 | + |
|
| 4838 | + $this->parsingCss->save(); |
|
| 4839 | + $this->parsingCss->analyse('tfoot', $param); |
|
| 4840 | + $this->parsingCss->setPosition(); |
|
| 4841 | + $this->parsingCss->fontSet(); |
|
| 4842 | + |
|
| 4843 | + return true; |
|
| 4844 | + } |
|
| 4845 | + |
|
| 4846 | + /** |
|
| 4847 | + * It is not a real TAG, does not use it ! |
|
| 4848 | + * |
|
| 4849 | + * @param array $param |
|
| 4850 | + * @return boolean |
|
| 4851 | + */ |
|
| 4852 | + protected function _tag_close_TFOOT_SUB($param) |
|
| 4853 | + { |
|
| 4854 | + if ($this->_isForOneLine) { |
|
| 4855 | + return false; |
|
| 4856 | + } |
|
| 4857 | + |
|
| 4858 | + $this->parsingCss->load(); |
|
| 4859 | + $this->parsingCss->fontSet(); |
|
| 4860 | + |
|
| 4861 | + return true; |
|
| 4862 | + } |
|
| 4863 | + |
|
| 4864 | + /** |
|
| 4865 | + * tag : FORM |
|
| 4866 | + * mode : OPEN |
|
| 4867 | + * |
|
| 4868 | + * @param array $param |
|
| 4869 | + * @return boolean |
|
| 4870 | + */ |
|
| 4871 | + protected function _tag_open_FORM($param) |
|
| 4872 | + { |
|
| 4873 | + $this->parsingCss->save(); |
|
| 4874 | + $this->parsingCss->analyse('form', $param); |
|
| 4875 | + $this->parsingCss->setPosition(); |
|
| 4876 | + $this->parsingCss->fontSet(); |
|
| 4877 | + |
|
| 4878 | + $this->pdf->setFormDefaultProp( |
|
| 4879 | + array( |
|
| 4880 | + 'lineWidth'=>1, |
|
| 4881 | + 'borderStyle'=>'solid', |
|
| 4882 | + 'fillColor'=>array(220, 220, 255), |
|
| 4883 | + 'strokeColor'=>array(128, 128, 200) |
|
| 4884 | + ) |
|
| 4885 | + ); |
|
| 4886 | + |
|
| 4887 | + $this->_isInForm = isset($param['action']) ? $param['action'] : ''; |
|
| 4888 | + |
|
| 4889 | + return true; |
|
| 4890 | + } |
|
| 4891 | + |
|
| 4892 | + /** |
|
| 4893 | + * tag : FORM |
|
| 4894 | + * mode : CLOSE |
|
| 4895 | + * |
|
| 4896 | + * @param array $param |
|
| 4897 | + * @return boolean |
|
| 4898 | + */ |
|
| 4899 | + protected function _tag_close_FORM($param) |
|
| 4900 | + { |
|
| 4901 | + $this->_isInForm = false; |
|
| 4902 | + $this->parsingCss->load(); |
|
| 4903 | + $this->parsingCss->fontSet(); |
|
| 4904 | + |
|
| 4905 | + return true; |
|
| 4906 | + } |
|
| 4907 | + |
|
| 4908 | + /** |
|
| 4909 | + * tag : TABLE |
|
| 4910 | + * mode : OPEN |
|
| 4911 | + * |
|
| 4912 | + * @param array $param |
|
| 4913 | + * @return boolean |
|
| 4914 | + */ |
|
| 4915 | + protected function _tag_open_TABLE($param, $other = 'table') |
|
| 4916 | + { |
|
| 4917 | + if ($this->_maxH) { |
|
| 4918 | + if ($this->_isForOneLine) { |
|
| 4919 | + return false; |
|
| 4920 | + } |
|
| 4921 | + $this->_tag_open_BR(array()); |
|
| 4922 | + } |
|
| 4923 | + |
|
| 4924 | + if ($this->_isForOneLine) { |
|
| 4925 | + $this->_maxX = $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 4926 | + return false; |
|
| 4927 | + } |
|
| 4928 | + |
|
| 4929 | + $this->_maxH = 0; |
|
| 4930 | + |
|
| 4931 | + $alignObject = isset($param['align']) ? strtolower($param['align']) : 'left'; |
|
| 4932 | + if (isset($param['align'])) unset($param['align']); |
|
| 4933 | + if ( ! in_array($alignObject, array('left', 'center', 'right'))) $alignObject = 'left'; |
|
| 4934 | + |
|
| 4935 | + $this->parsingCss->save(); |
|
| 4936 | + $this->parsingCss->analyse($other, $param); |
|
| 4937 | + $this->parsingCss->setPosition(); |
|
| 4938 | + $this->parsingCss->fontSet(); |
|
| 4939 | + |
|
| 4940 | + if ($this->parsingCss->value['margin-auto']) $alignObject = 'center'; |
|
| 4941 | + |
|
| 4942 | + // collapse table ? |
|
| 4943 | + $collapse = false; |
|
| 4944 | + if ($other == 'table') { |
|
| 4945 | + $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false; |
|
| 4946 | + } |
|
| 4947 | + |
|
| 4948 | + // if collapse => no borders for the table, only for TD |
|
| 4949 | + if ($collapse) { |
|
| 4950 | + $param['style']['border'] = 'none'; |
|
| 4951 | + $param['cellspacing'] = 0; |
|
| 4952 | + $none = $this->parsingCss->readBorder('none'); |
|
| 4953 | + $this->parsingCss->value['border']['t'] = $none; |
|
| 4954 | + $this->parsingCss->value['border']['r'] = $none; |
|
| 4955 | + $this->parsingCss->value['border']['b'] = $none; |
|
| 4956 | + $this->parsingCss->value['border']['l'] = $none; |
|
| 4957 | + } |
|
| 4958 | + |
|
| 4959 | + // if we are in a SUB html => prepare the properties of the table |
|
| 4960 | + if ($this->_subPart) { |
|
| 4961 | + if ($this->_debugActif) { |
|
| 4962 | + $this->_DEBUG_add('Table n'.$param['num'], true); |
|
| 4963 | + } |
|
| 4964 | + HTML2PDF::$_tables[$param['num']] = array(); |
|
| 4965 | + HTML2PDF::$_tables[$param['num']]['border'] = isset($param['border']) ? $this->parsingCss->readBorder($param['border']) : null; |
|
| 4966 | + HTML2PDF::$_tables[$param['num']]['cellpadding'] = $this->parsingCss->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px'); |
|
| 4967 | + HTML2PDF::$_tables[$param['num']]['cellspacing'] = $this->parsingCss->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); |
|
| 4968 | + HTML2PDF::$_tables[$param['num']]['cases'] = array(); // properties of each TR/TD |
|
| 4969 | + HTML2PDF::$_tables[$param['num']]['corr'] = array(); // link between TR/TD and colspan/rowspan |
|
| 4970 | + HTML2PDF::$_tables[$param['num']]['corr_x'] = 0; // position in 'cases' |
|
| 4971 | + HTML2PDF::$_tables[$param['num']]['corr_y'] = 0; // position in 'cases' |
|
| 4972 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; // current column |
|
| 4973 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] = 0; // current row |
|
| 4974 | + HTML2PDF::$_tables[$param['num']]['curr_x'] = $this->pdf->getX(); |
|
| 4975 | + HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY(); |
|
| 4976 | + HTML2PDF::$_tables[$param['num']]['width'] = 0; // global width |
|
| 4977 | + HTML2PDF::$_tables[$param['num']]['height'] = 0; // global height |
|
| 4978 | + HTML2PDF::$_tables[$param['num']]['align'] = $alignObject; |
|
| 4979 | + HTML2PDF::$_tables[$param['num']]['marge'] = array(); |
|
| 4980 | + HTML2PDF::$_tables[$param['num']]['marge']['t'] = $this->parsingCss->value['padding']['t'] + $this->parsingCss->value['border']['t']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4981 | + HTML2PDF::$_tables[$param['num']]['marge']['r'] = $this->parsingCss->value['padding']['r'] + $this->parsingCss->value['border']['r']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4982 | + HTML2PDF::$_tables[$param['num']]['marge']['b'] = $this->parsingCss->value['padding']['b'] + $this->parsingCss->value['border']['b']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4983 | + HTML2PDF::$_tables[$param['num']]['marge']['l'] = $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['border']['l']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4984 | + HTML2PDF::$_tables[$param['num']]['page'] = 0; // number of pages |
|
| 4985 | + HTML2PDF::$_tables[$param['num']]['new_page'] = true; // flag : new page for the current TR |
|
| 4986 | + HTML2PDF::$_tables[$param['num']]['style_value'] = null; // CSS style of the table |
|
| 4987 | + HTML2PDF::$_tables[$param['num']]['thead'] = array(); // properties on the thead |
|
| 4988 | + HTML2PDF::$_tables[$param['num']]['tfoot'] = array(); // properties on the tfoot |
|
| 4989 | + HTML2PDF::$_tables[$param['num']]['thead']['tr'] = array(); // list of the TRs in the thead |
|
| 4990 | + HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = array(); // list of the TRs in the tfoot |
|
| 4991 | + HTML2PDF::$_tables[$param['num']]['thead']['height'] = 0; // thead height |
|
| 4992 | + HTML2PDF::$_tables[$param['num']]['tfoot']['height'] = 0; // tfoot height |
|
| 4993 | + HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); // HTML content of the thead |
|
| 4994 | + HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); // HTML content of the tfoot |
|
| 4995 | + HTML2PDF::$_tables[$param['num']]['cols'] = array(); // properties of the COLs |
|
| 4996 | + |
|
| 4997 | + $this->_saveMargin($this->pdf->getlMargin(), $this->pdf->gettMargin(), $this->pdf->getrMargin()); |
|
| 4998 | + |
|
| 4999 | + $this->parsingCss->value['width'] -= HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r']; |
|
| 5000 | + } else { |
|
| 5001 | + // we start from the first page and the first page of the table |
|
| 5002 | + HTML2PDF::$_tables[$param['num']]['page'] = 0; |
|
| 5003 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5004 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] = 0; |
|
| 5005 | + HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['curr_x']; |
|
| 5006 | + HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5007 | + |
|
| 5008 | + // draw the borders/background of the first page/part of the table |
|
| 5009 | + $this->_drawRectangle( |
|
| 5010 | + HTML2PDF::$_tables[$param['num']]['curr_x'], |
|
| 5011 | + HTML2PDF::$_tables[$param['num']]['curr_y'], |
|
| 5012 | + HTML2PDF::$_tables[$param['num']]['width'], |
|
| 5013 | + isset(HTML2PDF::$_tables[$param['num']]['height'][0]) ? HTML2PDF::$_tables[$param['num']]['height'][0] : null, |
|
| 5014 | + $this->parsingCss->value['border'], |
|
| 5015 | + $this->parsingCss->value['padding'], |
|
| 5016 | + 0, |
|
| 5017 | + $this->parsingCss->value['background'] |
|
| 5018 | + ); |
|
| 5019 | + |
|
| 5020 | + HTML2PDF::$_tables[$param['num']]['style_value'] = $this->parsingCss->value; |
|
| 5021 | + } |
|
| 5022 | + |
|
| 5023 | + return true; |
|
| 5024 | + } |
|
| 5025 | + |
|
| 5026 | + /** |
|
| 5027 | + * tag : TABLE |
|
| 5028 | + * mode : CLOSE |
|
| 5029 | + * |
|
| 5030 | + * @param array $param |
|
| 5031 | + * @return boolean |
|
| 5032 | + */ |
|
| 5033 | + protected function _tag_close_TABLE($param) |
|
| 5034 | + { |
|
| 5035 | + if ($this->_isForOneLine) { |
|
| 5036 | + return false; |
|
| 5037 | + } |
|
| 5038 | + |
|
| 5039 | + $this->_maxH = 0; |
|
| 5040 | + |
|
| 5041 | + // if we are in a sub HTML |
|
| 5042 | + if ($this->_subPart) { |
|
| 5043 | + // calculate the size of each case |
|
| 5044 | + $this->_calculateTableCellSize(HTML2PDF::$_tables[$param['num']]['cases'], HTML2PDF::$_tables[$param['num']]['corr']); |
|
| 5045 | + |
|
| 5046 | + // calculate the height of the thead and the tfoot |
|
| 5047 | + $lst = array('thead', 'tfoot'); |
|
| 5048 | + foreach ($lst as $mode) { |
|
| 5049 | + HTML2PDF::$_tables[$param['num']][$mode]['height'] = 0; |
|
| 5050 | + foreach (HTML2PDF::$_tables[$param['num']][$mode]['tr'] as $tr) { |
|
| 5051 | + // hauteur de la ligne tr |
|
| 5052 | + $h = 0; |
|
| 5053 | + for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++) |
|
| 5054 | + if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan'] == 1) |
|
| 5055 | + $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['h']); |
|
| 5056 | + HTML2PDF::$_tables[$param['num']][$mode]['height'] += $h; |
|
| 5057 | + } |
|
| 5058 | + } |
|
| 5059 | + |
|
| 5060 | + // calculate the width of the table |
|
| 5061 | + HTML2PDF::$_tables[$param['num']]['width'] = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r']; |
|
| 5062 | + if (isset(HTML2PDF::$_tables[$param['num']]['cases'][0])) { |
|
| 5063 | + foreach (HTML2PDF::$_tables[$param['num']]['cases'][0] as $case) { |
|
| 5064 | + HTML2PDF::$_tables[$param['num']]['width'] += $case['w']; |
|
| 5065 | + } |
|
| 5066 | + } |
|
| 5067 | + |
|
| 5068 | + // X position of the table |
|
| 5069 | + $old = $this->parsingCss->getOldValues(); |
|
| 5070 | + $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 5071 | + $x = HTML2PDF::$_tables[$param['num']]['curr_x']; |
|
| 5072 | + $w = HTML2PDF::$_tables[$param['num']]['width']; |
|
| 5073 | + if ($parentWidth > $w) { |
|
| 5074 | + if (HTML2PDF::$_tables[$param['num']]['align'] == 'center') |
|
| 5075 | + $x = $x + ($parentWidth - $w) * 0.5; |
|
| 5076 | + else if (HTML2PDF::$_tables[$param['num']]['align'] == 'right') |
|
| 5077 | + $x = $x + $parentWidth - $w; |
|
| 5078 | + |
|
| 5079 | + HTML2PDF::$_tables[$param['num']]['curr_x'] = $x; |
|
| 5080 | + } |
|
| 5081 | + |
|
| 5082 | + // calculate the height of the table |
|
| 5083 | + HTML2PDF::$_tables[$param['num']]['height'] = array(); |
|
| 5084 | + |
|
| 5085 | + // minimum of the height because of margins, and of the thead and tfoot height |
|
| 5086 | + $h0 = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['marge']['b']; |
|
| 5087 | + $h0 += HTML2PDF::$_tables[$param['num']]['thead']['height'] + HTML2PDF::$_tables[$param['num']]['tfoot']['height']; |
|
| 5088 | + |
|
| 5089 | + // max height of the page |
|
| 5090 | + $max = $this->pdf->getH() - $this->pdf->getbMargin(); |
|
| 5091 | + |
|
| 5092 | + // current position on the page |
|
| 5093 | + $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5094 | + $height = $h0; |
|
| 5095 | + |
|
| 5096 | + // we get the height of each line |
|
| 5097 | + for ($k = 0; $k < count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) { |
|
| 5098 | + |
|
| 5099 | + // if it is a TR of the thead or of the tfoot => skip |
|
| 5100 | + if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) { |
|
| 5101 | + continue; |
|
| 5102 | + } |
|
| 5103 | + if (in_array($k, HTML2PDF::$_tables[$param['num']]['tfoot']['tr'])) { |
|
| 5104 | + continue; |
|
| 5105 | + } |
|
| 5106 | + |
|
| 5107 | + // height of the line |
|
| 5108 | + $th = 0; |
|
| 5109 | + $h = 0; |
|
| 5110 | + for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) { |
|
| 5111 | + $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
|
| 5112 | + |
|
| 5113 | + if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan'] == 1) |
|
| 5114 | + $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
|
| 5115 | + } |
|
| 5116 | + |
|
| 5117 | + // if the row does not fit on the page => new page |
|
| 5118 | + if ($y + $h + $height > $max) { |
|
| 5119 | + if ($height == $h0) $height = null; |
|
| 5120 | + HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5121 | + $height = $h0; |
|
| 5122 | + $y = $this->_margeTop; |
|
| 5123 | + } |
|
| 5124 | + $height += $th; |
|
| 5125 | + } |
|
| 5126 | + |
|
| 5127 | + // if ther is a height at the end, add it |
|
| 5128 | + if ($height != $h0 || $k == 0) HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5129 | + } else { |
|
| 5130 | + // if we have tfoor, draw it |
|
| 5131 | + if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) { |
|
| 5132 | + $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 5133 | + $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5134 | + $oldParsePos = $this->_parsePos; |
|
| 5135 | + $oldParseCode = $this->parsingHtml->code; |
|
| 5136 | + |
|
| 5137 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0]; |
|
| 5138 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5139 | + $this->_parsePos = 0; |
|
| 5140 | + $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['tfoot']['code']; |
|
| 5141 | + $this->_isInTfoot = true; |
|
| 5142 | + $this->_makeHTMLcode(); |
|
| 5143 | + $this->_isInTfoot = false; |
|
| 5144 | + |
|
| 5145 | + $this->_parsePos = $oldParsePos; |
|
| 5146 | + $this->parsingHtml->code = $oldParseCode; |
|
| 5147 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
|
| 5148 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
|
| 5149 | + } |
|
| 5150 | + |
|
| 5151 | + // get the positions of the end of the table |
|
| 5152 | + $x = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['width']; |
|
| 5153 | + if (count(HTML2PDF::$_tables[$param['num']]['height']) > 1) |
|
| 5154 | + $y = $this->_margeTop + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1]; |
|
| 5155 | + else if (count(HTML2PDF::$_tables[$param['num']]['height']) == 1) |
|
| 5156 | + $y = HTML2PDF::$_tables[$param['num']]['curr_y'] + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1]; |
|
| 5157 | + else |
|
| 5158 | + $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5159 | + |
|
| 5160 | + $this->_maxX = max($this->_maxX, $x); |
|
| 5161 | + $this->_maxY = max($this->_maxY, $y); |
|
| 5162 | + |
|
| 5163 | + $this->pdf->setXY($this->pdf->getlMargin(), $y); |
|
| 5164 | + |
|
| 5165 | + $this->_loadMargin(); |
|
| 5166 | + |
|
| 5167 | + if ($this->_debugActif) { |
|
| 5168 | + $this->_DEBUG_add('Table '.$param['num'], false); |
|
| 5169 | + } |
|
| 5170 | + } |
|
| 5171 | + |
|
| 5172 | + $this->parsingCss->load(); |
|
| 5173 | + $this->parsingCss->fontSet(); |
|
| 5174 | + |
|
| 5175 | + |
|
| 5176 | + return true; |
|
| 5177 | + } |
|
| 5178 | + |
|
| 5179 | + /** |
|
| 5180 | + * tag : COL |
|
| 5181 | + * mode : OPEN |
|
| 5182 | + * |
|
| 5183 | + * @param array $param |
|
| 5184 | + * @return boolean|null |
|
| 5185 | + */ |
|
| 5186 | + protected function _tag_open_COL($param) |
|
| 5187 | + { |
|
| 5188 | + $span = isset($param['span']) ? $param['span'] : 1; |
|
| 5189 | + for ($k = 0; $k < $span; $k++) |
|
| 5190 | + HTML2PDF::$_tables[$param['num']]['cols'][] = $param; |
|
| 5191 | + } |
|
| 5192 | + |
|
| 5193 | + /** |
|
| 5194 | + * tag : COL |
|
| 5195 | + * mode : CLOSE |
|
| 5196 | + * |
|
| 5197 | + * @param array $param |
|
| 5198 | + * @return boolean |
|
| 5199 | + */ |
|
| 5200 | + protected function _tag_close_COL($param) |
|
| 5201 | + { |
|
| 5202 | + // there is nothing to do here |
|
| 5203 | + |
|
| 5204 | + return true; |
|
| 5205 | + } |
|
| 5206 | + |
|
| 5207 | + /** |
|
| 5208 | + * tag : TR |
|
| 5209 | + * mode : OPEN |
|
| 5210 | + * |
|
| 5211 | + * @param array $param |
|
| 5212 | + * @return boolean |
|
| 5213 | + */ |
|
| 5214 | + protected function _tag_open_TR($param, $other = 'tr') |
|
| 5215 | + { |
|
| 5216 | + if ($this->_isForOneLine) { |
|
| 5217 | + return false; |
|
| 5218 | + } |
|
| 5219 | + |
|
| 5220 | + $this->_maxH = 0; |
|
| 5221 | + |
|
| 5222 | + $this->parsingCss->save(); |
|
| 5223 | + $this->parsingCss->analyse($other, $param); |
|
| 5224 | + $this->parsingCss->setPosition(); |
|
| 5225 | + $this->parsingCss->fontSet(); |
|
| 5226 | + |
|
| 5227 | + // position in the table |
|
| 5228 | + HTML2PDF::$_tables[$param['num']]['tr_curr']++; |
|
| 5229 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5230 | + |
|
| 5231 | + // if we are not in a sub html |
|
| 5232 | + if ( ! $this->_subPart) { |
|
| 5233 | + |
|
| 5234 | + // Y after the row |
|
| 5235 | + $ty = null; |
|
| 5236 | + for ($ii = 0; $ii < count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1]); $ii++) { |
|
| 5237 | + $ty = max($ty, HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['h']); |
|
| 5238 | + } |
|
| 5239 | + |
|
| 5240 | + // height of the tfoot |
|
| 5241 | + $hfoot = HTML2PDF::$_tables[$param['num']]['tfoot']['height']; |
|
| 5242 | + |
|
| 5243 | + // if the line does not fit on the page => new page |
|
| 5244 | + if ( ! $this->_isInTfoot && HTML2PDF::$_tables[$param['num']]['td_y'] + HTML2PDF::$_tables[$param['num']]['marge']['b'] + $ty + $hfoot > $this->pdf->getH() - $this->pdf->getbMargin()) { |
|
| 5245 | + |
|
| 5246 | + // fi ther is a tfoot => draw it |
|
| 5247 | + if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) { |
|
| 5248 | + $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 5249 | + $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5250 | + $oldParsePos = $this->_parsePos; |
|
| 5251 | + $oldParseCode = $this->parsingHtml->code; |
|
| 5252 | + |
|
| 5253 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0]; |
|
| 5254 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5255 | + $this->_parsePos = 0; |
|
| 5256 | + $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['tfoot']['code']; |
|
| 5257 | + $this->_isInTfoot = true; |
|
| 5258 | + $this->_makeHTMLcode(); |
|
| 5259 | + $this->_isInTfoot = false; |
|
| 5260 | + |
|
| 5261 | + $this->_parsePos = $oldParsePos; |
|
| 5262 | + $this->parsingHtml->code = $oldParseCode; |
|
| 5263 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
|
| 5264 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
|
| 5265 | + } |
|
| 5266 | + |
|
| 5267 | + // new page |
|
| 5268 | + HTML2PDF::$_tables[$param['num']]['new_page'] = true; |
|
| 5269 | + $this->_setNewPage(); |
|
| 5270 | + |
|
| 5271 | + // new position |
|
| 5272 | + HTML2PDF::$_tables[$param['num']]['page']++; |
|
| 5273 | + HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY(); |
|
| 5274 | + HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['curr_y'] + HTML2PDF::$_tables[$param['num']]['marge']['t']; |
|
| 5275 | + |
|
| 5276 | + // if we have the height of the tbale on the page => draw borders and background |
|
| 5277 | + if (isset(HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']])) { |
|
| 5278 | + $old = $this->parsingCss->value; |
|
| 5279 | + $this->parsingCss->value = HTML2PDF::$_tables[$param['num']]['style_value']; |
|
| 5280 | + |
|
| 5281 | + $this->_drawRectangle( |
|
| 5282 | + HTML2PDF::$_tables[$param['num']]['curr_x'], |
|
| 5283 | + HTML2PDF::$_tables[$param['num']]['curr_y'], |
|
| 5284 | + HTML2PDF::$_tables[$param['num']]['width'], |
|
| 5285 | + HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']], |
|
| 5286 | + $this->parsingCss->value['border'], |
|
| 5287 | + $this->parsingCss->value['padding'], |
|
| 5288 | + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5, |
|
| 5289 | + $this->parsingCss->value['background'] |
|
| 5290 | + ); |
|
| 5291 | + |
|
| 5292 | + $this->parsingCss->value = $old; |
|
| 5293 | + } |
|
| 5294 | + } |
|
| 5295 | + |
|
| 5296 | + // if we are in a new page, and if we have a thead => draw it |
|
| 5297 | + if (HTML2PDF::$_tables[$param['num']]['new_page'] && count(HTML2PDF::$_tables[$param['num']]['thead']['code'])) { |
|
| 5298 | + HTML2PDF::$_tables[$param['num']]['new_page'] = false; |
|
| 5299 | + $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 5300 | + $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5301 | + $oldParsePos = $this->_parsePos; |
|
| 5302 | + $oldParseCode = $this->parsingHtml->code; |
|
| 5303 | + |
|
| 5304 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0]; |
|
| 5305 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5306 | + $this->_parsePos = 0; |
|
| 5307 | + $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['thead']['code']; |
|
| 5308 | + $this->_isInThead = true; |
|
| 5309 | + $this->_makeHTMLcode(); |
|
| 5310 | + $this->_isInThead = false; |
|
| 5311 | + |
|
| 5312 | + $this->_parsePos = $oldParsePos; |
|
| 5313 | + $this->parsingHtml->code = $oldParseCode; |
|
| 5314 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
|
| 5315 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
|
| 5316 | + HTML2PDF::$_tables[$param['num']]['new_page'] = true; |
|
| 5317 | + } |
|
| 5318 | + // else (in a sub HTML) |
|
| 5319 | + } else { |
|
| 5320 | + // prepare it |
|
| 5321 | + HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1] = array(); |
|
| 5322 | + if ( ! isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']])) |
|
| 5323 | + HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array(); |
|
| 5324 | + |
|
| 5325 | + HTML2PDF::$_tables[$param['num']]['corr_x'] = 0; |
|
| 5326 | + while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) |
|
| 5327 | + HTML2PDF::$_tables[$param['num']]['corr_x']++; |
|
| 5328 | + } |
|
| 5329 | + |
|
| 5330 | + return true; |
|
| 5331 | + } |
|
| 5332 | + |
|
| 5333 | + /** |
|
| 5334 | + * tag : TR |
|
| 5335 | + * mode : CLOSE |
|
| 5336 | + * |
|
| 5337 | + * @param array $param |
|
| 5338 | + * @return boolean |
|
| 5339 | + */ |
|
| 5340 | + protected function _tag_close_TR($param) |
|
| 5341 | + { |
|
| 5342 | + if ($this->_isForOneLine) { |
|
| 5343 | + return false; |
|
| 5344 | + } |
|
| 5345 | + |
|
| 5346 | + $this->_maxH = 0; |
|
| 5347 | + |
|
| 5348 | + $this->parsingCss->load(); |
|
| 5349 | + $this->parsingCss->fontSet(); |
|
| 5350 | + |
|
| 5351 | + // if we are not in a sub HTML |
|
| 5352 | + if ( ! $this->_subPart) { |
|
| 5353 | + |
|
| 5354 | + // Y of the current line |
|
| 5355 | + $ty = null; |
|
| 5356 | + for ($ii = 0; $ii < count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1]); $ii++) { |
|
| 5357 | + if (HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['rowspan'] == 1) { |
|
| 5358 | + $ty = HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['h']; |
|
| 5359 | + } |
|
| 5360 | + } |
|
| 5361 | + |
|
| 5362 | + // new position |
|
| 5363 | + HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['marge']['l']; |
|
| 5364 | + HTML2PDF::$_tables[$param['num']]['td_y'] += $ty; |
|
| 5365 | + HTML2PDF::$_tables[$param['num']]['new_page'] = false; |
|
| 5366 | + } else { |
|
| 5367 | + HTML2PDF::$_tables[$param['num']]['corr_y']++; |
|
| 5368 | + } |
|
| 5369 | + |
|
| 5370 | + return true; |
|
| 5371 | + } |
|
| 5372 | + |
|
| 5373 | + /** |
|
| 5374 | + * tag : TD |
|
| 5375 | + * mode : OPEN |
|
| 5376 | + * |
|
| 5377 | + * @param array $param |
|
| 5378 | + * @return boolean |
|
| 5379 | + */ |
|
| 5380 | + protected function _tag_open_TD($param, $other = 'td') |
|
| 5381 | + { |
|
| 5382 | + if ($this->_isForOneLine) { |
|
| 5383 | + return false; |
|
| 5384 | + } |
|
| 5385 | + |
|
| 5386 | + $this->_maxH = 0; |
|
| 5387 | + |
|
| 5388 | + $param['cellpadding'] = HTML2PDF::$_tables[$param['num']]['cellpadding'].'mm'; |
|
| 5389 | + $param['cellspacing'] = HTML2PDF::$_tables[$param['num']]['cellspacing'].'mm'; |
|
| 5390 | + |
|
| 5391 | + // specific style for LI |
|
| 5392 | + if ($other == 'li') { |
|
| 5393 | + $specialLi = true; |
|
| 5394 | + } else { |
|
| 5395 | + $specialLi = false; |
|
| 5396 | + if ($other == 'li_sub') { |
|
| 5397 | + $param['style']['border'] = 'none'; |
|
| 5398 | + $param['style']['background-color'] = 'transparent'; |
|
| 5399 | + $param['style']['background-image'] = 'none'; |
|
| 5400 | + $param['style']['background-position'] = ''; |
|
| 5401 | + $param['style']['background-repeat'] = ''; |
|
| 5402 | + $other = 'li'; |
|
| 5403 | + } |
|
| 5404 | + } |
|
| 5405 | + |
|
| 5406 | + // get the properties of the TD |
|
| 5407 | + $x = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5408 | + $y = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1; |
|
| 5409 | + $colspan = isset($param['colspan']) ? $param['colspan'] : 1; |
|
| 5410 | + $rowspan = isset($param['rowspan']) ? $param['rowspan'] : 1; |
|
| 5411 | + |
|
| 5412 | + // flag for collapse table |
|
| 5413 | + $collapse = false; |
|
| 5414 | + |
|
| 5415 | + // specific traitment for TD and TH |
|
| 5416 | + if (in_array($other, array('td', 'th'))) { |
|
| 5417 | + // id of the column |
|
| 5418 | + $numCol = isset(HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr']) ? HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr'] : HTML2PDF::$_tables[$param['num']]['corr_x']; |
|
| 5419 | + |
|
| 5420 | + // we get the properties of the COL tag, if exist |
|
| 5421 | + if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol])) { |
|
| 5422 | + |
|
| 5423 | + $colParam = HTML2PDF::$_tables[$param['num']]['cols'][$numCol]; |
|
| 5424 | + |
|
| 5425 | + // for colspans => we get all the neede widths |
|
| 5426 | + $colParam['style']['width'] = array(); |
|
| 5427 | + for ($k = 0; $k < $colspan; $k++) { |
|
| 5428 | + if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol + $k]['style']['width'])) { |
|
| 5429 | + $colParam['style']['width'][] = HTML2PDF::$_tables[$param['num']]['cols'][$numCol + $k]['style']['width']; |
|
| 5430 | + } |
|
| 5431 | + } |
|
| 5432 | + |
|
| 5433 | + // calculate the total width of the column |
|
| 5434 | + $total = ''; |
|
| 5435 | + $last = $this->parsingCss->getLastWidth(); |
|
| 5436 | + if (count($colParam['style']['width'])) { |
|
| 5437 | + $total = $colParam['style']['width'][0]; unset($colParam['style']['width'][0]); |
|
| 5438 | + foreach ($colParam['style']['width'] as $width) { |
|
| 5439 | + if (substr($total, -1) == '%' && substr($width, -1) == '%') |
|
| 5440 | + $total = (str_replace('%', '', $total) + str_replace('%', '', $width)).'%'; |
|
| 5441 | + else |
|
| 5442 | + $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm'; |
|
| 5443 | + } |
|
| 5444 | + } |
|
| 5445 | + |
|
| 5446 | + // get the final width |
|
| 5447 | + if ($total) { |
|
| 5448 | + $colParam['style']['width'] = $total; |
|
| 5449 | + } else { |
|
| 5450 | + unset($colParam['style']['width']); |
|
| 5451 | + } |
|
| 5452 | + |
|
| 5453 | + |
|
| 5454 | + // merge the styles of the COL and the TD |
|
| 5455 | + $param['style'] = array_merge($colParam['style'], $param['style']); |
|
| 5456 | + |
|
| 5457 | + // merge the class of the COL and the TD |
|
| 5458 | + if (isset($colParam['class'])) { |
|
| 5459 | + $param['class'] = $colParam['class'].(isset($param['class']) ? ' '.$param['class'] : ''); |
|
| 5460 | + } |
|
| 5461 | + } |
|
| 5462 | + |
|
| 5463 | + $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false; |
|
| 5464 | + } |
|
| 5465 | + |
|
| 5466 | + $this->parsingCss->save(); |
|
| 5467 | + |
|
| 5468 | + // legacy for TD and TH |
|
| 5469 | + $legacy = null; |
|
| 5470 | + if (in_array($other, array('td', 'th'))) { |
|
| 5471 | + $legacy = array(); |
|
| 5472 | + |
|
| 5473 | + $old = $this->parsingCss->getLastValue('background'); |
|
| 5474 | + if ($old && ($old['color'] || $old['image'])) { |
|
| 5475 | + $legacy['background'] = $old; |
|
| 5476 | + } |
|
| 5477 | + |
|
| 5478 | + if (HTML2PDF::$_tables[$param['num']]['border']) { |
|
| 5479 | + $legacy['border'] = array(); |
|
| 5480 | + $legacy['border']['l'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5481 | + $legacy['border']['t'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5482 | + $legacy['border']['r'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5483 | + $legacy['border']['b'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5484 | + } |
|
| 5485 | + } |
|
| 5486 | + $return = $this->parsingCss->analyse($other, $param, $legacy); |
|
| 5487 | + |
|
| 5488 | + if ($specialLi) { |
|
| 5489 | + $this->parsingCss->value['width'] -= $this->parsingCss->ConvertToMM($this->_listeGetWidth()); |
|
| 5490 | + $this->parsingCss->value['width'] -= $this->parsingCss->ConvertToMM($this->_listeGetPadding()); |
|
| 5491 | + } |
|
| 5492 | + $this->parsingCss->setPosition(); |
|
| 5493 | + $this->parsingCss->fontSet(); |
|
| 5494 | + |
|
| 5495 | + // if tale collapse => modify the borders |
|
| 5496 | + if ($collapse) { |
|
| 5497 | + if ( ! $this->_subPart) { |
|
| 5498 | + if ( |
|
| 5499 | + (HTML2PDF::$_tables[$param['num']]['tr_curr'] > 1 && ! HTML2PDF::$_tables[$param['num']]['new_page']) || |
|
| 5500 | + ( ! $this->_isInThead && count(HTML2PDF::$_tables[$param['num']]['thead']['code'])) |
|
| 5501 | + ) { |
|
| 5502 | + $this->parsingCss->value['border']['t'] = $this->parsingCss->readBorder('none'); |
|
| 5503 | + } |
|
| 5504 | + } |
|
| 5505 | + |
|
| 5506 | + if (HTML2PDF::$_tables[$param['num']]['td_curr'] > 0) { |
|
| 5507 | + if ( ! $return) $this->parsingCss->value['width'] += $this->parsingCss->value['border']['l']['width']; |
|
| 5508 | + $this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none'); |
|
| 5509 | + } |
|
| 5510 | + } |
|
| 5511 | + |
|
| 5512 | + // margins of the table |
|
| 5513 | + $marge = array(); |
|
| 5514 | + $marge['t'] = $this->parsingCss->value['padding']['t'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['t']['width']; |
|
| 5515 | + $marge['r'] = $this->parsingCss->value['padding']['r'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['r']['width']; |
|
| 5516 | + $marge['b'] = $this->parsingCss->value['padding']['b'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['b']['width']; |
|
| 5517 | + $marge['l'] = $this->parsingCss->value['padding']['l'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['l']['width']; |
|
| 5518 | + |
|
| 5519 | + // if we are in a sub HTML |
|
| 5520 | + if ($this->_subPart) { |
|
| 5521 | + // new position in the table |
|
| 5522 | + HTML2PDF::$_tables[$param['num']]['td_curr']++; |
|
| 5523 | + HTML2PDF::$_tables[$param['num']]['cases'][$y][$x] = array(); |
|
| 5524 | + HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] = 0; |
|
| 5525 | + HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'] = 0; |
|
| 5526 | + HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw'] = 0; |
|
| 5527 | + HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['colspan'] = $colspan; |
|
| 5528 | + HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['rowspan'] = $rowspan; |
|
| 5529 | + HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr'] = HTML2PDF::$_tables[$param['num']]['corr_x']; |
|
| 5530 | + HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Yr'] = HTML2PDF::$_tables[$param['num']]['corr_y']; |
|
| 5531 | + |
|
| 5532 | + // prepare the mapping for rowspan and colspan |
|
| 5533 | + for ($j = 0; $j < $rowspan; $j++) { |
|
| 5534 | + for ($i = 0; $i < $colspan; $i++) { |
|
| 5535 | + HTML2PDF::$_tables[$param['num']]['corr'] |
|
| 5536 | + [HTML2PDF::$_tables[$param['num']]['corr_y'] + $j] |
|
| 5537 | + [HTML2PDF::$_tables[$param['num']]['corr_x'] + $i] = ($i + $j > 0) ? '' : array($x, $y, $colspan, $rowspan); |
|
| 5538 | + } |
|
| 5539 | + } |
|
| 5540 | + HTML2PDF::$_tables[$param['num']]['corr_x'] += $colspan; |
|
| 5541 | + while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) { |
|
| 5542 | + HTML2PDF::$_tables[$param['num']]['corr_x']++; |
|
| 5543 | + } |
|
| 5544 | + |
|
| 5545 | + // extract the content of the TD, and calculate his size |
|
| 5546 | + $level = $this->parsingHtml->getLevel($this->_tempPos); |
|
| 5547 | + $this->_createSubHTML($this->_subHtml); |
|
| 5548 | + $this->_subHtml->parsingHtml->code = $level; |
|
| 5549 | + $this->_subHtml->_makeHTMLcode(); |
|
| 5550 | + $this->_tempPos += count($level); |
|
| 5551 | + } else { |
|
| 5552 | + // new position in the table |
|
| 5553 | + HTML2PDF::$_tables[$param['num']]['td_curr']++; |
|
| 5554 | + HTML2PDF::$_tables[$param['num']]['td_x'] += HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw']; |
|
| 5555 | + |
|
| 5556 | + // borders and background of the TD |
|
| 5557 | + $this->_drawRectangle( |
|
| 5558 | + HTML2PDF::$_tables[$param['num']]['td_x'], |
|
| 5559 | + HTML2PDF::$_tables[$param['num']]['td_y'], |
|
| 5560 | + HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'], |
|
| 5561 | + HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'], |
|
| 5562 | + $this->parsingCss->value['border'], |
|
| 5563 | + $this->parsingCss->value['padding'], |
|
| 5564 | + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5, |
|
| 5565 | + $this->parsingCss->value['background'] |
|
| 5566 | + ); |
|
| 5567 | + |
|
| 5568 | + $this->parsingCss->value['width'] = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] - $marge['l'] - $marge['r']; |
|
| 5569 | + |
|
| 5570 | + // marges = size of the TD |
|
| 5571 | + $mL = HTML2PDF::$_tables[$param['num']]['td_x'] + $marge['l']; |
|
| 5572 | + $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width']; |
|
| 5573 | + $this->_saveMargin($mL, 0, $mR); |
|
| 5574 | + |
|
| 5575 | + // position of the content, from vertical-align |
|
| 5576 | + $hCorr = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h']; |
|
| 5577 | + $hReel = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['real_h']; |
|
| 5578 | + switch ($this->parsingCss->value['vertical-align']) |
|
| 5579 | + { |
|
| 5580 | + case 'bottom': |
|
| 5581 | + $yCorr = $hCorr - $hReel; |
|
| 5582 | + break; |
|
| 5583 | + |
|
| 5584 | + case 'middle': |
|
| 5585 | + $yCorr = ($hCorr - $hReel) * 0.5; |
|
| 5586 | + break; |
|
| 5587 | + |
|
| 5588 | + case 'top': |
|
| 5589 | + default: |
|
| 5590 | + $yCorr = 0; |
|
| 5591 | + break; |
|
| 5592 | + } |
|
| 5593 | + |
|
| 5594 | + // position of the content |
|
| 5595 | + $x = HTML2PDF::$_tables[$param['num']]['td_x'] + $marge['l']; |
|
| 5596 | + $y = HTML2PDF::$_tables[$param['num']]['td_y'] + $marge['t'] + $yCorr; |
|
| 5597 | + $this->pdf->setXY($x, $y); |
|
| 5598 | + $this->_setNewPositionForNewLine(); |
|
| 5599 | + } |
|
| 5600 | + |
|
| 5601 | + return true; |
|
| 5602 | + } |
|
| 5603 | + |
|
| 5604 | + /** |
|
| 5605 | + * tag : TD |
|
| 5606 | + * mode : CLOSE |
|
| 5607 | + * |
|
| 5608 | + * @param array $param |
|
| 5609 | + * @return boolean |
|
| 5610 | + */ |
|
| 5611 | + protected function _tag_close_TD($param) |
|
| 5612 | + { |
|
| 5613 | + if ($this->_isForOneLine) { |
|
| 5614 | + return false; |
|
| 5615 | + } |
|
| 5616 | + |
|
| 5617 | + $this->_maxH = 0; |
|
| 5618 | + |
|
| 5619 | + // get the margins |
|
| 5620 | + $marge = array(); |
|
| 5621 | + $marge['t'] = $this->parsingCss->value['padding']['t'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['t']['width']; |
|
| 5622 | + $marge['r'] = $this->parsingCss->value['padding']['r'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['r']['width']; |
|
| 5623 | + $marge['b'] = $this->parsingCss->value['padding']['b'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['b']['width']; |
|
| 5624 | + $marge['l'] = $this->parsingCss->value['padding']['l'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['l']['width']; |
|
| 5625 | + $marge['t'] += 0.001; |
|
| 5626 | + $marge['r'] += 0.001; |
|
| 5627 | + $marge['b'] += 0.001; |
|
| 5628 | + $marge['l'] += 0.001; |
|
| 5629 | + |
|
| 5630 | + // if we are in a sub HTML |
|
| 5631 | + if ($this->_subPart) { |
|
| 5632 | + |
|
| 5633 | + // it msut take only one page |
|
| 5634 | + if ($this->_testTdInOnepage && $this->_subHtml->pdf->getPage() > 1) { |
|
| 5635 | + throw new HTML2PDF_exception(7); |
|
| 5636 | + } |
|
| 5637 | + |
|
| 5638 | + // size of the content of the TD |
|
| 5639 | + $w0 = $this->_subHtml->_maxX + $marge['l'] + $marge['r']; |
|
| 5640 | + $h0 = $this->_subHtml->_maxY + $marge['t'] + $marge['b']; |
|
| 5641 | + |
|
| 5642 | + // size from the CSS style |
|
| 5643 | + $w2 = $this->parsingCss->value['width'] + $marge['l'] + $marge['r']; |
|
| 5644 | + $h2 = $this->parsingCss->value['height'] + $marge['t'] + $marge['b']; |
|
| 5645 | + |
|
| 5646 | + // final size of the TD |
|
| 5647 | + HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['w'] = max(array($w0, $w2)); |
|
| 5648 | + HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['h'] = max(array($h0, $h2)); |
|
| 5649 | + |
|
| 5650 | + // real position of the content |
|
| 5651 | + HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['real_w'] = $w0; |
|
| 5652 | + HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['real_h'] = $h0; |
|
| 5653 | + |
|
| 5654 | + // destroy the sub HTML |
|
| 5655 | + $this->_destroySubHTML($this->_subHtml); |
|
| 5656 | + } else { |
|
| 5657 | + $this->_loadMargin(); |
|
| 5658 | + |
|
| 5659 | + HTML2PDF::$_tables[$param['num']]['td_x'] += HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['w']; |
|
| 5660 | + } |
|
| 5661 | + |
|
| 5662 | + $this->parsingCss->load(); |
|
| 5663 | + $this->parsingCss->fontSet(); |
|
| 5664 | + |
|
| 5665 | + return true; |
|
| 5666 | + } |
|
| 5667 | + |
|
| 5668 | + |
|
| 5669 | + /** |
|
| 5670 | + * tag : TH |
|
| 5671 | + * mode : OPEN |
|
| 5672 | + * |
|
| 5673 | + * @param array $param |
|
| 5674 | + * @return boolean |
|
| 5675 | + */ |
|
| 5676 | + protected function _tag_open_TH($param) |
|
| 5677 | + { |
|
| 5678 | + if ($this->_isForOneLine) { |
|
| 5679 | + return false; |
|
| 5680 | + } |
|
| 5681 | + |
|
| 5682 | + $this->parsingCss->save(); |
|
| 5683 | + $this->parsingCss->value['font-bold'] = true; |
|
| 5684 | + |
|
| 5685 | + $this->_tag_open_TD($param, 'th'); |
|
| 5686 | + |
|
| 5687 | + return true; |
|
| 5688 | + } |
|
| 5689 | + |
|
| 5690 | + /** |
|
| 5691 | + * tag : TH |
|
| 5692 | + * mode : CLOSE |
|
| 5693 | + * |
|
| 5694 | + * @param array $param |
|
| 5695 | + * @return boolean |
|
| 5696 | + */ |
|
| 5697 | + protected function _tag_close_TH($param) |
|
| 5698 | + { |
|
| 5699 | + if ($this->_isForOneLine) { |
|
| 5700 | + return false; |
|
| 5701 | + } |
|
| 5702 | + |
|
| 5703 | + $this->_tag_close_TD($param); |
|
| 5704 | + |
|
| 5705 | + $this->parsingCss->load(); |
|
| 5706 | + |
|
| 5707 | + return true; |
|
| 5708 | + } |
|
| 5709 | + |
|
| 5710 | + /** |
|
| 5711 | + * tag : IMG |
|
| 5712 | + * mode : OPEN |
|
| 5713 | + * |
|
| 5714 | + * @param array $param |
|
| 5715 | + * @return boolean |
|
| 5716 | + */ |
|
| 5717 | + protected function _tag_open_IMG($param) |
|
| 5718 | + { |
|
| 5719 | + $src = str_replace('&', '&', $param['src']); |
|
| 5720 | + |
|
| 5721 | + $this->parsingCss->save(); |
|
| 5722 | + $this->parsingCss->value['width'] = 0; |
|
| 5723 | + $this->parsingCss->value['height'] = 0; |
|
| 5724 | + $this->parsingCss->value['border'] = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0)); |
|
| 5725 | + $this->parsingCss->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null); |
|
| 5726 | + $this->parsingCss->analyse('img', $param); |
|
| 5727 | + $this->parsingCss->setPosition(); |
|
| 5728 | + $this->parsingCss->fontSet(); |
|
| 5729 | + |
|
| 5730 | + $res = $this->_drawImage($src, isset($param['sub_li'])); |
|
| 5731 | + if ( ! $res) return $res; |
|
| 5732 | + |
|
| 5733 | + $this->parsingCss->load(); |
|
| 5734 | + $this->parsingCss->fontSet(); |
|
| 5735 | + $this->_maxE++; |
|
| 5736 | + |
|
| 5737 | + return true; |
|
| 5738 | + } |
|
| 5739 | + |
|
| 5740 | + /** |
|
| 5741 | + * tag : SELECT |
|
| 5742 | + * mode : OPEN |
|
| 5743 | + * |
|
| 5744 | + * @param array $param |
|
| 5745 | + * @return boolean |
|
| 5746 | + */ |
|
| 5747 | + protected function _tag_open_SELECT($param) |
|
| 5748 | + { |
|
| 5749 | + if ( ! isset($param['name'])) { |
|
| 5750 | + $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 5751 | + } |
|
| 5752 | + |
|
| 5753 | + $param['name'] = strtolower($param['name']); |
|
| 5754 | + |
|
| 5755 | + if (isset($this->_lstField[$param['name']])) { |
|
| 5756 | + $this->_lstField[$param['name']]++; |
|
| 5757 | + } else { |
|
| 5758 | + $this->_lstField[$param['name']] = 1; |
|
| 5759 | + } |
|
| 5760 | + |
|
| 5761 | + $this->parsingCss->save(); |
|
| 5762 | + $this->parsingCss->analyse('select', $param); |
|
| 5763 | + $this->parsingCss->setPosition(); |
|
| 5764 | + $this->parsingCss->fontSet(); |
|
| 5765 | + |
|
| 5766 | + $this->_lstSelect = array(); |
|
| 5767 | + $this->_lstSelect['name'] = $param['name']; |
|
| 5768 | + $this->_lstSelect['multi'] = isset($param['multiple']) ? true : false; |
|
| 5769 | + $this->_lstSelect['size'] = isset($param['size']) ? $param['size'] : 1; |
|
| 5770 | + $this->_lstSelect['options'] = array(); |
|
| 5771 | + |
|
| 5772 | + if ($this->_lstSelect['multi'] && $this->_lstSelect['size'] < 3) $this->_lstSelect['size'] = 3; |
|
| 5773 | + |
|
| 5774 | + return true; |
|
| 5775 | + } |
|
| 5776 | + |
|
| 5777 | + /** |
|
| 5778 | + * tag : OPTION |
|
| 5779 | + * mode : OPEN |
|
| 5780 | + * |
|
| 5781 | + * @param array $param |
|
| 5782 | + * @return boolean |
|
| 5783 | + */ |
|
| 5784 | + protected function _tag_open_OPTION($param) |
|
| 5785 | + { |
|
| 5786 | + // get the content of the option : it is the text of the option |
|
| 5787 | + $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 5788 | + $this->_parsePos += count($level); |
|
| 5789 | + $value = isset($param['value']) ? $param['value'] : 'aut_tag_open_opt_'.(count($this->_lstSelect) + 1); |
|
| 5790 | + |
|
| 5791 | + $this->_lstSelect['options'][$value] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : ''; |
|
| 5792 | + |
|
| 5793 | + return true; |
|
| 5794 | + } |
|
| 5795 | + |
|
| 5796 | + /** |
|
| 5797 | + * tag : OPTION |
|
| 5798 | + * mode : CLOSE |
|
| 5799 | + * |
|
| 5800 | + * @param array $param |
|
| 5801 | + * @return boolean |
|
| 5802 | + */ |
|
| 5803 | + protected function _tag_close_OPTION($param) |
|
| 5804 | + { |
|
| 5805 | + // nothing to do here |
|
| 5806 | + |
|
| 5807 | + return true; |
|
| 5808 | + } |
|
| 5809 | + |
|
| 5810 | + /** |
|
| 5811 | + * tag : SELECT |
|
| 5812 | + * mode : CLOSE |
|
| 5813 | + * |
|
| 5814 | + * @return boolean |
|
| 5815 | + */ |
|
| 5816 | + protected function _tag_close_SELECT() |
|
| 5817 | + { |
|
| 5818 | + // position of the select |
|
| 5819 | + $x = $this->pdf->getX(); |
|
| 5820 | + $y = $this->pdf->getY(); |
|
| 5821 | + $f = 1.08 * $this->parsingCss->value['font-size']; |
|
| 5822 | + |
|
| 5823 | + // width |
|
| 5824 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = 50; |
|
| 5825 | + |
|
| 5826 | + // height (automatic) |
|
| 5827 | + $h = ($f * 1.07 * $this->_lstSelect['size'] + 1); |
|
| 5828 | + |
|
| 5829 | + $prop = $this->parsingCss->getFormStyle(); |
|
| 5830 | + |
|
| 5831 | + // multy select |
|
| 5832 | + if ($this->_lstSelect['multi']) { |
|
| 5833 | + $prop['multipleSelection'] = 'true'; |
|
| 5834 | + } |
|
| 5835 | + |
|
| 5836 | + |
|
| 5837 | + // single or multi select |
|
| 5838 | + if ($this->_lstSelect['size'] > 1) { |
|
| 5839 | + $this->pdf->ListBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop); |
|
| 5840 | + } else { |
|
| 5841 | + $this->pdf->ComboBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop); |
|
| 5842 | + } |
|
| 5843 | + |
|
| 5844 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 5845 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 5846 | + $this->_maxH = max($this->_maxH, $h); |
|
| 5847 | + $this->_maxE++; |
|
| 5848 | + $this->pdf->setX($x + $w); |
|
| 5849 | + |
|
| 5850 | + $this->parsingCss->load(); |
|
| 5851 | + $this->parsingCss->fontSet(); |
|
| 5852 | + |
|
| 5853 | + $this->_lstSelect = array(); |
|
| 5854 | + |
|
| 5855 | + return true; |
|
| 5856 | + } |
|
| 5857 | + |
|
| 5858 | + /** |
|
| 5859 | + * tag : TEXTAREA |
|
| 5860 | + * mode : OPEN |
|
| 5861 | + * |
|
| 5862 | + * @param array $param |
|
| 5863 | + * @return boolean |
|
| 5864 | + */ |
|
| 5865 | + protected function _tag_open_TEXTAREA($param) |
|
| 5866 | + { |
|
| 5867 | + if ( ! isset($param['name'])) { |
|
| 5868 | + $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 5869 | + } |
|
| 5870 | + |
|
| 5871 | + $param['name'] = strtolower($param['name']); |
|
| 5872 | + |
|
| 5873 | + if (isset($this->_lstField[$param['name']])) { |
|
| 5874 | + $this->_lstField[$param['name']]++; |
|
| 5875 | + } else { |
|
| 5876 | + $this->_lstField[$param['name']] = 1; |
|
| 5877 | + } |
|
| 5878 | + |
|
| 5879 | + $this->parsingCss->save(); |
|
| 5880 | + $this->parsingCss->analyse('textarea', $param); |
|
| 5881 | + $this->parsingCss->setPosition(); |
|
| 5882 | + $this->parsingCss->fontSet(); |
|
| 5883 | + |
|
| 5884 | + $x = $this->pdf->getX(); |
|
| 5885 | + $y = $this->pdf->getY(); |
|
| 5886 | + $fx = 0.65 * $this->parsingCss->value['font-size']; |
|
| 5887 | + $fy = 1.08 * $this->parsingCss->value['font-size']; |
|
| 5888 | + |
|
| 5889 | + // extract the content the textarea : value |
|
| 5890 | + $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 5891 | + $this->_parsePos += count($level); |
|
| 5892 | + |
|
| 5893 | + // automatic size, from cols and rows properties |
|
| 5894 | + $w = $fx * (isset($param['cols']) ? $param['cols'] : 22) + 1; |
|
| 5895 | + $h = $fy * 1.07 * (isset($param['rows']) ? $param['rows'] : 3) + 3; |
|
| 5896 | + |
|
| 5897 | + $prop = $this->parsingCss->getFormStyle(); |
|
| 5898 | + |
|
| 5899 | + $prop['multiline'] = true; |
|
| 5900 | + $prop['value'] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : ''; |
|
| 5901 | + |
|
| 5902 | + $this->pdf->TextField($param['name'], $w, $h, $prop, array(), $x, $y); |
|
| 5903 | + |
|
| 5904 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 5905 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 5906 | + $this->_maxH = max($this->_maxH, $h); |
|
| 5907 | + $this->_maxE++; |
|
| 5908 | + $this->pdf->setX($x + $w); |
|
| 5909 | + |
|
| 5910 | + return true; |
|
| 5911 | + } |
|
| 5912 | + |
|
| 5913 | + /** |
|
| 5914 | + * tag : TEXTAREA |
|
| 5915 | + * mode : CLOSE |
|
| 5916 | + * |
|
| 5917 | + * @return boolean |
|
| 5918 | + */ |
|
| 5919 | + protected function _tag_close_TEXTAREA() |
|
| 5920 | + { |
|
| 5921 | + $this->parsingCss->load(); |
|
| 5922 | + $this->parsingCss->fontSet(); |
|
| 5923 | + |
|
| 5924 | + return true; |
|
| 5925 | + } |
|
| 5926 | + |
|
| 5927 | + /** |
|
| 5928 | + * tag : INPUT |
|
| 5929 | + * mode : OPEN |
|
| 5930 | + * |
|
| 5931 | + * @param array $param |
|
| 5932 | + * @return boolean |
|
| 5933 | + */ |
|
| 5934 | + protected function _tag_open_INPUT($param) |
|
| 5935 | + { |
|
| 5936 | + if ( ! isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 5937 | + if ( ! isset($param['value'])) $param['value'] = ''; |
|
| 5938 | + if ( ! isset($param['type'])) $param['type'] = 'text'; |
|
| 5939 | + |
|
| 5940 | + $param['name'] = strtolower($param['name']); |
|
| 5941 | + $param['type'] = strtolower($param['type']); |
|
| 5942 | + |
|
| 5943 | + // the type must be valid |
|
| 5944 | + if ( ! in_array($param['type'], array('text', 'checkbox', 'radio', 'hidden', 'submit', 'reset', 'button'))) { |
|
| 5945 | + $param['type'] = 'text'; |
|
| 5946 | + } |
|
| 5947 | + |
|
| 5948 | + if (isset($this->_lstField[$param['name']])) { |
|
| 5949 | + $this->_lstField[$param['name']]++; |
|
| 5950 | + } else { |
|
| 5951 | + $this->_lstField[$param['name']] = 1; |
|
| 5952 | + } |
|
| 5953 | + |
|
| 5954 | + $this->parsingCss->save(); |
|
| 5955 | + $this->parsingCss->analyse('input', $param); |
|
| 5956 | + $this->parsingCss->setPosition(); |
|
| 5957 | + $this->parsingCss->fontSet(); |
|
| 5958 | + |
|
| 5959 | + $name = $param['name']; |
|
| 5960 | + |
|
| 5961 | + $x = $this->pdf->getX(); |
|
| 5962 | + $y = $this->pdf->getY(); |
|
| 5963 | + $f = 1.08 * $this->parsingCss->value['font-size']; |
|
| 5964 | + |
|
| 5965 | + $prop = $this->parsingCss->getFormStyle(); |
|
| 5966 | + |
|
| 5967 | + switch ($param['type']) |
|
| 5968 | + { |
|
| 5969 | + case 'checkbox': |
|
| 5970 | + $w = 3; |
|
| 5971 | + $h = $w; |
|
| 5972 | + if ($h < $f) $y += ($f - $h) * 0.5; |
|
| 5973 | + $checked = (isset($param['checked']) && $param['checked'] == 'checked'); |
|
| 5974 | + $this->pdf->CheckBox($name, $w, $checked, $prop, array(), ($param['value'] ? $param['value'] : 'Yes'), $x, $y); |
|
| 5975 | + break; |
|
| 5976 | + |
|
| 5977 | + case 'radio': |
|
| 5978 | + $w = 3; |
|
| 5979 | + $h = $w; |
|
| 5980 | + if ($h < $f) $y += ($f - $h) * 0.5; |
|
| 5981 | + $checked = (isset($param['checked']) && $param['checked'] == 'checked'); |
|
| 5982 | + $this->pdf->RadioButton($name, $w, $prop, array(), ($param['value'] ? $param['value'] : 'On'), $checked, $x, $y); |
|
| 5983 | + break; |
|
| 5984 | + |
|
| 5985 | + case 'hidden': |
|
| 5986 | + $w = 0; |
|
| 5987 | + $h = 0; |
|
| 5988 | + $prop['value'] = $param['value']; |
|
| 5989 | + $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y); |
|
| 5990 | + break; |
|
| 5991 | + |
|
| 5992 | + case 'text': |
|
| 5993 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 5994 | + $h = $f * 1.3; |
|
| 5995 | + $prop['value'] = $param['value']; |
|
| 5996 | + $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y); |
|
| 5997 | + break; |
|
| 5998 | + |
|
| 5999 | + case 'submit': |
|
| 6000 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 6001 | + $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 6002 | + $action = array('S'=>'SubmitForm', 'F'=>$this->_isInForm, 'Flags'=>array('ExportFormat')); |
|
| 6003 | + $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
|
| 6004 | + break; |
|
| 6005 | + |
|
| 6006 | + case 'reset': |
|
| 6007 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 6008 | + $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 6009 | + $action = array('S'=>'ResetForm'); |
|
| 6010 | + $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
|
| 6011 | + break; |
|
| 6012 | + |
|
| 6013 | + case 'button': |
|
| 6014 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 6015 | + $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 6016 | + $action = isset($param['onclick']) ? $param['onclick'] : ''; |
|
| 6017 | + $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
|
| 6018 | + break; |
|
| 6019 | + |
|
| 6020 | + default: |
|
| 6021 | + $w = 0; |
|
| 6022 | + $h = 0; |
|
| 6023 | + break; |
|
| 6024 | + } |
|
| 6025 | + |
|
| 6026 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 6027 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 6028 | + $this->_maxH = max($this->_maxH, $h); |
|
| 6029 | + $this->_maxE++; |
|
| 6030 | + $this->pdf->setX($x + $w); |
|
| 6031 | + |
|
| 6032 | + $this->parsingCss->load(); |
|
| 6033 | + $this->parsingCss->fontSet(); |
|
| 6034 | + |
|
| 6035 | + return true; |
|
| 6036 | + } |
|
| 6037 | + |
|
| 6038 | + /** |
|
| 6039 | + * tag : DRAW |
|
| 6040 | + * mode : OPEN |
|
| 6041 | + * |
|
| 6042 | + * @param array $param |
|
| 6043 | + * @return boolean |
|
| 6044 | + */ |
|
| 6045 | + protected function _tag_open_DRAW($param) |
|
| 6046 | + { |
|
| 6047 | + if ($this->_isForOneLine) { |
|
| 6048 | + return false; |
|
| 6049 | + } |
|
| 6050 | + if ($this->_debugActif) { |
|
| 6051 | + $this->_DEBUG_add('DRAW', true); |
|
| 6052 | + } |
|
| 6053 | + |
|
| 6054 | + $this->parsingCss->save(); |
|
| 6055 | + $this->parsingCss->analyse('draw', $param); |
|
| 6056 | + $this->parsingCss->fontSet(); |
|
| 6057 | + |
|
| 6058 | + $alignObject = null; |
|
| 6059 | + if ($this->parsingCss->value['margin-auto']) { |
|
| 6060 | + $alignObject = 'center'; |
|
| 6061 | + } |
|
| 6062 | + |
|
| 6063 | + $overW = $this->parsingCss->value['width']; |
|
| 6064 | + $overH = $this->parsingCss->value['height']; |
|
| 6065 | + $this->parsingCss->value['old_maxX'] = $this->_maxX; |
|
| 6066 | + $this->parsingCss->value['old_maxY'] = $this->_maxY; |
|
| 6067 | + $this->parsingCss->value['old_maxH'] = $this->_maxH; |
|
| 6068 | + |
|
| 6069 | + $w = $this->parsingCss->value['width']; |
|
| 6070 | + $h = $this->parsingCss->value['height']; |
|
| 6071 | + |
|
| 6072 | + if ( ! $this->parsingCss->value['position']) { |
|
| 6073 | + if ( |
|
| 6074 | + $w < ($this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin()) && |
|
| 6075 | + $this->pdf->getX() + $w >= ($this->pdf->getW() - $this->pdf->getrMargin()) |
|
| 6076 | + ) |
|
| 6077 | + $this->_tag_open_BR(array()); |
|
| 6078 | + |
|
| 6079 | + if ( |
|
| 6080 | + ($h < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin())) && |
|
| 6081 | + ($this->pdf->getY() + $h >= ($this->pdf->getH() - $this->pdf->getbMargin())) && |
|
| 6082 | + ! $this->_isInOverflow |
|
| 6083 | + ) |
|
| 6084 | + $this->_setNewPage(); |
|
| 6085 | + |
|
| 6086 | + $old = $this->parsingCss->getOldValues(); |
|
| 6087 | + $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 6088 | + |
|
| 6089 | + if ($parentWidth > $w) { |
|
| 6090 | + if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 6091 | + else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 6092 | + } |
|
| 6093 | + |
|
| 6094 | + $this->parsingCss->setPosition(); |
|
| 6095 | + } else { |
|
| 6096 | + $old = $this->parsingCss->getOldValues(); |
|
| 6097 | + $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 6098 | + |
|
| 6099 | + if ($parentWidth > $w) { |
|
| 6100 | + if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 6101 | + else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 6102 | + } |
|
| 6103 | + |
|
| 6104 | + $this->parsingCss->setPosition(); |
|
| 6105 | + $this->_saveMax(); |
|
| 6106 | + $this->_maxX = 0; |
|
| 6107 | + $this->_maxY = 0; |
|
| 6108 | + $this->_maxH = 0; |
|
| 6109 | + $this->_maxE = 0; |
|
| 6110 | + } |
|
| 6111 | + |
|
| 6112 | + $this->_drawRectangle( |
|
| 6113 | + $this->parsingCss->value['x'], |
|
| 6114 | + $this->parsingCss->value['y'], |
|
| 6115 | + $this->parsingCss->value['width'], |
|
| 6116 | + $this->parsingCss->value['height'], |
|
| 6117 | + $this->parsingCss->value['border'], |
|
| 6118 | + $this->parsingCss->value['padding'], |
|
| 6119 | + 0, |
|
| 6120 | + $this->parsingCss->value['background'] |
|
| 6121 | + ); |
|
| 6122 | + |
|
| 6123 | + $marge = array(); |
|
| 6124 | + $marge['l'] = $this->parsingCss->value['border']['l']['width']; |
|
| 6125 | + $marge['r'] = $this->parsingCss->value['border']['r']['width']; |
|
| 6126 | + $marge['t'] = $this->parsingCss->value['border']['t']['width']; |
|
| 6127 | + $marge['b'] = $this->parsingCss->value['border']['b']['width']; |
|
| 6128 | + |
|
| 6129 | + $this->parsingCss->value['width'] -= $marge['l'] + $marge['r']; |
|
| 6130 | + $this->parsingCss->value['height'] -= $marge['t'] + $marge['b']; |
|
| 6131 | + |
|
| 6132 | + $overW -= $marge['l'] + $marge['r']; |
|
| 6133 | + $overH -= $marge['t'] + $marge['b']; |
|
| 6134 | + |
|
| 6135 | + // clipping to draw only in the size opf the DRAW tag |
|
| 6136 | + $this->pdf->clippingPathStart( |
|
| 6137 | + $this->parsingCss->value['x'] + $marge['l'], |
|
| 6138 | + $this->parsingCss->value['y'] + $marge['t'], |
|
| 6139 | + $this->parsingCss->value['width'], |
|
| 6140 | + $this->parsingCss->value['height'] |
|
| 6141 | + ); |
|
| 6142 | + |
|
| 6143 | + // left and right of the DRAW tag |
|
| 6144 | + $mL = $this->parsingCss->value['x'] + $marge['l']; |
|
| 6145 | + $mR = $this->pdf->getW() - $mL - $overW; |
|
| 6146 | + |
|
| 6147 | + // position of the DRAW tag |
|
| 6148 | + $x = $this->parsingCss->value['x'] + $marge['l']; |
|
| 6149 | + $y = $this->parsingCss->value['y'] + $marge['t']; |
|
| 6150 | + |
|
| 6151 | + // prepare the drawing area |
|
| 6152 | + $this->_saveMargin($mL, 0, $mR); |
|
| 6153 | + $this->pdf->setXY($x, $y); |
|
| 6154 | + |
|
| 6155 | + // we are in a draw tag |
|
| 6156 | + $this->_isInDraw = array( |
|
| 6157 | + 'x' => $x, |
|
| 6158 | + 'y' => $y, |
|
| 6159 | + 'w' => $overW, |
|
| 6160 | + 'h' => $overH, |
|
| 6161 | + ); |
|
| 6162 | + |
|
| 6163 | + // init the translate matrix : (0,0) => ($x, $y) |
|
| 6164 | + $this->pdf->doTransform(array(1, 0, 0, 1, $x, $y)); |
|
| 6165 | + $this->pdf->SetAlpha(1.); |
|
| 6166 | + return true; |
|
| 6167 | + } |
|
| 6168 | + |
|
| 6169 | + /** |
|
| 6170 | + * tag : DRAW |
|
| 6171 | + * mode : CLOSE |
|
| 6172 | + * |
|
| 6173 | + * @param array $param |
|
| 6174 | + * @return boolean |
|
| 6175 | + */ |
|
| 6176 | + protected function _tag_close_DRAW($param) |
|
| 6177 | + { |
|
| 6178 | + if ($this->_isForOneLine) { |
|
| 6179 | + return false; |
|
| 6180 | + } |
|
| 6181 | + |
|
| 6182 | + $this->pdf->SetAlpha(1.); |
|
| 6183 | + $this->pdf->undoTransform(); |
|
| 6184 | + $this->pdf->clippingPathStop(); |
|
| 6185 | + |
|
| 6186 | + $this->_maxX = $this->parsingCss->value['old_maxX']; |
|
| 6187 | + $this->_maxY = $this->parsingCss->value['old_maxY']; |
|
| 6188 | + $this->_maxH = $this->parsingCss->value['old_maxH']; |
|
| 6189 | + |
|
| 6190 | + $marge = array(); |
|
| 6191 | + $marge['l'] = $this->parsingCss->value['border']['l']['width']; |
|
| 6192 | + $marge['r'] = $this->parsingCss->value['border']['r']['width']; |
|
| 6193 | + $marge['t'] = $this->parsingCss->value['border']['t']['width']; |
|
| 6194 | + $marge['b'] = $this->parsingCss->value['border']['b']['width']; |
|
| 6195 | + |
|
| 6196 | + $x = $this->parsingCss->value['x']; |
|
| 6197 | + $y = $this->parsingCss->value['y']; |
|
| 6198 | + $w = $this->parsingCss->value['width'] + $marge['l'] + $marge['r']; |
|
| 6199 | + $h = $this->parsingCss->value['height'] + $marge['t'] + $marge['b']; |
|
| 6200 | + |
|
| 6201 | + if ($this->parsingCss->value['position'] != 'absolute') { |
|
| 6202 | + $this->pdf->setXY($x + $w, $y); |
|
| 6203 | + |
|
| 6204 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 6205 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 6206 | + $this->_maxH = max($this->_maxH, $h); |
|
| 6207 | + $this->_maxE++; |
|
| 6208 | + } else { |
|
| 6209 | + // position |
|
| 6210 | + $this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']); |
|
| 6211 | + |
|
| 6212 | + $this->_loadMax(); |
|
| 6213 | + } |
|
| 6214 | + |
|
| 6215 | + $block = ($this->parsingCss->value['display'] != 'inline' && $this->parsingCss->value['position'] != 'absolute'); |
|
| 6216 | + |
|
| 6217 | + $this->parsingCss->load(); |
|
| 6218 | + $this->parsingCss->fontSet(); |
|
| 6219 | + $this->_loadMargin(); |
|
| 6220 | + |
|
| 6221 | + if ($block) { |
|
| 6222 | + $this->_tag_open_BR(array()); |
|
| 6223 | + } |
|
| 6224 | + if ($this->_debugActif) { |
|
| 6225 | + $this->_DEBUG_add('DRAW', false); |
|
| 6226 | + } |
|
| 6227 | + |
|
| 6228 | + $this->_isInDraw = null; |
|
| 6229 | + |
|
| 6230 | + return true; |
|
| 6231 | + } |
|
| 6232 | + |
|
| 6233 | + /** |
|
| 6234 | + * tag : LINE |
|
| 6235 | + * mode : OPEN |
|
| 6236 | + * |
|
| 6237 | + * @param array $param |
|
| 6238 | + * @return boolean|null |
|
| 6239 | + */ |
|
| 6240 | + protected function _tag_open_LINE($param) |
|
| 6241 | + { |
|
| 6242 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'LINE'); |
|
| 6243 | + |
|
| 6244 | + $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6245 | + $this->parsingCss->save(); |
|
| 6246 | + $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6247 | + $styles['fill'] = null; |
|
| 6248 | + $style = $this->pdf->svgSetStyle($styles); |
|
| 6249 | + |
|
| 6250 | + $x1 = isset($param['x1']) ? $this->parsingCss->ConvertToMM($param['x1'], $this->_isInDraw['w']) : 0.; |
|
| 6251 | + $y1 = isset($param['y1']) ? $this->parsingCss->ConvertToMM($param['y1'], $this->_isInDraw['h']) : 0.; |
|
| 6252 | + $x2 = isset($param['x2']) ? $this->parsingCss->ConvertToMM($param['x2'], $this->_isInDraw['w']) : 0.; |
|
| 6253 | + $y2 = isset($param['y2']) ? $this->parsingCss->ConvertToMM($param['y2'], $this->_isInDraw['h']) : 0.; |
|
| 6254 | + $this->pdf->svgLine($x1, $y1, $x2, $y2); |
|
| 6255 | + |
|
| 6256 | + $this->pdf->undoTransform(); |
|
| 6257 | + $this->parsingCss->load(); |
|
| 6258 | + } |
|
| 6259 | + |
|
| 6260 | + /** |
|
| 6261 | + * tag : RECT |
|
| 6262 | + * mode : OPEN |
|
| 6263 | + * |
|
| 6264 | + * @param array $param |
|
| 6265 | + * @return boolean|null |
|
| 6266 | + */ |
|
| 6267 | + protected function _tag_open_RECT($param) |
|
| 6268 | + { |
|
| 6269 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'RECT'); |
|
| 6270 | + |
|
| 6271 | + $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6272 | + $this->parsingCss->save(); |
|
| 6273 | + $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6274 | + $style = $this->pdf->svgSetStyle($styles); |
|
| 6275 | + |
|
| 6276 | + $x = isset($param['x']) ? $this->parsingCss->ConvertToMM($param['x'], $this->_isInDraw['w']) : 0.; |
|
| 6277 | + $y = isset($param['y']) ? $this->parsingCss->ConvertToMM($param['y'], $this->_isInDraw['h']) : 0.; |
|
| 6278 | + $w = isset($param['w']) ? $this->parsingCss->ConvertToMM($param['w'], $this->_isInDraw['w']) : 0.; |
|
| 6279 | + $h = isset($param['h']) ? $this->parsingCss->ConvertToMM($param['h'], $this->_isInDraw['h']) : 0.; |
|
| 6280 | + |
|
| 6281 | + $this->pdf->svgRect($x, $y, $w, $h, $style); |
|
| 6282 | + |
|
| 6283 | + $this->pdf->undoTransform(); |
|
| 6284 | + $this->parsingCss->load(); |
|
| 6285 | + } |
|
| 6286 | + |
|
| 6287 | + /** |
|
| 6288 | + * tag : CIRCLE |
|
| 6289 | + * mode : OPEN |
|
| 6290 | + * |
|
| 6291 | + * @param array $param |
|
| 6292 | + * @return boolean|null |
|
| 6293 | + */ |
|
| 6294 | + protected function _tag_open_CIRCLE($param) |
|
| 6295 | + { |
|
| 6296 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'CIRCLE'); |
|
| 6297 | + |
|
| 6298 | + $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6299 | + $this->parsingCss->save(); |
|
| 6300 | + $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6301 | + $style = $this->pdf->svgSetStyle($styles); |
|
| 6302 | + |
|
| 6303 | + $cx = isset($param['cx']) ? $this->parsingCss->ConvertToMM($param['cx'], $this->_isInDraw['w']) : 0.; |
|
| 6304 | + $cy = isset($param['cy']) ? $this->parsingCss->ConvertToMM($param['cy'], $this->_isInDraw['h']) : 0.; |
|
| 6305 | + $r = isset($param['r']) ? $this->parsingCss->ConvertToMM($param['r'], $this->_isInDraw['w']) : 0.; |
|
| 6306 | + $this->pdf->svgEllipse($cx, $cy, $r, $r, $style); |
|
| 6307 | + |
|
| 6308 | + $this->pdf->undoTransform(); |
|
| 6309 | + $this->parsingCss->load(); |
|
| 6310 | + } |
|
| 6311 | + |
|
| 6312 | + /** |
|
| 6313 | + * tag : ELLIPSE |
|
| 6314 | + * mode : OPEN |
|
| 6315 | + * |
|
| 6316 | + * @param array $param |
|
| 6317 | + * @return boolean|null |
|
| 6318 | + */ |
|
| 6319 | + protected function _tag_open_ELLIPSE($param) |
|
| 6320 | + { |
|
| 6321 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'ELLIPSE'); |
|
| 6322 | + |
|
| 6323 | + $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6324 | + $this->parsingCss->save(); |
|
| 6325 | + $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6326 | + $style = $this->pdf->svgSetStyle($styles); |
|
| 6327 | + |
|
| 6328 | + $cx = isset($param['cx']) ? $this->parsingCss->ConvertToMM($param['cx'], $this->_isInDraw['w']) : 0.; |
|
| 6329 | + $cy = isset($param['cy']) ? $this->parsingCss->ConvertToMM($param['cy'], $this->_isInDraw['h']) : 0.; |
|
| 6330 | + $rx = isset($param['ry']) ? $this->parsingCss->ConvertToMM($param['rx'], $this->_isInDraw['w']) : 0.; |
|
| 6331 | + $ry = isset($param['rx']) ? $this->parsingCss->ConvertToMM($param['ry'], $this->_isInDraw['h']) : 0.; |
|
| 6332 | + $this->pdf->svgEllipse($cx, $cy, $rx, $ry, $style); |
|
| 6333 | + |
|
| 6334 | + $this->pdf->undoTransform(); |
|
| 6335 | + $this->parsingCss->load(); |
|
| 6336 | + } |
|
| 6337 | + |
|
| 6338 | + |
|
| 6339 | + /** |
|
| 6340 | + * tag : POLYLINE |
|
| 6341 | + * mode : OPEN |
|
| 6342 | + * |
|
| 6343 | + * @param array $param |
|
| 6344 | + * @return boolean|null |
|
| 6345 | + */ |
|
| 6346 | + protected function _tag_open_POLYLINE($param) |
|
| 6347 | + { |
|
| 6348 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6349 | + |
|
| 6350 | + $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6351 | + $this->parsingCss->save(); |
|
| 6352 | + $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6353 | + $style = $this->pdf->svgSetStyle($styles); |
|
| 6354 | + |
|
| 6355 | + $path = isset($param['points']) ? $param['points'] : null; |
|
| 6356 | + if ($path) { |
|
| 6357 | + $path = str_replace(',', ' ', $path); |
|
| 6358 | + $path = preg_replace('/[\s]+/', ' ', trim($path)); |
|
| 6359 | + |
|
| 6360 | + // prepare the path |
|
| 6361 | + $path = explode(' ', $path); |
|
| 6362 | + foreach ($path as $k => $v) { |
|
| 6363 | + $path[$k] = trim($v); |
|
| 6364 | + if ($path[$k] === '') unset($path[$k]); |
|
| 6365 | + } |
|
| 6366 | + $path = array_values($path); |
|
| 6367 | + |
|
| 6368 | + $actions = array(); |
|
| 6369 | + for ($k = 0; $k < count($path); $k += 2) { |
|
| 6370 | + $actions[] = array( |
|
| 6371 | + ($k ? 'L' : 'M'), |
|
| 6372 | + $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']), |
|
| 6373 | + $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']) |
|
| 6374 | + ); |
|
| 6375 | + } |
|
| 6376 | + |
|
| 6377 | + // drawing |
|
| 6378 | + $this->pdf->svgPolygone($actions, $style); |
|
| 6379 | + } |
|
| 6380 | + |
|
| 6381 | + $this->pdf->undoTransform(); |
|
| 6382 | + $this->parsingCss->load(); |
|
| 6383 | + } |
|
| 6384 | + |
|
| 6385 | + /** |
|
| 6386 | + * tag : POLYGON |
|
| 6387 | + * mode : OPEN |
|
| 6388 | + * |
|
| 6389 | + * @param array $param |
|
| 6390 | + * @return boolean|null |
|
| 6391 | + */ |
|
| 6392 | + protected function _tag_open_POLYGON($param) |
|
| 6393 | + { |
|
| 6394 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6395 | + |
|
| 6396 | + $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6397 | + $this->parsingCss->save(); |
|
| 6398 | + $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6399 | + $style = $this->pdf->svgSetStyle($styles); |
|
| 6400 | + |
|
| 6401 | + $path = (isset($param['points']) ? $param['points'] : null); |
|
| 6402 | + if ($path) { |
|
| 6403 | + $path = str_replace(',', ' ', $path); |
|
| 6404 | + $path = preg_replace('/[\s]+/', ' ', trim($path)); |
|
| 6405 | + |
|
| 6406 | + // prepare the path |
|
| 6407 | + $path = explode(' ', $path); |
|
| 6408 | + foreach ($path as $k => $v) { |
|
| 6409 | + $path[$k] = trim($v); |
|
| 6410 | + if ($path[$k] === '') unset($path[$k]); |
|
| 6411 | + } |
|
| 6412 | + $path = array_values($path); |
|
| 6413 | + |
|
| 6414 | + $actions = array(); |
|
| 6415 | + for ($k = 0; $k < count($path); $k += 2) { |
|
| 6416 | + $actions[] = array( |
|
| 6417 | + ($k ? 'L' : 'M'), |
|
| 6418 | + $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']), |
|
| 6419 | + $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']) |
|
| 6420 | + ); |
|
| 6421 | + } |
|
| 6422 | + $actions[] = array('z'); |
|
| 6423 | + |
|
| 6424 | + // drawing |
|
| 6425 | + $this->pdf->svgPolygone($actions, $style); |
|
| 6426 | + } |
|
| 6427 | + |
|
| 6428 | + $this->pdf->undoTransform(); |
|
| 6429 | + $this->parsingCss->load(); |
|
| 6430 | + } |
|
| 6431 | + |
|
| 6432 | + /** |
|
| 6433 | + * tag : PATH |
|
| 6434 | + * mode : OPEN |
|
| 6435 | + * |
|
| 6436 | + * @param array $param |
|
| 6437 | + * @return boolean|null |
|
| 6438 | + */ |
|
| 6439 | + protected function _tag_open_PATH($param) |
|
| 6440 | + { |
|
| 6441 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'PATH'); |
|
| 6442 | + |
|
| 6443 | + $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6444 | + $this->parsingCss->save(); |
|
| 6445 | + $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6446 | + $style = $this->pdf->svgSetStyle($styles); |
|
| 6447 | + |
|
| 6448 | + $path = isset($param['d']) ? $param['d'] : null; |
|
| 6449 | + |
|
| 6450 | + if ($path) { |
|
| 6451 | + // prepare the path |
|
| 6452 | + $path = str_replace(',', ' ', $path); |
|
| 6453 | + $path = preg_replace('/([a-zA-Z])([0-9\.\-])/', '$1 $2', $path); |
|
| 6454 | + $path = preg_replace('/([0-9\.])([a-zA-Z])/', '$1 $2', $path); |
|
| 6455 | + $path = preg_replace('/[\s]+/', ' ', trim($path)); |
|
| 6456 | + $path = preg_replace('/ ([a-z]{2})/', '$1', $path); |
|
| 6457 | + |
|
| 6458 | + $path = explode(' ', $path); |
|
| 6459 | + foreach ($path as $k => $v) { |
|
| 6460 | + $path[$k] = trim($v); |
|
| 6461 | + if ($path[$k] === '') unset($path[$k]); |
|
| 6462 | + } |
|
| 6463 | + $path = array_values($path); |
|
| 6464 | + |
|
| 6465 | + // read each actions in the path |
|
| 6466 | + $actions = array(); |
|
| 6467 | + $action = array(); |
|
| 6468 | + $lastAction = null; // last action found |
|
| 6469 | + for ($k = 0; $k < count($path); true) { |
|
| 6470 | + |
|
| 6471 | + // for this actions, we can not have multi coordonate |
|
| 6472 | + if (in_array($lastAction, array('z', 'Z'))) { |
|
| 6473 | + $lastAction = null; |
|
| 6474 | + } |
|
| 6475 | + |
|
| 6476 | + // read the new action (forcing if no action before) |
|
| 6477 | + if (preg_match('/^[a-z]+$/i', $path[$k]) || $lastAction === null) { |
|
| 6478 | + $lastAction = $path[$k]; |
|
| 6479 | + $k++; |
|
| 6480 | + } |
|
| 6481 | + |
|
| 6482 | + // current action |
|
| 6483 | + $action = array(); |
|
| 6484 | + $action[] = $lastAction; |
|
| 6485 | + switch ($lastAction) |
|
| 6486 | + { |
|
| 6487 | + case 'C': |
|
| 6488 | + case 'c': |
|
| 6489 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x1 |
|
| 6490 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y1 |
|
| 6491 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 2], $this->_isInDraw['w']); // x2 |
|
| 6492 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 3], $this->_isInDraw['h']); // y2 |
|
| 6493 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 4], $this->_isInDraw['w']); // x |
|
| 6494 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 5], $this->_isInDraw['h']); // y |
|
| 6495 | + $k += 6; |
|
| 6496 | + break; |
|
| 6497 | + |
|
| 6498 | + case 'Q': |
|
| 6499 | + case 'S': |
|
| 6500 | + case 'q': |
|
| 6501 | + case 's': |
|
| 6502 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x2 |
|
| 6503 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y2 |
|
| 6504 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 2], $this->_isInDraw['w']); // x |
|
| 6505 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 3], $this->_isInDraw['h']); // y |
|
| 6506 | + $k += 4; |
|
| 6507 | + break; |
|
| 6508 | + |
|
| 6509 | + case 'A': |
|
| 6510 | + case 'a': |
|
| 6511 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // rx |
|
| 6512 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // ry |
|
| 6513 | + $action[] = 1. * $path[$k + 2]; // angle de deviation de l'axe X |
|
| 6514 | + $action[] = ($path[$k + 3] == '1') ? 1 : 0; // large-arc-flag |
|
| 6515 | + $action[] = ($path[$k + 4] == '1') ? 1 : 0; // sweep-flag |
|
| 6516 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 5], $this->_isInDraw['w']); // x |
|
| 6517 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 6], $this->_isInDraw['h']); // y |
|
| 6518 | + $k += 7; |
|
| 6519 | + break; |
|
| 6520 | + |
|
| 6521 | + case 'M': |
|
| 6522 | + case 'L': |
|
| 6523 | + case 'T': |
|
| 6524 | + case 'm': |
|
| 6525 | + case 'l': |
|
| 6526 | + case 't': |
|
| 6527 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x |
|
| 6528 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y |
|
| 6529 | + $k += 2; |
|
| 6530 | + break; |
|
| 6531 | + |
|
| 6532 | + case 'H': |
|
| 6533 | + case 'h': |
|
| 6534 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x |
|
| 6535 | + $k += 1; |
|
| 6536 | + break; |
|
| 6537 | + |
|
| 6538 | + case 'V': |
|
| 6539 | + case 'v': |
|
| 6540 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['h']); // y |
|
| 6541 | + $k += 1; |
|
| 6542 | + break; |
|
| 6543 | + |
|
| 6544 | + case 'z': |
|
| 6545 | + case 'Z': |
|
| 6546 | + default: |
|
| 6547 | + break; |
|
| 6548 | + } |
|
| 6549 | + // add the action |
|
| 6550 | + $actions[] = $action; |
|
| 6551 | + } |
|
| 6552 | + |
|
| 6553 | + // drawing |
|
| 6554 | + $this->pdf->svgPolygone($actions, $style); |
|
| 6555 | + } |
|
| 6556 | + |
|
| 6557 | + $this->pdf->undoTransform(); |
|
| 6558 | + $this->parsingCss->load(); |
|
| 6559 | + } |
|
| 6560 | + |
|
| 6561 | + /** |
|
| 6562 | + * tag : G |
|
| 6563 | + * mode : OPEN |
|
| 6564 | + * |
|
| 6565 | + * @param array $param |
|
| 6566 | + * @return boolean|null |
|
| 6567 | + */ |
|
| 6568 | + protected function _tag_open_G($param) |
|
| 6569 | + { |
|
| 6570 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'G'); |
|
| 6571 | + |
|
| 6572 | + $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6573 | + $this->parsingCss->save(); |
|
| 6574 | + $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6575 | + $style = $this->pdf->svgSetStyle($styles); |
|
| 6576 | + } |
|
| 6577 | + |
|
| 6578 | + /** |
|
| 6579 | + * tag : G |
|
| 6580 | + * mode : CLOSE |
|
| 6581 | + * |
|
| 6582 | + * @param array $param |
|
| 6583 | + * @return boolean|null |
|
| 6584 | + */ |
|
| 6585 | + protected function _tag_close_G($param) |
|
| 6586 | + { |
|
| 6587 | + $this->pdf->undoTransform(); |
|
| 6588 | + $this->parsingCss->load(); |
|
| 6589 | + } |
|
| 6590 | + |
|
| 6591 | + /** |
|
| 6592 | + * new page for the automatic Index, does not use thie method. Only HTML2PDF_myPdf could use it !!!! |
|
| 6593 | + * |
|
| 6594 | + * @param &int $page |
|
| 6595 | + * @return integer $oldPage |
|
| 6596 | + */ |
|
| 6597 | + public function _INDEX_NewPage(&$page) |
|
| 6598 | + { |
|
| 6599 | + if ($page) { |
|
| 6600 | + $oldPage = $this->pdf->getPage(); |
|
| 6601 | + $this->pdf->setPage($page); |
|
| 6602 | + $this->pdf->setXY($this->_margeLeft, $this->_margeTop); |
|
| 6603 | + $this->_maxH = 0; |
|
| 6604 | + $page++; |
|
| 6605 | + return $oldPage; |
|
| 6606 | + } else { |
|
| 6607 | + $this->_setNewPage(); |
|
| 6608 | + return null; |
|
| 6609 | + } |
|
| 6610 | + } |
|
| 6611 | + |
|
| 6612 | + } |
|
| 6614 | 6613 | } |
@@ -162,7 +162,9 @@ discard block |
||
| 162 | 162 | $this->_subPart = false; |
| 163 | 163 | |
| 164 | 164 | // init the marges of the page |
| 165 | - if ( ! is_array($marges)) $marges = array($marges, $marges, $marges, $marges); |
|
| 165 | + if ( ! is_array($marges)) { |
|
| 166 | + $marges = array($marges, $marges, $marges, $marges); |
|
| 167 | + } |
|
| 166 | 168 | $this->_setDefaultMargins($marges[0], $marges[1], $marges[2], $marges[3]); |
| 167 | 169 | $this->_setMargins(); |
| 168 | 170 | $this->_marges = array(); |
@@ -357,14 +359,24 @@ discard block |
||
| 357 | 359 | } |
| 358 | 360 | |
| 359 | 361 | // complete parameters |
| 360 | - if ($dest === false) $dest = 'I'; |
|
| 361 | - if ($dest === true) $dest = 'S'; |
|
| 362 | - if ($dest === '') $dest = 'I'; |
|
| 363 | - if ($name == '') $name = 'document.pdf'; |
|
| 362 | + if ($dest === false) { |
|
| 363 | + $dest = 'I'; |
|
| 364 | + } |
|
| 365 | + if ($dest === true) { |
|
| 366 | + $dest = 'S'; |
|
| 367 | + } |
|
| 368 | + if ($dest === '') { |
|
| 369 | + $dest = 'I'; |
|
| 370 | + } |
|
| 371 | + if ($name == '') { |
|
| 372 | + $name = 'document.pdf'; |
|
| 373 | + } |
|
| 364 | 374 | |
| 365 | 375 | // clean up the destination |
| 366 | 376 | $dest = strtoupper($dest); |
| 367 | - if ( ! in_array($dest, array('I', 'D', 'F', 'S', 'FI', 'FD'))) $dest = 'I'; |
|
| 377 | + if ( ! in_array($dest, array('I', 'D', 'F', 'S', 'FI', 'FD'))) { |
|
| 378 | + $dest = 'I'; |
|
| 379 | + } |
|
| 368 | 380 | |
| 369 | 381 | // the name must be a PDF name |
| 370 | 382 | if (strtolower(substr($name, -4)) != '.pdf') { |
@@ -425,20 +437,24 @@ discard block |
||
| 425 | 437 | |
| 426 | 438 | // extract the content |
| 427 | 439 | $res = explode('<body', $html); |
| 428 | - if (count($res) < 2) return $html; |
|
| 440 | + if (count($res) < 2) { |
|
| 441 | + return $html; |
|
| 442 | + } |
|
| 429 | 443 | $content = '<page'.$res[1]; |
| 430 | 444 | $content = explode('</body', $content); |
| 431 | 445 | $content = $content[0].'</page>'; |
| 432 | 446 | |
| 433 | 447 | // extract the link tags |
| 434 | 448 | preg_match_all('/<link([^>]*)>/isU', $html, $match); |
| 435 | - foreach ($match[0] as $src) |
|
| 436 | - $content = $src.'</link>'.$content; |
|
| 449 | + foreach ($match[0] as $src) { |
|
| 450 | + $content = $src.'</link>'.$content; |
|
| 451 | + } |
|
| 437 | 452 | |
| 438 | 453 | // extract the css style tags |
| 439 | 454 | preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match); |
| 440 | - foreach ($match[0] as $src) |
|
| 441 | - $content = $src.$content; |
|
| 455 | + foreach ($match[0] as $src) { |
|
| 456 | + $content = $src.$content; |
|
| 457 | + } |
|
| 442 | 458 | |
| 443 | 459 | return $content; |
| 444 | 460 | } |
@@ -516,8 +532,12 @@ discard block |
||
| 516 | 532 | */ |
| 517 | 533 | protected function _setDefaultMargins($left, $top, $right = null, $bottom = null) |
| 518 | 534 | { |
| 519 | - if ($right === null) $right = $left; |
|
| 520 | - if ($bottom === null) $bottom = 8; |
|
| 535 | + if ($right === null) { |
|
| 536 | + $right = $left; |
|
| 537 | + } |
|
| 538 | + if ($bottom === null) { |
|
| 539 | + $bottom = 8; |
|
| 540 | + } |
|
| 521 | 541 | |
| 522 | 542 | $this->_defaultLeft = $this->parsingCss->ConvertToMM($left.'mm'); |
| 523 | 543 | $this->_defaultTop = $this->parsingCss->ConvertToMM($top.'mm'); |
@@ -621,7 +641,9 @@ discard block |
||
| 621 | 641 | protected function _DEBUG_add($name, $level = null) |
| 622 | 642 | { |
| 623 | 643 | // if true : UP |
| 624 | - if ($level === true) $this->_debugLevel++; |
|
| 644 | + if ($level === true) { |
|
| 645 | + $this->_debugLevel++; |
|
| 646 | + } |
|
| 625 | 647 | |
| 626 | 648 | $name = str_repeat(' ', $this->_debugLevel).$name.($level === true ? ' Begin' : ($level === false ? ' End' : '')); |
| 627 | 649 | $time = microtime(true); |
@@ -639,7 +661,9 @@ discard block |
||
| 639 | 661 | $this->_debugLastTime = $time; |
| 640 | 662 | |
| 641 | 663 | // it false : DOWN |
| 642 | - if ($level === false) $this->_debugLevel--; |
|
| 664 | + if ($level === false) { |
|
| 665 | + $this->_debugLevel--; |
|
| 666 | + } |
|
| 643 | 667 | |
| 644 | 668 | return $this; |
| 645 | 669 | } |
@@ -678,8 +702,9 @@ discard block |
||
| 678 | 702 | $y = floor($y * 100); |
| 679 | 703 | $x = array($this->pdf->getlMargin(), $this->pdf->getW() - $this->pdf->getrMargin()); |
| 680 | 704 | |
| 681 | - foreach ($this->_pageMarges as $mY => $mX) |
|
| 682 | - if ($mY <= $y) $x = $mX; |
|
| 705 | + foreach ($this->_pageMarges as $mY => $mX) { |
|
| 706 | + if ($mY <= $y) $x = $mX; |
|
| 707 | + } |
|
| 683 | 708 | |
| 684 | 709 | return $x; |
| 685 | 710 | } |
@@ -701,18 +726,30 @@ discard block |
||
| 701 | 726 | $oldBottom = $this->_getMargins($yBottom); |
| 702 | 727 | |
| 703 | 728 | // update the top float margin |
| 704 | - if ($float == 'left' && $oldTop[0] < $xRight) $oldTop[0] = $xRight; |
|
| 705 | - if ($float == 'right' && $oldTop[1] > $xLeft) $oldTop[1] = $xLeft; |
|
| 729 | + if ($float == 'left' && $oldTop[0] < $xRight) { |
|
| 730 | + $oldTop[0] = $xRight; |
|
| 731 | + } |
|
| 732 | + if ($float == 'right' && $oldTop[1] > $xLeft) { |
|
| 733 | + $oldTop[1] = $xLeft; |
|
| 734 | + } |
|
| 706 | 735 | |
| 707 | 736 | $yTop = floor($yTop * 100); |
| 708 | 737 | $yBottom = floor($yBottom * 100); |
| 709 | 738 | |
| 710 | 739 | // erase all the float margins that are smaller than the new one |
| 711 | 740 | foreach ($this->_pageMarges as $mY => $mX) { |
| 712 | - if ($mY < $yTop) continue; |
|
| 713 | - if ($mY > $yBottom) break; |
|
| 714 | - if ($float == 'left' && $this->_pageMarges[$mY][0] < $xRight) unset($this->_pageMarges[$mY]); |
|
| 715 | - if ($float == 'right' && $this->_pageMarges[$mY][1] > $xLeft) unset($this->_pageMarges[$mY]); |
|
| 741 | + if ($mY < $yTop) { |
|
| 742 | + continue; |
|
| 743 | + } |
|
| 744 | + if ($mY > $yBottom) { |
|
| 745 | + break; |
|
| 746 | + } |
|
| 747 | + if ($float == 'left' && $this->_pageMarges[$mY][0] < $xRight) { |
|
| 748 | + unset($this->_pageMarges[$mY]); |
|
| 749 | + } |
|
| 750 | + if ($float == 'right' && $this->_pageMarges[$mY][1] > $xLeft) { |
|
| 751 | + unset($this->_pageMarges[$mY]); |
|
| 752 | + } |
|
| 716 | 753 | } |
| 717 | 754 | |
| 718 | 755 | // save the new Top and Bottom margins |
@@ -810,7 +847,9 @@ discard block |
||
| 810 | 847 | */ |
| 811 | 848 | protected function _setPageHeader() |
| 812 | 849 | { |
| 813 | - if ( ! count($this->_subHEADER)) return false; |
|
| 850 | + if ( ! count($this->_subHEADER)) { |
|
| 851 | + return false; |
|
| 852 | + } |
|
| 814 | 853 | |
| 815 | 854 | $oldParsePos = $this->_parsePos; |
| 816 | 855 | $oldParseCode = $this->parsingHtml->code; |
@@ -830,7 +869,9 @@ discard block |
||
| 830 | 869 | */ |
| 831 | 870 | protected function _setPageFooter() |
| 832 | 871 | { |
| 833 | - if ( ! count($this->_subFOOTER)) return false; |
|
| 872 | + if ( ! count($this->_subFOOTER)) { |
|
| 873 | + return false; |
|
| 874 | + } |
|
| 834 | 875 | |
| 835 | 876 | $oldParsePos = $this->_parsePos; |
| 836 | 877 | $oldParseCode = $this->parsingHtml->code; |
@@ -891,15 +932,18 @@ discard block |
||
| 891 | 932 | $txt = $sub->parsingHtml->code[$this->_parsePos]['param']['txt']; |
| 892 | 933 | $txt = str_replace('[[page_cu]]', $sub->pdf->getMyNumPage($this->_page), $txt); |
| 893 | 934 | $sub->parsingHtml->code[$this->_parsePos]['param']['txt'] = substr($txt, $curr + 1); |
| 894 | - } else |
|
| 895 | - $sub->_parsePos++; |
|
| 935 | + } else { |
|
| 936 | + $sub->_parsePos++; |
|
| 937 | + } |
|
| 896 | 938 | |
| 897 | 939 | // for each element of the parsing => load the action |
| 898 | 940 | $res = null; |
| 899 | 941 | for ($sub->_parsePos; $sub->_parsePos < count($sub->parsingHtml->code); $sub->_parsePos++) { |
| 900 | 942 | $action = $sub->parsingHtml->code[$sub->_parsePos]; |
| 901 | 943 | $res = $sub->_executeAction($action); |
| 902 | - if ( ! $res) break; |
|
| 944 | + if ( ! $res) { |
|
| 945 | + break; |
|
| 946 | + } |
|
| 903 | 947 | } |
| 904 | 948 | |
| 905 | 949 | $w = $sub->_maxX; // max width |
@@ -910,12 +954,13 @@ discard block |
||
| 910 | 954 | $this->_destroySubHTML($sub); |
| 911 | 955 | |
| 912 | 956 | // adapt the start of the line, depending on the text-align |
| 913 | - if ($this->parsingCss->value['text-align'] == 'center') |
|
| 914 | - $this->pdf->setX(($rx + $this->pdf->getX() - $w) * 0.5 - 0.01); |
|
| 915 | - else if ($this->parsingCss->value['text-align'] == 'right') |
|
| 916 | - $this->pdf->setX($rx - $w - 0.01); |
|
| 917 | - else |
|
| 918 | - $this->pdf->setX($lx); |
|
| 957 | + if ($this->parsingCss->value['text-align'] == 'center') { |
|
| 958 | + $this->pdf->setX(($rx + $this->pdf->getX() - $w) * 0.5 - 0.01); |
|
| 959 | + } else if ($this->parsingCss->value['text-align'] == 'right') { |
|
| 960 | + $this->pdf->setX($rx - $w - 0.01); |
|
| 961 | + } else { |
|
| 962 | + $this->pdf->setX($lx); |
|
| 963 | + } |
|
| 919 | 964 | |
| 920 | 965 | // set the height of the line |
| 921 | 966 | $this->_currentH = $h; |
@@ -1028,8 +1073,12 @@ discard block |
||
| 1028 | 1073 | $nbBaseFive = array('V', 'L', 'D'); |
| 1029 | 1074 | $nbRoman = ''; |
| 1030 | 1075 | |
| 1031 | - if ($nbArabic < 1) return $nbArabic; |
|
| 1032 | - if ($nbArabic > 3999) return $nbArabic; |
|
| 1076 | + if ($nbArabic < 1) { |
|
| 1077 | + return $nbArabic; |
|
| 1078 | + } |
|
| 1079 | + if ($nbArabic > 3999) { |
|
| 1080 | + return $nbArabic; |
|
| 1081 | + } |
|
| 1033 | 1082 | |
| 1034 | 1083 | for ($i = 3; $i >= 0; $i--) { |
| 1035 | 1084 | $chiffre = floor($nbArabic / pow(10, $i)); |
@@ -1162,12 +1211,19 @@ discard block |
||
| 1162 | 1211 | } |
| 1163 | 1212 | |
| 1164 | 1213 | // prepare the datas |
| 1165 | - if ( ! in_array($type, array('ul', 'ol'))) $type = 'ul'; |
|
| 1166 | - if ( ! in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) $style = ''; |
|
| 1214 | + if ( ! in_array($type, array('ul', 'ol'))) { |
|
| 1215 | + $type = 'ul'; |
|
| 1216 | + } |
|
| 1217 | + if ( ! in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) { |
|
| 1218 | + $style = ''; |
|
| 1219 | + } |
|
| 1167 | 1220 | |
| 1168 | 1221 | if ( ! $style) { |
| 1169 | - if ($type == 'ul') $style = 'disc'; |
|
| 1170 | - else $style = 'decimal'; |
|
| 1222 | + if ($type == 'ul') { |
|
| 1223 | + $style = 'disc'; |
|
| 1224 | + } else { |
|
| 1225 | + $style = 'decimal'; |
|
| 1226 | + } |
|
| 1171 | 1227 | } |
| 1172 | 1228 | |
| 1173 | 1229 | // add the new level |
@@ -1276,8 +1332,9 @@ discard block |
||
| 1276 | 1332 | */ |
| 1277 | 1333 | protected function _getElementY($h) |
| 1278 | 1334 | { |
| 1279 | - if ($this->_subPart || $this->_isSubPart || ! $this->_currentH || $this->_currentH < $h) |
|
| 1280 | - return 0; |
|
| 1335 | + if ($this->_subPart || $this->_isSubPart || ! $this->_currentH || $this->_currentH < $h) { |
|
| 1336 | + return 0; |
|
| 1337 | + } |
|
| 1281 | 1338 | |
| 1282 | 1339 | return ($this->_currentH - $h) * 0.8; |
| 1283 | 1340 | } |
@@ -1292,10 +1349,11 @@ discard block |
||
| 1292 | 1349 | protected function _makeBreakLine($h, $curr = null) |
| 1293 | 1350 | { |
| 1294 | 1351 | if ($h) { |
| 1295 | - if (($this->pdf->getY() + $h < $this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter) |
|
| 1296 | - $this->_setNewLine($h, $curr); |
|
| 1297 | - else |
|
| 1298 | - $this->_setNewPage(null, '', null, $curr); |
|
| 1352 | + if (($this->pdf->getY() + $h < $this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter) { |
|
| 1353 | + $this->_setNewLine($h, $curr); |
|
| 1354 | + } else { |
|
| 1355 | + $this->_setNewPage(null, '', null, $curr); |
|
| 1356 | + } |
|
| 1299 | 1357 | } else { |
| 1300 | 1358 | $this->_setNewPositionForNewLine($curr); |
| 1301 | 1359 | } |
@@ -1419,7 +1477,9 @@ discard block |
||
| 1419 | 1477 | |
| 1420 | 1478 | // calculate the position of the image, if align to the right |
| 1421 | 1479 | if ($parentWidth > $w && $float != 'left') { |
| 1422 | - if ($float == 'right' || $this->parsingCss->value['text-align'] == 'li_right') $x = $parentX + $parentWidth - $w - $this->parsingCss->value['margin']['r'] - $this->parsingCss->value['margin']['l']; |
|
| 1480 | + if ($float == 'right' || $this->parsingCss->value['text-align'] == 'li_right') { |
|
| 1481 | + $x = $parentX + $parentWidth - $w - $this->parsingCss->value['margin']['r'] - $this->parsingCss->value['margin']['l']; |
|
| 1482 | + } |
|
| 1423 | 1483 | } |
| 1424 | 1484 | |
| 1425 | 1485 | // display the image |
@@ -1490,7 +1550,9 @@ discard block |
||
| 1490 | 1550 | protected function _drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background) |
| 1491 | 1551 | { |
| 1492 | 1552 | // if we are in a subpart or if height is null => return false |
| 1493 | - if ($this->_subPart || $this->_isSubPart || $h === null) return false; |
|
| 1553 | + if ($this->_subPart || $this->_isSubPart || $h === null) { |
|
| 1554 | + return false; |
|
| 1555 | + } |
|
| 1494 | 1556 | |
| 1495 | 1557 | // add the margin |
| 1496 | 1558 | $x += $margin; |
@@ -1533,10 +1595,18 @@ discard block |
||
| 1533 | 1595 | $inBL[1] -= $border['b']['width']; |
| 1534 | 1596 | } |
| 1535 | 1597 | |
| 1536 | - if ($inTL[0] <= 0 || $inTL[1] <= 0) $inTL = null; |
|
| 1537 | - if ($inTR[0] <= 0 || $inTR[1] <= 0) $inTR = null; |
|
| 1538 | - if ($inBR[0] <= 0 || $inBR[1] <= 0) $inBR = null; |
|
| 1539 | - if ($inBL[0] <= 0 || $inBL[1] <= 0) $inBL = null; |
|
| 1598 | + if ($inTL[0] <= 0 || $inTL[1] <= 0) { |
|
| 1599 | + $inTL = null; |
|
| 1600 | + } |
|
| 1601 | + if ($inTR[0] <= 0 || $inTR[1] <= 0) { |
|
| 1602 | + $inTR = null; |
|
| 1603 | + } |
|
| 1604 | + if ($inBR[0] <= 0 || $inBR[1] <= 0) { |
|
| 1605 | + $inBR = null; |
|
| 1606 | + } |
|
| 1607 | + if ($inBL[0] <= 0 || $inBL[1] <= 0) { |
|
| 1608 | + $inBL = null; |
|
| 1609 | + } |
|
| 1540 | 1610 | |
| 1541 | 1611 | // prepare the background color |
| 1542 | 1612 | $pdfStyle = ''; |
@@ -1594,13 +1664,21 @@ discard block |
||
| 1594 | 1664 | $imageHeight = 72. / 96. * $imageInfos[1] / $this->pdf->getK(); |
| 1595 | 1665 | |
| 1596 | 1666 | // prepare the position of the backgroung |
| 1597 | - if ($iRepeat[0]) $iPosition[0] = $bX; |
|
| 1598 | - else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1] * ($bW - $imageWidth) / 100; |
|
| 1599 | - else $iPosition[0] = $bX + $iPosition[0]; |
|
| 1667 | + if ($iRepeat[0]) { |
|
| 1668 | + $iPosition[0] = $bX; |
|
| 1669 | + } else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) { |
|
| 1670 | + $iPosition[0] = $bX + $match[1] * ($bW - $imageWidth) / 100; |
|
| 1671 | + } else { |
|
| 1672 | + $iPosition[0] = $bX + $iPosition[0]; |
|
| 1673 | + } |
|
| 1600 | 1674 | |
| 1601 | - if ($iRepeat[1]) $iPosition[1] = $bY; |
|
| 1602 | - else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1] * ($bH - $imageHeight) / 100; |
|
| 1603 | - else $iPosition[1] = $bY + $iPosition[1]; |
|
| 1675 | + if ($iRepeat[1]) { |
|
| 1676 | + $iPosition[1] = $bY; |
|
| 1677 | + } else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) { |
|
| 1678 | + $iPosition[1] = $bY + $match[1] * ($bH - $imageHeight) / 100; |
|
| 1679 | + } else { |
|
| 1680 | + $iPosition[1] = $bY + $iPosition[1]; |
|
| 1681 | + } |
|
| 1604 | 1682 | |
| 1605 | 1683 | $imageXmin = $bX; |
| 1606 | 1684 | $imageXmax = $bX + $bW; |
@@ -1652,10 +1730,18 @@ discard block |
||
| 1652 | 1730 | $y -= $loose; |
| 1653 | 1731 | $w += 2. * $loose; |
| 1654 | 1732 | $h += 2. * $loose; |
| 1655 | - if ($border['l']['width']) $border['l']['width'] += 2. * $loose; |
|
| 1656 | - if ($border['t']['width']) $border['t']['width'] += 2. * $loose; |
|
| 1657 | - if ($border['r']['width']) $border['r']['width'] += 2. * $loose; |
|
| 1658 | - if ($border['b']['width']) $border['b']['width'] += 2. * $loose; |
|
| 1733 | + if ($border['l']['width']) { |
|
| 1734 | + $border['l']['width'] += 2. * $loose; |
|
| 1735 | + } |
|
| 1736 | + if ($border['t']['width']) { |
|
| 1737 | + $border['t']['width'] += 2. * $loose; |
|
| 1738 | + } |
|
| 1739 | + if ($border['r']['width']) { |
|
| 1740 | + $border['r']['width'] += 2. * $loose; |
|
| 1741 | + } |
|
| 1742 | + if ($border['b']['width']) { |
|
| 1743 | + $border['b']['width'] += 2. * $loose; |
|
| 1744 | + } |
|
| 1659 | 1745 | |
| 1660 | 1746 | // prepare the test on borders |
| 1661 | 1747 | $testBl = ($border['l']['width'] && $border['l']['color'][0] !== null); |
@@ -1753,13 +1839,17 @@ discard block |
||
| 1753 | 1839 | if (is_array($outBL)) { |
| 1754 | 1840 | $bord -= 1; |
| 1755 | 1841 | $pt[3] -= $outBL[1] - $border['b']['width']; |
| 1756 | - if ($inBL) $pt[11] -= $inBL[1]; |
|
| 1842 | + if ($inBL) { |
|
| 1843 | + $pt[11] -= $inBL[1]; |
|
| 1844 | + } |
|
| 1757 | 1845 | unset($pt[0]); unset($pt[1]); |
| 1758 | 1846 | } |
| 1759 | 1847 | if (is_array($outTL)) { |
| 1760 | 1848 | $bord -= 2; |
| 1761 | 1849 | $pt[5] += $outTL[1] - $border['t']['width']; |
| 1762 | - if ($inTL) $pt[9] += $inTL[1]; |
|
| 1850 | + if ($inTL) { |
|
| 1851 | + $pt[9] += $inTL[1]; |
|
| 1852 | + } |
|
| 1763 | 1853 | unset($pt[6]); unset($pt[7]); |
| 1764 | 1854 | } |
| 1765 | 1855 | |
@@ -1781,13 +1871,17 @@ discard block |
||
| 1781 | 1871 | if (is_array($outTL)) { |
| 1782 | 1872 | $bord -= 1; |
| 1783 | 1873 | $pt[2] += $outTL[0] - $border['l']['width']; |
| 1784 | - if ($inTL) $pt[10] += $inTL[0]; |
|
| 1874 | + if ($inTL) { |
|
| 1875 | + $pt[10] += $inTL[0]; |
|
| 1876 | + } |
|
| 1785 | 1877 | unset($pt[0]); unset($pt[1]); |
| 1786 | 1878 | } |
| 1787 | 1879 | if (is_array($outTR)) { |
| 1788 | 1880 | $bord -= 2; |
| 1789 | 1881 | $pt[4] -= $outTR[0] - $border['r']['width']; |
| 1790 | - if ($inTR) $pt[8] -= $inTR[0]; |
|
| 1882 | + if ($inTR) { |
|
| 1883 | + $pt[8] -= $inTR[0]; |
|
| 1884 | + } |
|
| 1791 | 1885 | unset($pt[6]); unset($pt[7]); |
| 1792 | 1886 | } |
| 1793 | 1887 | |
@@ -1809,13 +1903,17 @@ discard block |
||
| 1809 | 1903 | if (is_array($outTR)) { |
| 1810 | 1904 | $bord -= 1; |
| 1811 | 1905 | $pt[3] += $outTR[1] - $border['t']['width']; |
| 1812 | - if ($inTR) $pt[11] += $inTR[1]; |
|
| 1906 | + if ($inTR) { |
|
| 1907 | + $pt[11] += $inTR[1]; |
|
| 1908 | + } |
|
| 1813 | 1909 | unset($pt[0]); unset($pt[1]); |
| 1814 | 1910 | } |
| 1815 | 1911 | if (is_array($outBR)) { |
| 1816 | 1912 | $bord -= 2; |
| 1817 | 1913 | $pt[5] -= $outBR[1] - $border['b']['width']; |
| 1818 | - if ($inBR) $pt[9] -= $inBR[1]; |
|
| 1914 | + if ($inBR) { |
|
| 1915 | + $pt[9] -= $inBR[1]; |
|
| 1916 | + } |
|
| 1819 | 1917 | unset($pt[6]); unset($pt[7]); |
| 1820 | 1918 | } |
| 1821 | 1919 | |
@@ -1837,13 +1935,17 @@ discard block |
||
| 1837 | 1935 | if (is_array($outBL)) { |
| 1838 | 1936 | $bord -= 2; |
| 1839 | 1937 | $pt[4] += $outBL[0] - $border['l']['width']; |
| 1840 | - if ($inBL) $pt[8] += $inBL[0]; |
|
| 1938 | + if ($inBL) { |
|
| 1939 | + $pt[8] += $inBL[0]; |
|
| 1940 | + } |
|
| 1841 | 1941 | unset($pt[6]); unset($pt[7]); |
| 1842 | 1942 | } |
| 1843 | 1943 | if (is_array($outBR)) { |
| 1844 | 1944 | $bord -= 1; |
| 1845 | 1945 | $pt[2] -= $outBR[0] - $border['r']['width']; |
| 1846 | - if ($inBR) $pt[10] -= $inBR[0]; |
|
| 1946 | + if ($inBR) { |
|
| 1947 | + $pt[10] -= $inBR[0]; |
|
| 1948 | + } |
|
| 1847 | 1949 | unset($pt[0]); unset($pt[1]); |
| 1848 | 1950 | |
| 1849 | 1951 | } |
@@ -1870,10 +1972,11 @@ discard block |
||
| 1870 | 1972 | { |
| 1871 | 1973 | $this->pdf->setFillColorArray($color); |
| 1872 | 1974 | |
| 1873 | - if (count($pt) == 10) |
|
| 1874 | - $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]); |
|
| 1875 | - else |
|
| 1876 | - $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]); |
|
| 1975 | + if (count($pt) == 10) { |
|
| 1976 | + $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]); |
|
| 1977 | + } else { |
|
| 1978 | + $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]); |
|
| 1979 | + } |
|
| 1877 | 1980 | } |
| 1878 | 1981 | |
| 1879 | 1982 | /** |
@@ -1944,10 +2047,18 @@ discard block |
||
| 1944 | 2047 | for ($i = 0; $l - ($px + $py) * ($i - 0.5) > 0; $i++) { |
| 1945 | 2048 | if (($i % 2) == $mode) { |
| 1946 | 2049 | $j = $i - 0.5; |
| 1947 | - $lx1 = $px * ($j); if ($lx1 < -$l) $lx1 = -$l; |
|
| 1948 | - $ly1 = $py * ($j); if ($ly1 < -$l) $ly1 = -$l; |
|
| 1949 | - $lx2 = $px * ($j + 1); if ($lx2 > $l) $lx2 = $l; |
|
| 1950 | - $ly2 = $py * ($j + 1); if ($ly2 > $l) $ly2 = $l; |
|
| 2050 | + $lx1 = $px * ($j); if ($lx1 < -$l) { |
|
| 2051 | + $lx1 = -$l; |
|
| 2052 | + } |
|
| 2053 | + $ly1 = $py * ($j); if ($ly1 < -$l) { |
|
| 2054 | + $ly1 = -$l; |
|
| 2055 | + } |
|
| 2056 | + $lx2 = $px * ($j + 1); if ($lx2 > $l) { |
|
| 2057 | + $lx2 = $l; |
|
| 2058 | + } |
|
| 2059 | + $ly2 = $py * ($j + 1); if ($ly2 > $l) { |
|
| 2060 | + $ly2 = $l; |
|
| 2061 | + } |
|
| 1951 | 2062 | |
| 1952 | 2063 | $tmp = array(); |
| 1953 | 2064 | $tmp[] = $x1 + $lx1; $tmp[] = $y1 + $ly1; |
@@ -2023,10 +2134,14 @@ discard block |
||
| 2023 | 2134 | protected function _prepareTransform($transform) |
| 2024 | 2135 | { |
| 2025 | 2136 | // it can not be empty |
| 2026 | - if ( ! $transform) return null; |
|
| 2137 | + if ( ! $transform) { |
|
| 2138 | + return null; |
|
| 2139 | + } |
|
| 2027 | 2140 | |
| 2028 | 2141 | // sctions must be like scale(...) |
| 2029 | - if ( ! preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null; |
|
| 2142 | + if ( ! preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) { |
|
| 2143 | + return null; |
|
| 2144 | + } |
|
| 2030 | 2145 | |
| 2031 | 2146 | // prepare the list of the actions |
| 2032 | 2147 | $actions = array(); |
@@ -2047,49 +2162,115 @@ discard block |
||
| 2047 | 2162 | switch ($name) |
| 2048 | 2163 | { |
| 2049 | 2164 | case 'scale': |
| 2050 | - if ( ! isset($val[0])) $val[0] = 1.; else $val[0] = 1. * $val[0]; |
|
| 2051 | - if ( ! isset($val[1])) $val[1] = $val[0]; else $val[1] = 1. * $val[1]; |
|
| 2165 | + if ( ! isset($val[0])) { |
|
| 2166 | + $val[0] = 1.; |
|
| 2167 | + } else { |
|
| 2168 | + $val[0] = 1. * $val[0]; |
|
| 2169 | + } |
|
| 2170 | + if ( ! isset($val[1])) { |
|
| 2171 | + $val[1] = $val[0]; |
|
| 2172 | + } else { |
|
| 2173 | + $val[1] = 1. * $val[1]; |
|
| 2174 | + } |
|
| 2052 | 2175 | $actions[] = array($val[0], 0, 0, $val[1], 0, 0); |
| 2053 | 2176 | break; |
| 2054 | 2177 | |
| 2055 | 2178 | case 'translate': |
| 2056 | - if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']); |
|
| 2057 | - if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']); |
|
| 2179 | + if ( ! isset($val[0])) { |
|
| 2180 | + $val[0] = 0.; |
|
| 2181 | + } else { |
|
| 2182 | + $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']); |
|
| 2183 | + } |
|
| 2184 | + if ( ! isset($val[1])) { |
|
| 2185 | + $val[1] = 0.; |
|
| 2186 | + } else { |
|
| 2187 | + $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']); |
|
| 2188 | + } |
|
| 2058 | 2189 | $actions[] = array(1, 0, 0, 1, $val[0], $val[1]); |
| 2059 | 2190 | break; |
| 2060 | 2191 | |
| 2061 | 2192 | case 'rotate': |
| 2062 | - if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2063 | - if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']); |
|
| 2064 | - if ( ! isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']); |
|
| 2065 | - if ($val[1] || $val[2]) $actions[] = array(1, 0, 0, 1, -$val[1], -$val[2]); |
|
| 2193 | + if ( ! isset($val[0])) { |
|
| 2194 | + $val[0] = 0.; |
|
| 2195 | + } else { |
|
| 2196 | + $val[0] = $val[0] * M_PI / 180.; |
|
| 2197 | + } |
|
| 2198 | + if ( ! isset($val[1])) { |
|
| 2199 | + $val[1] = 0.; |
|
| 2200 | + } else { |
|
| 2201 | + $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']); |
|
| 2202 | + } |
|
| 2203 | + if ( ! isset($val[2])) { |
|
| 2204 | + $val[2] = 0.; |
|
| 2205 | + } else { |
|
| 2206 | + $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']); |
|
| 2207 | + } |
|
| 2208 | + if ($val[1] || $val[2]) { |
|
| 2209 | + $actions[] = array(1, 0, 0, 1, -$val[1], -$val[2]); |
|
| 2210 | + } |
|
| 2066 | 2211 | $actions[] = array(cos($val[0]), sin($val[0]), -sin($val[0]), cos($val[0]), 0, 0); |
| 2067 | - if ($val[1] || $val[2]) $actions[] = array(1, 0, 0, 1, $val[1], $val[2]); |
|
| 2212 | + if ($val[1] || $val[2]) { |
|
| 2213 | + $actions[] = array(1, 0, 0, 1, $val[1], $val[2]); |
|
| 2214 | + } |
|
| 2068 | 2215 | break; |
| 2069 | 2216 | |
| 2070 | 2217 | case 'skewx': |
| 2071 | - if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2218 | + if ( ! isset($val[0])) { |
|
| 2219 | + $val[0] = 0.; |
|
| 2220 | + } else { |
|
| 2221 | + $val[0] = $val[0] * M_PI / 180.; |
|
| 2222 | + } |
|
| 2072 | 2223 | $actions[] = array(1, 0, tan($val[0]), 1, 0, 0); |
| 2073 | 2224 | break; |
| 2074 | 2225 | |
| 2075 | 2226 | case 'skewy': |
| 2076 | - if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2227 | + if ( ! isset($val[0])) { |
|
| 2228 | + $val[0] = 0.; |
|
| 2229 | + } else { |
|
| 2230 | + $val[0] = $val[0] * M_PI / 180.; |
|
| 2231 | + } |
|
| 2077 | 2232 | $actions[] = array(1, tan($val[0]), 0, 1, 0, 0); |
| 2078 | 2233 | break; |
| 2079 | 2234 | case 'matrix': |
| 2080 | - if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * 1.; |
|
| 2081 | - if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $val[1] * 1.; |
|
| 2082 | - if ( ! isset($val[2])) $val[2] = 0.; else $val[2] = $val[2] * 1.; |
|
| 2083 | - if ( ! isset($val[3])) $val[3] = 0.; else $val[3] = $val[3] * 1.; |
|
| 2084 | - if ( ! isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']); |
|
| 2085 | - if ( ! isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']); |
|
| 2235 | + if ( ! isset($val[0])) { |
|
| 2236 | + $val[0] = 0.; |
|
| 2237 | + } else { |
|
| 2238 | + $val[0] = $val[0] * 1.; |
|
| 2239 | + } |
|
| 2240 | + if ( ! isset($val[1])) { |
|
| 2241 | + $val[1] = 0.; |
|
| 2242 | + } else { |
|
| 2243 | + $val[1] = $val[1] * 1.; |
|
| 2244 | + } |
|
| 2245 | + if ( ! isset($val[2])) { |
|
| 2246 | + $val[2] = 0.; |
|
| 2247 | + } else { |
|
| 2248 | + $val[2] = $val[2] * 1.; |
|
| 2249 | + } |
|
| 2250 | + if ( ! isset($val[3])) { |
|
| 2251 | + $val[3] = 0.; |
|
| 2252 | + } else { |
|
| 2253 | + $val[3] = $val[3] * 1.; |
|
| 2254 | + } |
|
| 2255 | + if ( ! isset($val[4])) { |
|
| 2256 | + $val[4] = 0.; |
|
| 2257 | + } else { |
|
| 2258 | + $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']); |
|
| 2259 | + } |
|
| 2260 | + if ( ! isset($val[5])) { |
|
| 2261 | + $val[5] = 0.; |
|
| 2262 | + } else { |
|
| 2263 | + $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']); |
|
| 2264 | + } |
|
| 2086 | 2265 | $actions[] = $val; |
| 2087 | 2266 | break; |
| 2088 | 2267 | } |
| 2089 | 2268 | } |
| 2090 | 2269 | |
| 2091 | 2270 | // if ther is no actions => return |
| 2092 | - if ( ! $actions) return null; |
|
| 2271 | + if ( ! $actions) { |
|
| 2272 | + return null; |
|
| 2273 | + } |
|
| 2093 | 2274 | |
| 2094 | 2275 | // get the first matrix |
| 2095 | 2276 | $m = $actions[0]; unset($actions[0]); |
@@ -2117,7 +2298,9 @@ discard block |
||
| 2117 | 2298 | */ |
| 2118 | 2299 | protected function _calculateTableCellSize(&$cases, &$corr) |
| 2119 | 2300 | { |
| 2120 | - if ( ! isset($corr[0])) return true; |
|
| 2301 | + if ( ! isset($corr[0])) { |
|
| 2302 | + return true; |
|
| 2303 | + } |
|
| 2121 | 2304 | |
| 2122 | 2305 | // for each cell without colspan, we get the max width for each column |
| 2123 | 2306 | $sw = array(); |
@@ -2137,7 +2320,9 @@ discard block |
||
| 2137 | 2320 | if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2] > 1) { |
| 2138 | 2321 | |
| 2139 | 2322 | // sum the max width of each column in colspan |
| 2140 | - $s = 0; for ($i = 0; $i < $corr[$y][$x][2]; $i++) $s += $sw[$x + $i]; |
|
| 2323 | + $s = 0; for ($i = 0; $i < $corr[$y][$x][2]; $i++) { |
|
| 2324 | + $s += $sw[$x + $i]; |
|
| 2325 | + } |
|
| 2141 | 2326 | |
| 2142 | 2327 | // if the max width is < the width of the cell with colspan => we adapt the width of each max width |
| 2143 | 2328 | if ($s > 0 && $s < $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) { |
@@ -2186,7 +2371,9 @@ discard block |
||
| 2186 | 2371 | if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3] > 1) { |
| 2187 | 2372 | |
| 2188 | 2373 | // sum the max height of each line in rowspan |
| 2189 | - $s = 0; for ($i = 0; $i < $corr[$y][$x][3]; $i++) $s += $sh[$y + $i]; |
|
| 2374 | + $s = 0; for ($i = 0; $i < $corr[$y][$x][3]; $i++) { |
|
| 2375 | + $s += $sh[$y + $i]; |
|
| 2376 | + } |
|
| 2190 | 2377 | |
| 2191 | 2378 | // if the max height is < the height of the cell with rowspan => we adapt the height of each max height |
| 2192 | 2379 | if ($s > 0 && $s < $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) { |
@@ -2236,8 +2423,12 @@ discard block |
||
| 2236 | 2423 | */ |
| 2237 | 2424 | protected function _tag_open_PAGE($param) |
| 2238 | 2425 | { |
| 2239 | - if ($this->_isForOneLine) return false; |
|
| 2240 | - if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page + 1), true); |
|
| 2426 | + if ($this->_isForOneLine) { |
|
| 2427 | + return false; |
|
| 2428 | + } |
|
| 2429 | + if ($this->_debugActif) { |
|
| 2430 | + $this->_DEBUG_add('PAGE '.($this->_page + 1), true); |
|
| 2431 | + } |
|
| 2241 | 2432 | |
| 2242 | 2433 | $newPageSet = ( ! isset($param['pageset']) || $param['pageset'] != 'old'); |
| 2243 | 2434 | |
@@ -2254,12 +2445,22 @@ discard block |
||
| 2254 | 2445 | $orientation = ''; |
| 2255 | 2446 | if (isset($param['orientation'])) { |
| 2256 | 2447 | $param['orientation'] = strtolower($param['orientation']); |
| 2257 | - if ($param['orientation'] == 'p') $orientation = 'P'; |
|
| 2258 | - if ($param['orientation'] == 'portrait') $orientation = 'P'; |
|
| 2448 | + if ($param['orientation'] == 'p') { |
|
| 2449 | + $orientation = 'P'; |
|
| 2450 | + } |
|
| 2451 | + if ($param['orientation'] == 'portrait') { |
|
| 2452 | + $orientation = 'P'; |
|
| 2453 | + } |
|
| 2259 | 2454 | |
| 2260 | - if ($param['orientation'] == 'l') $orientation = 'L'; |
|
| 2261 | - if ($param['orientation'] == 'paysage') $orientation = 'L'; |
|
| 2262 | - if ($param['orientation'] == 'landscape') $orientation = 'L'; |
|
| 2455 | + if ($param['orientation'] == 'l') { |
|
| 2456 | + $orientation = 'L'; |
|
| 2457 | + } |
|
| 2458 | + if ($param['orientation'] == 'paysage') { |
|
| 2459 | + $orientation = 'L'; |
|
| 2460 | + } |
|
| 2461 | + if ($param['orientation'] == 'landscape') { |
|
| 2462 | + $orientation = 'L'; |
|
| 2463 | + } |
|
| 2263 | 2464 | } |
| 2264 | 2465 | |
| 2265 | 2466 | // format |
@@ -2283,12 +2484,24 @@ discard block |
||
| 2283 | 2484 | $background['img'] = str_replace('&', '&', $background['img']); |
| 2284 | 2485 | |
| 2285 | 2486 | // convert the positions |
| 2286 | - if ($background['posX'] == 'left') $background['posX'] = '0%'; |
|
| 2287 | - if ($background['posX'] == 'center') $background['posX'] = '50%'; |
|
| 2288 | - if ($background['posX'] == 'right') $background['posX'] = '100%'; |
|
| 2289 | - if ($background['posY'] == 'top') $background['posY'] = '0%'; |
|
| 2290 | - if ($background['posY'] == 'middle') $background['posY'] = '50%'; |
|
| 2291 | - if ($background['posY'] == 'bottom') $background['posY'] = '100%'; |
|
| 2487 | + if ($background['posX'] == 'left') { |
|
| 2488 | + $background['posX'] = '0%'; |
|
| 2489 | + } |
|
| 2490 | + if ($background['posX'] == 'center') { |
|
| 2491 | + $background['posX'] = '50%'; |
|
| 2492 | + } |
|
| 2493 | + if ($background['posX'] == 'right') { |
|
| 2494 | + $background['posX'] = '100%'; |
|
| 2495 | + } |
|
| 2496 | + if ($background['posY'] == 'top') { |
|
| 2497 | + $background['posY'] = '0%'; |
|
| 2498 | + } |
|
| 2499 | + if ($background['posY'] == 'middle') { |
|
| 2500 | + $background['posY'] = '50%'; |
|
| 2501 | + } |
|
| 2502 | + if ($background['posY'] == 'bottom') { |
|
| 2503 | + $background['posY'] = '100%'; |
|
| 2504 | + } |
|
| 2292 | 2505 | |
| 2293 | 2506 | if ($background['img']) { |
| 2294 | 2507 | // get the size of the image |
@@ -2338,7 +2551,9 @@ discard block |
||
| 2338 | 2551 | // get the background color |
| 2339 | 2552 | $res = false; |
| 2340 | 2553 | $background['color'] = isset($param['backcolor']) ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null; |
| 2341 | - if ( ! $res) $background['color'] = null; |
|
| 2554 | + if ( ! $res) { |
|
| 2555 | + $background['color'] = null; |
|
| 2556 | + } |
|
| 2342 | 2557 | |
| 2343 | 2558 | $this->parsingCss->save(); |
| 2344 | 2559 | $this->parsingCss->analyse('PAGE', $param); |
@@ -2412,14 +2627,20 @@ discard block |
||
| 2412 | 2627 | */ |
| 2413 | 2628 | protected function _tag_open_PAGE_HEADER($param) |
| 2414 | 2629 | { |
| 2415 | - if ($this->_isForOneLine) return false; |
|
| 2630 | + if ($this->_isForOneLine) { |
|
| 2631 | + return false; |
|
| 2632 | + } |
|
| 2416 | 2633 | |
| 2417 | 2634 | $this->_subHEADER = array(); |
| 2418 | 2635 | for ($this->_parsePos; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) { |
| 2419 | 2636 | $action = $this->parsingHtml->code[$this->_parsePos]; |
| 2420 | - if ($action['name'] == 'page_header') $action['name'] = 'page_header_sub'; |
|
| 2637 | + if ($action['name'] == 'page_header') { |
|
| 2638 | + $action['name'] = 'page_header_sub'; |
|
| 2639 | + } |
|
| 2421 | 2640 | $this->_subHEADER[] = $action; |
| 2422 | - if (strtolower($action['name']) == 'page_header_sub' && $action['close']) break; |
|
| 2641 | + if (strtolower($action['name']) == 'page_header_sub' && $action['close']) { |
|
| 2642 | + break; |
|
| 2643 | + } |
|
| 2423 | 2644 | } |
| 2424 | 2645 | |
| 2425 | 2646 | $this->_setPageHeader(); |
@@ -2436,14 +2657,20 @@ discard block |
||
| 2436 | 2657 | */ |
| 2437 | 2658 | protected function _tag_open_PAGE_FOOTER($param) |
| 2438 | 2659 | { |
| 2439 | - if ($this->_isForOneLine) return false; |
|
| 2660 | + if ($this->_isForOneLine) { |
|
| 2661 | + return false; |
|
| 2662 | + } |
|
| 2440 | 2663 | |
| 2441 | 2664 | $this->_subFOOTER = array(); |
| 2442 | 2665 | for ($this->_parsePos; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) { |
| 2443 | 2666 | $action = $this->parsingHtml->code[$this->_parsePos]; |
| 2444 | - if ($action['name'] == 'page_footer') $action['name'] = 'page_footer_sub'; |
|
| 2667 | + if ($action['name'] == 'page_footer') { |
|
| 2668 | + $action['name'] = 'page_footer_sub'; |
|
| 2669 | + } |
|
| 2445 | 2670 | $this->_subFOOTER[] = $action; |
| 2446 | - if (strtolower($action['name']) == 'page_footer_sub' && $action['close']) break; |
|
| 2671 | + if (strtolower($action['name']) == 'page_footer_sub' && $action['close']) { |
|
| 2672 | + break; |
|
| 2673 | + } |
|
| 2447 | 2674 | } |
| 2448 | 2675 | |
| 2449 | 2676 | $this->_setPageFooter(); |
@@ -2796,22 +3023,27 @@ discard block |
||
| 2796 | 3023 | if ( |
| 2797 | 3024 | $w < ($this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin()) && |
| 2798 | 3025 | $this->pdf->getX() + $w >= ($this->pdf->getW() - $this->pdf->getrMargin()) |
| 2799 | - ) |
|
| 2800 | - $this->_tag_open_BR(array()); |
|
| 3026 | + ) { |
|
| 3027 | + $this->_tag_open_BR(array()); |
|
| 3028 | + } |
|
| 2801 | 3029 | |
| 2802 | 3030 | if ( |
| 2803 | 3031 | ($h < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin())) && |
| 2804 | 3032 | ($this->pdf->getY() + $h >= ($this->pdf->getH() - $this->pdf->getbMargin())) && |
| 2805 | 3033 | ! $this->_isInOverflow |
| 2806 | - ) |
|
| 2807 | - $this->_setNewPage(); |
|
| 3034 | + ) { |
|
| 3035 | + $this->_setNewPage(); |
|
| 3036 | + } |
|
| 2808 | 3037 | |
| 2809 | 3038 | $old = $this->parsingCss->getOldValues(); |
| 2810 | 3039 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 2811 | 3040 | |
| 2812 | 3041 | if ($parentWidth > $w) { |
| 2813 | - if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 2814 | - else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 3042 | + if ($alignObject == 'center') { |
|
| 3043 | + $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 3044 | + } else if ($alignObject == 'right') { |
|
| 3045 | + $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 3046 | + } |
|
| 2815 | 3047 | } |
| 2816 | 3048 | |
| 2817 | 3049 | $this->parsingCss->setPosition(); |
@@ -2820,8 +3052,11 @@ discard block |
||
| 2820 | 3052 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 2821 | 3053 | |
| 2822 | 3054 | if ($parentWidth > $w) { |
| 2823 | - if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 2824 | - else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 3055 | + if ($alignObject == 'center') { |
|
| 3056 | + $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 3057 | + } else if ($alignObject == 'right') { |
|
| 3058 | + $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 3059 | + } |
|
| 2825 | 3060 | } |
| 2826 | 3061 | |
| 2827 | 3062 | $this->parsingCss->setPosition(); |
@@ -2870,7 +3105,9 @@ discard block |
||
| 2870 | 3105 | $xCorr = ($this->parsingCss->value['width'] - $wReel) * 0.5; |
| 2871 | 3106 | break; |
| 2872 | 3107 | } |
| 2873 | - if ($xCorr > 0) $xCorr = 0; |
|
| 3108 | + if ($xCorr > 0) { |
|
| 3109 | + $xCorr = 0; |
|
| 3110 | + } |
|
| 2874 | 3111 | switch ($this->parsingCss->value['vertical-align']) |
| 2875 | 3112 | { |
| 2876 | 3113 | case 'bottom': |
@@ -2954,7 +3191,9 @@ discard block |
||
| 2954 | 3191 | // get height of LEGEND element and make fieldset corrections |
| 2955 | 3192 | for ($tempPos = $this->_parsePos + 1; $tempPos < count($this->parsingHtml->code); $tempPos++) { |
| 2956 | 3193 | $action = $this->parsingHtml->code[$tempPos]; |
| 2957 | - if ($action['name'] == 'fieldset') break; |
|
| 3194 | + if ($action['name'] == 'fieldset') { |
|
| 3195 | + break; |
|
| 3196 | + } |
|
| 2958 | 3197 | if ($action['name'] == 'legend' && ! $action['close']) { |
| 2959 | 3198 | $legendOpenPos = $tempPos; |
| 2960 | 3199 | |
@@ -3120,16 +3359,27 @@ discard block |
||
| 3120 | 3359 | $lstBarcode['UPC_A'] = 'UPCA'; |
| 3121 | 3360 | $lstBarcode['CODE39'] = 'C39'; |
| 3122 | 3361 | |
| 3123 | - if ( ! isset($param['type'])) $param['type'] = 'C39'; |
|
| 3124 | - if ( ! isset($param['value'])) $param['value'] = 0; |
|
| 3125 | - if ( ! isset($param['label'])) $param['label'] = 'label'; |
|
| 3126 | - if ( ! isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3362 | + if ( ! isset($param['type'])) { |
|
| 3363 | + $param['type'] = 'C39'; |
|
| 3364 | + } |
|
| 3365 | + if ( ! isset($param['value'])) { |
|
| 3366 | + $param['value'] = 0; |
|
| 3367 | + } |
|
| 3368 | + if ( ! isset($param['label'])) { |
|
| 3369 | + $param['label'] = 'label'; |
|
| 3370 | + } |
|
| 3371 | + if ( ! isset($param['style']['color'])) { |
|
| 3372 | + $param['style']['color'] = '#000000'; |
|
| 3373 | + } |
|
| 3127 | 3374 | |
| 3128 | - if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w']))) |
|
| 3129 | - throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w')); |
|
| 3375 | + if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w']))) { |
|
| 3376 | + throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w')); |
|
| 3377 | + } |
|
| 3130 | 3378 | |
| 3131 | 3379 | $param['type'] = strtoupper($param['type']); |
| 3132 | - if (isset($lstBarcode[$param['type']])) $param['type'] = $lstBarcode[$param['type']]; |
|
| 3380 | + if (isset($lstBarcode[$param['type']])) { |
|
| 3381 | + $param['type'] = $lstBarcode[$param['type']]; |
|
| 3382 | + } |
|
| 3133 | 3383 | |
| 3134 | 3384 | $this->parsingCss->save(); |
| 3135 | 3385 | $this->parsingCss->analyse('barcode', $param); |
@@ -3138,8 +3388,12 @@ discard block |
||
| 3138 | 3388 | |
| 3139 | 3389 | $x = $this->pdf->getX(); |
| 3140 | 3390 | $y = $this->pdf->getY(); |
| 3141 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3142 | - $h = $this->parsingCss->value['height']; if ( ! $h) $h = $this->parsingCss->ConvertToMM('10mm'); |
|
| 3391 | + $w = $this->parsingCss->value['width']; if ( ! $w) { |
|
| 3392 | + $w = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3393 | + } |
|
| 3394 | + $h = $this->parsingCss->value['height']; if ( ! $h) { |
|
| 3395 | + $h = $this->parsingCss->ConvertToMM('10mm'); |
|
| 3396 | + } |
|
| 3143 | 3397 | $txt = ($param['label'] !== 'none' ? $this->parsingCss->value['font-size'] : false); |
| 3144 | 3398 | $c = $this->parsingCss->value['color']; |
| 3145 | 3399 | $infos = $this->pdf->myBarcode($param['value'], $param['type'], $x, $y, $w, $h, $txt, $c); |
@@ -3180,15 +3434,26 @@ discard block |
||
| 3180 | 3434 | */ |
| 3181 | 3435 | protected function _tag_open_QRCODE($param) |
| 3182 | 3436 | { |
| 3183 | - if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder']))) |
|
| 3184 | - throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder')); |
|
| 3437 | + if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder']))) { |
|
| 3438 | + throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder')); |
|
| 3439 | + } |
|
| 3185 | 3440 | |
| 3186 | - if ($this->_debugActif) $this->_DEBUG_add('QRCODE'); |
|
| 3441 | + if ($this->_debugActif) { |
|
| 3442 | + $this->_DEBUG_add('QRCODE'); |
|
| 3443 | + } |
|
| 3187 | 3444 | |
| 3188 | - if ( ! isset($param['value'])) $param['value'] = ''; |
|
| 3189 | - if ( ! isset($param['ec'])) $param['ec'] = 'H'; |
|
| 3190 | - if ( ! isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3191 | - if ( ! isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF'; |
|
| 3445 | + if ( ! isset($param['value'])) { |
|
| 3446 | + $param['value'] = ''; |
|
| 3447 | + } |
|
| 3448 | + if ( ! isset($param['ec'])) { |
|
| 3449 | + $param['ec'] = 'H'; |
|
| 3450 | + } |
|
| 3451 | + if ( ! isset($param['style']['color'])) { |
|
| 3452 | + $param['style']['color'] = '#000000'; |
|
| 3453 | + } |
|
| 3454 | + if ( ! isset($param['style']['background-color'])) { |
|
| 3455 | + $param['style']['background-color'] = '#FFFFFF'; |
|
| 3456 | + } |
|
| 3192 | 3457 | if (isset($param['style']['border'])) { |
| 3193 | 3458 | $borders = $param['style']['border'] != 'none'; |
| 3194 | 3459 | unset($param['style']['border']); |
@@ -3196,8 +3461,12 @@ discard block |
||
| 3196 | 3461 | $borders = true; |
| 3197 | 3462 | } |
| 3198 | 3463 | |
| 3199 | - if ($param['value'] === '') return true; |
|
| 3200 | - if ( ! in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H'; |
|
| 3464 | + if ($param['value'] === '') { |
|
| 3465 | + return true; |
|
| 3466 | + } |
|
| 3467 | + if ( ! in_array($param['ec'], array('L', 'M', 'Q', 'H'))) { |
|
| 3468 | + $param['ec'] = 'H'; |
|
| 3469 | + } |
|
| 3201 | 3470 | |
| 3202 | 3471 | $this->parsingCss->save(); |
| 3203 | 3472 | $this->parsingCss->analyse('qrcode', $param); |
@@ -3208,7 +3477,9 @@ discard block |
||
| 3208 | 3477 | $y = $this->pdf->getY(); |
| 3209 | 3478 | $w = $this->parsingCss->value['width']; |
| 3210 | 3479 | $h = $this->parsingCss->value['height']; |
| 3211 | - $size = max($w, $h); if ( ! $size) $size = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3480 | + $size = max($w, $h); if ( ! $size) { |
|
| 3481 | + $size = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3482 | + } |
|
| 3212 | 3483 | |
| 3213 | 3484 | $style = array( |
| 3214 | 3485 | 'fgcolor' => $this->parsingCss->value['color'], |
@@ -3266,8 +3537,12 @@ discard block |
||
| 3266 | 3537 | $titre = isset($param['title']) ? trim($param['title']) : ''; |
| 3267 | 3538 | $level = isset($param['level']) ? floor($param['level']) : 0; |
| 3268 | 3539 | |
| 3269 | - if ($level < 0) $level = 0; |
|
| 3270 | - if ($titre) $this->pdf->Bookmark($titre, $level, -1); |
|
| 3540 | + if ($level < 0) { |
|
| 3541 | + $level = 0; |
|
| 3542 | + } |
|
| 3543 | + if ($titre) { |
|
| 3544 | + $this->pdf->Bookmark($titre, $level, -1); |
|
| 3545 | + } |
|
| 3271 | 3546 | |
| 3272 | 3547 | return true; |
| 3273 | 3548 | } |
@@ -3311,12 +3586,13 @@ discard block |
||
| 3311 | 3586 | $txt = str_replace('[[page_cu]]', $this->pdf->getMyNumPage($this->_page), $txt); |
| 3312 | 3587 | |
| 3313 | 3588 | if ($this->parsingCss->value['text-transform'] != 'none') { |
| 3314 | - if ($this->parsingCss->value['text-transform'] == 'capitalize') |
|
| 3315 | - $txt = ucwords($txt); |
|
| 3316 | - else if ($this->parsingCss->value['text-transform'] == 'uppercase') |
|
| 3317 | - $txt = strtoupper($txt); |
|
| 3318 | - else if ($this->parsingCss->value['text-transform'] == 'lowercase') |
|
| 3319 | - $txt = strtolower($txt); |
|
| 3589 | + if ($this->parsingCss->value['text-transform'] == 'capitalize') { |
|
| 3590 | + $txt = ucwords($txt); |
|
| 3591 | + } else if ($this->parsingCss->value['text-transform'] == 'uppercase') { |
|
| 3592 | + $txt = strtoupper($txt); |
|
| 3593 | + } else if ($this->parsingCss->value['text-transform'] == 'lowercase') { |
|
| 3594 | + $txt = strtolower($txt); |
|
| 3595 | + } |
|
| 3320 | 3596 | } |
| 3321 | 3597 | |
| 3322 | 3598 | // size of the text |
@@ -3372,7 +3648,9 @@ discard block |
||
| 3372 | 3648 | array_shift($words); |
| 3373 | 3649 | $old = $str; |
| 3374 | 3650 | |
| 3375 | - if ( ! count($words)) break; |
|
| 3651 | + if ( ! count($words)) { |
|
| 3652 | + break; |
|
| 3653 | + } |
|
| 3376 | 3654 | $str[0] .= ' '.$words[0][0]; |
| 3377 | 3655 | $str[1] += $space + $words[0][1]; |
| 3378 | 3656 | } |
@@ -3389,7 +3667,9 @@ discard block |
||
| 3389 | 3667 | |
| 3390 | 3668 | // write the extract sentence that fit on the page |
| 3391 | 3669 | $wc = ($align == 'L' ? $str[1] : $this->parsingCss->value['width']); |
| 3392 | - if ($right - $left < $wc) $wc = $right - $left; |
|
| 3670 | + if ($right - $left < $wc) { |
|
| 3671 | + $wc = $right - $left; |
|
| 3672 | + } |
|
| 3393 | 3673 | |
| 3394 | 3674 | if (strlen($str[0])) { |
| 3395 | 3675 | $this->pdf->setXY($this->pdf->getX(), $y + $dh + $dy); |
@@ -3410,7 +3690,9 @@ discard block |
||
| 3410 | 3690 | // if we have again words to write |
| 3411 | 3691 | if (count($words)) { |
| 3412 | 3692 | // remove the space at the end |
| 3413 | - if ($add) $w -= $space; |
|
| 3693 | + if ($add) { |
|
| 3694 | + $w -= $space; |
|
| 3695 | + } |
|
| 3414 | 3696 | |
| 3415 | 3697 | // if we don't add any word, and if the first word is empty => useless space to skip |
| 3416 | 3698 | if ( ! $add && $words[0][0] === '') { |
@@ -3445,7 +3727,9 @@ discard block |
||
| 3445 | 3727 | // if more than 10000 line => error |
| 3446 | 3728 | $nb++; |
| 3447 | 3729 | if ($nb > 10000) { |
| 3448 | - $txt = ''; foreach ($words as $k => $word) $txt .= ($k ? ' ' : '').$word[0]; |
|
| 3730 | + $txt = ''; foreach ($words as $k => $word) { |
|
| 3731 | + $txt .= ($k ? ' ' : '').$word[0]; |
|
| 3732 | + } |
|
| 3449 | 3733 | throw new HTML2PDF_exception(2, array($txt, $right - $left, $w)); |
| 3450 | 3734 | } |
| 3451 | 3735 | |
@@ -3456,7 +3740,9 @@ discard block |
||
| 3456 | 3740 | |
| 3457 | 3741 | // if we have words after automatic cut, it is because they fit on the line => we write the text |
| 3458 | 3742 | if (count($words)) { |
| 3459 | - $txt = ''; foreach ($words as $k => $word) $txt .= ($k ? ' ' : '').$word[0]; |
|
| 3743 | + $txt = ''; foreach ($words as $k => $word) { |
|
| 3744 | + $txt .= ($k ? ' ' : '').$word[0]; |
|
| 3745 | + } |
|
| 3460 | 3746 | $w += $this->pdf->getWordSpacing() * (count($words)); |
| 3461 | 3747 | $this->pdf->setXY($this->pdf->getX(), $y + $dh + $dy); |
| 3462 | 3748 | $this->pdf->Cell(($align == 'L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink); |
@@ -3484,11 +3770,15 @@ discard block |
||
| 3484 | 3770 | */ |
| 3485 | 3771 | protected function _tag_open_BR($param, $curr = null) |
| 3486 | 3772 | { |
| 3487 | - if ($this->_isForOneLine) return false; |
|
| 3773 | + if ($this->_isForOneLine) { |
|
| 3774 | + return false; |
|
| 3775 | + } |
|
| 3488 | 3776 | |
| 3489 | 3777 | $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
| 3490 | 3778 | |
| 3491 | - if ($this->_maxH == 0) $this->_maxY = max($this->_maxY, $this->pdf->getY() + $h); |
|
| 3779 | + if ($this->_maxH == 0) { |
|
| 3780 | + $this->_maxY = max($this->_maxY, $this->pdf->getY() + $h); |
|
| 3781 | + } |
|
| 3492 | 3782 | |
| 3493 | 3783 | $this->_makeBreakLine($h, $curr); |
| 3494 | 3784 | |
@@ -3531,8 +3821,12 @@ discard block |
||
| 3531 | 3821 | $this->parsingCss->fontSet(); |
| 3532 | 3822 | |
| 3533 | 3823 | $h = $this->parsingCss->value['height']; |
| 3534 | - if ($h) $h -= $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width']; |
|
| 3535 | - if ($h <= 0) $h = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width']; |
|
| 3824 | + if ($h) { |
|
| 3825 | + $h -= $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width']; |
|
| 3826 | + } |
|
| 3827 | + if ($h <= 0) { |
|
| 3828 | + $h = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width']; |
|
| 3829 | + } |
|
| 3536 | 3830 | |
| 3537 | 3831 | $this->_drawRectangle($this->pdf->getX(), $this->pdf->getY(), $this->parsingCss->value['width'], $h, $this->parsingCss->value['border'], 0, 0, $this->parsingCss->value['background']); |
| 3538 | 3832 | $this->_maxH = $h; |
@@ -3868,7 +4162,9 @@ discard block |
||
| 3868 | 4162 | |
| 3869 | 4163 | if (isset($param['name'])) { |
| 3870 | 4164 | $name = $param['name']; |
| 3871 | - if ( ! isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 4165 | + if ( ! isset($this->_lstAnchor[$name])) { |
|
| 4166 | + $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 4167 | + } |
|
| 3872 | 4168 | |
| 3873 | 4169 | if ( ! $this->_lstAnchor[$name][1]) { |
| 3874 | 4170 | $this->_lstAnchor[$name][1] = true; |
@@ -3878,7 +4174,9 @@ discard block |
||
| 3878 | 4174 | |
| 3879 | 4175 | if (preg_match('/^#([^#]+)$/isU', $this->_isInLink, $match)) { |
| 3880 | 4176 | $name = $match[1]; |
| 3881 | - if ( ! isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 4177 | + if ( ! isset($this->_lstAnchor[$name])) { |
|
| 4178 | + $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 4179 | + } |
|
| 3882 | 4180 | |
| 3883 | 4181 | $this->_isInLink = $this->_lstAnchor[$name][0]; |
| 3884 | 4182 | } |
@@ -4182,10 +4480,14 @@ discard block |
||
| 4182 | 4480 | */ |
| 4183 | 4481 | protected function _tag_open_P($param) |
| 4184 | 4482 | { |
| 4185 | - if ($this->_isForOneLine) return false; |
|
| 4483 | + if ($this->_isForOneLine) { |
|
| 4484 | + return false; |
|
| 4485 | + } |
|
| 4186 | 4486 | |
| 4187 | 4487 | if ( ! in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
| 4188 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4488 | + if ($this->_maxH) { |
|
| 4489 | + $this->_tag_open_BR(array()); |
|
| 4490 | + } |
|
| 4189 | 4491 | } |
| 4190 | 4492 | |
| 4191 | 4493 | $this->parsingCss->save(); |
@@ -4250,7 +4552,9 @@ discard block |
||
| 4250 | 4552 | */ |
| 4251 | 4553 | protected function _tag_open_PRE($param, $other = 'pre') |
| 4252 | 4554 | { |
| 4253 | - if ($other == 'pre' && $this->_maxH) $this->_tag_open_BR(array()); |
|
| 4555 | + if ($other == 'pre' && $this->_maxH) { |
|
| 4556 | + $this->_tag_open_BR(array()); |
|
| 4557 | + } |
|
| 4254 | 4558 | |
| 4255 | 4559 | $this->parsingCss->save(); |
| 4256 | 4560 | $this->parsingCss->value['font-family'] = 'courier'; |
@@ -4258,7 +4562,9 @@ discard block |
||
| 4258 | 4562 | $this->parsingCss->setPosition(); |
| 4259 | 4563 | $this->parsingCss->fontSet(); |
| 4260 | 4564 | |
| 4261 | - if ($other == 'pre') return $this->_tag_open_DIV($param, $other); |
|
| 4565 | + if ($other == 'pre') { |
|
| 4566 | + return $this->_tag_open_DIV($param, $other); |
|
| 4567 | + } |
|
| 4262 | 4568 | |
| 4263 | 4569 | return true; |
| 4264 | 4570 | } |
@@ -4286,7 +4592,9 @@ discard block |
||
| 4286 | 4592 | protected function _tag_close_PRE($param, $other = 'pre') |
| 4287 | 4593 | { |
| 4288 | 4594 | if ($other == 'pre') { |
| 4289 | - if ($this->_isForOneLine) return false; |
|
| 4595 | + if ($this->_isForOneLine) { |
|
| 4596 | + return false; |
|
| 4597 | + } |
|
| 4290 | 4598 | |
| 4291 | 4599 | $this->_tag_close_DIV($param, $other); |
| 4292 | 4600 | $this->_tag_open_BR(array()); |
@@ -4452,14 +4760,22 @@ discard block |
||
| 4452 | 4760 | */ |
| 4453 | 4761 | protected function _tag_open_UL($param, $other = 'ul') |
| 4454 | 4762 | { |
| 4455 | - if ($this->_isForOneLine) return false; |
|
| 4763 | + if ($this->_isForOneLine) { |
|
| 4764 | + return false; |
|
| 4765 | + } |
|
| 4456 | 4766 | |
| 4457 | 4767 | if ( ! in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
| 4458 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4459 | - if ( ! count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4768 | + if ($this->_maxH) { |
|
| 4769 | + $this->_tag_open_BR(array()); |
|
| 4770 | + } |
|
| 4771 | + if ( ! count($this->_defList)) { |
|
| 4772 | + $this->_tag_open_BR(array()); |
|
| 4773 | + } |
|
| 4460 | 4774 | } |
| 4461 | 4775 | |
| 4462 | - if ( ! isset($param['style']['width'])) $param['allwidth'] = true; |
|
| 4776 | + if ( ! isset($param['style']['width'])) { |
|
| 4777 | + $param['allwidth'] = true; |
|
| 4778 | + } |
|
| 4463 | 4779 | $param['cellspacing'] = 0; |
| 4464 | 4780 | |
| 4465 | 4781 | // a list is like a table |
@@ -4492,14 +4808,18 @@ discard block |
||
| 4492 | 4808 | */ |
| 4493 | 4809 | protected function _tag_close_UL($param) |
| 4494 | 4810 | { |
| 4495 | - if ($this->_isForOneLine) return false; |
|
| 4811 | + if ($this->_isForOneLine) { |
|
| 4812 | + return false; |
|
| 4813 | + } |
|
| 4496 | 4814 | |
| 4497 | 4815 | $this->_tag_close_TABLE($param); |
| 4498 | 4816 | |
| 4499 | 4817 | $this->_listeDelLevel(); |
| 4500 | 4818 | |
| 4501 | 4819 | if ( ! $this->_subPart) { |
| 4502 | - if ( ! count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4820 | + if ( ! count($this->_defList)) { |
|
| 4821 | + $this->_tag_open_BR(array()); |
|
| 4822 | + } |
|
| 4503 | 4823 | } |
| 4504 | 4824 | |
| 4505 | 4825 | return true; |
@@ -4526,11 +4846,15 @@ discard block |
||
| 4526 | 4846 | */ |
| 4527 | 4847 | protected function _tag_open_LI($param) |
| 4528 | 4848 | { |
| 4529 | - if ($this->_isForOneLine) return false; |
|
| 4849 | + if ($this->_isForOneLine) { |
|
| 4850 | + return false; |
|
| 4851 | + } |
|
| 4530 | 4852 | |
| 4531 | 4853 | $this->_listeAddLi(); |
| 4532 | 4854 | |
| 4533 | - if ( ! isset($param['style']['width'])) $param['style']['width'] = '100%'; |
|
| 4855 | + if ( ! isset($param['style']['width'])) { |
|
| 4856 | + $param['style']['width'] = '100%'; |
|
| 4857 | + } |
|
| 4534 | 4858 | |
| 4535 | 4859 | $paramPUCE = $param; |
| 4536 | 4860 | |
@@ -4684,9 +5008,13 @@ discard block |
||
| 4684 | 5008 | HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); |
| 4685 | 5009 | for ($pos = $this->_tempPos; $pos < count($this->parsingHtml->code); $pos++) { |
| 4686 | 5010 | $action = $this->parsingHtml->code[$pos]; |
| 4687 | - if (strtolower($action['name']) == 'thead') $action['name'] = 'thead_sub'; |
|
| 5011 | + if (strtolower($action['name']) == 'thead') { |
|
| 5012 | + $action['name'] = 'thead_sub'; |
|
| 5013 | + } |
|
| 4688 | 5014 | HTML2PDF::$_tables[$param['num']]['thead']['code'][] = $action; |
| 4689 | - if (strtolower($action['name']) == 'thead_sub' && $action['close']) break; |
|
| 5015 | + if (strtolower($action['name']) == 'thead_sub' && $action['close']) { |
|
| 5016 | + break; |
|
| 5017 | + } |
|
| 4690 | 5018 | } |
| 4691 | 5019 | } else { |
| 4692 | 5020 | $level = $this->parsingHtml->getLevel($this->_parsePos); |
@@ -4747,9 +5075,13 @@ discard block |
||
| 4747 | 5075 | HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); |
| 4748 | 5076 | for ($pos = $this->_tempPos; $pos < count($this->parsingHtml->code); $pos++) { |
| 4749 | 5077 | $action = $this->parsingHtml->code[$pos]; |
| 4750 | - if (strtolower($action['name']) == 'tfoot') $action['name'] = 'tfoot_sub'; |
|
| 5078 | + if (strtolower($action['name']) == 'tfoot') { |
|
| 5079 | + $action['name'] = 'tfoot_sub'; |
|
| 5080 | + } |
|
| 4751 | 5081 | HTML2PDF::$_tables[$param['num']]['tfoot']['code'][] = $action; |
| 4752 | - if (strtolower($action['name']) == 'tfoot_sub' && $action['close']) break; |
|
| 5082 | + if (strtolower($action['name']) == 'tfoot_sub' && $action['close']) { |
|
| 5083 | + break; |
|
| 5084 | + } |
|
| 4753 | 5085 | } |
| 4754 | 5086 | } else { |
| 4755 | 5087 | $level = $this->parsingHtml->getLevel($this->_parsePos); |
@@ -4930,15 +5262,21 @@ discard block |
||
| 4930 | 5262 | $this->_maxH = 0; |
| 4931 | 5263 | |
| 4932 | 5264 | $alignObject = isset($param['align']) ? strtolower($param['align']) : 'left'; |
| 4933 | - if (isset($param['align'])) unset($param['align']); |
|
| 4934 | - if ( ! in_array($alignObject, array('left', 'center', 'right'))) $alignObject = 'left'; |
|
| 5265 | + if (isset($param['align'])) { |
|
| 5266 | + unset($param['align']); |
|
| 5267 | + } |
|
| 5268 | + if ( ! in_array($alignObject, array('left', 'center', 'right'))) { |
|
| 5269 | + $alignObject = 'left'; |
|
| 5270 | + } |
|
| 4935 | 5271 | |
| 4936 | 5272 | $this->parsingCss->save(); |
| 4937 | 5273 | $this->parsingCss->analyse($other, $param); |
| 4938 | 5274 | $this->parsingCss->setPosition(); |
| 4939 | 5275 | $this->parsingCss->fontSet(); |
| 4940 | 5276 | |
| 4941 | - if ($this->parsingCss->value['margin-auto']) $alignObject = 'center'; |
|
| 5277 | + if ($this->parsingCss->value['margin-auto']) { |
|
| 5278 | + $alignObject = 'center'; |
|
| 5279 | + } |
|
| 4942 | 5280 | |
| 4943 | 5281 | // collapse table ? |
| 4944 | 5282 | $collapse = false; |
@@ -5051,9 +5389,10 @@ discard block |
||
| 5051 | 5389 | foreach (HTML2PDF::$_tables[$param['num']][$mode]['tr'] as $tr) { |
| 5052 | 5390 | // hauteur de la ligne tr |
| 5053 | 5391 | $h = 0; |
| 5054 | - for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++) |
|
| 5055 | - if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan'] == 1) |
|
| 5392 | + for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++) { |
|
| 5393 | + if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan'] == 1) |
|
| 5056 | 5394 | $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['h']); |
| 5395 | + } |
|
| 5057 | 5396 | HTML2PDF::$_tables[$param['num']][$mode]['height'] += $h; |
| 5058 | 5397 | } |
| 5059 | 5398 | } |
@@ -5072,10 +5411,11 @@ discard block |
||
| 5072 | 5411 | $x = HTML2PDF::$_tables[$param['num']]['curr_x']; |
| 5073 | 5412 | $w = HTML2PDF::$_tables[$param['num']]['width']; |
| 5074 | 5413 | if ($parentWidth > $w) { |
| 5075 | - if (HTML2PDF::$_tables[$param['num']]['align'] == 'center') |
|
| 5076 | - $x = $x + ($parentWidth - $w) * 0.5; |
|
| 5077 | - else if (HTML2PDF::$_tables[$param['num']]['align'] == 'right') |
|
| 5078 | - $x = $x + $parentWidth - $w; |
|
| 5414 | + if (HTML2PDF::$_tables[$param['num']]['align'] == 'center') { |
|
| 5415 | + $x = $x + ($parentWidth - $w) * 0.5; |
|
| 5416 | + } else if (HTML2PDF::$_tables[$param['num']]['align'] == 'right') { |
|
| 5417 | + $x = $x + $parentWidth - $w; |
|
| 5418 | + } |
|
| 5079 | 5419 | |
| 5080 | 5420 | HTML2PDF::$_tables[$param['num']]['curr_x'] = $x; |
| 5081 | 5421 | } |
@@ -5111,13 +5451,16 @@ discard block |
||
| 5111 | 5451 | for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) { |
| 5112 | 5452 | $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
| 5113 | 5453 | |
| 5114 | - if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan'] == 1) |
|
| 5115 | - $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
|
| 5454 | + if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan'] == 1) { |
|
| 5455 | + $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
|
| 5456 | + } |
|
| 5116 | 5457 | } |
| 5117 | 5458 | |
| 5118 | 5459 | // if the row does not fit on the page => new page |
| 5119 | 5460 | if ($y + $h + $height > $max) { |
| 5120 | - if ($height == $h0) $height = null; |
|
| 5461 | + if ($height == $h0) { |
|
| 5462 | + $height = null; |
|
| 5463 | + } |
|
| 5121 | 5464 | HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
| 5122 | 5465 | $height = $h0; |
| 5123 | 5466 | $y = $this->_margeTop; |
@@ -5126,7 +5469,9 @@ discard block |
||
| 5126 | 5469 | } |
| 5127 | 5470 | |
| 5128 | 5471 | // if ther is a height at the end, add it |
| 5129 | - if ($height != $h0 || $k == 0) HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5472 | + if ($height != $h0 || $k == 0) { |
|
| 5473 | + HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5474 | + } |
|
| 5130 | 5475 | } else { |
| 5131 | 5476 | // if we have tfoor, draw it |
| 5132 | 5477 | if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) { |
@@ -5151,12 +5496,13 @@ discard block |
||
| 5151 | 5496 | |
| 5152 | 5497 | // get the positions of the end of the table |
| 5153 | 5498 | $x = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['width']; |
| 5154 | - if (count(HTML2PDF::$_tables[$param['num']]['height']) > 1) |
|
| 5155 | - $y = $this->_margeTop + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1]; |
|
| 5156 | - else if (count(HTML2PDF::$_tables[$param['num']]['height']) == 1) |
|
| 5157 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y'] + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1]; |
|
| 5158 | - else |
|
| 5159 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5499 | + if (count(HTML2PDF::$_tables[$param['num']]['height']) > 1) { |
|
| 5500 | + $y = $this->_margeTop + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1]; |
|
| 5501 | + } else if (count(HTML2PDF::$_tables[$param['num']]['height']) == 1) { |
|
| 5502 | + $y = HTML2PDF::$_tables[$param['num']]['curr_y'] + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1]; |
|
| 5503 | + } else { |
|
| 5504 | + $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5505 | + } |
|
| 5160 | 5506 | |
| 5161 | 5507 | $this->_maxX = max($this->_maxX, $x); |
| 5162 | 5508 | $this->_maxY = max($this->_maxY, $y); |
@@ -5187,8 +5533,9 @@ discard block |
||
| 5187 | 5533 | protected function _tag_open_COL($param) |
| 5188 | 5534 | { |
| 5189 | 5535 | $span = isset($param['span']) ? $param['span'] : 1; |
| 5190 | - for ($k = 0; $k < $span; $k++) |
|
| 5191 | - HTML2PDF::$_tables[$param['num']]['cols'][] = $param; |
|
| 5536 | + for ($k = 0; $k < $span; $k++) { |
|
| 5537 | + HTML2PDF::$_tables[$param['num']]['cols'][] = $param; |
|
| 5538 | + } |
|
| 5192 | 5539 | } |
| 5193 | 5540 | |
| 5194 | 5541 | /** |
@@ -5320,12 +5667,14 @@ discard block |
||
| 5320 | 5667 | } else { |
| 5321 | 5668 | // prepare it |
| 5322 | 5669 | HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1] = array(); |
| 5323 | - if ( ! isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']])) |
|
| 5324 | - HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array(); |
|
| 5670 | + if ( ! isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']])) { |
|
| 5671 | + HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array(); |
|
| 5672 | + } |
|
| 5325 | 5673 | |
| 5326 | 5674 | HTML2PDF::$_tables[$param['num']]['corr_x'] = 0; |
| 5327 | - while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) |
|
| 5328 | - HTML2PDF::$_tables[$param['num']]['corr_x']++; |
|
| 5675 | + while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) { |
|
| 5676 | + HTML2PDF::$_tables[$param['num']]['corr_x']++; |
|
| 5677 | + } |
|
| 5329 | 5678 | } |
| 5330 | 5679 | |
| 5331 | 5680 | return true; |
@@ -5437,10 +5786,11 @@ discard block |
||
| 5437 | 5786 | if (count($colParam['style']['width'])) { |
| 5438 | 5787 | $total = $colParam['style']['width'][0]; unset($colParam['style']['width'][0]); |
| 5439 | 5788 | foreach ($colParam['style']['width'] as $width) { |
| 5440 | - if (substr($total, -1) == '%' && substr($width, -1) == '%') |
|
| 5441 | - $total = (str_replace('%', '', $total) + str_replace('%', '', $width)).'%'; |
|
| 5442 | - else |
|
| 5443 | - $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm'; |
|
| 5789 | + if (substr($total, -1) == '%' && substr($width, -1) == '%') { |
|
| 5790 | + $total = (str_replace('%', '', $total) + str_replace('%', '', $width)).'%'; |
|
| 5791 | + } else { |
|
| 5792 | + $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm'; |
|
| 5793 | + } |
|
| 5444 | 5794 | } |
| 5445 | 5795 | } |
| 5446 | 5796 | |
@@ -5505,7 +5855,9 @@ discard block |
||
| 5505 | 5855 | } |
| 5506 | 5856 | |
| 5507 | 5857 | if (HTML2PDF::$_tables[$param['num']]['td_curr'] > 0) { |
| 5508 | - if ( ! $return) $this->parsingCss->value['width'] += $this->parsingCss->value['border']['l']['width']; |
|
| 5858 | + if ( ! $return) { |
|
| 5859 | + $this->parsingCss->value['width'] += $this->parsingCss->value['border']['l']['width']; |
|
| 5860 | + } |
|
| 5509 | 5861 | $this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none'); |
| 5510 | 5862 | } |
| 5511 | 5863 | } |
@@ -5729,7 +6081,9 @@ discard block |
||
| 5729 | 6081 | $this->parsingCss->fontSet(); |
| 5730 | 6082 | |
| 5731 | 6083 | $res = $this->_drawImage($src, isset($param['sub_li'])); |
| 5732 | - if ( ! $res) return $res; |
|
| 6084 | + if ( ! $res) { |
|
| 6085 | + return $res; |
|
| 6086 | + } |
|
| 5733 | 6087 | |
| 5734 | 6088 | $this->parsingCss->load(); |
| 5735 | 6089 | $this->parsingCss->fontSet(); |
@@ -5770,7 +6124,9 @@ discard block |
||
| 5770 | 6124 | $this->_lstSelect['size'] = isset($param['size']) ? $param['size'] : 1; |
| 5771 | 6125 | $this->_lstSelect['options'] = array(); |
| 5772 | 6126 | |
| 5773 | - if ($this->_lstSelect['multi'] && $this->_lstSelect['size'] < 3) $this->_lstSelect['size'] = 3; |
|
| 6127 | + if ($this->_lstSelect['multi'] && $this->_lstSelect['size'] < 3) { |
|
| 6128 | + $this->_lstSelect['size'] = 3; |
|
| 6129 | + } |
|
| 5774 | 6130 | |
| 5775 | 6131 | return true; |
| 5776 | 6132 | } |
@@ -5822,7 +6178,9 @@ discard block |
||
| 5822 | 6178 | $f = 1.08 * $this->parsingCss->value['font-size']; |
| 5823 | 6179 | |
| 5824 | 6180 | // width |
| 5825 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = 50; |
|
| 6181 | + $w = $this->parsingCss->value['width']; if ( ! $w) { |
|
| 6182 | + $w = 50; |
|
| 6183 | + } |
|
| 5826 | 6184 | |
| 5827 | 6185 | // height (automatic) |
| 5828 | 6186 | $h = ($f * 1.07 * $this->_lstSelect['size'] + 1); |
@@ -5934,9 +6292,15 @@ discard block |
||
| 5934 | 6292 | */ |
| 5935 | 6293 | protected function _tag_open_INPUT($param) |
| 5936 | 6294 | { |
| 5937 | - if ( ! isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 5938 | - if ( ! isset($param['value'])) $param['value'] = ''; |
|
| 5939 | - if ( ! isset($param['type'])) $param['type'] = 'text'; |
|
| 6295 | + if ( ! isset($param['name'])) { |
|
| 6296 | + $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 6297 | + } |
|
| 6298 | + if ( ! isset($param['value'])) { |
|
| 6299 | + $param['value'] = ''; |
|
| 6300 | + } |
|
| 6301 | + if ( ! isset($param['type'])) { |
|
| 6302 | + $param['type'] = 'text'; |
|
| 6303 | + } |
|
| 5940 | 6304 | |
| 5941 | 6305 | $param['name'] = strtolower($param['name']); |
| 5942 | 6306 | $param['type'] = strtolower($param['type']); |
@@ -5970,7 +6334,9 @@ discard block |
||
| 5970 | 6334 | case 'checkbox': |
| 5971 | 6335 | $w = 3; |
| 5972 | 6336 | $h = $w; |
| 5973 | - if ($h < $f) $y += ($f - $h) * 0.5; |
|
| 6337 | + if ($h < $f) { |
|
| 6338 | + $y += ($f - $h) * 0.5; |
|
| 6339 | + } |
|
| 5974 | 6340 | $checked = (isset($param['checked']) && $param['checked'] == 'checked'); |
| 5975 | 6341 | $this->pdf->CheckBox($name, $w, $checked, $prop, array(), ($param['value'] ? $param['value'] : 'Yes'), $x, $y); |
| 5976 | 6342 | break; |
@@ -5978,7 +6344,9 @@ discard block |
||
| 5978 | 6344 | case 'radio': |
| 5979 | 6345 | $w = 3; |
| 5980 | 6346 | $h = $w; |
| 5981 | - if ($h < $f) $y += ($f - $h) * 0.5; |
|
| 6347 | + if ($h < $f) { |
|
| 6348 | + $y += ($f - $h) * 0.5; |
|
| 6349 | + } |
|
| 5982 | 6350 | $checked = (isset($param['checked']) && $param['checked'] == 'checked'); |
| 5983 | 6351 | $this->pdf->RadioButton($name, $w, $prop, array(), ($param['value'] ? $param['value'] : 'On'), $checked, $x, $y); |
| 5984 | 6352 | break; |
@@ -5991,29 +6359,43 @@ discard block |
||
| 5991 | 6359 | break; |
| 5992 | 6360 | |
| 5993 | 6361 | case 'text': |
| 5994 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 6362 | + $w = $this->parsingCss->value['width']; if ( ! $w) { |
|
| 6363 | + $w = 40; |
|
| 6364 | + } |
|
| 5995 | 6365 | $h = $f * 1.3; |
| 5996 | 6366 | $prop['value'] = $param['value']; |
| 5997 | 6367 | $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y); |
| 5998 | 6368 | break; |
| 5999 | 6369 | |
| 6000 | 6370 | case 'submit': |
| 6001 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 6002 | - $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 6371 | + $w = $this->parsingCss->value['width']; if ( ! $w) { |
|
| 6372 | + $w = 40; |
|
| 6373 | + } |
|
| 6374 | + $h = $this->parsingCss->value['height']; if ( ! $h) { |
|
| 6375 | + $h = $f * 1.3; |
|
| 6376 | + } |
|
| 6003 | 6377 | $action = array('S'=>'SubmitForm', 'F'=>$this->_isInForm, 'Flags'=>array('ExportFormat')); |
| 6004 | 6378 | $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
| 6005 | 6379 | break; |
| 6006 | 6380 | |
| 6007 | 6381 | case 'reset': |
| 6008 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 6009 | - $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 6382 | + $w = $this->parsingCss->value['width']; if ( ! $w) { |
|
| 6383 | + $w = 40; |
|
| 6384 | + } |
|
| 6385 | + $h = $this->parsingCss->value['height']; if ( ! $h) { |
|
| 6386 | + $h = $f * 1.3; |
|
| 6387 | + } |
|
| 6010 | 6388 | $action = array('S'=>'ResetForm'); |
| 6011 | 6389 | $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
| 6012 | 6390 | break; |
| 6013 | 6391 | |
| 6014 | 6392 | case 'button': |
| 6015 | - $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 6016 | - $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 6393 | + $w = $this->parsingCss->value['width']; if ( ! $w) { |
|
| 6394 | + $w = 40; |
|
| 6395 | + } |
|
| 6396 | + $h = $this->parsingCss->value['height']; if ( ! $h) { |
|
| 6397 | + $h = $f * 1.3; |
|
| 6398 | + } |
|
| 6017 | 6399 | $action = isset($param['onclick']) ? $param['onclick'] : ''; |
| 6018 | 6400 | $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
| 6019 | 6401 | break; |
@@ -6074,22 +6456,27 @@ discard block |
||
| 6074 | 6456 | if ( |
| 6075 | 6457 | $w < ($this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin()) && |
| 6076 | 6458 | $this->pdf->getX() + $w >= ($this->pdf->getW() - $this->pdf->getrMargin()) |
| 6077 | - ) |
|
| 6078 | - $this->_tag_open_BR(array()); |
|
| 6459 | + ) { |
|
| 6460 | + $this->_tag_open_BR(array()); |
|
| 6461 | + } |
|
| 6079 | 6462 | |
| 6080 | 6463 | if ( |
| 6081 | 6464 | ($h < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin())) && |
| 6082 | 6465 | ($this->pdf->getY() + $h >= ($this->pdf->getH() - $this->pdf->getbMargin())) && |
| 6083 | 6466 | ! $this->_isInOverflow |
| 6084 | - ) |
|
| 6085 | - $this->_setNewPage(); |
|
| 6467 | + ) { |
|
| 6468 | + $this->_setNewPage(); |
|
| 6469 | + } |
|
| 6086 | 6470 | |
| 6087 | 6471 | $old = $this->parsingCss->getOldValues(); |
| 6088 | 6472 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 6089 | 6473 | |
| 6090 | 6474 | if ($parentWidth > $w) { |
| 6091 | - if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 6092 | - else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 6475 | + if ($alignObject == 'center') { |
|
| 6476 | + $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 6477 | + } else if ($alignObject == 'right') { |
|
| 6478 | + $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 6479 | + } |
|
| 6093 | 6480 | } |
| 6094 | 6481 | |
| 6095 | 6482 | $this->parsingCss->setPosition(); |
@@ -6098,8 +6485,11 @@ discard block |
||
| 6098 | 6485 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 6099 | 6486 | |
| 6100 | 6487 | if ($parentWidth > $w) { |
| 6101 | - if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 6102 | - else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 6488 | + if ($alignObject == 'center') { |
|
| 6489 | + $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 6490 | + } else if ($alignObject == 'right') { |
|
| 6491 | + $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 6492 | + } |
|
| 6103 | 6493 | } |
| 6104 | 6494 | |
| 6105 | 6495 | $this->parsingCss->setPosition(); |
@@ -6240,7 +6630,9 @@ discard block |
||
| 6240 | 6630 | */ |
| 6241 | 6631 | protected function _tag_open_LINE($param) |
| 6242 | 6632 | { |
| 6243 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'LINE'); |
|
| 6633 | + if ( ! $this->_isInDraw) { |
|
| 6634 | + throw new HTML2PDF_exception(8, 'LINE'); |
|
| 6635 | + } |
|
| 6244 | 6636 | |
| 6245 | 6637 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6246 | 6638 | $this->parsingCss->save(); |
@@ -6267,7 +6659,9 @@ discard block |
||
| 6267 | 6659 | */ |
| 6268 | 6660 | protected function _tag_open_RECT($param) |
| 6269 | 6661 | { |
| 6270 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'RECT'); |
|
| 6662 | + if ( ! $this->_isInDraw) { |
|
| 6663 | + throw new HTML2PDF_exception(8, 'RECT'); |
|
| 6664 | + } |
|
| 6271 | 6665 | |
| 6272 | 6666 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6273 | 6667 | $this->parsingCss->save(); |
@@ -6294,7 +6688,9 @@ discard block |
||
| 6294 | 6688 | */ |
| 6295 | 6689 | protected function _tag_open_CIRCLE($param) |
| 6296 | 6690 | { |
| 6297 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'CIRCLE'); |
|
| 6691 | + if ( ! $this->_isInDraw) { |
|
| 6692 | + throw new HTML2PDF_exception(8, 'CIRCLE'); |
|
| 6693 | + } |
|
| 6298 | 6694 | |
| 6299 | 6695 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6300 | 6696 | $this->parsingCss->save(); |
@@ -6319,7 +6715,9 @@ discard block |
||
| 6319 | 6715 | */ |
| 6320 | 6716 | protected function _tag_open_ELLIPSE($param) |
| 6321 | 6717 | { |
| 6322 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'ELLIPSE'); |
|
| 6718 | + if ( ! $this->_isInDraw) { |
|
| 6719 | + throw new HTML2PDF_exception(8, 'ELLIPSE'); |
|
| 6720 | + } |
|
| 6323 | 6721 | |
| 6324 | 6722 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6325 | 6723 | $this->parsingCss->save(); |
@@ -6346,7 +6744,9 @@ discard block |
||
| 6346 | 6744 | */ |
| 6347 | 6745 | protected function _tag_open_POLYLINE($param) |
| 6348 | 6746 | { |
| 6349 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6747 | + if ( ! $this->_isInDraw) { |
|
| 6748 | + throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6749 | + } |
|
| 6350 | 6750 | |
| 6351 | 6751 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6352 | 6752 | $this->parsingCss->save(); |
@@ -6362,7 +6762,9 @@ discard block |
||
| 6362 | 6762 | $path = explode(' ', $path); |
| 6363 | 6763 | foreach ($path as $k => $v) { |
| 6364 | 6764 | $path[$k] = trim($v); |
| 6365 | - if ($path[$k] === '') unset($path[$k]); |
|
| 6765 | + if ($path[$k] === '') { |
|
| 6766 | + unset($path[$k]); |
|
| 6767 | + } |
|
| 6366 | 6768 | } |
| 6367 | 6769 | $path = array_values($path); |
| 6368 | 6770 | |
@@ -6392,7 +6794,9 @@ discard block |
||
| 6392 | 6794 | */ |
| 6393 | 6795 | protected function _tag_open_POLYGON($param) |
| 6394 | 6796 | { |
| 6395 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6797 | + if ( ! $this->_isInDraw) { |
|
| 6798 | + throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6799 | + } |
|
| 6396 | 6800 | |
| 6397 | 6801 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6398 | 6802 | $this->parsingCss->save(); |
@@ -6408,7 +6812,9 @@ discard block |
||
| 6408 | 6812 | $path = explode(' ', $path); |
| 6409 | 6813 | foreach ($path as $k => $v) { |
| 6410 | 6814 | $path[$k] = trim($v); |
| 6411 | - if ($path[$k] === '') unset($path[$k]); |
|
| 6815 | + if ($path[$k] === '') { |
|
| 6816 | + unset($path[$k]); |
|
| 6817 | + } |
|
| 6412 | 6818 | } |
| 6413 | 6819 | $path = array_values($path); |
| 6414 | 6820 | |
@@ -6439,7 +6845,9 @@ discard block |
||
| 6439 | 6845 | */ |
| 6440 | 6846 | protected function _tag_open_PATH($param) |
| 6441 | 6847 | { |
| 6442 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'PATH'); |
|
| 6848 | + if ( ! $this->_isInDraw) { |
|
| 6849 | + throw new HTML2PDF_exception(8, 'PATH'); |
|
| 6850 | + } |
|
| 6443 | 6851 | |
| 6444 | 6852 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6445 | 6853 | $this->parsingCss->save(); |
@@ -6459,7 +6867,9 @@ discard block |
||
| 6459 | 6867 | $path = explode(' ', $path); |
| 6460 | 6868 | foreach ($path as $k => $v) { |
| 6461 | 6869 | $path[$k] = trim($v); |
| 6462 | - if ($path[$k] === '') unset($path[$k]); |
|
| 6870 | + if ($path[$k] === '') { |
|
| 6871 | + unset($path[$k]); |
|
| 6872 | + } |
|
| 6463 | 6873 | } |
| 6464 | 6874 | $path = array_values($path); |
| 6465 | 6875 | |
@@ -6568,7 +6978,9 @@ discard block |
||
| 6568 | 6978 | */ |
| 6569 | 6979 | protected function _tag_open_G($param) |
| 6570 | 6980 | { |
| 6571 | - if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'G'); |
|
| 6981 | + if ( ! $this->_isInDraw) { |
|
| 6982 | + throw new HTML2PDF_exception(8, 'G'); |
|
| 6983 | + } |
|
| 6572 | 6984 | |
| 6573 | 6985 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6574 | 6986 | $this->parsingCss->save(); |
@@ -131,63 +131,63 @@ discard block |
||
| 131 | 131 | <li> |
| 132 | 132 | |
| 133 | 133 | <?php |
| 134 | - $acc_info=$this->session->userdata('accountinfo'); |
|
| 135 | - if($this->session->userdata('userlevel_logintype') != '0'){?> |
|
| 136 | - <a href="<?php echo base_url();?>dashboard/" class=""> <? } else{?> |
|
| 137 | - <a href="<?php echo base_url();?>user/user/" class=""> |
|
| 134 | + $acc_info = $this->session->userdata('accountinfo'); |
|
| 135 | + if ($this->session->userdata('userlevel_logintype') != '0') {?> |
|
| 136 | + <a href="<?php echo base_url(); ?>dashboard/" class=""> <? } else {?> |
|
| 137 | + <a href="<?php echo base_url(); ?>user/user/" class=""> |
|
| 138 | 138 | <? } |
| 139 | - if($this->session->userdata('logintype')!=2){ |
|
| 140 | - $result=(array)$this->db->get_where('accounts',array("id"=>$acc_info['id']),1)->first_row(); |
|
| 141 | - $variable =$result['posttoexternal']==1 ? 'Credit' : gettext('Bal'); |
|
| 142 | - $amount=$result['posttoexternal']==1 ? $result['credit_limit'] :$result['balance']; |
|
| 143 | - $value= $this->common_model->calculate_currency($amount,'','',true); |
|
| 144 | - if($value >0){ |
|
| 145 | - $color='#397A13'; |
|
| 139 | + if ($this->session->userdata('logintype') != 2) { |
|
| 140 | + $result = (array)$this->db->get_where('accounts', array("id"=>$acc_info['id']), 1)->first_row(); |
|
| 141 | + $variable = $result['posttoexternal'] == 1 ? 'Credit' : gettext('Bal'); |
|
| 142 | + $amount = $result['posttoexternal'] == 1 ? $result['credit_limit'] : $result['balance']; |
|
| 143 | + $value = $this->common_model->calculate_currency($amount, '', '', true); |
|
| 144 | + if ($value > 0) { |
|
| 145 | + $color = '#397A13'; |
|
| 146 | 146 | } |
| 147 | - if($value < 0){ |
|
| 148 | - $color='#EE0E43'; |
|
| 147 | + if ($value < 0) { |
|
| 148 | + $color = '#EE0E43'; |
|
| 149 | 149 | } |
| 150 | - if($value == 0){ |
|
| 151 | - $color='#1A1919'; |
|
| 150 | + if ($value == 0) { |
|
| 151 | + $color = '#1A1919'; |
|
| 152 | 152 | } |
| 153 | 153 | $balance_str = '<span style="color:'.$color.'; font-size: 10px;"><b>('.$variable.' : '.$value.')</b></span>'; |
| 154 | - }else{ |
|
| 154 | + } else { |
|
| 155 | 155 | $balance_str = ''; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $logged_user=$acc_info['first_name']." ".$acc_info['last_name']; |
|
| 158 | + $logged_user = $acc_info['first_name']." ".$acc_info['last_name']; |
|
| 159 | 159 | ?> |
| 160 | 160 | <span> |
| 161 | 161 | <span class="profile_name"> |
| 162 | 162 | <?= $logged_user?> |
| 163 | 163 | </span> |
| 164 | - <label class="profile_label no-margin"><?php echo $balance_str;?> |
|
| 164 | + <label class="profile_label no-margin"><?php echo $balance_str; ?> |
|
| 165 | 165 | </label> |
| 166 | 166 | </span> |
| 167 | 167 | </a> |
| 168 | 168 | <ul class="dropdown-box"> |
| 169 | - <? if($this->session->userdata('userlevel_logintype') != '0' && $this->session->userdata('userlevel_logintype') != '3'){?> |
|
| 170 | - <li><a href="<?php echo base_url();?>dashboard/"><i class="fa fa-home"></i> <?php echo gettext('Dashboard'); ?></a></li> |
|
| 171 | - <? } else{?> |
|
| 172 | - <li><a href="<?php echo base_url();?>user/user/"><i class="fa fa-home"></i> <?php echo gettext('Dashboard'); ?></a></li> |
|
| 169 | + <? if ($this->session->userdata('userlevel_logintype') != '0' && $this->session->userdata('userlevel_logintype') != '3') {?> |
|
| 170 | + <li><a href="<?php echo base_url(); ?>dashboard/"><i class="fa fa-home"></i> <?php echo gettext('Dashboard'); ?></a></li> |
|
| 171 | + <? } else {?> |
|
| 172 | + <li><a href="<?php echo base_url(); ?>user/user/"><i class="fa fa-home"></i> <?php echo gettext('Dashboard'); ?></a></li> |
|
| 173 | 173 | <? }?> |
| 174 | 174 | |
| 175 | -<? if($this->session->userdata('userlevel_logintype') != '-1'){ |
|
| 175 | +<? if ($this->session->userdata('userlevel_logintype') != '-1') { |
|
| 176 | 176 | ?> |
| 177 | - <li><a href="<?php echo base_url();?>user/user_myprofile/"><i class= "fa fa-user"></i> |
|
| 177 | + <li><a href="<?php echo base_url(); ?>user/user_myprofile/"><i class= "fa fa-user"></i> |
|
| 178 | 178 | <?php echo gettext('My Profile'); ?></a></li> |
| 179 | 179 | <? |
| 180 | 180 | }?> |
| 181 | 181 | |
| 182 | - <? if($this->session->userdata('userlevel_logintype') == '-1'){?> |
|
| 182 | + <? if ($this->session->userdata('userlevel_logintype') == '-1') {?> |
|
| 183 | 183 | <li style="-moz-border-radius: 5px 5px 5px 5px;-webkit-border-radius: 5px 5px 5px 5px;border-radius: 5px 5px 5px 5px;"><a href="http://bugs.astppbilling.org/" target="_blank"><i class= "fa fa-bug"></i> <?php echo gettext('Report a Bug'); ?></a></li> |
| 184 | 184 | <?}?> |
| 185 | - <? if($this->session->userdata('userlevel_logintype') == '-1'){?> |
|
| 185 | + <? if ($this->session->userdata('userlevel_logintype') == '-1') {?> |
|
| 186 | 186 | <li><a href="https://astppdoc.atlassian.net/wiki/display/ASTPP/Welcome+to+ASTPP" target="_blank"><i class="fa fa-file-text"></i> Documentation</a></li> |
| 187 | 187 | <li><a href="http://www.astppbilling.org/sip-dialer" target="_blank"><i class="fa fa-mobile fa-lg" aria-hidden="true"></i> Get App</a></li> |
| 188 | 188 | <?}?> |
| 189 | 189 | |
| 190 | - <li><a href="<?php echo base_url();?>logout"><i class="fa fa-power-off"></i> Log out</a></li> |
|
| 190 | + <li><a href="<?php echo base_url(); ?>logout"><i class="fa fa-power-off"></i> Log out</a></li> |
|
| 191 | 191 | </ul> |
| 192 | 192 | </li> |
| 193 | 193 | </ul> |
@@ -203,49 +203,49 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | <?php |
| 205 | 205 | $menu_info = unserialize($this->session->userdata("menuinfo")); |
| 206 | - foreach($menu_info as $menu_key => $menu_values){ |
|
| 206 | + foreach ($menu_info as $menu_key => $menu_values) { |
|
| 207 | 207 | ?> |
| 208 | 208 | |
| 209 | 209 | <?php |
| 210 | - if(common_model::$global_config['system_config']['opensips']== 0 && $menu_key !='SIP Devices'){ |
|
| 210 | + if (common_model::$global_config['system_config']['opensips'] == 0 && $menu_key != 'SIP Devices') { |
|
| 211 | 211 | echo '<li><a href="">'.gettext($menu_key).'<b class="caret"></b></a>'; |
| 212 | 212 | } |
| 213 | - if(common_model::$global_config['system_config']['opensips']== 1 && $menu_key != 'Opensips'){ |
|
| 213 | + if (common_model::$global_config['system_config']['opensips'] == 1 && $menu_key != 'Opensips') { |
|
| 214 | 214 | echo '<li><a href="">'.gettext($menu_key).'<b class="caret"></b></a>'; |
| 215 | 215 | } |
| 216 | 216 | ?> |
| 217 | 217 | |
| 218 | 218 | <ul class="dropdown-menu"> |
| 219 | - <? foreach($menu_values as $sub_menu_key => $sub_menu_values){?> |
|
| 219 | + <? foreach ($menu_values as $sub_menu_key => $sub_menu_values) {?> |
|
| 220 | 220 | |
| 221 | - <? if($sub_menu_key === 0){ ?> |
|
| 222 | - <? foreach($sub_menu_values as $sub_key => $sub_menu_lables){ |
|
| 223 | - if((common_model::$global_config['system_config']['paypal_status']== 1 && strtolower($sub_menu_lables["menu_label"]) =='recharge') ||(common_model::$global_config['system_config']['opensips']== 1 && $sub_menu_lables["menu_label"] =='Opensips')|| |
|
| 224 | - (common_model::$global_config['system_config']['opensips']== 0 && $sub_menu_lables["menu_label"] =='SIP Devices') || |
|
| 225 | - (($acc_info['type'] == '3' || $acc_info['type'] == '0') && $acc_info['allow_ip_management'] == '1' && strtolower($sub_menu_lables["menu_label"]) == 'ip settings')){ |
|
| 226 | - }else{?> |
|
| 227 | - <li><a href="<?php echo base_url().$sub_menu_lables["module_url"];?>"><?php echo gettext($sub_menu_lables["menu_label"]);?></a></li> |
|
| 221 | + <? if ($sub_menu_key === 0) { ?> |
|
| 222 | + <? foreach ($sub_menu_values as $sub_key => $sub_menu_lables) { |
|
| 223 | + if ((common_model::$global_config['system_config']['paypal_status'] == 1 && strtolower($sub_menu_lables["menu_label"]) == 'recharge') || (common_model::$global_config['system_config']['opensips'] == 1 && $sub_menu_lables["menu_label"] == 'Opensips') || |
|
| 224 | + (common_model::$global_config['system_config']['opensips'] == 0 && $sub_menu_lables["menu_label"] == 'SIP Devices') || |
|
| 225 | + (($acc_info['type'] == '3' || $acc_info['type'] == '0') && $acc_info['allow_ip_management'] == '1' && strtolower($sub_menu_lables["menu_label"]) == 'ip settings')) { |
|
| 226 | + } else {?> |
|
| 227 | + <li><a href="<?php echo base_url().$sub_menu_lables["module_url"]; ?>"><?php echo gettext($sub_menu_lables["menu_label"]); ?></a></li> |
|
| 228 | 228 | <?}?> |
| 229 | 229 | <?} ?> |
| 230 | - <?php }else{ |
|
| 231 | - if(common_model::$global_config['system_config']['opensips']==0 && $menu_key !='System Configuration'){ ?> |
|
| 232 | - <li><a href=""><span><?=$sub_menu_key;?></span><i class="fa fa-caret-right pull-right"></i></a> |
|
| 233 | - <? } if(common_model::$global_config['system_config']['opensips']==1) {?> |
|
| 234 | - <li><a href=""><span><?=$sub_menu_key;?></span><i class="fa fa-caret-right pull-right"></i></a> |
|
| 235 | - <?php }if(($acc_info['type']==3 || $acc_info['type']== 0) && $acc_info['allow_ip_management']== 1 && strtolower($sub_menu_lables["menu_label"]) !='ip settings'){ ?> |
|
| 236 | - <li><a href=""><span><?=$sub_menu_key;?></span><i class="fa fa-caret-right pull-right"></i></a> |
|
| 230 | + <?php } else { |
|
| 231 | + if (common_model::$global_config['system_config']['opensips'] == 0 && $menu_key != 'System Configuration') { ?> |
|
| 232 | + <li><a href=""><span><?=$sub_menu_key; ?></span><i class="fa fa-caret-right pull-right"></i></a> |
|
| 233 | + <? } if (common_model::$global_config['system_config']['opensips'] == 1) {?> |
|
| 234 | + <li><a href=""><span><?=$sub_menu_key; ?></span><i class="fa fa-caret-right pull-right"></i></a> |
|
| 235 | + <?php }if (($acc_info['type'] == 3 || $acc_info['type'] == 0) && $acc_info['allow_ip_management'] == 1 && strtolower($sub_menu_lables["menu_label"]) != 'ip settings') { ?> |
|
| 236 | + <li><a href=""><span><?=$sub_menu_key; ?></span><i class="fa fa-caret-right pull-right"></i></a> |
|
| 237 | 237 | <? } |
| 238 | 238 | ?> |
| 239 | 239 | <div class="col-4"><div class="col-md-6 no-padding"> |
| 240 | 240 | <ul class="col-12 padding-x-8"> |
| 241 | - <? foreach($sub_menu_values as $sub_menu_lables){ |
|
| 242 | - if($sub_menu_lables['menu_label'] != 'Configuration'){ |
|
| 243 | - if(common_model::$global_config['system_config']['opensips']==0 && $sub_menu_lables["menu_label"] !='SIP Devices'){ |
|
| 241 | + <? foreach ($sub_menu_values as $sub_menu_lables) { |
|
| 242 | + if ($sub_menu_lables['menu_label'] != 'Configuration') { |
|
| 243 | + if (common_model::$global_config['system_config']['opensips'] == 0 && $sub_menu_lables["menu_label"] != 'SIP Devices') { |
|
| 244 | 244 | ?> |
| 245 | - <li><a href="<?php echo base_url().$sub_menu_lables["module_url"];?>"><?php echo gettext($sub_menu_lables["menu_label"]);?></a></li> |
|
| 245 | + <li><a href="<?php echo base_url().$sub_menu_lables["module_url"]; ?>"><?php echo gettext($sub_menu_lables["menu_label"]); ?></a></li> |
|
| 246 | 246 | <? } |
| 247 | - if(common_model::$global_config['system_config']['opensips']== 1 && $sub_menu_key !='opensips'){ ?> |
|
| 248 | - <li><a href="<?php echo base_url().$sub_menu_lables["module_url"];?>"><?=$sub_menu_lables["menu_label"];?></a></li> |
|
| 247 | + if (common_model::$global_config['system_config']['opensips'] == 1 && $sub_menu_key != 'opensips') { ?> |
|
| 248 | + <li><a href="<?php echo base_url().$sub_menu_lables["module_url"]; ?>"><?=$sub_menu_lables["menu_label"]; ?></a></li> |
|
| 249 | 249 | <? } |
| 250 | 250 | } |
| 251 | 251 | } ?> |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $color='#1A1919'; |
| 152 | 152 | } |
| 153 | 153 | $balance_str = '<span style="color:'.$color.'; font-size: 10px;"><b>('.$variable.' : '.$value.')</b></span>'; |
| 154 | - }else{ |
|
| 154 | + } else{ |
|
| 155 | 155 | $balance_str = ''; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -223,11 +223,11 @@ discard block |
||
| 223 | 223 | if((common_model::$global_config['system_config']['paypal_status']== 1 && strtolower($sub_menu_lables["menu_label"]) =='recharge') ||(common_model::$global_config['system_config']['opensips']== 1 && $sub_menu_lables["menu_label"] =='Opensips')|| |
| 224 | 224 | (common_model::$global_config['system_config']['opensips']== 0 && $sub_menu_lables["menu_label"] =='SIP Devices') || |
| 225 | 225 | (($acc_info['type'] == '3' || $acc_info['type'] == '0') && $acc_info['allow_ip_management'] == '1' && strtolower($sub_menu_lables["menu_label"]) == 'ip settings')){ |
| 226 | - }else{?> |
|
| 226 | + } else{?> |
|
| 227 | 227 | <li><a href="<?php echo base_url().$sub_menu_lables["module_url"];?>"><?php echo gettext($sub_menu_lables["menu_label"]);?></a></li> |
| 228 | 228 | <?}?> |
| 229 | 229 | <?} ?> |
| 230 | - <?php }else{ |
|
| 230 | + <?php } else{ |
|
| 231 | 231 | if(common_model::$global_config['system_config']['opensips']==0 && $menu_key !='System Configuration'){ ?> |
| 232 | 232 | <li><a href=""><span><?=$sub_menu_key;?></span><i class="fa fa-caret-right pull-right"></i></a> |
| 233 | 233 | <? } if(common_model::$global_config['system_config']['opensips']==1) {?> |
@@ -7,15 +7,15 @@ |
||
| 7 | 7 | |
| 8 | 8 | <?php |
| 9 | 9 | $this->db->select('*'); |
| 10 | - $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 11 | - $result=$this->db->get('invoice_conf'); |
|
| 12 | - if($result->num_rows() > 0){ |
|
| 13 | - $result=$result->result_array(); |
|
| 10 | + $this->db->where('domain', $_SERVER['HTTP_HOST']); |
|
| 11 | + $result = $this->db->get('invoice_conf'); |
|
| 12 | + if ($result->num_rows() > 0) { |
|
| 13 | + $result = $result->result_array(); |
|
| 14 | 14 | $footer = $result[0]['website_footer']; |
| 15 | - }else{ |
|
| 15 | + } else { |
|
| 16 | 16 | $footer = ''; |
| 17 | 17 | } |
| 18 | - if($footer != ''){ ?> |
|
| 18 | + if ($footer != '') { ?> |
|
| 19 | 19 | <div style="margin-left:470px; "><?=$footer ?> |
| 20 | 20 | |
| 21 | 21 | <div style="" class="pull-left"> |
@@ -208,7 +208,7 @@ |
||
| 208 | 208 | <?php |
| 209 | 209 | if($account_data['logo'] != ''){ |
| 210 | 210 | $logo=$account_data['file']; |
| 211 | - }else{ |
|
| 211 | + } else{ |
|
| 212 | 212 | $logo=$account_data['logo']; |
| 213 | 213 | } |
| 214 | 214 | if($logo != ''){ |
@@ -61,84 +61,83 @@ |
||
| 61 | 61 | <div class="sidebar collapse"> |
| 62 | 62 | |
| 63 | 63 | <?php |
| 64 | - $uri_string= uri_string(); |
|
| 65 | - $uri_arr=explode("/",$uri_string);
|
|
| 66 | - $entity_name=false; |
|
| 67 | - if(isset($uri_arr[1]) && !empty($uri_arr[1])){
|
|
| 68 | - $function_explode=explode("_",$uri_arr[1]);
|
|
| 69 | - $entity_name = isset($function_explode[1]) && !empty($function_explode[1]) ? $function_explode[0] : false; |
|
| 64 | + $uri_string = uri_string(); |
|
| 65 | + $uri_arr = explode("/", $uri_string);
|
|
| 66 | + $entity_name = false; |
|
| 67 | + if (isset($uri_arr[1]) && ! empty($uri_arr[1])) {
|
|
| 68 | + $function_explode = explode("_", $uri_arr[1]);
|
|
| 69 | + $entity_name = isset($function_explode[1]) && ! empty($function_explode[1]) ? $function_explode[0] : false; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $accountinfo=$this->session->userdata('accountinfo');
|
|
| 73 | - if($accountinfo['type'] != 0 && $accountinfo['type'] !=3){
|
|
| 74 | - $menu_info= ($uri_arr[0]=="user" |
|
| 75 | - ? unserialize(RESELLERPROFILE_ARRAY):($uri_arr[0]=="accounts"&& $entity_name =='customer' |
|
| 76 | - ? unserialize(CUSTOMEREDIT_ARRAY) :($uri_arr[0]=="accounts"&& $entity_name =='provider' |
|
| 77 | - ? unserialize(PROVIDEREDIT_ARRAY) :($uri_arr[0]=="accounts"&& $entity_name =='reseller' |
|
| 78 | - ? unserialize(RESELLEREDIT_ARRAY) : ($uri_arr[0] =="package" ? unserialize(PACKAGEEDIT_ARRAY):false) )))); |
|
| 79 | - }else{
|
|
| 80 | - $menu_info=null; |
|
| 81 | - $current_menu_url=$uri_arr[0]."/".$uri_arr[1]."/"; |
|
| 82 | - $new_menu_info=array(); |
|
| 83 | - $menus= unserialize($this->session->userdata('menuinfo'));
|
|
| 84 | - foreach($menus as $entity_key=>$entity_menu){
|
|
| 85 | - foreach($entity_menu as $entity_subkey=>$entity_submenu){
|
|
| 86 | - foreach($entity_submenu as $subkey=>$submenus){
|
|
| 87 | - if($submenus['module_url']==$current_menu_url){
|
|
| 88 | - $new_menu_info=$entity_menu; |
|
| 72 | + $accountinfo = $this->session->userdata('accountinfo');
|
|
| 73 | + if ($accountinfo['type'] != 0 && $accountinfo['type'] != 3) {
|
|
| 74 | + $menu_info = ($uri_arr[0] == "user" |
|
| 75 | + ? unserialize(RESELLERPROFILE_ARRAY) : ($uri_arr[0] == "accounts" && $entity_name == 'customer' |
|
| 76 | + ? unserialize(CUSTOMEREDIT_ARRAY) : ($uri_arr[0] == "accounts" && $entity_name == 'provider' |
|
| 77 | + ? unserialize(PROVIDEREDIT_ARRAY) : ($uri_arr[0] == "accounts" && $entity_name == 'reseller' |
|
| 78 | + ? unserialize(RESELLEREDIT_ARRAY) : ($uri_arr[0] == "package" ? unserialize(PACKAGEEDIT_ARRAY) : false))))); |
|
| 79 | + } else {
|
|
| 80 | + $menu_info = null; |
|
| 81 | + $current_menu_url = $uri_arr[0]."/".$uri_arr[1]."/"; |
|
| 82 | + $new_menu_info = array(); |
|
| 83 | + $menus = unserialize($this->session->userdata('menuinfo'));
|
|
| 84 | + foreach ($menus as $entity_key=>$entity_menu) {
|
|
| 85 | + foreach ($entity_menu as $entity_subkey=>$entity_submenu) {
|
|
| 86 | + foreach ($entity_submenu as $subkey=>$submenus) {
|
|
| 87 | + if ($submenus['module_url'] == $current_menu_url) {
|
|
| 88 | + $new_menu_info = $entity_menu; |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | - foreach($new_menu_info as $key=>$value){
|
|
| 94 | - foreach($value as $subvalue){
|
|
| 95 | - $menu_info[$subvalue['menu_label']]=$subvalue['module_url']; |
|
| 93 | + foreach ($new_menu_info as $key=>$value) {
|
|
| 94 | + foreach ($value as $subvalue) {
|
|
| 95 | + $menu_info[$subvalue['menu_label']] = $subvalue['module_url']; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | - if($accountinfo['type']==0 || $accountinfo['type']==3){
|
|
| 100 | - if($uri_arr[0]=='user' && $uri_arr[1] =='user_myprofile' || $uri_arr[0]=='user' && $uri_arr[1]=='user_change_password'){
|
|
| 101 | - $menu_info=unserialize(CUSTOMERPROFILE_ARRAY); |
|
| 99 | + if ($accountinfo['type'] == 0 || $accountinfo['type'] == 3) {
|
|
| 100 | + if ($uri_arr[0] == 'user' && $uri_arr[1] == 'user_myprofile' || $uri_arr[0] == 'user' && $uri_arr[1] == 'user_change_password') {
|
|
| 101 | + $menu_info = unserialize(CUSTOMERPROFILE_ARRAY); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | - if(!empty($menu_info)){
|
|
| 104 | + if ( ! empty($menu_info)) {
|
|
| 105 | 105 | echo "<ul class='sidemenu'>"; |
| 106 | - $i=0; |
|
| 107 | - foreach($menu_info as $key=>$value){
|
|
| 108 | - $url=($entity_name=='provider'||$entity_name =='customer' || $entity_name =='reseller' || $uri_arr[0] =="package") && isset($uri_arr[2]) && !empty($uri_arr[2]) |
|
| 106 | + $i = 0; |
|
| 107 | + foreach ($menu_info as $key=>$value) {
|
|
| 108 | + $url = ($entity_name == 'provider' || $entity_name == 'customer' || $entity_name == 'reseller' || $uri_arr[0] == "package") && isset($uri_arr[2]) && ! empty($uri_arr[2]) |
|
| 109 | 109 | ? |
| 110 | - base_url().$value.$uri_arr[2]."/" : |
|
| 111 | - base_url().$value; |
|
| 112 | - $value_flag=false; |
|
| 113 | - if($acc_info['type'] == '3' || $acc_info['type'] == '0'){
|
|
| 114 | - if($value == "user/user_ipmap/" && $acc_info['allow_ip_management'] == '1'){
|
|
| 115 | - $value_flag=false; |
|
| 116 | - }elseif(in_array('user/user_sipdevices/',$menu_info) && $value == "user/user_sipdevices/" && common_model::$global_config['system_config']['opensips']== 0){
|
|
| 117 | - $value_flag=false; |
|
| 118 | - }else{
|
|
| 119 | - $value_flag=true; |
|
| 110 | + base_url().$value.$uri_arr[2]."/" : base_url().$value; |
|
| 111 | + $value_flag = false; |
|
| 112 | + if ($acc_info['type'] == '3' || $acc_info['type'] == '0') {
|
|
| 113 | + if ($value == "user/user_ipmap/" && $acc_info['allow_ip_management'] == '1') {
|
|
| 114 | + $value_flag = false; |
|
| 115 | + }elseif (in_array('user/user_sipdevices/', $menu_info) && $value == "user/user_sipdevices/" && common_model::$global_config['system_config']['opensips'] == 0) {
|
|
| 116 | + $value_flag = false; |
|
| 117 | + } else {
|
|
| 118 | + $value_flag = true; |
|
| 120 | 119 | } |
| 121 | - }else{
|
|
| 122 | - if(common_model::$global_config['system_config']['opensips'] == 1 ){
|
|
| 123 | - if($value != "accounts/".$entity_name."_opensips/"){
|
|
| 124 | - $value_flag=true; |
|
| 125 | - }else{
|
|
| 126 | - $value_flag=false; |
|
| 120 | + } else {
|
|
| 121 | + if (common_model::$global_config['system_config']['opensips'] == 1) {
|
|
| 122 | + if ($value != "accounts/".$entity_name."_opensips/") {
|
|
| 123 | + $value_flag = true; |
|
| 124 | + } else {
|
|
| 125 | + $value_flag = false; |
|
| 127 | 126 | } |
| 128 | 127 | } |
| 129 | - if(common_model::$global_config['system_config']['opensips']== 0 ){
|
|
| 130 | - if($value != "accounts/".$entity_name."_sipdevices/"){
|
|
| 131 | - $value_flag=true; |
|
| 132 | - }else{
|
|
| 133 | - $value_flag=false; |
|
| 128 | + if (common_model::$global_config['system_config']['opensips'] == 0) {
|
|
| 129 | + if ($value != "accounts/".$entity_name."_sipdevices/") {
|
|
| 130 | + $value_flag = true; |
|
| 131 | + } else {
|
|
| 132 | + $value_flag = false; |
|
| 134 | 133 | } |
| 135 | 134 | } |
| 136 | 135 | } |
| 137 | 136 | |
| 138 | - if($value_flag){
|
|
| 139 | - $class = ($value == $uri_arr[0]."/".$uri_arr[1]."/" ) ? 'active' : ''; |
|
| 140 | - if($i==0) |
|
| 141 | - $class=($uri_arr[1]== $entity_name."_save") ? 'active': $class; |
|
| 137 | + if ($value_flag) {
|
|
| 138 | + $class = ($value == $uri_arr[0]."/".$uri_arr[1]."/") ? 'active' : ''; |
|
| 139 | + if ($i == 0) |
|
| 140 | + $class = ($uri_arr[1] == $entity_name."_save") ? 'active' : $class; |
|
| 142 | 141 | |
| 143 | 142 | echo "<li class='$class'><a href ='$url'>$key</a></li>"; |
| 144 | 143 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | ? unserialize(CUSTOMEREDIT_ARRAY) :($uri_arr[0]=="accounts"&& $entity_name =='provider' |
| 77 | 77 | ? unserialize(PROVIDEREDIT_ARRAY) :($uri_arr[0]=="accounts"&& $entity_name =='reseller' |
| 78 | 78 | ? unserialize(RESELLEREDIT_ARRAY) : ($uri_arr[0] =="package" ? unserialize(PACKAGEEDIT_ARRAY):false) )))); |
| 79 | - }else{
|
|
| 79 | + } else{
|
|
| 80 | 80 | $menu_info=null; |
| 81 | 81 | $current_menu_url=$uri_arr[0]."/".$uri_arr[1]."/"; |
| 82 | 82 | $new_menu_info=array(); |
@@ -113,23 +113,23 @@ discard block |
||
| 113 | 113 | if($acc_info['type'] == '3' || $acc_info['type'] == '0'){
|
| 114 | 114 | if($value == "user/user_ipmap/" && $acc_info['allow_ip_management'] == '1'){
|
| 115 | 115 | $value_flag=false; |
| 116 | - }elseif(in_array('user/user_sipdevices/',$menu_info) && $value == "user/user_sipdevices/" && common_model::$global_config['system_config']['opensips']== 0){
|
|
| 116 | + } elseif(in_array('user/user_sipdevices/',$menu_info) && $value == "user/user_sipdevices/" && common_model::$global_config['system_config']['opensips']== 0){
|
|
| 117 | 117 | $value_flag=false; |
| 118 | - }else{
|
|
| 118 | + } else{
|
|
| 119 | 119 | $value_flag=true; |
| 120 | 120 | } |
| 121 | - }else{
|
|
| 121 | + } else{
|
|
| 122 | 122 | if(common_model::$global_config['system_config']['opensips'] == 1 ){
|
| 123 | 123 | if($value != "accounts/".$entity_name."_opensips/"){
|
| 124 | 124 | $value_flag=true; |
| 125 | - }else{
|
|
| 125 | + } else{
|
|
| 126 | 126 | $value_flag=false; |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | if(common_model::$global_config['system_config']['opensips']== 0 ){
|
| 130 | 130 | if($value != "accounts/".$entity_name."_sipdevices/"){
|
| 131 | 131 | $value_flag=true; |
| 132 | - }else{
|
|
| 132 | + } else{
|
|
| 133 | 133 | $value_flag=false; |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -137,8 +137,9 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | if($value_flag){
|
| 139 | 139 | $class = ($value == $uri_arr[0]."/".$uri_arr[1]."/" ) ? 'active' : ''; |
| 140 | - if($i==0) |
|
| 141 | - $class=($uri_arr[1]== $entity_name."_save") ? 'active': $class; |
|
| 140 | + if($i==0) { |
|
| 141 | + $class=($uri_arr[1]== $entity_name."_save") ? 'active': $class; |
|
| 142 | + } |
|
| 142 | 143 | |
| 143 | 144 | echo "<li class='$class'><a href ='$url'>$key</a></li>"; |
| 144 | 145 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | function create_csv_string($data) { |
| 6 | - if (!$fp = fopen('php://temp', 'w+')) { |
|
| 6 | + if ( ! $fp = fopen('php://temp', 'w+')) { |
|
| 7 | 7 | return FALSE; |
| 8 | 8 | } |
| 9 | 9 | foreach ($data as $line) { |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | return stream_get_contents($fp); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -function send_csv_mail ($csvData, $body, $to, $subject,$file_name) { |
|
| 16 | +function send_csv_mail($csvData, $body, $to, $subject, $file_name) { |
|
| 17 | 17 | //print_r($csvData); |
| 18 | 18 | $where = array('group_title' =>'email'); |
| 19 | 19 | $query = $this->CI->db_model->getSelect("*", "system", $where); |
| 20 | 20 | $query = $query->result_array(); |
| 21 | - foreach($query as $key=>$val){ |
|
| 22 | - $from=$val['value']; |
|
| 21 | + foreach ($query as $key=>$val) { |
|
| 22 | + $from = $val['value']; |
|
| 23 | 23 | } |
| 24 | 24 | $multipartSep = '-----'.md5(time()).'-----'; |
| 25 | 25 | $headers = array( |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
| 1 | +<?php if ( ! defined('BASEPATH')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | // ------------------------------------------------------------------------ |
| 4 | 6 | |
@@ -309,10 +311,11 @@ discard block |
||
| 309 | 311 | if ( ! function_exists('form_table_row_4')) |
| 310 | 312 | { |
| 311 | 313 | function form_table_row_4($label, $field, $span, $wh = '10', $wd = '') { |
| 312 | - if (wd == '') |
|
| 313 | - echo '<th width="'.$wh.'%"><label>'.$label.'</label></th><td>'; |
|
| 314 | - else |
|
| 315 | - echo '<th width="'.$wh.'%"><label>'.$label.'</label></th><td width="'.$wd.'%">'; |
|
| 314 | + if (wd == '') { |
|
| 315 | + echo '<th width="'.$wh.'%"><label>'.$label.'</label></th><td>'; |
|
| 316 | + } else { |
|
| 317 | + echo '<th width="'.$wh.'%"><label>'.$label.'</label></th><td width="'.$wd.'%">'; |
|
| 318 | + } |
|
| 316 | 319 | echo $field; |
| 317 | 320 | echo '<br/><span class="helptext">'.$span.'</span>'; |
| 318 | 321 | echo '</td></tr>'; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | "Alert Threshold"=>"user/user_alert_threshold/" |
| 52 | 52 | )) |
| 53 | 53 | ); |
| 54 | -define("CUSTOMEREDIT_ARRAY",serialize(array( |
|
| 54 | +define("CUSTOMEREDIT_ARRAY", serialize(array( |
|
| 55 | 55 | "Customer Profile"=>"accounts/customer_edit/", |
| 56 | 56 | "SIP Devices"=>"accounts/customer_sipdevices/", |
| 57 | 57 | "Opensips Device"=>"accounts/customer_opensips/", |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | ) |
| 71 | 71 | )); |
| 72 | 72 | |
| 73 | -define("PROVIDEREDIT_ARRAY",serialize(array( |
|
| 73 | +define("PROVIDEREDIT_ARRAY", serialize(array( |
|
| 74 | 74 | "Provider Profile"=>"accounts/provider_edit/", |
| 75 | 75 | "SIP Devices"=>"accounts/provider_sipdevices/", |
| 76 | 76 | "Opensips Device"=>"accounts/provider_opensips/", |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | "Alert Threshold"=>"accounts/provider_alert_threshold/" |
| 89 | 89 | ) |
| 90 | 90 | )); |
| 91 | -define("RESELLEREDIT_ARRAY",serialize(array("Reseller Profile"=>"accounts/reseller_edit/", |
|
| 91 | +define("RESELLEREDIT_ARRAY", serialize(array("Reseller Profile"=>"accounts/reseller_edit/", |
|
| 92 | 92 | "DID"=>"accounts/reseller_dids/", |
| 93 | 93 | "Subscription"=>"accounts/reseller_subscription/", |
| 94 | 94 | "Invoice"=>"accounts/reseller_invoices/", |
@@ -100,15 +100,15 @@ discard block |
||
| 100 | 100 | "Emails"=>"accounts/reseller_emailhistory/", |
| 101 | 101 | "Alert Threshold"=>"accounts/reseller_alert_threshold/" |
| 102 | 102 | ))); |
| 103 | -define("PACKAGEEDIT_ARRAY", serialize( array( |
|
| 103 | +define("PACKAGEEDIT_ARRAY", serialize(array( |
|
| 104 | 104 | "Package Details"=>"package/package_edit/", |
| 105 | 105 | "Package Codes"=>"package/package_pattern_list/" |
| 106 | 106 | ))); |
| 107 | -define("CUSTOMERPROFILE_ARRAY",serialize(array( |
|
| 107 | +define("CUSTOMERPROFILE_ARRAY", serialize(array( |
|
| 108 | 108 | "My Profile"=>"user/user_myprofile/", |
| 109 | 109 | "Change Password"=>"user/user_change_password" |
| 110 | 110 | ))); |
| 111 | -define("DATABASE_DIRECTORY",FCPATH.'database_backup'.DIRECTORY_SEPARATOR); |
|
| 111 | +define("DATABASE_DIRECTORY", FCPATH.'database_backup'.DIRECTORY_SEPARATOR); |
|
| 112 | 112 | define('LOCALE_REQUEST_PARAM', 'lang'); |
| 113 | 113 | define('WEBSITE_DOMAIN', 'messages'); |
| 114 | 114 | |