Пример #1
0
 /**
  * Returns an array of chars containing soft hyphens.
  * @param $word (array) array of chars
  * @param $patterns (array) Array of hypenation patterns.
  * @param $dictionary (array) Array of words to be returned without applying the hyphenation algoritm.
  * @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens.
  * @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens.
  * @param $charmin (int) Minimum word length to apply the hyphenation algoritm.
  * @param $charmax (int) Maximum length of broken piece of word.
  * @return array text with soft hyphens
  * @author Nicola Asuni
  * @since 4.9.012 (2010-04-12)
  * @protected
  */
 protected function hyphenateWord($word, $patterns, $dictionary = array(), $leftmin = 1, $rightmin = 2, $charmin = 1, $charmax = 8)
 {
     $hyphenword = array();
     // hyphens positions
     $numchars = count($word);
     if ($numchars <= $charmin) {
         return $word;
     }
     $word_string = TCPDF_FONTS::UTF8ArrSubString($word, '', '', $this->isunicode);
     // some words will be returned as-is
     $pattern = '/^([a-zA-Z0-9_\\.\\-]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$/';
     if (preg_match($pattern, $word_string) > 0) {
         // email
         return $word;
     }
     $pattern = '/(([a-zA-Z0-9\\-]+\\.)?)((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$/';
     if (preg_match($pattern, $word_string) > 0) {
         // URL
         return $word;
     }
     if (isset($dictionary[$word_string])) {
         return TCPDF_FONTS::UTF8StringToArray($dictionary[$word_string], $this->isunicode, $this->CurrentFont);
     }
     // suround word with '_' characters
     $tmpword = array_merge(array(95), $word, array(95));
     $tmpnumchars = $numchars + 2;
     $maxpos = $tmpnumchars - $charmin;
     for ($pos = 0; $pos < $maxpos; ++$pos) {
         $imax = min($tmpnumchars - $pos, $charmax);
         for ($i = $charmin; $i <= $imax; ++$i) {
             $subword = strtolower(TCPDF_FONTS::UTF8ArrSubString($tmpword, $pos, $pos + $i, $this->isunicode));
             if (isset($patterns[$subword])) {
                 $pattern = TCPDF_FONTS::UTF8StringToArray($patterns[$subword], $this->isunicode, $this->CurrentFont);
                 $pattern_length = count($pattern);
                 $digits = 1;
                 for ($j = 0; $j < $pattern_length; ++$j) {
                     // check if $pattern[$j] is a number
                     if ($pattern[$j] >= 48 and $pattern[$j] <= 57) {
                         if ($j == 0) {
                             $zero = $pos - 1;
                         } else {
                             $zero = $pos + $j - $digits;
                         }
                         if (!isset($hyphenword[$zero]) or $hyphenword[$zero] != $pattern[$j]) {
                             $hyphenword[$zero] = TCPDF_FONTS::unichr($pattern[$j], $this->isunicode);
                         }
                         ++$digits;
                     }
                 }
             }
         }
     }
     $inserted = 0;
     $maxpos = $numchars - $rightmin;
     for ($i = $leftmin; $i <= $maxpos; ++$i) {
         if (isset($hyphenword[$i]) and $hyphenword[$i] % 2 != 0) {
             // 173 = soft hyphen character
             array_splice($word, $i + $inserted, 0, 173);
             ++$inserted;
         }
     }
     return $word;
 }
