/** * tag : PAGE * mode : OPEN * * @param array $param * @return boolean */ protected function _tag_open_PAGE($param) { if ($this->_isForOneLine) { return false; } if ($this->_debugActif) { $this->_DEBUG_add('PAGE ' . ($this->_page + 1), true); } $newPageSet = !isset($param['pageset']) || $param['pageset'] != 'old'; $resetPageNumber = isset($param['pagegroup']) && $param['pagegroup'] == 'new'; $this->_maxH = 0; // if new page set asked if ($newPageSet) { $this->_subHEADER = array(); $this->_subFOOTER = array(); // orientation $orientation = ''; if (isset($param['orientation'])) { $param['orientation'] = strtolower($param['orientation']); if ($param['orientation'] == 'p') { $orientation = 'P'; } if ($param['orientation'] == 'portrait') { $orientation = 'P'; } if ($param['orientation'] == 'l') { $orientation = 'L'; } if ($param['orientation'] == 'paysage') { $orientation = 'L'; } if ($param['orientation'] == 'landscape') { $orientation = 'L'; } } // format $format = null; if (isset($param['format'])) { $format = strtolower($param['format']); if (preg_match('/^([0-9]+)x([0-9]+)$/isU', $format, $match)) { $format = array(intval($match[1]), intval($match[2])); } } // background $background = array(); if (isset($param['backimg'])) { $background['img'] = isset($param['backimg']) ? $param['backimg'] : ''; // src of the image $background['posX'] = isset($param['backimgx']) ? $param['backimgx'] : 'center'; // horizontale position of the image $background['posY'] = isset($param['backimgy']) ? $param['backimgy'] : 'middle'; // vertical position of the image $background['width'] = isset($param['backimgw']) ? $param['backimgw'] : '100%'; // width of the image (100% = page width) // convert the src of the image, if parameters $background['img'] = str_replace('&', '&', $background['img']); // convert the positions if ($background['posX'] == 'left') { $background['posX'] = '0%'; } if ($background['posX'] == 'center') { $background['posX'] = '50%'; } if ($background['posX'] == 'right') { $background['posX'] = '100%'; } if ($background['posY'] == 'top') { $background['posY'] = '0%'; } if ($background['posY'] == 'middle') { $background['posY'] = '50%'; } if ($background['posY'] == 'bottom') { $background['posY'] = '100%'; } if ($background['img']) { // get the size of the image // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini $infos = @getimagesize($background['img']); if (count($infos) > 1) { $imageWidth = $this->parsingCss->ConvertToMM($background['width'], $this->pdf->getW()); $imageHeight = $imageWidth * $infos[1] / $infos[0]; $background['width'] = $imageWidth; $background['posX'] = $this->parsingCss->ConvertToMM($background['posX'], $this->pdf->getW() - $imageWidth); $background['posY'] = $this->parsingCss->ConvertToMM($background['posY'], $this->pdf->getH() - $imageHeight); } else { $background = array(); } } else { $background = array(); } } // margins of the page $background['top'] = isset($param['backtop']) ? $param['backtop'] : '0'; $background['bottom'] = isset($param['backbottom']) ? $param['backbottom'] : '0'; $background['left'] = isset($param['backleft']) ? $param['backleft'] : '0'; $background['right'] = isset($param['backright']) ? $param['backright'] : '0'; // if no unit => mm if (preg_match('/^([0-9]*)$/isU', $background['top'])) { $background['top'] .= 'mm'; } if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) { $background['bottom'] .= 'mm'; } if (preg_match('/^([0-9]*)$/isU', $background['left'])) { $background['left'] .= 'mm'; } if (preg_match('/^([0-9]*)$/isU', $background['right'])) { $background['right'] .= 'mm'; } // convert to mm $background['top'] = $this->parsingCss->ConvertToMM($background['top'], $this->pdf->getH()); $background['bottom'] = $this->parsingCss->ConvertToMM($background['bottom'], $this->pdf->getH()); $background['left'] = $this->parsingCss->ConvertToMM($background['left'], $this->pdf->getW()); $background['right'] = $this->parsingCss->ConvertToMM($background['right'], $this->pdf->getW()); // get the background color $res = false; $background['color'] = isset($param['backcolor']) ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null; if (!$res) { $background['color'] = null; } $this->parsingCss->save(); $this->parsingCss->analyse('PAGE', $param); $this->parsingCss->setPosition(); $this->parsingCss->fontSet(); // new page $this->_setNewPage($format, $orientation, $background, null, $resetPageNumber); // automatic footer if (isset($param['footer'])) { $lst = explode(';', $param['footer']); foreach ($lst as $key => $val) { $lst[$key] = trim(strtolower($val)); } $page = in_array('page', $lst); $date = in_array('date', $lst); $hour = in_array('heure', $lst); $form = in_array('form', $lst); } else { $page = null; $date = null; $hour = null; $form = null; } $this->pdf->SetMyFooter($page, $date, $hour, $form); // else => we use the last page set used } else { $this->parsingCss->save(); $this->parsingCss->analyse('PAGE', $param); $this->parsingCss->setPosition(); $this->parsingCss->fontSet(); $this->_setNewPage(null, null, null, null, $resetPageNumber); } return true; }