本文整理汇总了PHP中TCPDF_STATIC::empty_string方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF_STATIC::empty_string方法的具体用法?PHP TCPDF_STATIC::empty_string怎么用?PHP TCPDF_STATIC::empty_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF_STATIC
的用法示例。
在下文中一共展示了TCPDF_STATIC::empty_string方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getImageFileType
/**
* Return the image type given the file name or array returned by getimagesize() function.
* @param $imgfile (string) image file name
* @param $iminfo (array) array of image information returned by getimagesize() function.
* @return string image type
* @since 4.8.017 (2009-11-27)
* @public static
*/
public static function getImageFileType($imgfile, $iminfo=array()) {
$type = '';
if (isset($iminfo['mime']) AND !empty($iminfo['mime'])) {
$mime = explode('/', $iminfo['mime']);
if ((count($mime) > 1) AND ($mime[0] == 'image') AND (!empty($mime[1]))) {
$type = strtolower(trim($mime[1]));
}
}
if (empty($type)) {
$fileinfo = pathinfo($imgfile);
if (isset($fileinfo['extension']) AND (!TCPDF_STATIC::empty_string($fileinfo['extension']))) {
$type = strtolower(trim($fileinfo['extension']));
}
}
if ($type == 'jpg') {
$type = 'jpeg';
}
return $type;
}
示例2: checkPageBreak
/**
* Add page if needed.
*
* @param float|int $h cell height. Default value: 0
* @param mixed $y starting y position, leave empty for current
* position
* @param boolean $addpage if true add a page, otherwise only return
* the true/false state
*
* @return boolean true in case of page break, false otherwise.
*/
function checkPageBreak($h = 0, $y = '', $addpage = true)
{
if (TCPDF_STATIC::empty_string($y)) {
$y = $this->y;
}
$current_page = $this->page;
if ($y + $h > $this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak()) {
if ($addpage) {
//Automatic page break
$x = $this->x;
$this->AddPage($this->CurOrientation);
$this->y = $this->dataY;
$oldpage = $this->page - 1;
$this_page_orm = $this->pagedim[$this->page]['orm'];
$old_page_orm = $this->pagedim[$oldpage]['orm'];
$this_page_olm = $this->pagedim[$this->page]['olm'];
$old_page_olm = $this->pagedim[$oldpage]['olm'];
if ($this->rtl) {
if ($this_page_orm != $old_page_orm) {
$this->x = $x - ($this_page_orm - $old_page_orm);
} else {
$this->x = $x;
}
} else {
if ($this_page_olm != $old_page_olm) {
$this->x = $x + ($this_page_olm - $old_page_olm);
} else {
$this->x = $x;
}
}
}
return true;
}
if ($current_page != $this->page) {
// account for columns mode
return true;
}
return false;
}
示例3: startSVGElementHandler
/**
* Sets the opening SVG element handler function for the XML parser. (*** TO BE COMPLETED ***)
* @param $parser (resource) The first parameter, parser, is a reference to the XML parser calling the handler.
* @param $name (string) The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters.
* @param $attribs (array) The third parameter, attribs, contains an associative array with the element's attributes (if any). The keys of this array are the attribute names, the values are the attribute values. Attribute names are case-folded on the same criteria as element names. Attribute values are not case-folded. The original order of the attributes can be retrieved by walking through attribs the normal way, using each(). The first key in the array was the first attribute, and so on.
* @param $ctm (array) tranformation matrix for clipping mode (starting transformation matrix).
* @author Nicola Asuni
* @since 5.0.000 (2010-05-02)
* @protected
*/
protected function startSVGElementHandler($parser, $name, $attribs, $ctm = array())
{
// check if we are in clip mode
if ($this->svgclipmode) {
$this->svgclippaths[$this->svgclipid][] = array('name' => $name, 'attribs' => $attribs, 'tm' => $this->svgcliptm[$this->svgclipid]);
return;
}
if ($this->svgdefsmode and !in_array($name, array('clipPath', 'linearGradient', 'radialGradient', 'stop'))) {
if (!isset($attribs['id'])) {
$attribs['id'] = 'DF_' . (count($this->svgdefs) + 1);
}
$this->svgdefs[$attribs['id']] = array('name' => $name, 'attribs' => $attribs);
return;
}
$clipping = false;
if ($parser == 'clip-path') {
// set clipping mode
$clipping = true;
}
// get styling properties
$prev_svgstyle = $this->svgstyles[count($this->svgstyles) - 1];
// previous style
$svgstyle = $this->svgstyles[0];
// set default style
if ($clipping and !isset($attribs['fill']) and (!isset($attribs['style']) or !preg_match('/[;\\"\\s]{1}fill[\\s]*:[\\s]*([^;\\"]*)/si', $attribs['style'], $attrval))) {
// default fill attribute for clipping
$attribs['fill'] = 'none';
}
if (isset($attribs['style']) and !TCPDF_STATIC::empty_string($attribs['style'])) {
// fix style for regular expression
$attribs['style'] = ';' . $attribs['style'];
}
foreach ($prev_svgstyle as $key => $val) {
if (in_array($key, TCPDF_IMAGES::$svginheritprop)) {
// inherit previous value
$svgstyle[$key] = $val;
}
if (isset($attribs[$key]) and !TCPDF_STATIC::empty_string($attribs[$key])) {
// specific attribute settings
if ($attribs[$key] == 'inherit') {
$svgstyle[$key] = $val;
} else {
$svgstyle[$key] = $attribs[$key];
}
} elseif (isset($attribs['style']) and !TCPDF_STATIC::empty_string($attribs['style'])) {
// CSS style syntax
$attrval = array();
if (preg_match('/[;\\"\\s]{1}' . $key . '[\\s]*:[\\s]*([^;\\"]*)/si', $attribs['style'], $attrval) and isset($attrval[1])) {
if ($attrval[1] == 'inherit') {
$svgstyle[$key] = $val;
} else {
$svgstyle[$key] = $attrval[1];
}
}
}
}
// transformation matrix
if (!empty($ctm)) {
$tm = $ctm;
} else {
//$tm = $this->svgstyles[(count($this->svgstyles) - 1)]['transfmatrix'];
$tm = array(1, 0, 0, 1, 0, 0);
}
if (isset($attribs['transform']) and !empty($attribs['transform'])) {
$tm = TCPDF_STATIC::getTransformationMatrixProduct($tm, TCPDF_STATIC::getSVGTransformMatrix($attribs['transform']));
}
$svgstyle['transfmatrix'] = $tm;
$invisible = false;
if ($svgstyle['visibility'] == 'hidden' or $svgstyle['visibility'] == 'collapse' or $svgstyle['display'] == 'none') {
// the current graphics element is invisible (nothing is painted)
$invisible = true;
}
// process tag
switch ($name) {
case 'defs':
$this->svgdefsmode = true;
break;
// clipPath
// clipPath
case 'clipPath':
if ($invisible) {
break;
}
$this->svgclipmode = true;
if (!isset($attribs['id'])) {
$attribs['id'] = 'CP_' . (count($this->svgcliptm) + 1);
}
$this->svgclipid = $attribs['id'];
$this->svgclippaths[$this->svgclipid] = array();
$this->svgcliptm[$this->svgclipid] = $tm;
//.........这里部分代码省略.........
示例4: startSVGElementHandler
/**
* Sets the opening SVG element handler function for the XML parser. (*** TO BE COMPLETED ***)
* @param $parser (resource) The first parameter, parser, is a reference to the XML parser calling the handler.
* @param $name (string) The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters.
* @param $attribs (array) The third parameter, attribs, contains an associative array with the element's attributes (if any). The keys of this array are the attribute names, the values are the attribute values. Attribute names are case-folded on the same criteria as element names. Attribute values are not case-folded. The original order of the attributes can be retrieved by walking through attribs the normal way, using each(). The first key in the array was the first attribute, and so on.
* @param $ctm (array) tranformation matrix for clipping mode (starting transformation matrix).
* @author Nicola Asuni
* @since 5.0.000 (2010-05-02)
* @protected
*/
protected function startSVGElementHandler($parser, $name, $attribs, $ctm=array()) {
$name = $this->removeTagNamespace($name);
// check if we are in clip mode
if ($this->svgclipmode) {
$this->svgclippaths[$this->svgclipid][] = array('name' => $name, 'attribs' => $attribs, 'tm' => $this->svgcliptm[$this->svgclipid]);
return;
}
if ($this->svgdefsmode AND !in_array($name, array('clipPath', 'linearGradient', 'radialGradient', 'stop'))) {
if (isset($attribs['id'])) {
$attribs['child_elements'] = array();
$this->svgdefs[$attribs['id']] = array('name' => $name, 'attribs' => $attribs);
return;
}
if (end($this->svgdefs) !== FALSE) {
$last_svgdefs_id = key($this->svgdefs);
if (isset($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'])) {
$attribs['id'] = 'DF_'.(count($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements']) + 1);
$this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'][$attribs['id']] = array('name' => $name, 'attribs' => $attribs);
return;
}
}
return;
}
$clipping = false;
if ($parser == 'clip-path') {
// set clipping mode
$clipping = true;
}
// get styling properties
$prev_svgstyle = $this->svgstyles[max(0,(count($this->svgstyles) - 1))]; // previous style
$svgstyle = $this->svgstyles[0]; // set default style
if ($clipping AND !isset($attribs['fill']) AND (!isset($attribs['style']) OR (!preg_match('/[;\"\s]{1}fill[\s]*:[\s]*([^;\"]*)/si', $attribs['style'], $attrval)))) {
// default fill attribute for clipping
$attribs['fill'] = 'none';
}
if (isset($attribs['style']) AND !TCPDF_STATIC::empty_string($attribs['style']) AND ($attribs['style'][0] != ';')) {
// fix style for regular expression
$attribs['style'] = ';'.$attribs['style'];
}
foreach ($prev_svgstyle as $key => $val) {
if (in_array($key, TCPDF_IMAGES::$svginheritprop)) {
// inherit previous value
$svgstyle[$key] = $val;
}
if (isset($attribs[$key]) AND !TCPDF_STATIC::empty_string($attribs[$key])) {
// specific attribute settings
if ($attribs[$key] == 'inherit') {
$svgstyle[$key] = $val;
} else {
$svgstyle[$key] = $attribs[$key];
}
} elseif (isset($attribs['style']) AND !TCPDF_STATIC::empty_string($attribs['style'])) {
// CSS style syntax
$attrval = array();
if (preg_match('/[;\"\s]{1}'.$key.'[\s]*:[\s]*([^;\"]*)/si', $attribs['style'], $attrval) AND isset($attrval[1])) {
if ($attrval[1] == 'inherit') {
$svgstyle[$key] = $val;
} else {
$svgstyle[$key] = $attrval[1];
}
}
}
}
// transformation matrix
if (!empty($ctm)) {
$tm = $ctm;
} else {
$tm = array(1,0,0,1,0,0);
}
if (isset($attribs['transform']) AND !empty($attribs['transform'])) {
$tm = TCPDF_STATIC::getTransformationMatrixProduct($tm, TCPDF_STATIC::getSVGTransformMatrix($attribs['transform']));
}
$svgstyle['transfmatrix'] = $tm;
$invisible = false;
if (($svgstyle['visibility'] == 'hidden') OR ($svgstyle['visibility'] == 'collapse') OR ($svgstyle['display'] == 'none')) {
// the current graphics element is invisible (nothing is painted)
$invisible = true;
}
// process tag
switch($name) {
case 'defs': {
$this->svgdefsmode = true;
break;
}
// clipPath
case 'clipPath': {
if ($invisible) {
break;
}
$this->svgclipmode = true;
//.........这里部分代码省略.........
示例5: getHyphenPatternsFromTEX
/**
* Returns an array of hyphenation patterns.
* @param $file (string) TEX file containing hypenation patterns. TEX pattrns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
* @return array of hyphenation patterns
* @author Nicola Asuni
* @since 4.9.012 (2010-04-12)
* @public static
*/
public static function getHyphenPatternsFromTEX($file)
{
// TEX patterns are available at:
// http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
$data = file_get_contents($file);
$patterns = array();
// remove comments
$data = preg_replace('/\\%[^\\n]*/', '', $data);
// extract the patterns part
preg_match('/\\\\patterns\\{([^\\}]*)\\}/i', $data, $matches);
$data = trim(substr($matches[0], 10, -1));
// extract each pattern
$patterns_array = preg_split('/[\\s]+/', $data);
// create new language array of patterns
$patterns = array();
foreach ($patterns_array as $val) {
if (!TCPDF_STATIC::empty_string($val)) {
$val = trim($val);
$val = str_replace('\'', '\\\'', $val);
$key = preg_replace('/[0-9]+/', '', $val);
$patterns[$key] = $val;
}
}
return $patterns;
}
示例6: utf8Bidi
/**
* Reverse the RLT substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
* @param $ta (array) array of characters composing the string.
* @param $str (string) string to process
* @param $forcertl (bool) if 'R' forces RTL, if 'L' forces LTR
* @param $isunicode (boolean) True if the document is in Unicode mode, false otherwise.
* @param $currentfont (array) Reference to current font array.
* @return array of unicode chars
* @author Nicola Asuni
* @since 2.4.000 (2008-03-06)
* @public static
*/
public static function utf8Bidi($ta, $str='', $forcertl=false, $isunicode=true, &$currentfont) {
// paragraph embedding level
$pel = 0;
// max level
$maxlevel = 0;
if (TCPDF_STATIC::empty_string($str)) {
// create string from array
$str = self::UTF8ArrSubString($ta, '', '', $isunicode);
}
// check if string contains arabic text
if (preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC, $str)) {
$arabic = true;
} else {
$arabic = false;
}
// check if string contains RTL text
if (!($forcertl OR $arabic OR preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL, $str))) {
return $ta;
}
// get number of chars
$numchars = count($ta);
if ($forcertl == 'R') {
$pel = 1;
} elseif ($forcertl == 'L') {
$pel = 0;
} else {
// P2. In each paragraph, find the first character of type L, AL, or R.
// P3. If a character is found in P2 and it is of type AL or R, then set the paragraph embedding level to one; otherwise, set it to zero.
for ($i=0; $i < $numchars; ++$i) {
$type = TCPDF_FONT_DATA::$uni_type[$ta[$i]];
if ($type == 'L') {
$pel = 0;
break;
} elseif (($type == 'AL') OR ($type == 'R')) {
$pel = 1;
break;
}
}
}
// Current Embedding Level
$cel = $pel;
// directional override status
$dos = 'N';
$remember = array();
// start-of-level-run
$sor = $pel % 2 ? 'R' : 'L';
$eor = $sor;
// Array of characters data
$chardata = Array();
// X1. Begin by setting the current embedding level to the paragraph embedding level. Set the directional override status to neutral. Process each character iteratively, applying rules X2 through X9. Only embedding levels from 0 to 61 are valid in this phase.
// In the resolution of levels in rules I1 and I2, the maximum embedding level of 62 can be reached.
for ($i=0; $i < $numchars; ++$i) {
if ($ta[$i] == TCPDF_FONT_DATA::$uni_RLE) {
// X2. With each RLE, compute the least greater odd embedding level.
// a. If this new level would be valid, then this embedding code is valid. Remember (push) the current embedding level and override status. Reset the current level to this new level, and reset the override status to neutral.
// b. If the new level would not be valid, then this code is invalid. Do not change the current level or override status.
$next_level = $cel + ($cel % 2) + 1;
if ($next_level < 62) {
$remember[] = array('num' => TCPDF_FONT_DATA::$uni_RLE, 'cel' => $cel, 'dos' => $dos);
$cel = $next_level;
$dos = 'N';
$sor = $eor;
$eor = $cel % 2 ? 'R' : 'L';
}
} elseif ($ta[$i] == TCPDF_FONT_DATA::$uni_LRE) {
// X3. With each LRE, compute the least greater even embedding level.
// a. If this new level would be valid, then this embedding code is valid. Remember (push) the current embedding level and override status. Reset the current level to this new level, and reset the override status to neutral.
// b. If the new level would not be valid, then this code is invalid. Do not change the current level or override status.
$next_level = $cel + 2 - ($cel % 2);
if ( $next_level < 62 ) {
$remember[] = array('num' => TCPDF_FONT_DATA::$uni_LRE, 'cel' => $cel, 'dos' => $dos);
$cel = $next_level;
$dos = 'N';
$sor = $eor;
$eor = $cel % 2 ? 'R' : 'L';
}
} elseif ($ta[$i] == TCPDF_FONT_DATA::$uni_RLO) {
// X4. With each RLO, compute the least greater odd embedding level.
// a. If this new level would be valid, then this embedding code is valid. Remember (push) the current embedding level and override status. Reset the current level to this new level, and reset the override status to right-to-left.
// b. If the new level would not be valid, then this code is invalid. Do not change the current level or override status.
$next_level = $cel + ($cel % 2) + 1;
if ($next_level < 62) {
$remember[] = array('num' => TCPDF_FONT_DATA::$uni_RLO, 'cel' => $cel, 'dos' => $dos);
//.........这里部分代码省略.........
示例7: getCellCode
//.........这里部分代码省略.........
break;
case 'B':
// cell bottom
$y -= $h;
break;
case 'C':
case 'M':
// cell center
$y -= $h / 2;
break;
default:
case 'T':
// cell top
break;
}
// text vertical alignment
switch ($valign) {
case 'T':
// top
$yt = $y + $this->cell_padding['T'];
break;
case 'B':
// bottom
$yt = $y + $h - $this->cell_padding['B'] - $this->FontAscent - $this->FontDescent;
break;
default:
case 'C':
case 'M':
// center
$yt = $y + ($h - $this->FontAscent - $this->FontDescent) / 2;
break;
}
$basefonty = $yt + $this->FontAscent;
if (TCPDF_STATIC::empty_string($w) or $w <= 0) {
if ($this->rtl) {
$w = $x - $this->lMargin;
} else {
$w = $this->w - $this->rMargin - $x;
}
}
$s = '';
// fill and borders
if (is_string($border) and strlen($border) == 4) {
// full border
$border = 1;
}
if ($fill or $border == 1) {
if ($fill) {
$op = $border == 1 ? 'B' : 'f';
} else {
$op = 'S';
}
if ($this->rtl) {
$xk = ($x - $w) * $k;
} else {
$xk = $x * $k;
}
$s .= sprintf('%F %F %F %F re %s ', $xk, ($this->h - $y) * $k, $w * $k, -$h * $k, $op);
}
// draw borders
$s .= $this->getCellBorder($x, $y, $w, $h, $border);
if ($txt != '') {
$txt2 = $txt;
if ($this->isunicode) {
$txt2 = $this->UTF8ToLatin2($txt2, $this->isunicode);
}
示例8: addHTMLTOC
/**
* Output a Table Of Content Index (TOC) using HTML templates.
* This method must be called after all Bookmarks were set.
* Before calling this method you have to open the page using the addTOCPage() method.
* After calling this method you have to call endTOCPage() to close the TOC page.
* @param $page (int) page number where this TOC should be inserted (leave empty for current page).
* @param $toc_name (string) name to use for TOC bookmark.
* @param $templates (array) array of html templates. Use: "#TOC_DESCRIPTION#" for bookmark title, "#TOC_PAGE_NUMBER#" for page number.
* @param $correct_align (boolean) if true correct the number alignment (numbers must be in monospaced font like courier and right aligned on LTR, or left aligned on RTL)
* @param $style (string) Font style for title: B = Bold, I = Italic, BI = Bold + Italic.
* @param $color (array) RGB color array for title (values from 0 to 255).
* @param $afterContent (string) Content to add after the TOC
* @public
* @author Nicola Asuni
* @since 5.0.001 (2010-05-06)
* @see addTOCPage(), endTOCPage(), addTOC()
*/
public function addHTMLTOC($page = '', $toc_name = 'TOC', $templates = array(), $correct_align = true, $style = '', $color = array(0, 0, 0), $afterContent = '')
{
$filler = ' ';
$prev_htmlLinkColorArray = $this->htmlLinkColorArray;
$prev_htmlLinkFontStyle = $this->htmlLinkFontStyle;
// set new style for link
$this->htmlLinkColorArray = array();
$this->htmlLinkFontStyle = '';
$page_first = $this->getPage();
$page_fill_start = false;
$page_fill_end = false;
// get the font type used for numbers in each template
$current_font = $this->FontFamily;
foreach ($templates as $level => $html) {
$dom = $this->getHtmlDomArray($html);
foreach ($dom as $key => $value) {
if ($value['value'] == '#TOC_PAGE_NUMBER#') {
$this->SetFont($dom[$key - 1]['fontname']);
$templates['F' . $level] = $this->isUnicodeFont();
}
}
}
$this->SetFont($current_font);
$maxpage = 0;
//used for pages on attached documents
foreach ($this->outlines as $key => $outline) {
// get HTML template
$row = $templates[$outline['l']];
if (\TCPDF_STATIC::empty_string($page)) {
$pagenum = $outline['p'];
} else {
// placemark to be replaced with the correct number
$pagenum = '{#' . $outline['p'] . '}';
if ($templates['F' . $outline['l']]) {
$pagenum = '{' . $pagenum . '}';
}
$maxpage = max($maxpage, $outline['p']);
}
// replace templates with current values
$row = str_replace('#TOC_DESCRIPTION#', $outline['t'], $row);
$row = str_replace('#TOC_DESCRIPTION#', $outline['t'], $row);
$row = str_replace('#TOC_CHAPTERNUMBER#', $outline['cn'], $row);
$row = str_replace('#TOC_CSSCLASS#', $outline['cssClass'], $row);
$row = str_replace('#TOC_PAGE_NUMBER#', $pagenum, $row);
// add link to page
$row = '<a href="#' . $outline['p'] . ',' . $outline['y'] . '">' . $row . '</a>';
// write bookmark entry
$this->writeHTML($row, false, false, true, false, '');
}
// restore link styles
$this->htmlLinkColorArray = $prev_htmlLinkColorArray;
$this->htmlLinkFontStyle = $prev_htmlLinkFontStyle;
// move TOC page and replace numbers
$page_last = $this->getPage();
$numpages = $page_last - $page_first + 1;
// account for booklet mode
if ($this->booklet) {
// check if a blank page is required before TOC
$page_fill_start = ($page_first % 2 == 0 xor $page % 2 == 0);
$page_fill_end = !($numpages % 2 == 0 xor $page_fill_start);
if ($page_fill_start) {
// add a page at the end (to be moved before TOC)
$this->addPage();
++$page_last;
++$numpages;
}
if ($page_fill_end) {
// add a page at the end
$this->addPage();
++$page_last;
++$numpages;
}
}
$maxpage = max($maxpage, $page_last);
if (!\TCPDF_STATIC::empty_string($page)) {
for ($p = $page_first; $p <= $page_last; ++$p) {
// get page data
$temppage = $this->getPageBuffer($p);
for ($n = 1; $n <= $maxpage; ++$n) {
// update page numbers
$a = '{#' . $n . '}';
// get page number aliases
$pnalias = $this->getInternalPageNumberAliases($a);
//.........这里部分代码省略.........