Пример #2
0
 /**
  * Output an HTML list bullet or ordered item symbol
  * @param $listdepth (int) list nesting level
  * @param $listtype (string) type of list
  * @param $size (float) current font size
  * @protected
  * @since 4.4.004 (2008-12-10)
  */
 protected function putHtmlListBullet($listdepth, $listtype = '', $size = 10)
 {
     if ($this->state != 2) {
         return;
     }
     $size /= $this->k;
     $fill = '';
     $bgcolor = $this->bgcolor;
     $color = $this->fgcolor;
     $strokecolor = $this->strokecolor;
     $width = 0;
     $textitem = '';
     $tmpx = $this->x;
     $lspace = $this->GetStringWidth('  ');
     if ($listtype == '^') {
         // special symbol used for avoid justification of rect bullet
         $this->lispacer = '';
         return;
     } elseif ($listtype == '!') {
         // set default list type for unordered list
         $deftypes = array('disc', 'circle', 'square');
         $listtype = $deftypes[($listdepth - 1) % 3];
     } elseif ($listtype == '#') {
         // set default list type for ordered list
         $listtype = 'decimal';
     } elseif (substr($listtype, 0, 4) == 'img|') {
         // custom image type ('img|type|width|height|image.ext')
         $img = explode('|', $listtype);
         $listtype = 'img';
     }
     switch ($listtype) {
         // unordered types
         case 'none':
             break;
         case 'disc':
             $r = $size / 6;
             $lspace += 2 * $r;
             if ($this->rtl) {
                 $this->x += $lspace;
             } else {
                 $this->x -= $lspace;
             }
             $this->Circle($this->x + $r, $this->y + $this->lasth / 2, $r, 0, 360, 'F', array(), $color, 8);
             break;
         case 'circle':
             $r = $size / 6;
             $lspace += 2 * $r;
             if ($this->rtl) {
                 $this->x += $lspace;
             } else {
                 $this->x -= $lspace;
             }
             $prev_line_style = $this->linestyleWidth . ' ' . $this->linestyleCap . ' ' . $this->linestyleJoin . ' ' . $this->linestyleDash . ' ' . $this->DrawColor;
             $new_line_style = array('width' => $r / 3, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'phase' => 0, 'color' => $color);
             $this->Circle($this->x + $r, $this->y + $this->lasth / 2, $r * (1 - 1 / 6), 0, 360, 'D', $new_line_style, array(), 8);
             $this->_out($prev_line_style);
             // restore line settings
             break;
         case 'square':
             $l = $size / 3;
             $lspace += $l;
             if ($this->rtl) {
                 $this->x += $lspace;
             } else {
                 $this->x -= $lspace;
             }
             $this->Rect($this->x, $this->y + ($this->lasth - $l) / 2, $l, $l, 'F', array(), $color);
             break;
         case 'img':
             // 1=>type, 2=>width, 3=>height, 4=>image.ext
             $lspace += $img[2];
             if ($this->rtl) {
                 $this->x += $lspace;
             } else {
                 $this->x -= $lspace;
             }
             $imgtype = strtolower($img[1]);
             $prev_y = $this->y;
             switch ($imgtype) {
                 case 'svg':
                     $this->ImageSVG($img[4], $this->x, $this->y + ($this->lasth - $img[3]) / 2, $img[2], $img[3], '', 'T', '', 0, false);
                     break;
                 case 'ai':
                 case 'eps':
                     $this->ImageEps($img[4], $this->x, $this->y + ($this->lasth - $img[3]) / 2, $img[2], $img[3], '', true, 'T', '', 0, false);
                     break;
                 default:
                     $this->Image($img[4], $this->x, $this->y + ($this->lasth - $img[3]) / 2, $img[2], $img[3], $img[1], '', 'T', false, 300, '', false, false, 0, false, false, false);
                     break;
             }
             $this->y = $prev_y;
             break;
             // ordered types
             // $this->listcount[$this->listnum];
             // $textitem
         // ordered types
         // $this->listcount[$this->listnum];
         // $textitem
         case '1':
         case 'decimal':
             $textitem = $this->listcount[$this->listnum];
             break;
         case 'decimal-leading-zero':
             $textitem = sprintf('%02d', $this->listcount[$this->listnum]);
             break;
         case 'i':
         case 'lower-roman':
             $textitem = strtolower(TCPDF_STATIC::intToRoman($this->listcount[$this->listnum]));
             break;
         case 'I':
         case 'upper-roman':
             $textitem = TCPDF_STATIC::intToRoman($this->listcount[$this->listnum]);
             break;
         case 'a':
         case 'lower-alpha':
         case 'lower-latin':
             $textitem = chr(97 + $this->listcount[$this->listnum] - 1);
             break;
         case 'A':
         case 'upper-alpha':
         case 'upper-latin':
             $textitem = chr(65 + $this->listcount[$this->listnum] - 1);
             break;
         case 'lower-greek':
             $textitem = TCPDF_FONTS::unichr(945 + $this->listcount[$this->listnum] - 1, $this->isunicode);
             break;
             /*
             // Types to be implemented (special handling)
             case 'hebrew': {
             	break;
             }
             case 'armenian': {
             	break;
             }
             case 'georgian': {
             	break;
             }
             case 'cjk-ideographic': {
             	break;
             }
             case 'hiragana': {
             	break;
             }
             case 'katakana': {
             	break;
             }
             case 'hiragana-iroha': {
             	break;
             }
             case 'katakana-iroha': {
             	break;
             }
             */
         /*
         // Types to be implemented (special handling)
         case 'hebrew': {
         	break;
         }
         case 'armenian': {
         	break;
         }
         case 'georgian': {
         	break;
         }
         case 'cjk-ideographic': {
         	break;
         }
         case 'hiragana': {
         	break;
         }
         case 'katakana': {
         	break;
         }
         case 'hiragana-iroha': {
         	break;
         }
         case 'katakana-iroha': {
         	break;
         }
         */
         default:
             $textitem = $this->listcount[$this->listnum];
     }
     if (!TCPDF_STATIC::empty_string($textitem)) {
         // Check whether we need a new page or new column
         $prev_y = $this->y;
         $h = $this->getCellHeight($this->FontSize);
         if ($this->checkPageBreak($h) or $this->y < $prev_y) {
             $tmpx = $this->x;
         }
         // print ordered item
         if ($this->rtl) {
             $textitem = '.' . $textitem;
         } else {
             $textitem = $textitem . '.';
         }
         $lspace += $this->GetStringWidth($textitem);
         if ($this->rtl) {
             $this->x += $lspace;
         } else {
             $this->x -= $lspace;
         }
         $this->Write($this->lasth, $textitem, '', false, '', false, 0, false);
     }
     $this->x = $tmpx;
     $this->lispacer = '^';
     // restore colors
     $this->SetFillColorArray($bgcolor);
     $this->SetDrawColorArray($strokecolor);
     $this->SettextColorArray($color);
 }
Пример #3
0
 /**
  * Returns the PDF string code to print a cell (rectangular area) with optional borders, background color and character string. The upper-left corner of the cell corresponds to the current position. The text can be aligned or centered. After the call, the current position moves to the right or to the next line. It is possible to put a link on the text.<br />
  * If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.
  * @param $w (float) Cell width. If 0, the cell extends up to the right margin.
  * @param $h (float) Cell height. Default value: 0.
  * @param $txt (string) String to print. Default value: empty string.
  * @param $border (mixed) Indicates if borders must be drawn around the cell. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul> or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
  * @param $ln (int) Indicates where the current position should go after the call. Possible values are:<ul><li>0: to the right (or left for RTL languages)</li><li>1: to the beginning of the next line</li><li>2: below</li></ul>Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: 0.
  * @param $align (string) Allows to center or align the text. Possible values are:<ul><li>L or empty string: left align (default value)</li><li>C: center</li><li>R: right align</li><li>J: justify</li></ul>
  * @param $fill (boolean) Indicates if the cell background must be painted (true) or transparent (false).
  * @param $link (mixed) URL or identifier returned by AddLink().
  * @param $stretch (int) font stretch mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if text is larger than cell width</li><li>2 = forced horizontal scaling to fit cell width</li><li>3 = character spacing only if text is larger than cell width</li><li>4 = forced character spacing to fit cell width</li></ul> General font stretching and scaling values will be preserved when possible.
  * @param $ignore_min_height (boolean) if true ignore automatic minimum height value.
  * @param $calign (string) cell vertical alignment relative to the specified Y value. Possible values are:<ul><li>T : cell top</li><li>C : center</li><li>B : cell bottom</li><li>A : font top</li><li>L : font baseline</li><li>D : font bottom</li></ul>
  * @param $valign (string) text vertical alignment inside the cell. Possible values are:<ul><li>T : top</li><li>M : middle</li><li>B : bottom</li></ul>
  * @return string containing cell code
  * @protected
  * @since 1.0
  * @see Cell()
  */
 protected function getCellCode($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 0, $ignore_min_height = false, $calign = 'T', $valign = 'M')
 {
     // replace 'NO-BREAK SPACE' (U+00A0) character with a simple space
     $txt = str_replace(TCPDF_FONTS::unichr(160, $this->isunicode), ' ', $txt);
     $prev_cell_margin = $this->cell_margin;
     $prev_cell_padding = $this->cell_padding;
     $txt = TCPDF_STATIC::removeSHY($txt, $this->isunicode);
     $rs = '';
     //string to be returned
     $this->adjustCellPadding($border);
     if (!$ignore_min_height) {
         $min_cell_height = $this->getCellHeight($this->FontSize);
         if ($h < $min_cell_height) {
             $h = $min_cell_height;
         }
     }
     $k = $this->k;
     // check page for no-write regions and adapt page margins if necessary
     list($this->x, $this->y) = $this->checkPageRegions($h, $this->x, $this->y);
     if ($this->rtl) {
         $x = $this->x - $this->cell_margin['R'];
     } else {
         $x = $this->x + $this->cell_margin['L'];
     }
     $y = $this->y + $this->cell_margin['T'];
     $prev_font_stretching = $this->font_stretching;
     $prev_font_spacing = $this->font_spacing;
     // cell vertical alignment
     switch ($calign) {
         case 'A':
             // font top
             switch ($valign) {
                 case 'T':
                     // top
                     $y -= $this->cell_padding['T'];
                     break;
                 case 'B':
                     // bottom
                     $y -= $h - $this->cell_padding['B'] - $this->FontAscent - $this->FontDescent;
                     break;
                 default:
                 case 'C':
                 case 'M':
                     // center
                     $y -= ($h - $this->FontAscent - $this->FontDescent) / 2;
                     break;
             }
             break;
         case 'L':
             // font baseline
             switch ($valign) {
                 case 'T':
                     // top
                     $y -= $this->cell_padding['T'] + $this->FontAscent;
                     break;
                 case 'B':
                     // bottom
                     $y -= $h - $this->cell_padding['B'] - $this->FontDescent;
                     break;
                 default:
                 case 'C':
                 case 'M':
                     // center
                     $y -= ($h + $this->FontAscent - $this->FontDescent) / 2;
                     break;
             }
             break;
         case 'D':
             // font bottom
             switch ($valign) {
                 case 'T':
                     // top
                     $y -= $this->cell_padding['T'] + $this->FontAscent + $this->FontDescent;
                     break;
                 case 'B':
                     // bottom
                     $y -= $h - $this->cell_padding['B'];
                     break;
                 default:
                 case 'C':
                 case 'M':
                     // center
                     $y -= ($h + $this->FontAscent + $this->FontDescent) / 2;
                     break;
             }
             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);
         }
         $txt2 = TCPDF_STATIC::_escape($txt2);
         // get current text width (considering general font stretching and spacing)
         $txwidth = $this->GetStringWidth($txt);
         $width = $txwidth;
         // check for stretch mode
         if ($stretch > 0) {
             // calculate ratio between cell width and text width
             if ($width <= 0) {
                 $ratio = 1;
             } else {
                 $ratio = ($w - $this->cell_padding['L'] - $this->cell_padding['R']) / $width;
             }
             // check if stretching is required
             if ($ratio < 1 or $ratio > 1 and $stretch % 2 == 0) {
                 // the text will be stretched to fit cell width
                 if ($stretch > 2) {
                     // set new character spacing
                     $this->font_spacing += ($w - $this->cell_padding['L'] - $this->cell_padding['R'] - $width) / (max($this->GetNumChars($txt) - 1, 1) * ($this->font_stretching / 100));
                 } else {
                     // set new horizontal stretching
                     $this->font_stretching *= $ratio;
                 }
                 // recalculate text width (the text fills the entire cell)
                 $width = $w - $this->cell_padding['L'] - $this->cell_padding['R'];
                 // reset alignment
                 $align = '';
             }
         }
         if ($this->font_stretching != 100) {
             // apply font stretching
             $rs .= sprintf('BT %F Tz ET ', $this->font_stretching);
         }
         if ($this->font_spacing != 0) {
             // increase/decrease font spacing
             $rs .= sprintf('BT %F Tc ET ', $this->font_spacing * $this->k);
         }
         if ($this->ColorFlag and $this->textrendermode < 4) {
             $s .= 'q ' . $this->TextColor . ' ';
         }
         // rendering mode
         $s .= sprintf('BT %d Tr %F w ET ', $this->textrendermode, $this->textstrokewidth * $this->k);
         // count number of spaces
         $ns = substr_count($txt, chr(32));
         // Justification
         $spacewidth = 0;
         if ($align == 'J' and $ns > 0) {
             if ($this->isUnicodeFont()) {
                 // get string width without spaces
                 $width = $this->GetStringWidth(str_replace(' ', '', $txt));
                 // calculate average space width
                 $spacewidth = -1000 * ($w - $width - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns ? $ns : 1) / ($this->FontSize ? $this->FontSize : 1);
                 if ($this->font_stretching != 100) {
                     // word spacing is affected by stretching
                     $spacewidth /= $this->font_stretching / 100;
                 }
                 // set word position to be used with TJ operator
                 $txt2 = str_replace(chr(0) . chr(32), ') ' . sprintf('%F', $spacewidth) . ' (', $txt2);
                 $unicode_justification = true;
             } else {
                 // get string width
                 $width = $txwidth;
                 // new space width
                 $spacewidth = ($w - $width - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns ? $ns : 1) * $this->k;
                 if ($this->font_stretching != 100) {
                     // word spacing (Tw) is affected by stretching
                     $spacewidth /= $this->font_stretching / 100;
                 }
                 // set word spacing
                 $rs .= sprintf('BT %F Tw ET ', $spacewidth);
             }
             $width = $w - $this->cell_padding['L'] - $this->cell_padding['R'];
         }
         // replace carriage return characters
         $txt2 = str_replace("\r", ' ', $txt2);
         switch ($align) {
             case 'C':
                 $dx = ($w - $width) / 2;
                 break;
             case 'R':
                 if ($this->rtl) {
                     $dx = $this->cell_padding['R'];
                 } else {
                     $dx = $w - $width - $this->cell_padding['R'];
                 }
                 break;
             case 'L':
                 if ($this->rtl) {
                     $dx = $w - $width - $this->cell_padding['L'];
                 } else {
                     $dx = $this->cell_padding['L'];
                 }
                 break;
             case 'J':
             default:
                 if ($this->rtl) {
                     $dx = $this->cell_padding['R'];
                 } else {
                     $dx = $this->cell_padding['L'];
                 }
                 break;
         }
         if ($this->rtl) {
             $xdx = $x - $dx - $width;
         } else {
             $xdx = $x + $dx;
         }
         $xdk = $xdx * $k;
         // print text
         $s .= sprintf('BT %F %F Td [(%s)] TJ ET', $xdk, ($this->h - $basefonty) * $k, $txt2);
         if (isset($uniblock)) {
             // print overlapping characters as separate string
             $xshift = 0;
             // horizontal shift
             $ty = ($this->h - $basefonty + 0.2 * $this->FontSize) * $k;
             $spw = ($w - $txwidth - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns ? $ns : 1);
             foreach ($uniblock as $uk => $uniarr) {
                 if ($uk % 2 == 0) {
                     // x space to skip
                     if ($spacewidth != 0) {
                         // justification shift
                         $xshift += count(array_keys($uniarr, 32)) * $spw;
                     }
                     $xshift += $this->GetArrStringWidth($uniarr);
                     // + shift justification
                 } else {
                     // character to print
                     $topchr = TCPDF_FONTS::arrUTF8ToUTF16BE($uniarr, false);
                     $topchr = TCPDF_STATIC::_escape($topchr);
                     $s .= sprintf(' BT %F %F Td [(%s)] TJ ET', $xdk + $xshift * $k, $ty, $topchr);
                 }
             }
         }
         if ($this->underline) {
             $s .= ' ' . $this->_dounderlinew($xdx, $basefonty, $width);
         }
         if ($this->linethrough) {
             $s .= ' ' . $this->_dolinethroughw($xdx, $basefonty, $width);
         }
         if ($this->overline) {
             $s .= ' ' . $this->_dooverlinew($xdx, $basefonty, $width);
         }
         if ($this->ColorFlag and $this->textrendermode < 4) {
             $s .= ' Q';
         }
         if ($link) {
             $this->Link($xdx, $yt, $width, $this->FontAscent + $this->FontDescent, $link, $ns);
         }
     }
     // output cell
     if ($s) {
         // output cell
         $rs .= $s;
         if ($this->font_spacing != 0) {
             // reset font spacing mode
             $rs .= ' BT 0 Tc ET';
         }
         if ($this->font_stretching != 100) {
             // reset font stretching mode
             $rs .= ' BT 100 Tz ET';
         }
     }
     // reset word spacing
     if (!$this->isUnicodeFont() and $align == 'J') {
         $rs .= ' BT 0 Tw ET';
     }
     // reset stretching and spacing
     $this->font_stretching = $prev_font_stretching;
     $this->font_spacing = $prev_font_spacing;
     $this->lasth = $h;
     if ($ln > 0) {
         //Go to the beginning of the next line
         $this->y = $y + $h + $this->cell_margin['B'];
         if ($ln == 1) {
             if ($this->rtl) {
                 $this->x = $this->w - $this->rMargin;
             } else {
                 $this->x = $this->lMargin;
             }
         }
     } else {
         // go left or right by case
         if ($this->rtl) {
             $this->x = $x - $w - $this->cell_margin['L'];
         } else {
             $this->x = $x + $w + $this->cell_margin['R'];
         }
     }
     $gstyles = '' . $this->linestyleWidth . ' ' . $this->linestyleCap . ' ' . $this->linestyleJoin . ' ' . $this->linestyleDash . ' ' . $this->DrawColor . ' ' . $this->FillColor . "\n";
     $rs = $gstyles . $rs;
     $this->cell_padding = $prev_cell_padding;
     $this->cell_margin = $prev_cell_margin;
     return $rs;
 }
Пример #4
0
$core_fonts = array('courier', 'courierB', 'courierI', 'courierBI', 'helvetica', 'helveticaB', 'helveticaI', 'helveticaBI', 'times', 'timesB', 'timesI', 'timesBI', 'symbol', 'zapfdingbats');
// set fill color
$pdf->SetFillColor(221, 238, 255);
// create one HTML table for each core font
foreach ($core_fonts as $font) {
    // add a page
    $pdf->AddPage();
    // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
    // set font for title
    $pdf->SetFont('helvetica', 'B', 16);
    // print font name
    $pdf->Cell(0, 10, 'FONT: ' . $font, 1, 1, 'C', true, '', 0, false, 'T', 'M');
    // set font for chars
    $pdf->SetFont($font, '', 16);
    // print each character
    for ($i = 0; $i < 256; ++$i) {
        if ($i > 0 and $i % 16 == 0) {
            $pdf->Ln();
        }
        $pdf->Cell(11.25, 11.25, TCPDF_FONTS::unichr($i), 1, 0, 'C', false, '', 0, false, 'T', 'M');
    }
    $pdf->Ln(20);
    // print a pangram
    $pdf->Cell(0, 0, 'The quick brown fox jumps over the lazy dog', 0, 1, 'C', false, '', 0, false, 'T', 'M');
}
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_055.pdf', 'D');
//============================================================+
// END OF FILE
//============================================================+
Пример #5
-4
 public function testPdfOutput()
 {
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 055');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 055', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('helvetica', '', 14);
     // array of font names
     $core_fonts = array('courier', 'courierB', 'courierI', 'courierBI', 'helvetica', 'helveticaB', 'helveticaI', 'helveticaBI', 'times', 'timesB', 'timesI', 'timesBI', 'symbol', 'zapfdingbats');
     // set fill color
     $pdf->SetFillColor(221, 238, 255);
     // create one HTML table for each core font
     foreach ($core_fonts as $font) {
         // add a page
         $pdf->AddPage();
         // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
         // set font for title
         $pdf->SetFont('helvetica', 'B', 16);
         // print font name
         $pdf->Cell(0, 10, 'FONT: ' . $font, 1, 1, 'C', true, '', 0, false, 'T', 'M');
         // set font for chars
         $pdf->SetFont($font, '', 16);
         // print each character
         for ($i = 0; $i < 256; ++$i) {
             if ($i > 0 and $i % 16 == 0) {
                 $pdf->Ln();
             }
             $pdf->Cell(11.25, 11.25, TCPDF_FONTS::unichr($i), 1, 0, 'C', false, '', 0, false, 'T', 'M');
         }
         $pdf->Ln(20);
         // print a pangram
         $pdf->Cell(0, 0, 'The quick brown fox jumps over the lazy dog', 0, 1, 'C', false, '', 0, false, 'T', 'M');
     }
     // ---------------------------------------------------------
     $this->comparePdfs($pdf);
 }