146 if (!defined(
'K_TCPDF_EXTERNAL_CONFIG')) {
148 $tcpdf_config_files = array(dirname(__FILE__).
'/config/tcpdf_config.php',
'/etc/php-tcpdf/tcpdf_config.php',
'/etc/tcpdf/tcpdf_config.php',
'/etc/tcpdf_config.php');
149 foreach ($tcpdf_config_files as $tcpdf_config) {
150 if (file_exists($tcpdf_config) AND is_readable($tcpdf_config)) {
151 require_once($tcpdf_config);
156 if (!defined(
'K_PATH_MAIN')) {
157 $this->Error(
'Unable to include configuration file.');
163 require_once(dirname( __FILE__ ) .
'/include/tcpdf_font_data.php');
165 require_once(dirname( __FILE__ ) .
'/include/tcpdf_fonts.php');
167 require_once(dirname( __FILE__ ) .
'/include/tcpdf_colors.php');
169 require_once(dirname( __FILE__ ) .
'/include/tcpdf_images.php');
171 require_once(dirname( __FILE__ ) .
'/include/tcpdf_static.php');
338 protected $cell_margin = array(
'T' => 0,
'R' => 0,
'B' => 0,
'L' => 0);
740 protected $txtshadow = array(
'enabled'=>
false,
'depth_w'=>0,
'depth_h'=>0,
'color'=>
false,
'opacity'=>1,
'blend_mode'=>
'Normal');
1381 protected $default_form_prop = array(
'lineWidth'=>1,
'borderStyle'=>
'solid',
'fillColor'=>array(255, 255, 255),
'strokeColor'=>array(128, 128, 128));
1500 protected $colxshift = array(
'x' => 0,
's' => array(
'H' => 0,
'V' => 0),
'p' => array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0));
1724 'alignment-baseline' =>
'auto',
1725 'baseline-shift' =>
'baseline',
1727 'clip-path' =>
'none',
1728 'clip-rule' =>
'nonzero',
1730 'color-interpolation' =>
'sRGB',
1731 'color-interpolation-filters' =>
'linearRGB',
1732 'color-profile' =>
'auto',
1733 'color-rendering' =>
'auto',
1735 'direction' =>
'ltr',
1736 'display' =>
'inline',
1737 'dominant-baseline' =>
'auto',
1738 'enable-background' =>
'accumulate',
1740 'fill-opacity' => 1,
1741 'fill-rule' =>
'nonzero',
1743 'flood-color' =>
'black',
1744 'flood-opacity' => 1,
1746 'font-family' =>
'helvetica',
1747 'font-size' =>
'medium',
1748 'font-size-adjust' =>
'none',
1749 'font-stretch' =>
'normal',
1750 'font-style' =>
'normal',
1751 'font-variant' =>
'normal',
1752 'font-weight' =>
'normal',
1753 'glyph-orientation-horizontal' =>
'0deg',
1754 'glyph-orientation-vertical' =>
'auto',
1755 'image-rendering' =>
'auto',
1756 'kerning' =>
'auto',
1757 'letter-spacing' =>
'normal',
1758 'lighting-color' =>
'white',
1760 'marker-end' =>
'none',
1761 'marker-mid' =>
'none',
1762 'marker-start' =>
'none',
1765 'overflow' =>
'auto',
1766 'pointer-events' =>
'visiblePainted',
1767 'shape-rendering' =>
'auto',
1768 'stop-color' =>
'black',
1769 'stop-opacity' => 1,
1771 'stroke-dasharray' =>
'none',
1772 'stroke-dashoffset' => 0,
1773 'stroke-linecap' =>
'butt',
1774 'stroke-linejoin' =>
'miter',
1775 'stroke-miterlimit' => 4,
1776 'stroke-opacity' => 1,
1777 'stroke-width' => 1,
1778 'text-anchor' =>
'start',
1779 'text-decoration' =>
'none',
1780 'text-rendering' =>
'auto',
1781 'unicode-bidi' =>
'normal',
1782 'visibility' =>
'visible',
1783 'word-spacing' =>
'normal',
1784 'writing-mode' =>
'lr-tb',
1785 'text-color' =>
'black',
1786 'transfmatrix' => array(1, 0, 0, 1, 0, 0)
1830 protected $overprint = array(
'OP' =>
false,
'op' =>
false,
'OPM' => 0);
1838 protected $alpha = array(
'CA' => 1,
'ca' => 1,
'BM' =>
'/Normal',
'AIS' =>
false);
1845 protected $page_boxes = array(
'MediaBox',
'CropBox',
'BleedBox',
'TrimBox',
'ArtBox');
1880 if (function_exists(
'mb_internal_encoding') AND mb_internal_encoding()) {
1881 $this->internal_encoding = mb_internal_encoding();
1882 mb_internal_encoding(
'ASCII');
1884 $this->font_obj_ids = array();
1885 $this->page_obj_id = array();
1886 $this->form_obj_id = array();
1888 $this->pdfa_mode = $pdfa;
1889 $this->force_srgb =
false;
1891 $this->diskcache =
$diskcache ?
true :
false;
1894 $this->tmprtl =
false;
1898 $this->isunicode = $unicode;
1900 $this->transfmrk[0] = array();
1901 $this->pagedim = array();
1904 $this->pages = array();
1906 $this->fonts = array();
1907 $this->FontFiles = array();
1908 $this->diffs = array();
1909 $this->images = array();
1910 $this->links = array();
1911 $this->gradients = array();
1912 $this->InFooter =
false;
1914 $this->FontFamily = defined(
'PDF_FONT_NAME_MAIN')?PDF_FONT_NAME_MAIN:
'helvetica';
1915 $this->FontStyle =
'';
1916 $this->FontSizePt = 12;
1917 $this->underline =
false;
1918 $this->overline =
false;
1919 $this->linethrough =
false;
1920 $this->DrawColor =
'0 G';
1921 $this->FillColor =
'0 g';
1922 $this->TextColor =
'0 g';
1923 $this->ColorFlag =
false;
1924 $this->pdflayers = array();
1926 $this->encrypted =
false;
1927 $this->last_enc_key =
'';
1929 $this->CoreFonts = array(
1930 'courier'=>
'Courier',
1931 'courierB'=>
'Courier-Bold',
1932 'courierI'=>
'Courier-Oblique',
1933 'courierBI'=>
'Courier-BoldOblique',
1934 'helvetica'=>
'Helvetica',
1935 'helveticaB'=>
'Helvetica-Bold',
1936 'helveticaI'=>
'Helvetica-Oblique',
1937 'helveticaBI'=>
'Helvetica-BoldOblique',
1938 'times'=>
'Times-Roman',
1939 'timesB'=>
'Times-Bold',
1940 'timesI'=>
'Times-Italic',
1941 'timesBI'=>
'Times-BoldItalic',
1943 'zapfdingbats'=>
'ZapfDingbats'
1955 $cpadding = $margin / 10;
1960 $this->LineWidth = 0.57 /
$this->k;
1961 $this->linestyleWidth = sprintf(
'%F w', ($this->LineWidth * $this->k));
1962 $this->linestyleCap =
'0 J';
1963 $this->linestyleJoin =
'0 j';
1964 $this->linestyleDash =
'[] 0 d';
1973 $this->tcpdflink =
true;
1975 $this->HREF = array();
1977 $this->fgcolor = array(
'R' => 0,
'G' => 0,
'B' => 0);
1978 $this->strokecolor = array(
'R' => 0,
'G' => 0,
'B' => 0);
1979 $this->bgcolor = array(
'R' => 255,
'G' => 255,
'B' => 255);
1980 $this->extgstates = array();
1983 $this->sign =
false;
1984 $this->ur[
'enabled'] =
false;
1985 $this->ur[
'document'] =
'/FullSave';
1986 $this->ur[
'annots'] =
'/Create/Delete/Modify/Copy/Import/Export';
1987 $this->ur[
'form'] =
'/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate';
1988 $this->ur[
'signature'] =
'/Modify';
1989 $this->ur[
'ef'] =
'/Create/Delete/Modify/Import';
1990 $this->ur[
'formex'] =
'';
1991 $this->signature_appearance = array(
'page' => 1,
'rect' =>
'0 0 0 0');
1992 $this->empty_signature_appearance = array();
1994 $this->jpeg_quality = 75;
1998 $this->
SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
2000 if ($this->isunicode AND (@preg_match(
'/\pL/u',
'a') == 1)) {
2011 $this->default_form_prop = array(
'lineWidth'=>1,
'borderStyle'=>
'solid',
'fillColor'=>array(255, 255, 255),
'strokeColor'=>array(128, 128, 128));
2013 $serformat = (is_array($format) ? serialize($format) : $format);
2016 $this->doc_creation_timestamp = time();
2020 $this->header_xobj_autoreset =
false;
2021 $this->custom_xmp =
'';
2031 if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
2032 mb_internal_encoding($this->internal_encoding);
2045 $unit = strtolower($unit);
2056 $this->k = $this->dpi / 25.4;
2061 $this->k = $this->dpi / 2.54;
2071 $this->
Error(
'Incorrect unit: '.$unit);
2075 $this->pdfunit = $unit;
2076 if (isset($this->CurOrientation)) {
2137 if (!empty($format) AND isset($this->pagedim[$this->page])) {
2139 unset($this->pagedim[$this->page]);
2141 if (is_string($format)) {
2144 $this->fwPt = $pf[0];
2145 $this->fhPt = $pf[1];
2148 if (isset($format[
'MediaBox'])) {
2149 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'MediaBox', $format[
'MediaBox'][
'llx'], $format[
'MediaBox'][
'lly'], $format[
'MediaBox'][
'urx'], $format[
'MediaBox'][
'ury'],
false, $this->k, $this->pagedim);
2150 $this->fwPt = (($format[
'MediaBox'][
'urx'] - $format[
'MediaBox'][
'llx']) * $this->k);
2151 $this->fhPt = (($format[
'MediaBox'][
'ury'] - $format[
'MediaBox'][
'lly']) * $this->k);
2153 if (isset($format[0]) AND is_numeric($format[0]) AND isset($format[1]) AND is_numeric($format[1])) {
2154 $pf = array(($format[0] * $this->k), ($format[1] * $this->k));
2156 if (!isset($format[
'format'])) {
2158 $format[
'format'] =
'A4';
2162 $this->fwPt = $pf[0];
2163 $this->fhPt = $pf[1];
2164 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'MediaBox', 0, 0, $this->fwPt, $this->fhPt,
true, $this->k, $this->pagedim);
2167 if (isset($format[
'CropBox'])) {
2168 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'CropBox', $format[
'CropBox'][
'llx'], $format[
'CropBox'][
'lly'], $format[
'CropBox'][
'urx'], $format[
'CropBox'][
'ury'],
false, $this->k, $this->pagedim);
2171 if (isset($format[
'BleedBox'])) {
2172 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'BleedBox', $format[
'BleedBox'][
'llx'], $format[
'BleedBox'][
'lly'], $format[
'BleedBox'][
'urx'], $format[
'BleedBox'][
'ury'],
false, $this->k, $this->pagedim);
2175 if (isset($format[
'TrimBox'])) {
2176 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'TrimBox', $format[
'TrimBox'][
'llx'], $format[
'TrimBox'][
'lly'], $format[
'TrimBox'][
'urx'], $format[
'TrimBox'][
'ury'],
false, $this->k, $this->pagedim);
2179 if (isset($format[
'ArtBox'])) {
2180 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'ArtBox', $format[
'ArtBox'][
'llx'], $format[
'ArtBox'][
'lly'], $format[
'ArtBox'][
'urx'], $format[
'ArtBox'][
'ury'],
false, $this->k, $this->pagedim);
2183 if (isset($format[
'BoxColorInfo'])) {
2184 $this->pagedim[
$this->page][
'BoxColorInfo'] = $format[
'BoxColorInfo'];
2186 if (isset($format[
'Rotate']) AND (($format[
'Rotate'] % 90) == 0)) {
2188 $this->pagedim[
$this->page][
'Rotate'] = intval($format[
'Rotate']);
2190 if (isset($format[
'PZ'])) {
2192 $this->pagedim[
$this->page][
'PZ'] = floatval($format[
'PZ']);
2194 if (isset($format[
'trans'])) {
2196 if (isset($format[
'trans'][
'Dur'])) {
2198 $this->pagedim[
$this->page][
'trans'][
'Dur'] = floatval($format[
'trans'][
'Dur']);
2200 $stansition_styles = array(
'Split',
'Blinds',
'Box',
'Wipe',
'Dissolve',
'Glitter',
'R',
'Fly',
'Push',
'Cover',
'Uncover',
'Fade');
2201 if (isset($format[
'trans'][
'S']) AND in_array($format[
'trans'][
'S'], $stansition_styles)) {
2203 $this->pagedim[
$this->page][
'trans'][
'S'] = $format[
'trans'][
'S'];
2204 $valid_effect = array(
'Split',
'Blinds');
2205 $valid_vals = array(
'H',
'V');
2206 if (isset($format[
'trans'][
'Dm']) AND in_array($format[
'trans'][
'S'], $valid_effect) AND in_array($format[
'trans'][
'Dm'], $valid_vals)) {
2207 $this->pagedim[
$this->page][
'trans'][
'Dm'] = $format[
'trans'][
'Dm'];
2209 $valid_effect = array(
'Split',
'Box',
'Fly');
2210 $valid_vals = array(
'I',
'O');
2211 if (isset($format[
'trans'][
'M']) AND in_array($format[
'trans'][
'S'], $valid_effect) AND in_array($format[
'trans'][
'M'], $valid_vals)) {
2212 $this->pagedim[
$this->page][
'trans'][
'M'] = $format[
'trans'][
'M'];
2214 $valid_effect = array(
'Wipe',
'Glitter',
'Fly',
'Cover',
'Uncover',
'Push');
2215 if (isset($format[
'trans'][
'Di']) AND in_array($format[
'trans'][
'S'], $valid_effect)) {
2216 if (((($format[
'trans'][
'Di'] == 90) OR ($format[
'trans'][
'Di'] == 180)) AND ($format[
'trans'][
'S'] ==
'Wipe'))
2217 OR (($format[
'trans'][
'Di'] == 315) AND ($format[
'trans'][
'S'] ==
'Glitter'))
2218 OR (($format[
'trans'][
'Di'] == 0) OR ($format[
'trans'][
'Di'] == 270))) {
2219 $this->pagedim[
$this->page][
'trans'][
'Di'] = intval($format[
'trans'][
'Di']);
2222 if (isset($format[
'trans'][
'SS']) AND ($format[
'trans'][
'S'] ==
'Fly')) {
2223 $this->pagedim[
$this->page][
'trans'][
'SS'] = floatval($format[
'trans'][
'SS']);
2225 if (isset($format[
'trans'][
'B']) AND ($format[
'trans'][
'B'] ===
true) AND ($format[
'trans'][
'S'] ==
'Fly')) {
2226 $this->pagedim[
$this->page][
'trans'][
'B'] =
'true';
2231 if (isset($format[
'trans'][
'D'])) {
2233 $this->pagedim[
$this->page][
'trans'][
'D'] = floatval($format[
'trans'][
'D']);
2251 if (!isset($this->pagedim[$this->page][
'MediaBox'])) {
2253 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'MediaBox', 0, 0, $this->fwPt, $this->fhPt,
true, $this->k, $this->pagedim);
2255 if (!isset($this->pagedim[$this->page][
'CropBox'])) {
2257 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'CropBox', $this->pagedim[$this->page][
'MediaBox'][
'llx'], $this->pagedim[$this->page][
'MediaBox'][
'lly'], $this->pagedim[$this->page][
'MediaBox'][
'urx'], $this->pagedim[$this->page][
'MediaBox'][
'ury'],
true, $this->k, $this->pagedim);
2259 if (!isset($this->pagedim[$this->page][
'BleedBox'])) {
2261 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'BleedBox', $this->pagedim[$this->page][
'CropBox'][
'llx'], $this->pagedim[$this->page][
'CropBox'][
'lly'], $this->pagedim[$this->page][
'CropBox'][
'urx'], $this->pagedim[$this->page][
'CropBox'][
'ury'],
true, $this->k, $this->pagedim);
2263 if (!isset($this->pagedim[$this->page][
'TrimBox'])) {
2265 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'TrimBox', $this->pagedim[$this->page][
'CropBox'][
'llx'], $this->pagedim[$this->page][
'CropBox'][
'lly'], $this->pagedim[$this->page][
'CropBox'][
'urx'], $this->pagedim[$this->page][
'CropBox'][
'ury'],
true, $this->k, $this->pagedim);
2267 if (!isset($this->pagedim[$this->page][
'ArtBox'])) {
2269 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'ArtBox', $this->pagedim[$this->page][
'CropBox'][
'llx'], $this->pagedim[$this->page][
'CropBox'][
'lly'], $this->pagedim[$this->page][
'CropBox'][
'urx'], $this->pagedim[$this->page][
'CropBox'][
'ury'],
true, $this->k, $this->pagedim);
2271 if (!isset($this->pagedim[$this->page][
'Rotate'])) {
2275 if (!isset($this->pagedim[$this->page][
'PZ'])) {
2279 if ($this->fwPt > $this->fhPt) {
2281 $default_orientation =
'L';
2284 $default_orientation =
'P';
2286 $valid_orientations = array(
'P',
'L');
2287 if (empty($orientation)) {
2288 $orientation = $default_orientation;
2290 $orientation = strtoupper($orientation{0});
2292 if (in_array($orientation, $valid_orientations) AND ($orientation != $default_orientation)) {
2293 $this->CurOrientation = $orientation;
2297 $this->CurOrientation = $default_orientation;
2301 if ((abs($this->pagedim[$this->page][
'MediaBox'][
'urx'] - $this->hPt) < $this->feps) AND (abs($this->pagedim[$this->page][
'MediaBox'][
'ury'] - $this->wPt) < $this->feps)){
2305 $this->w = ($this->wPt /
$this->k);
2306 $this->h = ($this->hPt /
$this->k);
2308 if (isset($this->AutoPageBreak)) {
2311 $autopagebreak =
true;
2315 if (isset($this->bMargin)) {
2319 $bottommargin = 2 * 28.35 /
$this->k;
2329 $this->pagedim[
$this->page][
'bm'] = $bottommargin;
2332 $this->pagedim[
$this->page][
'pb'] = $autopagebreak;
2356 $this->re_spaces = $re;
2357 $re_parts = explode(
'/', $re);
2359 $this->re_space = array();
2360 if (isset($re_parts[1]) AND !empty($re_parts[1])) {
2361 $this->re_space[
'p'] = $re_parts[1];
2363 $this->re_space[
'p'] =
'[\s]';
2366 if (isset($re_parts[2]) AND !empty($re_parts[2])) {
2367 $this->re_space[
'm'] = $re_parts[2];
2369 $this->re_space[
'm'] =
'';
2380 public function setRTL($enable, $resetx=
true) {
2381 $enable = $enable ?
true :
false;
2382 $resetx = ($resetx AND ($enable != $this->rtl));
2383 $this->rtl = $enable;
2384 $this->tmprtl =
false;
2408 switch (strtoupper($mode)) {
2429 $this->tmprtl = $newmode;
2439 return ($this->rtl OR ($this->tmprtl ==
'R'));
2480 $this->imgscale = $scale;
2504 if (empty($pagenum)) {
2507 return $this->pagedim[$pagenum];
2520 if (empty($pagenum)) {
2523 return $this->pagedim[$pagenum][
'w'];
2536 if (empty($pagenum)) {
2539 return $this->pagedim[$pagenum][
'h'];
2552 if (empty($pagenum)) {
2555 return $this->pagedim[$pagenum][
'bm'];
2579 public function SetMargins($left, $top, $right=-1, $keepmargins=
false) {
2581 $this->lMargin = $left;
2582 $this->tMargin = $top;
2586 $this->rMargin = $right;
2603 $this->lMargin = $margin;
2604 if (($this->page > 0) AND ($this->x < $margin)) {
2618 $this->tMargin = $margin;
2619 if (($this->page > 0) AND ($this->y < $margin)) {
2632 $this->rMargin = $margin;
2633 if (($this->page > 0) AND ($this->x > ($this->w - $margin))) {
2634 $this->x = $this->w - $margin;
2647 $this->cell_padding[
'L'] = $pad;
2648 $this->cell_padding[
'T'] = $pad;
2649 $this->cell_padding[
'R'] = $pad;
2650 $this->cell_padding[
'B'] = $pad;
2665 if (($left !==
'') AND ($left >= 0)) {
2666 $this->cell_padding[
'L'] = $left;
2668 if (($top !==
'') AND ($top >= 0)) {
2669 $this->cell_padding[
'T'] = $top;
2671 if (($right !==
'') AND ($right >= 0)) {
2672 $this->cell_padding[
'R'] = $right;
2674 if (($bottom !==
'') AND ($bottom >= 0)) {
2675 $this->cell_padding[
'B'] = $bottom;
2701 if (($left !==
'') AND ($left >= 0)) {
2702 $this->cell_margin[
'L'] = $left;
2704 if (($top !==
'') AND ($top >= 0)) {
2705 $this->cell_margin[
'T'] = $top;
2707 if (($right !==
'') AND ($right >= 0)) {
2708 $this->cell_margin[
'R'] = $right;
2710 if (($bottom !==
'') AND ($bottom >= 0)) {
2711 $this->cell_margin[
'B'] = $bottom;
2737 if (is_string($brd)) {
2739 $slen = strlen($brd);
2741 for ($i = 0; $i < $slen; ++$i) {
2742 $newbrd[$brd[$i]] =
true;
2745 } elseif (($brd === 1) OR ($brd ===
true) OR (is_numeric($brd) AND (intval($brd) > 0))) {
2746 $brd = array(
'LRTB' =>
true);
2748 if (!is_array($brd)) {
2754 if (isset($brd[
'mode'])) {
2755 $mode = $brd[
'mode'];
2756 unset($brd[
'mode']);
2761 foreach ($brd as $border => $style) {
2763 if (is_array($style) AND isset($style[
'width'])) {
2765 $line_width = $style[
'width'];
2779 $adj = ($line_width / 2);
2784 if ((strpos($border,
'T') !==
false) AND ($this->cell_padding[
'T'] < $adj)) {
2785 $this->cell_padding[
'T'] = $adj;
2787 if ((strpos($border,
'R') !==
false) AND ($this->cell_padding[
'R'] < $adj)) {
2788 $this->cell_padding[
'R'] = $adj;
2790 if ((strpos($border,
'B') !==
false) AND ($this->cell_padding[
'B'] < $adj)) {
2791 $this->cell_padding[
'B'] = $adj;
2793 if ((strpos($border,
'L') !==
false) AND ($this->cell_padding[
'L'] < $adj)) {
2794 $this->cell_padding[
'L'] = $adj;
2797 return array(
'T' => ($this->cell_padding[
'T'] - $cp[
'T']),
'R' => ($this->cell_padding[
'R'] - $cp[
'R']),
'B' => ($this->cell_padding[
'B'] - $cp[
'B']),
'L' => ($this->cell_padding[
'L'] - $cp[
'L']));
2809 $this->AutoPageBreak = $auto ?
true :
false;
2810 $this->bMargin = $margin;
2811 $this->PageBreakTrigger = $this->h - $margin;
2833 if (($zoom ==
'fullpage') OR ($zoom ==
'fullwidth') OR ($zoom ==
'real') OR ($zoom ==
'default') OR (!is_string($zoom))) {
2834 $this->ZoomMode = $zoom;
2836 $this->
Error(
'Incorrect zoom display mode: '.$zoom);
2850 if (function_exists(
'gzcompress')) {
2851 $this->compress =
$compress ?
true :
false;
2853 $this->compress =
false;
2864 $this->force_srgb = $mode ?
true :
false;
2875 $this->docinfounicode = $unicode ?
true :
false;
2943 $phpmainver = PHP_VERSION;
2945 if ((intval($phpmainver[0]) < 5) OR !defined(
'K_TCPDF_THROW_EXCEPTION_ERROR') OR !K_TCPDF_THROW_EXCEPTION_ERROR) {
2946 die(
'<strong>TCPDF ERROR: </strong>'.$msg);
2948 throw new Exception(
'TCPDF ERROR: '.$msg);
2973 if ($this->state == 3) {
2976 if ($this->page == 0) {
2980 if ($this->tcpdflink) {
2984 $this->lastpage(
true);
2987 $this->y = $this->h - (1 /
$this->k);
2990 $font = defined(
'PDF_FONT_NAME_MAIN')?PDF_FONT_NAME_MAIN:
'helvetica';
2993 $msg =
"\x50\x6f\x77\x65\x72\x65\x64\x20\x62\x79\x20\x54\x43\x50\x44\x46\x20\x28\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67\x29";
2994 $lnk =
"\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67";
2995 $this->
Cell(0, 0, $msg, 0, 0,
'L', 0, $lnk, 0,
false,
'D',
'B');
3016 public function setPage($pnum, $resetmargins=
false) {
3017 if (($pnum == $this->page) AND ($this->state == 2)) {
3020 if (($pnum > 0) AND ($pnum <= $this->numpages)) {
3025 $this->page = $pnum;
3030 $this->tMargin = $this->pagedim[
$this->page][
'tm'];
3031 $this->bMargin = $this->pagedim[
$this->page][
'bm'];
3032 $this->original_lMargin = $this->pagedim[
$this->page][
'olm'];
3033 $this->original_rMargin = $this->pagedim[
$this->page][
'orm'];
3034 $this->AutoPageBreak = $this->pagedim[
$this->page][
'pb'];
3035 $this->CurOrientation = $this->pagedim[
$this->page][
'or'];
3039 if ($resetmargins) {
3040 $this->lMargin = $this->pagedim[
$this->page][
'olm'];
3041 $this->rMargin = $this->pagedim[
$this->page][
'orm'];
3042 $this->
SetY($this->tMargin);
3045 if ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$oldpage][
'olm']) {
3047 $this->lMargin += $deltam;
3048 $this->rMargin -= $deltam;
3052 $this->
Error(
'Wrong page number on setPage() function: '.$pnum);
3098 public function addTOCPage($orientation=
'', $format=
'', $keepmargins=
false) {
3099 $this->
AddPage($orientation, $format, $keepmargins,
true);
3123 public function AddPage($orientation=
'', $format=
'', $keepmargins=
false,
$tocpage=
false) {
3124 if ($this->inxobj) {
3128 if (!isset($this->original_lMargin) OR $keepmargins) {
3131 if (!isset($this->original_rMargin) OR $keepmargins) {
3149 if (($this->page == 0) OR ($this->numpages > $this->page) OR (!$this->pageopen[$this->page])) {
3159 $this->tocpage =
false;
3175 $this->tocpage =
true;
3178 if ($this->tocpage) {
3182 foreach ($tmpoutlines as $key => $outline) {
3183 if ($outline[
'p'] > $this->numpages) {
3184 $this->outlines[$key][
'p'] = ($outline[
'p'] + 1);
3189 foreach ($tmpdests as $key => $dest) {
3190 if ($dest[
'p'] > $this->numpages) {
3191 $this->dests[$key][
'p'] = ($dest[
'p'] + 1);
3196 foreach ($tmplinks as $key => $link) {
3197 if ($link[0] > $this->numpages) {
3198 $this->links[$key][0] = ($link[0] + 1);
3202 if ($this->numpages > $this->page) {
3204 $this->
setPage($this->page + 1);
3205 $this->
SetY($this->tMargin);
3209 if ($this->state == 0) {
3261 if (isset($this->footerlen[
$page])) {
3262 $this->cntmrk[
$page] = $this->pagelen[
$page] - $this->footerlen[
$page];
3264 $this->cntmrk[
$page] = $this->pagelen[
$page];
3278 public function setHeaderData($ln=
'', $lw=0, $ht=
'', $hs=
'', $tc=array(0,0,0), $lc=array(0,0,0)) {
3279 $this->header_logo = $ln;
3280 $this->header_logo_width = $lw;
3281 $this->header_title = $ht;
3282 $this->header_string = $hs;
3283 $this->header_text_color = $tc;
3284 $this->header_line_color = $lc;
3294 $this->footer_text_color = $tc;
3295 $this->footer_line_color = $lc;
3323 $this->header_margin = $hm;
3343 $this->footer_margin = $fm;
3361 $this->print_header = $val ?
true :
false;
3370 $this->print_footer = $val ?
true :
false;
3396 $this->header_xobjid = -1;
3405 $this->header_xobj_autoreset = $val ?
true :
false;
3414 if ($this->header_xobjid < 0) {
3416 $this->header_xobjid = $this->
startTemplate($this->w, $this->tMargin);
3425 if (($headerdata[
'logo']) AND ($headerdata[
'logo'] != K_BLANK_IMAGE)) {
3427 if (($imgtype ==
'eps') OR ($imgtype ==
'ai')) {
3428 $this->
ImageEps(K_PATH_IMAGES.$headerdata[
'logo'],
'',
'', $headerdata[
'logo_width']);
3429 } elseif ($imgtype ==
'svg') {
3430 $this->
ImageSVG(K_PATH_IMAGES.$headerdata[
'logo'],
'',
'', $headerdata[
'logo_width']);
3432 $this->
Image(K_PATH_IMAGES.$headerdata[
'logo'],
'',
'', $headerdata[
'logo_width']);
3438 $cell_height = round(($this->cell_height_ratio * $headerfont[2]) / $this->k, 2);
3441 $header_x = $this->original_rMargin + ($headerdata[
'logo_width'] * 1.1);
3443 $header_x = $this->original_lMargin + ($headerdata[
'logo_width'] * 1.1);
3445 $cw = $this->w - $this->original_lMargin - $this->original_rMargin - ($headerdata[
'logo_width'] * 1.1);
3448 $this->
SetFont($headerfont[0],
'B', $headerfont[2] + 1);
3449 $this->
SetX($header_x);
3450 $this->
Cell($cw, $cell_height, $headerdata[
'title'], 0, 1,
'', 0,
'', 0);
3452 $this->
SetFont($headerfont[0], $headerfont[1], $headerfont[2]);
3453 $this->
SetX($header_x);
3454 $this->
MultiCell($cw, $cell_height, $headerdata[
'string'], 0,
'', 0, 1,
'',
'',
true, 0,
false,
true, 0,
'T',
false);
3456 $this->
SetLineStyle(array(
'width' => 0.85 / $this->k,
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $headerdata[
'line_color']));
3457 $this->
SetY((2.835 / $this->k) + max($imgy, $this->y));
3459 $this->
SetX($this->original_rMargin);
3461 $this->
SetX($this->original_lMargin);
3463 $this->
Cell(($this->w - $this->original_lMargin - $this->original_rMargin), 0,
'',
'T', 0,
'C');
3469 if (!$this->header_xobj_autoreset AND $this->booklet AND (($this->page % 2) == 0)) {
3474 $x = $this->w + $dx;
3478 $this->
printTemplate($this->header_xobjid,
$x, 0, 0, 0,
'',
'',
false);
3479 if ($this->header_xobj_autoreset) {
3481 $this->header_xobjid = -1;
3495 $this->
SetLineStyle(array(
'width' => $line_width,
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $this->footer_line_color));
3499 $this->
Ln($line_width);
3500 $barcode_width = round(($this->w - $this->original_lMargin - $this->original_rMargin) / 3);
3502 'position' => $this->rtl?
'R':
'L',
3503 'align' => $this->rtl?
'R':
'L',
3506 'cellfitalign' =>
'',
3509 'fgcolor' => array(0,0,0),
3513 $this->
write1DBarcode(
$barcode,
'C128',
'', $cur_y + $line_width,
'', (($this->footer_margin / 3) - $line_width), 0.3, $style,
'');
3515 $w_page = isset($this->l[
'w_page']) ? $this->l[
'w_page'].
' ' :
'';
3516 if (empty($this->pagegroups)) {
3517 $pagenumtxt = $w_page.$this->getAliasNumPage().
' / '.$this->
getAliasNbPages();
3519 $pagenumtxt = $w_page.$this->getPageNumGroupAlias().
' / '.$this->
getPageGroupAlias();
3521 $this->
SetY($cur_y);
3524 $this->
SetX($this->original_rMargin);
3525 $this->
Cell(0, 0, $pagenumtxt,
'T', 0,
'L');
3527 $this->
SetX($this->original_lMargin);
3538 if (!$this->print_header OR ($this->state != 2)) {
3541 $this->InHeader =
true;
3552 $this->
SetXY($this->original_rMargin, $this->header_margin);
3554 $this->
SetXY($this->original_lMargin, $this->header_margin);
3556 $this->
SetFont($this->header_font[0], $this->header_font[1], $this->header_font[2]);
3560 $this->
SetXY($this->original_rMargin, $this->tMargin);
3562 $this->
SetXY($this->original_lMargin, $this->tMargin);
3566 $this->thead = $temp_thead;
3567 $this->theadMargins = $temp_theadMargins;
3568 $this->newline =
false;
3569 $this->InHeader =
false;
3578 if ($this->state != 2) {
3581 $this->InFooter =
true;
3587 if ($this->print_footer) {
3589 $this->current_column = 0;
3590 $this->num_columns = 1;
3601 $this->
SetXY($this->original_rMargin, $footer_y);
3603 $this->
SetXY($this->original_lMargin, $footer_y);
3605 $this->
SetFont($this->footer_font[0], $this->footer_font[1], $this->footer_font[2]);
3609 $this->
SetXY($this->original_rMargin, $this->tMargin);
3611 $this->
SetXY($this->original_lMargin, $this->tMargin);
3615 $this->thead = $temp_thead;
3616 $this->theadMargins = $temp_theadMargins;
3620 $this->current_column = $gvars[
'current_column'];
3621 $this->num_columns = $gvars[
'num_columns'];
3624 $this->InFooter =
false;
3634 return (($this->InHeader ===
false) AND ($this->InFooter ===
false));
3643 if ($this->num_columns > 1) {
3647 if (isset($this->theadMargins[
'top'])) {
3649 $this->tMargin = $this->theadMargins[
'top'];
3658 $this->lMargin = $this->theadMargins[
'lmargin'] + ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$this->theadMargins[
'page']][
'olm']);
3659 $this->rMargin = $this->theadMargins[
'rmargin'] + ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$this->theadMargins[
'page']][
'orm']);
3660 $this->cell_padding = $this->theadMargins[
'cell_padding'];
3667 if ($this->theadMargins[
'cell']) {
3669 $this->x -= $this->cell_padding[
'R'];
3671 $this->x += $this->cell_padding[
'L'];
3675 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
3677 if (!isset($this->theadMargins[
'top'])) {
3681 if (!isset($this->columns[0][
'th'])) {
3682 $this->columns[0][
'th'] = array();
3684 $this->columns[0][
'th'][
'\''.$this->page.
'\''] =
$this->y;
3688 $this->lMargin = $prev_lMargin;
3689 $this->rMargin = $prev_rMargin;
3690 $this->cell_padding = $prev_cell_padding;
3719 if (!isset($this->spot_colors[$name])) {
3720 $i = (1 + count($this->spot_colors));
3721 $this->spot_colors[$name] = array(
'C' => $c,
'M' => $m,
'Y' =>
$y,
'K' =>
$k,
'name' => $name,
'i' => $i);
3736 if ($spotcolor ===
false) {
3737 $this->
Error(
'Undefined spot color: '.$name.
', you must add it on the spotcolors.php file.');
3739 $tint = (max(0, min(100, $tint)) / 100);
3740 $pdfcolor = sprintf(
'/CS%d ', $this->spot_colors[$name][
'i']);
3743 $pdfcolor .= sprintf(
'CS %F SCN', $tint);
3744 $this->DrawColor = $pdfcolor;
3745 $this->strokecolor = $spotcolor;
3749 $pdfcolor .= sprintf(
'cs %F scn', $tint);
3750 $this->FillColor = $pdfcolor;
3751 $this->bgcolor = $spotcolor;
3755 $pdfcolor .= sprintf(
'cs %F scn', $tint);
3756 $this->TextColor = $pdfcolor;
3757 $this->fgcolor = $spotcolor;
3762 if ($this->state == 2) {
3763 $this->
_out($pdfcolor);
3765 if ($this->inxobj) {
3767 $this->xobjects[
$this->xobjid][
'spot_colors'][$name] = $this->spot_colors[$name];
3820 if (is_array($color)) {
3821 $color = array_values($color);
3823 $c = isset($color[0]) ? $color[0] : -1;
3825 $m = isset($color[1]) ? $color[1] : -1;
3827 $y = isset($color[2]) ? $color[2] : -1;
3829 $k = isset($color[3]) ? $color[3] : -1;
3831 $name = isset($color[4]) ? $color[4] :
'';
3894 public function setColor($type, $col1=0, $col2=-1, $col3=-1, $col4=-1,
$ret=
false, $name=
'') {
3896 if (!is_numeric($col1)) {
3899 if (!is_numeric($col2)) {
3902 if (!is_numeric($col3)) {
3905 if (!is_numeric($col4)) {
3910 if (($col2 == -1) AND ($col3 == -1) AND ($col4 == -1)) {
3912 $col1 = max(0, min(255, $col1));
3913 $intcolor = array(
'G' => $col1);
3914 $pdfcolor = sprintf(
'%F ', ($col1 / 255));
3916 } elseif ($col4 == -1) {
3918 $col1 = max(0, min(255, $col1));
3919 $col2 = max(0, min(255, $col2));
3920 $col3 = max(0, min(255, $col3));
3921 $intcolor = array(
'R' => $col1,
'G' => $col2,
'B' => $col3);
3922 $pdfcolor = sprintf(
'%F %F %F ', ($col1 / 255), ($col2 / 255), ($col3 / 255));
3925 $col1 = max(0, min(100, $col1));
3926 $col2 = max(0, min(100, $col2));
3927 $col3 = max(0, min(100, $col3));
3928 $col4 = max(0, min(100, $col4));
3931 $intcolor = array(
'C' => $col1,
'M' => $col2,
'Y' => $col3,
'K' => $col4);
3932 $pdfcolor = sprintf(
'%F %F %F %F ', ($col1 / 100), ($col2 / 100), ($col3 / 100), ($col4 / 100));
3936 $intcolor = array(
'C' => $col1,
'M' => $col2,
'Y' => $col3,
'K' => $col4,
'name' => $name);
3937 $this->
AddSpotColor($name, $col1, $col2, $col3, $col4);
3943 $pdfcolor .= strtoupper($suffix);
3944 $this->DrawColor = $pdfcolor;
3945 $this->strokecolor = $intcolor;
3949 $pdfcolor .= $suffix;
3950 $this->FillColor = $pdfcolor;
3951 $this->bgcolor = $intcolor;
3955 $pdfcolor .= $suffix;
3956 $this->TextColor = $pdfcolor;
3957 $this->fgcolor = $intcolor;
3962 if (($type !=
'text') AND ($this->state == 2)) {
3964 $this->
_out($pdfcolor);
3985 return $this->
setColor(
'draw', $col1, $col2, $col3, $col4,
$ret, $name);
4002 return $this->
setColor(
'fill', $col1, $col2, $col3, $col4,
$ret, $name);
4019 return $this->
setColor(
'text', $col1, $col2, $col3, $col4,
$ret, $name);
4034 public function GetStringWidth($s, $fontname=
'', $fontstyle=
'', $fontsize=0, $getarray=
false) {
4035 return $this->
GetArrStringWidth(
TCPDF_FONTS::utf8Bidi(
TCPDF_FONTS::UTF8StringToArray($s, $this->isunicode, $this->CurrentFont), $s, $this->tmprtl, $this->isunicode, $this->CurrentFont), $fontname, $fontstyle, $fontsize, $getarray);
4056 $this->
SetFont($fontname, $fontstyle, $fontsize,
'',
'default',
false);
4064 foreach ($sa as $ck => $char) {
4066 $cw = $this->
GetCharWidth($char, isset($sa[($ck + 1)]));
4072 $this->
SetFont($prev_FontFamily, $prev_FontStyle, $prev_FontSizePt,
'',
'default',
false);
4092 if (($this->font_spacing < 0) OR (($this->font_spacing > 0) AND $notlast)) {
4096 if ($this->font_stretching != 100) {
4098 $chw *= ($this->font_stretching / 100);
4116 if (isset($this->CurrentFont[
'cw'][$char])) {
4117 $w = $this->CurrentFont[
'cw'][$char];
4118 } elseif (isset($this->CurrentFont[
'dw'])) {
4120 $w = $this->CurrentFont[
'dw'];
4121 } elseif (isset($this->CurrentFont[
'cw'][32])) {
4123 $w = $this->CurrentFont[
'cw'][32];
4151 while ((
$file = readdir($fontsdir)) !==
false) {
4152 if (substr(
$file, -4) ==
'.php') {
4153 array_push($this->fontlist, strtolower(basename(
$file,
'.php')));
4156 closedir($fontsdir);
4188 public function addTTFfont($fontfile, $fonttype=
'', $enc=
'', $flags=32, $outpath=
'', $platid=3, $encid=1, $addcbbox=
false) {
4205 public function AddFont($family, $style=
'', $fontfile=
'', $subset=
'default') {
4206 if ($subset ===
'default') {
4209 if ($this->pdfa_mode) {
4216 $this->
Error(
'Empty font family');
4220 if (substr($family, -1) ==
'I') {
4222 $family = substr($family, 0, -1);
4224 if (substr($family, -1) ==
'B') {
4226 $family = substr($family, 0, -1);
4229 $family = strtolower($family);
4230 if ((!$this->isunicode) AND ($family ==
'arial')) {
4231 $family =
'helvetica';
4233 if (($family ==
'symbol') OR ($family ==
'zapfdingbats')) {
4236 if ($this->pdfa_mode AND (isset($this->CoreFonts[$family]))) {
4238 $family =
'pdfa'.$family;
4240 $tempstyle = strtoupper($style);
4243 if (strpos($tempstyle,
'U') !==
false) {
4244 $this->underline =
true;
4246 $this->underline =
false;
4249 if (strpos($tempstyle,
'D') !==
false) {
4250 $this->linethrough =
true;
4252 $this->linethrough =
false;
4255 if (strpos($tempstyle,
'O') !==
false) {
4256 $this->overline =
true;
4258 $this->overline =
false;
4261 if (strpos($tempstyle,
'B') !==
false) {
4265 if (strpos($tempstyle,
'I') !==
false) {
4269 $fontkey = $family.$style;
4270 $font_style = $style.($this->underline ?
'U' :
'').($this->linethrough ?
'D' :
'').($this->overline ?
'O' :
'');
4271 $fontdata = array(
'fontkey' => $fontkey,
'family' => $family,
'style' => $font_style);
4274 if ($fb !==
false) {
4275 if ($this->inxobj) {
4277 $this->xobjects[
$this->xobjid][
'fonts'][$fontkey] = $fb[
'i'];
4284 $fontdir = dirname($fontfile);
4291 $missing_style =
false;
4295 $tmp_fontfile = str_replace(
' ',
'', $family).strtolower($style).
'.php';
4297 if (($fontdir !==
false) AND file_exists($fontdir.$tmp_fontfile)) {
4298 $fontfile = $fontdir.$tmp_fontfile;
4301 } elseif (file_exists($tmp_fontfile)) {
4302 $fontfile = $tmp_fontfile;
4304 $missing_style =
true;
4306 $tmp_fontfile = str_replace(
' ',
'', $family).
'.php';
4307 if (($fontdir !==
false) AND file_exists($fontdir.$tmp_fontfile)) {
4308 $fontfile = $fontdir.$tmp_fontfile;
4312 $fontfile = $tmp_fontfile;
4317 if (file_exists($fontfile)) {
4320 $this->
Error(
'Could not include font definition file: '.$family.
'');
4323 if ((!isset($type)) OR (!isset($cw))) {
4324 $this->
Error(
'The font definition file has a bad format: '.$fontfile.
'');
4334 $cidinfo = array(
'Registry'=>
'Adobe',
'Ordering'=>
'Identity',
'Supplement'=>0);
4335 $cidinfo[
'uni2cid'] = array();
4354 if (isset($desc[
'MissingWidth']) AND ($desc[
'MissingWidth'] > 0)) {
4355 $dw = $desc[
'MissingWidth'];
4356 } elseif (isset($cw[32])) {
4363 if ($type ==
'core') {
4364 $name = $this->CoreFonts[$fontkey];
4366 } elseif (($type ==
'TrueType') OR ($type ==
'Type1')) {
4368 } elseif ($type ==
'TrueTypeUnicode') {
4369 $enc =
'Identity-H';
4370 } elseif ($type ==
'cidfont0') {
4371 if ($this->pdfa_mode) {
4372 $this->
Error(
'All fonts must be embedded in PDF/A mode!');
4375 $this->
Error(
'Unknow font type: '.$type.
'');
4378 if (!isset($name) OR empty($name)) {
4382 if (($type !=
'core') AND $missing_style) {
4384 $styles = array(
'' =>
'',
'B' =>
',Bold',
'I' =>
',Italic',
'BI' =>
',BoldItalic');
4385 $name .= $styles[$bistyle];
4387 if (strpos($bistyle,
'B') !==
false) {
4388 if (isset($desc[
'StemV'])) {
4390 $desc[
'StemV'] = round($desc[
'StemV'] * 1.75);
4393 $desc[
'StemV'] = 123;
4397 if (strpos($bistyle,
'I') !==
false) {
4398 if (isset($desc[
'ItalicAngle'])) {
4399 $desc[
'ItalicAngle'] -= 11;
4401 $desc[
'ItalicAngle'] = -11;
4403 if (isset($desc[
'Flags'])) {
4404 $desc[
'Flags'] |= 64;
4406 $desc[
'Flags'] = 64;
4411 if (!isset($cbbox)) {
4415 $subsetchars = array_fill(0, 255,
true);
4416 $this->
setFontBuffer($fontkey, array(
'fontkey' => $fontkey,
'i' => $this->numfonts,
'type' => $type,
'name' => $name,
'desc' => $desc,
'up' => $up,
'ut' => $ut,
'cw' => $cw,
'cbbox' => $cbbox,
'dw' => $dw,
'enc' => $enc,
'cidinfo' => $cidinfo,
'file' =>
$file,
'ctg' => $ctg,
'subset' => $subset,
'subsetchars' => $subsetchars));
4417 if ($this->inxobj) {
4421 if (isset($diff) AND (!empty($diff))) {
4424 $nb = count($this->diffs);
4425 for ($i=1; $i <= $nb; ++$i) {
4426 if ($this->diffs[$i] == $diff) {
4433 $this->diffs[
$d] = $diff;
4438 if (!isset($this->FontFiles[
$file])) {
4439 if ((strcasecmp($type,
'TrueType') == 0) OR (strcasecmp($type,
'TrueTypeUnicode') == 0)) {
4440 $this->FontFiles[
$file] = array(
'length1' => $originalsize,
'fontdir' => $fontdir,
'subset' => $subset,
'fontkeys' => array($fontkey));
4441 } elseif ($type !=
'core') {
4442 $this->FontFiles[
$file] = array(
'length1' => $size1,
'length2' => $size2,
'fontdir' => $fontdir,
'subset' => $subset,
'fontkeys' => array($fontkey));
4446 $this->FontFiles[
$file][
'subset'] = ($this->FontFiles[
$file][
'subset'] AND $subset);
4447 if (!in_array($fontkey, $this->FontFiles[$file][
'fontkeys'])) {
4448 $this->FontFiles[
$file][
'fontkeys'][] = $fontkey;
4472 public function SetFont($family, $style=
'',
$size=null, $fontfile=
'', $subset=
'default',
$out=
true) {
4474 if (
$size === null) {
4481 $fontdata = $this->
AddFont($family, $style, $fontfile, $subset);
4482 $this->FontFamily = $fontdata[
'family'];
4483 $this->FontStyle = $fontdata[
'style'];
4484 if (isset($this->CurrentFont[
'fontkey']) AND isset($this->CurrentFont[
'subsetchars'])) {
4486 $this->
setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
4488 $this->CurrentFont = $this->
getFontBuffer($fontdata[
'fontkey']);
4502 $this->FontSizePt =
$size;
4506 if (isset($this->CurrentFont[
'desc'][
'FontBBox'])) {
4507 $bbox = explode(
' ', substr($this->CurrentFont[
'desc'][
'FontBBox'], 1, -1));
4508 $font_height = ((intval($bbox[3]) - intval($bbox[1])) *
$size / 1000);
4510 $font_height =
$size * 1.219;
4512 if (isset($this->CurrentFont[
'desc'][
'Ascent']) AND ($this->CurrentFont[
'desc'][
'Ascent'] > 0)) {
4513 $font_ascent = ($this->CurrentFont[
'desc'][
'Ascent'] *
$size / 1000);
4515 if (isset($this->CurrentFont[
'desc'][
'Descent']) AND ($this->CurrentFont[
'desc'][
'Descent'] <= 0)) {
4516 $font_descent = (- $this->CurrentFont[
'desc'][
'Descent'] *
$size / 1000);
4518 if (!isset($font_ascent) AND !isset($font_descent)) {
4520 $font_ascent = 0.76 * $font_height;
4521 $font_descent = $font_height - $font_ascent;
4522 } elseif (!isset($font_descent)) {
4523 $font_descent = $font_height - $font_ascent;
4524 } elseif (!isset($font_ascent)) {
4525 $font_ascent = $font_height - $font_descent;
4527 $this->FontAscent = ($font_ascent /
$this->k);
4528 $this->FontDescent = ($font_descent /
$this->k);
4529 if (
$out AND ($this->page > 0) AND (isset($this->CurrentFont[
'i'])) AND ($this->state == 2)) {
4530 $this->
_out(sprintf(
'BT /F%d %F Tf ET', $this->CurrentFont[
'i'], $this->FontSizePt));
4542 if (isset($this->CurrentFont[
'desc'][
'FontBBox'])) {
4543 $tmpbbox = explode(
' ', substr($this->CurrentFont[
'desc'][
'FontBBox'], 1, -1));
4544 $fbbox = array_map(array($this,
'getAbsFontMeasure'), $tmpbbox);
4547 if (isset($this->CurrentFont[
'desc'][
'MaxWidth'])) {
4548 $maxw = $this->
getAbsFontMeasure(intval($this->CurrentFont[
'desc'][
'MaxWidth']));
4551 if (isset($this->CurrentFont[
'desc'][
'MissingWidth'])) {
4552 $maxw = max($maxw, $this->CurrentFont[
'desc'][
'MissingWidth']);
4554 if (isset($this->CurrentFont[
'desc'][
'AvgWidth'])) {
4555 $maxw = max($maxw, $this->CurrentFont[
'desc'][
'AvgWidth']);
4557 if (isset($this->CurrentFont[
'dw'])) {
4558 $maxw = max($maxw, $this->CurrentFont[
'dw']);
4560 foreach ($this->CurrentFont[
'cw'] as $char =>
$w) {
4561 $maxw = max($maxw,
$w);
4568 $fbbox = array(0, (0 - $this->FontDescent), $maxw, $this->FontAscent);
4580 return ($s * $this->FontSize / 1000);
4590 if (isset($this->CurrentFont[
'cbbox'][$char])) {
4591 return array_map(array($this,
'getAbsFontMeasure'), $this->CurrentFont[
'cbbox'][intval($char)]);
4607 $fontdata = $this->
AddFont($font, $style);
4609 if (isset($fontinfo[
'desc'][
'Descent']) AND ($fontinfo[
'desc'][
'Descent'] <= 0)) {
4610 $descent = (- $fontinfo[
'desc'][
'Descent'] *
$size / 1000);
4612 $descent = (1.219 * 0.24 *
$size);
4614 return ($descent / $this->k);
4628 $fontdata = $this->
AddFont($font, $style);
4630 if (isset($fontinfo[
'desc'][
'Ascent']) AND ($fontinfo[
'desc'][
'Ascent'] > 0)) {
4631 $ascent = ($fontinfo[
'desc'][
'Ascent'] *
$size / 1000);
4633 $ascent = 1.219 * 0.76 *
$size;
4635 return ($ascent / $this->k);
4648 if (is_string($char)) {
4655 return (isset($this->CurrentFont[
'cw'][intval($char)]));
4659 $fontdata = $this->
AddFont($font, $style);
4661 return (isset($fontinfo[
'cw'][intval($char)]));
4681 $fontdata = $this->
AddFont($font, $style);
4684 foreach ($uniarr as
$k => $chr) {
4685 if (!isset($fontinfo[
'cw'][$chr])) {
4687 if (isset($subs[$chr])) {
4689 if (is_array($subs[$chr])) {
4690 foreach($subs[$chr] as $s) {
4691 if (isset($fontinfo[
'cw'][$s])) {
4696 } elseif (isset($fontinfo[
'cw'][$subs[$chr]])) {
4697 $uniarr[
$k] = $subs[$chr];
4712 $this->default_monospaced_font = $font;
4724 $n = count($this->links) + 1;
4725 $this->links[
$n] = array(0, 0);
4745 $this->links[$link] = array(
$page,
$y);
4779 if ($this->inxobj) {
4781 $this->xobjects[
$this->xobjid][
'annotations'][] = array(
'x' =>
$x,
'y' =>
$y,
'w' =>
$w,
'h' =>
$h,
'text' => $text,
'opt' => $opt,
'spaces' => $spaces);
4793 if (isset($this->transfmatrix) AND !empty($this->transfmatrix)) {
4794 for ($i=$this->transfmatrix_key; $i > 0; --$i) {
4795 $maxid = count($this->transfmatrix[$i]) - 1;
4796 for ($j=$maxid; $j >= 0; --$j) {
4797 $ctm = $this->transfmatrix[$i][$j];
4798 if (isset($ctm[
'a'])) {
4800 $y = ($this->h -
$y) * $this->k;
4806 $x1 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4807 $y1 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4811 $x2 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4812 $y2 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4816 $x3 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4817 $y3 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4821 $x4 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4822 $y4 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4824 $x = min($x1, $x2, $x3, $x4);
4825 $y = max($y1, $y2, $y3, $y4);
4826 $w = (max($x1, $x2, $x3, $x4) -
$x) / $this->k;
4827 $h = (
$y - min($y1, $y2, $y3, $y4)) / $this->k;
4834 if ($this->page <= 0) {
4839 if (!isset($this->PageAnnots[
$page])) {
4840 $this->PageAnnots[
$page] = array();
4842 $this->PageAnnots[
$page][] = array(
'n' => ++$this->
n,
'x' =>
$x,
'y' =>
$y,
'w' =>
$w,
'h' =>
$h,
'txt' => $text,
'opt' => $opt,
'numspaces' => $spaces);
4843 if (!$this->pdfa_mode) {
4846 AND (!isset($this->embeddedfiles[basename($opt[
'FS'])]))) {
4847 $this->embeddedfiles[basename($opt[
'FS'])] = array(
'f' => ++$this->
n,
'n' => ++$this->
n,
'file' => $opt[
'FS']);
4851 if (isset($opt[
'mk'][
'i']) AND file_exists($opt[
'mk'][
'i'])) {
4852 $this->
Image($opt[
'mk'][
'i'],
'',
'', 10, 10,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
4854 if (isset($opt[
'mk'][
'ri']) AND file_exists($opt[
'mk'][
'ri'])) {
4855 $this->
Image($opt[
'mk'][
'ri'],
'',
'', 0, 0,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
4857 if (isset($opt[
'mk'][
'ix']) AND file_exists($opt[
'mk'][
'ix'])) {
4858 $this->
Image($opt[
'mk'][
'ix'],
'',
'', 0, 0,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
4869 if ($this->pdfa_mode) {
4873 reset($this->embeddedfiles);
4874 foreach ($this->embeddedfiles as
$filename => $filedata) {
4876 $this->efnames[
$filename] = $filedata[
'f'].
' 0 R';
4879 $out .=
'<</Type /Filespec /F '.$this->_datastring(
$filename, $filedata[
'f']).
' /EF <</F '.$filedata[
'n'].
' 0 R>> >>';
4880 $out .=
"\n".
'endobj';
4883 $data = file_get_contents($filedata[
'file']);
4885 $rawsize = strlen($data);
4886 if ($this->compress) {
4887 $data = gzcompress($data);
4888 $filter =
' /Filter /FlateDecode';
4892 $out .=
'<< /Type /EmbeddedFile'.$filter.
' /Length '.strlen($stream).
' /Params <</Size '.$rawsize.
'>> >>';
4893 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
4894 $out .=
"\n".
'endobj';
4922 public function Text(
$x,
$y,
$txt, $fstroke=
false, $fclip=
false, $ffill=
true, $border=0, $ln=0, $align=
'', $fill=
false, $link=
'', $stretch=0, $ignore_min_height=
false, $calign=
'T', $valign=
'M', $rtloff=
false) {
4927 $this->
Cell(0, 0,
$txt, $border, $ln, $align, $fill, $link, $stretch, $ignore_min_height, $calign, $valign);
4943 if ($this->num_columns > 1) {
4945 if ($this->current_column < ($this->num_columns - 1)) {
4948 } elseif ($this->AutoPageBreak) {
4978 $this->
AddPage($this->CurOrientation);
4980 $oldpage = $this->page - 1;
4982 if ($this->pagedim[$this->page][
'orm'] != $this->pagedim[$oldpage][
'orm']) {
4983 $this->x =
$x - ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$oldpage][
'orm']);
4988 if ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$oldpage][
'olm']) {
4989 $this->x =
$x + ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$oldpage][
'olm']);
4997 if ($current_page != $this->page) {
5023 public function Cell(
$w,
$h=0,
$txt=
'', $border=0, $ln=0, $align=
'', $fill=
false, $link=
'', $stretch=0, $ignore_min_height=
false, $calign=
'T', $valign=
'M') {
5027 if (!$ignore_min_height) {
5028 $min_cell_height = ($this->FontSize *
$this->cell_height_ratio) + $this->cell_padding[
'T'] + $this->cell_padding[
'B'];
5029 if (
$h < $min_cell_height) {
5030 $h = $min_cell_height;
5033 $this->
checkPageBreak(
$h + $this->cell_margin[
'T'] + $this->cell_margin[
'B']);
5035 if ($this->txtshadow[
'enabled']) {
5044 $this->x += $this->txtshadow[
'depth_w'];
5045 $this->y += $this->txtshadow[
'depth_h'];
5049 if ($this->txtshadow[
'opacity'] !=
$alpha[
'CA']) {
5050 $this->
setAlpha($this->txtshadow[
'opacity'], $this->txtshadow[
'blend_mode']);
5052 if ($this->state == 2) {
5053 $this->
_out($this->
getCellCode(
$w,
$h,
$txt, $border, $ln, $align, $fill, $link, $stretch,
true, $calign, $valign));
5061 if ($this->txtshadow[
'opacity'] !=
$alpha[
'CA']) {
5065 if ($this->state == 2) {
5066 $this->
_out($this->
getCellCode(
$w,
$h,
$txt, $border, $ln, $align, $fill, $link, $stretch,
true, $calign, $valign));
5068 $this->cell_padding = $prev_cell_padding;
5069 $this->cell_margin = $prev_cell_margin;
5092 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') {
5100 if (!$ignore_min_height) {
5101 $min_cell_height = ($this->FontSize *
$this->cell_height_ratio) + $this->cell_padding[
'T'] + $this->cell_padding[
'B'];
5102 if (
$h < $min_cell_height) {
5103 $h = $min_cell_height;
5110 $x = $this->x - $this->cell_margin[
'R'];
5112 $x = $this->x + $this->cell_margin[
'L'];
5114 $y = $this->y + $this->cell_margin[
'T'];
5124 $y -= $this->cell_padding[
'T'];
5175 $y -= (
$h - $this->cell_padding[
'B']);
5209 $yt =
$y + $this->cell_padding[
'T'];
5230 $w = $this->w - $this->rMargin -
$x;
5235 if (is_string($border) AND (strlen($border) == 4)) {
5239 if ($fill OR ($border == 1)) {
5241 $op = ($border == 1) ?
'B' :
'f';
5250 $s .= sprintf(
'%F %F %F %F re %s ', $xk, (($this->h -
$y) *
$k), (
$w * $k), (-
$h * $k), $op);
5256 if ($this->isunicode) {
5257 if (($this->CurrentFont[
'type'] ==
'core') OR ($this->CurrentFont[
'type'] ==
'TrueType') OR ($this->CurrentFont[
'type'] ==
'Type1')) {
5261 $unicode =
TCPDF_FONTS::utf8Bidi($unicode,
'', $this->tmprtl, $this->isunicode, $this->CurrentFont);
5263 if (defined(
'K_THAI_TOPCHARS') AND (K_THAI_TOPCHARS ==
true)) {
5265 $numchars = count($unicode);
5267 $longtail = array(0x0e1b, 0x0e1d, 0x0e1f);
5269 $lowtail = array(0x0e0e, 0x0e0f);
5271 $upvowel = array(0x0e31, 0x0e34, 0x0e35, 0x0e36, 0x0e37);
5273 $tonemark = array(0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c);
5275 $lowvowel = array(0x0e38, 0x0e39, 0x0e3a);
5277 for ($i = 0; $i < $numchars; $i++) {
5278 if (($unicode[$i] >= 0x0e00) && ($unicode[$i] <= 0x0e5b)) {
5279 $ch0 = $unicode[$i];
5280 $ch1 = ($i > 0) ? $unicode[($i - 1)] : 0;
5281 $ch2 = ($i > 1) ? $unicode[($i - 2)] : 0;
5282 $chn = ($i < ($numchars - 1)) ? $unicode[($i + 1)] : 0;
5283 if (in_array($ch0, $tonemark)) {
5284 if ($chn == 0x0e33) {
5286 if (in_array($ch1, $longtail)) {
5288 $output[] = $this->
replaceChar($ch0, (0xf713 + $ch0 - 0x0e48));
5293 } elseif (in_array($ch1, $longtail) OR (in_array($ch2, $longtail) AND in_array($ch1, $lowvowel))) {
5295 $output[] = $this->
replaceChar($ch0, (0xf705 + $ch0 - 0x0e48));
5296 } elseif (in_array($ch1, $upvowel)) {
5297 if (in_array($ch2, $longtail)) {
5299 $output[] = $this->
replaceChar($ch0, (0xf713 + $ch0 - 0x0e48));
5306 $output[] = $this->
replaceChar($ch0, (0xf70a + $ch0 - 0x0e48));
5308 } elseif (($ch0 == 0x0e33) AND (in_array($ch1, $longtail) OR (in_array($ch2, $longtail) AND in_array($ch1, $tonemark)))) {
5312 $this->CurrentFont[
'subsetchars'][0xf711] =
true;
5314 $this->CurrentFont[
'subsetchars'][0x0e32] =
true;
5318 } elseif (in_array($ch1, $longtail)) {
5319 if ($ch0 == 0x0e31) {
5322 } elseif (in_array($ch0, $upvowel)) {
5324 $output[] = $this->
replaceChar($ch0, (0xf701 + $ch0 - 0x0e34));
5325 } elseif ($ch0 == 0x0e47) {
5332 } elseif (in_array($ch1, $lowtail) AND in_array($ch0, $lowvowel)) {
5334 $output[] = $this->
replaceChar($ch0, (0xf718 + $ch0 - 0x0e38));
5335 } elseif (($ch0 == 0x0e0d) AND in_array($chn, $lowvowel)) {
5338 } elseif (($ch0 == 0x0e10) AND in_array($chn, $lowvowel)) {
5346 $output[] = $unicode[$i];
5351 $this->
setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
5366 $ratio = ((
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / $width);
5369 if (($ratio < 1) OR (($ratio > 1) AND (($stretch % 2) == 0))) {
5373 $this->font_spacing += (
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'] - $width) / (max(($this->
GetNumChars(
$txt) - 1), 1) * ($this->font_stretching / 100));
5376 $this->font_stretching *= $ratio;
5379 $width =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
5384 if ($this->font_stretching != 100) {
5386 $rs .= sprintf(
'BT %F Tz ET ', $this->font_stretching);
5388 if ($this->font_spacing != 0) {
5390 $rs .= sprintf(
'BT %F Tc ET ', ($this->font_spacing * $this->k));
5392 if ($this->ColorFlag AND ($this->textrendermode < 4)) {
5393 $s .=
'q '.$this->TextColor.
' ';
5396 $s .= sprintf(
'BT %d Tr %F w ET ', $this->textrendermode, ($this->textstrokewidth * $this->k));
5398 $ns = substr_count(
$txt, chr(32));
5401 if (($align ==
'J') AND ($ns > 0)) {
5406 $spacewidth = -1000 * (
$w - $width - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1) /
$this->FontSize;
5407 if ($this->font_stretching != 100) {
5409 $spacewidth /= ($this->font_stretching / 100);
5412 $txt2 = str_replace(chr(0).chr(32),
') '.sprintf(
'%F', $spacewidth).
' (', $txt2);
5413 $unicode_justification =
true;
5418 $spacewidth = ((
$w - $width - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1)) * $this->k;
5419 if ($this->font_stretching != 100) {
5421 $spacewidth /= ($this->font_stretching / 100);
5424 $rs .= sprintf(
'BT %F Tw ET ', $spacewidth);
5426 $width =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
5429 $txt2 = str_replace(
"\r",
' ', $txt2);
5432 $dx = (
$w - $width) / 2;
5437 $dx = $this->cell_padding[
'R'];
5439 $dx =
$w - $width - $this->cell_padding[
'R'];
5445 $dx =
$w - $width - $this->cell_padding[
'L'];
5447 $dx = $this->cell_padding[
'L'];
5454 $dx = $this->cell_padding[
'R'];
5456 $dx = $this->cell_padding[
'L'];
5462 $xdx =
$x - $dx - $width;
5468 $s .= sprintf(
'BT %F %F Td [(%s)] TJ ET', $xdk, (($this->h - $basefonty) * $k), $txt2);
5469 if (isset($uniblock)) {
5473 $spw = ((
$w - $txwidth - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1));
5474 foreach ($uniblock as $uk => $uniarr) {
5475 if (($uk % 2) == 0) {
5477 if ($spacewidth != 0) {
5479 $xshift += (count(array_keys($uniarr, 32)) * $spw);
5486 $s .= sprintf(
' BT %F %F Td [(%s)] TJ ET', ($xdk + ($xshift * $k)), $ty, $topchr);
5490 if ($this->underline) {
5491 $s .=
' '.$this->_dounderlinew($xdx, $basefonty, $width);
5493 if ($this->linethrough) {
5494 $s .=
' '.$this->_dolinethroughw($xdx, $basefonty, $width);
5496 if ($this->overline) {
5497 $s .=
' '.$this->_dooverlinew($xdx, $basefonty, $width);
5499 if ($this->ColorFlag AND ($this->textrendermode < 4)) {
5503 $this->
Link($xdx, $yt, $width, ($this->FontAscent + $this->FontDescent), $link, $ns);
5510 if ($this->font_spacing != 0) {
5512 $rs .=
' BT 0 Tc ET';
5514 if ($this->font_stretching != 100) {
5516 $rs .=
' BT 100 Tz ET';
5521 $rs .=
' BT 0 Tw ET';
5524 $this->font_stretching = $prev_font_stretching;
5525 $this->font_spacing = $prev_font_spacing;
5529 $this->y =
$y +
$h + $this->cell_margin[
'B'];
5540 $this->x =
$x -
$w - $this->cell_margin[
'L'];
5542 $this->x =
$x +
$w + $this->cell_margin[
'R'];
5545 $gstyles =
''.$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' '.$this->FillColor.
"\n";
5547 $this->cell_padding = $prev_cell_padding;
5548 $this->cell_margin = $prev_cell_margin;
5563 $this->CurrentFont[
'subsetchars'][$newchar] =
true;
5589 $brd = array(
'LRTB' =>
true);
5598 $xeR = (
$x +
$w) * $k;
5600 $yeL = (($this->h - (
$y +
$h)) *
$k);
5601 $yeT = (($this->h -
$y) *
$k);
5606 if (is_string($brd)) {
5608 $slen = strlen($brd);
5610 for ($i = 0; $i < $slen; ++$i) {
5611 $newbrd[$brd[$i]] = array(
'cap' =>
'square',
'join' =>
'miter');
5615 if (isset($brd[
'mode'])) {
5616 $mode = $brd[
'mode'];
5617 unset($brd[
'mode']);
5621 foreach ($brd as $border => $style) {
5622 if (is_array($style) AND !empty($style)) {
5624 $prev_style = $this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' ';
5629 $off = (($this->LineWidth / 2) *
$k);
5643 $off = ($this->LineWidth / 2) *
$k;
5670 if (strlen($border) == 4) {
5671 $s .= sprintf(
'%F %F %F %F re S ', $xT, $yT, (
$w *
$k), (-
$h * $k));
5672 } elseif (strlen($border) == 3) {
5673 if (strpos($border,
'B') ===
false) {
5674 $s .= sprintf(
'%F %F m ', $xL, $yL);
5675 $s .= sprintf(
'%F %F l ', $xT, $yT);
5676 $s .= sprintf(
'%F %F l ', $xR, $yR);
5677 $s .= sprintf(
'%F %F l ', $xB, $yB);
5679 } elseif (strpos($border,
'L') ===
false) {
5680 $s .= sprintf(
'%F %F m ', $xT, $yT);
5681 $s .= sprintf(
'%F %F l ', $xR, $yR);
5682 $s .= sprintf(
'%F %F l ', $xB, $yB);
5683 $s .= sprintf(
'%F %F l ', $xL, $yL);
5685 } elseif (strpos($border,
'T') ===
false) {
5686 $s .= sprintf(
'%F %F m ', $xR, $yR);
5687 $s .= sprintf(
'%F %F l ', $xB, $yB);
5688 $s .= sprintf(
'%F %F l ', $xL, $yL);
5689 $s .= sprintf(
'%F %F l ', $xT, $yT);
5691 } elseif (strpos($border,
'R') ===
false) {
5692 $s .= sprintf(
'%F %F m ', $xB, $yB);
5693 $s .= sprintf(
'%F %F l ', $xL, $yL);
5694 $s .= sprintf(
'%F %F l ', $xT, $yT);
5695 $s .= sprintf(
'%F %F l ', $xR, $yR);
5698 } elseif (strlen($border) == 2) {
5699 if ((strpos($border,
'L') !==
false) AND (strpos($border,
'T') !==
false)) {
5700 $s .= sprintf(
'%F %F m ', $xL, $yL);
5701 $s .= sprintf(
'%F %F l ', $xT, $yT);
5702 $s .= sprintf(
'%F %F l ', $xR, $yR);
5704 } elseif ((strpos($border,
'T') !==
false) AND (strpos($border,
'R') !==
false)) {
5705 $s .= sprintf(
'%F %F m ', $xT, $yT);
5706 $s .= sprintf(
'%F %F l ', $xR, $yR);
5707 $s .= sprintf(
'%F %F l ', $xB, $yB);
5709 } elseif ((strpos($border,
'R') !==
false) AND (strpos($border,
'B') !==
false)) {
5710 $s .= sprintf(
'%F %F m ', $xR, $yR);
5711 $s .= sprintf(
'%F %F l ', $xB, $yB);
5712 $s .= sprintf(
'%F %F l ', $xL, $yL);
5714 } elseif ((strpos($border,
'B') !==
false) AND (strpos($border,
'L') !==
false)) {
5715 $s .= sprintf(
'%F %F m ', $xB, $yB);
5716 $s .= sprintf(
'%F %F l ', $xL, $yL);
5717 $s .= sprintf(
'%F %F l ', $xT, $yT);
5719 } elseif ((strpos($border,
'L') !==
false) AND (strpos($border,
'R') !==
false)) {
5720 $s .= sprintf(
'%F %F m ', $xL, $yL);
5721 $s .= sprintf(
'%F %F l ', $xT, $yT);
5723 $s .= sprintf(
'%F %F m ', $xR, $yR);
5724 $s .= sprintf(
'%F %F l ', $xB, $yB);
5726 } elseif ((strpos($border,
'T') !==
false) AND (strpos($border,
'B') !==
false)) {
5727 $s .= sprintf(
'%F %F m ', $xT, $yT);
5728 $s .= sprintf(
'%F %F l ', $xR, $yR);
5730 $s .= sprintf(
'%F %F m ', $xB, $yB);
5731 $s .= sprintf(
'%F %F l ', $xL, $yL);
5735 if (strpos($border,
'L') !==
false) {
5736 $s .= sprintf(
'%F %F m ', $xL, $yL);
5737 $s .= sprintf(
'%F %F l ', $xT, $yT);
5739 } elseif (strpos($border,
'T') !==
false) {
5740 $s .= sprintf(
'%F %F m ', $xT, $yT);
5741 $s .= sprintf(
'%F %F l ', $xR, $yR);
5743 } elseif (strpos($border,
'R') !==
false) {
5744 $s .= sprintf(
'%F %F m ', $xR, $yR);
5745 $s .= sprintf(
'%F %F l ', $xB, $yB);
5747 } elseif (strpos($border,
'B') !==
false) {
5748 $s .= sprintf(
'%F %F m ', $xB, $yB);
5749 $s .= sprintf(
'%F %F l ', $xL, $yL);
5753 if (is_array($style) AND !empty($style)) {
5755 $s .=
"\n".$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
"\n";
5786 public function MultiCell(
$w,
$h,
$txt, $border=0, $align=
'J', $fill=
false, $ln=1,
$x=
'',
$y=
'', $reseth=
true, $stretch=0, $ishtml=
false, $autopadding=
true, $maxh=0, $valign=
'T', $fitcell=
false) {
5793 $this->cell_padding[
'T'] = 0;
5794 $this->cell_padding[
'B'] = 0;
5806 if ((
$h > 0) AND $this->
inPageBody() AND ((
$y +
$h + $mc_margin[
'T'] + $mc_margin[
'B']) > $this->PageBreakTrigger)) {
5808 $newh = ($this->PageBreakTrigger -
$y);
5809 $resth = (
$h - $newh);
5824 $oy =
$y + $mc_margin[
'T'];
5826 $ox = ($this->w -
$x - $mc_margin[
'R']);
5828 $ox = (
$x + $mc_margin[
'L']);
5835 $w = ($this->x - $this->lMargin - $mc_margin[
'L']);
5837 $w = ($this->w - $this->x - $this->rMargin - $mc_margin[
'R']);
5844 $this->rMargin = ($this->w -
$this->x);
5845 $this->lMargin = ($this->x -
$w);
5848 $this->rMargin = ($this->w - $this->x -
$w);
5854 $this->y += $mc_padding[
'T'];
5869 $prev_text_height = $text_height;
5871 while ($maxit > 0) {
5872 $fmid = (($fmax + $fmin) / 2);
5876 if (($text_height == $maxh) OR (($text_height < $maxh) AND ($fmin >= ($fmax - 0.01)))) {
5878 } elseif ($text_height < $maxh) {
5887 if ($text_height < $maxh) {
5888 if ($valign ==
'M') {
5890 $this->y += (($maxh - $text_height) / 2);
5891 } elseif ($valign ==
'B') {
5893 $this->y += ($maxh - $text_height);
5897 $nl = $this->
Write($this->lasth,
$txt,
'', 0, $align,
true, $stretch,
false,
true, $maxh, 0, $mc_margin);
5905 $this->y += $mc_padding[
'B'];
5912 $skip = ($endpage - $startpage);
5914 while ($tmpresth > 0) {
5919 if ($this->num_columns > 1) {
5931 if ($this->num_columns == 0) {
5932 $this->num_columns = 1;
5936 $this->check_page_regions =
false;
5945 if ($this->num_columns < 2) {
5951 if (
$page > $startpage) {
5952 if (($this->rtl) AND ($this->pagedim[
$page][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
5953 $this->x -= ($this->pagedim[
$page][
'orm'] - $this->pagedim[$startpage][
'orm']);
5954 } elseif ((!$this->rtl) AND ($this->pagedim[
$page][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
5955 $this->x += ($this->pagedim[
$page][
'olm'] - $this->pagedim[$startpage][
'olm']);
5958 if ($startpage == $endpage) {
5960 for ($column = $startcolumn; $column <= $endcolumn; ++$column) {
5963 $this->x -= $mc_margin[
'R'];
5965 $this->x += $mc_margin[
'L'];
5967 if ($startcolumn == $endcolumn) {
5969 $h = max(
$h, ($currentY - $oy));
5971 } elseif ($column == $startcolumn) {
5972 $cborder = $border_start;
5975 } elseif ($column == $endcolumn) {
5976 $cborder = $border_end;
5982 $cborder = $border_middle;
5986 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
5988 } elseif (
$page == $startpage) {
5992 $this->x -= $mc_margin[
'R'];
5994 $this->x += $mc_margin[
'L'];
5996 if ($column == $startcolumn) {
5997 $cborder = $border_start;
6001 $cborder = $border_middle;
6005 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6007 } elseif (
$page == $endpage) {
6008 for ($column = 0; $column <= $endcolumn; ++$column) {
6011 $this->x -= $mc_margin[
'R'];
6013 $this->x += $mc_margin[
'L'];
6015 if ($column == $endcolumn) {
6017 $cborder = $border_end;
6024 $cborder = $border_middle;
6028 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6034 $this->x -= $mc_margin[
'R'];
6036 $this->x += $mc_margin[
'L'];
6038 $cborder = $border_middle;
6041 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6044 if ($cborder OR $fill) {
6045 $offsetlen = strlen($ccode);
6047 if ($this->inxobj) {
6049 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
6050 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
6051 $pagemark = $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey];
6052 $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey] += $offsetlen;
6058 $pstart = substr($pagebuff, 0, $pagemark);
6059 $pend = substr($pagebuff, $pagemark);
6060 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
6062 if (end($this->transfmrk[$this->page]) !==
false) {
6063 $pagemarkkey = key($this->transfmrk[$this->page]);
6064 $pagemark = $this->transfmrk[
$this->page][$pagemarkkey];
6065 $this->transfmrk[
$this->page][$pagemarkkey] += $offsetlen;
6066 } elseif ($this->InFooter) {
6074 $pstart = substr($pagebuff, 0, $pagemark);
6075 $pend = substr($pagebuff, $pagemark);
6083 $currentY = $this->
GetY();
6085 if ($this->num_columns > 1) {
6091 if ($this->page > $startpage) {
6093 $dl = ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$startpage][
'olm']);
6094 $dr = ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$startpage][
'orm']);
6095 if (($dl != 0) OR ($dr != 0)) {
6096 $this->lMargin += $dl;
6097 $this->rMargin += $dr;
6103 $this->
SetY($currentY + $mc_margin[
'B']);
6105 $this->
SetX(
$x +
$w + $mc_margin[
'L'] + $mc_margin[
'R']);
6111 $this->
SetX(
$x +
$w + $mc_margin[
'L'] + $mc_margin[
'R']);
6114 $this->cell_padding = $prev_cell_padding;
6115 $this->cell_margin = $prev_cell_margin;
6134 public function getNumLines(
$txt,
$w=0, $reseth=
false, $autopadding=
true, $cellpadding=
'', $border=0) {
6142 if (is_array($cellpadding)) {
6143 $this->cell_padding = $cellpadding;
6153 $wmax =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
6162 $length = count($chars);
6163 $lastSeparator = -1;
6164 for ($i = 0; $i < $length; ++$i) {
6165 $charWidth = $charsWidth[$i];
6167 $lastSeparator = $i;
6169 if ((($sum + $charWidth) > $wmax) OR ($chars[$i] == 10)) {
6171 if ($chars[$i] == 10) {
6172 $lastSeparator = -1;
6174 } elseif ($lastSeparator != -1) {
6175 $i = $lastSeparator;
6176 $lastSeparator = -1;
6185 if ($chars[($length - 1)] == 10) {
6188 $this->cell_padding = $prev_cell_padding;
6189 $this->lasth = $prev_lasth;
6244 if (is_array($cellpadding)) {
6245 $this->cell_padding = $cellpadding;
6248 $lines = $this->
getNumLines(
$txt,
$w, $reseth, $autopadding, $cellpadding, $border);
6252 $height += ($this->cell_padding[
'T'] + $this->cell_padding[
'B']);
6254 $this->cell_padding = $prev_cell_padding;
6255 $this->lasth = $prev_lasth;
6277 public function Write(
$h,
$txt, $link=
'', $fill=
false, $align=
'', $ln=
false, $stretch=0, $firstline=
false, $firstblock=
false, $maxh=0, $wadj=0, $margin=
'') {
6280 if (strlen(
$txt) == 0) {
6284 if ($margin ===
'') {
6289 $s = str_replace(
"\r",
'',
$txt);
6308 array_walk($chrw, array($this,
'getRawCharWidth'));
6309 $maxchwidth = max($chrw);
6313 $nb = count($chars);
6315 $shy_replacement = 45;
6318 $shy_replacement_width = $this->
GetCharWidth($shy_replacement);
6320 $maxy = $this->y + $maxh -
$h - $this->cell_padding[
'T'] - $this->cell_padding[
'B'];
6330 $wmax = (
$w - $wadj);
6332 $wmax -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
6334 if ((!$firstline) AND (($chrwidth > $wmax) OR ($maxchwidth > $wmax))) {
6339 $row_height = max(
$h, $this->FontSize * $this->cell_height_ratio);
6351 if (($maxh > 0) AND ($this->y >= $maxy) ) {
6358 if ($align ==
'J') {
6370 $tmparr = array_slice($chars, $j, ($i - $j));
6372 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6377 $this->endlinex = $startx - $linew;
6379 $this->endlinex = $startx + $linew;
6391 if (!empty($tmpstr) OR ($this->y < ($this->PageBreakTrigger - $row_height))) {
6392 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $talign, $fill, $link, $stretch);
6396 $this->cell_padding = $tmpcellpadding;
6405 if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND ($this->
inPageBody())) {
6408 $this->x -= $margin[
'R'];
6410 $this->x += $margin[
'L'];
6412 $this->lMargin += $margin[
'L'];
6413 $this->rMargin += $margin[
'R'];
6416 $wmax = (
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R']);
6427 AND ($i < ($nb - 1))
6428 AND @preg_match(
'/[\p{L}]/'.$this->re_space[
'm'],
TCPDF_FONTS::unichr($pc, $this->isunicode))
6429 AND @preg_match(
'/[\p{L}]/'.$this->re_space[
'm'],
TCPDF_FONTS::unichr($chars[($i + 1)], $this->isunicode))
6436 if (($c == 173) OR ($c == 45)) {
6439 $tmp_shy_replacement_width = 0;
6440 $tmp_shy_replacement_char =
'';
6442 $tmp_shy_replacement_width = $shy_replacement_width;
6443 $tmp_shy_replacement_char = $shy_replacement_char;
6457 if ((
$l > $wmax) OR (($c == 173) AND ((
$l + $tmp_shy_replacement_width) > $wmax)) ) {
6461 if (($this->rtl AND ($this->x <= ($this->w - $this->rMargin - $this->cell_padding[
'R'] - $margin[
'R'] - $chrwidth)))
6462 OR ((!$this->rtl) AND ($this->x >= ($this->lMargin + $this->cell_padding[
'L'] + $margin[
'L'] + $chrwidth)))) {
6474 $tmparr = array_slice($chars, $j, ($i - $j));
6476 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6481 $this->endlinex = $startx - $linew;
6483 $this->endlinex = $startx + $linew;
6494 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $align, $fill, $link, $stretch);
6497 $this->cell_padding = $tmpcellpadding;
6505 if ($this->rtl AND (!$firstblock) AND ($sep < $i)) {
6512 $nextstr = preg_split(
'/'.$this->re_space[
'p'].
'/'.$this->re_space[
'm'], $this->
stringTrim($strrest));
6513 if (isset($nextstr[0]) AND ($this->
GetStringWidth($nextstr[0]) > $pw)) {
6518 $tmparr = array_slice($chars, $j, ($i - $j));
6520 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6525 $this->endlinex = ($startx - $linew);
6527 $this->endlinex = ($startx + $linew);
6538 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $align, $fill, $link, $stretch);
6541 $this->cell_padding = $tmpcellpadding;
6550 $shy_width = $tmp_shy_replacement_width;
6552 $shy_char_left = $tmp_shy_replacement_char;
6553 $shy_char_right =
'';
6555 $shy_char_left =
'';
6556 $shy_char_right = $tmp_shy_replacement_char;
6560 $shy_char_left =
'';
6561 $shy_char_right =
'';
6566 $tmparr = array_slice($chars, $j, (($sep + $endspace) - $j));
6568 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6573 $this->endlinex = $startx - $linew - $shy_width;
6575 $this->endlinex = $startx + $linew + $shy_width;
6587 $this->
Cell(
$w,
$h, $shy_char_left.$tmpstr.$shy_char_right, 0, 1, $align, $fill, $link, $stretch);
6590 if ($chars[$sep] == 45) {
6594 $this->cell_padding = $tmpcellpadding;
6604 if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND ($this->
inPageBody())) {
6607 $this->x -= $margin[
'R'];
6609 $this->x += $margin[
'L'];
6611 $this->lMargin += $margin[
'L'];
6612 $this->rMargin += $margin[
'R'];
6615 $wmax =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
6660 $tmparr = array_slice($chars, $j, ($nb - $j));
6662 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6667 $this->endlinex = $startx - $linew;
6669 $this->endlinex = $startx + $linew;
6680 $this->
Cell(
$w,
$h, $tmpstr, 0, $ln, $align, $fill, $link, $stretch);
6683 $this->cell_padding = $tmpcellpadding;
6702 return ($this->x - $this->lMargin);
6704 return ($this->w - $this->rMargin - $this->x);
6729 if ($fitonpage OR $this->AutoPageBreak) {
6730 $ratio_wh = (
$w /
$h);
6731 if (
$h > ($this->PageBreakTrigger - $this->tMargin)) {
6733 $w = (
$h * $ratio_wh);
6740 $h = (
$w / $ratio_wh);
6752 $x += ($this->x - $prev_x);
6754 $this->newline =
true;
6758 $ratio_wh = (
$w /
$h);
6760 $h = $this->PageBreakTrigger -
$y;
6761 $w = (
$h * $ratio_wh);
6763 if ((!$this->rtl) AND ((
$x +
$w) > ($this->w - $this->rMargin))) {
6764 $w = $this->w - $this->rMargin -
$x;
6765 $h = (
$w / $ratio_wh);
6766 } elseif (($this->rtl) AND ((
$x -
$w) < ($this->lMargin))) {
6768 $h = (
$w / $ratio_wh);
6808 public function Image(
$file,
$x=
'',
$y=
'',
$w=0,
$h=0, $type=
'', $link=
'', $align=
'', $resize=
false,
$dpi=300, $palign=
'', $ismask=
false, $imgmask=
false, $border=0, $fitbox=
false, $hidden=
false, $fitonpage=
false, $alt=
false, $altimgs=array()) {
6809 if ($this->state != 2) {
6822 if (
$file[0] ===
'@') {
6824 $imgdata = substr(
$file, 1);
6826 if (
$file{0} ===
'*') {
6832 if (!@file_exists(
$file)) {
6836 if (@file_exists(
$file)) {
6838 $imsize = @getimagesize(
$file);
6842 if ($imsize === FALSE) {
6843 if (function_exists(
'curl_init')) {
6846 curl_setopt($cs, CURLOPT_URL,
$file);
6847 curl_setopt($cs, CURLOPT_BINARYTRANSFER,
true);
6848 curl_setopt($cs, CURLOPT_FAILONERROR,
true);
6849 curl_setopt($cs, CURLOPT_RETURNTRANSFER,
true);
6850 if ((ini_get(
'open_basedir') ==
'') AND (!ini_get(
'safe_mode'))) {
6851 curl_setopt($cs, CURLOPT_FOLLOWLOCATION,
true);
6853 curl_setopt($cs, CURLOPT_CONNECTTIMEOUT, 5);
6854 curl_setopt($cs, CURLOPT_TIMEOUT, 30);
6855 curl_setopt($cs, CURLOPT_SSL_VERIFYPEER,
false);
6856 curl_setopt($cs, CURLOPT_SSL_VERIFYHOST,
false);
6857 curl_setopt($cs, CURLOPT_USERAGENT,
'TCPDF');
6858 $imgdata = curl_exec($cs);
6861 $imgdata = @file_get_contents(
$file);
6865 if (isset($imgdata) AND ($imgdata !== FALSE)) {
6868 $fp = fopen(
$file,
'w');
6869 fwrite($fp, $imgdata);
6872 $imsize = @getimagesize(
$file);
6873 if ($imsize === FALSE) {
6876 $this->cached_files[] =
$file;
6879 if ($imsize === FALSE) {
6880 if ((
$w > 0) AND (
$h > 0)) {
6884 $imsize = array($pw, $ph);
6886 $this->
Error(
'[Image] Unable to get image: '.
$file);
6890 $filehash = md5($this->file_id.$file);
6892 list($pixw, $pixh) = $imsize;
6894 if ((
$w <= 0) AND (
$h <= 0)) {
6898 } elseif (
$w <= 0) {
6899 $w =
$h * $pixw / $pixh;
6900 } elseif (
$h <= 0) {
6901 $h =
$w * $pixh / $pixw;
6902 } elseif (($fitbox !==
false) AND (
$w > 0) AND (
$h > 0)) {
6903 if (strlen($fitbox) !== 2) {
6908 if (((
$w * $pixh) / (
$h * $pixw)) < 1) {
6912 $h =
$w * $pixh / $pixw;
6914 $hdiff = ($oldh -
$h);
6916 switch (strtoupper($fitbox{1})) {
6933 $w =
$h * $pixw / $pixh;
6935 $wdiff = ($oldw -
$w);
6937 switch (strtoupper($fitbox{0})) {
6964 $neww = round(
$w * $this->k *
$dpi / $this->dpi);
6965 $newh = round(
$h * $this->k *
$dpi / $this->dpi);
6967 $newsize = ($neww * $newh);
6968 $pixsize = ($pixw * $pixh);
6969 if (intval($resize) == 2) {
6971 } elseif ($newsize >= $pixsize) {
6976 if (in_array(
$file, $this->imagekeys)) {
6980 if (substr(
$file, 0, -34) != K_PATH_CACHE.
'msk') {
6982 $oldsize = ($info[
'w'] * $info[
'h']);
6983 if ((($oldsize < $newsize) AND ($resize)) OR (($oldsize < $pixsize) AND (!$resize))) {
6987 } elseif (substr(
$file, 0, -34) != K_PATH_CACHE.
'msk') {
6989 $tempfile_plain = K_PATH_CACHE.
'mskp_'.$filehash;
6990 $tempfile_alpha = K_PATH_CACHE.
'mska_'.$filehash;
6991 if (in_array($tempfile_plain, $this->imagekeys)) {
6995 $oldsize = ($info[
'w'] * $info[
'h']);
6996 if ((($oldsize < $newsize) AND ($resize)) OR (($oldsize < $pixsize) AND (!$resize))) {
7001 $imgmask = $this->
Image($tempfile_alpha,
$x,
$y,
$w,
$h,
'PNG',
'',
'', $resize,
$dpi,
'',
true,
false);
7003 return $this->
Image($tempfile_plain,
$x,
$y,
$w,
$h, $type, $link, $align, $resize,
$dpi, $palign,
false, $imgmask);
7009 $type = strtolower($type);
7012 } elseif ($type ==
'jpg') {
7018 $mtd =
'_parse'.$type;
7020 $gdfunction =
'imagecreatefrom'.$type;
7022 if ((method_exists(
'TCPDF_IMAGES', $mtd)) AND (!($resize AND (function_exists($gdfunction) OR extension_loaded(
'imagick'))))) {
7024 $info = TCPDF_IMAGES::$mtd(
$file);
7025 if ($info ==
'pngalpha') {
7026 return $this->
ImagePngAlpha(
$file,
$x,
$y, $pixw, $pixh,
$w,
$h,
'PNG', $link, $align, $resize,
$dpi, $palign, $filehash);
7030 if (function_exists($gdfunction)) {
7034 $imgr = imagecreatetruecolor($neww, $newh);
7035 if (($type ==
'gif') OR ($type ==
'png')) {
7038 imagecopyresampled($imgr,
$img, 0, 0, 0, 0, $neww, $newh, $pixw, $pixh);
7039 if (($type ==
'gif') OR ($type ==
'png')) {
7045 if (($type ==
'gif') OR ($type ==
'png')) {
7051 } elseif (extension_loaded(
'imagick')) {
7053 $img =
new Imagick();
7054 if ($type ==
'SVG') {
7056 $svgimg = file_get_contents(
$file);
7059 if (preg_match(
'/<svg([^>]*)>/si', $svgimg, $regs)) {
7062 if (preg_match(
'/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
7064 $owu = sprintf(
'%F', ($ow *
$dpi / 72)).$this->pdfunit;
7065 $svgtag = preg_replace(
'/[\s]+width[\s]*=[\s]*"[^"]*"/si',
' width="'.$owu.
'"', $svgtag, 1);
7070 if (preg_match(
'/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
7072 $ohu = sprintf(
'%F', ($oh *
$dpi / 72)).$this->pdfunit;
7073 $svgtag = preg_replace(
'/[\s]+height[\s]*=[\s]*"[^"]*"/si',
' height="'.$ohu.
'"', $svgtag, 1);
7078 if (!preg_match(
'/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $svgtag, $tmp)) {
7079 $vbw = ($ow * $this->imgscale *
$this->k);
7080 $vbh = ($oh * $this->imgscale *
$this->k);
7081 $vbox = sprintf(
' viewBox="0 0 %F %F" ', $vbw, $vbh);
7082 $svgtag = $vbox.$svgtag;
7084 $svgimg = preg_replace(
'/<svg([^>]*)>/si',
'<svg'.$svgtag.
'>', $svgimg, 1);
7086 $img->readImageBlob($svgimg);
7091 $img->resizeImage($neww, $newh, 10, 1,
false);
7093 $img->setCompressionQuality($this->jpeg_quality);
7094 $img->setImageFormat(
'jpeg');
7096 $img->writeImage($tempname);
7104 if ($info ===
false) {
7111 $info[
'cs'] =
'DeviceGray';
7113 if ($imgmask !==
false) {
7114 $info[
'masked'] = $imgmask;
7116 if (!empty($exurl)) {
7117 $info[
'exurl'] = $exurl;
7120 $info[
'altimgs'] = $altimgs;
7125 $this->img_rb_y =
$y +
$h;
7128 if ($palign ==
'L') {
7130 } elseif ($palign ==
'C') {
7131 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
7132 } elseif ($palign ==
'R') {
7133 $ximg = $this->w - $this->rMargin -
$w;
7137 $this->img_rb_x = $ximg;
7139 if ($palign ==
'L') {
7141 } elseif ($palign ==
'C') {
7142 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
7143 } elseif ($palign ==
'R') {
7144 $ximg = $this->w - $this->rMargin -
$w;
7148 $this->img_rb_x = $ximg +
$w;
7150 if ($ismask OR $hidden) {
7157 $this->
_out(sprintf(
'q %F 0 0 %F %F %F cm /I%u Do Q', (
$w * $this->k), ($h * $this->k), $xkimg, (($this->h - (
$y + $h)) * $this->k), $info[
'i']));
7159 if (!empty($border)) {
7167 $this->
Cell(
$w, $h,
'', $border, 0,
'', 0,
'', 0,
true);
7172 $this->
Link($ximg,
$y,
$w, $h, $link, 0);
7182 $this->y =
$y + round($h/2);
7192 $this->
SetY($this->img_rb_y);
7200 if ($this->inxobj) {
7228 protected function ImagePngAlpha(
$file,
$x,
$y, $wpx, $hpx,
$w,
$h, $type, $link, $align, $resize,
$dpi, $palign, $filehash=
'') {
7229 if (empty($filehash)) {
7230 $filehash = md5($this->file_id.$file);
7233 $tempfile_plain = K_PATH_CACHE.
'mskp_'.$filehash;
7235 $tempfile_alpha = K_PATH_CACHE.
'mska_'.$filehash;
7236 if (extension_loaded(
'imagick')) {
7238 $img =
new Imagick();
7243 if (method_exists(
$img,
'setImageAlphaChannel') AND defined(
'Imagick::ALPHACHANNEL_EXTRACT')) {
7244 $img->setImageAlphaChannel(Imagick::ALPHACHANNEL_EXTRACT);
7246 $img->separateImageChannel(8);
7247 $img->negateImage(
true);
7249 $img->setImageFormat(
'png');
7250 $img->writeImage($tempfile_alpha);
7252 if (method_exists($imga,
'setImageMatte')) {
7253 $imga->setImageMatte(
false);
7255 $imga->separateImageChannel(39);
7257 $imga->setImageFormat(
'png');
7258 $imga->writeImage($tempfile_plain);
7259 } elseif (function_exists(
'imagecreatefrompng')) {
7262 $imgalpha = imagecreate($wpx, $hpx);
7264 for ($c = 0; $c < 256; ++$c) {
7265 ImageColorAllocate($imgalpha, $c, $c, $c);
7268 for ($xpx = 0; $xpx < $wpx; ++$xpx) {
7269 for ($ypx = 0; $ypx < $hpx; ++$ypx) {
7270 $color = imagecolorat(
$img, $xpx, $ypx);
7272 imagesetpixel($imgalpha, $xpx, $ypx,
$alpha);
7275 imagepng($imgalpha, $tempfile_alpha);
7276 imagedestroy($imgalpha);
7278 $imgplain = imagecreatetruecolor($wpx, $hpx);
7279 imagecopy($imgplain,
$img, 0, 0, 0, 0, $wpx, $hpx);
7280 imagepng($imgplain, $tempfile_plain);
7281 imagedestroy($imgplain);
7283 $this->
Error(
'TCPDF requires the Imagick or GD extension to handle PNG images with alpha channel.');
7286 $imgmask = $this->
Image($tempfile_alpha,
$x,
$y,
$w,
$h,
'PNG',
'',
'', $resize,
$dpi,
'',
true,
false);
7288 $this->
Image($tempfile_plain,
$x,
$y,
$w,
$h, $type, $link, $align, $resize,
$dpi, $palign,
false, $imgmask);
7290 unlink($tempfile_alpha);
7291 unlink($tempfile_plain);
7301 if (!isset($this->gdgammacache[
"'".$c.
"'"])) {
7308 $this->gdgammacache[
"'".$c.
"'"] = (pow((
$alpha / 255), 2.2) * 255);
7310 if (count($this->gdgammacache) > 8) {
7312 array_shift($this->gdgammacache);
7315 return $this->gdgammacache[
"'".$c.
"'"];
7327 public function Ln(
$h=
'', $cell=
false) {
7328 if (($this->num_columns > 1) AND ($this->y == $this->columns[$this->current_column][
'y']) AND isset($this->columns[$this->current_column][
'x']) AND ($this->x == $this->columns[$this->current_column][
'x'])) {
7334 $cellpadding = $this->cell_padding[
'R'];
7336 $cellpadding = $this->cell_padding[
'L'];
7342 $this->x = $this->w - $this->rMargin - $cellpadding;
7344 $this->x = $this->lMargin + $cellpadding;
7346 if (is_string(
$h)) {
7351 $this->newline =
true;
7365 return ($this->w - $this->x);
7404 if (!$rtloff AND $this->rtl) {
7406 $this->x = $this->w -
$x;
7414 $this->x = $this->w +
$x;
7420 if ($this->x > $this->w) {
7435 public function SetY(
$y, $resetx=
true, $rtloff=
false) {
7439 if (!$rtloff AND $this->rtl) {
7448 $this->y = $this->h +
$y;
7453 if ($this->y > $this->h) {
7469 $this->
SetY(
$y,
false, $rtloff);
7470 $this->
SetX(
$x, $rtloff);
7481 $this->x = floatval(
$x);
7492 $this->y = floatval(
$y);
7518 public function Output($name=
'doc.pdf', $dest=
'I') {
7521 if ($this->state < 3) {
7525 if (is_bool($dest)) {
7526 $dest = $dest ?
'D' :
'F';
7528 $dest = strtoupper($dest);
7529 if ($dest{0} !=
'F') {
7530 $name = preg_replace(
'/[\s]+/',
'_', $name);
7531 $name = preg_replace(
'/[^a-zA-Z0-9_\.-]/',
'', $name);
7538 $pdfdoc = substr($pdfdoc, 0, -1);
7540 if (isset($this->diskcache) AND $this->diskcache) {
7542 unlink($this->buffer);
7544 unset($this->buffer);
7548 $byte_range = array();
7551 $byte_range[2] = $byte_range[1] + $this->signature_max_length + 2;
7552 $byte_range[3] = strlen($pdfdoc) - $byte_range[2];
7553 $pdfdoc = substr($pdfdoc, 0, $byte_range[1]).substr($pdfdoc, $byte_range[2]);
7555 $byterange = sprintf(
'/ByteRange[0 %u %u %u]', $byte_range[1], $byte_range[2], $byte_range[3]);
7556 $byterange .= str_repeat(
' ', ($byterange_string_len - strlen($byterange)));
7560 $f = fopen($tempdoc,
'wb');
7562 $this->
Error(
'Unable to create temporary file: '.$tempdoc);
7564 $pdfdoc_length = strlen($pdfdoc);
7565 fwrite($f, $pdfdoc, $pdfdoc_length);
7569 if (empty($this->signature_data[
'extracerts'])) {
7570 openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data[
'signcert'], array($this->signature_data[
'privkey'], $this->signature_data[
'password']), array(), PKCS7_BINARY | PKCS7_DETACHED);
7572 openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data[
'signcert'], array($this->signature_data[
'privkey'], $this->signature_data[
'password']), array(), PKCS7_BINARY | PKCS7_DETACHED, $this->signature_data[
'extracerts']);
7576 $signature = file_get_contents($tempsign);
7579 $signature = substr($signature, $pdfdoc_length);
7580 $signature = substr($signature, (strpos($signature,
"%%EOF\n\n------") + 13));
7581 $tmparr = explode(
"\n\n", $signature);
7582 $signature = $tmparr[1];
7585 $signature = base64_decode(trim($signature));
7587 $signature = current(unpack(
'H*', $signature));
7588 $signature = str_pad($signature, $this->signature_max_length,
'0');
7590 $this->diskcache =
false;
7592 $this->buffer = substr($pdfdoc, 0, $byte_range[1]).
'<'.$signature.
'>'.substr($pdfdoc, $byte_range[1]);
7593 $this->bufferlen = strlen($this->buffer);
7598 if (ob_get_contents()) {
7599 $this->
Error(
'Some data has already been output, can\'t send PDF file');
7601 if (php_sapi_name() !=
'cli') {
7603 header(
'Content-Type: application/pdf');
7604 if (headers_sent()) {
7605 $this->
Error(
'Some data has already been output to browser, can\'t send PDF file');
7607 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7609 header(
'Pragma: public');
7610 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7611 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7612 header(
'Content-Disposition: inline; filename="'.basename($name).
'"');
7621 if (ob_get_contents()) {
7622 $this->
Error(
'Some data has already been output, can\'t send PDF file');
7624 header(
'Content-Description: File Transfer');
7625 if (headers_sent()) {
7626 $this->
Error(
'Some data has already been output to browser, can\'t send PDF file');
7628 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7630 header(
'Pragma: public');
7631 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7632 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7634 if (strpos(php_sapi_name(),
'cgi') ===
false) {
7635 header(
'Content-Type: application/force-download');
7636 header(
'Content-Type: application/octet-stream',
false);
7637 header(
'Content-Type: application/download',
false);
7638 header(
'Content-Type: application/pdf',
false);
7640 header(
'Content-Type: application/pdf');
7643 header(
'Content-Disposition: attachment; filename="'.basename($name).
'"');
7644 header(
'Content-Transfer-Encoding: binary');
7652 if ($this->diskcache) {
7653 copy($this->buffer, $name);
7655 $f = fopen($name,
'wb');
7657 $this->
Error(
'Unable to create output file: '.$name);
7659 fwrite($f, $this->
getBuffer(), $this->bufferlen);
7662 if ($dest ==
'FI') {
7664 header(
'Content-Type: application/pdf');
7665 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7667 header(
'Pragma: public');
7668 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7669 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7670 header(
'Content-Disposition: inline; filename="'.basename($name).
'"');
7672 } elseif ($dest ==
'FD') {
7674 if (ob_get_contents()) {
7675 $this->
Error(
'Some data has already been output, can\'t send PDF file');
7677 header(
'Content-Description: File Transfer');
7678 if (headers_sent()) {
7679 $this->
Error(
'Some data has already been output to browser, can\'t send PDF file');
7681 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7682 header(
'Pragma: public');
7683 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7684 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7686 if (strpos(php_sapi_name(),
'cgi') ===
false) {
7687 header(
'Content-Type: application/force-download');
7688 header(
'Content-Type: application/octet-stream',
false);
7689 header(
'Content-Type: application/download',
false);
7690 header(
'Content-Type: application/pdf',
false);
7692 header(
'Content-Type: application/pdf');
7695 header(
'Content-Disposition: attachment; filename="'.basename($name).
'"');
7696 header(
'Content-Transfer-Encoding: binary');
7703 $retval =
'Content-Type: application/pdf;'.
"\r\n";
7704 $retval .=
' name="'.$name.
'"'.
"\r\n";
7705 $retval .=
'Content-Transfer-Encoding: base64'.
"\r\n";
7706 $retval .=
'Content-Disposition: attachment;'.
"\r\n";
7707 $retval .=
' filename="'.$name.
'"'.
"\r\n\r\n";
7708 $retval .= chunk_split(base64_encode($this->
getBuffer()), 76,
"\r\n");
7716 $this->
Error(
'Incorrect output destination: '.$dest);
7729 public function _destroy($destroyall=
false, $preserve_objcopy=
false) {
7730 if ($destroyall AND isset($this->diskcache) AND $this->diskcache AND (!$preserve_objcopy) AND (!
TCPDF_STATIC::empty_string($this->buffer))) {
7732 unlink($this->buffer);
7734 if ($destroyall AND isset($this->cached_files) AND !empty($this->cached_files)) {
7736 foreach ($this->cached_files as $cachefile) {
7737 if (is_file($cachefile)) {
7741 unset($this->cached_files);
7743 foreach (array_keys(get_object_vars($this)) as $val) {
7744 if ($destroyall OR (
7745 ($val !=
'internal_encoding')
7746 AND ($val !=
'state')
7747 AND ($val !=
'bufferlen')
7748 AND ($val !=
'buffer')
7749 AND ($val !=
'diskcache')
7750 AND ($val !=
'cached_files')
7751 AND ($val !=
'sign')
7752 AND ($val !=
'signature_data')
7753 AND ($val !=
'signature_max_length')
7754 AND ($val !=
'byterange_string')
7756 if ((!$preserve_objcopy OR ($val !=
'objcopy')) AND isset($this->$val)) {
7770 $this->
Error(
'Don\'t alter the locale before including class file');
7773 if (sprintf(
'%.1F', 1.0) !=
'1.0') {
7774 setlocale(LC_NUMERIC,
'C');
7787 $alias = array(
'u' => array(),
'a' => array());
7790 if ($this->isunicode) {
7808 foreach($basic_alias as
$k => $a) {
7824 foreach ($aliases as $type => $alias) {
7825 foreach ($alias as $a) {
7827 $startnum = (strpos($a,
':') + 1);
7828 $a = substr($a, 0, $startnum);
7829 if (($pos = strpos(
$page, $a)) !==
false) {
7831 $endnum = strpos(
$page,
'}', $pos);
7833 $aa = substr(
$page, $pos, ($endnum - $pos + 1));
7835 $ratio = substr(
$page, ($pos + $startnum), ($endnum - $pos - $startnum));
7836 $ratio = preg_replace(
'/[^0-9\.]/',
'', $ratio);
7837 $ratio = floatval($ratio);
7839 $chrdiff = floor(($diff + 12) * $ratio);
7840 $shift = str_repeat(
' ', $chrdiff);
7843 $chrdiff = floor(($diff + 11) * $ratio);
7844 $shift = str_repeat(
' ', $chrdiff);
7859 $this->page_boxes = array();
7860 foreach ($boxes as $box) {
7862 $this->page_boxes[] = $box;
7883 for (
$n = 1;
$n <= $num_pages; ++
$n) {
7893 if (!empty($this->pagegroups)) {
7894 if (isset($this->newpagegroup[
$n])) {
7907 $replace[] = array($ptgu, $ptg_num_chars, 9, $pnalias[2][
'u']);
7908 $replace[] = array($ptga, $ptg_num_chars, 7, $pnalias[2][
'a']);
7909 $replace[] = array($pngu, $png_num_chars, 9, $pnalias[3][
'u']);
7910 $replace[] = array($pnga, $png_num_chars, 7, $pnalias[3][
'a']);
7915 $replace[] = array($ptpu, $ptp_num_chars, 9, $pnalias[0][
'u']);
7916 $replace[] = array($ptpa, $ptp_num_chars, 7, $pnalias[0][
'a']);
7917 $replace[] = array($pnpu, $pnp_num_chars, 9, $pnalias[1][
'u']);
7918 $replace[] = array($pnpa, $pnp_num_chars, 7, $pnalias[1][
'a']);
7923 $temppage = str_replace($this->epsmarker,
'', $temppage);
7925 $this->page_obj_id[
$n] = $this->
_newobj();
7927 $out .=
' /Type /Page';
7928 $out .=
' /Parent 1 0 R';
7929 $out .=
' /LastModified '.$this->_datestring(0, $this->doc_modification_timestamp);
7930 $out .=
' /Resources 2 0 R';
7931 foreach ($this->page_boxes as $box) {
7933 $out .= sprintf(
' [%F %F %F %F]', $this->pagedim[
$n][$box][
'llx'], $this->pagedim[
$n][$box][
'lly'], $this->pagedim[
$n][$box][
'urx'], $this->pagedim[
$n][$box][
'ury']);
7935 if (isset($this->pagedim[
$n][
'BoxColorInfo']) AND !empty($this->pagedim[$n][
'BoxColorInfo'])) {
7936 $out .=
' /BoxColorInfo <<';
7937 foreach ($this->page_boxes as $box) {
7938 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box])) {
7939 $out .=
' /'.$box.
' <<';
7940 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'C'])) {
7941 $color = $this->pagedim[
$n][
'BoxColorInfo'][$box][
'C'];
7943 $out .= sprintf(
' %F %F %F', ($color[0] / 255), ($color[1] / 255), ($color[2] / 255));
7946 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'W'])) {
7947 $out .=
' /W '.($this->pagedim[
$n][
'BoxColorInfo'][$box][
'W'] *
$this->k);
7949 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'S'])) {
7950 $out .=
' /S /'.$this->pagedim[
$n][
'BoxColorInfo'][$box][
'S'];
7952 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'D'])) {
7953 $dashes = $this->pagedim[
$n][
'BoxColorInfo'][$box][
'D'];
7955 foreach ($dashes as $dash) {
7956 $out .= sprintf(
' %F', ($dash * $this->k));
7965 $out .=
' /Contents '.($this->n + 1).
' 0 R';
7966 $out .=
' /Rotate '.$this->pagedim[
$n][
'Rotate'];
7967 if (!$this->pdfa_mode) {
7968 $out .=
' /Group << /Type /Group /S /Transparency /CS /DeviceRGB >>';
7970 if (isset($this->pagedim[$n][
'trans']) AND !empty($this->pagedim[$n][
'trans'])) {
7972 if (isset($this->pagedim[$n][
'trans'][
'Dur'])) {
7973 $out .=
' /Dur '.$this->pagedim[
$n][
'trans'][
'Dur'];
7975 $out .=
' /Trans <<';
7976 $out .=
' /Type /Trans';
7977 if (isset($this->pagedim[$n][
'trans'][
'S'])) {
7978 $out .=
' /S /'.$this->pagedim[
$n][
'trans'][
'S'];
7980 if (isset($this->pagedim[$n][
'trans'][
'D'])) {
7981 $out .=
' /D '.$this->pagedim[
$n][
'trans'][
'D'];
7983 if (isset($this->pagedim[$n][
'trans'][
'Dm'])) {
7984 $out .=
' /Dm /'.$this->pagedim[
$n][
'trans'][
'Dm'];
7986 if (isset($this->pagedim[$n][
'trans'][
'M'])) {
7987 $out .=
' /M /'.$this->pagedim[
$n][
'trans'][
'M'];
7989 if (isset($this->pagedim[$n][
'trans'][
'Di'])) {
7990 $out .=
' /Di '.$this->pagedim[
$n][
'trans'][
'Di'];
7992 if (isset($this->pagedim[$n][
'trans'][
'SS'])) {
7993 $out .=
' /SS '.$this->pagedim[
$n][
'trans'][
'SS'];
7995 if (isset($this->pagedim[$n][
'trans'][
'B'])) {
7996 $out .=
' /B '.$this->pagedim[
$n][
'trans'][
'B'];
8001 $out .=
' /PZ '.$this->pagedim[
$n][
'PZ'];
8003 $out .=
"\n".
'endobj';
8009 $this->
_out(
'<<'.$filter.
'/Length '.strlen($p).
'>> stream'.
"\n".$p.
"\n".
'endstream'.
"\n".
'endobj');
8010 if ($this->diskcache) {
8012 unlink($this->pages[$n]);
8017 $out .=
'<< /Type /Pages /Kids [';
8018 foreach($this->page_obj_id as $page_obj) {
8019 $out .=
' '.$page_obj.
' 0 R';
8021 $out .=
' ] /Count '.$num_pages.
' >>';
8022 $out .=
"\n".
'endobj';
8047 if (!(isset($this->PageAnnots[
$n]) OR ($this->sign AND isset($this->signature_data[
'cert_type'])))) {
8050 $out =
' /Annots [';
8051 if (isset($this->PageAnnots[$n])) {
8052 foreach ($this->PageAnnots[$n] as $key => $val) {
8053 if (!in_array($val[
'n'], $this->radio_groups)) {
8054 $out .=
' '.$val[
'n'].
' 0 R';
8058 if (isset($this->radiobutton_groups[$n])) {
8059 foreach ($this->radiobutton_groups[$n] as $key => $data) {
8060 if (isset($data[
'n'])) {
8061 $out .=
' '.$data[
'n'].
' 0 R';
8066 if ($this->sign AND ($n == $this->signature_appearance[
'page']) AND isset($this->signature_data[
'cert_type'])) {
8068 $out .=
' '.$this->sig_obj_id.
' 0 R';
8070 if (!empty($this->empty_signature_appearance)) {
8071 foreach ($this->empty_signature_appearance as $esa) {
8072 if ($esa[
'page'] == $n) {
8074 $out .=
' '.$esa[
'objid'].
' 0 R';
8093 if (isset($this->PageAnnots[
$n])) {
8095 foreach ($this->PageAnnots[$n] as $key => $pl) {
8096 $annot_obj_id = $this->PageAnnots[
$n][$key][
'n'];
8098 if (isset($this->radiobutton_groups[$n][$pl[
'txt']]) AND is_array($this->radiobutton_groups[$n][$pl[
'txt']])) {
8099 $radio_button_obj_id = $this->radiobutton_groups[
$n][$pl[
'txt']][
'n'];
8101 $annots .=
' /Type /Annot';
8102 $annots .=
' /Subtype /Widget';
8103 $annots .=
' /Rect [0 0 0 0]';
8104 if ($this->radiobutton_groups[$n][$pl[
'txt']][
'#readonly#']) {
8106 $annots .=
' /F 68';
8107 $annots .=
' /Ff 49153';
8110 $annots .=
' /Ff 49152';
8112 $annots .=
' /T '.$this->_datastring($pl[
'txt'], $radio_button_obj_id);
8113 if (isset($pl[
'opt'][
'tu']) AND is_string($pl[
'opt'][
'tu'])) {
8114 $annots .=
' /TU '.$this->_datastring($pl[
'opt'][
'tu'], $radio_button_obj_id);
8116 $annots .=
' /FT /Btn';
8117 $annots .=
' /Kids [';
8119 foreach ($this->radiobutton_groups[$n][$pl[
'txt']] as $key => $data) {
8120 if (isset($data[
'kid'])) {
8121 $annots .=
' '.$data[
'kid'].
' 0 R';
8122 if ($data[
'def'] !==
'Off') {
8123 $defval = $data[
'def'];
8128 if (!empty($defval)) {
8129 $annots .=
' /V /'.$defval;
8132 $this->
_out($this->
_getobj($radio_button_obj_id).
"\n".$annots.
"\n".
'endobj');
8133 $this->form_obj_id[] = $radio_button_obj_id;
8135 $this->radiobutton_groups[
$n][$pl[
'txt']] = $radio_button_obj_id;
8138 $pl[
'opt'] = array_change_key_case($pl[
'opt'], CASE_LOWER);
8140 $b = $this->pagedim[
$n][
'h'] - (($pl[
'y'] + $pl[
'h']) * $this->k);
8143 $rect = sprintf(
'%F %F %F %F', $a, $b, $a+$c, $b+
$d);
8145 $annots =
'<</Type /Annot';
8146 $annots .=
' /Subtype /'.$pl[
'opt'][
'subtype'];
8147 $annots .=
' /Rect ['.$rect.
']';
8148 $ft = array(
'Btn',
'Tx',
'Ch',
'Sig');
8149 if (isset($pl[
'opt'][
'ft']) AND in_array($pl[
'opt'][
'ft'], $ft)) {
8150 $annots .=
' /FT /'.$pl[
'opt'][
'ft'];
8153 $annots .=
' /Contents '.$this->_textstring($pl[
'txt'], $annot_obj_id);
8154 $annots .=
' /P '.$this->page_obj_id[
$n].
' 0 R';
8155 $annots .=
' /NM '.$this->_datastring(sprintf(
'%04u-%04u', $n, $key), $annot_obj_id);
8156 $annots .=
' /M '.$this->_datestring($annot_obj_id, $this->doc_modification_timestamp);
8157 if (isset($pl[
'opt'][
'f'])) {
8159 if (is_array($pl[
'opt'][
'f'])) {
8160 foreach ($pl[
'opt'][
'f'] as $f) {
8161 switch (strtolower($f)) {
8194 case 'togglenoview': {
8198 case 'lockedcontents': {
8208 $fval = intval($pl[
'opt'][
'f']);
8213 if ($this->pdfa_mode) {
8217 $annots .=
' /F '.intval($fval);
8218 if (isset($pl[
'opt'][
'as']) AND is_string($pl[
'opt'][
'as'])) {
8219 $annots .=
' /AS /'.$pl[
'opt'][
'as'];
8221 if (isset($pl[
'opt'][
'ap'])) {
8223 $annots .=
' /AP <<';
8224 if (is_array($pl[
'opt'][
'ap'])) {
8225 foreach ($pl[
'opt'][
'ap'] as $apmode => $apdef) {
8227 $annots .=
' /'.strtoupper($apmode);
8228 if (is_array($apdef)) {
8230 foreach ($apdef as $apstate => $stream) {
8233 $annots .=
' /'.$apstate.
' '.$apsobjid.
' 0 R';
8239 $annots .=
' '.$apsobjid.
' 0 R';
8243 $annots .= $pl[
'opt'][
'ap'];
8247 if (isset($pl[
'opt'][
'bs']) AND (is_array($pl[
'opt'][
'bs']))) {
8248 $annots .=
' /BS <<';
8249 $annots .=
' /Type /Border';
8250 if (isset($pl[
'opt'][
'bs'][
'w'])) {
8251 $annots .=
' /W '.intval($pl[
'opt'][
'bs'][
'w']);
8253 $bstyles = array(
'S',
'D',
'B',
'I',
'U');
8254 if (isset($pl[
'opt'][
'bs'][
's']) AND in_array($pl[
'opt'][
'bs'][
's'], $bstyles)) {
8255 $annots .=
' /S /'.$pl[
'opt'][
'bs'][
's'];
8257 if (isset($pl[
'opt'][
'bs'][
'd']) AND (is_array($pl[
'opt'][
'bs'][
'd']))) {
8259 foreach ($pl[
'opt'][
'bs'][
'd'] as $cord) {
8260 $annots .=
' '.intval($cord);
8266 $annots .=
' /Border [';
8267 if (isset($pl[
'opt'][
'border']) AND (count($pl[
'opt'][
'border']) >= 3)) {
8268 $annots .= intval($pl[
'opt'][
'border'][0]).
' ';
8269 $annots .= intval($pl[
'opt'][
'border'][1]).
' ';
8270 $annots .= intval($pl[
'opt'][
'border'][2]);
8271 if (isset($pl[
'opt'][
'border'][3]) AND is_array($pl[
'opt'][
'border'][3])) {
8273 foreach ($pl[
'opt'][
'border'][3] as $dash) {
8274 $annots .= intval($dash).
' ';
8283 if (isset($pl[
'opt'][
'be']) AND (is_array($pl[
'opt'][
'be']))) {
8284 $annots .=
' /BE <<';
8285 $bstyles = array(
'S',
'C');
8286 if (isset($pl[
'opt'][
'be'][
's']) AND in_array($pl[
'opt'][
'be'][
's'], $bstyles)) {
8287 $annots .=
' /S /'.$pl[
'opt'][
'bs'][
's'];
8289 $annots .=
' /S /S';
8291 if (isset($pl[
'opt'][
'be'][
'i']) AND ($pl[
'opt'][
'be'][
'i'] >= 0) AND ($pl[
'opt'][
'be'][
'i'] <= 2)) {
8292 $annots .=
' /I '.sprintf(
' %F', $pl[
'opt'][
'be'][
'i']);
8296 if (isset($pl[
'opt'][
'c']) AND (is_array($pl[
'opt'][
'c'])) AND !empty($pl[
'opt'][
'c'])) {
8297 $annots .=
' /C '.TCPDF_COLORS::getColorStringFromArray($pl[
'opt'][
'c']);
8301 $markups = array(
'text',
'freetext',
'line',
'square',
'circle',
'polygon',
'polyline',
'highlight',
'underline',
'squiggly',
'strikeout',
'stamp',
'caret',
'ink',
'fileattachment',
'sound');
8302 if (in_array(strtolower($pl[
'opt'][
'subtype']), $markups)) {
8304 if (isset($pl[
'opt'][
't']) AND is_string($pl[
'opt'][
't'])) {
8305 $annots .=
' /T '.$this->_textstring($pl[
'opt'][
't'], $annot_obj_id);
8308 if (isset($pl[
'opt'][
'ca'])) {
8309 $annots .=
' /CA '.sprintf(
'%F', floatval($pl[
'opt'][
'ca']));
8311 if (isset($pl[
'opt'][
'rc'])) {
8312 $annots .=
' /RC '.$this->_textstring($pl[
'opt'][
'rc'], $annot_obj_id);
8314 $annots .=
' /CreationDate '.$this->_datestring($annot_obj_id, $this->doc_creation_timestamp);
8316 if (isset($pl[
'opt'][
'subj'])) {
8317 $annots .=
' /Subj '.$this->_textstring($pl[
'opt'][
'subj'], $annot_obj_id);
8323 $lineendings = array(
'Square',
'Circle',
'Diamond',
'OpenArrow',
'ClosedArrow',
'None',
'Butt',
'ROpenArrow',
'RClosedArrow',
'Slash');
8325 switch (strtolower($pl[
'opt'][
'subtype'])) {
8327 if (isset($pl[
'opt'][
'open'])) {
8328 $annots .=
' /Open '. (strtolower($pl[
'opt'][
'open']) ==
'true' ?
'true' :
'false');
8330 $iconsapp = array(
'Comment',
'Help',
'Insert',
'Key',
'NewParagraph',
'Note',
'Paragraph');
8331 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8332 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8334 $annots .=
' /Name /Note';
8336 $statemodels = array(
'Marked',
'Review');
8337 if (isset($pl[
'opt'][
'statemodel']) AND in_array($pl[
'opt'][
'statemodel'], $statemodels)) {
8338 $annots .=
' /StateModel /'.$pl[
'opt'][
'statemodel'];
8340 $pl[
'opt'][
'statemodel'] =
'Marked';
8341 $annots .=
' /StateModel /'.$pl[
'opt'][
'statemodel'];
8343 if ($pl[
'opt'][
'statemodel'] ==
'Marked') {
8344 $states = array(
'Accepted',
'Unmarked');
8346 $states = array(
'Accepted',
'Rejected',
'Cancelled',
'Completed',
'None');
8348 if (isset($pl[
'opt'][
'state']) AND in_array($pl[
'opt'][
'state'], $states)) {
8349 $annots .=
' /State /'.$pl[
'opt'][
'state'];
8351 if ($pl[
'opt'][
'statemodel'] ==
'Marked') {
8352 $annots .=
' /State /Unmarked';
8354 $annots .=
' /State /None';
8360 if (is_string($pl[
'txt'])) {
8361 if ($pl[
'txt'][0] ==
'#') {
8363 $annots .=
' /Dest /'.TCPDF_STATIC::encodeNameObject(substr($pl[
'txt'], 1));
8364 } elseif ($pl[
'txt'][0] ==
'%') {
8366 $filename = basename(substr($pl[
'txt'], 1));
8367 $annots .=
' /A << /S /GoToE /D [0 /Fit] /NewWindow true /T << /R /C /P '.($n - 1).
' /A '.$this->embeddedfiles[
$filename][
'a'].
' >> >>';
8368 } elseif ($pl[
'txt'][0] ==
'*') {
8370 $filename = basename(substr($pl[
'txt'], 1));
8371 $jsa =
'var D=event.target.doc;var MyData=D.dataObjects;for (var i in MyData) if (MyData[i].path=="'.$filename.
'") D.exportDataObject( { cName : MyData[i].name, nLaunch : 2});';
8372 $annots .=
' /A << /S /JavaScript /JS '.$this->_textstring($jsa, $annot_obj_id).
'>>';
8375 $annots .=
' /A <</S /URI /URI '.$this->_datastring($this->
unhtmlentities($pl[
'txt']), $annot_obj_id).
'>>';
8377 } elseif (isset($this->links[$pl[
'txt']])) {
8379 $l = $this->links[$pl[
'txt']];
8380 if (isset($this->page_obj_id[(
$l[0])])) {
8381 $annots .= sprintf(
' /Dest [%u 0 R /XYZ 0 %F null]', $this->page_obj_id[(
$l[0])], ($this->pagedim[
$l[0]][
'h'] - (
$l[1] * $this->k)));
8384 $hmodes = array(
'N',
'I',
'O',
'P');
8385 if (isset($pl[
'opt'][
'h']) AND in_array($pl[
'opt'][
'h'], $hmodes)) {
8386 $annots .=
' /H /'.$pl[
'opt'][
'h'];
8388 $annots .=
' /H /I';
8395 if (isset($pl[
'opt'][
'da']) AND !empty($pl[
'opt'][
'da'])) {
8396 $annots .=
' /DA ('.$pl[
'opt'][
'da'].
')';
8398 if (isset($pl[
'opt'][
'q']) AND ($pl[
'opt'][
'q'] >= 0) AND ($pl[
'opt'][
'q'] <= 2)) {
8399 $annots .=
' /Q '.intval($pl[
'opt'][
'q']);
8401 if (isset($pl[
'opt'][
'rc'])) {
8402 $annots .=
' /RC '.$this->_textstring($pl[
'opt'][
'rc'], $annot_obj_id);
8404 if (isset($pl[
'opt'][
'ds'])) {
8405 $annots .=
' /DS '.$this->_textstring($pl[
'opt'][
'ds'], $annot_obj_id);
8407 if (isset($pl[
'opt'][
'cl']) AND is_array($pl[
'opt'][
'cl'])) {
8408 $annots .=
' /CL [';
8409 foreach ($pl[
'opt'][
'cl'] as $cl) {
8410 $annots .= sprintf(
'%F ', $cl * $this->k);
8414 $tfit = array(
'FreeText',
'FreeTextCallout',
'FreeTextTypeWriter');
8415 if (isset($pl[
'opt'][
'it']) AND in_array($pl[
'opt'][
'it'], $tfit)) {
8416 $annots .=
' /IT /'.$pl[
'opt'][
'it'];
8418 if (isset($pl[
'opt'][
'rd']) AND is_array($pl[
'opt'][
'rd'])) {
8420 $r = $pl[
'opt'][
'rd'][1] *
$this->k;
8422 $b = $pl[
'opt'][
'rd'][3] *
$this->k;
8423 $annots .=
' /RD ['.sprintf(
'%F %F %F %F',
$l, $r,
$t, $b).
']';
8425 if (isset($pl[
'opt'][
'le']) AND in_array($pl[
'opt'][
'le'], $lineendings)) {
8426 $annots .=
' /LE /'.$pl[
'opt'][
'le'];
8469 case 'fileattachment': {
8470 if ($this->pdfa_mode) {
8474 if (!isset($pl[
'opt'][
'fs'])) {
8478 if (isset($this->embeddedfiles[
$filename][
'f'])) {
8479 $annots .=
' /FS '.$this->embeddedfiles[
$filename][
'f'].
' 0 R';
8480 $iconsapp = array(
'Graph',
'Paperclip',
'PushPin',
'Tag');
8481 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8482 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8484 $annots .=
' /Name /PushPin';
8487 $this->embeddedfiles[
$filename][
'a'] = $key;
8492 if (!isset($pl[
'opt'][
'fs'])) {
8496 if (isset($this->embeddedfiles[
$filename][
'f'])) {
8499 $annots .=
' /Sound '.$this->embeddedfiles[
$filename][
'f'].
' 0 R';
8500 $iconsapp = array(
'Speaker',
'Mic');
8501 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8502 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8504 $annots .=
' /Name /Speaker';
8513 $hmode = array(
'N',
'I',
'O',
'P',
'T');
8514 if (isset($pl[
'opt'][
'h']) AND in_array($pl[
'opt'][
'h'], $hmode)) {
8515 $annots .=
' /H /'.$pl[
'opt'][
'h'];
8517 if (isset($pl[
'opt'][
'mk']) AND (is_array($pl[
'opt'][
'mk'])) AND !empty($pl[
'opt'][
'mk'])) {
8518 $annots .=
' /MK <<';
8519 if (isset($pl[
'opt'][
'mk'][
'r'])) {
8520 $annots .=
' /R '.$pl[
'opt'][
'mk'][
'r'];
8522 if (isset($pl[
'opt'][
'mk'][
'bc']) AND (is_array($pl[
'opt'][
'mk'][
'bc']))) {
8523 $annots .=
' /BC '.TCPDF_COLORS::getColorStringFromArray($pl[
'opt'][
'mk'][
'bc']);
8525 if (isset($pl[
'opt'][
'mk'][
'bg']) AND (is_array($pl[
'opt'][
'mk'][
'bg']))) {
8526 $annots .=
' /BG '.TCPDF_COLORS::getColorStringFromArray($pl[
'opt'][
'mk'][
'bg']);
8528 if (isset($pl[
'opt'][
'mk'][
'ca'])) {
8529 $annots .=
' /CA '.$pl[
'opt'][
'mk'][
'ca'];
8531 if (isset($pl[
'opt'][
'mk'][
'rc'])) {
8532 $annots .=
' /RC '.$pl[
'opt'][
'mk'][
'rc'];
8534 if (isset($pl[
'opt'][
'mk'][
'ac'])) {
8535 $annots .=
' /AC '.$pl[
'opt'][
'mk'][
'ac'];
8537 if (isset($pl[
'opt'][
'mk'][
'i'])) {
8539 if ($info !==
false) {
8540 $annots .=
' /I '.$info[
'n'].
' 0 R';
8543 if (isset($pl[
'opt'][
'mk'][
'ri'])) {
8545 if ($info !==
false) {
8546 $annots .=
' /RI '.$info[
'n'].
' 0 R';
8549 if (isset($pl[
'opt'][
'mk'][
'ix'])) {
8551 if ($info !==
false) {
8552 $annots .=
' /IX '.$info[
'n'].
' 0 R';
8555 if (isset($pl[
'opt'][
'mk'][
'if']) AND (is_array($pl[
'opt'][
'mk'][
'if'])) AND !empty($pl[
'opt'][
'mk'][
'if'])) {
8556 $annots .=
' /IF <<';
8557 $if_sw = array(
'A',
'B',
'S',
'N');
8558 if (isset($pl[
'opt'][
'mk'][
'if'][
'sw']) AND in_array($pl[
'opt'][
'mk'][
'if'][
'sw'], $if_sw)) {
8559 $annots .=
' /SW /'.$pl[
'opt'][
'mk'][
'if'][
'sw'];
8561 $if_s = array(
'A',
'P');
8562 if (isset($pl[
'opt'][
'mk'][
'if'][
's']) AND in_array($pl[
'opt'][
'mk'][
'if'][
's'], $if_s)) {
8563 $annots .=
' /S /'.$pl[
'opt'][
'mk'][
'if'][
's'];
8565 if (isset($pl[
'opt'][
'mk'][
'if'][
'a']) AND (is_array($pl[
'opt'][
'mk'][
'if'][
'a'])) AND !empty($pl[
'opt'][
'mk'][
'if'][
'a'])) {
8566 $annots .= sprintf(
' /A [%F %F]', $pl[
'opt'][
'mk'][
'if'][
'a'][0], $pl[
'opt'][
'mk'][
'if'][
'a'][1]);
8568 if (isset($pl[
'opt'][
'mk'][
'if'][
'fb']) AND ($pl[
'opt'][
'mk'][
'if'][
'fb'])) {
8569 $annots .=
' /FB true';
8573 if (isset($pl[
'opt'][
'mk'][
'tp']) AND ($pl[
'opt'][
'mk'][
'tp'] >= 0) AND ($pl[
'opt'][
'mk'][
'tp'] <= 6)) {
8574 $annots .=
' /TP '.intval($pl[
'opt'][
'mk'][
'tp']);
8579 if (isset($this->radiobutton_groups[$n][$pl[
'txt']])) {
8581 $annots .=
' /Parent '.$this->radiobutton_groups[
$n][$pl[
'txt']].
' 0 R';
8583 if (isset($pl[
'opt'][
't']) AND is_string($pl[
'opt'][
't'])) {
8584 $annots .=
' /T '.$this->_datastring($pl[
'opt'][
't'], $annot_obj_id);
8586 if (isset($pl[
'opt'][
'tu']) AND is_string($pl[
'opt'][
'tu'])) {
8587 $annots .=
' /TU '.$this->_datastring($pl[
'opt'][
'tu'], $annot_obj_id);
8589 if (isset($pl[
'opt'][
'tm']) AND is_string($pl[
'opt'][
'tm'])) {
8590 $annots .=
' /TM '.$this->_datastring($pl[
'opt'][
'tm'], $annot_obj_id);
8592 if (isset($pl[
'opt'][
'ff'])) {
8593 if (is_array($pl[
'opt'][
'ff'])) {
8596 foreach($pl[
'opt'][
'ff'] as $val) {
8597 $flag += 1 << ($val - 1);
8600 $flag = intval($pl[
'opt'][
'ff']);
8602 $annots .=
' /Ff '.$flag;
8604 if (isset($pl[
'opt'][
'maxlen'])) {
8605 $annots .=
' /MaxLen '.intval($pl[
'opt'][
'maxlen']);
8607 if (isset($pl[
'opt'][
'v'])) {
8609 if (is_array($pl[
'opt'][
'v'])) {
8610 foreach ($pl[
'opt'][
'v'] AS $optval) {
8611 if (is_float($optval)) {
8612 $optval = sprintf(
'%F', $optval);
8614 $annots .=
' '.$optval;
8617 $annots .=
' '.$this->_textstring($pl[
'opt'][
'v'], $annot_obj_id);
8620 if (isset($pl[
'opt'][
'dv'])) {
8622 if (is_array($pl[
'opt'][
'dv'])) {
8623 foreach ($pl[
'opt'][
'dv'] AS $optval) {
8624 if (is_float($optval)) {
8625 $optval = sprintf(
'%F', $optval);
8627 $annots .=
' '.$optval;
8630 $annots .=
' '.$this->_textstring($pl[
'opt'][
'dv'], $annot_obj_id);
8633 if (isset($pl[
'opt'][
'rv'])) {
8635 if (is_array($pl[
'opt'][
'rv'])) {
8636 foreach ($pl[
'opt'][
'rv'] AS $optval) {
8637 if (is_float($optval)) {
8638 $optval = sprintf(
'%F', $optval);
8640 $annots .=
' '.$optval;
8643 $annots .=
' '.$this->_textstring($pl[
'opt'][
'rv'], $annot_obj_id);
8646 if (isset($pl[
'opt'][
'a']) AND !empty($pl[
'opt'][
'a'])) {
8647 $annots .=
' /A << '.$pl[
'opt'][
'a'].
' >>';
8649 if (isset($pl[
'opt'][
'aa']) AND !empty($pl[
'opt'][
'aa'])) {
8650 $annots .=
' /AA << '.$pl[
'opt'][
'aa'].
' >>';
8652 if (isset($pl[
'opt'][
'da']) AND !empty($pl[
'opt'][
'da'])) {
8653 $annots .=
' /DA ('.$pl[
'opt'][
'da'].
')';
8655 if (isset($pl[
'opt'][
'q']) AND ($pl[
'opt'][
'q'] >= 0) AND ($pl[
'opt'][
'q'] <= 2)) {
8656 $annots .=
' /Q '.intval($pl[
'opt'][
'q']);
8658 if (isset($pl[
'opt'][
'opt']) AND (is_array($pl[
'opt'][
'opt'])) AND !empty($pl[
'opt'][
'opt'])) {
8659 $annots .=
' /Opt [';
8660 foreach($pl[
'opt'][
'opt'] AS $copt) {
8661 if (is_array($copt)) {
8662 $annots .=
' ['.$this->_textstring($copt[0], $annot_obj_id).
' '.$this->
_textstring($copt[1], $annot_obj_id).
']';
8664 $annots .=
' '.$this->_textstring($copt, $annot_obj_id);
8669 if (isset($pl[
'opt'][
'ti'])) {
8670 $annots .=
' /TI '.intval($pl[
'opt'][
'ti']);
8672 if (isset($pl[
'opt'][
'i']) AND (is_array($pl[
'opt'][
'i'])) AND !empty($pl[
'opt'][
'i'])) {
8674 foreach($pl[
'opt'][
'i'] AS $copt) {
8675 $annots .= intval($copt).
' ';
8684 case 'printermark': {
8702 $this->
_out($this->
_getobj($annot_obj_id).
"\n".$annots.
"\n".
'endobj');
8703 if ($formfield AND !isset($this->radiobutton_groups[$n][$pl[
'txt']])) {
8705 $this->form_obj_id[] = $annot_obj_id;
8722 $stream = trim($stream);
8724 $this->xobjects[
'AX'.$this->n] = array(
'n' => $this->
n);
8726 $out .=
' /Type /XObject';
8727 $out .=
' /Subtype /Form';
8728 $out .=
' /FormType 1';
8729 if ($this->compress) {
8730 $stream = gzcompress($stream);
8731 $out .=
' /Filter /FlateDecode';
8733 $rect = sprintf(
'%F %F',
$w,
$h);
8734 $out .=
' /BBox [0 0 '.$rect.
']';
8735 $out .=
' /Matrix [1 0 0 1 0 0]';
8736 $out .=
' /Resources 2 0 R';
8738 $out .=
' /Length '.strlen($stream);
8740 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
8741 $out .=
"\n".
'endobj';
8753 foreach ($this->diffs as $diff) {
8756 $this->
_out(
'<< /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.
'] >>'.
"\n".
'endobj');
8760 foreach ($this->FontFiles as
$file => $info) {
8762 $fontdir = $info[
'fontdir'];
8766 if (($fontdir !==
false) AND file_exists($fontdir.$file)) {
8767 $fontfile = $fontdir.$file;
8770 } elseif (file_exists(
$file)) {
8774 $font = file_get_contents($fontfile);
8775 $compressed = (substr(
$file, -2) ==
'.z');
8776 if ((!$compressed) AND (isset($info[
'length2']))) {
8777 $header = (ord($font{0}) == 128);
8780 $font = substr($font, 6);
8782 if ($header AND (ord($font[$info[
'length1']]) == 128)) {
8784 $font = substr($font, 0, $info[
'length1']).substr($font, ($info[
'length1'] + 6));
8786 } elseif ($info[
'subset'] AND ((!$compressed) OR ($compressed AND function_exists(
'gzcompress')))) {
8789 $font = gzuncompress($font);
8792 $subsetchars = array();
8793 foreach ($info[
'fontkeys'] as $fontkey) {
8795 $subsetchars += $fontinfo[
'subsetchars'];
8800 $info[
'length1'] = strlen($font);
8803 $font = gzcompress($font);
8809 $out =
'<< /Length '.strlen($stream);
8811 $out .=
' /Filter /FlateDecode';
8813 $out .=
' /Length1 '.$info[
'length1'];
8814 if (isset($info[
'length2'])) {
8815 $out .=
' /Length2 '.$info[
'length2'].
' /Length3 0';
8818 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
8819 $out .=
"\n".
'endobj';
8824 foreach ($this->fontkeys as
$k) {
8827 $type = $font[
'type'];
8828 $name = $font[
'name'];
8829 if ($type ==
'core') {
8831 $out = $this->
_getobj($this->font_obj_ids[$k]).
"\n";
8832 $out .=
'<</Type /Font';
8833 $out .=
' /Subtype /Type1';
8834 $out .=
' /BaseFont /'.$name;
8835 $out .=
' /Name /F'.$font[
'i'];
8836 if ((strtolower($name) !=
'symbol') AND (strtolower($name) !=
'zapfdingbats')) {
8837 $out .=
' /Encoding /WinAnsiEncoding';
8839 if ($k ==
'helvetica') {
8841 $this->annotation_fonts[
$k] = $font[
'i'];
8844 $out .=
"\n".
'endobj';
8846 } elseif (($type ==
'Type1') OR ($type ==
'TrueType')) {
8848 $out = $this->
_getobj($this->font_obj_ids[$k]).
"\n";
8849 $out .=
'<</Type /Font';
8850 $out .=
' /Subtype /'.$type;
8851 $out .=
' /BaseFont /'.$name;
8852 $out .=
' /Name /F'.$font[
'i'];
8853 $out .=
' /FirstChar 32 /LastChar 255';
8854 $out .=
' /Widths '.($this->n + 1).
' 0 R';
8855 $out .=
' /FontDescriptor '.($this->n + 2).
' 0 R';
8857 if (isset($font[
'diff'])) {
8858 $out .=
' /Encoding '.($nf + $font[
'diff']).
' 0 R';
8860 $out .=
' /Encoding /WinAnsiEncoding';
8864 $out .=
"\n".
'endobj';
8869 for ($i = 32; $i < 256; ++$i) {
8870 if (isset($font[
'cw'][$i])) {
8871 $s .= $font[
'cw'][$i].
' ';
8873 $s .= $font[
'dw'].
' ';
8877 $s .=
"\n".
'endobj';
8881 $s =
'<</Type /FontDescriptor /FontName /'.$name;
8882 foreach ($font[
'desc'] as $fdk => $fdv) {
8883 if (is_float($fdv)) {
8884 $fdv = sprintf(
'%F', $fdv);
8886 $s .=
' /'.$fdk.
' '.$fdv.
'';
8889 $s .=
' /FontFile'.($type ==
'Type1' ?
'' :
'2').
' '.$this->FontFiles[$font[
'file']][
'n'].
' 0 R';
8892 $s .=
"\n".
'endobj';
8896 $mtd =
'_put'.strtolower($type);
8897 if (!method_exists($this, $mtd)) {
8898 $this->
Error(
'Unsupported font type: '.$type);
8915 if ($font[
'subset']) {
8917 $subtag = sprintf(
'%06u', $font[
'i']);
8918 $subtag = strtr($subtag,
'0123456789',
'ABCDEFGHIJ');
8919 $fontname .= $subtag.
'+';
8921 $fontname .= $font[
'name'];
8924 $out = $this->
_getobj($this->font_obj_ids[$font[
'fontkey']]).
"\n";
8925 $out .=
'<< /Type /Font';
8926 $out .=
' /Subtype /Type0';
8927 $out .=
' /BaseFont /'.$fontname;
8928 $out .=
' /Name /F'.$font[
'i'];
8929 $out .=
' /Encoding /'.$font[
'enc'];
8930 $out .=
' /ToUnicode '.($this->n + 1).
' 0 R';
8931 $out .=
' /DescendantFonts ['.($this->n + 2).
' 0 R]';
8933 $out .=
"\n".
'endobj';
8942 $this->
_out(
'<<'.$filter.
'/Length '.strlen($stream).
'>> stream'.
"\n".$stream.
"\n".
'endstream'.
"\n".
'endobj');
8946 $out =
'<< /Type /Font';
8947 $out .=
' /Subtype /CIDFontType2';
8948 $out .=
' /BaseFont /'.$fontname;
8950 $cidinfo =
'/Registry '.$this->_datastring($font[
'cidinfo'][
'Registry'], $oid);
8951 $cidinfo .=
' /Ordering '.$this->_datastring($font[
'cidinfo'][
'Ordering'], $oid);
8952 $cidinfo .=
' /Supplement '.$font[
'cidinfo'][
'Supplement'];
8953 $out .=
' /CIDSystemInfo << '.$cidinfo.
' >>';
8954 $out .=
' /FontDescriptor '.($this->n + 1).
' 0 R';
8955 $out .=
' /DW '.$font[
'dw'];
8956 $out .=
"\n".TCPDF_FONTS::_putfontwidths($font, 0);
8958 $out .=
"\n".
'/CIDToGIDMap '.($this->
n + 2).
' 0 R';
8961 $out .=
"\n".
'endobj';
8966 $out =
'<< /Type /FontDescriptor';
8967 $out .=
' /FontName /'.$fontname;
8968 foreach ($font[
'desc'] as $key => $value) {
8969 if (is_float($value)) {
8970 $value = sprintf(
'%F', $value);
8972 $out .=
' /'.$key.
' '.$value;
8977 $out .=
' /FontFile2 '.$this->FontFiles[$font[
'file']][
'n'].
' 0 R';
8978 $fontdir = $this->FontFiles[$font[
'file']][
'fontdir'];
8981 $out .=
"\n".
'endobj';
8988 $ctgfile = strtolower($font[
'ctg']);
8992 if (($fontdir !==
false) AND file_exists($fontdir.$ctgfile)) {
8993 $fontfile = $fontdir.$ctgfile;
8996 } elseif (file_exists($ctgfile)) {
8997 $fontfile = $ctgfile;
9000 $this->
Error(
'Font file not found: '.$ctgfile);
9002 $stream = $this->
_getrawstream(file_get_contents($fontfile));
9003 $out =
'<< /Length '.strlen($stream).
'';
9004 if (substr($fontfile, -2) ==
'.z') {
9008 $out .=
' /Filter /FlateDecode';
9011 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
9012 $out .=
"\n".
'endobj';
9027 if (!isset($font[
'cw'][1])) {
9030 if (isset($font[
'cidinfo'][
'uni2cid'])) {
9032 $uni2cid = $font[
'cidinfo'][
'uni2cid'];
9034 foreach ($font[
'cw'] as $uni => $width) {
9035 if (isset($uni2cid[$uni])) {
9036 $cw[($uni2cid[$uni] + $cidoffset)] = $width;
9037 } elseif ($uni < 256) {
9041 $font = array_merge($font, array(
'cw' => $cw));
9043 $name = $font[
'name'];
9044 $enc = $font[
'enc'];
9046 $longname = $name.
'-'.$enc;
9050 $out = $this->
_getobj($this->font_obj_ids[$font[
'fontkey']]).
"\n";
9051 $out .=
'<</Type /Font';
9052 $out .=
' /Subtype /Type0';
9053 $out .=
' /BaseFont /'.$longname;
9054 $out .=
' /Name /F'.$font[
'i'];
9056 $out .=
' /Encoding /'.$enc;
9058 $out .=
' /DescendantFonts ['.($this->n + 1).
' 0 R]';
9060 $out .=
"\n".
'endobj';
9063 $out =
'<</Type /Font';
9064 $out .=
' /Subtype /CIDFontType0';
9065 $out .=
' /BaseFont /'.$name;
9066 $cidinfo =
'/Registry '.$this->_datastring($font[
'cidinfo'][
'Registry'], $oid);
9067 $cidinfo .=
' /Ordering '.$this->_datastring($font[
'cidinfo'][
'Ordering'], $oid);
9068 $cidinfo .=
' /Supplement '.$font[
'cidinfo'][
'Supplement'];
9069 $out .=
' /CIDSystemInfo <<'.$cidinfo.
'>>';
9070 $out .=
' /FontDescriptor '.($this->n + 1).
' 0 R';
9071 $out .=
' /DW '.$font[
'dw'];
9072 $out .=
"\n".TCPDF_FONTS::_putfontwidths($font, $cidoffset);
9074 $out .=
"\n".
'endobj';
9077 $s =
'<</Type /FontDescriptor /FontName /'.$name;
9078 foreach ($font[
'desc'] as
$k => $v) {
9079 if (
$k !=
'Style') {
9081 $v = sprintf(
'%F', $v);
9083 $s .=
' /'.$k.
' '.$v.
'';
9087 $s .=
"\n".
'endobj';
9097 foreach ($this->imagekeys as
$file) {
9100 if ((!$this->pdfa_mode) AND isset($info[
'altimgs']) AND !empty($info[
'altimgs'])) {
9103 foreach ($info[
'altimgs'] as $altimage) {
9104 if (isset($this->xobjects[
'I'.$altimage[0]][
'n'])) {
9105 $out .=
' << /Image '.$this->xobjects[
'I'.$altimage[0]][
'n'].
' 0 R';
9106 $out .=
' /DefaultForPrinting';
9107 if ($altimage[1] ===
true) {
9116 $out .=
"\n".
'endobj';
9121 $this->xobjects[
'I'.$info[
'i']] = array(
'n' => $oid);
9123 $out =
'<</Type /XObject';
9124 $out .=
' /Subtype /Image';
9125 $out .=
' /Width '.$info[
'w'];
9126 $out .=
' /Height '.$info[
'h'];
9127 if (array_key_exists(
'masked', $info)) {
9128 $out .=
' /SMask '.($this->n - 1).
' 0 R';
9132 if (isset($info[
'icc']) AND ($info[
'icc'] !==
false)) {
9135 $out .=
' /ColorSpace [/ICCBased '.($this->n + 1).
' 0 R]';
9136 } elseif ($info[
'cs'] ==
'Indexed') {
9138 $out .=
' /ColorSpace [/Indexed /DeviceRGB '.((strlen($info[
'pal']) / 3) - 1).
' '.($this->
n + 1).
' 0 R]';
9141 $out .=
' /ColorSpace /'.$info[
'cs'];
9143 if ($info[
'cs'] ==
'DeviceCMYK') {
9144 $out .=
' /Decode [1 0 1 0 1 0 1 0]';
9146 $out .=
' /BitsPerComponent '.$info[
'bpc'];
9147 if (isset($altoid) AND ($altoid > 0)) {
9149 $out .=
' /Alternates '.$altoid.
' 0 R';
9151 if (isset($info[
'exurl']) AND !empty($info[
'exurl'])) {
9153 $out .=
' /Length 0';
9154 $out .=
' /F << /FS /URL /F '.$this->_datastring($info[
'exurl'], $oid).
' >>';
9155 if (isset($info[
'f'])) {
9156 $out .=
' /FFilter /'.$info[
'f'];
9159 $out .=
' stream'.
"\n".
'endstream';
9161 if (isset($info[
'f'])) {
9162 $out .=
' /Filter /'.$info[
'f'];
9164 if (isset($info[
'parms'])) {
9165 $out .=
' '.$info[
'parms'];
9167 if (isset($info[
'trns']) AND is_array($info[
'trns'])) {
9169 $count_info = count($info[
'trns']);
9170 for ($i=0; $i < $count_info; ++$i) {
9171 $trns .= $info[
'trns'][$i].
' '.$info[
'trns'][$i].
' ';
9173 $out .=
' /Mask ['.$trns.
']';
9176 $out .=
' /Length '.strlen($stream).
' >>';
9177 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
9179 $out .=
"\n".
'endobj';
9186 $this->
_out(
'<</N '.$info[
'ch'].
' /Alternate /'.$info[
'cs'].
' '.$filter.
'/Length '.strlen($icc).
'>> stream'.
"\n".$icc.
"\n".
'endstream'.
"\n".
'endobj');
9187 } elseif ($info[
'cs'] ==
'Indexed') {
9192 $this->
_out(
'<<'.$filter.
'/Length '.strlen($pal).
'>> stream'.
"\n".$pal.
"\n".
'endstream'.
"\n".
'endobj');
9205 foreach ($this->xobjects as $key => $data) {
9206 if (isset($data[
'outdata'])) {
9207 $stream = str_replace($this->epsmarker,
'', trim($data[
'outdata']));
9210 $out .=
' /Type /XObject';
9211 $out .=
' /Subtype /Form';
9212 $out .=
' /FormType 1';
9213 if ($this->compress) {
9214 $stream = gzcompress($stream);
9215 $out .=
' /Filter /FlateDecode';
9217 $out .= sprintf(
' /BBox [%F %F %F %F]', ($data[
'x'] * $this->k), (-$data[
'y'] * $this->k), (($data[
'w'] + $data[
'x']) * $this->k), (($data[
'h'] - $data[
'y']) * $this->k));
9218 $out .=
' /Matrix [1 0 0 1 0 0]';
9219 $out .=
' /Resources <<';
9220 $out .=
' /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]';
9221 if (!$this->pdfa_mode) {
9223 if (isset($data[
'extgstates']) AND !empty($data[
'extgstates'])) {
9224 $out .=
' /ExtGState <<';
9225 foreach ($data[
'extgstates'] as
$k => $extgstate) {
9226 if (isset($this->extgstates[
$k][
'name'])) {
9227 $out .=
' /'.$this->extgstates[
$k][
'name'];
9231 $out .=
' '.$this->extgstates[
$k][
'n'].
' 0 R';
9235 if (isset($data[
'gradients']) AND !empty($data[
'gradients'])) {
9238 foreach ($data[
'gradients'] as $id => $grad) {
9240 $gp .=
' /p'.$id.
' '.$this->gradients[$id][
'pattern'].
' 0 R';
9242 $gs .=
' /Sh'.$id.
' '.$this->gradients[$id][
'id'].
' 0 R';
9244 $out .=
' /Pattern <<'.$gp.
' >>';
9245 $out .=
' /Shading <<'.$gs.
' >>';
9249 if (isset($data[
'spot_colors']) AND !empty($data[
'spot_colors'])) {
9250 $out .=
' /ColorSpace <<';
9251 foreach ($data[
'spot_colors'] as $name => $color) {
9252 $out .=
' /CS'.$color[
'i'].
' '.$this->spot_colors[$name][
'n'].
' 0 R';
9257 if (!empty($data[
'fonts'])) {
9258 $out .=
' /Font <<';
9259 foreach ($data[
'fonts'] as $fontkey => $fontid) {
9260 $out .=
' /F'.$fontid.
' '.$this->font_obj_ids[$fontkey].
' 0 R';
9265 if (!empty($data[
'images']) OR !empty($data[
'xobjects'])) {
9266 $out .=
' /XObject <<';
9267 foreach ($data[
'images'] as $imgid) {
9268 $out .=
' /I'.$imgid.
' '.$this->xobjects[
'I'.$imgid][
'n'].
' 0 R';
9270 foreach ($data[
'xobjects'] as $sub_id => $sub_objid) {
9271 $out .=
' /'.$sub_id.
' '.$sub_objid[
'n'].
' 0 R';
9276 if (isset($data[
'group']) AND ($data[
'group'] !==
false)) {
9278 $out .=
' /Group << /Type /Group /S /Transparency';
9279 if (is_array($data[
'group'])) {
9280 if (isset($data[
'group'][
'CS']) AND !empty($data[
'group'][
'CS'])) {
9281 $out .=
' /CS /'.$data[
'group'][
'CS'];
9283 if (isset($data[
'group'][
'I'])) {
9284 $out .=
' /I /'.($data[
'group'][
'I']===
true?
'true':
'false');
9286 if (isset($data[
'group'][
'K'])) {
9287 $out .=
' /K /'.($data[
'group'][
'K']===
true?
'true':
'false');
9293 $out .=
' /Length '.strlen($stream);
9295 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
9296 $out .=
"\n".
'endobj';
9308 foreach ($this->spot_colors as $name => $color) {
9310 $this->spot_colors[$name][
'n'] =
$this->n;
9311 $out =
'[/Separation /'.str_replace(
' ',
'#20', $name);
9312 $out .=
' /DeviceCMYK <<';
9313 $out .=
' /Range [0 1 0 1 0 1 0 1] /C0 [0 0 0 0]';
9314 $out .=
' '.sprintf(
'/C1 [%F %F %F %F] ', ($color[
'C'] / 100), ($color[
'M'] / 100), ($color[
'Y'] / 100), ($color[
'K'] / 100));
9315 $out .=
' /FunctionType 2 /Domain [0 1] /N 1>>]';
9316 $out .=
"\n".
'endobj';
9329 foreach ($this->xobjects as $id => $objid) {
9330 $out .=
' /'.$id.
' '.$objid[
'n'].
' 0 R';
9341 $out .=
'<< /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]';
9342 $out .=
' /Font <<';
9343 foreach ($this->fontkeys as $fontkey) {
9345 $out .=
' /F'.$font[
'i'].
' '.$font[
'n'].
' 0 R';
9348 $out .=
' /XObject <<';
9352 if (!empty($this->pdflayers)) {
9353 $out .=
' /Properties <<';
9354 foreach ($this->pdflayers as $layer) {
9355 $out .=
' /'.$layer[
'layer'].
' '.$layer[
'objid'].
' 0 R';
9359 if (!$this->pdfa_mode) {
9361 if (isset($this->extgstates) AND !empty($this->extgstates)) {
9362 $out .=
' /ExtGState <<';
9363 foreach ($this->extgstates as
$k => $extgstate) {
9364 if (isset($extgstate[
'name'])) {
9365 $out .=
' /'.$extgstate[
'name'];
9369 $out .=
' '.$extgstate[
'n'].
' 0 R';
9373 if (isset($this->gradients) AND !empty($this->gradients)) {
9376 foreach ($this->gradients as $id => $grad) {
9378 $gp .=
' /p'.$id.
' '.$grad[
'pattern'].
' 0 R';
9380 $gs .=
' /Sh'.$id.
' '.$grad[
'id'].
' 0 R';
9382 $out .=
' /Pattern <<'.$gp.
' >>';
9383 $out .=
' /Shading <<'.$gs.
' >>';
9387 if (isset($this->spot_colors) AND !empty($this->spot_colors)) {
9388 $out .=
' /ColorSpace <<';
9389 foreach ($this->spot_colors as $color) {
9390 $out .=
' /CS'.$color[
'i'].
' '.$color[
'n'].
' 0 R';
9395 $out .=
"\n".
'endobj';
9431 if ($this->docinfounicode) {
9432 $this->isunicode =
true;
9436 $out .=
' /Title '.$this->_textstring($this->title, $oid);
9440 $out .=
' /Author '.$this->_textstring($this->author, $oid);
9444 $out .=
' /Subject '.$this->_textstring($this->subject, $oid);
9448 $out .=
' /Keywords '.$this->_textstring($this->keywords.
' TCPDF', $oid);
9452 $out .=
' /Creator '.$this->_textstring($this->creator, $oid);
9455 $this->isunicode = $prev_isunicode;
9459 $out .=
' /CreationDate '.$this->_datestring(0, $this->doc_creation_timestamp);
9461 $out .=
' /ModDate '.$this->_datestring(0, $this->doc_modification_timestamp);
9463 $out .=
' /Trapped /False';
9465 $out .=
"\n".
'endobj';
9478 $this->custom_xmp = $xmp;
9491 $this->isunicode =
true;
9493 $this->encrypted =
false;
9495 $xmp =
'<?xpacket begin="'.TCPDF_FONTS::unichr(0xfeff, $this->isunicode).
'" id="W5M0MpCehiHzreSzNTczkc9d"?>'.
"\n";
9496 $xmp .=
'<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:08:04">'.
"\n";
9497 $xmp .=
"\t".
'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">'.
"\n";
9498 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">'.
"\n";
9499 $xmp .=
"\t\t\t".
'<dc:format>application/pdf</dc:format>'.
"\n";
9500 $xmp .=
"\t\t\t".
'<dc:title>'.
"\n";
9501 $xmp .=
"\t\t\t\t".
'<rdf:Alt>'.
"\n";
9503 $xmp .=
"\t\t\t\t".
'</rdf:Alt>'.
"\n";
9504 $xmp .=
"\t\t\t".
'</dc:title>'.
"\n";
9505 $xmp .=
"\t\t\t".
'<dc:creator>'.
"\n";
9506 $xmp .=
"\t\t\t\t".
'<rdf:Seq>'.
"\n";
9508 $xmp .=
"\t\t\t\t".
'</rdf:Seq>'.
"\n";
9509 $xmp .=
"\t\t\t".
'</dc:creator>'.
"\n";
9510 $xmp .=
"\t\t\t".
'<dc:description>'.
"\n";
9511 $xmp .=
"\t\t\t\t".
'<rdf:Alt>'.
"\n";
9513 $xmp .=
"\t\t\t\t".
'</rdf:Alt>'.
"\n";
9514 $xmp .=
"\t\t\t".
'</dc:description>'.
"\n";
9515 $xmp .=
"\t\t\t".
'<dc:subject>'.
"\n";
9516 $xmp .=
"\t\t\t\t".
'<rdf:Bag>'.
"\n";
9518 $xmp .=
"\t\t\t\t".
'</rdf:Bag>'.
"\n";
9519 $xmp .=
"\t\t\t".
'</dc:subject>'.
"\n";
9520 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9523 $doccreationdate = substr($dcdate, 0, 4).
'-'.substr($dcdate, 4, 2).
'-'.substr($dcdate, 6, 2);
9524 $doccreationdate .=
'T'.substr($dcdate, 8, 2).
':'.substr($dcdate, 10, 2).
':'.substr($dcdate, 12, 2);
9525 $doccreationdate .=
'+'.substr($dcdate, 15, 2).
':'.substr($dcdate, 18, 2);
9529 $docmoddate = substr($dmdate, 0, 4).
'-'.substr($dmdate, 4, 2).
'-'.substr($dmdate, 6, 2);
9530 $docmoddate .=
'T'.substr($dmdate, 8, 2).
':'.substr($dmdate, 10, 2).
':'.substr($dmdate, 12, 2);
9531 $docmoddate .=
'+'.substr($dmdate, 15, 2).
':'.substr($dmdate, 18, 2);
9533 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">'.
"\n";
9534 $xmp .=
"\t\t\t".
'<xmp:CreateDate>'.$doccreationdate.
'</xmp:CreateDate>'.
"\n";
9535 $xmp .=
"\t\t\t".
'<xmp:CreatorTool>'.$this->creator.
'</xmp:CreatorTool>'.
"\n";
9536 $xmp .=
"\t\t\t".
'<xmp:ModifyDate>'.$docmoddate.
'</xmp:ModifyDate>'.
"\n";
9537 $xmp .=
"\t\t\t".
'<xmp:MetadataDate>'.$doccreationdate.
'</xmp:MetadataDate>'.
"\n";
9538 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9539 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">'.
"\n";
9542 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9543 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">'.
"\n";
9544 $uuid =
'uuid:'.substr($this->file_id, 0, 8).
'-'.substr($this->file_id, 8, 4).
'-'.substr($this->file_id, 12, 4).
'-'.substr($this->file_id, 16, 4).
'-'.substr($this->file_id, 20, 12);
9545 $xmp .=
"\t\t\t".
'<xmpMM:DocumentID>'.$uuid.
'</xmpMM:DocumentID>'.
"\n";
9546 $xmp .=
"\t\t\t".
'<xmpMM:InstanceID>'.$uuid.
'</xmpMM:InstanceID>'.
"\n";
9547 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9548 if ($this->pdfa_mode) {
9549 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/">'.
"\n";
9550 $xmp .=
"\t\t\t".
'<pdfaid:part>1</pdfaid:part>'.
"\n";
9551 $xmp .=
"\t\t\t".
'<pdfaid:conformance>B</pdfaid:conformance>'.
"\n";
9552 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9555 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/" xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#" xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#">'.
"\n";
9556 $xmp .=
"\t\t\t".
'<pdfaExtension:schemas>'.
"\n";
9557 $xmp .=
"\t\t\t\t".
'<rdf:Bag>'.
"\n";
9558 $xmp .=
"\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9559 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:namespaceURI>http://ns.adobe.com/pdf/1.3/</pdfaSchema:namespaceURI>'.
"\n";
9560 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:prefix>pdf</pdfaSchema:prefix>'.
"\n";
9561 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:schema>Adobe PDF Schema</pdfaSchema:schema>'.
"\n";
9562 $xmp .=
"\t\t\t\t\t".
'</rdf:li>'.
"\n";
9563 $xmp .=
"\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9564 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:namespaceURI>http://ns.adobe.com/xap/1.0/mm/</pdfaSchema:namespaceURI>'.
"\n";
9565 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:prefix>xmpMM</pdfaSchema:prefix>'.
"\n";
9566 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:schema>XMP Media Management Schema</pdfaSchema:schema>'.
"\n";
9567 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:property>'.
"\n";
9568 $xmp .=
"\t\t\t\t\t\t\t".
'<rdf:Seq>'.
"\n";
9569 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9570 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9571 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>UUID based identifier for specific incarnation of a document</pdfaProperty:description>'.
"\n";
9572 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>InstanceID</pdfaProperty:name>'.
"\n";
9573 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>URI</pdfaProperty:valueType>'.
"\n";
9574 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9575 $xmp .=
"\t\t\t\t\t\t\t".
'</rdf:Seq>'.
"\n";
9576 $xmp .=
"\t\t\t\t\t\t".
'</pdfaSchema:property>'.
"\n";
9577 $xmp .=
"\t\t\t\t\t".
'</rdf:li>'.
"\n";
9578 $xmp .=
"\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9579 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:namespaceURI>http://www.aiim.org/pdfa/ns/id/</pdfaSchema:namespaceURI>'.
"\n";
9580 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:prefix>pdfaid</pdfaSchema:prefix>'.
"\n";
9581 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:schema>PDF/A ID Schema</pdfaSchema:schema>'.
"\n";
9582 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:property>'.
"\n";
9583 $xmp .=
"\t\t\t\t\t\t\t".
'<rdf:Seq>'.
"\n";
9584 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9585 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9586 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>Part of PDF/A standard</pdfaProperty:description>'.
"\n";
9587 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>part</pdfaProperty:name>'.
"\n";
9588 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>Integer</pdfaProperty:valueType>'.
"\n";
9589 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9590 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9591 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9592 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>Amendment of PDF/A standard</pdfaProperty:description>'.
"\n";
9593 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>amd</pdfaProperty:name>'.
"\n";
9594 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>Text</pdfaProperty:valueType>'.
"\n";
9595 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9596 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9597 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9598 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>Conformance level of PDF/A standard</pdfaProperty:description>'.
"\n";
9599 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>conformance</pdfaProperty:name>'.
"\n";
9600 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>Text</pdfaProperty:valueType>'.
"\n";
9601 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9602 $xmp .=
"\t\t\t\t\t\t\t".
'</rdf:Seq>'.
"\n";
9603 $xmp .=
"\t\t\t\t\t\t".
'</pdfaSchema:property>'.
"\n";
9604 $xmp .=
"\t\t\t\t\t".
'</rdf:li>'.
"\n";
9605 $xmp .=
"\t\t\t\t".
'</rdf:Bag>'.
"\n";
9606 $xmp .=
"\t\t\t".
'</pdfaExtension:schemas>'.
"\n";
9607 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9608 $xmp .=
"\t".
'</rdf:RDF>'.
"\n";
9610 $xmp .=
'</x:xmpmeta>'.
"\n";
9611 $xmp .=
'<?xpacket end="w"?>';
9612 $out =
'<< /Type /Metadata /Subtype /XML /Length '.strlen($xmp).
' >> stream'.
"\n".$xmp.
"\n".
'endstream'.
"\n".
'endobj';
9614 $this->isunicode = $prev_isunicode;
9615 $this->encrypted = $prev_encrypted;
9629 if ($this->pdfa_mode OR $this->force_srgb) {
9631 $icc = file_get_contents(dirname(__FILE__).
'/include/sRGB.icc');
9633 if ($this->compress) {
9634 $filter =
' /Filter /FlateDecode';
9635 $icc = gzcompress($icc);
9638 $this->
_out(
'<</N 3 '.$filter.
'/Length '.strlen($icc).
'>> stream'.
"\n".$icc.
"\n".
'endstream'.
"\n".
'endobj');
9642 $out =
'<< /Type /Catalog';
9643 $out .=
' /Version /'.$this->PDFVersion;
9645 $out .=
' /Pages 1 0 R';
9647 $out .=
' /Names <<';
9648 if ((!$this->pdfa_mode) AND !empty($this->n_js)) {
9649 $out .=
' /JavaScript '.$this->n_js;
9651 if (!empty($this->efnames)) {
9652 $out .=
' /EmbeddedFiles <</Names [';
9653 foreach ($this->efnames AS $fn => $fref) {
9654 $out .=
' '.$this->_datastring($fn).
' '.$fref;
9659 if (!empty($this->dests)) {
9660 $out .=
' /Dests '.($this->n_dests).
' 0 R';
9664 $out .=
' /PageLayout /'.$this->LayoutMode;
9667 $out .=
' /PageMode /'.$this->PageMode;
9669 if (count($this->outlines) > 0) {
9670 $out .=
' /Outlines '.$this->OutlineRoot.
' 0 R';
9671 $out .=
' /PageMode /UseOutlines';
9674 if ($this->ZoomMode ==
'fullpage') {
9675 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /Fit]';
9676 } elseif ($this->ZoomMode ==
'fullwidth') {
9677 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /FitH null]';
9678 } elseif ($this->ZoomMode ==
'real') {
9679 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /XYZ null null 1]';
9680 } elseif (!is_string($this->ZoomMode)) {
9681 $out .= sprintf(
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /XYZ null null %F]', ($this->ZoomMode / 100));
9685 $out .=
' /Metadata '.$xmpobj.
' 0 R';
9688 if (isset($this->l[
'a_meta_language'])) {
9689 $out .=
' /Lang '.$this->_textstring($this->l[
'a_meta_language'], $oid);
9693 if ($this->pdfa_mode OR $this->force_srgb) {
9694 $out .=
' /OutputIntents [<<';
9695 $out .=
' /Type /OutputIntent';
9696 $out .=
' /S /GTS_PDFA1';
9697 $out .=
' /OutputCondition '.$this->_textstring(
'sRGB IEC61966-2.1', $oid);
9698 $out .=
' /OutputConditionIdentifier '.$this->_textstring(
'sRGB IEC61966-2.1', $oid);
9699 $out .=
' /RegistryName '.$this->_textstring(
'http://www.color.org', $oid);
9700 $out .=
' /Info '.$this->_textstring(
'sRGB IEC61966-2.1', $oid);
9701 $out .=
' /DestOutputProfile '.$iccobj.
' 0 R';
9705 if (!empty($this->pdflayers)) {
9707 $lyrobjs_print =
'';
9709 foreach ($this->pdflayers as $layer) {
9710 $lyrobjs .=
' '.$layer[
'objid'].
' 0 R';
9711 if ($layer[
'print']) {
9712 $lyrobjs_print .=
' '.$layer[
'objid'].
' 0 R';
9714 if ($layer[
'view']) {
9715 $lyrobjs_view .=
' '.$layer[
'objid'].
' 0 R';
9718 $out .=
' /OCProperties << /OCGs ['.$lyrobjs.
']';
9720 $out .=
' /Name '.$this->_textstring(
'Layers', $oid);
9721 $out .=
' /Creator '.$this->_textstring(
'TCPDF', $oid);
9722 $out .=
' /BaseState /ON';
9723 $out .=
' /ON ['.$lyrobjs_print.
']';
9724 $out .=
' /OFF ['.$lyrobjs_view.
']';
9725 $out .=
' /Intent /View';
9727 $out .=
' << /Event /Print /OCGs ['.$lyrobjs.
'] /Category [/Print] >>';
9728 $out .=
' << /Event /View /OCGs ['.$lyrobjs.
'] /Category [/View] >>';
9730 $out .=
' /Order ['.$lyrobjs.
']';
9731 $out .=
' /ListMode /AllPages';
9738 if (!empty($this->form_obj_id) OR ($this->sign AND isset($this->signature_data[
'cert_type']))) {
9739 $out .=
' /AcroForm <<';
9741 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9743 $objrefs .= $this->sig_obj_id.
' 0 R';
9745 if (!empty($this->empty_signature_appearance)) {
9746 foreach ($this->empty_signature_appearance as $esa) {
9748 $objrefs .=
' '.$esa[
'objid'].
' 0 R';
9751 if (!empty($this->form_obj_id)) {
9752 foreach($this->form_obj_id as $objid) {
9753 $objrefs .=
' '.$objid.
' 0 R';
9756 $out .=
' /Fields ['.$objrefs.
']';
9758 $out .=
' /NeedAppearances false';
9759 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9760 if ($this->signature_data[
'cert_type'] > 0) {
9761 $out .=
' /SigFlags 3';
9763 $out .=
' /SigFlags 1';
9767 if (isset($this->annotation_fonts) AND !empty($this->annotation_fonts)) {
9769 $out .=
' /Font <<';
9770 foreach ($this->annotation_fonts as $fontkey => $fontid) {
9771 $out .=
' /F'.$fontid.
' '.$this->font_obj_ids[$fontkey].
' 0 R';
9776 $out .=
' /DA (/F'.$font[
'i'].
' 0 Tf 0 g)';
9777 $out .=
' /Q '.(($this->rtl)?
'2':
'0');
9781 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9782 if ($this->signature_data[
'cert_type'] > 0) {
9783 $out .=
' /Perms << /DocMDP '.($this->sig_obj_id + 1).
' 0 R >>';
9785 $out .=
' /Perms << /UR3 '.($this->sig_obj_id + 1).
' 0 R >>';
9794 $out .=
"\n".
'endobj';
9808 $out =
' /ViewerPreferences <<';
9810 $out .=
' /Direction /R2L';
9812 $out .=
' /Direction /L2R';
9814 if (isset($vp[
'HideToolbar']) AND ($vp[
'HideToolbar'])) {
9815 $out .=
' /HideToolbar true';
9817 if (isset($vp[
'HideMenubar']) AND ($vp[
'HideMenubar'])) {
9818 $out .=
' /HideMenubar true';
9820 if (isset($vp[
'HideWindowUI']) AND ($vp[
'HideWindowUI'])) {
9821 $out .=
' /HideWindowUI true';
9823 if (isset($vp[
'FitWindow']) AND ($vp[
'FitWindow'])) {
9824 $out .=
' /FitWindow true';
9826 if (isset($vp[
'CenterWindow']) AND ($vp[
'CenterWindow'])) {
9827 $out .=
' /CenterWindow true';
9829 if (isset($vp[
'DisplayDocTitle']) AND ($vp[
'DisplayDocTitle'])) {
9830 $out .=
' /DisplayDocTitle true';
9832 if (isset($vp[
'NonFullScreenPageMode'])) {
9833 $out .=
' /NonFullScreenPageMode /'.$vp[
'NonFullScreenPageMode'];
9835 if (isset($vp[
'ViewArea'])) {
9836 $out .=
' /ViewArea /'.$vp[
'ViewArea'];
9838 if (isset($vp[
'ViewClip'])) {
9839 $out .=
' /ViewClip /'.$vp[
'ViewClip'];
9841 if (isset($vp[
'PrintArea'])) {
9842 $out .=
' /PrintArea /'.$vp[
'PrintArea'];
9844 if (isset($vp[
'PrintClip'])) {
9845 $out .=
' /PrintClip /'.$vp[
'PrintClip'];
9847 if (isset($vp[
'PrintScaling'])) {
9848 $out .=
' /PrintScaling /'.$vp[
'PrintScaling'];
9851 $out .=
' /Duplex /'.$vp[
'Duplex'];
9853 if (isset($vp[
'PickTrayByPDFSize'])) {
9854 if ($vp[
'PickTrayByPDFSize']) {
9855 $out .=
' /PickTrayByPDFSize true';
9857 $out .=
' /PickTrayByPDFSize false';
9860 if (isset($vp[
'PrintPageRange'])) {
9861 $PrintPageRangeNum =
'';
9862 foreach ($vp[
'PrintPageRange'] as
$k => $v) {
9863 $PrintPageRangeNum .=
' '.($v - 1).
'';
9865 $out .=
' /PrintPageRange ['.substr($PrintPageRangeNum,1).
']';
9867 if (isset($vp[
'NumCopies'])) {
9868 $out .=
' /NumCopies '.intval($vp[
'NumCopies']);
9879 $this->
_out(
'%PDF-'.$this->PDFVersion);
9880 $this->
_out(
'%'.chr(0xe2).chr(0xe3).chr(0xcf).chr(0xd3));
9888 if (isset($this->CurrentFont[
'fontkey']) AND isset($this->CurrentFont[
'subsetchars'])) {
9890 $this->
setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
9897 if (!empty($this->empty_signature_appearance)) {
9898 foreach ($this->empty_signature_appearance as $key => $esa) {
9901 $out .=
'<< /Type /Annot';
9902 $out .=
' /Subtype /Widget';
9903 $out .=
' /Rect ['.$esa[
'rect'].
']';
9904 $out .=
' /P '.$this->page_obj_id[($esa[
'page'])].
' 0 R';
9906 $out .=
' /FT /Sig';
9907 $signame = $esa[
'name'].sprintf(
' [%03d]', ($key + 1));
9908 $out .=
' /T '.$this->_textstring($signame, $esa[
'objid']);
9911 $out .=
"\n".
'endobj';
9916 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9919 $out .=
'<< /Type /Annot';
9920 $out .=
' /Subtype /Widget';
9921 $out .=
' /Rect ['.$this->signature_appearance[
'rect'].
']';
9922 $out .=
' /P '.$this->page_obj_id[($this->signature_appearance[
'page'])].
' 0 R';
9924 $out .=
' /FT /Sig';
9925 $out .=
' /T '.$this->_textstring($this->signature_appearance[
'name'], $this->sig_obj_id);
9927 $out .=
' /V '.($this->sig_obj_id + 1).
' 0 R';
9929 $out .=
"\n".
'endobj';
9941 $this->
_out(
'xref');
9942 $this->
_out(
'0 '.($this->
n + 1));
9943 $this->
_out(
'0000000000 65535 f ');
9944 $freegen = ($this->
n + 2);
9946 if (!isset($this->offsets[$i]) AND ($i > 1)) {
9947 $this->
_out(sprintf(
'0000000000 %05d f ', $freegen));
9950 $this->
_out(sprintf(
'%010d 00000 n ', $this->offsets[$i]));
9954 $out =
'trailer'.
"\n";
9956 $out .=
' /Size '.($this->n + 1);
9957 $out .=
' /Root '.$objid_catalog.
' 0 R';
9958 $out .=
' /Info '.$objid_info.
' 0 R';
9959 if ($this->encrypted) {
9960 $out .=
' /Encrypt '.$this->encryptdata[
'objid'].
' 0 R';
9962 $out .=
' /ID [ <'.$this->file_id.
'> <'.$this->file_id.
'> ]';
9965 $this->
_out(
'startxref');
9967 $this->
_out(
'%%EOF');
9969 if ($this->diskcache) {
9971 foreach ($this->imagekeys as $key) {
9973 unlink($this->images[$key]);
9975 foreach ($this->fontkeys as $key) {
9977 unlink($this->fonts[$key]);
9997 if (isset($this->CurOrientation)) {
9999 } elseif ($this->fwPt > $this->fhPt) {
10001 $orientation =
'L';
10004 $orientation =
'P';
10008 $this->pagedim[
$this->page] = $this->pagedim[($this->page - 1)];
10019 if (isset($this->newpagegroup[$this->page])) {
10021 $this->currpagegroup = $this->newpagegroup[
$this->page];
10023 } elseif (isset($this->currpagegroup) AND ($this->currpagegroup > 0)) {
10055 if ($objid ===
'') {
10061 return $objid.
' 0 obj';
10086 return sprintf(
'%F %F %F %F re f',
$x * $this->k, ((($this->h -
$y) * $this->k) + $linew),
$w * $this->k, $linew);
10111 return sprintf(
'%F %F %F %F re f',
$x * $this->k, ((($this->h -
$y) * $this->k) + $linew + ($this->FontSizePt / 3)),
$w * $this->k, $linew);
10137 return sprintf(
'%F %F %F %F re f',
$x * $this->k, (($this->h -
$y + $this->FontAscent) * $this->k) - $linew,
$w * $this->k, $linew);
10163 if (is_string($time)) {
10166 $this->doc_creation_timestamp = intval($time);
10176 if (is_string($time)) {
10179 $this->doc_modification_timestamp = intval($time);
10225 if ($this->isunicode) {
10241 if ($this->isunicode) {
10242 if (($this->CurrentFont[
'type'] ==
'core') OR ($this->CurrentFont[
'type'] ==
'TrueType') OR ($this->CurrentFont[
'type'] ==
'Type1')) {
10296 if ($this->state == 2) {
10297 if ($this->inxobj) {
10300 } elseif ((!$this->InFooter) AND isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) {
10303 $page = substr($pagebuff, 0, -$this->footerlen[$this->page]);
10304 $footer = substr($pagebuff, -$this->footerlen[$this->page]);
10307 $this->footerpos[
$this->page] += strlen($s.
"\n");
10312 } elseif ($this->state > 0) {
10325 $this->header_font = $font;
10345 $this->footer_font = $font;
10365 $this->l = $language;
10366 if (isset($this->l[
'a_meta_dir'])) {
10367 $this->rtl = $this->l[
'a_meta_dir']==
'rtl' ?
true :
false;
10369 $this->rtl =
false;
10378 if ($this->state < 3) {
10396 public function addHtmlLink($url, $name, $fill=
false, $firstline=
false, $color=
'', $style=-1, $firstblock=
false) {
10397 if (isset($url[1]) AND ($url[0] ==
'#') AND is_numeric($url[1])) {
10399 $lnkdata = explode(
',', $url);
10400 if (isset($lnkdata[0])) {
10401 $page = intval(substr($lnkdata[0], 1));
10405 if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
10406 $lnky = floatval($lnkdata[1]);
10417 if (empty($color)) {
10422 if ($style == -1) {
10423 $this->
SetFont(
'', $this->FontStyle.$this->htmlLinkFontStyle);
10425 $this->
SetFont(
'', $this->FontStyle.$style);
10427 $ret = $this->
Write($this->lasth, $name, $url, $fill,
'',
false, 0, $firstline, $firstblock, 0);
10429 $this->
SetFont(
'', $prevstyle);
10442 return ($px / ($this->imgscale * $this->k));
10453 return @html_entity_decode($text_to_convert, ENT_QUOTES, $this->encoding);
10468 $objkey = $this->encryptdata[
'key'].pack(
'VXxx',
$n);
10469 if ($this->encryptdata[
'mode'] == 2) {
10471 $objkey .=
"\x73\x41\x6C\x54";
10474 $objkey = substr($objkey, 0, 16);
10488 if (!$this->encrypted) {
10491 switch ($this->encryptdata[
'mode']) {
10516 if (!$this->encrypted) {
10519 $this->encryptdata[
'objid'] = $this->
_newobj();
10521 if (!isset($this->encryptdata[
'Filter']) OR empty($this->encryptdata[
'Filter'])) {
10522 $this->encryptdata[
'Filter'] =
'Standard';
10524 $out .=
' /Filter /'.$this->encryptdata[
'Filter'];
10525 if (isset($this->encryptdata[
'SubFilter']) AND !empty($this->encryptdata[
'SubFilter'])) {
10526 $out .=
' /SubFilter /'.$this->encryptdata[
'SubFilter'];
10528 if (!isset($this->encryptdata[
'V']) OR empty($this->encryptdata[
'V'])) {
10529 $this->encryptdata[
'V'] = 1;
10532 $out .=
' /V '.$this->encryptdata[
'V'];
10533 if (isset($this->encryptdata[
'Length']) AND !empty($this->encryptdata[
'Length'])) {
10535 $out .=
' /Length '.$this->encryptdata[
'Length'];
10537 $out .=
' /Length 40';
10539 if ($this->encryptdata[
'V'] >= 4) {
10540 if (!isset($this->encryptdata[
'StmF']) OR empty($this->encryptdata[
'StmF'])) {
10541 $this->encryptdata[
'StmF'] =
'Identity';
10543 if (!isset($this->encryptdata[
'StrF']) OR empty($this->encryptdata[
'StrF'])) {
10545 $this->encryptdata[
'StrF'] =
'Identity';
10548 if (isset($this->encryptdata[
'CF']) AND !empty($this->encryptdata[
'CF'])) {
10550 $out .=
' /'.$this->encryptdata[
'StmF'].
' <<';
10551 $out .=
' /Type /CryptFilter';
10552 if (isset($this->encryptdata[
'CF'][
'CFM']) AND !empty($this->encryptdata[
'CF'][
'CFM'])) {
10554 $out .=
' /CFM /'.$this->encryptdata[
'CF'][
'CFM'];
10555 if ($this->encryptdata[
'pubkey']) {
10556 $out .=
' /Recipients [';
10557 foreach ($this->encryptdata[
'Recipients'] as $rec) {
10558 $out .=
' <'.$rec.
'>';
10561 if (isset($this->encryptdata[
'CF'][
'EncryptMetadata']) AND (!$this->encryptdata[
'CF'][
'EncryptMetadata'])) {
10562 $out .=
' /EncryptMetadata false';
10564 $out .=
' /EncryptMetadata true';
10568 $out .=
' /CFM /None';
10570 if (isset($this->encryptdata[
'CF'][
'AuthEvent']) AND !empty($this->encryptdata[
'CF'][
'AuthEvent'])) {
10572 $out .=
' /AuthEvent /'.$this->encryptdata[
'CF'][
'AuthEvent'];
10574 $out .=
' /AuthEvent /DocOpen';
10576 if (isset($this->encryptdata[
'CF'][
'Length']) AND !empty($this->encryptdata[
'CF'][
'Length'])) {
10578 $out .=
' /Length '.$this->encryptdata[
'CF'][
'Length'];
10583 $out .=
' /StmF /'.$this->encryptdata[
'StmF'];
10585 $out .=
' /StrF /'.$this->encryptdata[
'StrF'];
10586 if (isset($this->encryptdata[
'EFF']) AND !empty($this->encryptdata[
'EFF'])) {
10588 $out .=
' /EFF /'.$this->encryptdata[
''];
10592 if ($this->encryptdata[
'pubkey']) {
10593 if (($this->encryptdata[
'V'] < 4) AND isset($this->encryptdata[
'Recipients']) AND !empty($this->encryptdata[
'Recipients'])) {
10594 $out .=
' /Recipients [';
10595 foreach ($this->encryptdata[
'Recipients'] as $rec) {
10596 $out .=
' <'.$rec.
'>';
10602 if ($this->encryptdata[
'V'] == 5) {
10604 $out .=
' /OE ('.TCPDF_STATIC::_escape($this->encryptdata[
'OE']).
')';
10605 $out .=
' /UE ('.TCPDF_STATIC::_escape($this->encryptdata[
'UE']).
')';
10606 $out .=
' /Perms ('.TCPDF_STATIC::_escape($this->encryptdata[
'perms']).
')';
10607 } elseif ($this->encryptdata[
'V'] == 4) {
10609 } elseif ($this->encryptdata[
'V'] < 2) {
10614 $out .=
' /O ('.TCPDF_STATIC::_escape($this->encryptdata[
'O']).
')';
10615 $out .=
' /U ('.TCPDF_STATIC::_escape($this->encryptdata[
'U']).
')';
10616 $out .=
' /P '.$this->encryptdata[
'P'];
10617 if (isset($this->encryptdata[
'EncryptMetadata']) AND (!$this->encryptdata[
'EncryptMetadata'])) {
10618 $out .=
' /EncryptMetadata false';
10620 $out .=
' /EncryptMetadata true';
10624 $out .=
"\n".
'endobj';
10636 if ($this->encryptdata[
'mode'] == 0) {
10638 } elseif ($this->encryptdata[
'mode'] < 3) {
10640 $enc =
TCPDF_STATIC::_RC4($this->encryptdata[
'key'], $tmp, $this->last_enc_key, $this->last_enc_key_c);
10641 $len = strlen($tmp);
10642 for ($i = 1; $i <= 19; ++$i) {
10644 for ($j = 0; $j < $len; ++$j) {
10645 $ek .= chr(ord($this->encryptdata[
'key'][$j]) ^ $i);
10649 $enc .= str_repeat(
"\x00", 16);
10650 return substr($enc, 0, 32);
10651 } elseif ($this->encryptdata[
'mode'] == 3) {
10654 $this->encryptdata[
'UVS'] = substr($seed, 0, 8);
10656 $this->encryptdata[
'UKS'] = substr($seed, 8, 16);
10657 return hash(
'sha256', $this->encryptdata[
'user_password'].$this->encryptdata[
'UVS'],
true).$this->encryptdata[
'UVS'].$this->encryptdata[
'UKS'];
10669 $hashkey = hash(
'sha256', $this->encryptdata[
'user_password'].$this->encryptdata[
'UKS'],
true);
10670 $iv = str_repeat(
"\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
10671 return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $hashkey, $this->encryptdata[
'key'], MCRYPT_MODE_CBC, $iv);
10682 if ($this->encryptdata[
'mode'] < 3) {
10684 if ($this->encryptdata[
'mode'] > 0) {
10685 for ($i = 0; $i < 50; ++$i) {
10689 $owner_key = substr($tmp, 0, ($this->encryptdata[
'Length'] / 8));
10690 $enc =
TCPDF_STATIC::_RC4($owner_key, $this->encryptdata[
'user_password'], $this->last_enc_key, $this->last_enc_key_c);
10691 if ($this->encryptdata[
'mode'] > 0) {
10692 $len = strlen($owner_key);
10693 for ($i = 1; $i <= 19; ++$i) {
10695 for ($j = 0; $j < $len; ++$j) {
10696 $ek .= chr(ord($owner_key[$j]) ^ $i);
10702 } elseif ($this->encryptdata[
'mode'] == 3) {
10705 $this->encryptdata[
'OVS'] = substr($seed, 0, 8);
10707 $this->encryptdata[
'OKS'] = substr($seed, 8, 16);
10708 return hash(
'sha256', $this->encryptdata[
'owner_password'].$this->encryptdata[
'OVS'].$this->encryptdata[
'U'],
true).$this->encryptdata[
'OVS'].$this->encryptdata[
'OKS'];
10720 $hashkey = hash(
'sha256', $this->encryptdata[
'owner_password'].$this->encryptdata[
'OKS'].$this->encryptdata[
'U'],
true);
10721 $iv = str_repeat(
"\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
10722 return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $hashkey, $this->encryptdata[
'key'], MCRYPT_MODE_CBC, $iv);
10736 foreach ($psw_array as $c) {
10739 return substr($psw, 0, 127);
10749 $keybytelen = ($this->encryptdata[
'Length'] / 8);
10750 if (!$this->encryptdata[
'pubkey']) {
10751 if ($this->encryptdata[
'mode'] == 3) {
10755 $this->encryptdata[
'user_password'] = $this->
_fixAES256Password($this->encryptdata[
'user_password']);
10756 $this->encryptdata[
'owner_password'] = $this->
_fixAES256Password($this->encryptdata[
'owner_password']);
10758 $this->encryptdata[
'U'] = $this->
_Uvalue();
10760 $this->encryptdata[
'UE'] = $this->
_UEvalue();
10762 $this->encryptdata[
'O'] = $this->
_Ovalue();
10764 $this->encryptdata[
'OE'] = $this->
_OEvalue();
10766 $this->encryptdata[
'P'] = $this->encryptdata[
'protection'];
10769 $perms .= chr(255).chr(255).chr(255).chr(255);
10770 if (isset($this->encryptdata[
'CF'][
'EncryptMetadata']) AND (!$this->encryptdata[
'CF'][
'EncryptMetadata'])) {
10777 $iv = str_repeat(
"\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB));
10778 $this->encryptdata[
'perms'] = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->encryptdata[
'key'], $perms, MCRYPT_MODE_ECB, $iv);
10782 $this->encryptdata[
'owner_password'] = substr($this->encryptdata[
'owner_password'].TCPDF_STATIC::$enc_padding, 0, 32);
10784 $this->encryptdata[
'O'] = $this->
_Ovalue();
10788 $tmp =
TCPDF_STATIC::_md5_16($this->encryptdata[
'user_password'].$this->encryptdata[
'O'].$permissions.$this->encryptdata[
'fileid']);
10789 if ($this->encryptdata[
'mode'] > 0) {
10790 for ($i = 0; $i < 50; ++$i) {
10794 $this->encryptdata[
'key'] = substr($tmp, 0, $keybytelen);
10796 $this->encryptdata[
'U'] = $this->
_Uvalue();
10798 $this->encryptdata[
'P'] = $this->encryptdata[
'protection'];
10803 $recipient_bytes =
'';
10804 foreach ($this->encryptdata[
'pubkeys'] as $pubkey) {
10806 if (isset($pubkey[
'p'])) {
10809 $pkprotection = $this->encryptdata[
'protection'];
10814 $envelope = $seed.$pkpermissions;
10817 $f = fopen($tempkeyfile,
'wb');
10819 $this->
Error(
'Unable to create temporary key file: '.$tempkeyfile);
10821 $envelope_length = strlen($envelope);
10822 fwrite($f, $envelope, $envelope_length);
10825 if (!openssl_pkcs7_encrypt($tempkeyfile, $tempencfile, $pubkey[
'c'], array(), PKCS7_BINARY | PKCS7_DETACHED)) {
10826 $this->
Error(
'Unable to encrypt the file: '.$tempkeyfile);
10828 unlink($tempkeyfile);
10830 $signature = file_get_contents($tempencfile,
false, null, $envelope_length);
10831 unlink($tempencfile);
10833 $signature = substr($signature, strpos($signature,
'Content-Disposition'));
10834 $tmparr = explode(
"\n\n", $signature);
10835 $signature = trim($tmparr[1]);
10838 $signature = base64_decode($signature);
10840 $hexsignature = current(unpack(
'H*', $signature));
10842 $this->encryptdata[
'Recipients'][] = $hexsignature;
10844 $recipient_bytes .= $signature;
10847 if ($this->encryptdata[
'mode'] == 3) {
10848 $this->encryptdata[
'key'] = substr(hash(
'sha256', $seed.$recipient_bytes,
true), 0, $keybytelen);
10850 $this->encryptdata[
'key'] = substr(sha1($seed.$recipient_bytes,
true), 0, $keybytelen);
10869 public function SetProtection($permissions=array(
'print',
'modify',
'copy',
'annot-forms',
'fill-forms',
'extract',
'assemble',
'print-high'), $user_pass=
'', $owner_pass=null, $mode=0, $pubkeys=null) {
10870 if ($this->pdfa_mode) {
10875 if (($pubkeys !== null) AND (is_array($pubkeys))) {
10877 $this->encryptdata[
'pubkeys'] = $pubkeys;
10882 if (!function_exists(
'openssl_pkcs7_encrypt')) {
10883 $this->
Error(
'Public-Key Security requires openssl library.');
10886 $this->encryptdata[
'pubkey'] =
true;
10887 $this->encryptdata[
'Filter'] =
'Adobe.PubSec';
10888 $this->encryptdata[
'StmF'] =
'DefaultCryptFilter';
10889 $this->encryptdata[
'StrF'] =
'DefaultCryptFilter';
10892 $this->encryptdata[
'pubkey'] =
false;
10893 $this->encryptdata[
'Filter'] =
'Standard';
10894 $this->encryptdata[
'StmF'] =
'StdCF';
10895 $this->encryptdata[
'StrF'] =
'StdCF';
10898 if (!extension_loaded(
'mcrypt')) {
10899 $this->
Error(
'AES encryption requires mcrypt library (http://www.php.net/manual/en/mcrypt.requirements.php).');
10901 if (mcrypt_get_cipher_name(MCRYPT_RIJNDAEL_128) ===
false) {
10902 $this->
Error(
'AES encryption requires MCRYPT_RIJNDAEL_128 cypher.');
10904 if (($mode == 3) AND !function_exists(
'hash')) {
10906 $this->
Error(
'AES 256 encryption requires HASH Message Digest Framework (http://www.php.net/manual/en/book.hash.php).');
10909 if ($owner_pass === null) {
10912 $this->encryptdata[
'user_password'] = $user_pass;
10913 $this->encryptdata[
'owner_password'] = $owner_pass;
10914 $this->encryptdata[
'mode'] = $mode;
10917 $this->encryptdata[
'V'] = 1;
10918 $this->encryptdata[
'Length'] = 40;
10919 $this->encryptdata[
'CF'][
'CFM'] =
'V2';
10923 $this->encryptdata[
'V'] = 2;
10924 $this->encryptdata[
'Length'] = 128;
10925 $this->encryptdata[
'CF'][
'CFM'] =
'V2';
10926 if ($this->encryptdata[
'pubkey']) {
10927 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s4';
10928 $this->encryptdata[
'Recipients'] = array();
10933 $this->encryptdata[
'V'] = 4;
10934 $this->encryptdata[
'Length'] = 128;
10935 $this->encryptdata[
'CF'][
'CFM'] =
'AESV2';
10936 $this->encryptdata[
'CF'][
'Length'] = 128;
10937 if ($this->encryptdata[
'pubkey']) {
10938 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s5';
10939 $this->encryptdata[
'Recipients'] = array();
10944 $this->encryptdata[
'V'] = 5;
10945 $this->encryptdata[
'Length'] = 256;
10946 $this->encryptdata[
'CF'][
'CFM'] =
'AESV3';
10947 $this->encryptdata[
'CF'][
'Length'] = 256;
10948 if ($this->encryptdata[
'pubkey']) {
10949 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s5';
10950 $this->encryptdata[
'Recipients'] = array();
10955 $this->encrypted =
true;
10973 if ($this->state != 2) {
10977 if ($this->inxobj) {
10979 $this->xobjects[
$this->xobjid][
'transfmrk'][] = strlen($this->xobjects[$this->xobjid][
'outdata']);
10996 if ($this->state != 2) {
11000 if (isset($this->transfmatrix[$this->transfmatrix_key])) {
11001 array_pop($this->transfmatrix[$this->transfmatrix_key]);
11004 if ($this->inxobj) {
11006 array_pop($this->xobjects[$this->xobjid][
'transfmrk']);
11008 array_pop($this->transfmrk[$this->page]);
11067 if (($s_x == 0) OR ($s_y == 0)) {
11068 $this->
Error(
'Please do not use values equal to zero for scaling');
11070 $y = ($this->h -
$y) * $this->k;
11080 $tm[4] =
$x * (1 - $s_x);
11081 $tm[5] =
$y * (1 - $s_y);
11105 $this->
Scale(100, -100,
'',
$y);
11193 $y = ($this->h -
$y) * $this->k;
11197 $tm[0] = cos(deg2rad($angle));
11198 $tm[1] = sin(deg2rad($angle));
11201 $tm[4] =
$x + ($tm[1] *
$y) - ($tm[0] *
$x);
11202 $tm[5] =
$y - ($tm[0] *
$y) - ($tm[1] * $x);
11250 if (($angle_x <= -90) OR ($angle_x >= 90) OR ($angle_y <= -90) OR ($angle_y >= 90)) {
11251 $this->
Error(
'Please use values between -90 and +90 degrees for Skewing.');
11254 $y = ($this->h -
$y) * $this->k;
11258 $tm[1] = tan(deg2rad($angle_y));
11259 $tm[2] = tan(deg2rad($angle_x));
11261 $tm[4] = -$tm[2] *
$y;
11262 $tm[5] = -$tm[1] *
$x;
11275 if ($this->state != 2) {
11278 $this->
_out(sprintf(
'%F %F %F %F %F %F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
11280 $this->transfmatrix[
$this->transfmatrix_key][] = array(
'a' => $tm[0],
'b' => $tm[1],
'c' => $tm[2],
'd' => $tm[3],
'e' => $tm[4],
'f' => $tm[5]);
11282 if ($this->inxobj) {
11284 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
11285 $key = key($this->xobjects[$this->xobjid][
'transfmrk']);
11286 $this->xobjects[
$this->xobjid][
'transfmrk'][$key] = strlen($this->xobjects[$this->xobjid][
'outdata']);
11288 } elseif (end($this->transfmrk[$this->page]) !==
false) {
11289 $key = key($this->transfmrk[$this->page]);
11308 $this->LineWidth = $width;
11309 $this->linestyleWidth = sprintf(
'%F w', ($width * $this->k));
11310 if ($this->state == 2) {
11311 $this->
_out($this->linestyleWidth);
11351 if (!is_array($style)) {
11354 if (isset($style[
'width'])) {
11355 $this->LineWidth = $style[
'width'];
11356 $this->linestyleWidth = sprintf(
'%F w', ($style[
'width'] * $this->k));
11357 $s .= $this->linestyleWidth.
' ';
11359 if (isset($style[
'cap'])) {
11360 $ca = array(
'butt' => 0,
'round'=> 1,
'square' => 2);
11361 if (isset($ca[$style[
'cap']])) {
11362 $this->linestyleCap = $ca[$style[
'cap']].
' J';
11363 $s .= $this->linestyleCap.
' ';
11366 if (isset($style[
'join'])) {
11367 $ja = array(
'miter' => 0,
'round' => 1,
'bevel' => 2);
11368 if (isset($ja[$style[
'join']])) {
11369 $this->linestyleJoin = $ja[$style[
'join']].
' j';
11370 $s .= $this->linestyleJoin.
' ';
11373 if (isset($style[
'dash'])) {
11375 if ($style[
'dash']) {
11376 if (preg_match(
'/^.+,/', $style[
'dash']) > 0) {
11377 $tab = explode(
',', $style[
'dash']);
11379 $tab = array($style[
'dash']);
11382 foreach (
$tab as $i => $v) {
11384 $dash_string .=
' ';
11386 $dash_string .= sprintf(
'%F', $v);
11389 if (!isset($style[
'phase']) OR !$style[
'dash']) {
11390 $style[
'phase'] = 0;
11392 $this->linestyleDash = sprintf(
'[%s] %F d', $dash_string, $style[
'phase']);
11393 $s .= $this->linestyleDash.
' ';
11395 if (isset($style[
'color'])) {
11398 if (!
$ret AND ($this->state == 2)) {
11412 if ($this->state == 2) {
11413 $this->
_out(sprintf(
'%F %F m', (
$x * $this->k), (($this->h -
$y) * $this->k)));
11426 if ($this->state == 2) {
11427 $this->
_out(sprintf(
'%F %F l', (
$x * $this->k), (($this->h -
$y) * $this->k)));
11442 if ($this->state == 2) {
11443 $this->
_out(sprintf(
'%F %F %F %F re %s', (
$x * $this->k), (($this->h -
$y) * $this->k), (
$w * $this->k), (-
$h * $this->k), $op));
11460 if ($this->state == 2) {
11461 $this->
_out(sprintf(
'%F %F %F %F %F %F c', ($x1 * $this->k), (($this->h - $y1) * $this->k), ($x2 * $this->k), (($this->h - $y2) * $this->k), ($x3 * $this->k), (($this->h - $y3) * $this->k)));
11476 if ($this->state == 2) {
11477 $this->
_out(sprintf(
'%F %F %F %F v', ($x2 * $this->k), (($this->h - $y2) * $this->k), ($x3 * $this->k), (($this->h - $y3) * $this->k)));
11492 if ($this->state == 2) {
11493 $this->
_out(sprintf(
'%F %F %F %F y', ($x1 * $this->k), (($this->h - $y1) * $this->k), ($x3 * $this->k), (($this->h - $y3) * $this->k)));
11508 public function Line($x1, $y1, $x2, $y2, $style=array()) {
11509 if ($this->state != 2) {
11512 if (is_array($style)) {
11538 public function Rect(
$x,
$y,
$w,
$h, $style=
'', $border_style=array(), $fill_color=array()) {
11539 if ($this->state != 2) {
11542 if (empty($style)) {
11545 if (!(strpos($style,
'F') ===
false) AND !empty($fill_color)) {
11549 if (!empty($border_style)) {
11550 if (isset($border_style[
'all']) AND !empty($border_style[
'all'])) {
11553 $border_style = array();
11556 $opnostroke = array(
'S' =>
'',
'D' =>
'',
's' =>
'',
'd' =>
'',
'B' =>
'F',
'FD' =>
'F',
'DF' =>
'F',
'B*' =>
'F*',
'F*D' =>
'F*',
'DF*' =>
'F*',
'b' =>
'f',
'fd' =>
'f',
'df' =>
'f',
'b*' =>
'f*',
'f*d' =>
'f*',
'df*' =>
'f*' );
11557 if (isset($opnostroke[$style])) {
11558 $style = $opnostroke[$style];
11562 if (!empty($style)) {
11566 if (!empty($border_style)) {
11567 $border_style2 = array();
11568 foreach ($border_style as $line => $value) {
11569 $length = strlen($line);
11570 for ($i = 0; $i < $length; ++$i) {
11571 $border_style2[$line[$i]] = $value;
11574 $border_style = $border_style2;
11575 if (isset($border_style[
'L']) AND $border_style[
'L']) {
11578 if (isset($border_style[
'T']) AND $border_style[
'T']) {
11581 if (isset($border_style[
'R']) AND $border_style[
'R']) {
11584 if (isset($border_style[
'B']) AND $border_style[
'B']) {
11609 public function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style=
'', $line_style=array(), $fill_color=array()) {
11610 if ($this->state != 2) {
11613 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
11621 $this->
_outCurve($x1, $y1, $x2, $y2, $x3, $y3);
11639 public function Polycurve($x0, $y0, $segments, $style=
'', $line_style=array(), $fill_color=array()) {
11640 if ($this->state != 2) {
11643 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
11648 $line_style = array();
11654 foreach ($segments as $segment) {
11655 list($x1, $y1, $x2, $y2, $x3, $y3) = $segment;
11656 $this->
_outCurve($x1, $y1, $x2, $y2, $x3, $y3);
11679 public function Ellipse($x0, $y0, $rx, $ry=
'', $angle=0, $astart=0, $afinish=360, $style=
'', $line_style=array(), $fill_color=array(), $nc=2) {
11680 if ($this->state != 2) {
11686 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
11691 $line_style = array();
11696 $this->
_outellipticalarc($x0, $y0, $rx, $ry, $angle, $astart, $afinish,
false, $nc,
true,
true,
false);
11720 protected function _outellipticalarc($xc, $yc, $rx, $ry, $xang=0, $angs=0, $angf=360, $pie=
false, $nc=2, $startpoint=
true, $ccw=
true, $svg=
false) {
11725 $xmin = 2147483647;
11726 $ymin = 2147483647;
11733 $xang = deg2rad((
float) $xang);
11734 $angs = deg2rad((
float) $angs);
11735 $angf = deg2rad((
float) $angf);
11740 $as = atan2((sin($angs) / $ry), (cos($angs) / $rx));
11741 $af = atan2((sin($angf) / $ry), (cos($angf) / $rx));
11749 if ($ccw AND ($as > $af)) {
11752 } elseif (!$ccw AND ($as < $af)) {
11756 $total_angle = ($af - $as);
11761 $nc *= (2 * abs($total_angle) / M_PI);
11762 $nc = round($nc) + 1;
11764 $arcang = ($total_angle / $nc);
11767 $y0 = ($this->h - $yc);
11770 $alpha = sin($arcang) * ((sqrt(4 + (3 * pow(tan(($arcang) / 2), 2))) - 1) / 3);
11771 $cos_xang = cos($xang);
11772 $sin_xang = sin($xang);
11773 $cos_ang = cos($ang);
11774 $sin_ang = sin($ang);
11776 $px1 = $x0 + ($rx * $cos_xang * $cos_ang) - ($ry * $sin_xang * $sin_ang);
11777 $py1 = $y0 + ($rx * $sin_xang * $cos_ang) + ($ry * $cos_xang * $sin_ang);
11779 $qx1 = (
$alpha * ((-$rx * $cos_xang * $sin_ang) - ($ry * $sin_xang * $cos_ang)));
11780 $qy1 = (
$alpha * ((-$rx * $sin_xang * $sin_ang) + ($ry * $cos_xang * $cos_ang)));
11783 $this->
_outLine($px1, $this->h - $py1);
11784 } elseif ($startpoint) {
11786 $this->
_outPoint($px1, $this->h - $py1);
11789 for ($i = 1; $i <= $nc; ++$i) {
11791 $ang = $as + ($i * $arcang);
11795 $cos_ang = cos($ang);
11796 $sin_ang = sin($ang);
11798 $px2 = $x0 + ($rx * $cos_xang * $cos_ang) - ($ry * $sin_xang * $sin_ang);
11799 $py2 = $y0 + ($rx * $sin_xang * $cos_ang) + ($ry * $cos_xang * $sin_ang);
11801 $qx2 = (
$alpha * ((-$rx * $cos_xang * $sin_ang) - ($ry * $sin_xang * $cos_ang)));
11802 $qy2 = (
$alpha * ((-$rx * $sin_xang * $sin_ang) + ($ry * $cos_xang * $cos_ang)));
11804 $cx1 = ($px1 + $qx1);
11805 $cy1 = ($this->h - ($py1 + $qy1));
11806 $cx2 = ($px2 - $qx2);
11807 $cy2 = ($this->h - ($py2 - $qy2));
11809 $cy3 = ($this->h - $py2);
11810 $this->
_outCurve($cx1, $cy1, $cx2, $cy2, $cx3, $cy3);
11812 $xmin = min($xmin, $cx1, $cx2, $cx3);
11813 $ymin = min($ymin, $cy1, $cy2, $cy3);
11814 $xmax = max($xmax, $cx1, $cx2, $cx3);
11815 $ymax = max($ymax, $cy1, $cy2, $cy3);
11825 $xmin = min($xmin, $xc);
11826 $ymin = min($ymin, $yc);
11827 $xmax = max($xmax, $xc);
11828 $ymax = max($ymax, $yc);
11830 return array($xmin, $ymin, $xmax, $ymax);
11848 public function Circle($x0, $y0, $r, $angstr=0, $angend=360, $style=
'', $line_style=array(), $fill_color=array(), $nc=2) {
11849 $this->
Ellipse($x0, $y0, $r, $r, 0, $angstr, $angend, $style, $line_style, $fill_color, $nc);
11866 public function PolyLine($p, $style=
'', $line_style=array(), $fill_color=array()) {
11867 $this->
Polygon($p, $style, $line_style, $fill_color,
false);
11885 public function Polygon($p, $style=
'', $line_style=array(), $fill_color=array(), $closed=
true) {
11886 if ($this->state != 2) {
11893 for ($i = 0; $i < 4; ++$i) {
11894 $p[$nc + $i] = $p[$i];
11897 if (isset($line_style[0])) {
11898 $line_style[$np] = $line_style[0];
11902 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
11907 $line_style = array();
11911 if (isset($line_style[
'all'])) {
11919 for ($i = 2; $i < $nc; $i = $i + 2) {
11920 $this->
_outLine($p[$i], $p[$i + 1]);
11926 for ($i = 2; $i < $nc; $i = $i + 2) {
11927 $line_num = ($i / 2) - 1;
11928 if (isset($line_style[$line_num])) {
11929 if ($line_style[$line_num] != 0) {
11930 if (is_array($line_style[$line_num])) {
11933 $this->
_outPoint($p[$i - 2], $p[$i - 1]);
11934 $this->
_outLine($p[$i], $p[$i + 1]);
11938 $this->
_outLine($p[$i], $p[$i + 1]);
11942 $this->
_outLine($p[$i], $p[$i + 1]);
11950 for ($i = 2; $i < $nc; $i = $i + 2) {
11951 $this->
_outLine($p[$i], $p[$i + 1]);
11986 public function RegularPolygon($x0, $y0, $r, $ns, $angle=0, $draw_circle=
false, $style=
'', $line_style=array(), $fill_color=array(), $circle_style=
'', $circle_outLine_style=array(), $circle_fill_color=array()) {
11990 if ($draw_circle) {
11991 $this->
Circle($x0, $y0, $r, 0, 360, $circle_style, $circle_outLine_style, $circle_fill_color);
11994 for ($i = 0; $i < $ns; ++$i) {
11995 $a = $angle + ($i * 360 / $ns);
11996 $a_rad = deg2rad((
float) $a);
11997 $p[] = $x0 + ($r * sin($a_rad));
11998 $p[] = $y0 + ($r * cos($a_rad));
12000 $this->
Polygon($p, $style, $line_style, $fill_color);
12034 public function StarPolygon($x0, $y0, $r, $nv, $ng, $angle=0, $draw_circle=
false, $style=
'', $line_style=array(), $fill_color=array(), $circle_style=
'', $circle_outLine_style=array(), $circle_fill_color=array()) {
12038 if ($draw_circle) {
12039 $this->
Circle($x0, $y0, $r, 0, 360, $circle_style, $circle_outLine_style, $circle_fill_color);
12042 $visited = array();
12043 for ($i = 0; $i < $nv; ++$i) {
12044 $a = $angle + ($i * 360 / $nv);
12045 $a_rad = deg2rad((
float) $a);
12046 $p2[] = $x0 + ($r * sin($a_rad));
12047 $p2[] = $y0 + ($r * cos($a_rad));
12048 $visited[] =
false;
12053 $p[] = $p2[$i * 2];
12054 $p[] = $p2[($i * 2) + 1];
12055 $visited[$i] =
true;
12058 }
while (!$visited[$i]);
12059 $this->
Polygon($p, $style, $line_style, $fill_color);
12076 public function RoundedRect(
$x,
$y,
$w,
$h, $r, $round_corner=
'1111', $style=
'', $border_style=array(), $fill_color=array()) {
12095 public function RoundedRectXY(
$x,
$y,
$w,
$h, $rx, $ry, $round_corner=
'1111', $style=
'', $border_style=array(), $fill_color=array()) {
12096 if ($this->state != 2) {
12099 if (($round_corner ==
'0000') OR (($rx == $ry) AND ($rx == 0))) {
12101 $this->
Rect(
$x,
$y,
$w,
$h, $style, $border_style, $fill_color);
12105 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
12110 $border_style = array();
12112 if ($border_style) {
12115 $MyArc = 4 / 3 * (sqrt(2) - 1);
12117 $xc =
$x +
$w - $rx;
12120 if ($round_corner[0]) {
12121 $this->
_outCurve($xc + ($rx * $MyArc), $yc - $ry, $xc + $rx, $yc - ($ry * $MyArc), $xc + $rx, $yc);
12125 $xc =
$x +
$w - $rx;
12126 $yc =
$y +
$h - $ry;
12128 if ($round_corner[1]) {
12129 $this->
_outCurve($xc + $rx, $yc + ($ry * $MyArc), $xc + ($rx * $MyArc), $yc + $ry, $xc, $yc + $ry);
12134 $yc =
$y +
$h - $ry;
12136 if ($round_corner[2]) {
12137 $this->
_outCurve($xc - ($rx * $MyArc), $yc + $ry, $xc - $rx, $yc + ($ry * $MyArc), $xc - $rx, $yc);
12144 if ($round_corner[3]) {
12145 $this->
_outCurve($xc - $rx, $yc - ($ry * $MyArc), $xc - ($rx * $MyArc), $yc - $ry, $xc, $yc - $ry);
12165 public function Arrow($x0, $y0, $x1, $y1, $head_style=0, $arm_size=5, $arm_angle=15) {
12168 $dir_angle = atan2(($y0 - $y1), ($x0 - $x1));
12169 if ($dir_angle < 0) {
12170 $dir_angle += (2 * M_PI);
12172 $arm_angle = deg2rad($arm_angle);
12175 if ($head_style > 0) {
12181 $this->
Line($x0, $y0, $sx1, $sy1);
12183 $x2L = $x1 + ($arm_size * cos($dir_angle + $arm_angle));
12184 $y2L = $y1 + ($arm_size * sin($dir_angle + $arm_angle));
12186 $x2R = $x1 + ($arm_size * cos($dir_angle - $arm_angle));
12187 $y2R = $y1 + ($arm_size * sin($dir_angle - $arm_angle));
12190 switch ($head_style) {
12194 $style = array(1, 1, 0);
12213 $this->
Polygon(array($x2L, $y2L, $x1, $y1, $x2R, $y2R), $mode, $style, array());
12238 } elseif (
$y < 0) {
12240 } elseif (
$y > $this->h) {
12245 } elseif (
$x < 0) {
12247 } elseif (
$x > $this->w) {
12250 if (empty(
$page)) {
12252 if (empty(
$page)) {
12256 $this->dests[$name] = array(
'x' =>
$x,
'y' =>
$y,
'p' =>
$page);
12278 if (empty($this->dests)) {
12281 $this->n_dests = $this->
_newobj();
12283 foreach($this->dests as $name => $o) {
12284 $out .=
' /'.$name.
' '.sprintf(
'[%u 0 R /XYZ %F %F null]', $this->page_obj_id[($o[
'p'])], ($o[
'x'] * $this->k), ($this->pagedim[$o[
'p']][
'h'] - ($o[
'y'] * $this->k)));
12287 $out .=
"\n".
'endobj';
12324 if (isset($this->outlines[0])) {
12325 $lastoutline = end($this->outlines);
12326 $maxlevel = $lastoutline[
'l'] + 1;
12330 if ($level > $maxlevel) {
12331 $level = $maxlevel;
12335 } elseif (
$y < 0) {
12337 } elseif (
$y > $this->h) {
12342 } elseif (
$x < 0) {
12344 } elseif (
$x > $this->w) {
12347 if (empty(
$page)) {
12349 if (empty(
$page)) {
12353 $this->outlines[] = array(
't' =>
$txt,
'l' => $level,
'x' =>
$x,
'y' =>
$y,
'p' =>
$page,
's' => strtoupper($style),
'c' => $color,
'u' => $link);
12363 $outline_p = array();
12364 $outline_y = array();
12365 foreach ($this->outlines as $key =>
$row) {
12366 $outline_p[$key] =
$row[
'p'];
12367 $outline_k[$key] = $key;
12370 array_multisort($outline_p, SORT_NUMERIC, SORT_ASC, $outline_k, SORT_NUMERIC, SORT_ASC, $this->outlines);
12380 $nb = count($this->outlines);
12388 foreach ($this->outlines as $i => $o) {
12390 $parent = $lru[($o[
'l'] - 1)];
12392 $this->outlines[$i][
'parent'] = $parent;
12393 $this->outlines[$parent][
'last'] = $i;
12394 if ($o[
'l'] > $level) {
12396 $this->outlines[$parent][
'first'] = $i;
12399 $this->outlines[$i][
'parent'] = $nb;
12401 if (($o[
'l'] <= $level) AND ($i > 0)) {
12403 $prev = $lru[$o[
'l']];
12404 $this->outlines[$prev][
'next'] = $i;
12405 $this->outlines[$i][
'prev'] = $prev;
12407 $lru[$o[
'l']] = $i;
12412 $nltags =
'/<br[\s]?\/>|<\/(blockquote|dd|dl|div|dt|h1|h2|h3|h4|h5|h6|hr|li|ol|p|pre|ul|tcpdf|table|tr|td)>/si';
12413 foreach ($this->outlines as $i => $o) {
12416 $title = preg_replace($nltags,
"\n", $o[
't']);
12421 $out =
'<</Title '.$this->_textstring(
$title, $oid);
12422 $out .=
' /Parent '.($n + $o[
'parent']).
' 0 R';
12423 if (isset($o[
'prev'])) {
12424 $out .=
' /Prev '.($n + $o[
'prev']).
' 0 R';
12426 if (isset($o[
'next'])) {
12427 $out .=
' /Next '.($n + $o[
'next']).
' 0 R';
12429 if (isset($o[
'first'])) {
12430 $out .=
' /First '.($n + $o[
'first']).
' 0 R';
12432 if (isset($o[
'last'])) {
12433 $out .=
' /Last '.($n + $o[
'last']).
' 0 R';
12435 if (isset($o[
'u']) AND !empty($o[
'u'])) {
12437 if (is_string($o[
'u'])) {
12438 if ($o[
'u'][0] ==
'#') {
12440 $out .=
' /Dest /'.TCPDF_STATIC::encodeNameObject(substr($o[
'u'], 1));
12441 } elseif ($o[
'u'][0] ==
'%') {
12443 $filename = basename(substr($o[
'u'], 1));
12444 $out .=
' /A <</S /GoToE /D [0 /Fit] /NewWindow true /T << /R /C /P '.($o[
'p'] - 1).
' /A '.$this->embeddedfiles[
$filename][
'a'].
' >> >>';
12445 } elseif ($o[
'u'][0] ==
'*') {
12447 $filename = basename(substr($o[
'u'], 1));
12448 $jsa =
'var D=event.target.doc;var MyData=D.dataObjects;for (var i in MyData) if (MyData[i].path=="'.$filename.
'") D.exportDataObject( { cName : MyData[i].name, nLaunch : 2});';
12449 $out .=
' /A <</S /JavaScript /JS '.$this->_textstring($jsa, $oid).
'>>';
12452 $out .=
' /A <</S /URI /URI '.$this->_datastring($this->
unhtmlentities($o[
'u']), $oid).
'>>';
12454 } elseif (isset($this->links[$o[
'u']])) {
12456 $l = $this->links[$o[
'u']];
12457 if (isset($this->page_obj_id[(
$l[0])])) {
12458 $out .= sprintf(
' /Dest [%u 0 R /XYZ 0 %F null]', $this->page_obj_id[(
$l[0])], ($this->pagedim[
$l[0]][
'h'] - (
$l[1] * $this->k)));
12461 } elseif (isset($this->page_obj_id[($o[
'p'])])) {
12463 $out .=
' '.sprintf(
'/Dest [%u 0 R /XYZ %F %F null]', $this->page_obj_id[($o[
'p'])], ($o[
'x'] * $this->k), ($this->pagedim[$o[
'p']][
'h'] - ($o[
'y'] * $this->k)));
12467 if (!empty($o[
's'])) {
12469 if (strpos($o[
's'],
'B') !==
false) {
12473 if (strpos($o[
's'],
'I') !==
false) {
12477 $out .= sprintf(
' /F %d', $style);
12479 if (isset($o[
'c']) AND is_array($o[
'c']) AND (count($o[
'c']) == 3)) {
12480 $color = array_values($o[
'c']);
12481 $out .= sprintf(
' /C [%F %F %F]', ($color[0] / 255), ($color[1] / 255), ($color[2] / 255));
12484 $out .=
' /C [0.0 0.0 0.0]';
12486 $out .=
' /Count 0';
12488 $out .=
"\n".
'endobj';
12492 $this->OutlineRoot = $this->
_newobj();
12493 $this->
_out(
'<< /Type /Outlines /First '.
$n.
' 0 R /Last '.(
$n + $lru[0]).
' 0 R >>'.
"\n".
'endobj');
12506 $this->javascript .= $script;
12519 if ($this->pdfa_mode) {
12524 $this->js_objects[
$this->n] = array(
'n' => $this->
n,
'js' => $script,
'onload' => $onload);
12535 if ($this->pdfa_mode OR (empty($this->javascript) AND empty($this->js_objects))) {
12538 if (strpos($this->javascript,
'this.addField') > 0) {
12539 if (!$this->ur[
'enabled']) {
12544 $jsa = sprintf(
"ftcpdfdocsaved=this.addField('%s','%s',%d,[%F,%F,%F,%F]);",
'tcpdfdocsaved',
'text', 0, 0, 1, 0, 1);
12545 $jsb =
"getField('tcpdfdocsaved').value='saved';";
12546 $this->javascript = $jsa.
"\n".$this->javascript.
"\n".$jsb;
12549 $this->n_js =
'<< /Names [';
12550 if (!empty($this->javascript)) {
12551 $this->n_js .=
' (EmbeddedJS) '.($this->n + 1).
' 0 R';
12553 if (!empty($this->js_objects)) {
12554 foreach ($this->js_objects as $key => $val) {
12555 if ($val[
'onload']) {
12556 $this->n_js .=
' (JS'.$key.
') '.$key.
' 0 R';
12560 $this->n_js .=
' ] >>';
12562 if (!empty($this->javascript)) {
12564 $out =
'<< /S /JavaScript';
12565 $out .=
' /JS '.$this->_textstring($this->javascript, $obj_id);
12567 $out .=
"\n".
'endobj';
12571 if (!empty($this->js_objects)) {
12572 foreach ($this->js_objects as $key => $val) {
12573 $out = $this->
_getobj($key).
"\n".
' << /S /JavaScript /JS '.$this->_textstring($val[
'js'], $key).
' >>'.
"\n".
'endobj';
12597 $this->javascript .=
"if (getField('tcpdfdocsaved').value != 'saved') {";
12599 $this->javascript .= sprintf(
"f".$name.
"=this.addField('%s','%s',%u,[%F,%F,%F,%F]);", $name, $type, $this->PageNo()-1,
$x*
$k, ($this->h-
$y)*$k+1, (
$x+
$w)*
$k, ($this->h-
$y-
$h)*$k+1).
"\n";
12600 $this->javascript .=
'f'.$name.
'.textSize='.$this->FontSizePt.
";\n";
12601 while (list($key, $val) = each($prop)) {
12602 if (strcmp(substr($key, -5),
'Color') == 0) {
12605 $val =
"'".$val.
"'";
12607 $this->javascript .=
'f'.$name.
'.'.$key.
'='.$val.
";\n";
12614 $this->javascript .=
'}';
12629 $this->default_form_prop = $prop;
12675 $this->annotation_fonts[$this->CurrentFont[
'fontkey']] = $this->CurrentFont[
'i'];
12676 $fontstyle = sprintf(
'/F%d %F Tf %s', $this->CurrentFont[
'i'], $this->FontSizePt, $this->TextColor);
12677 $popt[
'da'] = $fontstyle;
12679 $popt[
'ap'] = array();
12680 $popt[
'ap'][
'n'] =
'/Tx BMC q '.$fontstyle.
' ';
12682 if (isset($prop[
'value']) AND !empty($prop[
'value'])) {
12683 $text = $prop[
'value'];
12684 } elseif (isset($opt[
'v']) AND !empty($opt[
'v'])) {
12689 if (isset($popt[
'q'])) {
12690 switch ($popt[
'q']) {
12709 $this->
MultiCell(
$w,
$h, $text, 0, $align,
false, 0, 0, 0,
true, 0,
false,
true, 0,
'T',
false);
12712 $popt[
'ap'][
'n'] .= $this->xobjects[$tmpid][
'outdata'];
12713 unset($this->xobjects[$tmpid]);
12714 $popt[
'ap'][
'n'] .=
'Q EMC';
12716 $opt = array_merge($popt, $opt);
12720 $opt[
'Subtype'] =
'Widget';
12735 unset($opt[
'mk'][
'ca']);
12736 unset($opt[
'mk'][
'rc']);
12737 unset($opt[
'mk'][
'ac']);
12738 unset($opt[
'mk'][
'i']);
12739 unset($opt[
'mk'][
'ri']);
12740 unset($opt[
'mk'][
'ix']);
12741 unset($opt[
'mk'][
'if']);
12746 unset($opt[
'mk'][
'tp']);
12778 public function RadioButton($name,
$w, $prop=array(), $opt=array(), $onvalue=
'On', $checked=
false,
$x=
'',
$y=
'', $js=
false) {
12795 $defval = $onvalue;
12800 $font =
'zapfdingbats';
12801 if ($this->pdfa_mode) {
12803 $font =
'pdfa'.$font;
12808 if (!isset($this->radiobutton_groups[$this->page])) {
12809 $this->radiobutton_groups[
$this->page] = array();
12811 if (!isset($this->radiobutton_groups[$this->page][$name])) {
12812 $this->radiobutton_groups[
$this->page][$name] = array();
12817 $kid = ($this->
n + 1);
12819 $this->radiobutton_groups[
$this->page][$name][] = array(
'kid' => $kid,
'def' => $defval);
12822 $prop[
'NoToggleToOff'] =
'true';
12823 $prop[
'Radio'] =
'true';
12824 $prop[
'borderStyle'] =
'inset';
12828 $this->annotation_fonts[$tmpfont[
'fontkey']] = $tmpfont[
'i'];
12829 $fontstyle = sprintf(
'/F%d %F Tf %s', $tmpfont[
'i'], $this->FontSizePt, $this->TextColor);
12830 $popt[
'da'] = $fontstyle;
12832 $popt[
'ap'] = array();
12833 $popt[
'ap'][
'n'] = array();
12835 $fy = ((
$w - ((($tmpfont[
'desc'][
'Ascent'] - $tmpfont[
'desc'][
'Descent']) * $this->FontSizePt / 1000) /
$this->k)) *
$this->k);
12836 $popt[
'ap'][
'n'][$onvalue] = sprintf(
'q %s BT /F%d %F Tf %F %F Td ('.chr(108).
') Tj ET Q', $this->TextColor, $tmpfont[
'i'], $this->FontSizePt, $fx, $fy);
12837 $popt[
'ap'][
'n'][
'Off'] = sprintf(
'q %s BT /F%d %F Tf %F %F Td ('.chr(109).
') Tj ET Q', $this->TextColor, $tmpfont[
'i'], $this->FontSizePt, $fx, $fy);
12838 if (!isset($popt[
'mk'])) {
12839 $popt[
'mk'] = array();
12841 $popt[
'mk'][
'ca'] =
'(l)';
12843 $opt = array_merge($popt, $opt);
12845 $opt[
'Subtype'] =
'Widget';
12846 $opt[
'ft'] =
'Btn';
12848 $opt[
'v'] = array(
'/'.$onvalue);
12849 $opt[
'as'] = $onvalue;
12851 $opt[
'as'] =
'Off';
12854 if (!isset($this->radiobutton_groups[$this->page][$name][
'#readonly#'])) {
12855 $this->radiobutton_groups[
$this->page][$name][
'#readonly#'] =
false;
12857 $this->radiobutton_groups[
$this->page][$name][
'#readonly#'] |= ($opt[
'f'] & 64);
12881 public function ListBox($name,
$w,
$h, $values, $prop=array(), $opt=array(),
$x=
'',
$y=
'', $js=
false) {
12893 foreach ($values as $value) {
12894 if (is_array($value)) {
12895 $s .=
',[\''.addslashes($value[1]).
'\',\
''.addslashes($value[0]).
'\']
';
12897 $s .= ',[\
''.addslashes($value).
'\',\
''.addslashes($value).
'\']
';
12900 $this->javascript .= 'f
'.$name.'.setItems(
'.substr($s, 1).');
'."\n";
12903 // get default style
12904 $prop = array_merge($this->getFormDefaultProp(), $prop);
12905 // get annotation data
12906 $popt = TCPDF_STATIC::getAnnotOptFromJSProp($prop, $this->spot_colors, $this->rtl);
12907 // set additional default values
12908 $this->annotation_fonts[$this->CurrentFont['fontkey
']] = $this->CurrentFont['i
'];
12909 $fontstyle = sprintf('/F%d %F Tf %s
', $this->CurrentFont['i
'], $this->FontSizePt, $this->TextColor);
12910 $popt['da
'] = $fontstyle;
12911 // build appearance stream
12912 $popt['ap
'] = array();
12913 $popt['ap
']['n'] = '/Tx BMC q
'.$fontstyle.' ';
12915 foreach($values as $item) {
12916 if (is_array($item)) {
12917 $text .= $item[1]."\n";
12919 $text .= $item."\n";
12922 $tmpid = $this->startTemplate($w, $h, false);
12923 $this->MultiCell($w, $h, $text, 0, '', false, 0, 0, 0, true, 0, false, true, 0, 'T
', false);
12924 $this->endTemplate();
12926 $popt['ap
']['n'] .= $this->xobjects[$tmpid]['outdata
'];
12927 unset($this->xobjects[$tmpid]);
12928 $popt['ap
']['n'] .= 'Q EMC
';
12930 $opt = array_merge($popt, $opt);
12931 // set remaining annotation data
12932 $opt['Subtype
'] = 'Widget
';
12935 $opt['opt
'] = $values;
12936 unset($opt['mk
']['ca
']);
12937 unset($opt['mk
']['rc
']);
12938 unset($opt['mk
']['ac
']);
12939 unset($opt['mk
']['i
']);
12940 unset($opt['mk
']['ri
']);
12941 unset($opt['mk
']['ix
']);
12942 unset($opt['mk
']['if']);
12943 unset($opt['mk
']['tp
']);
12944 $this->Annotation($x, $y, $w, $h, $name, $opt, 0);
12967 public function ComboBox($name, $w, $h, $values, $prop=array(), $opt=array(), $x='', $y='', $js=false) {
12974 // check page for no-write regions and adapt page margins if necessary
12975 list($x, $y) = $this->checkPageRegions($h, $x, $y);
12977 $this->_addfield('combobox
', $name, $x, $y, $w, $h, $prop);
12979 foreach ($values as $value) {
12980 if (is_array($value)) {
12981 $s .= ',[\
''.addslashes($value[1]).
'\',\
''.addslashes($value[0]).
'\']
';
12983 $s .= ',[\
''.addslashes($value).
'\',\
''.addslashes($value).
'\']
';
12986 $this->javascript .= 'f
'.$name.'.setItems(
'.substr($s, 1).');
'."\n";
12989 // get default style
12990 $prop = array_merge($this->getFormDefaultProp(), $prop);
12991 $prop['Combo
'] = true;
12992 // get annotation data
12993 $popt = TCPDF_STATIC::getAnnotOptFromJSProp($prop, $this->spot_colors, $this->rtl);
12994 // set additional default options
12995 $this->annotation_fonts[$this->CurrentFont['fontkey
']] = $this->CurrentFont['i
'];
12996 $fontstyle = sprintf('/F%d %F Tf %s
', $this->CurrentFont['i
'], $this->FontSizePt, $this->TextColor);
12997 $popt['da
'] = $fontstyle;
12998 // build appearance stream
12999 $popt['ap
'] = array();
13000 $popt['ap
']['n'] = '/Tx BMC q
'.$fontstyle.' ';
13002 foreach($values as $item) {
13003 if (is_array($item)) {
13004 $text .= $item[1]."\n";
13006 $text .= $item."\n";
13009 $tmpid = $this->startTemplate($w, $h, false);
13010 $this->MultiCell($w, $h, $text, 0, '', false, 0, 0, 0, true, 0, false, true, 0, 'T
', false);
13011 $this->endTemplate();
13013 $popt['ap
']['n'] .= $this->xobjects[$tmpid]['outdata
'];
13014 unset($this->xobjects[$tmpid]);
13015 $popt['ap
']['n'] .= 'Q EMC
';
13017 $opt = array_merge($popt, $opt);
13018 // set remaining annotation data
13019 $opt['Subtype
'] = 'Widget
';
13022 $opt['opt
'] = $values;
13023 unset($opt['mk
']['ca
']);
13024 unset($opt['mk
']['rc
']);
13025 unset($opt['mk
']['ac
']);
13026 unset($opt['mk
']['i
']);
13027 unset($opt['mk
']['ri
']);
13028 unset($opt['mk
']['ix
']);
13029 unset($opt['mk
']['if']);
13030 unset($opt['mk
']['tp
']);
13031 $this->Annotation($x, $y, $w, $h, $name, $opt, 0);
13054 public function CheckBox($name, $w, $checked=false, $prop=array(), $opt=array(), $onvalue='Yes
', $x='', $y='', $js=false) {
13061 // check page for no-write regions and adapt page margins if necessary
13062 list($x, $y) = $this->checkPageRegions($w, $x, $y);
13064 $this->_addfield('checkbox
', $name, $x, $y, $w, $w, $prop);
13067 if (!isset($prop['value
'])) {
13068 $prop['value
'] = array('Yes
');
13070 // get default style
13071 $prop = array_merge($this->getFormDefaultProp(), $prop);
13072 $prop['borderStyle
'] = 'inset
';
13073 // get annotation data
13074 $popt = TCPDF_STATIC::getAnnotOptFromJSProp($prop, $this->spot_colors, $this->rtl);
13075 // set additional default options
13076 $font = 'zapfdingbats
';
13077 if ($this->pdfa_mode) {
13078 // all fonts must be embedded
13079 $font = 'pdfa
'.$font;
13081 $this->AddFont($font);
13082 $tmpfont = $this->getFontBuffer($font);
13083 $this->annotation_fonts[$tmpfont['fontkey
']] = $tmpfont['i
'];
13084 $fontstyle = sprintf('/F%d %F Tf %s
', $tmpfont['i
'], $this->FontSizePt, $this->TextColor);
13085 $popt['da
'] = $fontstyle;
13086 // build appearance stream
13087 $popt['ap
'] = array();
13088 $popt['ap
']['n'] = array();
13089 $fx = ((($w - $this->getAbsFontMeasure($tmpfont['cw
'][110])) / 2) * $this->k);
13090 $fy = (($w - ((($tmpfont['desc
']['Ascent
'] - $tmpfont['desc
']['Descent
']) * $this->FontSizePt / 1000) / $this->k)) * $this->k);
13091 $popt['ap
']['n']['Yes
'] = sprintf('q %s BT /F%d %F Tf %F %F Td (
'.chr(110).') Tj ET Q', $this->TextColor, $tmpfont['i'], $this->FontSizePt, $fx, $fy);
13092 $popt['ap']['
n']['Off'] = sprintf('q %s BT /F%d %F Tf %F %F Td ('.chr(111).') Tj ET Q', $this->TextColor, $tmpfont['i'], $this->FontSizePt, $fx, $fy);
13094 $opt = array_merge($popt, $opt);
13096 $opt['Subtype'] = 'Widget';
13097 $opt['ft'] = 'Btn';
13102 $opt[
'opt'] = array($onvalue);
13104 $opt[
'v'] = array(
'/Yes');
13105 $opt[
'as'] =
'Yes';
13107 $opt[
'v'] = array(
'/Off');
13108 $opt[
'as'] =
'Off';
13134 public function Button($name,
$w,
$h, $caption, $action, $prop=array(), $opt=array(),
$x=
'',
$y=
'', $js=
false) {
13144 $this->
_addfield(
'button', $name, $this->x, $this->y,
$w,
$h, $prop);
13145 $this->javascript .=
'f'.$name.
".buttonSetCaption('".addslashes($caption).
"');\n";
13146 $this->javascript .=
'f'.$name.
".setAction('MouseUp','".addslashes($action).
"');\n";
13147 $this->javascript .=
'f'.$name.
".highlight='push';\n";
13148 $this->javascript .=
'f'.$name.
".print=false;\n";
13153 $prop[
'Pushbutton'] =
'true';
13154 $prop[
'highlight'] =
'push';
13155 $prop[
'display'] =
'display.noPrint';
13158 $this->annotation_fonts[$this->CurrentFont[
'fontkey']] = $this->CurrentFont[
'i'];
13159 $fontstyle = sprintf(
'/F%d %F Tf %s', $this->CurrentFont[
'i'], $this->FontSizePt, $this->TextColor);
13160 $popt[
'da'] = $fontstyle;
13162 $popt[
'ap'] = array();
13163 $popt[
'ap'][
'n'] =
'/Tx BMC q '.$fontstyle.
' ';
13167 'L' => array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' => array(231)),
13168 'R' => array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' => array(51)),
13169 'T' => array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' => array(231)),
13170 'B' => array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' => array(51)));
13172 $this->
Cell(
$w,
$h, $caption, $border, 0,
'C',
true,
'', 1,
false,
'T',
'M');
13175 $popt[
'ap'][
'n'] .= $this->xobjects[$tmpid][
'outdata'];
13176 unset($this->xobjects[$tmpid]);
13177 $popt[
'ap'][
'n'] .=
'Q EMC';
13179 if (!isset($popt[
'mk'])) {
13180 $popt[
'mk'] = array();
13182 $ann_obj_id = ($this->
n + 1);
13183 if (!empty($action) AND !is_array($action)) {
13184 $ann_obj_id = ($this->
n + 2);
13186 $popt[
'mk'][
'ca'] = $this->
_textstring($caption, $ann_obj_id);
13187 $popt[
'mk'][
'rc'] = $this->
_textstring($caption, $ann_obj_id);
13188 $popt[
'mk'][
'ac'] = $this->
_textstring($caption, $ann_obj_id);
13190 $opt = array_merge($popt, $opt);
13192 $opt[
'Subtype'] =
'Widget';
13193 $opt[
'ft'] =
'Btn';
13194 $opt[
't'] = $caption;
13196 if (!empty($action)) {
13197 if (is_array($action)) {
13199 $opt[
'aa'] =
'/D <<';
13200 $bmode = array(
'SubmitForm',
'ResetForm',
'ImportData');
13201 foreach ($action AS $key => $val) {
13202 if (($key ==
'S') AND in_array($val, $bmode)) {
13203 $opt[
'aa'] .=
' /S /'.$val;
13204 } elseif (($key ==
'F') AND (!empty($val))) {
13205 $opt[
'aa'] .=
' /F '.$this->_datastring($val, $ann_obj_id);
13206 } elseif (($key ==
'Fields') AND is_array($val) AND !empty($val)) {
13207 $opt[
'aa'] .=
' /Fields [';
13208 foreach ($val AS $field) {
13209 $opt[
'aa'] .=
' '.$this->_textstring($field, $ann_obj_id);
13212 } elseif (($key ==
'Flags')) {
13214 if (is_array($val)) {
13215 foreach ($val AS $flag) {
13217 case 'Include/Exclude': {
13221 case 'IncludeNoValueFields': {
13225 case 'ExportFormat': {
13229 case 'GetMethod': {
13233 case 'SubmitCoordinates': {
13241 case 'IncludeAppendSaves': {
13245 case 'IncludeAnnotations': {
13249 case 'SubmitPDF': {
13253 case 'CanonicalFormat': {
13257 case 'ExclNonUserAnnots': {
13265 case 'EmbedForm': {
13272 $ff = intval($val);
13274 $opt[
'aa'] .=
' /Flags '.$ff;
13277 $opt[
'aa'] .=
' >>';
13281 $opt[
'aa'] =
'/D '.$js_obj_id.
' 0 R';
13302 if ((!$this->sign) OR (!isset($this->signature_data[
'cert_type']))) {
13305 $sigobjid = ($this->sig_obj_id + 1);
13307 $out .=
'<< /Type /Sig';
13308 $out .=
' /Filter /Adobe.PPKLite';
13309 $out .=
' /SubFilter /adbe.pkcs7.detached';
13310 $out .=
' '.TCPDF_STATIC::$byterange_string;
13311 $out .=
' /Contents<'.str_repeat(
'0', $this->signature_max_length).
'>';
13312 $out .=
' /Reference [';
13313 $out .=
' << /Type /SigRef';
13314 if ($this->signature_data[
'cert_type'] > 0) {
13315 $out .=
' /TransformMethod /DocMDP';
13316 $out .=
' /TransformParams <<';
13317 $out .=
' /Type /TransformParams';
13318 $out .=
' /P '.$this->signature_data[
'cert_type'];
13319 $out .=
' /V /1.2';
13321 $out .=
' /TransformMethod /UR3';
13322 $out .=
' /TransformParams <<';
13323 $out .=
' /Type /TransformParams';
13324 $out .=
' /V /2.2';
13326 $out .=
' /Document['.$this->ur[
'document'].
']';
13329 $out .=
' /Form['.$this->ur[
'form'].
']';
13332 $out .=
' /Signature['.$this->ur[
'signature'].
']';
13335 $out .=
' /Annots['.$this->ur[
'annots'].
']';
13338 $out .=
' /EF['.$this->ur[
'ef'].
']';
13341 $out .=
' /FormEX['.$this->ur[
'formex'].
']';
13353 $out .=
' /Name '.$this->_textstring($this->signature_data[
'info'][
'Name'], $sigobjid);
13355 if (isset($this->signature_data[
'info'][
'Location']) AND !
TCPDF_STATIC::empty_string($this->signature_data[
'info'][
'Location'])) {
13356 $out .=
' /Location '.$this->_textstring($this->signature_data[
'info'][
'Location'], $sigobjid);
13358 if (isset($this->signature_data[
'info'][
'Reason']) AND !
TCPDF_STATIC::empty_string($this->signature_data[
'info'][
'Reason'])) {
13359 $out .=
' /Reason '.$this->_textstring($this->signature_data[
'info'][
'Reason'], $sigobjid);
13361 if (isset($this->signature_data[
'info'][
'ContactInfo']) AND !
TCPDF_STATIC::empty_string($this->signature_data[
'info'][
'ContactInfo'])) {
13362 $out .=
' /ContactInfo '.$this->_textstring($this->signature_data[
'info'][
'ContactInfo'], $sigobjid);
13364 $out .=
' /M '.$this->_datestring($sigobjid, $this->doc_modification_timestamp);
13366 $out .=
"\n".
'endobj';
13389 $document=
'/FullSave',
13390 $annots=
'/Create/Delete/Modify/Copy/Import/Export',
13391 $form=
'/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate',
13392 $signature=
'/Modify',
13393 $ef=
'/Create/Delete/Modify/Import',
13395 $this->ur[
'enabled'] = $enable;
13396 $this->ur[
'document'] = $document;
13397 $this->ur[
'annots'] = $annots;
13398 $this->ur[
'form'] = $form;
13399 $this->ur[
'signature'] = $signature;
13400 $this->ur[
'ef'] = $ef;
13401 $this->ur[
'formex'] = $formex;
13402 if (!$this->sign) {
13423 public function setSignature($signing_cert=
'', $private_key=
'', $private_key_password=
'', $extracerts=
'', $cert_type=2, $info=array()) {
13428 $this->sign =
true;
13432 $this->signature_data = array();
13433 if (strlen($signing_cert) == 0) {
13434 $this->
Error(
'Please provide a certificate file and password!');
13436 if (strlen($private_key) == 0) {
13437 $private_key = $signing_cert;
13439 $this->signature_data[
'signcert'] = $signing_cert;
13440 $this->signature_data[
'privkey'] = $private_key;
13441 $this->signature_data[
'password'] = $private_key_password;
13442 $this->signature_data[
'extracerts'] = $extracerts;
13443 $this->signature_data[
'cert_type'] = $cert_type;
13444 $this->signature_data[
'info'] = $info;
13495 if ((
$page < 1) OR (
$page > $this->numpages)) {
13498 $sigapp[
'page'] = intval(
$page);
13500 if (empty($name)) {
13501 $sigapp[
'name'] =
'Signature';
13503 $sigapp[
'name'] = $name;
13506 $b = $this->pagedim[($sigapp[
'page'])][
'h'] - ((
$y +
$h) *
$this->k);
13509 $sigapp[
'rect'] = sprintf(
'%F %F %F %F', $a, $b, ($a + $c), ($b +
$d));
13521 if (empty(
$page)) {
13522 $page = $this->page + 1;
13534 $this->starting_page_number = max(0, intval($num));
13547 $rep = str_repeat(
' ', $this->
GetNumChars($ref));
13549 $sdiff = sprintf(
'%F', $wdiff);
13552 $alias =
'{'.$alias;
13567 return '{'.TCPDF_STATIC::$alias_tot_pages.
'}';
13582 return '{'.TCPDF_STATIC::$alias_num_page.
'}';
13597 return '{'.TCPDF_STATIC::$alias_group_tot_pages.
'}';
13612 return '{'.TCPDF_STATIC::$alias_group_num_page.
'}';
13653 if (empty($this->pdflayers)) {
13656 foreach ($this->pdflayers as $key => $layer) {
13657 $this->pdflayers[$key][
'objid'] = $this->
_newobj();
13658 $out =
'<< /Type /OCG';
13659 $out .=
' /Name '.$this->_textstring($layer[
'name'], $this->pdflayers[$key][
'objid']);
13660 $out .=
' /Usage <<';
13661 $out .=
' /Print <</PrintState /'.($layer[
'print']?
'ON':
'OFF').
'>>';
13662 $out .=
' /View <</ViewState /'.($layer[
'view']?
'ON':
'OFF').
'>>';
13664 $out .=
"\n".
'endobj';
13678 if ($this->state != 2) {
13681 $layer = sprintf(
'LYR%03d', (count($this->pdflayers) + 1));
13682 if (empty($name)) {
13685 $name = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $name);
13687 $this->pdflayers[] = array(
'layer' => $layer,
'name' => $name,
'print' => $print,
'view' => $view);
13688 $this->openMarkedContent =
true;
13689 $this->
_out(
'/OC /'.$layer.
' BDC');
13698 if ($this->state != 2) {
13701 if ($this->openMarkedContent) {
13703 $this->
_out(
'EMC');
13704 $this->openMarkedContent =
false;
13717 if ($this->state != 2) {
13736 $this->
Error(
'Incorrect visibility: '.$v);
13750 if ($this->pdfa_mode) {
13755 foreach ($this->extgstates as $i => $ext) {
13756 if ($ext[
'parms'] == $parms) {
13757 if ($this->inxobj) {
13765 $n = (count($this->extgstates) + 1);
13766 $this->extgstates[
$n] = array(
'parms' => $parms);
13767 if ($this->inxobj) {
13781 if ($this->pdfa_mode OR ($this->state != 2)) {
13785 $this->
_out(sprintf(
'/GS%d gs', $gs));
13794 foreach ($this->extgstates as $i => $ext) {
13795 $this->extgstates[$i][
'n'] = $this->
_newobj();
13796 $out =
'<< /Type /ExtGState';
13797 foreach ($ext[
'parms'] as
$k => $v) {
13798 if (is_float($v)) {
13799 $v = sprintf(
'%F', $v);
13800 } elseif ($v ===
true) {
13802 } elseif ($v ===
false) {
13805 $out .=
' /'.$k.
' '.$v;
13808 $out .=
"\n".
'endobj';
13823 if ($this->state != 2) {
13826 $stroking = $stroking ?
true :
false;
13829 $nonstroking = $stroking;
13831 $nonstroking = $nonstroking ?
true :
false;
13833 if (($mode != 0) AND ($mode != 1)) {
13836 $this->overprint = array(
'OP' => $stroking,
'op' => $nonstroking,
'OPM' => $mode);
13861 public function setAlpha($stroking=1, $bm=
'Normal', $nonstroking=
'', $ais=
false) {
13862 if ($this->pdfa_mode) {
13866 $stroking = floatval($stroking);
13869 $nonstroking = $stroking;
13871 $nonstroking = floatval($nonstroking);
13873 if ($bm[0] ==
'/') {
13875 $bm = substr($bm, 1);
13877 if (!in_array($bm, array(
'Normal',
'Multiply',
'Screen',
'Overlay',
'Darken',
'Lighten',
'ColorDodge',
'ColorBurn',
'HardLight',
'SoftLight',
'Difference',
'Exclusion',
'Hue',
'Saturation',
'Color',
'Luminosity'))) {
13880 $ais = $ais ?
true :
false;
13881 $this->alpha = array(
'CA' => $stroking,
'ca' => $nonstroking,
'BM' =>
'/'.$bm,
'AIS' => $ais);
13904 if (($quality < 1) OR ($quality > 100)) {
13907 $this->jpeg_quality = intval($quality);
13917 $this->default_table_columns = intval($cols);
13927 $this->cell_height_ratio =
$h;
13946 if ($this->pdfa_mode) {
13948 $this->PDFVersion =
'1.4';
13950 $this->PDFVersion = $version;
13964 $this->viewer_preferences = $preferences;
13980 public function colorRegistrationBar(
$x,
$y,
$w,
$h, $transition=
true, $vertical=
false, $colors=
'A,R,G,B,C,M,Y,K') {
13981 $bars = explode(
',', $colors);
13982 $numbars = count($bars);
13985 $coords = array(0, 0, 0, 1);
13986 $wb =
$w / $numbars;
13991 $coords = array(1, 0, 0, 0);
13993 $hb =
$h / $numbars;
13999 foreach ($bars as $col) {
14003 $col_a = array(255);
14009 $col_b = array(255);
14013 $col_a = array(255,255,255);
14014 $col_b = array(255,0,0);
14018 $col_a = array(255,255,255);
14019 $col_b = array(0,255,0);
14023 $col_a = array(255,255,255);
14024 $col_b = array(0,0,255);
14028 $col_a = array(0,0,0,0);
14029 $col_b = array(100,0,0,0);
14033 $col_a = array(0,0,0,0);
14034 $col_b = array(0,100,0,0);
14038 $col_a = array(0,0,0,0);
14039 $col_b = array(0,0,100,0);
14043 $col_a = array(0,0,0,0);
14044 $col_b = array(0,0,0,100);
14048 $col_a = array(255);
14055 $this->
LinearGradient($xb, $yb, $wb, $hb, $col_a, $col_b, $coords);
14059 $this->
Rect($xb, $yb, $wb, $hb,
'F', array());
14078 public function cropMark(
$x,
$y,
$w,
$h, $type=
'T,R,B,L', $color=array(0,0,0)) {
14079 $this->
SetLineStyle(array(
'width' => (0.5 / $this->k),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $color));
14080 $type = strtoupper($type);
14081 $type = preg_replace(
'/[^A-Z\-\,]*/',
'', $type);
14083 $type = str_replace(
'-',
',', $type);
14084 $type = str_replace(
'TL',
'T,L', $type);
14085 $type = str_replace(
'TR',
'T,R', $type);
14086 $type = str_replace(
'BL',
'F,L', $type);
14087 $type = str_replace(
'BR',
'F,R', $type);
14088 $type = str_replace(
'A',
'T,L', $type);
14089 $type = str_replace(
'B',
'T,R', $type);
14090 $type = str_replace(
'T,RO',
'BO', $type);
14091 $type = str_replace(
'C',
'F,L', $type);
14092 $type = str_replace(
'D',
'F,R', $type);
14093 $crops = explode(
',', strtoupper($type));
14095 $crops = array_unique($crops);
14098 foreach ($crops as $crop) {
14133 $this->
Line($x1, $y1, $x2, $y2);
14150 $line_style = array(
'width' => (0.5 / $this->k),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $cola);
14154 $this->
Circle(
$x,
$y, $r, 0, 360,
'C', $line_style, array(), 8);
14163 $this->
Circle(
$x,
$y, $r2, 0, 360,
'C', $line_style, array(), 8);
14182 $this->
Gradient(2, $coords, array(array(
'color' => $col1,
'offset' => 0,
'exponent' => 1), array(
'color' => $col2,
'offset' => 1,
'exponent' => 1)), array(),
false);
14198 public function RadialGradient(
$x,
$y,
$w,
$h, $col1=array(), $col2=array(), $coords=array(0.5,0.5,0.5,0.5,1)) {
14200 $this->
Gradient(3, $coords, array(array(
'color' => $col1,
'offset' => 0,
'exponent' => 1), array(
'color' => $col2,
'offset' => 1,
'exponent' => 1)), array(),
false);
14221 public function CoonsPatchMesh(
$x,
$y,
$w,
$h, $col1=array(), $col2=array(), $col3=array(), $col4=array(), $coords=array(0.00,0.0,0.33,0.00,0.67,0.00,1.00,0.00,1.00,0.33,1.00,0.67,1.00,1.00,0.67,1.00,0.33,1.00,0.00,1.00,0.00,0.67,0.00,0.33), $coords_min=0, $coords_max=1, $antialias=
false) {
14222 if ($this->pdfa_mode OR ($this->state != 2)) {
14226 $n = count($this->gradients) + 1;
14227 $this->gradients[
$n] = array();
14228 $this->gradients[
$n][
'type'] = 6;
14229 $this->gradients[
$n][
'coords'] = array();
14230 $this->gradients[
$n][
'antialias'] = $antialias;
14231 $this->gradients[
$n][
'colors'] = array();
14232 $this->gradients[
$n][
'transparency'] =
false;
14234 if (!isset($coords[0][
'f'])) {
14236 if (!isset($col1[1])) {
14237 $col1[1] = $col1[2] = $col1[0];
14239 if (!isset($col2[1])) {
14240 $col2[1] = $col2[2] = $col2[0];
14242 if (!isset($col3[1])) {
14243 $col3[1] = $col3[2] = $col3[0];
14245 if (!isset($col4[1])) {
14246 $col4[1] = $col4[2] = $col4[0];
14248 $patch_array[0][
'f'] = 0;
14249 $patch_array[0][
'points'] = $coords;
14250 $patch_array[0][
'colors'][0][
'r'] = $col1[0];
14251 $patch_array[0][
'colors'][0][
'g'] = $col1[1];
14252 $patch_array[0][
'colors'][0][
'b'] = $col1[2];
14253 $patch_array[0][
'colors'][1][
'r'] = $col2[0];
14254 $patch_array[0][
'colors'][1][
'g'] = $col2[1];
14255 $patch_array[0][
'colors'][1][
'b'] = $col2[2];
14256 $patch_array[0][
'colors'][2][
'r'] = $col3[0];
14257 $patch_array[0][
'colors'][2][
'g'] = $col3[1];
14258 $patch_array[0][
'colors'][2][
'b'] = $col3[2];
14259 $patch_array[0][
'colors'][3][
'r'] = $col4[0];
14260 $patch_array[0][
'colors'][3][
'g'] = $col4[1];
14261 $patch_array[0][
'colors'][3][
'b'] = $col4[2];
14264 $patch_array = $coords;
14268 $this->gradients[
$n][
'stream'] =
'';
14269 $count_patch = count($patch_array);
14270 for ($i=0; $i < $count_patch; ++$i) {
14271 $this->gradients[
$n][
'stream'] .= chr($patch_array[$i][
'f']);
14272 $count_points = count($patch_array[$i][
'points']);
14273 for ($j=0; $j < $count_points; ++$j) {
14275 $patch_array[$i][
'points'][$j] = (($patch_array[$i][
'points'][$j] - $coords_min) / ($coords_max - $coords_min)) * $bpcd;
14276 if ($patch_array[$i][
'points'][$j] < 0) {
14277 $patch_array[$i][
'points'][$j] = 0;
14279 if ($patch_array[$i][
'points'][$j] > $bpcd) {
14280 $patch_array[$i][
'points'][$j] = $bpcd;
14282 $this->gradients[
$n][
'stream'] .= chr(floor($patch_array[$i][
'points'][$j] / 256));
14283 $this->gradients[
$n][
'stream'] .= chr(floor($patch_array[$i][
'points'][$j] % 256));
14285 $count_cols = count($patch_array[$i][
'colors']);
14286 for ($j=0; $j < $count_cols; ++$j) {
14288 $this->gradients[
$n][
'stream'] .= chr($patch_array[$i][
'colors'][$j][
'r']);
14289 $this->gradients[
$n][
'stream'] .= chr($patch_array[$i][
'colors'][$j][
'g']);
14290 $this->gradients[
$n][
'stream'] .= chr($patch_array[$i][
'colors'][$j][
'b']);
14294 $this->
_out(
'/Sh'.
$n.
' sh');
14297 if ($this->inxobj) {
14314 if ($this->state != 2) {
14318 $x = $this->w -
$x -
$w;
14323 $s .= sprintf(
' %F %F %F %F re W n',
$x*$this->k, ($this->h-
$y)*$this->k,
$w*$this->k, -
$h*$this->k);
14325 $s .= sprintf(
' %F 0 0 %F %F %F cm',
$w*$this->k,
$h*$this->k,
$x*$this->k, ($this->h-(
$y+
$h))*$this->k);
14340 public function Gradient($type, $coords, $stops, $background=array(), $antialias=
false) {
14341 if ($this->pdfa_mode OR ($this->state != 2)) {
14344 $n = count($this->gradients) + 1;
14345 $this->gradients[
$n] = array();
14346 $this->gradients[
$n][
'type'] = $type;
14347 $this->gradients[
$n][
'coords'] = $coords;
14348 $this->gradients[
$n][
'antialias'] = $antialias;
14349 $this->gradients[
$n][
'colors'] = array();
14350 $this->gradients[
$n][
'transparency'] =
false;
14352 $numcolspace = count($stops[0][
'color']);
14353 $bcolor = array_values($background);
14354 switch($numcolspace) {
14356 $this->gradients[
$n][
'colspace'] =
'DeviceCMYK';
14357 if (!empty($background)) {
14358 $this->gradients[
$n][
'background'] = sprintf(
'%F %F %F %F', $bcolor[0]/100, $bcolor[1]/100, $bcolor[2]/100, $bcolor[3]/100);
14363 $this->gradients[
$n][
'colspace'] =
'DeviceRGB';
14364 if (!empty($background)) {
14365 $this->gradients[
$n][
'background'] = sprintf(
'%F %F %F', $bcolor[0]/255, $bcolor[1]/255, $bcolor[2]/255);
14370 $this->gradients[
$n][
'colspace'] =
'DeviceGray';
14371 if (!empty($background)) {
14372 $this->gradients[
$n][
'background'] = sprintf(
'%F', $bcolor[0]/255);
14377 $num_stops = count($stops);
14378 $last_stop_id = $num_stops - 1;
14379 foreach ($stops as $key => $stop) {
14380 $this->gradients[
$n][
'colors'][$key] = array();
14382 if (isset($stop[
'offset'])) {
14383 $this->gradients[
$n][
'colors'][$key][
'offset'] = $stop[
'offset'];
14386 $this->gradients[
$n][
'colors'][$key][
'offset'] = 0;
14387 } elseif ($key == $last_stop_id) {
14388 $this->gradients[
$n][
'colors'][$key][
'offset'] = 1;
14390 $offsetstep = (1 - $this->gradients[
$n][
'colors'][($key - 1)][
'offset']) / ($num_stops - $key);
14391 $this->gradients[
$n][
'colors'][$key][
'offset'] = $this->gradients[
$n][
'colors'][($key - 1)][
'offset'] + $offsetstep;
14394 if (isset($stop[
'opacity'])) {
14395 $this->gradients[
$n][
'colors'][$key][
'opacity'] = $stop[
'opacity'];
14396 if ((!$this->pdfa_mode) AND ($stop[
'opacity'] < 1)) {
14397 $this->gradients[
$n][
'transparency'] =
true;
14400 $this->gradients[
$n][
'colors'][$key][
'opacity'] = 1;
14403 if (isset($stop[
'exponent'])) {
14404 $this->gradients[
$n][
'colors'][$key][
'exponent'] = $stop[
'exponent'];
14406 $this->gradients[
$n][
'colors'][$key][
'exponent'] = 1;
14409 $color = array_values($stop[
'color']);
14410 switch($numcolspace) {
14412 $this->gradients[
$n][
'colors'][$key][
'color'] = sprintf(
'%F %F %F %F', $color[0]/100, $color[1]/100, $color[2]/100, $color[3]/100);
14416 $this->gradients[
$n][
'colors'][$key][
'color'] = sprintf(
'%F %F %F', $color[0]/255, $color[1]/255, $color[2]/255);
14420 $this->gradients[
$n][
'colors'][$key][
'color'] = sprintf(
'%F', $color[0]/255);
14425 if ($this->gradients[
$n][
'transparency']) {
14427 $this->
_out(
'/TGS'.$n.
' gs');
14430 $this->
_out(
'/Sh'.$n.
' sh');
14433 if ($this->inxobj) {
14446 if ($this->pdfa_mode) {
14449 $idt = count($this->gradients);
14450 foreach ($this->gradients as $id => $grad) {
14451 if (($grad[
'type'] == 2) OR ($grad[
'type'] == 3)) {
14454 $out .=
' /FunctionType 3';
14455 $out .=
' /Domain [0 1]';
14460 $num_cols = count($grad[
'colors']);
14461 $lastcols = $num_cols - 1;
14462 for ($i = 1; $i < $num_cols; ++$i) {
14463 $functions .= ($fc + $i).
' 0 R ';
14464 if ($i < $lastcols) {
14465 $bounds .= sprintf(
'%F ', $grad[
'colors'][$i][
'offset']);
14469 $out .=
' /Functions ['.trim($functions).
']';
14470 $out .=
' /Bounds ['.trim($bounds).
']';
14471 $out .=
' /Encode ['.trim($encode).
']';
14473 $out .=
"\n".
'endobj';
14475 for ($i = 1; $i < $num_cols; ++$i) {
14478 $out .=
' /FunctionType 2';
14479 $out .=
' /Domain [0 1]';
14480 $out .=
' /C0 ['.$grad[
'colors'][($i - 1)][
'color'].
']';
14481 $out .=
' /C1 ['.$grad[
'colors'][$i][
'color'].
']';
14482 $out .=
' /N '.$grad[
'colors'][$i][
'exponent'];
14484 $out .=
"\n".
'endobj';
14488 if ($grad[
'transparency']) {
14491 $out .=
' /FunctionType 3';
14492 $out .=
' /Domain [0 1]';
14495 $num_cols = count($grad[
'colors']);
14496 for ($i = 1; $i < $num_cols; ++$i) {
14497 $functions .= ($ft + $i).
' 0 R ';
14499 $out .=
' /Functions ['.trim($functions).
']';
14500 $out .=
' /Bounds ['.trim($bounds).
']';
14501 $out .=
' /Encode ['.trim($encode).
']';
14503 $out .=
"\n".
'endobj';
14505 for ($i = 1; $i < $num_cols; ++$i) {
14508 $out .=
' /FunctionType 2';
14509 $out .=
' /Domain [0 1]';
14510 $out .=
' /C0 ['.$grad[
'colors'][($i - 1)][
'opacity'].
']';
14511 $out .=
' /C1 ['.$grad[
'colors'][$i][
'opacity'].
']';
14512 $out .=
' /N '.$grad[
'colors'][$i][
'exponent'];
14514 $out .=
"\n".
'endobj';
14521 $out =
'<< /ShadingType '.$grad[
'type'];
14522 if (isset($grad[
'colspace'])) {
14523 $out .=
' /ColorSpace /'.$grad[
'colspace'];
14525 $out .=
' /ColorSpace /DeviceRGB';
14527 if (isset($grad[
'background']) AND !empty($grad[
'background'])) {
14528 $out .=
' /Background ['.$grad[
'background'].
']';
14530 if (isset($grad[
'antialias']) AND ($grad[
'antialias'] ===
true)) {
14531 $out .=
' /AntiAlias true';
14533 if ($grad[
'type'] == 2) {
14534 $out .=
' '.sprintf(
'/Coords [%F %F %F %F]', $grad[
'coords'][0], $grad[
'coords'][1], $grad[
'coords'][2], $grad[
'coords'][3]);
14535 $out .=
' /Domain [0 1]';
14536 $out .=
' /Function '.$fc.
' 0 R';
14537 $out .=
' /Extend [true true]';
14539 } elseif ($grad[
'type'] == 3) {
14542 $out .=
' '.sprintf(
'/Coords [%F %F 0 %F %F %F]', $grad[
'coords'][0], $grad[
'coords'][1], $grad[
'coords'][2], $grad[
'coords'][3], $grad[
'coords'][4]);
14543 $out .=
' /Domain [0 1]';
14544 $out .=
' /Function '.$fc.
' 0 R';
14545 $out .=
' /Extend [true true]';
14547 } elseif ($grad[
'type'] == 6) {
14548 $out .=
' /BitsPerCoordinate 16';
14549 $out .=
' /BitsPerComponent 8';
14550 $out .=
' /Decode[0 1 0 1 0 1 0 1 0 1]';
14551 $out .=
' /BitsPerFlag 8';
14553 $out .=
' /Length '.strlen($stream);
14555 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
14557 $out .=
"\n".
'endobj';
14559 if ($grad[
'transparency']) {
14560 $shading_transparency = preg_replace(
'/\/ColorSpace \/[^\s]+/si',
'/ColorSpace /DeviceGray',
$out);
14561 $shading_transparency = preg_replace(
'/\/Function [0-9]+ /si',
'/Function '.$ft.
' ', $shading_transparency);
14563 $this->gradients[$id][
'id'] =
$this->n;
14566 $out =
'<< /Type /Pattern /PatternType 2';
14567 $out .=
' /Shading '.$this->gradients[$id][
'id'].
' 0 R';
14569 $out .=
"\n".
'endobj';
14571 $this->gradients[$id][
'pattern'] =
$this->n;
14573 if ($grad[
'transparency']) {
14575 $idgs = $id + $idt;
14577 $this->
_out($shading_transparency);
14578 $this->gradients[$idgs][
'id'] =
$this->n;
14580 $out =
'<< /Type /Pattern /PatternType 2';
14581 $out .=
' /Shading '.$this->gradients[$idgs][
'id'].
' 0 R';
14583 $out .=
"\n".
'endobj';
14585 $this->gradients[$idgs][
'pattern'] =
$this->n;
14588 $this->xobjects[
'LX'.$oid] = array(
'n' => $oid);
14590 $stream =
'q /a0 gs /Pattern cs /p'.$idgs.
' scn 0 0 '.$this->wPt.
' '.$this->hPt.
' re f Q';
14591 if ($this->compress) {
14592 $filter =
' /Filter /FlateDecode';
14593 $stream = gzcompress($stream);
14596 $out =
'<< /Type /XObject /Subtype /Form /FormType 1'.$filter;
14597 $out .=
' /Length '.strlen($stream);
14598 $rect = sprintf(
'%F %F', $this->wPt, $this->hPt);
14599 $out .=
' /BBox [0 0 '.$rect.
']';
14600 $out .=
' /Group << /Type /Group /S /Transparency /CS /DeviceGray >>';
14601 $out .=
' /Resources <<';
14602 $out .=
' /ExtGState << /a0 << /ca 1 /CA 1 >> >>';
14603 $out .=
' /Pattern << /p'.$idgs.
' '.$this->gradients[$idgs][
'pattern'].
' 0 R >>';
14606 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
14607 $out .=
"\n".
'endobj';
14611 $out =
'<< /Type /Mask /S /Luminosity /G '.($this->n - 1).
' 0 R >>'.
"\n".
'endobj';
14615 $out =
'<< /Type /ExtGState /SMask '.($this->n - 1).
' 0 R /AIS false >>'.
"\n".
'endobj';
14617 $this->extgstates[] = array(
'n' => $this->
n,
'name' =>
'TGS'.$id);
14637 public function PieSector($xc, $yc, $r, $a, $b, $style=
'FD', $cw=
true, $o=90) {
14638 $this->
PieSectorXY($xc, $yc, $r, $r, $a, $b, $style, $cw, $o);
14658 public function PieSectorXY($xc, $yc, $rx, $ry, $a, $b, $style=
'FD', $cw=
false, $o=0, $nc=2) {
14659 if ($this->state != 2) {
14663 $xc = ($this->w - $xc);
14667 $line_style = array();
14671 $b = (360 - $a + $o);
14672 $a = (360 -
$d + $o);
14702 public function ImageEps(
$file,
$x=
'',
$y=
'',
$w=0,
$h=0, $link=
'', $useBoundingBox=
true, $align=
'', $palign=
'', $border=0, $fitonpage=
false, $fixoutvals=
false) {
14703 if ($this->state != 2) {
14706 if ($this->rasterize_vector_images AND (
$w > 0) AND (
$h > 0)) {
14708 return $this->
Image(
$file,
$x,
$y,
$w,
$h,
'EPS', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false, $fitonpage);
14719 if (
$file{0} ===
'@') {
14720 $data = substr(
$file, 1);
14722 $data = file_get_contents(
$file);
14724 if ($data ===
false) {
14729 preg_match(
"/%%Creator:([^\r\n]+)/", $data, $regs); # find Creator
14730 if (count($regs) > 1) {
14731 $version_str = trim($regs[1]); # e.g.
"Adobe Illustrator(R) 8.0"
14732 if (strpos($version_str,
'Adobe Illustrator') !==
false) {
14733 $versexp = explode(
' ', $version_str);
14734 $version = (float)array_pop($versexp);
14735 if ($version >= 9) {
14736 $this->
Error(
'This version of Adobe Illustrator file is not supported: '.
$file);
14741 $start = strpos($data,
'%!PS-Adobe');
14743 $data = substr($data, $start);
14746 preg_match(
"/%%BoundingBox:([^\r\n]+)/", $data, $regs);
14747 if (count($regs) > 1) {
14748 list($x1, $y1, $x2, $y2) = explode(
' ', trim($regs[1]));
14750 $this->
Error(
'No BoundingBox found in EPS/AI file: '.
$file);
14752 $start = strpos($data,
'%%EndSetup');
14753 if ($start ===
false) {
14754 $start = strpos($data,
'%%EndProlog');
14756 if ($start ===
false) {
14757 $start = strpos($data,
'%%BoundingBox');
14759 $data = substr($data, $start);
14760 $end = strpos($data,
'%%PageTrailer');
14761 if ($end===
false) {
14762 $end = strpos($data,
'showpage');
14765 $data = substr($data, 0, $end);
14768 if ((
$w <= 0) AND (
$h <= 0)) {
14769 $w = ($x2 - $x1) /
$k;
14770 $h = ($y2 - $y1) /
$k;
14771 } elseif (
$w <= 0) {
14772 $w = ($x2-$x1) /
$k * (
$h / (($y2 - $y1) /
$k));
14773 } elseif (
$h <= 0) {
14774 $h = ($y2 - $y1) /
$k * (
$w / (($x2 - $x1) /
$k));
14778 if ($this->rasterize_vector_images) {
14780 return $this->
Image(
$file,
$x,
$y,
$w,
$h,
'EPS', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false, $fitonpage);
14783 $scale_x =
$w / (($x2 - $x1) /
$k);
14784 $scale_y =
$h / (($y2 - $y1) /
$k);
14786 $this->img_rb_y =
$y +
$h;
14789 if ($palign ==
'L') {
14791 } elseif ($palign ==
'C') {
14792 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
14793 } elseif ($palign ==
'R') {
14794 $ximg = $this->w - $this->rMargin -
$w;
14798 $this->img_rb_x = $ximg;
14800 if ($palign ==
'L') {
14802 } elseif ($palign ==
'C') {
14803 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
14804 } elseif ($palign ==
'R') {
14805 $ximg = $this->w - $this->rMargin -
$w;
14809 $this->img_rb_x = $ximg +
$w;
14811 if ($useBoundingBox) {
14812 $dx = $ximg *
$k - $x1;
14813 $dy =
$y *
$k - $y1;
14819 $this->
_out(
'q'.$this->epsmarker);
14821 $this->
_out(sprintf(
'%F %F %F %F %F %F cm', 1, 0, 0, 1, $dx, $dy + ($this->hPt - (2 *
$y *
$k) - ($y2 - $y1))));
14823 if (isset($scale_x)) {
14824 $this->
_out(sprintf(
'%F %F %F %F %F %F cm', $scale_x, 0, 0, $scale_y, $x1 * (1 - $scale_x), $y2 * (1 - $scale_y)));
14827 $lines = preg_split(
'/[\r\n]+/si', $data, -1, PREG_SPLIT_NO_EMPTY);
14829 $cnt = count($lines);
14830 for ($i=0; $i < $cnt; ++$i) {
14831 $line = $lines[$i];
14832 if (($line ==
'') OR ($line{0} ==
'%')) {
14835 $len = strlen($line);
14838 if (strcasecmp(
'x', substr(trim($line), -1)) == 0) {
14839 if (preg_match(
'/\([^\)]*\)/', $line, $matches) > 0) {
14841 $color_name = $matches[0];
14843 $line = str_replace(
' '.$color_name,
'', $line);
14845 $color_name = substr($color_name, 1, -1);
14848 $chunks = explode(
' ', $line);
14849 $cmd = trim(array_pop($chunks));
14851 if ((
$cmd ==
'Xa') OR (
$cmd ==
'XA')) {
14852 $b = array_pop($chunks);
14853 $g = array_pop($chunks);
14854 $r = array_pop($chunks);
14855 $this->
_out(
''.$r.
' '.$g.
' '.$b.
' '.(
$cmd==
'Xa'?
'rg':
'RG'));
14866 foreach ($chunks as $key => $val) {
14867 if ((($key % 2) == 0) AND (($val < $x1) OR ($val > $x2))) {
14869 } elseif ((($key % 2) != 0) AND (($val < $y1) OR ($val > $y2))) {
14897 $this->
_out($line);
14901 if (empty($color_name)) {
14903 list($col_c, $col_m, $col_y, $col_k) = $chunks;
14904 $this->
_out(
''.$col_c.
' '.$col_m.
' '.$col_y.
' '.$col_k.
' k');
14907 list($col_c, $col_m, $col_y, $col_k, $col_t) = $chunks;
14908 $this->
AddSpotColor($color_name, ($col_c * 100), ($col_m * 100), ($col_y * 100), ($col_k * 100));
14909 $color_cmd = sprintf(
'/CS%d cs %F scn', $this->spot_colors[$color_name][
'i'], (1 - $col_t));
14910 $this->
_out($color_cmd);
14915 if (empty($color_name)) {
14917 list($col_c, $col_m, $col_y, $col_k) = $chunks;
14918 $this->
_out(
''.$col_c.
' '.$col_m.
' '.$col_y.
' '.$col_k.
' K');
14921 list($col_c, $col_m, $col_y, $col_k, $col_t) = $chunks;
14922 $this->
AddSpotColor($color_name, ($col_c * 100), ($col_m * 100), ($col_y * 100), ($col_k * 100));
14923 $color_cmd = sprintf(
'/CS%d CS %F SCN', $this->spot_colors[$color_name][
'i'], (1 - $col_t));
14924 $this->
_out($color_cmd);
14936 $line[($len - 1)] = strtolower(
$cmd);
14937 $this->
_out($line);
14949 $max = min(($i + 5), $cnt);
14950 for ($j = ($i + 1); $j < $max; ++$j) {
14951 $isU = ($isU OR (($lines[$j] ==
'U') OR ($lines[$j] ==
'*U')));
14972 $this->
_out($this->epsmarker.
'Q');
14973 if (!empty($border)) {
14981 $this->
Cell(
$w, $h,
'', $border, 0,
'', 0,
'', 0,
true);
14986 $this->
Link($ximg,
$y,
$w, $h, $link, 0);
14996 $this->y =
$y + round($h/2);
15006 $this->
SetY($this->img_rb_y);
15022 $this->barcode = $bc;
15069 require_once(dirname( __FILE__ ) .
'/tcpdf_barcodes_1d.php');
15074 $arrcode = $barcodeobj->getBarcodeArray();
15075 if (($arrcode ===
false) OR empty($arrcode) OR ($arrcode[
'maxw'] == 0)) {
15076 $this->
Error(
'Error in 1D barcode string');
15079 if (!isset($style[
'position'])) {
15080 $style[
'position'] =
'';
15081 } elseif ($style[
'position'] ==
'S') {
15083 $style[
'position'] =
'';
15084 $style[
'stretch'] =
true;
15086 if (!isset($style[
'fitwidth'])) {
15087 if (!isset($style[
'stretch'])) {
15088 $style[
'fitwidth'] =
true;
15090 $style[
'fitwidth'] =
false;
15093 if ($style[
'fitwidth']) {
15095 $style[
'stretch'] =
false;
15097 if (!isset($style[
'stretch'])) {
15098 if ((
$w ===
'') OR (
$w <= 0)) {
15099 $style[
'stretch'] =
false;
15101 $style[
'stretch'] =
true;
15104 if (!isset($style[
'fgcolor'])) {
15105 $style[
'fgcolor'] = array(0,0,0);
15107 if (!isset($style[
'bgcolor'])) {
15108 $style[
'bgcolor'] =
false;
15110 if (!isset($style[
'border'])) {
15111 $style[
'border'] =
false;
15114 if (!isset($style[
'text'])) {
15115 $style[
'text'] =
false;
15117 if ($style[
'text'] AND isset($style[
'font'])) {
15118 if (isset($style[
'fontsize'])) {
15119 $fontsize = $style[
'fontsize'];
15121 $this->
SetFont($style[
'font'],
'', $fontsize);
15123 if (!isset($style[
'stretchtext'])) {
15124 $style[
'stretchtext'] = 4;
15134 if ((
$w ===
'') OR (
$w <= 0)) {
15138 $w = $this->w - $this->rMargin -
$x;
15142 if (!isset($style[
'padding'])) {
15144 } elseif ($style[
'padding'] ===
'auto') {
15145 $padding = 10 * (
$w / ($arrcode[
'maxw'] + 20));
15147 $padding = floatval($style[
'padding']);
15150 if (!isset($style[
'hpadding'])) {
15151 $hpadding = $padding;
15152 } elseif ($style[
'hpadding'] ===
'auto') {
15153 $hpadding = 10 * (
$w / ($arrcode[
'maxw'] + 20));
15155 $hpadding = floatval($style[
'hpadding']);
15158 if (!isset($style[
'vpadding'])) {
15159 $vpadding = $padding;
15160 } elseif ($style[
'vpadding'] ===
'auto') {
15161 $vpadding = ($hpadding / 2);
15163 $vpadding = floatval($style[
'vpadding']);
15166 $max_xres = (
$w - (2 * $hpadding)) / $arrcode[
'maxw'];
15167 if ($style[
'stretch']) {
15173 if ($xres > $max_xres) {
15177 if ((isset($style[
'padding']) AND ($style[
'padding'] ===
'auto'))
15178 OR (isset($style[
'hpadding']) AND ($style[
'hpadding'] ===
'auto'))) {
15179 $hpadding = 10 * $xres;
15180 if (isset($style[
'vpadding']) AND ($style[
'vpadding'] ===
'auto')) {
15181 $vpadding = ($hpadding / 2);
15185 if ($style[
'fitwidth']) {
15187 $w = (($arrcode[
'maxw'] * $xres) + (2 * $hpadding));
15188 if (isset($style[
'cellfitalign'])) {
15189 switch ($style[
'cellfitalign']) {
15192 $x -= ($wold -
$w);
15198 $x += ($wold -
$w);
15204 $x -= (($wold -
$w) / 2);
15206 $x += (($wold -
$w) / 2);
15216 $text_height = ($this->cell_height_ratio * $fontsize /
$this->k);
15218 if ((
$h ===
'') OR (
$h <= 0)) {
15220 $h = (($arrcode[
'maxw'] * $xres) / 3) + (2 * $vpadding) + $text_height;
15222 $barh =
$h - $text_height - (2 * $vpadding);
15225 if ($text_height >
$h) {
15226 $fontsize = ((
$h *
$this->k) / (4 * $this->cell_height_ratio));
15227 $text_height = ($this->cell_height_ratio * $fontsize /
$this->k);
15228 $this->
SetFont($style[
'font'],
'', $fontsize);
15230 if ($vpadding > 0) {
15231 $vpadding = ((
$h - $text_height) / 4);
15233 $barh =
$h - $text_height - (2 * $vpadding);
15238 $this->img_rb_y =
$y +
$h;
15241 if ($style[
'position'] ==
'L') {
15243 } elseif ($style[
'position'] ==
'C') {
15244 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15245 } elseif ($style[
'position'] ==
'R') {
15246 $xpos = $this->w - $this->rMargin -
$w;
15250 $this->img_rb_x = $xpos;
15252 if ($style[
'position'] ==
'L') {
15254 } elseif ($style[
'position'] ==
'C') {
15255 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15256 } elseif ($style[
'position'] ==
'R') {
15257 $xpos = $this->w - $this->rMargin -
$w;
15261 $this->img_rb_x = $xpos +
$w;
15263 $xpos_rect = $xpos;
15264 if (!isset($style[
'align'])) {
15265 $style[
'align'] =
'C';
15267 switch ($style[
'align']) {
15269 $xpos = $xpos_rect + $hpadding;
15273 $xpos = $xpos_rect + (
$w - ($arrcode[
'maxw'] * $xres)) - $hpadding;
15278 $xpos = $xpos_rect + ((
$w - ($arrcode[
'maxw'] * $xres)) / 2);
15282 $xpos_text = $xpos;
15285 $this->rtl =
false;
15287 if ($style[
'bgcolor']) {
15288 $this->
Rect($xpos_rect,
$y,
$w, $h, $style[
'border'] ?
'DF' :
'F',
'', $style[
'bgcolor']);
15289 } elseif ($style[
'border']) {
15290 $this->
Rect($xpos_rect,
$y,
$w, $h,
'D');
15296 foreach ($arrcode[
'bcode'] as
$k => $v) {
15297 $bw = ($v[
'w'] * $xres);
15300 $ypos =
$y + $vpadding + ($v[
'p'] * $barh / $arrcode[
'maxh']);
15301 $this->
Rect($xpos, $ypos, $bw, ($v[
'h'] * $barh / $arrcode[
'maxh']),
'F', array(), $style[
'fgcolor']);
15306 if ($style[
'text']) {
15308 $label = $style[
'label'];
15312 $txtwidth = ($arrcode[
'maxw'] * $xres);
15314 $style[
'stretchtext'] = 2;
15317 $this->x = $xpos_text;
15318 $this->y =
$y + $vpadding + $barh;
15321 $this->
Cell($txtwidth,
'', $label, 0, 0,
'C',
false,
'', $style[
'stretchtext'],
false,
'T',
'T');
15322 $this->cell_padding = $cellpadding;
15325 $this->rtl = $tempRTL;
15336 $this->y =
$y + round($h / 2);
15346 $this->
SetY($this->img_rb_y);
15385 require_once(dirname( __FILE__ ) .
'/tcpdf_barcodes_2d.php');
15390 $arrcode = $barcodeobj->getBarcodeArray();
15391 if (($arrcode ===
false) OR empty($arrcode) OR !isset($arrcode[
'num_rows']) OR ($arrcode[
'num_rows'] == 0) OR !isset($arrcode[
'num_cols']) OR ($arrcode[
'num_cols'] == 0)) {
15392 $this->
Error(
'Error in 2D barcode string');
15395 if (!isset($style[
'position'])) {
15396 $style[
'position'] =
'';
15398 if (!isset($style[
'fgcolor'])) {
15399 $style[
'fgcolor'] = array(0,0,0);
15401 if (!isset($style[
'bgcolor'])) {
15402 $style[
'bgcolor'] =
false;
15404 if (!isset($style[
'border'])) {
15405 $style[
'border'] =
false;
15408 if (!isset($style[
'padding'])) {
15409 $style[
'padding'] = 0;
15410 } elseif ($style[
'padding'] ===
'auto') {
15411 $style[
'padding'] = 4;
15413 if (!isset($style[
'hpadding'])) {
15414 $style[
'hpadding'] = $style[
'padding'];
15415 } elseif ($style[
'hpadding'] ===
'auto') {
15416 $style[
'hpadding'] = 4;
15418 if (!isset($style[
'vpadding'])) {
15419 $style[
'vpadding'] = $style[
'padding'];
15420 } elseif ($style[
'vpadding'] ===
'auto') {
15421 $style[
'vpadding'] = 4;
15423 $hpad = (2 * $style[
'hpadding']);
15424 $vpad = (2 * $style[
'vpadding']);
15426 if (!isset($style[
'module_width'])) {
15427 $style[
'module_width'] = 1;
15429 if (!isset($style[
'module_height'])) {
15430 $style[
'module_height'] = 1;
15441 $rows = $arrcode[
'num_rows'];
15442 $cols = $arrcode[
'num_cols'];
15444 $mw = $style[
'module_width'];
15445 $mh = $style[
'module_height'];
15446 if (($mw == 0) OR ($mh == 0)) {
15447 $this->
Error(
'Error in 2D barcode string');
15453 $maxw = $this->w - $this->rMargin -
$x;
15456 $ratioHW = ((($rows * $mh) + $hpad) / (($cols * $mw) + $vpad));
15457 $ratioWH = ((($cols * $mw) + $vpad) / (($rows * $mh) + $hpad));
15459 if (($maxw * $ratioHW) > $maxh) {
15460 $maxw = $maxh * $ratioWH;
15462 if (($maxh * $ratioWH) > $maxw) {
15463 $maxh = $maxw * $ratioHW;
15474 if (((
$w ===
'') OR (
$w <= 0)) AND ((
$h ===
'') OR (
$h <= 0))) {
15475 $w = ($cols + $hpad) * ($mw / $this->k);
15476 $h = ($rows + $vpad) * ($mh / $this->k);
15477 } elseif ((
$w ===
'') OR (
$w <= 0)) {
15478 $w =
$h * $ratioWH;
15479 } elseif ((
$h ===
'') OR (
$h <= 0)) {
15480 $h =
$w * $ratioHW;
15483 $bw = (
$w * $cols) / ($cols + $hpad);
15484 $bh = (
$h * $rows) / ($rows + $vpad);
15489 if (($cw / $ch) > ($mw / $mh)) {
15491 $cw = $ch * $mw / $mh;
15493 $style[
'hpadding'] = (
$w - $bw) / (2 * $cw);
15496 $ch = $cw * $mh / $mw;
15498 $style[
'vpadding'] = (
$h - $bh) / (2 * $ch);
15504 $this->img_rb_y =
$y +
$h;
15507 if ($style[
'position'] ==
'L') {
15509 } elseif ($style[
'position'] ==
'C') {
15510 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15511 } elseif ($style[
'position'] ==
'R') {
15512 $xpos = $this->w - $this->rMargin -
$w;
15516 $this->img_rb_x = $xpos;
15518 if ($style[
'position'] ==
'L') {
15520 } elseif ($style[
'position'] ==
'C') {
15521 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15522 } elseif ($style[
'position'] ==
'R') {
15523 $xpos = $this->w - $this->rMargin -
$w;
15527 $this->img_rb_x = $xpos +
$w;
15529 $xstart = $xpos + ($style[
'hpadding'] * $cw);
15530 $ystart =
$y + ($style[
'vpadding'] * $ch);
15533 $this->rtl =
false;
15535 if ($style[
'bgcolor']) {
15536 $this->
Rect($xpos,
$y,
$w, $h, $style[
'border'] ?
'DF' :
'F',
'', $style[
'bgcolor']);
15537 } elseif ($style[
'border']) {
15538 $this->
Rect($xpos,
$y,
$w, $h,
'D');
15544 for ($r = 0; $r < $rows; ++$r) {
15547 for ($c = 0; $c < $cols; ++$c) {
15548 if ($arrcode[
'bcode'][$r][$c] == 1) {
15550 $this->
Rect($xr, $ystart, $cw, $ch,
'F', array(), $style[
'fgcolor']);
15557 $this->rtl = $tempRTL;
15568 $this->y =
$y + round($h/2);
15578 $this->
SetY($this->img_rb_y);
15609 'left' => $this->lMargin,
15610 'right' => $this->rMargin,
15611 'top' => $this->tMargin,
15612 'bottom' => $this->bMargin,
15613 'header' => $this->header_margin,
15614 'footer' => $this->footer_margin,
15615 'cell' => $this->cell_padding,
15616 'padding_left' => $this->cell_padding[
'L'],
15617 'padding_top' => $this->cell_padding[
'T'],
15618 'padding_right' => $this->cell_padding[
'R'],
15619 'padding_bottom' => $this->cell_padding[
'B']
15636 'left' => $this->original_lMargin,
15637 'right' => $this->original_rMargin
15694 public function fixHTMLCode($html, $default_css=
'', $tagvs=
'', $tidy_options=
'') {
15706 if ($width ==
'thin') {
15708 } elseif ($width ==
'medium') {
15710 } elseif ($width ==
'thick') {
15726 switch (strtolower($style)) {
15762 $bprop = preg_split(
'/[\s]+/', trim($cssborder));
15764 switch (count($bprop)) {
15766 $width = $bprop[0];
15767 $style = $bprop[1];
15768 $color = $bprop[2];
15773 $style = $bprop[0];
15774 $color = $bprop[1];
15779 $style = $bprop[0];
15790 if ($style ==
'none') {
15793 $border[
'cap'] =
'square';
15794 $border[
'join'] =
'miter';
15796 if ($border[
'dash'] < 0) {
15813 $padding = preg_split(
'/[\s]+/', trim($csspadding));
15815 switch (count($padding)) {
15867 $margin = preg_split(
'/[\s]+/', trim($cssmargin));
15869 switch (count($margin)) {
15921 $space = preg_split(
'/[\s]+/', trim($cssbspace));
15922 $border_spacing = array();
15923 switch (count(
$space)) {
15925 $border_spacing[
'H'] =
$space[0];
15926 $border_spacing[
'V'] =
$space[1];
15930 $border_spacing[
'H'] =
$space[0];
15931 $border_spacing[
'V'] =
$space[0];
15935 return array(
'H' => 0,
'V' => 0);
15941 $border_spacing[
'H'] = $this->
getHTMLUnitToUnits($border_spacing[
'H'], $width,
'px',
false);
15942 $border_spacing[
'V'] = $this->
getHTMLUnitToUnits($border_spacing[
'V'], $width,
'px',
false);
15943 return $border_spacing;
15956 $spacing = trim($spacing);
15957 switch ($spacing) {
15963 if ($parent ==
'normal') {
15987 $stretch = trim($stretch);
15988 switch ($stretch) {
15989 case 'ultra-condensed': {
15993 case 'extra-condensed': {
15997 case 'condensed': {
16001 case 'semi-condensed': {
16009 case 'semi-expanded': {
16017 case 'extra-expanded': {
16021 case 'ultra-expanded': {
16026 $val = ($parent + 10);
16030 $val = ($parent - 10);
16034 if ($parent ==
'normal') {
16062 $size = ($refsize - 4);
16066 $size = ($refsize - 3);
16070 $size = ($refsize - 2);
16078 $size = ($refsize + 2);
16082 $size = ($refsize + 4);
16086 $size = ($refsize + 6);
16090 $size = ($parent_size - 3);
16094 $size = ($parent_size + 3);
16115 $matches = array();
16116 if (preg_match_all(
'/<cssarray>([^<]*)<\/cssarray>/isU', $html, $matches) > 0) {
16117 if (isset($matches[1][0])) {
16118 $css = array_merge($css, unserialize($this->
unhtmlentities($matches[1][0])));
16120 $html = preg_replace(
'/<cssarray>(.*?)<\/cssarray>/isU',
'', $html);
16123 $matches = array();
16124 if (preg_match_all(
'/<link([^>]*)>/isU', $html, $matches) > 0) {
16125 foreach ($matches[1] as $key => $link) {
16127 if (preg_match(
'/type[\s]*=[\s]*"text\/css"/', $link, $type)) {
16129 preg_match(
'/media[\s]*=[\s]*"([^"]*)"/', $link, $type);
16132 if (empty($type) OR (isset($type[1]) AND (($type[1] ==
'all') OR ($type[1] ==
'print')))) {
16134 if (preg_match(
'/href[\s]*=[\s]*"([^"]*)"/', $link, $type) > 0) {
16136 $cssdata = file_get_contents(trim($type[1]));
16144 $matches = array();
16145 if (preg_match_all(
'/<style([^>]*)>([^<]*)<\/style>/isU', $html, $matches) > 0) {
16146 foreach ($matches[1] as $key => $media) {
16148 preg_match(
'/media[\s]*=[\s]*"([^"]*)"/', $media, $type);
16151 if (empty($type) OR (isset($type[1]) AND (($type[1] ==
'all') OR ($type[1] ==
'print')))) {
16152 $cssdata = $matches[2][$key];
16158 $csstagarray =
'<cssarray>'.htmlentities(serialize($css)).
'</cssarray>';
16160 $html = preg_replace(
'/<head([^>]*)>(.*?)<\/head>/siU',
'', $html);
16161 $html = preg_replace(
'/<style([^>]*)>([^<]*)<\/style>/isU',
'', $html);
16163 $blocktags = array(
'blockquote',
'br',
'dd',
'dl',
'div',
'dt',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'hr',
'li',
'ol',
'p',
'pre',
'ul',
'tcpdf',
'table',
'tr',
'td');
16165 $selfclosingtags = array(
'area',
'base',
'basefont',
'br',
'hr',
'input',
'img',
'link',
'meta');
16167 $html = strip_tags($html,
'<marker/><a><b><blockquote><body><br><br/><dd><del><div><dl><dt><em><font><form><h1><h2><h3><h4><h5><h6><hr><hr/><i><img><input><label><li><ol><option><p><pre><s><select><small><span><strike><strong><sub><sup><table><tablehead><tcpdf><td><textarea><th><thead><tr><tt><u><ul>');
16169 $html = preg_replace(
'/<pre/',
'<xre', $html);
16170 $html = preg_replace(
'/<(table|tr|td|th|tcpdf|blockquote|dd|div|dl|dt|form|h1|h2|h3|h4|h5|h6|br|hr|li|ol|ul|p)([^>]*)>[\n\r\t]+/',
'<\\1\\2>', $html);
16171 $html = preg_replace(
'@(\r\n|\r)@',
"\n", $html);
16172 $repTable = array(
"\t" =>
' ',
"\0" =>
' ',
"\x0B" =>
' ',
"\\" =>
"\\\\");
16173 $html = strtr($html, $repTable);
16175 while (($offset < strlen($html)) AND ($pos = strpos($html,
'</pre>', $offset)) !==
false) {
16176 $html_a = substr($html, 0, $offset);
16177 $html_b = substr($html, $offset, ($pos - $offset + 6));
16178 while (preg_match(
"'<xre([^>]*)>(.*?)\n(.*?)</pre>'si", $html_b)) {
16180 $html_b = preg_replace(
"'<xre([^>]*)>(.*?)\n(.*?)</pre>'si",
"<xre\\1>\\2<br />\\3</pre>", $html_b);
16182 while (preg_match(
"'<xre([^>]*)>(.*?)".$this->re_space[
'p'].
"(.*?)</pre>'".$this->re_space[
'm'], $html_b)) {
16184 $html_b = preg_replace(
"'<xre([^>]*)>(.*?)".$this->re_space[
'p'].
"(.*?)</pre>'".$this->re_space[
'm'],
"<xre\\1>\\2 \\3</pre>", $html_b);
16186 $html = $html_a.$html_b.substr($html, $pos + 6);
16187 $offset = strlen($html_a.$html_b);
16190 while (($offset < strlen($html)) AND ($pos = strpos($html,
'</textarea>', $offset)) !==
false) {
16191 $html_a = substr($html, 0, $offset);
16192 $html_b = substr($html, $offset, ($pos - $offset + 11));
16193 while (preg_match(
"'<textarea([^>]*)>(.*?)\n(.*?)</textarea>'si", $html_b)) {
16195 $html_b = preg_replace(
"'<textarea([^>]*)>(.*?)\n(.*?)</textarea>'si",
"<textarea\\1>\\2<TBR>\\3</textarea>", $html_b);
16196 $html_b = preg_replace(
"'<textarea([^>]*)>(.*?)[\"](.*?)</textarea>'si",
"<textarea\\1>\\2''\\3</textarea>", $html_b);
16198 $html = $html_a.$html_b.substr($html, $pos + 11);
16199 $offset = strlen($html_a.$html_b);
16201 $html = preg_replace(
'/([\s]*)<option/si',
'<option', $html);
16202 $html = preg_replace(
'/<\/option>([\s]*)/si',
'</option>', $html);
16204 while (($offset < strlen($html)) AND ($pos = strpos($html,
'</option>', $offset)) !==
false) {
16205 $html_a = substr($html, 0, $offset);
16206 $html_b = substr($html, $offset, ($pos - $offset + 9));
16207 while (preg_match(
"'<option([^>]*)>(.*?)</option>'si", $html_b)) {
16208 $html_b = preg_replace(
"'<option([\s]+)value=\"([^\"]*)\"([^>]*)>(.*?)</option>'si",
"\\2#!TaB!#\\4#!NwL!#", $html_b);
16209 $html_b = preg_replace(
"'<option([^>]*)>(.*?)</option>'si",
"\\2#!NwL!#", $html_b);
16211 $html = $html_a.$html_b.substr($html, $pos + 9);
16212 $offset = strlen($html_a.$html_b);
16214 if (preg_match(
"'</select'si", $html)) {
16215 $html = preg_replace(
"'<select([^>]*)>'si",
"<select\\1 opt=\"", $html);
16216 $html = preg_replace(
"'#!NwL!#</select>'si",
"\" />", $html);
16218 $html = str_replace(
"\n",
' ', $html);
16220 $html = str_replace(
'<TBR>',
"\n", $html);
16222 $html = preg_replace(
'/[\s]+<\/(table|tr|ul|ol|dl)>/',
'</\\1>', $html);
16223 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<\/(td|th|li|dt|dd)>/'.$this->re_space[
'm'],
'</\\1>', $html);
16224 $html = preg_replace(
'/[\s]+<(tr|td|th|li|dt|dd)/',
'<\\1', $html);
16225 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<(ul|ol|dl|br)/'.$this->re_space[
'm'],
'<\\1', $html);
16226 $html = preg_replace(
'/<\/(table|tr|td|th|blockquote|dd|dt|dl|div|dt|h1|h2|h3|h4|h5|h6|hr|li|ol|ul|p)>[\s]+</',
'</\\1><', $html);
16227 $html = preg_replace(
'/<\/(td|th)>/',
'<marker style="font-size:0"/></\\1>', $html);
16228 $html = preg_replace(
'/<\/table>([\s]*)<marker style="font-size:0"\/>/',
'</table>', $html);
16229 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<img/'.$this->re_space[
'm'], chr(32).
'<img', $html);
16230 $html = preg_replace(
'/<img([^>]*)>[\s]+([^<])/xi',
'<img\\1> \\2', $html);
16231 $html = preg_replace(
'/<img([^>]*)>/xi',
'<img\\1><span><marker style="font-size:0"/></span>', $html);
16232 $html = preg_replace(
'/<xre/',
'<pre', $html);
16233 $html = preg_replace(
'/<textarea([^>]*)>([^<]*)<\/textarea>/xi',
'<textarea\\1 value="\\2" />', $html);
16234 $html = preg_replace(
'/<li([^>]*)><\/li>/',
'<li\\1> </li>', $html);
16235 $html = preg_replace(
'/<li([^>]*)>'.$this->re_space[
'p'].
'*<img/'.$this->re_space[
'm'],
'<li\\1><font size="1"> </font><img', $html);
16236 $html = preg_replace(
'/<([^>\/]*)>[\s]/',
'<\\1> ', $html);
16237 $html = preg_replace(
'/[\s]<\/([^>]*)>/',
' </\\1>', $html);
16238 $html = preg_replace(
'/<su([bp])/',
'<zws/><su\\1', $html);
16239 $html = preg_replace(
'/<\/su([bp])>/',
'</su\\1><zws/>', $html);
16240 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+/'.$this->re_space[
'm'], chr(32), $html);
16244 $html = preg_replace(
'/^<img/',
'<span style="font-size:0"><br /></span> <img', $html, 1);
16246 $tagpattern =
'/(<[^>]+>)/';
16248 $a = preg_split($tagpattern, $html, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
16250 $maxel = count($a);
16255 $dom[$key] = array();
16258 $dom[$key][
'tag'] =
false;
16259 $dom[$key][
'block'] =
false;
16260 $dom[$key][
'value'] =
'';
16261 $dom[$key][
'parent'] = 0;
16262 $dom[$key][
'hide'] =
false;
16269 $dom[$key][
'fill'] = (($this->textrendermode % 2) == 0);
16270 $dom[$key][
'clip'] = ($this->textrendermode > 3);
16272 $dom[$key][
'bgcolor'] =
false;
16275 $dom[$key][
'align'] =
'';
16276 $dom[$key][
'listtype'] =
'';
16277 $dom[$key][
'text-indent'] = 0;
16278 $dom[$key][
'border'] = array();
16279 $dom[$key][
'dir'] = $this->rtl?
'rtl':
'ltr';
16283 array_push($level, 0);
16284 while ($elkey < $maxel) {
16285 $dom[$key] = array();
16286 $element = $a[$elkey];
16287 $dom[$key][
'elkey'] = $elkey;
16288 if (preg_match($tagpattern, $element)) {
16290 $element = substr($element, 1, -1);
16292 preg_match(
'/[\/]?([a-zA-Z0-9]*)/', $element, $tag);
16293 $tagname = strtolower($tag[1]);
16295 if ($tagname ==
'thead') {
16296 if ($element{0} ==
'/') {
16304 $dom[$key][
'tag'] =
true;
16305 $dom[$key][
'value'] = $tagname;
16306 if (in_array($dom[$key][
'value'], $blocktags)) {
16307 $dom[$key][
'block'] =
true;
16309 $dom[$key][
'block'] =
false;
16311 if ($element{0} ==
'/') {
16313 $dom[$key][
'opening'] =
false;
16314 $dom[$key][
'parent'] = end($level);
16316 $dom[$key][
'hide'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'hide'];
16317 $dom[$key][
'fontname'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontname'];
16318 $dom[$key][
'fontstyle'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontstyle'];
16319 $dom[$key][
'fontsize'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontsize'];
16320 $dom[$key][
'font-stretch'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'font-stretch'];
16321 $dom[$key][
'letter-spacing'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'letter-spacing'];
16322 $dom[$key][
'stroke'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'stroke'];
16323 $dom[$key][
'fill'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fill'];
16324 $dom[$key][
'clip'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'clip'];
16325 $dom[$key][
'line-height'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'line-height'];
16326 $dom[$key][
'bgcolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'bgcolor'];
16327 $dom[$key][
'fgcolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fgcolor'];
16328 $dom[$key][
'strokecolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'strokecolor'];
16329 $dom[$key][
'align'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'align'];
16330 $dom[$key][
'dir'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'dir'];
16331 if (isset($dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'listtype'])) {
16332 $dom[$key][
'listtype'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'listtype'];
16335 if (($dom[$key][
'value'] ==
'tr') AND (!isset($dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'cols']))) {
16336 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'cols'] = $dom[($dom[$key][
'parent'])][
'cols'];
16338 if (($dom[$key][
'value'] ==
'td') OR ($dom[$key][
'value'] ==
'th')) {
16339 $dom[($dom[$key][
'parent'])][
'content'] = $csstagarray;
16340 for ($i = ($dom[$key][
'parent'] + 1); $i < $key; ++$i) {
16341 $dom[($dom[$key][
'parent'])][
'content'] .= $a[$dom[$i][
'elkey']];
16345 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'<table',
'<table nested="true"', $dom[($dom[$key][
'parent'])][
'content']);
16347 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'<thead>',
'', $dom[($dom[$key][
'parent'])][
'content']);
16348 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'</thead>',
'', $dom[($dom[$key][
'parent'])][
'content']);
16351 if (($dom[$key][
'value'] ==
'tr') AND ($dom[($dom[$key][
'parent'])][
'thead'] ===
true)) {
16353 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'thead'] = $csstagarray.$a[$dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'elkey']];
16355 for ($i = $dom[$key][
'parent']; $i <= $key; ++$i) {
16356 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'thead'] .= $a[$dom[$i][
'elkey']];
16358 if (!isset($dom[($dom[$key][
'parent'])][
'attribute'])) {
16359 $dom[($dom[$key][
'parent'])][
'attribute'] = array();
16362 $dom[($dom[$key][
'parent'])][
'attribute'][
'nobr'] =
'true';
16366 $dom[($dom[$key][
'parent'])][
'thead'] = str_replace(
' nobr="true"',
'', $dom[($dom[$key][
'parent'])][
'thead']);
16367 $dom[($dom[$key][
'parent'])][
'thead'] .=
'</tablehead>';
16371 $dom[$key][
'opening'] =
true;
16372 $dom[$key][
'parent'] = end($level);
16373 if ((substr($element, -1, 1) ==
'/') OR (in_array($dom[$key][
'value'], $selfclosingtags))) {
16375 $dom[$key][
'self'] =
true;
16378 array_push($level, $key);
16379 $dom[$key][
'self'] =
false;
16384 $parentkey = $dom[$key][
'parent'];
16385 $dom[$key][
'hide'] = $dom[$parentkey][
'hide'];
16386 $dom[$key][
'fontname'] = $dom[$parentkey][
'fontname'];
16387 $dom[$key][
'fontstyle'] = $dom[$parentkey][
'fontstyle'];
16388 $dom[$key][
'fontsize'] = $dom[$parentkey][
'fontsize'];
16389 $dom[$key][
'font-stretch'] = $dom[$parentkey][
'font-stretch'];
16390 $dom[$key][
'letter-spacing'] = $dom[$parentkey][
'letter-spacing'];
16391 $dom[$key][
'stroke'] = $dom[$parentkey][
'stroke'];
16392 $dom[$key][
'fill'] = $dom[$parentkey][
'fill'];
16393 $dom[$key][
'clip'] = $dom[$parentkey][
'clip'];
16394 $dom[$key][
'line-height'] = $dom[$parentkey][
'line-height'];
16395 $dom[$key][
'bgcolor'] = $dom[$parentkey][
'bgcolor'];
16396 $dom[$key][
'fgcolor'] = $dom[$parentkey][
'fgcolor'];
16397 $dom[$key][
'strokecolor'] = $dom[$parentkey][
'strokecolor'];
16398 $dom[$key][
'align'] = $dom[$parentkey][
'align'];
16399 $dom[$key][
'listtype'] = $dom[$parentkey][
'listtype'];
16400 $dom[$key][
'text-indent'] = $dom[$parentkey][
'text-indent'];
16401 $dom[$key][
'border'] = array();
16402 $dom[$key][
'dir'] = $dom[$parentkey][
'dir'];
16405 preg_match_all(
'/([^=\s]*)[\s]*=[\s]*"([^"]*)"/', $element, $attr_array, PREG_PATTERN_ORDER);
16406 $dom[$key][
'attribute'] = array();
16407 while (list($id, $name) = each($attr_array[1])) {
16408 $dom[$key][
'attribute'][strtolower($name)] = $attr_array[2][$id];
16410 if (!empty($css)) {
16416 if (isset($dom[$key][
'attribute'][
'style']) AND !empty($dom[$key][
'attribute'][
'style'])) {
16418 preg_match_all(
'/([^;:\s]*):([^;]*)/', $dom[$key][
'attribute'][
'style'], $style_array, PREG_PATTERN_ORDER);
16419 $dom[$key][
'style'] = array();
16420 while (list($id, $name) = each($style_array[1])) {
16422 $dom[$key][
'style'][strtolower($name)] = trim($style_array[2][$id]);
16426 if (isset($dom[$key][
'style'][
'direction'])) {
16427 $dom[$key][
'dir'] = $dom[$key][
'style'][
'direction'];
16430 if (isset($dom[$key][
'style'][
'display'])) {
16431 $dom[$key][
'hide'] = (trim(strtolower($dom[$key][
'style'][
'display'])) ==
'none');
16434 if (isset($dom[$key][
'style'][
'font-family'])) {
16435 $dom[$key][
'fontname'] = $this->
getFontFamilyName($dom[$key][
'style'][
'font-family']);
16438 if (isset($dom[$key][
'style'][
'list-style-type'])) {
16439 $dom[$key][
'listtype'] = trim(strtolower($dom[$key][
'style'][
'list-style-type']));
16440 if ($dom[$key][
'listtype'] ==
'inherit') {
16441 $dom[$key][
'listtype'] = $dom[$parentkey][
'listtype'];
16445 if (isset($dom[$key][
'style'][
'text-indent'])) {
16446 $dom[$key][
'text-indent'] = $this->
getHTMLUnitToUnits($dom[$key][
'style'][
'text-indent']);
16447 if ($dom[$key][
'text-indent'] ==
'inherit') {
16448 $dom[$key][
'text-indent'] = $dom[$parentkey][
'text-indent'];
16452 if (isset($dom[$key][
'style'][
'font-size'])) {
16453 $fsize = trim($dom[$key][
'style'][
'font-size']);
16454 $dom[$key][
'fontsize'] = $this->
getHTMLFontUnits($fsize, $dom[0][
'fontsize'], $dom[$parentkey][
'fontsize'],
'pt');
16457 if (isset($dom[$key][
'style'][
'font-stretch'])) {
16458 $dom[$key][
'font-stretch'] = $this->
getCSSFontStretching($dom[$key][
'style'][
'font-stretch'], $dom[$parentkey][
'font-stretch']);
16461 if (isset($dom[$key][
'style'][
'letter-spacing'])) {
16462 $dom[$key][
'letter-spacing'] = $this->
getCSSFontSpacing($dom[$key][
'style'][
'letter-spacing'], $dom[$parentkey][
'letter-spacing']);
16465 if (isset($dom[$key][
'style'][
'line-height'])) {
16466 $lineheight = trim($dom[$key][
'style'][
'line-height']);
16467 switch ($lineheight) {
16470 $dom[$key][
'line-height'] = $dom[0][
'line-height'];
16474 if (is_numeric($lineheight)) {
16475 $lineheight = $lineheight * 100;
16482 if (isset($dom[$key][
'style'][
'font-weight'])) {
16483 if (strtolower($dom[$key][
'style'][
'font-weight']{0}) ==
'n') {
16484 if (strpos($dom[$key][
'fontstyle'],
'B') !==
false) {
16485 $dom[$key][
'fontstyle'] = str_replace(
'B',
'', $dom[$key][
'fontstyle']);
16487 } elseif (strtolower($dom[$key][
'style'][
'font-weight']{0}) ==
'b') {
16488 $dom[$key][
'fontstyle'] .=
'B';
16491 if (isset($dom[$key][
'style'][
'font-style']) AND (strtolower($dom[$key][
'style'][
'font-style']{0}) ==
'i')) {
16492 $dom[$key][
'fontstyle'] .=
'I';
16497 } elseif ($dom[$key][
'value'] ==
'a') {
16501 if (isset($dom[$key][
'style'][
'background-color']) AND (!
TCPDF_STATIC::empty_string($dom[$key][
'style'][
'background-color']))) {
16505 if (isset($dom[$key][
'style'][
'text-decoration'])) {
16506 $decors = explode(
' ', strtolower($dom[$key][
'style'][
'text-decoration']));
16507 foreach ($decors as $dec) {
16510 if ($dec{0} ==
'u') {
16512 $dom[$key][
'fontstyle'] .=
'U';
16513 } elseif ($dec{0} ==
'l') {
16515 $dom[$key][
'fontstyle'] .=
'D';
16516 } elseif ($dec{0} ==
'o') {
16518 $dom[$key][
'fontstyle'] .=
'O';
16522 } elseif ($dom[$key][
'value'] ==
'a') {
16526 if (isset($dom[$key][
'style'][
'width'])) {
16527 $dom[$key][
'width'] = $dom[$key][
'style'][
'width'];
16530 if (isset($dom[$key][
'style'][
'height'])) {
16531 $dom[$key][
'height'] = $dom[$key][
'style'][
'height'];
16534 if (isset($dom[$key][
'style'][
'text-align'])) {
16535 $dom[$key][
'align'] = strtoupper($dom[$key][
'style'][
'text-align']{0});
16538 if (isset($dom[$key][
'style'][
'border'])) {
16540 if (!empty($borderstyle)) {
16541 $dom[$key][
'border'][
'LTRB'] = $borderstyle;
16544 if (isset($dom[$key][
'style'][
'border-color'])) {
16545 $brd_colors = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-color']));
16546 if (isset($brd_colors[3])) {
16549 if (isset($brd_colors[1])) {
16552 if (isset($brd_colors[0])) {
16555 if (isset($brd_colors[2])) {
16559 if (isset($dom[$key][
'style'][
'border-width'])) {
16560 $brd_widths = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-width']));
16561 if (isset($brd_widths[3])) {
16564 if (isset($brd_widths[1])) {
16567 if (isset($brd_widths[0])) {
16570 if (isset($brd_widths[2])) {
16574 if (isset($dom[$key][
'style'][
'border-style'])) {
16575 $brd_styles = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-style']));
16576 if (isset($brd_styles[3]) AND ($brd_styles[3]!=
'none')) {
16577 $dom[$key][
'border'][
'L'][
'cap'] =
'square';
16578 $dom[$key][
'border'][
'L'][
'join'] =
'miter';
16580 if ($dom[$key][
'border'][
'L'][
'dash'] < 0) {
16581 $dom[$key][
'border'][
'L'] = array();
16584 if (isset($brd_styles[1])) {
16585 $dom[$key][
'border'][
'R'][
'cap'] =
'square';
16586 $dom[$key][
'border'][
'R'][
'join'] =
'miter';
16588 if ($dom[$key][
'border'][
'R'][
'dash'] < 0) {
16589 $dom[$key][
'border'][
'R'] = array();
16592 if (isset($brd_styles[0])) {
16593 $dom[$key][
'border'][
'T'][
'cap'] =
'square';
16594 $dom[$key][
'border'][
'T'][
'join'] =
'miter';
16596 if ($dom[$key][
'border'][
'T'][
'dash'] < 0) {
16597 $dom[$key][
'border'][
'T'] = array();
16600 if (isset($brd_styles[2])) {
16601 $dom[$key][
'border'][
'B'][
'cap'] =
'square';
16602 $dom[$key][
'border'][
'B'][
'join'] =
'miter';
16604 if ($dom[$key][
'border'][
'B'][
'dash'] < 0) {
16605 $dom[$key][
'border'][
'B'] = array();
16609 $cellside = array(
'L' =>
'left',
'R' =>
'right',
'T' =>
'top',
'B' =>
'bottom');
16610 foreach ($cellside as $bsk => $bsv) {
16611 if (isset($dom[$key][
'style'][
'border-'.$bsv])) {
16613 if (!empty($borderstyle)) {
16614 $dom[$key][
'border'][$bsk] = $borderstyle;
16617 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-color'])) {
16620 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-width'])) {
16621 $dom[$key][
'border'][$bsk][
'width'] = $this->
getCSSBorderWidth($dom[$key][
'style'][
'border-'.$bsv.
'-width']);
16623 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-style'])) {
16624 $dom[$key][
'border'][$bsk][
'dash'] = $this->
getCSSBorderDashStyle($dom[$key][
'style'][
'border-'.$bsv.
'-style']);
16625 if ($dom[$key][
'border'][$bsk][
'dash'] < 0) {
16626 $dom[$key][
'border'][$bsk] = array();
16631 if (isset($dom[$key][
'style'][
'padding'])) {
16632 $dom[$key][
'padding'] = $this->
getCSSPadding($dom[$key][
'style'][
'padding']);
16636 foreach ($cellside as $psk => $psv) {
16637 if (isset($dom[$key][
'style'][
'padding-'.$psv])) {
16638 $dom[$key][
'padding'][$psk] = $this->
getHTMLUnitToUnits($dom[$key][
'style'][
'padding-'.$psv], 0,
'px',
false);
16642 if (isset($dom[$key][
'style'][
'margin'])) {
16643 $dom[$key][
'margin'] = $this->
getCSSMargin($dom[$key][
'style'][
'margin']);
16647 foreach ($cellside as $psk => $psv) {
16648 if (isset($dom[$key][
'style'][
'margin-'.$psv])) {
16649 $dom[$key][
'margin'][$psk] = $this->
getHTMLUnitToUnits(str_replace(
'auto',
'0', $dom[$key][
'style'][
'margin-'.$psv]), 0,
'px',
false);
16653 if (isset($dom[$key][
'style'][
'border-spacing'])) {
16654 $dom[$key][
'border-spacing'] = $this->
getCSSBorderMargin($dom[$key][
'style'][
'border-spacing']);
16657 if (isset($dom[$key][
'style'][
'page-break-inside']) AND ($dom[$key][
'style'][
'page-break-inside'] ==
'avoid')) {
16658 $dom[$key][
'attribute'][
'nobr'] =
'true';
16661 if (isset($dom[$key][
'style'][
'page-break-before'])) {
16662 if ($dom[$key][
'style'][
'page-break-before'] ==
'always') {
16663 $dom[$key][
'attribute'][
'pagebreak'] =
'true';
16664 } elseif ($dom[$key][
'style'][
'page-break-before'] ==
'left') {
16665 $dom[$key][
'attribute'][
'pagebreak'] =
'left';
16666 } elseif ($dom[$key][
'style'][
'page-break-before'] ==
'right') {
16667 $dom[$key][
'attribute'][
'pagebreak'] =
'right';
16671 if (isset($dom[$key][
'style'][
'page-break-after'])) {
16672 if ($dom[$key][
'style'][
'page-break-after'] ==
'always') {
16673 $dom[$key][
'attribute'][
'pagebreakafter'] =
'true';
16674 } elseif ($dom[$key][
'style'][
'page-break-after'] ==
'left') {
16675 $dom[$key][
'attribute'][
'pagebreakafter'] =
'left';
16676 } elseif ($dom[$key][
'style'][
'page-break-after'] ==
'right') {
16677 $dom[$key][
'attribute'][
'pagebreakafter'] =
'right';
16681 if (isset($dom[$key][
'attribute'][
'display'])) {
16682 $dom[$key][
'hide'] = (trim(strtolower($dom[$key][
'attribute'][
'display'])) ==
'none');
16684 if (isset($dom[$key][
'attribute'][
'border']) AND ($dom[$key][
'attribute'][
'border'] != 0)) {
16685 $borderstyle = $this->
getCSSBorderStyle($dom[$key][
'attribute'][
'border'].
' solid black');
16686 if (!empty($borderstyle)) {
16687 $dom[$key][
'border'][
'LTRB'] = $borderstyle;
16691 if ($dom[$key][
'value'] ==
'font') {
16693 if (isset($dom[$key][
'attribute'][
'face'])) {
16694 $dom[$key][
'fontname'] = $this->
getFontFamilyName($dom[$key][
'attribute'][
'face']);
16697 if (isset($dom[$key][
'attribute'][
'size'])) {
16699 if ($dom[$key][
'attribute'][
'size']{0} ==
'+') {
16700 $dom[$key][
'fontsize'] = $dom[($dom[$key][
'parent'])][
'fontsize'] + intval(substr($dom[$key][
'attribute'][
'size'], 1));
16701 } elseif ($dom[$key][
'attribute'][
'size']{0} ==
'-') {
16702 $dom[$key][
'fontsize'] = $dom[($dom[$key][
'parent'])][
'fontsize'] - intval(substr($dom[$key][
'attribute'][
'size'], 1));
16704 $dom[$key][
'fontsize'] = intval($dom[$key][
'attribute'][
'size']);
16707 $dom[$key][
'fontsize'] = intval($dom[$key][
'attribute'][
'size']);
16712 if ((($dom[$key][
'value'] ==
'ul') OR ($dom[$key][
'value'] ==
'ol') OR ($dom[$key][
'value'] ==
'dl'))
16715 $dom[$key][
'align'] =
'R';
16717 $dom[$key][
'align'] =
'L';
16720 if (($dom[$key][
'value'] ==
'small') OR ($dom[$key][
'value'] ==
'sup') OR ($dom[$key][
'value'] ==
'sub')) {
16721 if (!isset($dom[$key][
'attribute'][
'size']) AND !isset($dom[$key][
'style'][
'font-size'])) {
16722 $dom[$key][
'fontsize'] = $dom[$key][
'fontsize'] * K_SMALL_RATIO;
16725 if (($dom[$key][
'value'] ==
'strong') OR ($dom[$key][
'value'] ==
'b')) {
16726 $dom[$key][
'fontstyle'] .=
'B';
16728 if (($dom[$key][
'value'] ==
'em') OR ($dom[$key][
'value'] ==
'i')) {
16729 $dom[$key][
'fontstyle'] .=
'I';
16731 if ($dom[$key][
'value'] ==
'u') {
16732 $dom[$key][
'fontstyle'] .=
'U';
16734 if (($dom[$key][
'value'] ==
'del') OR ($dom[$key][
'value'] ==
's') OR ($dom[$key][
'value'] ==
'strike')) {
16735 $dom[$key][
'fontstyle'] .=
'D';
16737 if (!isset($dom[$key][
'style'][
'text-decoration']) AND ($dom[$key][
'value'] ==
'a')) {
16740 if (($dom[$key][
'value'] ==
'pre') OR ($dom[$key][
'value'] ==
'tt')) {
16743 if (($dom[$key][
'value']{0} ==
'h') AND (intval($dom[$key][
'value']{1}) > 0) AND (intval($dom[$key][
'value']{1}) < 7)) {
16745 if (!isset($dom[$key][
'attribute'][
'size']) AND !isset($dom[$key][
'style'][
'font-size'])) {
16746 $headsize = (4 - intval($dom[$key][
'value']{1})) * 2;
16747 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'] + $headsize;
16749 if (!isset($dom[$key][
'style'][
'font-weight'])) {
16750 $dom[$key][
'fontstyle'] .=
'B';
16753 if (($dom[$key][
'value'] ==
'table')) {
16754 $dom[$key][
'rows'] = 0;
16755 $dom[$key][
'trids'] = array();
16756 $dom[$key][
'thead'] =
'';
16758 if (($dom[$key][
'value'] ==
'tr')) {
16759 $dom[$key][
'cols'] = 0;
16761 $dom[$key][
'thead'] =
true;
16764 $dom[$key][
'thead'] =
false;
16766 ++$dom[($dom[$key][
'parent'])][
'rows'];
16768 array_push($dom[($dom[$key][
'parent'])][
'trids'], $key);
16771 if (($dom[$key][
'value'] ==
'th') OR ($dom[$key][
'value'] ==
'td')) {
16772 if (isset($dom[$key][
'attribute'][
'colspan'])) {
16773 $colspan = intval($dom[$key][
'attribute'][
'colspan']);
16777 $dom[$key][
'attribute'][
'colspan'] = $colspan;
16778 $dom[($dom[$key][
'parent'])][
'cols'] += $colspan;
16781 if (isset($dom[$key][
'attribute'][
'dir'])) {
16782 $dom[$key][
'dir'] = $dom[$key][
'attribute'][
'dir'];
16787 } elseif (!isset($dom[$key][
'style'][
'color']) AND ($dom[$key][
'value'] ==
'a')) {
16795 if (isset($dom[$key][
'attribute'][
'strokecolor']) AND (!
TCPDF_STATIC::empty_string($dom[$key][
'attribute'][
'strokecolor']))) {
16799 if (isset($dom[$key][
'attribute'][
'width'])) {
16800 $dom[$key][
'width'] = $dom[$key][
'attribute'][
'width'];
16803 if (isset($dom[$key][
'attribute'][
'height'])) {
16804 $dom[$key][
'height'] = $dom[$key][
'attribute'][
'height'];
16807 if (isset($dom[$key][
'attribute'][
'align']) AND (!
TCPDF_STATIC::empty_string($dom[$key][
'attribute'][
'align'])) AND ($dom[$key][
'value'] !==
'img')) {
16808 $dom[$key][
'align'] = strtoupper($dom[$key][
'attribute'][
'align']{0});
16811 if (isset($dom[$key][
'attribute'][
'stroke'])) {
16813 $dom[$key][
'stroke'] = $this->
getHTMLUnitToUnits($dom[$key][
'attribute'][
'stroke'], $dom[$key][
'fontsize'],
'pt',
true);
16815 if (isset($dom[$key][
'attribute'][
'fill'])) {
16817 if ($dom[$key][
'attribute'][
'fill'] ==
'true') {
16818 $dom[$key][
'fill'] =
true;
16820 $dom[$key][
'fill'] =
false;
16823 if (isset($dom[$key][
'attribute'][
'clip'])) {
16825 if ($dom[$key][
'attribute'][
'clip'] ==
'true') {
16826 $dom[$key][
'clip'] =
true;
16828 $dom[$key][
'clip'] =
false;
16834 $dom[$key][
'tag'] =
false;
16835 $dom[$key][
'block'] =
false;
16837 $dom[$key][
'value'] = stripslashes($this->
unhtmlentities($element));
16838 $dom[$key][
'parent'] = end($level);
16839 $dom[$key][
'dir'] = $dom[$dom[$key][
'parent']][
'dir'];
16855 $spacestr = chr(32);
16857 $spacestr = chr(0).chr(32);
16896 public function writeHTMLCell(
$w,
$h,
$x,
$y, $html=
'', $border=0, $ln=0, $fill=
false, $reseth=
true, $align=
'', $autopadding=
true) {
16897 return $this->
MultiCell(
$w,
$h, $html, $border, $align, $fill, $ln,
$x,
$y, $reseth, 0,
true, $autopadding, 0,
'T',
false);
16913 public function writeHTML($html, $ln=
true, $fill=
false, $reseth=
false, $cell=
false, $align=
'') {
16924 $curfontascent = $this->
getFontAscent($curfontname, $curfontstyle, $curfontsize);
16925 $curfontdescent = $this->
getFontDescent($curfontname, $curfontstyle, $curfontsize);
16928 $this->newline =
true;
16932 $maxbottomliney = 0;
16938 $this_method_vars = array();
16940 $fontaligned =
false;
16941 $reverse_dir =
false;
16942 $this->premode =
false;
16943 if ($this->inxobj) {
16945 $pask = count($this->xobjects[$this->xobjid][
'annotations']);
16946 } elseif (isset($this->PageAnnots[$this->page])) {
16947 $pask = count($this->PageAnnots[$this->page]);
16951 if ($this->inxobj) {
16953 $startlinepos = strlen($this->xobjects[$this->xobjid][
'outdata']);
16954 } elseif (!$this->InFooter) {
16955 if (isset($this->footerlen[$this->page])) {
16972 $w -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
16975 $this->x -= $this->cell_padding[
'R'];
16976 $this->lMargin += $this->cell_padding[
'R'];
16978 $this->x += $this->cell_padding[
'L'];
16979 $this->rMargin += $this->cell_padding[
'L'];
16982 if ($this->customlistindent >= 0) {
16987 $this->listindentlevel = 0;
16994 $this->listnum = 0;
16995 $this->listordered = array();
16996 $this->listcount = array();
16997 $this->lispacer =
'';
17003 $maxel = count($dom);
17005 $hidden_node_key = -1;
17006 while ($key < $maxel) {
17007 if ($dom[$key][
'tag']) {
17008 if ($dom[$key][
'opening']) {
17009 if (($hidden_node_key <= 0) AND $dom[$key][
'hide']) {
17011 $hidden_node_key = $key;
17013 } elseif (($hidden_node_key > 0) AND ($dom[$key][
'parent'] == $hidden_node_key)) {
17015 $hidden_node_key = 0;
17018 if ($hidden_node_key >= 0) {
17021 if ($hidden_node_key == 0) {
17023 $hidden_node_key = -1;
17027 if ($dom[$key][
'tag'] AND isset($dom[$key][
'attribute'][
'pagebreak'])) {
17029 if (($dom[$key][
'attribute'][
'pagebreak'] ==
'true') OR ($dom[$key][
'attribute'][
'pagebreak'] ==
'left') OR ($dom[$key][
'attribute'][
'pagebreak'] ==
'right')) {
17032 $this->htmlvspace = ($this->PageBreakTrigger + 1);
17034 if ((($dom[$key][
'attribute'][
'pagebreak'] ==
'left') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
17035 OR (($dom[$key][
'attribute'][
'pagebreak'] ==
'right') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
17038 $this->htmlvspace = ($this->PageBreakTrigger + 1);
17041 if ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND isset($dom[$key][
'attribute'][
'nobr']) AND ($dom[$key][
'attribute'][
'nobr'] ==
'true')) {
17042 if (isset($dom[($dom[$key][
'parent'])][
'attribute'][
'nobr']) AND ($dom[($dom[$key][
'parent'])][
'attribute'][
'nobr'] ==
'true')) {
17043 $dom[$key][
'attribute'][
'nobr'] =
false;
17048 $this_method_vars[
'html'] = $html;
17049 $this_method_vars[
'ln'] = $ln;
17050 $this_method_vars[
'fill'] = $fill;
17051 $this_method_vars[
'reseth'] = $reseth;
17052 $this_method_vars[
'cell'] = $cell;
17053 $this_method_vars[
'align'] = $align;
17054 $this_method_vars[
'gvars'] = $gvars;
17055 $this_method_vars[
'prevPage'] = $prevPage;
17056 $this_method_vars[
'prev_cell_margin'] = $prev_cell_margin;
17057 $this_method_vars[
'prev_cell_padding'] = $prev_cell_padding;
17058 $this_method_vars[
'prevlMargin'] = $prevlMargin;
17059 $this_method_vars[
'prevrMargin'] = $prevrMargin;
17060 $this_method_vars[
'curfontname'] = $curfontname;
17061 $this_method_vars[
'curfontstyle'] = $curfontstyle;
17062 $this_method_vars[
'curfontsize'] = $curfontsize;
17063 $this_method_vars[
'curfontascent'] = $curfontascent;
17064 $this_method_vars[
'curfontdescent'] = $curfontdescent;
17065 $this_method_vars[
'curfontstretcing'] = $curfontstretcing;
17066 $this_method_vars[
'curfonttracking'] = $curfonttracking;
17067 $this_method_vars[
'minstartliney'] = $minstartliney;
17068 $this_method_vars[
'maxbottomliney'] = $maxbottomliney;
17069 $this_method_vars[
'yshift'] = $yshift;
17070 $this_method_vars[
'startlinepage'] = $startlinepage;
17071 $this_method_vars[
'startlinepos'] = $startlinepos;
17072 $this_method_vars[
'startlinex'] = $startlinex;
17073 $this_method_vars[
'startliney'] = $startliney;
17074 $this_method_vars[
'newline'] =
$newline;
17075 $this_method_vars[
'loop'] = $loop;
17076 $this_method_vars[
'curpos'] = $curpos;
17077 $this_method_vars[
'pask'] = $pask;
17078 $this_method_vars[
'lalign'] = $lalign;
17079 $this_method_vars[
'plalign'] = $plalign;
17080 $this_method_vars[
'w'] =
$w;
17081 $this_method_vars[
'prev_cell_height_ratio'] = $prev_cell_height_ratio;
17082 $this_method_vars[
'prev_listnum'] = $prev_listnum;
17083 $this_method_vars[
'prev_listordered'] = $prev_listordered;
17084 $this_method_vars[
'prev_listcount'] = $prev_listcount;
17085 $this_method_vars[
'prev_lispacer'] = $prev_lispacer;
17086 $this_method_vars[
'fontaligned'] = $fontaligned;
17087 $this_method_vars[
'key'] = $key;
17088 $this_method_vars[
'dom'] = $dom;
17092 if (($dom[$key][
'value'] ==
'tr') AND isset($dom[$key][
'thead']) AND $dom[$key][
'thead']) {
17093 if (isset($dom[$key][
'parent']) AND isset($dom[$dom[$key][
'parent']][
'thead']) AND !
TCPDF_STATIC::empty_string($dom[$dom[$key][
'parent']][
'thead'])) {
17094 $this->inthead =
true;
17096 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
17098 if (($this->y < $this->start_transaction_y) OR ($this->
checkPageBreak($this->lasth,
'',
false))) {
17103 foreach ($this_method_vars as $vkey => $vval) {
17111 if ((!$this->
checkPageBreak($this->PageBreakTrigger + 1)) AND ($this->y < $pre_y)) {
17116 $this->start_transaction_y =
$this->y;
17118 $this->thead = $tmp_thead;
17120 if (isset($dom[$dom[$key][
'parent']][
'attribute'][
'cellspacing'])) {
17121 $tmp_cellspacing = $this->
getHTMLUnitToUnits($dom[$dom[$key][
'parent']][
'attribute'][
'cellspacing'], 1,
'px');
17122 } elseif (isset($dom[$dom[$key][
'parent']][
'border-spacing'])) {
17123 $tmp_cellspacing = $dom[$dom[$key][
'parent']][
'border-spacing'][
'V'];
17125 $tmp_cellspacing = 0;
17127 $dom[$dom[$key][
'parent']][
'borderposition'][
'page'] =
$this->page;
17129 $dom[$dom[$key][
'parent']][
'borderposition'][
'y'] = $this->y + $tmp_cellspacing;
17130 $xoffset = ($this->x - $dom[$dom[$key][
'parent']][
'borderposition'][
'x']);
17131 $dom[$dom[$key][
'parent']][
'borderposition'][
'x'] += $xoffset;
17132 $dom[$dom[$key][
'parent']][
'borderposition'][
'xmax'] += $xoffset;
17134 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
17138 while ( ($key < $maxel) AND (!(
17139 ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'tr') AND (!isset($dom[$key][
'thead']) OR !$dom[$key][
'thead']))
17140 OR ($dom[$key][
'tag'] AND (!$dom[$key][
'opening']) AND ($dom[$key][
'value'] ==
'table'))) )) {
17144 if ($dom[$key][
'tag'] OR ($key == 0)) {
17145 if ((($dom[$key][
'value'] ==
'table') OR ($dom[$key][
'value'] ==
'tr')) AND (isset($dom[$key][
'align']))) {
17146 $dom[$key][
'align'] = (
$this->rtl) ?
'R' :
'L';
17149 if ((!$this->newline) AND ($dom[$key][
'value'] ==
'img') AND (isset($dom[$key][
'height'])) AND ($dom[$key][
'height'] > 0)) {
17152 $autolinebreak =
false;
17153 if (isset($dom[$key][
'width']) AND ($dom[$key][
'width'] > 0)) {
17155 if (($imgw <= ($this->w - $this->lMargin - $this->rMargin - $this->cell_padding[
'L'] - $this->cell_padding[
'R']))
17156 AND ((($this->rtl) AND (($this->x - $imgw) < ($this->lMargin + $this->cell_padding[
'L'])))
17157 OR ((!$this->rtl) AND (($this->x + $imgw) > ($this->w - $this->rMargin - $this->cell_padding[
'R']))))) {
17159 $autolinebreak =
true;
17160 $this->
Ln(
'', $cell);
17161 if ((!$dom[($key-1)][
'tag']) AND ($dom[($key-1)][
'value'] ==
' ')) {
17167 if (!$autolinebreak) {
17176 if ($this->page > $startlinepage) {
17178 if (isset($this->footerlen[$startlinepage])) {
17179 $curpos = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17183 $linebeg = substr($pagebuff, $startlinepos, ($curpos - $startlinepos));
17184 $tstart = substr($pagebuff, 0, $startlinepos);
17185 $tend = substr($this->
getPageBuffer($startlinepage), $curpos);
17189 $tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
17190 $tend = substr($pagebuff, $this->cntmrk[$this->page]);
17192 $yshift = ($minstartliney -
$this->y);
17193 if ($fontaligned) {
17194 $yshift += ($curfontsize /
$this->k);
17196 $try = sprintf(
'1 0 0 1 0 %F cm', ($yshift * $this->k));
17197 $this->
setPageBuffer($this->page, $tstart.
"\nq\n".$try.
"\n".$linebeg.
"\nQ\n".$tend);
17199 if (isset($this->PageAnnots[$this->page])) {
17200 $next_pask = count($this->PageAnnots[$this->page]);
17204 if (isset($this->PageAnnots[$startlinepage])) {
17205 foreach ($this->PageAnnots[$startlinepage] as $pak => $pac) {
17206 if ($pak >= $pask) {
17208 unset($this->PageAnnots[$startlinepage][$pak]);
17209 $npak = count($this->PageAnnots[$this->page]) - 1;
17210 $this->PageAnnots[
$this->page][$npak][
'y'] -= $yshift;
17214 $pask = $next_pask;
17218 $this->newline =
false;
17220 $this->y += ((($curfontsize * $this->cell_height_ratio /
$this->k) + $curfontascent - $curfontdescent) / 2) - $imgh;
17221 $minstartliney = min($this->y, $minstartliney);
17224 } elseif (isset($dom[$key][
'fontname']) OR isset($dom[$key][
'fontstyle']) OR isset($dom[$key][
'fontsize']) OR isset($dom[$key][
'line-height'])) {
17226 $pfontname = $curfontname;
17227 $pfontstyle = $curfontstyle;
17228 $pfontsize = $curfontsize;
17229 $fontname = isset($dom[$key][
'fontname']) ? $dom[$key][
'fontname'] : $curfontname;
17230 $fontstyle = isset($dom[$key][
'fontstyle']) ? $dom[$key][
'fontstyle'] : $curfontstyle;
17231 $fontsize = isset($dom[$key][
'fontsize']) ? $dom[$key][
'fontsize'] : $curfontsize;
17232 $fontascent = $this->
getFontAscent($fontname, $fontstyle, $fontsize);
17233 $fontdescent = $this->
getFontDescent($fontname, $fontstyle, $fontsize);
17234 if (($fontname != $curfontname) OR ($fontstyle != $curfontstyle) OR ($fontsize != $curfontsize)
17235 OR ($this->cell_height_ratio != $dom[$key][
'line-height'])
17236 OR ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'li')) ) {
17237 if (($key < ($maxel - 1)) AND (
17238 ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'li'))
17239 OR ($this->cell_height_ratio != $dom[$key][
'line-height'])
17240 OR (!$this->newline AND is_numeric($fontsize) AND is_numeric($curfontsize) AND ($fontsize >= 0) AND ($curfontsize >= 0) AND ($fontsize != $curfontsize))
17242 if ($this->page > $startlinepage) {
17244 if (isset($this->footerlen[$startlinepage])) {
17245 $curpos = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17249 $linebeg = substr($pagebuff, $startlinepos, ($curpos - $startlinepos));
17250 $tstart = substr($pagebuff, 0, $startlinepos);
17251 $tend = substr($this->
getPageBuffer($startlinepage), $curpos);
17255 $tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
17256 $tend = substr($pagebuff, $this->cntmrk[$this->page]);
17258 $yshift = ($minstartliney -
$this->y);
17259 $try = sprintf(
'1 0 0 1 0 %F cm', ($yshift * $this->k));
17260 $this->
setPageBuffer($this->page, $tstart.
"\nq\n".$try.
"\n".$linebeg.
"\nQ\n".$tend);
17262 if (isset($this->PageAnnots[$this->page])) {
17263 $next_pask = count($this->PageAnnots[$this->page]);
17267 if (isset($this->PageAnnots[$startlinepage])) {
17268 foreach ($this->PageAnnots[$startlinepage] as $pak => $pac) {
17269 if ($pak >= $pask) {
17271 unset($this->PageAnnots[$startlinepage][$pak]);
17272 $npak = count($this->PageAnnots[$this->page]) - 1;
17273 $this->PageAnnots[
$this->page][$npak][
'y'] -= $yshift;
17277 $pask = $next_pask;
17282 if (!isset($dom[$key][
'line-height'])) {
17285 if (!$dom[$key][
'block']) {
17286 if (!(isset($dom[($key + 1)]) AND $dom[($key + 1)][
'tag'] AND (!$dom[($key + 1)][
'opening']) AND ($dom[($key + 1)][
'value'] !=
'li') AND $dom[$key][
'tag'] AND (!$dom[$key][
'opening']))) {
17287 $this->y += (((($curfontsize *
$this->cell_height_ratio) - ($fontsize * $dom[$key][
'line-height'])) / $this->k) + $curfontascent - $fontascent - $curfontdescent + $fontdescent) / 2;
17289 if (($dom[$key][
'value'] !=
'sup') AND ($dom[$key][
'value'] !=
'sub')) {
17290 $current_line_align_data = array($key, $minstartliney, $maxbottomliney);
17291 if (isset($line_align_data) AND (($line_align_data[0] == ($key - 1)) OR (($line_align_data[0] == ($key - 2)) AND (isset($dom[($key - 1)])) AND (preg_match(
'/^([\s]+)$/', $dom[($key - 1)][
'value']) > 0)))) {
17292 $minstartliney = min($this->y, $line_align_data[1]);
17293 $maxbottomliney = max(($this->y + (($fontsize * $this->cell_height_ratio) / $this->k)), $line_align_data[2]);
17295 $minstartliney = min($this->y, $minstartliney);
17296 $maxbottomliney = max(($this->y + (($fontsize * $this->cell_height_ratio) / $this->k)), $maxbottomliney);
17298 $line_align_data = $current_line_align_data;
17301 $this->cell_height_ratio = $dom[$key][
'line-height'];
17302 $fontaligned =
true;
17304 $this->
SetFont($fontname, $fontstyle, $fontsize);
17307 $curfontname = $fontname;
17308 $curfontstyle = $fontstyle;
17309 $curfontsize = $fontsize;
17310 $curfontascent = $fontascent;
17311 $curfontdescent = $fontdescent;
17316 $textfill = isset($dom[$key][
'fill']) ? $dom[$key][
'fill'] : (($this->textrendermode % 2) == 0);
17317 $textclip = isset($dom[$key][
'clip']) ? $dom[$key][
'clip'] : ($this->textrendermode > 3);
17319 if (isset($dom[$key][
'font-stretch']) AND ($dom[$key][
'font-stretch'] !==
false)) {
17322 if (isset($dom[$key][
'letter-spacing']) AND ($dom[$key][
'letter-spacing'] !==
false)) {
17325 if (($plalign ==
'J') AND $dom[$key][
'block']) {
17329 $curpos = $this->pagelen[$startlinepage];
17330 if (isset($dom[$key][
'bgcolor']) AND ($dom[$key][
'bgcolor'] !==
false)) {
17334 $wfill = $fill |
false;
17336 if (isset($dom[$key][
'fgcolor']) AND ($dom[$key][
'fgcolor'] !==
false)) {
17339 if (isset($dom[$key][
'strokecolor']) AND ($dom[$key][
'strokecolor'] !==
false)) {
17342 if (isset($dom[$key][
'align'])) {
17343 $lalign = $dom[$key][
'align'];
17350 if ($this->newline AND (strlen($dom[$key][
'value']) > 0) AND ($dom[$key][
'value'] !=
'td') AND ($dom[$key][
'value'] !=
'th')) {
17352 $fontaligned =
false;
17354 if (isset($startlinex)) {
17355 $yshift = ($minstartliney - $startliney);
17356 if (($yshift > 0) OR ($this->page > $startlinepage)) {
17361 $linew = abs($this->endlinex - $startlinex);
17362 if ($this->inxobj) {
17364 $pstart = substr($this->xobjects[$this->xobjid][
'outdata'], 0, $startlinepos);
17365 if (isset($opentagpos)) {
17366 $midpos = $opentagpos;
17371 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos, ($midpos - $startlinepos));
17372 $pend = substr($this->xobjects[$this->xobjid][
'outdata'], $midpos);
17374 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos);
17378 $pstart = substr($this->
getPageBuffer($startlinepage), 0, $startlinepos);
17379 if (isset($opentagpos) AND isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
17380 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17381 $midpos = min($opentagpos, $this->footerpos[$startlinepage]);
17382 } elseif (isset($opentagpos)) {
17383 $midpos = $opentagpos;
17384 } elseif (isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
17385 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17386 $midpos = $this->footerpos[$startlinepage];
17391 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos, ($midpos - $startlinepos));
17392 $pend = substr($this->
getPageBuffer($startlinepage), $midpos);
17394 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos);
17398 if ((isset($plalign) AND ((($plalign ==
'C') OR ($plalign ==
'J') OR (($plalign ==
'R') AND (!$this->rtl)) OR (($plalign ==
'L') AND ($this->rtl)))))) {
17401 if (($plalign ==
'J') AND $this->
isRTLTextDir() AND ($this->num_columns > 1)) {
17402 $tw += $this->cell_padding[
'R'];
17404 if ($this->lMargin != $prevlMargin) {
17407 if ($this->rMargin != $prevrMargin) {
17416 $pos1 = intval($pos1);
17424 if ($pos1 == $pos2) {
17425 $pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
17426 if (substr($pmid, $pos1, 4) ==
'[()]') {
17427 $linew -= $one_space_width;
17428 } elseif ($pos1 == strpos($pmid,
'[(')) {
17437 $pos1 = intval($pos1);
17445 if ($pos1 == $pos2) {
17446 $pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
17447 $linew -= $one_space_width;
17451 $mdiff = ($tw - $linew);
17452 if ($plalign ==
'C') {
17454 $t_x = -($mdiff / 2);
17456 $t_x = ($mdiff / 2);
17458 } elseif ($plalign ==
'R') {
17461 } elseif ($plalign ==
'L') {
17464 } elseif (($plalign ==
'J') AND ($plalign == $lalign)) {
17473 $pmidtemp = preg_replace(
'/[\\\][\(]/x',
'\\#!#OP#!#', $pmidtemp);
17474 $pmidtemp = preg_replace(
'/[\\\][\)]/x',
'\\#!#CP#!#', $pmidtemp);
17476 if (preg_match_all(
'/\[\(([^\)]*)\)\]/x', $pmidtemp, $lnstring, PREG_PATTERN_ORDER)) {
17478 $maxkk = count($lnstring[1]) - 1;
17479 for ($kk=0; $kk <= $maxkk; ++$kk) {
17481 $lnstring[1][$kk] = str_replace(
'#!#OP#!#',
'(', $lnstring[1][$kk]);
17482 $lnstring[1][$kk] = str_replace(
'#!#CP#!#',
')', $lnstring[1][$kk]);
17484 $lnstring[2][$kk] = substr_count($lnstring[1][$kk], $spacestr);
17486 $ns += $lnstring[2][$kk];
17487 $lnstring[3][$kk] = $ns;
17493 $spacewidth = ($mdiff / ($ns - $no)) *
$this->k;
17494 $spacewidthu = -1000 * ($mdiff + (($ns + $no) * $one_space_width)) / $ns / $this->FontSize;
17495 if ($this->font_spacing != 0) {
17498 $spacewidthu += $osw;
17505 $prev_epsposbeg = 0;
17511 while (preg_match(
'/([0-9\.\+\-]*)[\s](Td|cm|m|l|c|re)[\s]/x', $pmid, $strpiece, PREG_OFFSET_CAPTURE, $offset) == 1) {
17513 $stroffset = strpos($pmid,
'[(', $offset);
17514 if (($stroffset !==
false) AND ($stroffset <= $strpiece[2][1])) {
17516 $offset = strpos($pmid,
')]', $stroffset);
17517 while (($offset !==
false) AND ($pmid[($offset - 1)] ==
'\\')) {
17518 $offset = strpos($pmid,
')]', ($offset + 1));
17520 if ($offset ===
false) {
17521 $this->
Error(
'HTML Justification: malformed PDF code.');
17526 $spacew = ($spacewidth * ($nsmax - $ns));
17528 $spacew = ($spacewidth * $ns);
17530 $offset = $strpiece[2][1] + strlen($strpiece[2][0]);
17531 $epsposbeg = strpos($pmid,
'q'.$this->epsmarker, $offset);
17532 $epsposend = strpos($pmid, $this->epsmarker.
'Q', $offset) + strlen($this->epsmarker.
'Q');
17533 if ((($epsposbeg > 0) AND ($epsposend > 0) AND ($offset > $epsposbeg) AND ($offset < $epsposend))
17534 OR (($epsposbeg ===
false) AND ($epsposend > 0) AND ($offset < $epsposend))) {
17536 $trx = sprintf(
'1 0 0 1 %F 0 cm', $spacew);
17537 $epsposbeg = strpos($pmid,
'q'.$this->epsmarker, ($prev_epsposbeg - 6));
17538 $pmid_b = substr($pmid, 0, $epsposbeg);
17539 $pmid_m = substr($pmid, $epsposbeg, ($epsposend - $epsposbeg));
17540 $pmid_e = substr($pmid, $epsposend);
17541 $pmid = $pmid_b.
"\nq\n".$trx.
"\n".$pmid_m.
"\nQ\n".$pmid_e;
17542 $offset = $epsposend;
17546 $prev_epsposbeg = $epsposbeg;
17549 switch ($strpiece[2][0]) {
17555 preg_match(
'/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s]('.$strpiece[2][0].
')([\s]*)/x', $pmid, $xmatches);
17556 $currentxpos = $xmatches[1];
17557 $textpos = $currentxpos;
17558 if (($strcount <= $maxkk) AND ($strpiece[2][0] ==
'Td')) {
17559 $ns = $lnstring[3][$strcount];
17561 $spacew = ($spacewidth * ($nsmax - $ns));
17566 $pmid = preg_replace_callback(
'/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s]('.$strpiece[2][0].
')([\s]*)/x',
17567 create_function(
'$matches',
'global $spacew;
17568 $newx = sprintf("%F",(floatval($matches[1]) + $spacew));
17569 return "".$newx." ".$matches[2]." x*#!#*x".$matches[3].$matches[4];'), $pmid, 1);
17575 $this->lispacer =
'';
17578 preg_match(
'/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s](re)([\s]*)/x', $pmid, $xmatches);
17579 $currentxpos = $xmatches[1];
17580 global $x_diff, $w_diff;
17584 if ($currentxpos < $textpos) {
17585 $x_diff = ($spacewidth * ($nsmax - $lnstring[3][$strcount]));
17586 $w_diff = ($spacewidth * $lnstring[2][$strcount]);
17588 if ($strcount > 0) {
17589 $x_diff = ($spacewidth * ($nsmax - $lnstring[3][($strcount - 1)]));
17590 $w_diff = ($spacewidth * $lnstring[2][($strcount - 1)]);
17594 if ($currentxpos > $textpos) {
17595 if ($strcount > 0) {
17596 $x_diff = ($spacewidth * $lnstring[3][($strcount - 1)]);
17598 $w_diff = ($spacewidth * $lnstring[2][$strcount]);
17600 if ($strcount > 1) {
17601 $x_diff = ($spacewidth * $lnstring[3][($strcount - 2)]);
17603 if ($strcount > 0) {
17604 $w_diff = ($spacewidth * $lnstring[2][($strcount - 1)]);
17608 $pmid = preg_replace_callback(
'/('.$xmatches[1].
')[\s]('.$xmatches[2].
')[\s]('.$xmatches[3].
')[\s]('.$strpiece[1][0].
')[\s](re)([\s]*)/x',
17609 create_function(
'$matches',
'global $x_diff, $w_diff;
17610 $newx = sprintf("%F",(floatval($matches[1]) + $x_diff));
17611 $neww = sprintf("%F",(floatval($matches[3]) + $w_diff));
17612 return "".$newx." ".$matches[2]." ".$neww." ".$matches[4]." x*#!#*x".$matches[5].$matches[6];'), $pmid, 1);
17617 preg_match(
'/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s](c)([\s]*)/x', $pmid, $xmatches);
17618 $currentxpos = $xmatches[1];
17620 $pmid = preg_replace_callback(
'/('.$xmatches[1].
')[\s]('.$xmatches[2].
')[\s]('.$xmatches[3].
')[\s]('.$xmatches[4].
')[\s]('.$xmatches[5].
')[\s]('.$strpiece[1][0].
')[\s](c)([\s]*)/x',
17621 create_function(
'$matches',
'global $spacew;
17622 $newx1 = sprintf("%F",(floatval($matches[1]) + $spacew));
17623 $newx2 = sprintf("%F",(floatval($matches[3]) + $spacew));
17624 $newx3 = sprintf("%F",(floatval($matches[5]) + $spacew));
17625 return "".$newx1." ".$matches[2]." ".$newx2." ".$matches[4]." ".$newx3." ".$matches[6]." x*#!#*x".$matches[7].$matches[8];'), $pmid, 1);
17630 $cxpos = ($currentxpos /
$this->k);
17631 $lmpos = ($this->lMargin + $this->cell_padding[
'L'] +
$this->feps);
17632 if ($this->inxobj) {
17634 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
17635 if (($pac[
'y'] >= $minstartliney) AND (($pac[
'x'] * $this->k) >= ($currentxpos - $this->feps)) AND (($pac[
'x'] * $this->k) <= ($currentxpos + $this->feps))) {
17636 if ($cxpos > $lmpos) {
17638 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17640 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17645 } elseif (isset($this->PageAnnots[$this->page])) {
17646 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
17647 if (($pac[
'y'] >= $minstartliney) AND (($pac[
'x'] * $this->k) >= ($currentxpos - $this->feps)) AND (($pac[
'x'] * $this->k) <= ($currentxpos + $this->feps))) {
17648 if ($cxpos > $lmpos) {
17650 $this->PageAnnots[
$this->page][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17652 $this->PageAnnots[
$this->page][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17660 $pmid = str_replace(
'x*#!#*x',
'', $pmid);
17663 $spacew = $spacewidthu;
17664 if ($this->font_stretching != 100) {
17666 $spacew /= ($this->font_stretching / 100);
17670 $pmidtemp = preg_replace(
'/[\\\][\(]/x',
'\\#!#OP#!#', $pmidtemp);
17671 $pmidtemp = preg_replace(
'/[\\\][\)]/x',
'\\#!#CP#!#', $pmidtemp);
17672 $pmid = preg_replace_callback(
"/\[\(([^\)]*)\)\]/x",
17673 create_function(
'$matches',
'global $spacew;
17674 $matches[1] = str_replace("#!#OP#!#", "(", $matches[1]);
17675 $matches[1] = str_replace("#!#CP#!#", ")", $matches[1]);
17676 return "[(".str_replace(chr(0).chr(32), ") ".sprintf("%F", $spacew)." (", $matches[1]).")]";'), $pmidtemp);
17677 if ($this->inxobj) {
17679 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.
"\n".$pmid.
"\n".$pend;
17681 $this->
setPageBuffer($startlinepage, $pstart.
"\n".$pmid.
"\n".$pend);
17683 $endlinepos = strlen($pstart.
"\n".$pmid.
"\n");
17686 if ($this->font_stretching != 100) {
17688 $spacewidth /= ($this->font_stretching / 100);
17690 $rs = sprintf(
'%F Tw', $spacewidth);
17691 $pmid = preg_replace(
"/\[\(/x", $rs.
' [(', $pmid);
17692 if ($this->inxobj) {
17694 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n".$pend;
17696 $this->
setPageBuffer($startlinepage, $pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n".$pend);
17698 $endlinepos = strlen($pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n");
17703 if (($t_x != 0) OR ($yshift < 0)) {
17705 $trx = sprintf(
'1 0 0 1 %F %F cm', ($t_x * $this->k), ($yshift * $this->k));
17706 $pstart .=
"\nq\n".$trx.
"\n".$pmid.
"\nQ\n";
17707 $endlinepos = strlen($pstart);
17708 if ($this->inxobj) {
17711 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
17712 if ($pak >= $pask) {
17713 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'x'] += $t_x;
17714 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'y'] -= $yshift;
17720 if (isset($this->PageAnnots[$this->page])) {
17721 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
17722 if ($pak >= $pask) {
17723 $this->PageAnnots[
$this->page][$pak][
'x'] += $t_x;
17724 $this->PageAnnots[
$this->page][$pak][
'y'] -= $yshift;
17729 $this->y -= $yshift;
17733 $this->newline =
false;
17736 if ($dom[$dom[$key][
'parent']][
'value'] ==
'sup') {
17738 } elseif ($dom[$dom[$key][
'parent']][
'value'] ==
'sub') {
17739 $startliney -= (($this->FontSizePt / 0.7) /
$this->k);
17741 $minstartliney = $startliney;
17745 if (isset($endlinepos) AND (!$pbrk)) {
17746 $startlinepos = $endlinepos;
17748 if ($this->inxobj) {
17750 $startlinepos = strlen($this->xobjects[$this->xobjid][
'outdata']);
17751 } elseif (!$this->InFooter) {
17752 if (isset($this->footerlen[$this->page])) {
17762 unset($endlinepos);
17763 $plalign = $lalign;
17764 if (isset($this->PageAnnots[$this->page])) {
17765 $pask = count($this->PageAnnots[$this->page]);
17769 if (!($dom[$key][
'tag'] AND !$dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'table')
17770 AND (isset($this->emptypagemrk[$this->page]))
17771 AND ($this->emptypagemrk[$this->page] == $this->pagelen[$this->page]))) {
17772 $this->
SetFont($fontname, $fontstyle, $fontsize);
17778 if (isset($opentagpos)) {
17779 unset($opentagpos);
17781 if ($dom[$key][
'tag']) {
17782 if ($dom[$key][
'opening']) {
17784 if (isset($dom[$key][
'text-indent']) AND $dom[$key][
'block']) {
17785 $this->textindent = $dom[$key][
'text-indent'];
17786 $this->newline =
true;
17789 if ($dom[$key][
'value'] ==
'table') {
17794 $wtmp = $this->w - $this->rMargin -
$this->x;
17797 if (isset($dom[$key][
'attribute'][
'cellspacing'])) {
17799 $cellspacing = array(
'H' => $clsp,
'V' => $clsp);
17800 } elseif (isset($dom[$key][
'border-spacing'])) {
17801 $cellspacing = $dom[$key][
'border-spacing'];
17803 $cellspacing = array(
'H' => 0,
'V' => 0);
17806 if (isset($dom[$key][
'width'])) {
17809 $table_width = $wtmp;
17811 $table_width -= (2 * $cellspacing[
'H']);
17812 if (!$this->inthead) {
17813 $this->y += $cellspacing[
'V'];
17816 $cellspacingx = -$cellspacing[
'H'];
17818 $cellspacingx = $cellspacing[
'H'];
17821 $table_columns_width = ($table_width - ($cellspacing[
'H'] * ($dom[$key][
'cols'] - 1)));
17825 if ($table_columns_width == 0 || $dom[$key][
'cols'] == 0)
17827 $table_min_column_width = 1;
17831 $table_min_column_width = ($table_columns_width / $dom[$key][
'cols']);
17833 if ($dom[$key][
'cols'] != 0)
17836 $table_colwidths = array_fill(0, $dom[$key][
'cols'], $table_min_column_width);
17842 if ($dom[$key][
'value'] ==
'tr') {
17847 if (($dom[$key][
'value'] ==
'td') OR ($dom[$key][
'value'] ==
'th')) {
17848 $trid = $dom[$key][
'parent'];
17849 $table_el = $dom[$trid][
'parent'];
17850 if (!isset($dom[$table_el][
'cols'])) {
17851 $dom[$table_el][
'cols'] = $dom[$trid][
'cols'];
17855 if (isset($dom[$key][
'border']) AND !empty($dom[$key][
'border'])) {
17856 $tdborder = $dom[$key][
'border'];
17858 $colspan = $dom[$key][
'attribute'][
'colspan'];
17860 if (isset($dom[($dom[$trid][
'parent'])][
'attribute'][
'cellpadding'])) {
17861 $crclpd = $this->
getHTMLUnitToUnits($dom[($dom[$trid][
'parent'])][
'attribute'][
'cellpadding'], 1,
'px');
17862 $current_cell_padding = array(
'L' => $crclpd,
'T' => $crclpd,
'R' => $crclpd,
'B' => $crclpd);
17863 } elseif (isset($dom[($dom[$trid][
'parent'])][
'padding'])) {
17864 $current_cell_padding = $dom[($dom[$trid][
'parent'])][
'padding'];
17866 $current_cell_padding = array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0);
17868 $this->cell_padding = $current_cell_padding;
17869 if (isset($dom[$key][
'height'])) {
17875 if (isset($dom[$key][
'content'])) {
17876 $cell_content = stripslashes($dom[$key][
'content']);
17878 $cell_content =
' ';
17880 $tagtype = $dom[$key][
'value'];
17882 while (($key < $maxel) AND (!(($dom[$key][
'tag']) AND (!$dom[$key][
'opening']) AND ($dom[$key][
'value'] == $tagtype) AND ($dom[$key][
'parent'] == $parentid)))) {
17886 if (!isset($dom[$trid][
'startpage'])) {
17889 $this->
setPage($dom[$trid][
'startpage']);
17891 if (!isset($dom[$trid][
'startcolumn'])) {
17893 } elseif ($this->current_column != $dom[$trid][
'startcolumn']) {
17898 if (!isset($dom[$trid][
'starty'])) {
17901 $this->y = $dom[$trid][
'starty'];
17903 if (!isset($dom[$trid][
'startx'])) {
17905 $this->x += $cellspacingx;
17907 $this->x += ($cellspacingx / 2);
17909 if (isset($dom[$parentid][
'attribute'][
'rowspan'])) {
17910 $rowspan = intval($dom[$parentid][
'attribute'][
'rowspan']);
17915 if (isset($dom[$table_el][
'rowspans'])) {
17917 $rskmax = count($dom[$table_el][
'rowspans']);
17918 while ($rsk < $rskmax) {
17919 $trwsp = $dom[$table_el][
'rowspans'][$rsk];
17920 $rsstartx = $trwsp[
'startx'];
17921 $rsendx = $trwsp[
'endx'];
17923 if ($trwsp[
'startpage'] < $this->page) {
17924 if (($this->rtl) AND ($this->pagedim[$this->page][
'orm'] != $this->pagedim[$trwsp[
'startpage']][
'orm'])) {
17925 $dl = ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$trwsp[
'startpage']][
'orm']);
17928 } elseif ((!$this->rtl) AND ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$trwsp[
'startpage']][
'olm'])) {
17929 $dl = ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$trwsp[
'startpage']][
'olm']);
17934 if (($trwsp[
'rowspan'] > 0)
17935 AND ($rsstartx > ($this->x - $cellspacing[
'H'] - $current_cell_padding[
'L'] - $this->feps))
17936 AND ($rsstartx < ($this->x + $cellspacing[
'H'] + $current_cell_padding[
'R'] + $this->feps))
17937 AND (($trwsp[
'starty'] < ($this->y - $this->feps)) OR ($trwsp[
'startpage'] < $this->page) OR ($trwsp[
'startcolumn'] < $this->current_column))) {
17939 $this->x = $rsendx + $cellspacingx;
17941 $colid += $trwsp[
'colspan'];
17942 if (($trwsp[
'rowspan'] == 1)
17943 AND (isset($dom[$trid][
'endy']))
17944 AND (isset($dom[$trid][
'endpage']))
17945 AND (isset($dom[$trid][
'endcolumn']))
17946 AND ($trwsp[
'endpage'] == $dom[$trid][
'endpage'])
17947 AND ($trwsp[
'endcolumn'] == $dom[$trid][
'endcolumn'])) {
17949 $dom[$table_el][
'rowspans'][$rsk][
'endy'] = max($dom[$trid][
'endy'], $trwsp[
'endy']);
17950 $dom[$trid][
'endy'] = $dom[$table_el][
'rowspans'][$rsk][
'endy'];
17958 if (isset($dom[$parentid][
'width'])) {
17960 $cellw = $this->
getHTMLUnitToUnits($dom[$parentid][
'width'], $table_columns_width,
'px');
17961 $tmpcw = ($cellw / $colspan);
17962 for ($i = 0; $i < $colspan; ++$i) {
17963 $table_colwidths[($colid + $i)] = $tmpcw;
17968 for ($i = 0; $i < $colspan; ++$i) {
17969 $cellw += $table_colwidths[($colid + $i)];
17972 $cellw += (($colspan - 1) * $cellspacing[
'H']);
17974 $colid += $colspan;
17976 if ($rowspan > 1) {
17977 $trsid = array_push($dom[$table_el][
'rowspans'], array(
'trid' => $trid,
'rowspan' => $rowspan,
'mrowspan' => $rowspan,
'colspan' => $colspan,
'startpage' => $this->page,
'startcolumn' => $this->current_column,
'startx' => $this->x,
'starty' => $this->y));
17979 $cellid = array_push($dom[$trid][
'cellpos'], array(
'startx' => $this->x));
17980 if ($rowspan > 1) {
17981 $dom[$trid][
'cellpos'][($cellid - 1)][
'rowspanid'] = ($trsid - 1);
17984 if (isset($dom[$parentid][
'bgcolor']) AND ($dom[$parentid][
'bgcolor'] !==
false)) {
17985 $dom[$trid][
'cellpos'][($cellid - 1)][
'bgcolor'] = $dom[$parentid][
'bgcolor'];
17988 if (isset($tdborder) AND !empty($tdborder)) {
17989 $dom[$trid][
'cellpos'][($cellid - 1)][
'border'] = $tdborder;
17998 $this->colxshift[
's'] = $cellspacing;
17999 $this->colxshift[
'p'] = $current_cell_padding;
18001 $this->
MultiCell($cellw, $cellh, $cell_content,
false, $lalign,
false, 2,
'',
'',
true, 0,
true,
true, 0,
'T',
false);
18003 $this->colxshift = array(
'x' => 0,
's' => array(
'H' => 0,
'V' => 0),
'p' => array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0));
18004 $this->lasth = $prevLastH;
18005 $this->cell_padding = $old_cell_padding;
18006 $dom[$trid][
'cellpos'][($cellid - 1)][
'endx'] = $this->x;
18008 if ($rowspan <= 1) {
18009 if (isset($dom[$trid][
'endy'])) {
18010 if (($this->page == $dom[$trid][
'endpage']) AND ($this->current_column == $dom[$trid][
'endcolumn'])) {
18011 $dom[$trid][
'endy'] = max($this->y, $dom[$trid][
'endy']);
18012 } elseif (($this->page > $dom[$trid][
'endpage']) OR ($this->current_column > $dom[$trid][
'endcolumn'])) {
18018 if (isset($dom[$trid][
'endpage'])) {
18019 $dom[$trid][
'endpage'] = max($this->page, $dom[$trid][
'endpage']);
18023 if (isset($dom[$trid][
'endcolumn'])) {
18024 $dom[$trid][
'endcolumn'] = max($this->current_column, $dom[$trid][
'endcolumn']);
18030 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endx'] = $this->x;
18031 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endy'] = $this->y;
18032 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endpage'] = $this->page;
18033 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endcolumn'] = $this->current_column;
18035 if (isset($dom[$table_el][
'rowspans'])) {
18037 foreach ($dom[$table_el][
'rowspans'] as
$k => $trwsp) {
18038 if ($trwsp[
'rowspan'] > 0) {
18039 if (isset($dom[$trid][
'endpage'])) {
18040 if (($trwsp[
'endpage'] == $dom[$trid][
'endpage']) AND ($trwsp[
'endcolumn'] == $dom[$trid][
'endcolumn'])) {
18041 $dom[$table_el][
'rowspans'][
$k][
'endy'] = max($dom[$trid][
'endy'], $trwsp[
'endy']);
18042 } elseif (($trwsp[
'endpage'] < $dom[$trid][
'endpage']) OR ($trwsp[
'endcolumn'] < $dom[$trid][
'endcolumn'])) {
18043 $dom[$table_el][
'rowspans'][
$k][
'endy'] = $dom[$trid][
'endy'];
18044 $dom[$table_el][
'rowspans'][
$k][
'endpage'] = $dom[$trid][
'endpage'];
18045 $dom[$table_el][
'rowspans'][
$k][
'endcolumn'] = $dom[$trid][
'endcolumn'];
18047 $dom[$trid][
'endy'] = $this->pagedim[$dom[$trid][
'endpage']][
'hk'] - $this->pagedim[$dom[$trid][
'endpage']][
'bm'];
18053 $this->x += ($cellspacingx / 2);
18056 if (!isset($opentagpos)) {
18057 if ($this->inxobj) {
18059 $opentagpos = strlen($this->xobjects[$this->xobjid][
'outdata']);
18060 } elseif (!$this->InFooter) {
18061 if (isset($this->footerlen[$this->page])) {
18075 if ($this->bordermrk[$this->page] > $old_bordermrk) {
18076 $startlinepos += ($this->bordermrk[
$this->page] - $old_bordermrk);
18078 if ($prev_numpages > $this->numpages) {
18082 } elseif (strlen($dom[$key][
'value']) > 0) {
18085 $this->
SetFont($pfontname, $pfontstyle, $pfontsize);
18090 $this->
SetFont($curfontname, $curfontstyle, $curfontsize);
18092 if (is_numeric($pfontsize) AND ($pfontsize > 0) AND is_numeric($curfontsize) AND ($curfontsize > 0) AND ($pfontsize != $curfontsize)) {
18093 $pfontascent = $this->
getFontAscent($pfontname, $pfontstyle, $pfontsize);
18094 $pfontdescent = $this->
getFontDescent($pfontname, $pfontstyle, $pfontsize);
18095 $this->y += ((($pfontsize - $curfontsize) * $this->cell_height_ratio / $this->k) + $pfontascent - $curfontascent - $pfontdescent + $curfontdescent) / 2;
18096 $minstartliney = min($this->y, $minstartliney);
18097 $maxbottomliney = max(($this->y + (($pfontsize * $this->cell_height_ratio) / $this->k)), $maxbottomliney);
18101 $this->htmlvspace = 0;
18106 if (preg_match(
'/^('.$this->re_space[
'p'].
'+)/'.$this->re_space[
'm'], $dom[$key][
'value'], $matches)) {
18107 $lsp = $matches[1];
18109 if (preg_match(
'/('.$this->re_space[
'p'].
'+)$/'.$this->re_space[
'm'], $dom[$key][
'value'], $matches)) {
18110 $rsp = $matches[1];
18112 $dom[$key][
'value'] = $rsp.$this->stringTrim($dom[$key][
'value']).$lsp;
18115 if (!$this->premode) {
18116 $prelen = strlen($dom[$key][
'value']);
18122 $dom[$key][
'value'] = $this->
stringLeftTrim($dom[$key][
'value']);
18124 $postlen = strlen($dom[$key][
'value']);
18125 if (($postlen == 0) AND ($prelen > 0)) {
18126 $dom[$key][
'trimmed_space'] =
true;
18130 $firstblock =
true;
18132 $firstblock =
false;
18134 $dom[$key][
'value'] = preg_replace(
'/^'.$this->re_space[
'p'].
'+$/'.$this->re_space[
'm'], chr(32), $dom[$key][
'value']);
18142 if (!isset($dom[$key][
'trimmed_space']) OR !$dom[$key][
'trimmed_space']) {
18144 if (!empty($this->HREF) AND (isset($this->HREF[
'url']))) {
18147 if (isset($dom[($dom[$key][
'parent'])][
'fgcolor']) AND ($dom[($dom[$key][
'parent'])][
'fgcolor'] !==
false)) {
18148 $hrefcolor = $dom[($dom[$key][
'parent'])][
'fgcolor'];
18151 if (isset($dom[($dom[$key][
'parent'])][
'fontstyle']) AND ($dom[($dom[$key][
'parent'])][
'fontstyle'] !==
false)) {
18152 $hrefstyle = $dom[($dom[$key][
'parent'])][
'fontstyle'];
18154 $strrest = $this->
addHtmlLink($this->HREF[
'url'], $dom[$key][
'value'], $wfill,
true, $hrefcolor, $hrefstyle,
true);
18160 $cwa = ($this->w - $this->rMargin -
$this->x);
18162 if (($strlinelen < $cwa) AND (isset($dom[($key + 1)])) AND ($dom[($key + 1)][
'tag']) AND (!$dom[($key + 1)][
'block'])) {
18164 $nkey = ($key + 1);
18165 $write_block =
true;
18166 $same_textdir =
true;
18170 while ($write_block AND isset($dom[$nkey])) {
18171 if ($dom[$nkey][
'tag']) {
18172 if ($dom[$nkey][
'block']) {
18174 $write_block =
false;
18176 $tmp_fontname = isset($dom[$nkey][
'fontname']) ? $dom[$nkey][
'fontname'] :
$this->FontFamily;
18177 $tmp_fontstyle = isset($dom[$nkey][
'fontstyle']) ? $dom[$nkey][
'fontstyle'] :
$this->FontStyle;
18178 $tmp_fontsize = isset($dom[$nkey][
'fontsize']) ? $dom[$nkey][
'fontsize'] :
$this->FontSizePt;
18179 $same_textdir = ($dom[$nkey][
'dir'] == $dom[$key][
'dir']);
18181 $nextstr = preg_split(
'/'.$this->re_space[
'p'].
'+/'.$this->re_space[
'm'], $dom[$nkey][
'value']);
18182 if (isset($nextstr[0]) AND $same_textdir) {
18183 $wadj += $this->
GetStringWidth($nextstr[0], $tmp_fontname, $tmp_fontstyle, $tmp_fontsize);
18184 if (isset($nextstr[1])) {
18185 $write_block =
false;
18192 if (($wadj > 0) AND (($strlinelen + $wadj) >= $cwa)) {
18194 $nextstr = preg_split(
'/'.$this->re_space[
'p'].
'/'.$this->re_space[
'm'], $dom[$key][
'value']);
18195 $numblks = count($nextstr);
18196 if ($numblks > 1) {
18198 $wadj = ($cwa - $strlinelen + $this->
GetStringWidth($nextstr[($numblks - 1)]));
18205 if (($wadj > 0) AND (($this->rtl AND ($this->tmprtl ===
'L')) OR (!$this->rtl AND ($this->tmprtl ===
'R')))) {
18207 $reverse_dir =
true;
18209 $revshift = ($strlinelen + $wadj + 0.000001);
18211 $this->x += $revshift;
18213 $this->x -= $revshift;
18218 $strrest = $this->
Write($this->lasth, $dom[$key][
'value'],
'', $wfill,
'',
false, 0,
true, $firstblock, 0, $wadj);
18220 if ($reverse_dir AND ($wadj == 0)) {
18223 $reverse_dir =
false;
18227 $this->textindent = 0;
18228 if (strlen($strrest) > 0) {
18230 $this->newline =
true;
18231 if ($strrest == $dom[$key][
'value']) {
18237 $dom[$key][
'value'] = $strrest;
18240 $this->x -= $this->cell_padding[
'R'];
18242 $this->x += $this->cell_padding[
'L'];
18251 if ($this->font_spacing > 0) {
18261 if (isset($dom[$key][
'tag']) AND $dom[$key][
'tag'] AND (!isset($dom[$key][
'opening']) OR !$dom[$key][
'opening']) AND isset($dom[($dom[$key][
'parent'])][
'attribute'][
'nobr']) AND ($dom[($dom[$key][
'parent'])][
'attribute'][
'nobr'] ==
'true')) {
18263 if ((!$undo) AND (($this->y < $this->start_transaction_y) OR (($dom[$key][
'value'] ==
'tr') AND ($dom[($dom[$key][
'parent'])][
'endy'] < $this->start_transaction_y)))) {
18268 foreach ($this_method_vars as $vkey => $vval) {
18273 if ((!$this->
checkPageBreak($this->PageBreakTrigger + 1)) AND ($this->y < $pre_y)) {
18283 if (isset($startlinex)) {
18284 $yshift = ($minstartliney - $startliney);
18285 if (($yshift > 0) OR ($this->page > $startlinepage)) {
18290 $linew = abs($this->endlinex - $startlinex);
18291 if ($this->inxobj) {
18293 $pstart = substr($this->xobjects[$this->xobjid][
'outdata'], 0, $startlinepos);
18294 if (isset($opentagpos)) {
18295 $midpos = $opentagpos;
18300 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos, ($midpos - $startlinepos));
18301 $pend = substr($this->xobjects[$this->xobjid][
'outdata'], $midpos);
18303 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos);
18307 $pstart = substr($this->
getPageBuffer($startlinepage), 0, $startlinepos);
18308 if (isset($opentagpos) AND isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
18309 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
18310 $midpos = min($opentagpos, $this->footerpos[$startlinepage]);
18311 } elseif (isset($opentagpos)) {
18312 $midpos = $opentagpos;
18313 } elseif (isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
18314 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
18315 $midpos = $this->footerpos[$startlinepage];
18320 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos, ($midpos - $startlinepos));
18321 $pend = substr($this->
getPageBuffer($startlinepage), $midpos);
18323 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos);
18327 if ((isset($plalign) AND ((($plalign ==
'C') OR (($plalign ==
'R') AND (!$this->rtl)) OR (($plalign ==
'L') AND ($this->rtl)))))) {
18330 if ($this->lMargin != $prevlMargin) {
18333 if ($this->rMargin != $prevrMargin) {
18342 $pos1 = intval($pos1);
18350 if ($pos1 == $pos2) {
18351 $pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
18352 if (substr($pmid, $pos1, 4) ==
'[()]') {
18353 $linew -= $one_space_width;
18354 } elseif ($pos1 == strpos($pmid,
'[(')) {
18363 $pos1 = intval($pos1);
18371 if ($pos1 == $pos2) {
18372 $pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
18373 $linew -= $one_space_width;
18377 $mdiff = ($tw - $linew);
18378 if ($plalign ==
'C') {
18380 $t_x = -($mdiff / 2);
18382 $t_x = ($mdiff / 2);
18384 } elseif ($plalign ==
'R') {
18387 } elseif ($plalign ==
'L') {
18392 if (($t_x != 0) OR ($yshift < 0)) {
18394 $trx = sprintf(
'1 0 0 1 %F %F cm', ($t_x * $this->k), ($yshift * $this->k));
18395 $pstart .=
"\nq\n".$trx.
"\n".$pmid.
"\nQ\n";
18396 $endlinepos = strlen($pstart);
18397 if ($this->inxobj) {
18400 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
18401 if ($pak >= $pask) {
18402 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'x'] += $t_x;
18403 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'y'] -= $yshift;
18409 if (isset($this->PageAnnots[$this->page])) {
18410 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
18411 if ($pak >= $pask) {
18412 $this->PageAnnots[
$this->page][$pak][
'x'] += $t_x;
18413 $this->PageAnnots[
$this->page][$pak][
'y'] -= $yshift;
18418 $this->y -= $yshift;
18424 if ($this->num_columns > 1) {
18426 } elseif ($this->page > $prevPage) {
18427 $this->lMargin = $this->pagedim[
$this->page][
'olm'];
18428 $this->rMargin = $this->pagedim[
$this->page][
'orm'];
18431 $this->cell_height_ratio = $prev_cell_height_ratio;
18432 $this->listnum = $prev_listnum;
18433 $this->listordered = $prev_listordered;
18434 $this->listcount = $prev_listcount;
18435 $this->lispacer = $prev_lispacer;
18436 if ($ln AND (!($cell AND ($dom[$key-1][
'value'] ==
'table')))) {
18437 $this->
Ln($this->lasth);
18438 if ($this->y < $maxbottomliney) {
18439 $this->y = $maxbottomliney;
18455 $parent = $dom[($dom[$key][
'parent'])];
18456 $firsttag = ($key == 1);
18458 if (isset($tag[
'dir'])) {
18461 $this->tmprtl =
false;
18463 if ($tag[
'block']) {
18467 if (isset($this->tagvspaces[$tag[
'value']][0][
'h']) AND ($this->tagvspaces[$tag[
'value']][0][
'h'] >= 0)) {
18468 $cur_h = $this->tagvspaces[$tag[
'value']][0][
'h'];
18469 } elseif (isset($tag[
'fontsize'])) {
18470 $cur_h = ($tag[
'fontsize'] /
$this->k) * $this->cell_height_ratio;
18474 if (isset($this->tagvspaces[$tag[
'value']][0][
'n'])) {
18475 $n = $this->tagvspaces[$tag[
'value']][0][
'n'];
18476 } elseif (preg_match(
'/[h][0-9]/', $tag[
'value']) > 0) {
18481 if ((!isset($this->tagvspaces[$tag[
'value']])) AND (in_array($tag[
'value'], array(
'div',
'dt',
'dd',
'li',
'br')))) {
18484 $hb = (
$n * $cur_h);
18486 if (($this->htmlvspace <= 0) AND (
$n > 0)) {
18487 if (isset($parent[
'fontsize'])) {
18488 $hbz = (($parent[
'fontsize'] /
$this->k) * $this->cell_height_ratio);
18493 if (isset($dom[($key - 1)]) AND ($dom[($key - 1)][
'value'] ==
'table')) {
18499 switch($tag[
'value']) {
18503 $dom[$key][
'rowspans'] = array();
18504 if (!isset($dom[$key][
'attribute'][
'nested']) OR ($dom[$key][
'attribute'][
'nested'] !=
'true')) {
18505 $this->htmlvspace = 0;
18509 $this->thead = $dom[$key][
'thead'];
18510 if (!isset($this->theadMargins) OR (empty($this->theadMargins))) {
18511 $this->theadMargins = array();
18516 $this->theadMargins[
'cell'] = $cell;
18522 if (isset($tag[
'attribute'][
'cellpadding'])) {
18525 } elseif (isset($tag[
'padding'])) {
18526 $this->cell_padding = $tag[
'padding'];
18528 if (isset($tag[
'attribute'][
'cellspacing'])) {
18530 } elseif (isset($tag[
'border-spacing'])) {
18531 $cs = $tag[
'border-spacing'][
'V'];
18534 if ($this->
checkPageBreak(((2 * $cp) + (2 * $cs) + $this->lasth),
'',
false) OR ($this->y < $prev_y)) {
18535 $this->inthead =
true;
18543 $dom[$key][
'cellpos'] = array();
18547 if ((isset($tag[
'height'])) AND ($tag[
'height'] !=
'')) {
18557 $wtmp -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
18559 if ((isset($tag[
'width'])) AND ($tag[
'width'] !=
'')) {
18568 $this->
addHTMLVertSpace(($hrHeight / 2), 0, $cell, !isset($dom[($key + 1)]));
18572 if (array_key_exists(
'href', $tag[
'attribute'])) {
18573 $this->HREF[
'url'] = $tag[
'attribute'][
'href'];
18578 if (isset($tag[
'attribute'][
'src'])) {
18579 if ($tag[
'attribute'][
'src']{0} ===
'@') {
18581 $tag[
'attribute'][
'src'] =
'@'.base64_decode(substr($tag[
'attribute'][
'src'], 1));
18585 if (preg_match(
'%^/{2}%', $tag[
'attribute'][
'src'])) {
18586 $tag[
'attribute'][
'src'] =
'http:'.$tag[
'attribute'][
'src'];
18589 if (($tag[
'attribute'][
'src'][0] ==
'/') AND !empty($_SERVER[
'DOCUMENT_ROOT']) AND ($_SERVER[
'DOCUMENT_ROOT'] !=
'/')) {
18590 $findroot = strpos($tag[
'attribute'][
'src'], $_SERVER[
'DOCUMENT_ROOT']);
18591 if (($findroot ===
false) OR ($findroot > 1)) {
18592 if (substr($_SERVER[
'DOCUMENT_ROOT'], -1) ==
'/') {
18593 $tag[
'attribute'][
'src'] = substr($_SERVER[
'DOCUMENT_ROOT'], 0, -1).$tag[
'attribute'][
'src'];
18595 $tag[
'attribute'][
'src'] = $_SERVER[
'DOCUMENT_ROOT'].$tag[
'attribute'][
'src'];
18599 $tag[
'attribute'][
'src'] = htmlspecialchars_decode(urldecode($tag[
'attribute'][
'src']));
18601 $testscrtype = @parse_url($tag[
'attribute'][
'src']);
18602 if (!isset($testscrtype[
'query']) OR empty($testscrtype[
'query'])) {
18604 $tag[
'attribute'][
'src'] = str_replace(K_PATH_URL, K_PATH_MAIN, $tag[
'attribute'][
'src']);
18607 if (!isset($tag[
'width'])) {
18610 if (!isset($tag[
'height'])) {
18611 $tag[
'height'] = 0;
18616 $tag[
'attribute'][
'align'] =
'bottom';
18618 switch($tag[
'attribute'][
'align']) {
18640 $imglink = $this->HREF[
'url'];
18641 if ($imglink{0} ==
'#') {
18643 $lnkdata = explode(
',', $imglink);
18644 if (isset($lnkdata[0])) {
18645 $page = intval(substr($lnkdata[0], 1));
18649 if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
18650 $lnky = floatval($lnkdata[1]);
18660 if (isset($tag[
'border']) AND !empty($tag[
'border'])) {
18662 $border = $tag[
'border'];
18665 if (isset($tag[
'width'])) {
18669 if (isset($tag[
'height'])) {
18672 if (($type ==
'eps') OR ($type ==
'ai')) {
18673 $this->
ImageEps($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih, $imglink,
true, $align,
'', $border,
true);
18674 } elseif ($type ==
'svg') {
18675 $this->
ImageSVG($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih, $imglink, $align,
'', $border,
true);
18677 $this->
Image($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih,
'', $imglink, $align,
false, 300,
'',
false,
false, $border,
false,
false,
true);
18685 $this->y = (($this->img_rb_y + $prevy - ($tag[
'fontsize'] /
$this->k)) / 2) ;
18689 $this->y = $this->img_rb_y - ($tag[
'fontsize'] /
$this->k);
18698 if ($this->listnum == 1) {
18722 if ($tag[
'value'] ==
'ol') {
18727 if (isset($tag[
'attribute'][
'start'])) {
18728 $this->listcount[
$this->listnum] = intval($tag[
'attribute'][
'start']) - 1;
18740 if ($this->listnum == 1) {
18753 if ($this->listordered[$this->listnum]) {
18756 $this->lispacer = $parent[
'attribute'][
'type'];
18758 $this->lispacer = $parent[
'listtype'];
18762 $this->lispacer =
'#';
18765 if (isset($tag[
'attribute'][
'value'])) {
18766 $this->listcount[
$this->listnum] = intval($tag[
'attribute'][
'value']);
18771 $this->lispacer = $parent[
'attribute'][
'type'];
18773 $this->lispacer = $parent[
'listtype'];
18777 $this->lispacer =
'!';
18782 case 'blockquote': {
18806 $this->premode =
true;
18810 $this->
SetXY($this->
GetX(), $this->
GetY() - ((0.7 * $this->FontSizePt) / $this->k));
18814 $this->
SetXY($this->
GetX(), $this->
GetY() + ((0.3 * $this->FontSizePt) / $this->k));
18828 if (isset($tag[
'attribute'][
'action'])) {
18829 $this->form_action = $tag[
'attribute'][
'action'];
18831 $this->
Error(
'Please explicitly set action attribute path!');
18833 if (isset($tag[
'attribute'][
'enctype'])) {
18834 $this->form_enctype = $tag[
'attribute'][
'enctype'];
18836 $this->form_enctype =
'application/x-www-form-urlencoded';
18838 if (isset($tag[
'attribute'][
'method'])) {
18839 $this->form_mode = $tag[
'attribute'][
'method'];
18841 $this->form_mode =
'post';
18847 $name = $tag[
'attribute'][
'name'];
18854 $prop[
'readonly'] =
true;
18857 $value = $tag[
'attribute'][
'value'];
18860 $opt[
'maxlen'] = intval($tag[
'attribute'][
'maxlength']);
18864 $w = intval($tag[
'attribute'][
'size']) * $this->
GetStringWidth(chr(32)) * 2;
18868 if (isset($tag[
'attribute'][
'checked']) AND (($tag[
'attribute'][
'checked'] ==
'checked') OR ($tag[
'attribute'][
'checked'] ==
'true'))) {
18873 if (isset($tag[
'align'])) {
18874 switch ($tag[
'align']) {
18889 switch ($tag[
'attribute'][
'type']) {
18891 if (isset($value)) {
18892 $opt[
'v'] = $value;
18894 $this->
TextField($name,
$w,
$h, $prop, $opt,
'',
'',
false);
18898 if (isset($value)) {
18899 $opt[
'v'] = $value;
18901 $prop[
'password'] =
'true';
18902 $this->
TextField($name,
$w,
$h, $prop, $opt,
'',
'',
false);
18906 if (!isset($value)) {
18909 $this->
CheckBox($name,
$w, $checked, $prop, $opt, $value,
'',
'',
false);
18913 if (!isset($value)) {
18916 $this->
RadioButton($name,
$w, $prop, $opt, $value, $checked,
'',
'',
false);
18920 if (!isset($value)) {
18925 $prop = array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>array(196, 196, 196),
'strokeColor'=>array(255, 255, 255));
18927 $action[
'S'] =
'SubmitForm';
18929 if ($this->form_enctype !=
'FDF') {
18930 $action[
'Flags'] = array(
'ExportFormat');
18932 if ($this->form_mode ==
'get') {
18933 $action[
'Flags'] = array(
'GetMethod');
18935 $this->
Button($name,
$w,
$h, $value, $action, $prop, $opt,
'',
'',
false);
18939 if (!isset($value)) {
18944 $prop = array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>array(196, 196, 196),
'strokeColor'=>array(255, 255, 255));
18945 $this->
Button($name,
$w,
$h, $value, array(
'S'=>
'ResetForm'), $prop, $opt,
'',
'',
false);
18949 $prop[
'fileSelect'] =
'true';
18950 $this->
TextField($name,
$w,
$h, $prop, $opt,
'',
'',
false);
18951 if (!isset($value)) {
18956 $prop = array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>array(196, 196, 196),
'strokeColor'=>array(255, 255, 255));
18957 $jsaction =
'var f=this.getField(\''.$name.
'\'); f.browseForFileToSubmit();
';
18958 $this->Button('FB_
'.$name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false);
18962 if (isset($value)) {
18963 $opt['v'] = $value;
18965 $opt['f
'] = array('invisible
', 'hidden
');
18966 $this->TextField($name, 0, 0, $prop, $opt, '', '', false);
18970 // THIS TYPE MUST BE FIXED
18971 if (isset($tag['attribute
']['src
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['src
'])) {
18972 $img = $tag['attribute
']['src
'];
18977 //$opt['mk
'] = array('i
'=>$img, 'tp
'=>1, 'if'=>array('sw
'=>'A
', 's
'=>'A
', 'fb
'=>false));
18978 if (isset($tag['attribute
']['onclick
']) AND !empty($tag['attribute
']['onclick
'])) {
18979 $jsaction = $tag['attribute
']['onclick
'];
18983 $this->Button($name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false);
18987 if (!isset($value)) {
18990 $w = $this->GetStringWidth($value) * 1.5;
18992 $prop = array('lineWidth
'=>1, 'borderStyle
'=>'beveled
', 'fillColor
'=>array(196, 196, 196), 'strokeColor
'=>array(255, 255, 255));
18993 if (isset($tag['attribute
']['onclick
']) AND !empty($tag['attribute
']['onclick
'])) {
18994 $jsaction = $tag['attribute
']['onclick
'];
18998 $this->Button($name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false);
19007 if (isset($tag['attribute
']['readonly
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['readonly
'])) {
19008 $prop['readonly
'] = true;
19010 if (isset($tag['attribute
']['name
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['name
'])) {
19011 $name = $tag['attribute
']['name
'];
19015 if (isset($tag['attribute
']['value
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['value
'])) {
19016 $opt['v'] = $tag['attribute
']['value
'];
19018 if (isset($tag['attribute
']['cols
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['cols
'])) {
19019 $w = intval($tag['attribute
']['cols
']) * $this->GetStringWidth(chr(32)) * 2;
19023 if (isset($tag['attribute
']['rows
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['rows
'])) {
19024 $h = intval($tag['attribute
']['rows
']) * $this->FontSize * $this->cell_height_ratio;
19028 $prop['multiline
'] = 'true';
19029 $this->TextField($name, $w, $h, $prop, $opt, '', '', false);
19033 $h = $this->FontSize * $this->cell_height_ratio;
19034 if (isset($tag['attribute
']['size
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['size
'])) {
19035 $h *= ($tag['attribute
']['size
'] + 1);
19039 if (isset($tag['attribute
']['name
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['name
'])) {
19040 $name = $tag['attribute
']['name
'];
19045 if (isset($tag['attribute
']['opt
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['opt
'])) {
19046 $options = explode('#!NwL!#
', $tag['attribute
']['opt
']);
19048 foreach ($options as $val) {
19049 if (strpos($val, '#!TaB!#
') !== false) {
19050 $opts = explode('#!TaB!#
', $val);
19052 $w = max($w, $this->GetStringWidth($opts[1]));
19055 $w = max($w, $this->GetStringWidth($val));
19062 if (isset($tag['attribute
']['multiple
']) AND ($tag['attribute
']['multiple
']='multiple
')) {
19063 $prop['multipleSelection
'] = 'true';
19064 $this->ListBox($name, $w, $h, $values, $prop, $opt, '', '', false);
19066 $this->ComboBox($name, $w, $h, $values, $prop, $opt, '', '', false);
19071 if (defined('K_TCPDF_CALLS_IN_HTML
') AND (K_TCPDF_CALLS_IN_HTML === true)) {
19072 // Special tag used to call TCPDF methods
19073 if (isset($tag['attribute
']['method
'])) {
19074 $tcpdf_method = $tag['attribute
']['method
'];
19075 if (method_exists($this, $tcpdf_method)) {
19076 if (isset($tag['attribute
']['params
']) AND (!empty($tag['attribute
']['params
']))) {
19077 $params = unserialize(urldecode($tag['attribute
']['params
']));
19078 call_user_func_array(array($this, $tcpdf_method), $params);
19080 $this->$tcpdf_method();
19082 $this->newline = true;
19092 // define tags that support borders and background colors
19093 $bordertags = array('blockquote
','br
','dd
','dl
','div
','dt
','h1
','h2
','h3
','h4
','h5
','h6
','hr
','li
','ol
','p
','pre
','ul
','tcpdf
','table
');
19094 if (in_array($tag['value
'], $bordertags)) {
19096 $dom[$key]['borderposition
'] = $this->getBorderStartPosition();
19098 if ($dom[$key]['self'] AND isset($dom[$key]['attribute
']['pagebreakafter
'])) {
19099 $pba = $dom[$key]['attribute
']['pagebreakafter
'];
19100 // check for pagebreak
19101 if (($pba == 'true') OR ($pba == 'left
') OR ($pba == 'right
')) {
19102 // add a page (or trig AcceptPageBreak() for multicolumn mode)
19103 $this->checkPageBreak($this->PageBreakTrigger + 1);
19105 if ((($pba == 'left
') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
19106 OR (($pba == 'right
') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
19107 // add a page (or trig AcceptPageBreak() for multicolumn mode)
19108 $this->checkPageBreak($this->PageBreakTrigger + 1);
19123 protected function closeHTMLTagHandler($dom, $key, $cell, $maxbottomliney=0) {
19125 $parent = $dom[($dom[$key]['parent
'])];
19126 $lasttag = ((!isset($dom[($key + 1)])) OR ((!isset($dom[($key + 2)])) AND ($dom[($key + 1)]['value
'] == 'marker
')));
19127 $in_table_head = false;
19128 // maximum x position (used to draw borders)
19134 if ($tag['block
']) {
19135 $hbz = 0; // distance from y to line bottom
19136 $hb = 0; // vertical space between block tags
19137 // calculate vertical space for block tags
19138 if (isset($this->tagvspaces[$tag['value
']][1]['h
']) AND ($this->tagvspaces[$tag['value
']][1]['h
'] >= 0)) {
19139 $pre_h = $this->tagvspaces[$tag['value
']][1]['h
'];
19140 } elseif (isset($parent['fontsize
'])) {
19141 $pre_h = (($parent['fontsize
'] / $this->k) * $this->cell_height_ratio);
19143 $pre_h = $this->FontSize * $this->cell_height_ratio;
19145 if (isset($this->tagvspaces[$tag['value
']][1]['n'])) {
19146 $n = $this->tagvspaces[$tag['value
']][1]['n'];
19147 } elseif (preg_match('/[h][0-9]/
', $tag['value
']) > 0) {
19152 if ((!isset($this->tagvspaces[$tag['value
']])) AND ($tag['value
'] == 'div
')) {
19155 $hb = ($n * $pre_h);
19157 if ($maxbottomliney > $this->PageBreakTrigger) {
19158 $hbz = ($this->FontSize * $this->cell_height_ratio);
19159 } elseif ($this->y < $maxbottomliney) {
19160 $hbz = ($maxbottomliney - $this->y);
19164 switch($tag['value
']) {
19166 $table_el = $dom[($dom[$key]['parent
'])]['parent
'];
19167 if (!isset($parent['endy
'])) {
19168 $dom[($dom[$key]['parent
'])]['endy
'] = $this->y;
19169 $parent['endy
'] = $this->y;
19171 if (!isset($parent['endpage
'])) {
19172 $dom[($dom[$key]['parent
'])]['endpage
'] = $this->page;
19173 $parent['endpage
'] = $this->page;
19175 if (!isset($parent['endcolumn
'])) {
19176 $dom[($dom[$key]['parent
'])]['endcolumn
'] = $this->current_column;
19177 $parent['endcolumn
'] = $this->current_column;
19179 // update row-spanned cells
19180 if (isset($dom[$table_el]['rowspans
'])) {
19181 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) {
19182 $dom[$table_el]['rowspans
'][$k]['rowspan
'] -= 1;
19183 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) {
19184 if (($dom[$table_el]['rowspans
'][$k]['endpage
'] == $parent['endpage
']) AND ($dom[$table_el]['rowspans
'][$k]['endcolumn
'] == $parent['endcolumn
'])) {
19185 $dom[($dom[$key]['parent
'])]['endy
'] = max($dom[$table_el]['rowspans
'][$k]['endy
'], $parent['endy
']);
19186 } elseif (($dom[$table_el]['rowspans
'][$k]['endpage
'] > $parent['endpage
']) OR ($dom[$table_el]['rowspans
'][$k]['endcolumn
'] > $parent['endcolumn
'])) {
19187 $dom[($dom[$key]['parent
'])]['endy
'] = $dom[$table_el]['rowspans
'][$k]['endy
'];
19188 $dom[($dom[$key]['parent
'])]['endpage
'] = $dom[$table_el]['rowspans
'][$k]['endpage
'];
19189 $dom[($dom[$key]['parent
'])]['endcolumn
'] = $dom[$table_el]['rowspans
'][$k]['endcolumn
'];
19193 // report new endy and endpage to the rowspanned cells
19194 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) {
19195 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) {
19196 $dom[$table_el]['rowspans
'][$k]['endpage
'] = max($dom[$table_el]['rowspans
'][$k]['endpage
'], $dom[($dom[$key]['parent
'])]['endpage
']);
19197 $dom[($dom[$key]['parent
'])]['endpage
'] = $dom[$table_el]['rowspans
'][$k]['endpage
'];
19198 $dom[$table_el]['rowspans
'][$k]['endcolumn
'] = max($dom[$table_el]['rowspans
'][$k]['endcolumn
'], $dom[($dom[$key]['parent
'])]['endcolumn
']);
19199 $dom[($dom[$key]['parent
'])]['endcolumn
'] = $dom[$table_el]['rowspans
'][$k]['endcolumn
'];
19200 $dom[$table_el]['rowspans
'][$k]['endy
'] = max($dom[$table_el]['rowspans
'][$k]['endy
'], $dom[($dom[$key]['parent
'])]['endy
']);
19201 $dom[($dom[$key]['parent
'])]['endy
'] = $dom[$table_el]['rowspans
'][$k]['endy
'];
19204 // update remaining rowspanned cells
19205 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) {
19206 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) {
19207 $dom[$table_el]['rowspans
'][$k]['endpage
'] = $dom[($dom[$key]['parent
'])]['endpage
'];
19208 $dom[$table_el]['rowspans
'][$k]['endcolumn
'] = $dom[($dom[$key]['parent
'])]['endcolumn
'];
19209 $dom[$table_el]['rowspans
'][$k]['endy
'] = $dom[($dom[$key]['parent
'])]['endy
'];
19213 $this->setPage($dom[($dom[$key]['parent
'])]['endpage
']);
19214 if ($this->num_columns > 1) {
19215 $this->selectColumn($dom[($dom[$key]['parent
'])]['endcolumn
']);
19217 $this->y = $dom[($dom[$key]['parent
'])]['endy
'];
19218 if (isset($dom[$table_el]['attribute
']['cellspacing
'])) {
19219 $this->y += $this->getHTMLUnitToUnits($dom[$table_el]['attribute
']['cellspacing
'], 1, 'px
');
19220 } elseif (isset($dom[$table_el]['border-spacing
'])) {
19221 $this->y += $dom[$table_el]['border-spacing
']['V
'];
19223 $this->Ln(0, $cell);
19224 if ($this->current_column == $parent['startcolumn
']) {
19225 $this->x = $parent['startx
'];
19227 // account for booklet mode
19228 if ($this->page > $parent['startpage
']) {
19229 if (($this->rtl) AND ($this->pagedim[$this->page]['orm
'] != $this->pagedim[$parent['startpage
']]['orm
'])) {
19230 $this->x -= ($this->pagedim[$this->page]['orm
'] - $this->pagedim[$parent['startpage
']]['orm
']);
19231 } elseif ((!$this->rtl) AND ($this->pagedim[$this->page]['olm
'] != $this->pagedim[$parent['startpage
']]['olm
'])) {
19232 $this->x += ($this->pagedim[$this->page]['olm
'] - $this->pagedim[$parent['startpage
']]['olm
']);
19238 // closing tag used for the thead part
19239 $in_table_head = true;
19240 $this->inthead = false;
19242 $table_el = $parent;
19243 // set default border
19244 if (isset($table_el['attribute
']['border
']) AND ($table_el['attribute
']['border
'] > 0)) {
19245 // set default border
19246 $border = array('LTRB
' => array('width
' => $this->getCSSBorderWidth($table_el['attribute
']['border
']), 'cap
'=>'square
', 'join
'=>'miter
', 'dash
'=> 0, 'color
'=>array(0,0,0)));
19250 $default_border = $border;
19251 // fix bottom line alignment of last line before page break
19252 foreach ($dom[($dom[$key]['parent
'])]['trids
'] as $j => $trkey) {
19253 // update row-spanned cells
19254 if (isset($dom[($dom[$key]['parent
'])]['rowspans
'])) {
19255 foreach ($dom[($dom[$key]['parent
'])]['rowspans
'] as $k => $trwsp) {
19256 if (isset($prevtrkey) AND ($trwsp['trid
'] == $prevtrkey) AND ($trwsp['mrowspan
'] > 0)) {
19257 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['trid
'] = $trkey;
19259 if ($dom[($dom[$key]['parent
'])]['rowspans
'][$k]['trid
'] == $trkey) {
19260 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['mrowspan
'] -= 1;
19264 if (isset($prevtrkey) AND ($dom[$trkey]['startpage
'] > $dom[$prevtrkey]['endpage
'])) {
19265 $pgendy = $this->pagedim[$dom[$prevtrkey]['endpage
']]['hk
'] - $this->pagedim[$dom[$prevtrkey]['endpage
']]['bm
'];
19266 $dom[$prevtrkey]['endy
'] = $pgendy;
19267 // update row-spanned cells
19268 if (isset($dom[($dom[$key]['parent
'])]['rowspans
'])) {
19269 foreach ($dom[($dom[$key]['parent
'])]['rowspans
'] as $k => $trwsp) {
19270 if (($trwsp['trid
'] == $trkey) AND ($trwsp['mrowspan
'] > 1) AND ($trwsp['endpage
'] == $dom[$prevtrkey]['endpage
'])) {
19271 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['endy
'] = $pgendy;
19272 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['mrowspan
'] = -1;
19277 $prevtrkey = $trkey;
19278 $table_el = $dom[($dom[$key]['parent
'])];
19281 if (count($table_el['trids
']) > 0) {
19284 foreach ($table_el['trids
'] as $j => $trkey) {
19285 $parent = $dom[$trkey];
19286 if (!isset($xmax)) {
19287 $xmax = $parent['cellpos
'][(count($parent['cellpos
']) - 1)]['endx
'];
19289 // for each cell on the row
19290 foreach ($parent['cellpos
'] as $k => $cellpos) {
19291 if (isset($cellpos['rowspanid
']) AND ($cellpos['rowspanid
'] >= 0)) {
19292 $cellpos['startx
'] = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startx
'];
19293 $cellpos['endx
'] = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endx
'];
19294 $endy = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endy
'];
19295 $startpage = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startpage
'];
19296 $endpage = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endpage
'];
19297 $startcolumn = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startcolumn
'];
19298 $endcolumn = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endcolumn
'];
19300 $endy = $parent['endy
'];
19301 $startpage = $parent['startpage
'];
19302 $endpage = $parent['endpage
'];
19303 $startcolumn = $parent['startcolumn
'];
19304 $endcolumn = $parent['endcolumn
'];
19306 if ($this->num_columns == 0) {
19307 $this->num_columns = 1;
19309 if (isset($cellpos['border
'])) {
19310 $border = $cellpos['border
'];
19312 if (isset($cellpos['bgcolor
']) AND ($cellpos['bgcolor
']) !== false) {
19313 $this->SetFillColorArray($cellpos['bgcolor
']);
19318 $x = $cellpos['startx
'];
19319 $y = $parent['starty
'];
19321 $w = abs($cellpos['endx
'] - $cellpos['startx
']);
19322 // get border modes
19323 $border_start = TCPDF_STATIC::getBorderMode($border, $position='start
', $this->opencell);
19324 $border_end = TCPDF_STATIC::getBorderMode($border, $position='end
', $this->opencell);
19325 $border_middle = TCPDF_STATIC::getBorderMode($border, $position='middle
', $this->opencell);
19326 // design borders around HTML cells.
19327 for ($page = $startpage; $page <= $endpage; ++$page) { // for each page
19329 $this->setPage($page);
19330 if ($this->num_columns < 2) {
19331 // single-column mode
19333 $this->y = $this->tMargin;
19335 // account for margin changes
19336 if ($page > $startpage) {
19337 if (($this->rtl) AND ($this->pagedim[$page]['orm
'] != $this->pagedim[$startpage]['orm
'])) {
19338 $this->x -= ($this->pagedim[$page]['orm
'] - $this->pagedim[$startpage]['orm
']);
19339 } elseif ((!$this->rtl) AND ($this->pagedim[$page]['olm
'] != $this->pagedim[$startpage]['olm
'])) {
19340 $this->x += ($this->pagedim[$page]['olm
'] - $this->pagedim[$startpage]['olm
']);
19343 if ($startpage == $endpage) { // single page
19346 for ($column = $startcolumn; $column <= $endcolumn; ++$column) { // for each column
19347 $this->selectColumn($column);
19348 if ($startcolumn == $endcolumn) { // single column
19349 $cborder = $border;
19350 $h = $endy - $parent['starty
'];
19353 } elseif ($column == $startcolumn) { // first column
19354 $cborder = $border_start;
19355 $this->y = $starty;
19357 $h = $this->h - $this->y - $this->bMargin;
19359 $deltacol = $this->x + $this->rMargin - $this->w;
19361 $deltacol = $this->x - $this->lMargin;
19363 } elseif ($column == $endcolumn) { // end column
19364 $cborder = $border_end;
19365 if (isset($this->columns[$column]['th
']['\
''.$page.
'\''])) {
19366 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19368 $this->x += $deltacol;
19371 $cborder = $border_middle;
19372 if (isset($this->columns[$column][
'th'][
'\''.
$page.
'\''])) {
19373 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19375 $this->x += $deltacol;
19378 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19380 } elseif (
$page == $startpage) {
19385 if ($column == $startcolumn) {
19386 $cborder = $border_start;
19387 $this->y = $starty;
19391 $deltacol = $this->x + $this->rMargin -
$this->w;
19396 $cborder = $border_middle;
19397 if (isset($this->columns[$column][
'th'][
'\''.
$page.
'\''])) {
19398 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19400 $this->x += $deltacol;
19403 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19405 } elseif (
$page == $endpage) {
19408 for ($column = 0; $column <= $endcolumn; ++$column) {
19410 if ($column == $endcolumn) {
19411 $cborder = $border_end;
19412 if (isset($this->columns[$column][
'th'][
'\''.
$page.
'\''])) {
19413 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19415 $this->x += $deltacol;
19418 $cborder = $border_middle;
19419 if (isset($this->columns[$column][
'th'][
'\''.
$page.
'\''])) {
19420 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19422 $this->x += $deltacol;
19425 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19432 $cborder = $border_middle;
19433 if (isset($this->columns[$column][
'th'][
'\''.
$page.
'\''])) {
19434 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19436 $this->x += $deltacol;
19438 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19441 if ($cborder OR $fill) {
19442 $offsetlen = strlen($ccode);
19444 if ($this->inxobj) {
19446 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
19447 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
19448 $pagemark = $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey];
19449 $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey] += $offsetlen;
19455 $pstart = substr($pagebuff, 0, $pagemark);
19456 $pend = substr($pagebuff, $pagemark);
19457 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
19460 if (end($this->transfmrk[$this->page]) !==
false) {
19461 $pagemarkkey = key($this->transfmrk[$this->page]);
19462 $pagemark = $this->transfmrk[
$this->page][$pagemarkkey];
19463 } elseif ($this->InFooter) {
19469 $pstart = substr($pagebuff, 0, $pagemark);
19470 $pend = substr($pagebuff, $pagemark);
19476 $border = $default_border;
19478 if (isset($table_el[
'attribute'][
'cellspacing'])) {
19479 $this->y += $this->
getHTMLUnitToUnits($table_el[
'attribute'][
'cellspacing'], 1,
'px');
19480 } elseif (isset($table_el[
'border-spacing'])) {
19481 $this->y += $table_el[
'border-spacing'][
'V'];
19483 $this->
Ln(0, $cell);
19484 $this->x = $parent[
'startx'];
19485 if ($endpage > $startpage) {
19486 if (($this->rtl) AND ($this->pagedim[$endpage][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
19487 $this->x += ($this->pagedim[$endpage][
'orm'] - $this->pagedim[$startpage][
'orm']);
19488 } elseif ((!$this->rtl) AND ($this->pagedim[$endpage][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
19489 $this->x += ($this->pagedim[$endpage][
'olm'] - $this->pagedim[$startpage][
'olm']);
19493 if (!$in_table_head) {
19494 $this->cell_padding = $table_el[
'old_cell_padding'];
19497 if (($this->page == ($this->numpages - 1)) AND ($this->pageopen[$this->numpages])) {
19499 if (($plendiff > 0) AND ($plendiff < 60)) {
19500 $pagediff = substr($this->
getPageBuffer($this->numpages), $this->emptypagemrk[$this->numpages], $plendiff);
19501 if (substr($pagediff, 0, 5) ==
'BT /F') {
19506 if ($plendiff == 0) {
19511 if (isset($this->theadMargins[
'top'])) {
19513 $this->tMargin = $this->theadMargins[
'top'];
19515 if (!isset($table_el[
'attribute'][
'nested']) OR ($table_el[
'attribute'][
'nested'] !=
'true')) {
19518 $this->theadMargins = array();
19522 $parent = $table_el;
19530 $this->
SetXY($this->
GetX(), $this->
GetY() + ((0.7 * $parent[
'fontsize']) / $this->k));
19534 $this->
SetXY($this->
GetX(), $this->
GetY() - ((0.3 * $parent[
'fontsize']) / $this->k));
19541 case 'blockquote': {
19557 $this->premode =
false;
19562 if ($this->listnum <= 0) {
19563 $this->listnum = 0;
19572 $this->lispacer =
'';
19577 $this->lispacer =
'';
19590 $this->lispacer =
'';
19597 if ($this->listnum <= 0) {
19598 $this->listnum = 0;
19607 $this->lispacer =
'';
19622 $this->form_action =
'';
19623 $this->form_enctype =
'application/x-www-form-urlencoded';
19632 if (isset($dom[($dom[$key][
'parent'])][
'attribute'][
'pagebreakafter'])) {
19633 $pba = $dom[($dom[$key][
'parent'])][
'attribute'][
'pagebreakafter'];
19635 if (($pba ==
'true') OR ($pba ==
'left') OR ($pba == 'right')) {
19639 if ((($pba ==
'left') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
19640 OR (($pba ==
'right') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
19645 $this->tmprtl =
false;
19660 $this->Ln(0, $cell);
19661 $this->htmlvspace = 0;
19665 $this->Ln($hbz, $cell);
19666 $this->htmlvspace = 0;
19669 if ($hb < $this->htmlvspace) {
19672 $hd = $hb - $this->htmlvspace;
19673 $this->htmlvspace = $hb;
19675 $this->Ln(($hbz + $hd), $cell);
19686 $xmax = $this->lMargin;
19688 $xmax = $this->w - $this->rMargin;
19690 return array(
'page' => $this->page,
'column' => $this->current_column,
'x' => $this->x,
'y' => $this->y,
'xmax' => $xmax);
19701 if (!isset($tag[
'borderposition'])) {
19705 $prev_x = $this->x;
19706 $prev_y = $this->y;
19707 $prev_lasth = $this->lasth;
19711 if (isset($tag[
'border']) AND !empty($tag[
'border'])) {
19713 $border = $tag[
'border'];
19719 if (isset($tag[
'bgcolor']) AND ($tag[
'bgcolor'] !==
false)) {
19721 $old_bgcolor = $this->bgcolor;
19722 $this->SetFillColorArray($tag[
'bgcolor']);
19725 if (!$border AND !$fill) {
19729 if (isset($tag[
'attribute'][
'cellspacing'])) {
19730 $clsp = $this->getHTMLUnitToUnits($tag[
'attribute'][
'cellspacing'], 1,
'px');
19731 $cellspacing = array(
'H' => $clsp,
'V' => $clsp);
19732 } elseif (isset($tag[
'border-spacing'])) {
19733 $cellspacing = $tag[
'border-spacing'];
19735 $cellspacing = array(
'H' => 0,
'V' => 0);
19737 if (($tag[
'value'] !=
'table') AND (is_array($border)) AND (!empty($border))) {
19739 $border[
'mode'] =
'ext';
19742 if ($xmax >= $tag[
'borderposition'][
'x']) {
19743 $xmax = $tag[
'borderposition'][
'xmax'];
19745 $w = ($tag[
'borderposition'][
'x'] - $xmax);
19747 if ($xmax <= $tag[
'borderposition'][
'x']) {
19748 $xmax = $tag[
'borderposition'][
'xmax'];
19750 $w = ($xmax - $tag[
'borderposition'][
'x']);
19755 $w += $cellspacing[
'H'];
19756 $startpage = $tag[
'borderposition'][
'page'];
19757 $startcolumn = $tag[
'borderposition'][
'column'];
19758 $x = $tag[
'borderposition'][
'x'];
19759 $y = $tag[
'borderposition'][
'y'];
19760 $endpage = $this->page;
19761 $starty = $tag[
'borderposition'][
'y'] - $cellspacing[
'V'];
19762 $currentY = $this->y;
19765 $endcolumn = $this->current_column;
19766 if ($this->num_columns == 0) {
19767 $this->num_columns = 1;
19774 $temp_page_regions = $this->page_regions;
19775 $this->page_regions = array();
19777 for ($page = $startpage; $page <= $endpage; ++$page) {
19779 $this->setPage($page);
19780 if ($this->num_columns < 2) {
19783 $this->y = $this->tMargin;
19786 if ($page > $startpage) {
19787 if (($this->rtl) AND ($this->pagedim[$page][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
19788 $this->x -= ($this->pagedim[$page][
'orm'] - $this->pagedim[$startpage][
'orm']);
19789 } elseif ((!$this->rtl) AND ($this->pagedim[$page][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
19790 $this->x += ($this->pagedim[$page][
'olm'] - $this->pagedim[$startpage][
'olm']);
19793 if ($startpage == $endpage) {
19795 for ($column = $startcolumn; $column <= $endcolumn; ++$column) {
19796 $this->selectColumn($column);
19797 if ($startcolumn == $endcolumn) {
19798 $cborder = $border;
19799 $h = ($currentY - $y) + $cellspacing[
'V'];
19800 $this->y = $starty;
19801 } elseif ($column == $startcolumn) {
19802 $cborder = $border_start;
19803 $this->y = $starty;
19804 $h = $this->h - $this->y - $this->bMargin;
19805 } elseif ($column == $endcolumn) {
19806 $cborder = $border_end;
19807 $h = $currentY - $this->y;
19809 $cborder = $border_middle;
19810 $h = $this->h - $this->y - $this->bMargin;
19812 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19814 } elseif ($page == $startpage) {
19815 for ($column = $startcolumn; $column < $this->num_columns; ++$column) {
19816 $this->selectColumn($column);
19817 if ($column == $startcolumn) {
19818 $cborder = $border_start;
19819 $this->y = $starty;
19820 $h = $this->h - $this->y - $this->bMargin;
19822 $cborder = $border_middle;
19823 $h = $this->h - $this->y - $this->bMargin;
19825 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19827 } elseif ($page == $endpage) {
19828 for ($column = 0; $column <= $endcolumn; ++$column) {
19829 $this->selectColumn($column);
19830 if ($column == $endcolumn) {
19832 $cborder = $border_end;
19833 $h = $currentY - $this->y;
19836 $cborder = $border_middle;
19837 $h = $this->h - $this->y - $this->bMargin;
19839 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19842 for ($column = 0; $column < $this->num_columns; ++$column) {
19843 $this->selectColumn($column);
19844 $cborder = $border_middle;
19845 $h = $this->h - $this->y - $this->bMargin;
19846 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19849 if ($cborder OR $fill) {
19850 $offsetlen = strlen($ccode);
19852 if ($this->inxobj) {
19854 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
19855 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
19856 $pagemark = $this->xobjects[$this->xobjid][
'transfmrk'][$pagemarkkey];
19857 $this->xobjects[$this->xobjid][
'transfmrk'][$pagemarkkey] += $offsetlen;
19859 $pagemark = $this->xobjects[$this->xobjid][
'intmrk'];
19860 $this->xobjects[$this->xobjid][
'intmrk'] += $offsetlen;
19862 $pagebuff = $this->xobjects[$this->xobjid][
'outdata'];
19863 $pstart = substr($pagebuff, 0, $pagemark);
19864 $pend = substr($pagebuff, $pagemark);
19865 $this->xobjects[$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
19867 if (end($this->transfmrk[$this->page]) !==
false) {
19868 $pagemarkkey = key($this->transfmrk[$this->page]);
19869 $pagemark = $this->transfmrk[$this->page][$pagemarkkey];
19870 } elseif ($this->InFooter) {
19871 $pagemark = $this->footerpos[$this->page];
19873 $pagemark = $this->intmrk[$this->page];
19875 $pagebuff = $this->getPageBuffer($this->page);
19876 $pstart = substr($pagebuff, 0, $pagemark);
19877 $pend = substr($pagebuff, $pagemark);
19878 $this->setPageBuffer($this->page, $pstart.$ccode.$pend);
19879 $this->bordermrk[$this->page] += $offsetlen;
19880 $this->cntmrk[$this->page] += $offsetlen;
19885 $this->page_regions = $temp_page_regions;
19886 if (isset($old_bgcolor)) {
19888 $this->SetFillColorArray($old_bgcolor);
19891 $this->x = $prev_x;
19892 $this->y = $prev_y;
19893 $this->lasth = $prev_lasth;
19904 if (substr($symbol, 0, 4) ==
'img|') {
19905 $this->lisymbol = $symbol;
19908 $symbol = strtolower($symbol);
19917 case 'decimal-leading-zero':
19919 case 'lower-roman':
19921 case 'upper-roman':
19923 case 'lower-alpha':
19924 case 'lower-latin':
19926 case 'upper-alpha':
19927 case 'upper-latin':
19928 case 'lower-greek': {
19929 $this->lisymbol = $symbol;
19933 $this->lisymbol =
'';
19947 $this->booklet = $booklet;
19949 $this->lMargin = $inner;
19952 $this->rMargin = $outer;
19965 $mtemp = $this->original_lMargin;
19966 $this->original_lMargin = $this->original_rMargin;
19967 $this->original_rMargin = $mtemp;
19968 $deltam = $this->original_lMargin - $this->original_rMargin;
19969 $this->lMargin += $deltam;
19970 $this->rMargin -= $deltam;
19987 $this->tagvspaces = $tagvs;
19997 return $this->customlistindent = floatval($width);
20007 $this->opencell = $isopen;
20018 $this->htmlLinkColorArray = $color;
20019 $this->htmlLinkFontStyle = $fontstyle;
20033 $supportedunits = array(
'%',
'em',
'ex',
'px',
'in',
'cm',
'mm',
'pc',
'pt');
20042 if (in_array($defaultunit, $supportedunits)) {
20043 $unit = $defaultunit;
20045 if (is_numeric($htmlval)) {
20046 $value = floatval($htmlval);
20047 } elseif (preg_match(
'/([0-9\.\-\+]+)/', $htmlval, $mnum)) {
20048 $value = floatval($mnum[1]);
20049 if (preg_match(
'/([a-z%]+)/', $htmlval, $munit)) {
20050 if (in_array($munit[1], $supportedunits)) {
20058 $retval = (($value * $refsize) / 100);
20063 $retval = ($value * $refsize);
20068 $retval = ($value * ($refsize / 2));
20073 $retval = (($value * $this->dpi) / $k);
20078 $retval = (($value / 2.54 * $this->dpi) / $k);
20083 $retval = (($value / 25.4 * $this->dpi) / $k);
20088 $retval = (($value * 12) / $k);
20093 $retval = ($value / $k);
20098 $retval = $this->pixelsToUnits($value);
20100 $retval *= $this->k;
20117 if ($this->state != 2) {
20122 $bgcolor = $this->bgcolor;
20123 $color = $this->fgcolor;
20124 $strokecolor = $this->strokecolor;
20128 $lspace = $this->GetStringWidth(
' ');
20129 if ($listtype ==
'^') {
20131 $this->lispacer =
'';
20133 } elseif ($listtype ==
'!') {
20135 $deftypes = array(
'disc',
'circle',
'square');
20136 $listtype = $deftypes[($listdepth - 1) % 3];
20137 } elseif ($listtype ==
'#') {
20139 $listtype =
'decimal';
20140 } elseif (substr($listtype, 0, 4) ==
'img|') {
20142 $img = explode(
'|', $listtype);
20145 switch ($listtype) {
20152 $lspace += (2 * $r);
20154 $this->x += $lspace;
20156 $this->x -= $lspace;
20158 $this->Circle(($this->x + $r), ($this->y + ($this->lasth / 2)), $r, 0, 360,
'F', array(), $color, 8);
20163 $lspace += (2 * $r);
20165 $this->x += $lspace;
20167 $this->x -= $lspace;
20169 $prev_line_style = $this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor;
20170 $new_line_style = array(
'width' => ($r / 3),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'phase' => 0,
'color'=>$color);
20171 $this->Circle(($this->x + $r), ($this->y + ($this->lasth / 2)), ($r * (1 - (1/6))), 0, 360,
'D', $new_line_style, array(), 8);
20172 $this->_out($prev_line_style);
20179 $this->x += $lspace;
20181 $this->x -= $lspace;
20183 $this->Rect($this->x, ($this->y + (($this->lasth - $l) / 2)), $l, $l,
'F', array(), $color);
20188 $lspace +=
$img[2];
20190 $this->x += $lspace;
20192 $this->x -= $lspace;
20194 $imgtype = strtolower(
$img[1]);
20195 $prev_y = $this->y;
20196 switch ($imgtype) {
20198 $this->ImageSVG(
$img[4], $this->x, ($this->y + (($this->lasth -
$img[3]) / 2)),
$img[2],
$img[3],
'',
'T',
'', 0,
false);
20203 $this->ImageEps(
$img[4], $this->x, ($this->y + (($this->lasth -
$img[3]) / 2)),
$img[2],
$img[3],
'',
true,
'T',
'', 0,
false);
20207 $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);
20211 $this->y = $prev_y;
20219 $textitem = $this->listcount[$this->listnum];
20222 case 'decimal-leading-zero': {
20223 $textitem = sprintf(
'%02d', $this->listcount[$this->listnum]);
20227 case 'lower-roman': {
20232 case 'upper-roman': {
20237 case 'lower-alpha':
20238 case 'lower-latin': {
20239 $textitem = chr(97 + $this->listcount[$this->listnum] - 1);
20243 case 'upper-alpha':
20244 case 'upper-latin': {
20245 $textitem = chr(65 + $this->listcount[$this->listnum] - 1);
20248 case 'lower-greek': {
20249 $textitem =
TCPDF_FONTS::unichr((945 + $this->listcount[$this->listnum] - 1), $this->isunicode);
20280 $textitem = $this->listcount[$this->listnum];
20285 $prev_y = $this->y;
20286 $h = ($this->FontSize * $this->cell_height_ratio) + $this->cell_padding[
'T'] + $this->cell_padding[
'B'];
20287 if ($this->checkPageBreak($h) OR ($this->y < $prev_y)) {
20292 $textitem =
'.'.$textitem;
20294 $textitem = $textitem.
'.';
20296 $lspace += $this->GetStringWidth($textitem);
20298 $this->x += $lspace;
20300 $this->x -= $lspace;
20302 $this->Write($this->lasth, $textitem,
'',
false,
'',
false, 0,
false);
20305 $this->lispacer =
'^';
20307 $this->SetFillColorArray($bgcolor);
20308 $this->SetDrawColorArray($strokecolor);
20309 $this->SettextColorArray($color);
20320 'FontFamily' => $this->FontFamily,
20321 'FontStyle' => $this->FontStyle,
20322 'FontSizePt' => $this->FontSizePt,
20323 'rMargin' => $this->rMargin,
20324 'lMargin' => $this->lMargin,
20325 'cell_padding' => $this->cell_padding,
20326 'cell_margin' => $this->cell_margin,
20327 'LineWidth' => $this->LineWidth,
20328 'linestyleWidth' => $this->linestyleWidth,
20329 'linestyleCap' => $this->linestyleCap,
20330 'linestyleJoin' => $this->linestyleJoin,
20331 'linestyleDash' => $this->linestyleDash,
20332 'textrendermode' => $this->textrendermode,
20333 'textstrokewidth' => $this->textstrokewidth,
20334 'DrawColor' => $this->DrawColor,
20335 'FillColor' => $this->FillColor,
20336 'TextColor' => $this->TextColor,
20337 'ColorFlag' => $this->ColorFlag,
20338 'bgcolor' => $this->bgcolor,
20339 'fgcolor' => $this->fgcolor,
20340 'htmlvspace' => $this->htmlvspace,
20341 'listindent' => $this->listindent,
20342 'listindentlevel' => $this->listindentlevel,
20343 'listnum' => $this->listnum,
20344 'listordered' => $this->listordered,
20345 'listcount' => $this->listcount,
20346 'lispacer' => $this->lispacer,
20347 'cell_height_ratio' => $this->cell_height_ratio,
20348 'font_stretching' => $this->font_stretching,
20349 'font_spacing' => $this->font_spacing,
20350 'alpha' => $this->alpha,
20352 'lasth' => $this->lasth,
20353 'tMargin' => $this->tMargin,
20354 'bMargin' => $this->bMargin,
20355 'AutoPageBreak' => $this->AutoPageBreak,
20356 'PageBreakTrigger' => $this->PageBreakTrigger,
20361 'wPt' => $this->wPt,
20362 'hPt' => $this->hPt,
20363 'fwPt' => $this->fwPt,
20364 'fhPt' => $this->fhPt,
20365 'page' => $this->page,
20366 'current_column' => $this->current_column,
20367 'num_columns' => $this->num_columns
20380 if ($this->state != 2) {
20383 $this->FontFamily = $gvars[
'FontFamily'];
20384 $this->FontStyle = $gvars[
'FontStyle'];
20385 $this->FontSizePt = $gvars[
'FontSizePt'];
20386 $this->rMargin = $gvars[
'rMargin'];
20387 $this->lMargin = $gvars[
'lMargin'];
20388 $this->cell_padding = $gvars[
'cell_padding'];
20389 $this->cell_margin = $gvars[
'cell_margin'];
20390 $this->LineWidth = $gvars[
'LineWidth'];
20391 $this->linestyleWidth = $gvars[
'linestyleWidth'];
20392 $this->linestyleCap = $gvars[
'linestyleCap'];
20393 $this->linestyleJoin = $gvars[
'linestyleJoin'];
20394 $this->linestyleDash = $gvars[
'linestyleDash'];
20395 $this->textrendermode = $gvars[
'textrendermode'];
20396 $this->textstrokewidth = $gvars[
'textstrokewidth'];
20397 $this->DrawColor = $gvars[
'DrawColor'];
20398 $this->FillColor = $gvars[
'FillColor'];
20399 $this->TextColor = $gvars[
'TextColor'];
20400 $this->ColorFlag = $gvars[
'ColorFlag'];
20401 $this->bgcolor = $gvars[
'bgcolor'];
20402 $this->fgcolor = $gvars[
'fgcolor'];
20403 $this->htmlvspace = $gvars[
'htmlvspace'];
20404 $this->listindent = $gvars[
'listindent'];
20405 $this->listindentlevel = $gvars[
'listindentlevel'];
20406 $this->listnum = $gvars[
'listnum'];
20407 $this->listordered = $gvars[
'listordered'];
20408 $this->listcount = $gvars[
'listcount'];
20409 $this->lispacer = $gvars[
'lispacer'];
20410 $this->cell_height_ratio = $gvars[
'cell_height_ratio'];
20411 $this->font_stretching = $gvars[
'font_stretching'];
20412 $this->font_spacing = $gvars[
'font_spacing'];
20413 $this->alpha = $gvars[
'alpha'];
20416 $this->lasth = $gvars[
'lasth'];
20417 $this->tMargin = $gvars[
'tMargin'];
20418 $this->bMargin = $gvars[
'bMargin'];
20419 $this->AutoPageBreak = $gvars[
'AutoPageBreak'];
20420 $this->PageBreakTrigger = $gvars[
'PageBreakTrigger'];
20421 $this->x = $gvars[
'x'];
20422 $this->y = $gvars[
'y'];
20423 $this->w = $gvars[
'w'];
20424 $this->h = $gvars[
'h'];
20425 $this->wPt = $gvars[
'wPt'];
20426 $this->hPt = $gvars[
'hPt'];
20427 $this->fwPt = $gvars[
'fwPt'];
20428 $this->fhPt = $gvars[
'fhPt'];
20429 $this->page = $gvars[
'page'];
20430 $this->current_column = $gvars[
'current_column'];
20431 $this->num_columns = $gvars[
'num_columns'];
20433 $this->_out(
''.$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' '.$this->FillColor.
'');
20435 $this->SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
20455 $this->Error(
'Unable to write cache file: '.
$filename);
20461 if (!isset($this->cache_file_length[
'_'.
$filename])) {
20462 $this->cache_file_length[
'_'.$filename] = strlen($data);
20464 $this->cache_file_length[
'_'.$filename] += strlen($data);
20486 $this->bufferlen += strlen($data);
20487 if ($this->diskcache) {
20491 $this->writeDiskCache($this->buffer, $data,
true);
20493 $this->buffer .= $data;
20504 $this->bufferlen = strlen($data);
20505 if ($this->diskcache) {
20509 $this->writeDiskCache($this->buffer, $data,
false);
20511 $this->buffer = $data;
20522 if ($this->diskcache) {
20523 return $this->readDiskCache($this->buffer);
20525 return $this->buffer;
20538 if ($this->diskcache) {
20539 if (!isset($this->pages[$page])) {
20542 $this->writeDiskCache($this->pages[$page], $data, $append);
20545 $this->pages[$page] .= $data;
20547 $this->pages[$page] = $data;
20550 if ($append AND isset($this->pagelen[$page])) {
20551 $this->pagelen[$page] += strlen($data);
20553 $this->pagelen[$page] = strlen($data);
20565 if ($this->diskcache) {
20566 return $this->readDiskCache($this->pages[$page]);
20567 } elseif (isset($this->pages[$page])) {
20568 return $this->pages[$page];
20582 if (($data[
'i'] = array_search($image, $this->imagekeys)) === FALSE) {
20583 $this->imagekeys[$this->numimages] = $image;
20584 $data[
'i'] = $this->numimages;
20585 ++$this->numimages;
20587 if ($this->diskcache) {
20588 if (!isset($this->images[$image])) {
20591 $this->writeDiskCache($this->images[$image], serialize($data));
20593 $this->images[$image] = $data;
20607 if (!isset($this->images[$image])) {
20608 $this->setImageBuffer($image, array());
20610 if ($this->diskcache) {
20611 $tmpimg = $this->getImageBuffer($image);
20612 $tmpimg[$key] = $data;
20613 $this->writeDiskCache($this->images[$image], serialize($tmpimg));
20615 $this->images[$image][$key] = $data;
20627 if ($this->diskcache AND isset($this->images[$image])) {
20628 return unserialize($this->readDiskCache($this->images[$image]));
20629 } elseif (isset($this->images[$image])) {
20630 return $this->images[$image];
20643 if ($this->diskcache) {
20644 if (!isset($this->fonts[$font])) {
20647 $this->writeDiskCache($this->fonts[$font], serialize($data));
20649 $this->fonts[$font] = $data;
20651 if (!in_array($font, $this->fontkeys)) {
20652 $this->fontkeys[] = $font;
20655 $this->font_obj_ids[$font] =
$this->n;
20656 $this->setFontSubBuffer($font,
'n', $this->
n);
20669 if (!isset($this->fonts[$font])) {
20670 $this->setFontBuffer($font, array());
20672 if ($this->diskcache) {
20673 $tmpfont = $this->getFontBuffer($font);
20674 $tmpfont[$key] = $data;
20675 $this->writeDiskCache($this->fonts[$font], serialize($tmpfont));
20677 $this->fonts[$font][$key] = $data;
20689 if ($this->diskcache AND isset($this->fonts[$font])) {
20690 return unserialize($this->readDiskCache($this->fonts[$font]));
20691 } elseif (isset($this->fonts[$font])) {
20692 return $this->fonts[$font];
20706 if (($frompage > $this->numpages) OR ($frompage <= $topage)) {
20709 if ($frompage == $this->page) {
20714 $tmppage = $this->getPageBuffer($frompage);
20715 $tmppagedim = $this->pagedim[$frompage];
20716 $tmppagelen = $this->pagelen[$frompage];
20717 $tmpintmrk = $this->intmrk[$frompage];
20718 $tmpbordermrk = $this->bordermrk[$frompage];
20719 $tmpcntmrk = $this->cntmrk[$frompage];
20720 $tmppageobjects = $this->pageobjects[$frompage];
20721 if (isset($this->footerpos[$frompage])) {
20722 $tmpfooterpos = $this->footerpos[$frompage];
20724 if (isset($this->footerlen[$frompage])) {
20725 $tmpfooterlen = $this->footerlen[$frompage];
20727 if (isset($this->transfmrk[$frompage])) {
20728 $tmptransfmrk = $this->transfmrk[$frompage];
20730 if (isset($this->PageAnnots[$frompage])) {
20731 $tmpannots = $this->PageAnnots[$frompage];
20733 if (isset($this->newpagegroup) AND !empty($this->newpagegroup)) {
20734 for ($i = $frompage; $i > $topage; --$i) {
20735 if (isset($this->newpagegroup[$i]) AND (($i + $this->pagegroups[$this->newpagegroup[$i]]) > $frompage)) {
20736 --$this->pagegroups[$this->newpagegroup[$i]];
20740 for ($i = $topage; $i > 0; --$i) {
20741 if (isset($this->newpagegroup[$i]) AND (($i + $this->pagegroups[$this->newpagegroup[$i]]) > $topage)) {
20742 ++$this->pagegroups[$this->newpagegroup[$i]];
20747 for ($i = $frompage; $i > $topage; --$i) {
20750 $this->setPageBuffer($i, $this->getPageBuffer($j));
20751 $this->pagedim[$i] = $this->pagedim[$j];
20752 $this->pagelen[$i] = $this->pagelen[$j];
20753 $this->intmrk[$i] = $this->intmrk[$j];
20754 $this->bordermrk[$i] = $this->bordermrk[$j];
20755 $this->cntmrk[$i] = $this->cntmrk[$j];
20756 $this->pageobjects[$i] = $this->pageobjects[$j];
20757 if (isset($this->footerpos[$j])) {
20758 $this->footerpos[$i] = $this->footerpos[$j];
20759 } elseif (isset($this->footerpos[$i])) {
20760 unset($this->footerpos[$i]);
20762 if (isset($this->footerlen[$j])) {
20763 $this->footerlen[$i] = $this->footerlen[$j];
20764 } elseif (isset($this->footerlen[$i])) {
20765 unset($this->footerlen[$i]);
20767 if (isset($this->transfmrk[$j])) {
20768 $this->transfmrk[$i] = $this->transfmrk[$j];
20769 } elseif (isset($this->transfmrk[$i])) {
20770 unset($this->transfmrk[$i]);
20772 if (isset($this->PageAnnots[$j])) {
20773 $this->PageAnnots[$i] = $this->PageAnnots[$j];
20774 } elseif (isset($this->PageAnnots[$i])) {
20775 unset($this->PageAnnots[$i]);
20777 if (isset($this->newpagegroup[$j])) {
20778 $this->newpagegroup[$i] = $this->newpagegroup[$j];
20779 unset($this->newpagegroup[$j]);
20781 if ($this->currpagegroup == $j) {
20782 $this->currpagegroup = $i;
20785 $this->setPageBuffer($topage, $tmppage);
20786 $this->pagedim[$topage] = $tmppagedim;
20787 $this->pagelen[$topage] = $tmppagelen;
20788 $this->intmrk[$topage] = $tmpintmrk;
20789 $this->bordermrk[$topage] = $tmpbordermrk;
20790 $this->cntmrk[$topage] = $tmpcntmrk;
20791 $this->pageobjects[$topage] = $tmppageobjects;
20792 if (isset($tmpfooterpos)) {
20793 $this->footerpos[$topage] = $tmpfooterpos;
20794 } elseif (isset($this->footerpos[$topage])) {
20795 unset($this->footerpos[$topage]);
20797 if (isset($tmpfooterlen)) {
20798 $this->footerlen[$topage] = $tmpfooterlen;
20799 } elseif (isset($this->footerlen[$topage])) {
20800 unset($this->footerlen[$topage]);
20802 if (isset($tmptransfmrk)) {
20803 $this->transfmrk[$topage] = $tmptransfmrk;
20804 } elseif (isset($this->transfmrk[$topage])) {
20805 unset($this->transfmrk[$topage]);
20807 if (isset($tmpannots)) {
20808 $this->PageAnnots[$topage] = $tmpannots;
20809 } elseif (isset($this->PageAnnots[$topage])) {
20810 unset($this->PageAnnots[$topage]);
20813 $tmpoutlines = $this->outlines;
20814 foreach ($tmpoutlines as $key => $outline) {
20815 if (($outline[
'p'] >= $topage) AND ($outline[
'p'] < $frompage)) {
20816 $this->outlines[$key][
'p'] = ($outline[
'p'] + 1);
20817 } elseif ($outline[
'p'] == $frompage) {
20818 $this->outlines[$key][
'p'] = $topage;
20822 $tmpdests = $this->dests;
20823 foreach ($tmpdests as $key => $dest) {
20824 if (($dest[
'p'] >= $topage) AND ($dest[
'p'] < $frompage)) {
20825 $this->dests[$key][
'p'] = ($dest[
'p'] + 1);
20826 } elseif ($dest[
'p'] == $frompage) {
20827 $this->dests[$key][
'p'] = $topage;
20831 $tmplinks = $this->links;
20832 foreach ($tmplinks as $key => $link) {
20833 if (($link[0] >= $topage) AND ($link[0] < $frompage)) {
20834 $this->links[$key][0] = ($link[0] + 1);
20835 } elseif ($link[0] == $frompage) {
20836 $this->links[$key][0] = $topage;
20840 $tmpjavascript = $this->javascript;
20841 global $jfrompage, $jtopage;
20842 $jfrompage = $frompage;
20843 $jtopage = $topage;
20844 $this->javascript = preg_replace_callback(
'/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/',
20845 create_function(
'$matches',
'global $jfrompage, $jtopage;
20846 $pagenum = intval($matches[3]) + 1;
20847 if (($pagenum >= $jtopage) AND ($pagenum < $jfrompage)) {
20848 $newpage = ($pagenum + 1);
20849 } elseif ($pagenum == $jfrompage) {
20850 $newpage = $jtopage;
20852 $newpage = $pagenum;
20855 return "this.addField(\'".$matches[1]."\',\'".$matches[2]."\',".$newpage."";'), $tmpjavascript);
20857 $this->lastPage(
true);
20869 if (($page < 1) OR ($page > $this->numpages)) {
20873 unset($this->pages[$page]);
20874 unset($this->pagedim[$page]);
20875 unset($this->pagelen[$page]);
20876 unset($this->intmrk[$page]);
20877 unset($this->bordermrk[$page]);
20878 unset($this->cntmrk[$page]);
20879 foreach ($this->pageobjects[$page] as $oid) {
20880 if (isset($this->offsets[$oid])){
20881 unset($this->offsets[$oid]);
20884 unset($this->pageobjects[$page]);
20885 if (isset($this->footerpos[$page])) {
20886 unset($this->footerpos[$page]);
20888 if (isset($this->footerlen[$page])) {
20889 unset($this->footerlen[$page]);
20891 if (isset($this->transfmrk[$page])) {
20892 unset($this->transfmrk[$page]);
20894 if (isset($this->PageAnnots[$page])) {
20895 unset($this->PageAnnots[$page]);
20897 if (isset($this->newpagegroup) AND !empty($this->newpagegroup)) {
20898 for ($i = $page; $i > 0; --$i) {
20899 if (isset($this->newpagegroup[$i]) AND (($i + $this->pagegroups[$this->newpagegroup[$i]]) > $page)) {
20900 --$this->pagegroups[$this->newpagegroup[$i]];
20905 if (isset($this->pageopen[$page])) {
20906 unset($this->pageopen[$page]);
20908 if ($page < $this->numpages) {
20910 for ($i = $page; $i < $this->numpages; ++$i) {
20913 $this->setPageBuffer($i, $this->getPageBuffer($j));
20914 $this->pagedim[$i] = $this->pagedim[$j];
20915 $this->pagelen[$i] = $this->pagelen[$j];
20916 $this->intmrk[$i] = $this->intmrk[$j];
20917 $this->bordermrk[$i] = $this->bordermrk[$j];
20918 $this->cntmrk[$i] = $this->cntmrk[$j];
20919 $this->pageobjects[$i] = $this->pageobjects[$j];
20920 if (isset($this->footerpos[$j])) {
20921 $this->footerpos[$i] = $this->footerpos[$j];
20922 } elseif (isset($this->footerpos[$i])) {
20923 unset($this->footerpos[$i]);
20925 if (isset($this->footerlen[$j])) {
20926 $this->footerlen[$i] = $this->footerlen[$j];
20927 } elseif (isset($this->footerlen[$i])) {
20928 unset($this->footerlen[$i]);
20930 if (isset($this->transfmrk[$j])) {
20931 $this->transfmrk[$i] = $this->transfmrk[$j];
20932 } elseif (isset($this->transfmrk[$i])) {
20933 unset($this->transfmrk[$i]);
20935 if (isset($this->PageAnnots[$j])) {
20936 $this->PageAnnots[$i] = $this->PageAnnots[$j];
20937 } elseif (isset($this->PageAnnots[$i])) {
20938 unset($this->PageAnnots[$i]);
20940 if (isset($this->newpagegroup[$j])) {
20941 $this->newpagegroup[$i] = $this->newpagegroup[$j];
20942 unset($this->newpagegroup[$j]);
20944 if ($this->currpagegroup == $j) {
20945 $this->currpagegroup = $i;
20947 if (isset($this->pageopen[$j])) {
20948 $this->pageopen[$i] = $this->pageopen[$j];
20949 } elseif (isset($this->pageopen[$i])) {
20950 unset($this->pageopen[$i]);
20954 unset($this->pages[$this->numpages]);
20955 unset($this->pagedim[$this->numpages]);
20956 unset($this->pagelen[$this->numpages]);
20957 unset($this->intmrk[$this->numpages]);
20958 unset($this->bordermrk[$this->numpages]);
20959 unset($this->cntmrk[$this->numpages]);
20960 foreach ($this->pageobjects[$this->numpages] as $oid) {
20961 if (isset($this->offsets[$oid])){
20962 unset($this->offsets[$oid]);
20965 unset($this->pageobjects[$this->numpages]);
20966 if (isset($this->footerpos[$this->numpages])) {
20967 unset($this->footerpos[$this->numpages]);
20969 if (isset($this->footerlen[$this->numpages])) {
20970 unset($this->footerlen[$this->numpages]);
20972 if (isset($this->transfmrk[$this->numpages])) {
20973 unset($this->transfmrk[$this->numpages]);
20975 if (isset($this->PageAnnots[$this->numpages])) {
20976 unset($this->PageAnnots[$this->numpages]);
20978 if (isset($this->newpagegroup[$this->numpages])) {
20979 unset($this->newpagegroup[$this->numpages]);
20981 if ($this->currpagegroup == $this->numpages) {
20982 $this->currpagegroup = ($this->numpages - 1);
20984 if (isset($this->pagegroups[$this->numpages])) {
20985 unset($this->pagegroups[$this->numpages]);
20987 if (isset($this->pageopen[$this->numpages])) {
20988 unset($this->pageopen[$this->numpages]);
20992 $this->page = $this->numpages;
20994 $tmpoutlines = $this->outlines;
20995 foreach ($tmpoutlines as $key => $outline) {
20996 if ($outline[
'p'] > $page) {
20997 $this->outlines[$key][
'p'] = $outline[
'p'] - 1;
20998 } elseif ($outline[
'p'] == $page) {
20999 unset($this->outlines[$key]);
21003 $tmpdests = $this->dests;
21004 foreach ($tmpdests as $key => $dest) {
21005 if ($dest[
'p'] > $page) {
21006 $this->dests[$key][
'p'] = $dest[
'p'] - 1;
21007 } elseif ($dest[
'p'] == $page) {
21008 unset($this->dests[$key]);
21012 $tmplinks = $this->links;
21013 foreach ($tmplinks as $key => $link) {
21014 if ($link[0] > $page) {
21015 $this->links[$key][0] = $link[0] - 1;
21016 } elseif ($link[0] == $page) {
21017 unset($this->links[$key]);
21021 $tmpjavascript = $this->javascript;
21024 $this->javascript = preg_replace_callback(
'/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/',
21025 create_function(
'$matches',
'global $jpage;
21026 $pagenum = intval($matches[3]) + 1;
21027 if ($pagenum >= $jpage) {
21028 $newpage = ($pagenum - 1);
21029 } elseif ($pagenum == $jpage) {
21032 $newpage = $pagenum;
21035 return "this.addField(\'".$matches[1]."\',\'".$matches[2]."\',".$newpage."";'), $tmpjavascript);
21037 if ($this->numpages > 0) {
21038 $this->lastPage(
true);
21053 $page = $this->page;
21055 if (($page < 1) OR ($page > $this->numpages)) {
21062 $this->page = $this->numpages;
21063 $this->setPageBuffer($this->page, $this->getPageBuffer($page));
21064 $this->pagedim[$this->page] = $this->pagedim[$page];
21065 $this->pagelen[$this->page] = $this->pagelen[$page];
21066 $this->intmrk[$this->page] = $this->intmrk[$page];
21067 $this->bordermrk[$this->page] = $this->bordermrk[$page];
21068 $this->cntmrk[$this->page] = $this->cntmrk[$page];
21069 $this->pageobjects[$this->page] = $this->pageobjects[$page];
21070 $this->pageopen[$this->page] =
false;
21071 if (isset($this->footerpos[$page])) {
21072 $this->footerpos[$this->page] = $this->footerpos[$page];
21074 if (isset($this->footerlen[$page])) {
21075 $this->footerlen[$this->page] = $this->footerlen[$page];
21077 if (isset($this->transfmrk[$page])) {
21078 $this->transfmrk[$this->page] = $this->transfmrk[$page];
21080 if (isset($this->PageAnnots[$page])) {
21081 $this->PageAnnots[$this->page] = $this->PageAnnots[$page];
21083 if (isset($this->newpagegroup[$page])) {
21085 $this->newpagegroup[$this->page] =
sizeof($this->newpagegroup) + 1;
21086 $this->currpagegroup = $this->newpagegroup[$this->page];
21087 $this->pagegroups[$this->currpagegroup] = 1;
21088 } elseif (isset($this->currpagegroup) AND ($this->currpagegroup > 0)) {
21089 ++$this->pagegroups[$this->currpagegroup];
21092 $tmpoutlines = $this->outlines;
21093 foreach ($tmpoutlines as $key => $outline) {
21094 if ($outline[
'p'] == $page) {
21095 $this->outlines[] = array(
't' => $outline[
't'],
'l' => $outline[
'l'],
'x' => $outline[
'x'],
'y' => $outline[
'y'],
'p' => $this->page,
's' => $outline[
's'],
'c' => $outline[
'c']);
21099 $tmplinks = $this->links;
21100 foreach ($tmplinks as $key => $link) {
21101 if ($link[0] == $page) {
21102 $this->links[] = array($this->page, $link[1]);
21106 $this->lastPage(
true);
21127 public function addTOC($page=
'', $numbersfont=
'', $filler=
'.', $toc_name=
'TOC', $style=
'', $color=array(0,0,0)) {
21128 $fontsize = $this->FontSizePt;
21129 $fontfamily = $this->FontFamily;
21130 $fontstyle = $this->FontStyle;
21131 $w = $this->w - $this->lMargin - $this->rMargin;
21132 $spacer = $this->GetStringWidth(chr(32)) * 4;
21133 $lmargin = $this->lMargin;
21134 $rmargin = $this->rMargin;
21135 $x_start = $this->GetX();
21136 $page_first = $this->page;
21137 $current_page = $this->page;
21138 $page_fill_start =
false;
21139 $page_fill_end =
false;
21140 $current_column = $this->current_column;
21142 $numbersfont = $this->default_monospaced_font;
21155 $this->SetFont($numbersfont, $fontstyle, $fontsize);
21156 $numwidth = $this->GetStringWidth(
'00000');
21158 foreach ($this->outlines as $key => $outline) {
21160 if (($this->page > $page_first) AND ($outline[
'p'] >= $this->numpages)) {
21161 $outline[
'p'] += ($this->page - $page_first);
21170 if ($outline[
'l'] == 0) {
21171 $this->SetFont($fontfamily, $outline[
's'].
'B', $fontsize);
21173 $this->SetFont($fontfamily, $outline[
's'], $fontsize - $outline[
'l']);
21175 $this->SetTextColorArray($outline[
'c']);
21177 $this->checkPageBreak((2 * $this->FontSize * $this->cell_height_ratio));
21179 if (($this->page == $current_page) AND ($this->current_column == $current_column)) {
21180 $this->lMargin = $lmargin;
21181 $this->rMargin = $rmargin;
21183 if ($this->current_column != $current_column) {
21185 $x_start = $this->w - $this->columns[$this->current_column][
'x'];
21187 $x_start = $this->columns[$this->current_column][
'x'];
21190 $lmargin = $this->lMargin;
21191 $rmargin = $this->rMargin;
21192 $current_page = $this->page;
21193 $current_column = $this->current_column;
21195 $this->SetX($x_start);
21196 $indent = ($spacer * $outline[
'l']);
21198 $this->x -= $indent;
21199 $this->rMargin = $this->w - $this->x;
21201 $this->x += $indent;
21202 $this->lMargin = $this->x;
21204 $link = $this->AddLink();
21205 $this->SetLink($link, $outline[
'y'], $outline[
'p']);
21208 $txt =
' '.$outline[
't'];
21210 $txt = $outline[
't'].
' ';
21212 $this->Write(0,
$txt, $link,
false, $aligntext,
false, 0,
false,
false, 0, $numwidth,
'');
21214 $tw = $this->x - $this->lMargin;
21216 $tw = $this->w - $this->rMargin - $this->x;
21218 $this->SetFont($numbersfont, $fontstyle, $fontsize);
21220 $pagenum = $outline[
'p'];
21223 $pagenum =
'{#'.($outline[
'p']).
'}';
21224 if ($this->isUnicodeFont()) {
21225 $pagenum =
'{'.$pagenum.
'}';
21227 $maxpage = max($maxpage, $outline[
'p']);
21229 $fw = ($tw - $this->GetStringWidth($pagenum.$filler));
21230 $numfills = floor($fw / $this->GetStringWidth($filler));
21231 if ($numfills > 0) {
21232 $rowfill = str_repeat($filler, $numfills);
21237 $pagenum = $pagenum.$gap.$rowfill;
21239 $pagenum = $rowfill.$gap.$pagenum;
21242 $this->Cell($tw, 0, $pagenum, 0, 1, $alignnum, 0, $link, 0);
21244 $page_last = $this->getPage();
21245 $numpages = ($page_last - $page_first + 1);
21247 if ($this->booklet) {
21249 $page_fill_start = ((($page_first % 2) == 0) XOR (($page % 2) == 0));
21250 $page_fill_end = (!((($numpages % 2) == 0) XOR ($page_fill_start)));
21251 if ($page_fill_start) {
21257 if ($page_fill_end) {
21264 $maxpage = max($maxpage, $page_last);
21266 for ($p = $page_first; $p <= $page_last; ++$p) {
21268 $temppage = $this->getPageBuffer($p);
21269 for (
$n = 1;
$n <= $maxpage; ++
$n) {
21273 $pnalias = $this->getInternalPageNumberAliases($a);
21275 if ((
$n >= $page) AND ($n <= $this->numpages)) {
21276 $np =
$n + $numpages;
21283 foreach ($pnalias[
'u'] as $u) {
21284 $sfill = str_repeat($filler, max(0, (strlen($u) - strlen($nu.
' '))));
21286 $nr = $nu.TCPDF_FONTS::UTF8ToUTF16BE(
' '.$sfill,
false, $this->isunicode, $this->CurrentFont);
21290 $temppage = str_replace($u, $nr, $temppage);
21292 foreach ($pnalias[
'a'] as $a) {
21293 $sfill = str_repeat($filler, max(0, (strlen($a) - strlen($na.
' '))));
21295 $nr = $na.
' '.$sfill;
21297 $nr = $sfill.
' '.$na;
21299 $temppage = str_replace($a, $nr, $temppage);
21303 $this->setPageBuffer($p, $temppage);
21306 $this->Bookmark($toc_name, 0, 0, $page_first, $style, $color);
21307 if ($page_fill_start) {
21308 $this->movePage($page_last, $page_first);
21310 for ($i = 0; $i < $numpages; ++$i) {
21311 $this->movePage($page_last, $page);
21332 public function addHTMLTOC($page=
'', $toc_name=
'TOC', $templates=array(), $correct_align=
true, $style=
'', $color=array(0,0,0)) {
21334 $prev_htmlLinkColorArray = $this->htmlLinkColorArray;
21335 $prev_htmlLinkFontStyle = $this->htmlLinkFontStyle;
21337 $this->htmlLinkColorArray = array();
21338 $this->htmlLinkFontStyle =
'';
21339 $page_first = $this->getPage();
21340 $page_fill_start =
false;
21341 $page_fill_end =
false;
21343 $current_font = $this->FontFamily;
21344 foreach ($templates as $level => $html) {
21345 $dom = $this->getHtmlDomArray($html);
21346 foreach ($dom as $key => $value) {
21347 if ($value[
'value'] ==
'#TOC_PAGE_NUMBER#') {
21348 $this->SetFont($dom[($key - 1)][
'fontname']);
21349 $templates[
'F'.$level] = $this->isUnicodeFont();
21353 $this->SetFont($current_font);
21355 foreach ($this->outlines as $key => $outline) {
21357 $row = $templates[$outline[
'l']];
21359 $pagenum = $outline[
'p'];
21362 $pagenum =
'{#'.($outline[
'p']).
'}';
21363 if ($templates[
'F'.$outline[
'l']]) {
21364 $pagenum =
'{'.$pagenum.
'}';
21366 $maxpage = max($maxpage, $outline[
'p']);
21369 $row = str_replace(
'#TOC_DESCRIPTION#', $outline[
't'],
$row);
21370 $row = str_replace(
'#TOC_PAGE_NUMBER#', $pagenum,
$row);
21372 $row =
'<a href="#'.$outline[
'p'].
','.$outline[
'y'].
'">'.
$row.
'</a>';
21374 $this->writeHTML(
$row,
false,
false,
true,
false,
'');
21377 $this->htmlLinkColorArray = $prev_htmlLinkColorArray;
21378 $this->htmlLinkFontStyle = $prev_htmlLinkFontStyle;
21380 $page_last = $this->getPage();
21381 $numpages = ($page_last - $page_first + 1);
21383 if ($this->booklet) {
21385 $page_fill_start = ((($page_first % 2) == 0) XOR (($page % 2) == 0));
21386 $page_fill_end = (!((($numpages % 2) == 0) XOR ($page_fill_start)));
21387 if ($page_fill_start) {
21393 if ($page_fill_end) {
21400 $maxpage = max($maxpage, $page_last);
21402 for ($p = $page_first; $p <= $page_last; ++$p) {
21404 $temppage = $this->getPageBuffer($p);
21405 for (
$n = 1;
$n <= $maxpage; ++
$n) {
21409 $pnalias = $this->getInternalPageNumberAliases($a);
21412 $np =
$n + $numpages;
21419 foreach ($pnalias[
'u'] as $u) {
21420 if ($correct_align) {
21421 $sfill = str_repeat($filler, (strlen($u) - strlen($nu.
' ')));
21423 $nr = $nu.TCPDF_FONTS::UTF8ToUTF16BE(
' '.$sfill,
false, $this->isunicode, $this->CurrentFont);
21430 $temppage = str_replace($u, $nr, $temppage);
21432 foreach ($pnalias[
'a'] as $a) {
21433 if ($correct_align) {
21434 $sfill = str_repeat($filler, (strlen($a) - strlen($na.
' ')));
21436 $nr = $na.
' '.$sfill;
21438 $nr = $sfill.
' '.$na;
21443 $temppage = str_replace($a, $nr, $temppage);
21447 $this->setPageBuffer($p, $temppage);
21450 $this->Bookmark($toc_name, 0, 0, $page_first, $style, $color);
21451 if ($page_fill_start) {
21452 $this->movePage($page_last, $page_first);
21454 for ($i = 0; $i < $numpages; ++$i) {
21455 $this->movePage($page_last, $page);
21466 if (isset($this->objcopy)) {
21468 $this->commitTransaction();
21471 $this->start_transaction_page = $this->page;
21472 $this->start_transaction_y = $this->y;
21483 if (isset($this->objcopy)) {
21484 $this->objcopy->_destroy(
true,
true);
21485 unset($this->objcopy);
21497 if (isset($this->objcopy)) {
21498 if (isset($this->objcopy->diskcache) AND $this->objcopy->diskcache) {
21500 foreach ($this->objcopy->cache_file_length as
$file => $length) {
21502 $handle = fopen(
$file,
'r+');
21503 ftruncate($handle, $length);
21506 $this->_destroy(
true,
true);
21508 $objvars = get_object_vars($this->objcopy);
21509 foreach ($objvars as $key => $value) {
21510 $this->$key = $value;
21513 return $this->objcopy;
21529 $this->columns = array();
21530 if ($numcols < 2) {
21532 $this->columns = array();
21535 $maxwidth = ($this->w - $this->original_lMargin - $this->original_rMargin) / $numcols;
21536 if (($width == 0) OR ($width > $maxwidth)) {
21537 $width = $maxwidth;
21543 $space = (($this->w - $this->original_lMargin - $this->original_rMargin - ($numcols * $width)) / ($numcols - 1));
21545 for ($i = 0; $i < $numcols; ++$i) {
21546 $this->columns[$i] = array(
'w' => $width,
's' =>
$space,
'y' => $y);
21549 $this->num_columns = $numcols;
21550 $this->current_column = 0;
21551 $this->column_start_page = $this->page;
21552 $this->selectColumn(0);
21561 $this->lMargin = $this->original_lMargin;
21562 $this->rMargin = $this->original_rMargin;
21563 $this->setEqualColumns();
21575 $this->num_columns = count(
$columns);
21576 $this->current_column = 0;
21577 $this->column_start_page = $this->page;
21578 $this->selectColumn(0);
21588 if (is_string($col)) {
21589 $col = $this->current_column;
21590 } elseif ($col >= $this->num_columns) {
21593 $xshift = array(
'x' => 0,
's' => array(
'H' => 0,
'V' => 0),
'p' => array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0));
21594 $enable_thead =
false;
21595 if ($this->num_columns > 1) {
21596 if ($col != $this->current_column) {
21598 if ($this->column_start_page == $this->page) {
21599 $this->y = $this->columns[$col][
'y'];
21601 $this->y = $this->tMargin;
21604 if (($this->page > $this->maxselcol[
'page']) OR (($this->page == $this->maxselcol[
'page']) AND ($col > $this->maxselcol[
'column']))) {
21605 $enable_thead =
true;
21606 $this->maxselcol[
'page'] = $this->page;
21607 $this->maxselcol[
'column'] = $col;
21610 $xshift = $this->colxshift;
21612 $listindent = ($this->listindentlevel * $this->listindent);
21615 for ($i = 0; $i < $col; ++$i) {
21616 $colpos += ($this->columns[$i][
'w'] + $this->columns[$i][
's']);
21619 $x = $this->w - $this->original_rMargin - $colpos;
21620 $this->rMargin = ($this->w - $x + $listindent);
21621 $this->lMargin = ($x - $this->columns[$col][
'w']);
21622 $this->x = $x - $listindent;
21624 $x = $this->original_lMargin + $colpos;
21625 $this->lMargin = ($x + $listindent);
21626 $this->rMargin = ($this->w - $x - $this->columns[$col][
'w']);
21627 $this->x = $x + $listindent;
21629 $this->columns[$col][
'x'] = $x;
21631 $this->current_column = $col;
21633 $this->newline =
true;
21636 if ($enable_thead) {
21638 $this->writeHTML($this->thead,
false,
false,
false,
false,
'');
21639 $this->y += $xshift[
's'][
'V'];
21641 if (!isset($this->columns[$col][
'th'])) {
21642 $this->columns[$col][
'th'] = array();
21644 $this->columns[$col][
'th'][
'\''.$this->page.
'\''] = $this->y;
21646 } elseif (isset($this->columns[$col][
'th'][
'\''.$this->page.
'\''])) {
21647 $this->y = $this->columns[$col][
'th'][
'\''.$this->page.
'\''];
21652 $this->rMargin += $xshift[
'x'];
21653 $this->x -= ($xshift[
'x'] + $xshift[
'p'][
'R']);
21655 $this->lMargin += $xshift[
'x'];
21656 $this->x += $xshift[
'x'] + $xshift[
'p'][
'L'];
21667 return $this->current_column;
21677 return $this->num_columns;
21694 if ($fill ===
true) {
21696 if ($clip ===
true) {
21698 $textrendermode = 6;
21701 $textrendermode = 2;
21703 $textstrokewidth = $stroke;
21705 if ($clip ===
true) {
21707 $textrendermode = 4;
21710 $textrendermode = 0;
21715 if ($clip ===
true) {
21717 $textrendermode = 5;
21720 $textrendermode = 1;
21722 $textstrokewidth = $stroke;
21724 if ($clip ===
true) {
21726 $textrendermode = 7;
21729 $textrendermode = 3;
21733 $this->textrendermode = $textrendermode;
21734 $this->textstrokewidth = $stroke;
21743 public function setTextShadow($params=array(
'enabled'=>
false,
'depth_w'=>0,
'depth_h'=>0,
'color'=>
false,
'opacity'=>1,
'blend_mode'=>
'Normal')) {
21744 if (isset($params[
'enabled'])) {
21745 $this->txtshadow[
'enabled'] = $params[
'enabled']?
true:
false;
21747 $this->txtshadow[
'enabled'] =
false;
21749 if (isset($params[
'depth_w'])) {
21750 $this->txtshadow[
'depth_w'] = floatval($params[
'depth_w']);
21752 $this->txtshadow[
'depth_w'] = 0;
21754 if (isset($params[
'depth_h'])) {
21755 $this->txtshadow[
'depth_h'] = floatval($params[
'depth_h']);
21757 $this->txtshadow[
'depth_h'] = 0;
21759 if (isset($params[
'color']) AND ($params[
'color'] !==
false) AND is_array($params[
'color'])) {
21760 $this->txtshadow[
'color'] = $params[
'color'];
21762 $this->txtshadow[
'color'] = $this->strokecolor;
21764 if (isset($params[
'opacity'])) {
21765 $this->txtshadow[
'opacity'] = min(1, max(0, floatval($params[
'opacity'])));
21767 $this->txtshadow[
'opacity'] = 1;
21769 if (isset($params[
'blend_mode']) AND in_array($params[
'blend_mode'], array(
'Normal',
'Multiply',
'Screen',
'Overlay',
'Darken',
'Lighten',
'ColorDodge',
'ColorBurn',
'HardLight',
'SoftLight',
'Difference',
'Exclusion',
'Hue',
'Saturation',
'Color',
'Luminosity'))) {
21770 $this->txtshadow[
'blend_mode'] = $params[
'blend_mode'];
21772 $this->txtshadow[
'blend_mode'] =
'Normal';
21774 if ((($this->txtshadow[
'depth_w'] == 0) AND ($this->txtshadow[
'depth_h'] == 0)) OR ($this->txtshadow[
'opacity'] == 0)) {
21775 $this->txtshadow[
'enabled'] =
false;
21786 return $this->txtshadow;
21803 protected function hyphenateWord($word, $patterns, $dictionary=array(), $leftmin=1, $rightmin=2, $charmin=1, $charmax=8) {
21804 $hyphenword = array();
21805 $numchars = count($word);
21806 if ($numchars <= $charmin) {
21811 $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})(\]?)$/';
21812 if (preg_match($pattern, $word_string) > 0) {
21816 $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})(\]?)$/';
21817 if (preg_match($pattern, $word_string) > 0) {
21821 if (isset($dictionary[$word_string])) {
21825 $tmpword = array_merge(array(95), $word, array(95));
21826 $tmpnumchars = $numchars + 2;
21827 $maxpos = $tmpnumchars - $charmin;
21828 for ($pos = 0; $pos < $maxpos; ++$pos) {
21829 $imax = min(($tmpnumchars - $pos), $charmax);
21830 for ($i = $charmin; $i <= $imax; ++$i) {
21832 if (isset($patterns[$subword])) {
21834 $pattern_length = count($pattern);
21836 for ($j = 0; $j < $pattern_length; ++$j) {
21838 if (($pattern[$j] >= 48) AND ($pattern[$j] <= 57)) {
21842 $zero = $pos + $j - $digits;
21844 if (!isset($hyphenword[$zero]) OR ($hyphenword[$zero] != $pattern[$j])) {
21854 $maxpos = $numchars - $rightmin;
21855 for ($i = $leftmin; $i <= $maxpos; ++$i) {
21856 if (isset($hyphenword[$i]) AND (($hyphenword[$i] % 2) != 0)) {
21858 array_splice($word, $i + $inserted, 0, 173);
21879 public function hyphenateText($text, $patterns, $dictionary=array(), $leftmin=1, $rightmin=2, $charmin=1, $charmax=8) {
21880 $text = $this->unhtmlentities($text);
21884 if (!is_array($patterns)) {
21890 foreach ($unichars as $char) {
21898 $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
21902 if (chr($char) ==
'<') {
21905 } elseif ($intag AND (chr($char) ==
'>')) {
21913 $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
21926 $this->rasterize_vector_images = $mode;
21937 if ($this->pdfa_mode) {
21938 $this->font_subsetting =
false;
21940 $this->font_subsetting = $enable ?
true :
false;
21952 return $this->font_subsetting;
21965 return preg_replace(
'/^'.$this->re_space[
'p'].
'+/'.$this->re_space[
'm'], $replace, $str);
21978 return preg_replace(
'/'.$this->re_space[
'p'].
'+$/'.$this->re_space[
'm'], $replace, $str);
21991 $str = $this->stringLeftTrim($str, $replace);
21992 $str = $this->stringRightTrim($str, $replace);
22004 return (($this->CurrentFont[
'type'] ==
'TrueTypeUnicode') OR ($this->CurrentFont[
'type'] ==
'cidfont0'));
22017 $fontfamily = preg_replace(
'/[^a-z0-9_\,]/',
'', strtolower($fontfamily));
22019 $fontslist = preg_split(
'/[,]/', $fontfamily);
22021 foreach ($fontslist as $font) {
22023 $font = preg_replace(
'/italic$/',
'I', $font);
22024 $font = preg_replace(
'/oblique$/',
'I', $font);
22025 $font = preg_replace(
'/bold([I]?)$/',
'B\\1', $font);
22027 $pattern = array();
22028 $replacement = array();
22029 $pattern[] =
'/^serif|^cursive|^fantasy|^timesnewroman/';
22030 $replacement[] =
'times';
22031 $pattern[] =
'/^sansserif/';
22032 $replacement[] =
'helvetica';
22033 $pattern[] =
'/^monospace/';
22034 $replacement[] =
'courier';
22035 $font = preg_replace($pattern, $replacement, $font);
22036 if (in_array(strtolower($font), $this->fontlist) OR in_array($font, $this->fontkeys)) {
22041 return $this->CurrentFont[
'fontkey'];
22059 if ($this->inxobj) {
22063 $this->inxobj =
true;
22066 $this->xobjid =
'XT'.$this->n;
22068 $this->xobjects[$this->xobjid] = array(
'n' => $this->
n);
22070 $this->xobjects[$this->xobjid][
'gvars'] = $this->getGraphicVars();
22072 $this->xobjects[$this->xobjid][
'intmrk'] = 0;
22073 $this->xobjects[$this->xobjid][
'transfmrk'] = array();
22074 $this->xobjects[$this->xobjid][
'outdata'] =
'';
22075 $this->xobjects[$this->xobjid][
'xobjects'] = array();
22076 $this->xobjects[$this->xobjid][
'images'] = array();
22077 $this->xobjects[$this->xobjid][
'fonts'] = array();
22078 $this->xobjects[$this->xobjid][
'annotations'] = array();
22079 $this->xobjects[$this->xobjid][
'extgstates'] = array();
22080 $this->xobjects[$this->xobjid][
'gradients'] = array();
22081 $this->xobjects[$this->xobjid][
'spot_colors'] = array();
22083 $this->num_columns = 1;
22084 $this->current_column = 0;
22085 $this->SetAutoPageBreak(
false);
22086 if (($w ===
'') OR ($w <= 0)) {
22087 $w = $this->w - $this->lMargin - $this->rMargin;
22089 if (($h ===
'') OR ($h <= 0)) {
22090 $h = $this->h - $this->tMargin - $this->bMargin;
22092 $this->xobjects[$this->xobjid][
'x'] = 0;
22093 $this->xobjects[$this->xobjid][
'y'] = 0;
22094 $this->xobjects[$this->xobjid][
'w'] = $w;
22095 $this->xobjects[$this->xobjid][
'h'] = $h;
22098 $this->wPt = $this->w * $this->k;
22099 $this->hPt = $this->h * $this->k;
22100 $this->fwPt = $this->wPt;
22101 $this->fhPt = $this->hPt;
22104 $this->lMargin = 0;
22105 $this->rMargin = 0;
22106 $this->tMargin = 0;
22107 $this->bMargin = 0;
22109 $this->xobjects[$this->xobjid][
'group'] = $group;
22110 return $this->xobjid;
22124 if (!$this->inxobj) {
22128 $this->inxobj =
false;
22130 $this->setGraphicVars($this->xobjects[$this->xobjid][
'gvars'],
true);
22131 return $this->xobjid;
22152 public function printTemplate($id, $x=
'', $y=
'', $w=0, $h=0, $align=
'', $palign=
'', $fitonpage=
false) {
22153 if ($this->state != 2) {
22156 if (!isset($this->xobjects[$id])) {
22157 $this->Error(
'The XObject Template \''.$id.
'\' doesn\
't exist!');
22159 if ($this->inxobj) {
22160 if ($id == $this->xobjid) {
22162 $this->endTemplate();
22165 $this->xobjects[$this->xobjid][
'xobjects'][$id] = $this->xobjects[$id];
22176 list($x, $y) = $this->checkPageRegions($h, $x, $y);
22177 $ow = $this->xobjects[$id][
'w'];
22178 $oh = $this->xobjects[$id][
'h'];
22180 if (($w <= 0) AND ($h <= 0)) {
22183 } elseif ($w <= 0) {
22184 $w = $h * $ow / $oh;
22185 } elseif ($h <= 0) {
22186 $h = $w * $oh / $ow;
22189 list($w, $h, $x, $y) = $this->fitBlock($w, $h, $x, $y, $fitonpage);
22194 if ($palign ==
'L') {
22195 $xt = $this->lMargin;
22196 } elseif ($palign ==
'C') {
22197 $xt = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
22198 } elseif ($palign ==
'R') {
22199 $xt = $this->w - $this->rMargin - $w;
22205 if ($palign ==
'L') {
22206 $xt = $this->lMargin;
22207 } elseif ($palign ==
'C') {
22208 $xt = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
22209 } elseif ($palign ==
'R') {
22210 $xt = $this->w - $this->rMargin - $w;
22217 $this->StartTransform();
22219 $sx = ($w / $this->xobjects[$id][
'w']);
22220 $sy = ($h / $this->xobjects[$id][
'h']);
22226 $tm[4] = $xt * $this->k;
22227 $tm[5] = ($this->h - $h - $y) * $this->k;
22228 $this->Transform($tm);
22230 $this->_out(
'/'.$id.
' Do');
22231 $this->StopTransform();
22233 if (!empty($this->xobjects[$id][
'annotations'])) {
22234 foreach ($this->xobjects[$id][
'annotations'] as $annot) {
22237 $ax = ($coordlt[4] / $this->k);
22238 $ay = ($this->h - $h - ($coordlt[5] / $this->k));
22240 $aw = ($coordrb[4] / $this->k) - $ax;
22241 $ah = ($this->h - $h - ($coordrb[5] / $this->k)) - $ay;
22242 $this->Annotation($ax, $ay, $aw, $ah, $annot[
'text'], $annot[
'opt'], $annot[
'spaces']);
22253 $this->y = $y + round($h/2);
22263 $this->SetY($rb_y);
22280 $this->font_stretching = $perc;
22291 return $this->font_stretching;
22302 $this->font_spacing = $spacing;
22313 return $this->font_spacing;
22325 return $this->page_regions;
22341 $this->page_regions = array();
22343 foreach ($regions as $data) {
22344 $this->addPageRegion($data);
22360 if (!isset($region[
'page']) OR empty($region[
'page'])) {
22361 $region[
'page'] = $this->page;
22363 if (isset($region[
'xt']) AND isset($region[
'xb']) AND ($region[
'xt'] > 0) AND ($region[
'xb'] > 0)
22364 AND isset($region[
'yt']) AND isset($region[
'yb']) AND ($region[
'yt'] >= 0) AND ($region[
'yt'] < $region[
'yb'])
22365 AND isset($region[
'side']) AND (($region[
'side'] ==
'L') OR ($region[
'side'] ==
'R'))) {
22366 $this->page_regions[] = $region;
22379 if (isset($this->page_regions[$key])) {
22380 unset($this->page_regions[$key]);
22404 if (!$this->check_page_regions OR empty($this->page_regions)) {
22406 return array($x, $y);
22409 $h = ($this->FontSize * $this->cell_height_ratio) + $this->cell_padding[
'T'] + $this->cell_padding[
'B'];
22412 if ($this->checkPageBreak($h, $y)) {
22417 if ($this->num_columns > 1) {
22419 $this->lMargin = ($this->columns[$this->current_column][
'x'] - $this->columns[$this->current_column][
'w']);
22421 $this->rMargin = ($this->w - $this->columns[$this->current_column][
'x'] - $this->columns[$this->current_column][
'w']);
22425 $this->lMargin = max($this->clMargin, $this->original_lMargin);
22427 $this->rMargin = max($this->crMargin, $this->original_rMargin);
22431 foreach ($this->page_regions as $regid => $regdata) {
22432 if ($regdata[
'page'] == $this->page) {
22434 if (($y > ($regdata[
'yt'] - $h)) AND ($y <= $regdata[
'yb'])) {
22436 $minv = ($regdata[
'xb'] - $regdata[
'xt']) / ($regdata[
'yb'] - $regdata[
'yt']);
22437 $yt = max($y, $regdata[
'yt']);
22438 $yb = min(($yt + $h), $regdata[
'yb']);
22439 $xt = (($yt - $regdata[
'yt']) * $minv) + $regdata[
'xt'];
22440 $xb = (($yb - $regdata[
'yt']) * $minv) + $regdata[
'xt'];
22441 if ($regdata[
'side'] ==
'L') {
22442 $new_margin = max($xt, $xb);
22443 if ($this->lMargin < $new_margin) {
22446 $this->lMargin = max(0, $new_margin);
22448 if ($x < $new_margin) {
22451 if ($new_margin > ($this->w - $this->rMargin)) {
22453 $y = $regdata[
'yb'] - $h;
22457 } elseif ($regdata[
'side'] ==
'R') {
22458 $new_margin = min($xt, $xb);
22459 if (($this->w - $this->rMargin) > $new_margin) {
22462 $this->rMargin = max(0, ($this->w - $new_margin));
22464 if ($x > $new_margin) {
22467 if ($new_margin > $this->lMargin) {
22469 $y = $regdata[
'yb'] - $h;
22477 return array($x, $y);
22499 public function ImageSVG(
$file, $x=
'', $y=
'', $w=0, $h=0, $link=
'', $align=
'', $palign=
'', $border=0, $fitonpage=
false) {
22500 if ($this->state != 2) {
22503 if ($this->rasterize_vector_images AND ($w > 0) AND ($h > 0)) {
22505 return $this->Image(
$file, $x, $y, $w, $h,
'SVG', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false,
false);
22507 if (
$file{0} ===
'@') {
22508 $this->svgdir =
'';
22509 $svgdata = substr(
$file, 1);
22511 $this->svgdir = dirname(
$file);
22512 $svgdata = file_get_contents(
$file);
22514 if ($svgdata ===
false) {
22515 $this->Error(
'SVG file not found: '.
$file);
22524 list($x, $y) = $this->checkPageRegions($h, $x, $y);
22530 $aspect_ratio_align =
'xMidYMid';
22531 $aspect_ratio_ms =
'meet';
22534 preg_match(
'/<svg([^>]*)>/si', $svgdata, $regs);
22535 if (isset($regs[1]) AND !empty($regs[1])) {
22537 if (preg_match(
'/[\s]+x[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22538 $ox = $this->getHTMLUnitToUnits($tmp[1], 0, $this->svgunit,
false);
22541 if (preg_match(
'/[\s]+y[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22542 $oy = $this->getHTMLUnitToUnits($tmp[1], 0, $this->svgunit,
false);
22545 if (preg_match(
'/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22546 $ow = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit,
false);
22549 if (preg_match(
'/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22550 $oh = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit,
false);
22553 $view_box = array();
22554 if (preg_match(
'/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.\-]+)[\s]+([0-9\.\-]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $regs[1], $tmp)) {
22555 if (count($tmp) == 5) {
22557 foreach ($tmp as $key => $val) {
22558 $view_box[$key] = $this->getHTMLUnitToUnits($val, 0, $this->svgunit,
false);
22560 $ox = $view_box[0];
22561 $oy = $view_box[1];
22565 if (preg_match(
'/[\s]+preserveAspectRatio[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22566 $aspect_ratio = preg_split(
'/[\s]+/si', $tmp[1]);
22567 switch (count($aspect_ratio)) {
22569 $aspect_ratio_align = $aspect_ratio[1];
22570 $aspect_ratio_ms = $aspect_ratio[2];
22574 $aspect_ratio_align = $aspect_ratio[0];
22575 $aspect_ratio_ms = $aspect_ratio[1];
22579 $aspect_ratio_align = $aspect_ratio[0];
22580 $aspect_ratio_ms =
'meet';
22588 if (($w <= 0) AND ($h <= 0)) {
22592 } elseif ($w <= 0) {
22593 $w = $h * $ow / $oh;
22594 } elseif ($h <= 0) {
22595 $h = $w * $oh / $ow;
22598 list($w, $h, $x, $y) = $this->fitBlock($w, $h, $x, $y, $fitonpage);
22599 if ($this->rasterize_vector_images) {
22601 return $this->Image(
$file, $x, $y, $w, $h,
'SVG', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false,
false);
22604 $this->img_rb_y = $y + $h;
22607 if ($palign ==
'L') {
22608 $ximg = $this->lMargin;
22609 } elseif ($palign ==
'C') {
22610 $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
22611 } elseif ($palign ==
'R') {
22612 $ximg = $this->w - $this->rMargin - $w;
22616 $this->img_rb_x = $ximg;
22618 if ($palign ==
'L') {
22619 $ximg = $this->lMargin;
22620 } elseif ($palign ==
'C') {
22621 $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
22622 } elseif ($palign ==
'R') {
22623 $ximg = $this->w - $this->rMargin - $w;
22627 $this->img_rb_x = $ximg + $w;
22630 $gvars = $this->getGraphicVars();
22632 $svgoffset_x = ($ximg - $ox) * $this->k;
22633 $svgoffset_y = -($y - $oy) * $this->k;
22634 if (isset($view_box[2]) AND ($view_box[2] > 0) AND ($view_box[3] > 0)) {
22635 $ow = $view_box[2];
22636 $oh = $view_box[3];
22645 $svgscale_x = $w / $ow;
22646 $svgscale_y = $h / $oh;
22648 if ($aspect_ratio_align !=
'none') {
22650 $svgscale_old_x = $svgscale_x;
22651 $svgscale_old_y = $svgscale_y;
22653 if ($aspect_ratio_ms ==
'slice') {
22655 if ($svgscale_x > $svgscale_y) {
22656 $svgscale_y = $svgscale_x;
22657 } elseif ($svgscale_x < $svgscale_y) {
22658 $svgscale_x = $svgscale_y;
22662 if ($svgscale_x < $svgscale_y) {
22663 $svgscale_y = $svgscale_x;
22664 } elseif ($svgscale_x > $svgscale_y) {
22665 $svgscale_x = $svgscale_y;
22669 switch (substr($aspect_ratio_align, 1, 3)) {
22675 $svgoffset_x += (($w * $this->k) - ($ow * $this->k * $svgscale_x));
22680 $svgoffset_x += ((($w * $this->k) - ($ow * $this->k * $svgscale_x)) / 2);
22685 switch (substr($aspect_ratio_align, 5)) {
22691 $svgoffset_y -= (($h * $this->k) - ($oh * $this->k * $svgscale_y));
22696 $svgoffset_y -= ((($h * $this->k) - ($oh * $this->k * $svgscale_y)) / 2);
22702 $page_break_mode = $this->AutoPageBreak;
22703 $page_break_margin = $this->getBreakMargin();
22704 $cell_padding = $this->cell_padding;
22705 $this->SetCellPadding(0);
22706 $this->SetAutoPageBreak(
false);
22708 $this->_out(
'q'.$this->epsmarker);
22710 $this->Rect($x, $y, $w, $h,
'CNZ', array(), array());
22712 $e = $ox * $this->k * (1 - $svgscale_x);
22713 $f = ($this->h - $oy) * $this->k * (1 - $svgscale_y);
22714 $this->_out(sprintf(
'%F %F %F %F %F %F cm', $svgscale_x, 0, 0, $svgscale_y, ($e + $svgoffset_x), ($f + $svgoffset_y)));
22716 $this->parser = xml_parser_create(
'UTF-8');
22718 xml_set_object($this->parser, $this);
22720 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
22722 xml_set_element_handler($this->parser,
'startSVGElementHandler',
'endSVGElementHandler');
22724 xml_set_character_data_handler($this->parser,
'segSVGContentHandler');
22726 if (!xml_parse($this->parser, $svgdata)) {
22727 $error_message = sprintf(
'SVG Error: %s at line %d', xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser));
22728 $this->Error($error_message);
22731 xml_parser_free($this->parser);
22733 $this->_out($this->epsmarker.
'Q');
22735 $this->setGraphicVars($gvars);
22736 $this->lasth = $gvars[
'lasth'];
22737 if (!empty($border)) {
22745 $this->Cell($w, $h,
'', $border, 0,
'', 0,
'', 0,
true);
22750 $this->Link($ximg, $y, $w, $h, $link, 0);
22756 $this->x = $this->img_rb_x;
22760 $this->y = $y + round($h/2);
22761 $this->x = $this->img_rb_x;
22765 $this->y = $this->img_rb_y;
22766 $this->x = $this->img_rb_x;
22770 $this->SetY($this->img_rb_y);
22775 $this->x = $gvars[
'x'];
22776 $this->y = $gvars[
'y'];
22777 $this->page = $gvars[
'page'];
22778 $this->current_column = $gvars[
'current_column'];
22779 $this->tMargin = $gvars[
'tMargin'];
22780 $this->bMargin = $gvars[
'bMargin'];
22781 $this->w = $gvars[
'w'];
22782 $this->h = $gvars[
'h'];
22783 $this->wPt = $gvars[
'wPt'];
22784 $this->hPt = $gvars[
'hPt'];
22785 $this->fwPt = $gvars[
'fwPt'];
22786 $this->fhPt = $gvars[
'fhPt'];
22790 $this->endlinex = $this->img_rb_x;
22792 $this->SetAutoPageBreak($page_break_mode, $page_break_margin);
22793 $this->cell_padding = $cell_padding;
22808 $e = $this->getHTMLUnitToUnits($tm[4], 1, $this->svgunit,
false) * $this->k;
22809 $f = -$this->getHTMLUnitToUnits($tm[5], 1, $this->svgunit,
false) * $this->k;
22811 $y = $this->h * $this->k;
22812 $e = ($x * (1 - $a)) - ($y * $c) + $e;
22813 $f = ($y * (1 -
$d)) - ($x * $b) + $f;
22814 return array($a, $b, $c,
$d, $e, $f);
22824 $this->Transform($this->convertSVGtMatrix($tm));
22842 protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1, $clip_function=
'', $clip_params=array()) {
22843 if ($this->state != 2) {
22847 $minlen = (0.01 / $this->k);
22848 if (!isset($svgstyle[
'opacity'])) {
22853 if (preg_match(
'/url\([\s]*\#([^\)]*)\)/si', $svgstyle[
'clip-path'], $regs)) {
22854 $clip_path = $this->svgclippaths[$regs[1]];
22855 foreach ($clip_path as $cp) {
22856 $this->startSVGElementHandler(
'clip-path', $cp[
'name'], $cp[
'attribs'], $cp[
'tm']);
22860 if ($svgstyle[
'opacity'] != 1) {
22861 $this->setAlpha($svgstyle[
'opacity'],
'Normal', $svgstyle[
'opacity'],
false);
22865 $this->SetFillColorArray($fill_color);
22868 $this->SetTextColorArray($text_color);
22870 if (preg_match(
'/rect\(([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)\)/si', $svgstyle[
'clip'], $regs)) {
22871 $top = (isset($regs[1])?$this->getHTMLUnitToUnits($regs[1], 0, $this->svgunit,
false):0);
22872 $right = (isset($regs[2])?$this->getHTMLUnitToUnits($regs[2], 0, $this->svgunit,
false):0);
22873 $bottom = (isset($regs[3])?$this->getHTMLUnitToUnits($regs[3], 0, $this->svgunit,
false):0);
22874 $left = (isset($regs[4])?$this->getHTMLUnitToUnits($regs[4], 0, $this->svgunit,
false):0);
22877 $cw = $w - $left - $right;
22878 $ch = $h - $top - $bottom;
22879 if ($svgstyle[
'clip-rule'] ==
'evenodd') {
22880 $clip_rule =
'CNZ';
22882 $clip_rule =
'CEO';
22884 $this->Rect($cx, $cy, $cw, $ch, $clip_rule, array(), array());
22888 if (preg_match(
'/url\([\s]*\#([^\)]*)\)/si', $svgstyle[
'fill'], $regs)) {
22890 $gradient = $this->svggradients[$regs[1]];
22891 if (isset($gradient[
'xref'])) {
22893 $newgradient = $this->svggradients[$gradient[
'xref']];
22894 $newgradient[
'coords'] = $gradient[
'coords'];
22895 $newgradient[
'mode'] = $gradient[
'mode'];
22896 $newgradient[
'gradientUnits'] = $gradient[
'gradientUnits'];
22897 if (isset($gradient[
'gradientTransform'])) {
22898 $newgradient[
'gradientTransform'] = $gradient[
'gradientTransform'];
22900 $gradient = $newgradient;
22905 if (!empty($clip_function) AND method_exists($this, $clip_function)) {
22906 $bbox = call_user_func_array(array($this, $clip_function), $clip_params);
22907 if (is_array($bbox) AND (count($bbox) == 4)) {
22908 list($x, $y, $w, $h) = $bbox;
22911 if ($gradient[
'mode'] ==
'measure') {
22912 if (isset($gradient[
'gradientTransform']) AND !empty($gradient[
'gradientTransform'])) {
22913 $gtm = $gradient[
'gradientTransform'];
22915 $xa = ($gtm[0] * $gradient[
'coords'][0]) + ($gtm[2] * $gradient[
'coords'][1]) + $gtm[4];
22916 $ya = ($gtm[1] * $gradient[
'coords'][0]) + ($gtm[3] * $gradient[
'coords'][1]) + $gtm[5];
22917 $xb = ($gtm[0] * $gradient[
'coords'][2]) + ($gtm[2] * $gradient[
'coords'][3]) + $gtm[4];
22918 $yb = ($gtm[1] * $gradient[
'coords'][2]) + ($gtm[3] * $gradient[
'coords'][3]) + $gtm[5];
22919 if (isset($gradient[
'coords'][4])) {
22920 $gradient[
'coords'][4] = sqrt(pow(($gtm[0] * $gradient[
'coords'][4]), 2) + pow(($gtm[1] * $gradient[
'coords'][4]), 2));
22922 $gradient[
'coords'][0] = $xa;
22923 $gradient[
'coords'][1] = $ya;
22924 $gradient[
'coords'][2] = $xb;
22925 $gradient[
'coords'][3] = $yb;
22928 $gradient[
'coords'][0] = $this->getHTMLUnitToUnits($gradient[
'coords'][0], 0, $this->svgunit,
false);
22929 $gradient[
'coords'][1] = $this->getHTMLUnitToUnits($gradient[
'coords'][1], 0, $this->svgunit,
false);
22930 $gradient[
'coords'][2] = $this->getHTMLUnitToUnits($gradient[
'coords'][2], 0, $this->svgunit,
false);
22931 $gradient[
'coords'][3] = $this->getHTMLUnitToUnits($gradient[
'coords'][3], 0, $this->svgunit,
false);
22932 if (isset($gradient[
'coords'][4])) {
22933 $gradient[
'coords'][4] = $this->getHTMLUnitToUnits($gradient[
'coords'][4], 0, $this->svgunit,
false);
22935 if ($w <= $minlen) {
22938 if ($h <= $minlen) {
22942 if ($gradient[
'gradientUnits'] ==
'objectBoundingBox') {
22944 $gradient[
'coords'][0] += $x;
22945 $gradient[
'coords'][1] += $y;
22946 $gradient[
'coords'][2] += $x;
22947 $gradient[
'coords'][3] += $y;
22950 $gradient[
'coords'][0] = (($gradient[
'coords'][0] - $x) / $w);
22951 $gradient[
'coords'][1] = (($gradient[
'coords'][1] - $y) / $h);
22952 $gradient[
'coords'][2] = (($gradient[
'coords'][2] - $x) / $w);
22953 $gradient[
'coords'][3] = (($gradient[
'coords'][3] - $y) / $h);
22954 if (isset($gradient[
'coords'][4])) {
22955 $gradient[
'coords'][4] /= $w;
22957 } elseif ($gradient[
'mode'] ==
'percentage') {
22958 foreach($gradient[
'coords'] as $key => $val) {
22959 $gradient[
'coords'][$key] = (intval($val) / 100);
22961 $gradient[
'coords'][$key] = 0;
22962 } elseif ($val > 1) {
22963 $gradient[
'coords'][$key] = 1;
22967 if (($gradient[
'type'] == 2) AND ($gradient[
'coords'][0] == $gradient[
'coords'][2]) AND ($gradient[
'coords'][1] == $gradient[
'coords'][3])) {
22969 $gradient[
'coords'][0] = 1;
22970 $gradient[
'coords'][1] = 0;
22971 $gradient[
'coords'][2] = 0.999;
22972 $gradient[
'coords'][3] = 0;
22975 $tmp = $gradient[
'coords'][1];
22976 $gradient[
'coords'][1] = $gradient[
'coords'][3];
22977 $gradient[
'coords'][3] = $tmp;
22979 if ($gradient[
'type'] == 3) {
22981 $cy = $this->h - $y - ($gradient[
'coords'][1] * ($w + $h));
22982 $this->_out(sprintf(
'%F 0 0 %F %F %F cm', ($w * $this->k), ($w * $this->k), ($x * $this->k), ($cy * $this->k)));
22984 $this->_out(sprintf(
'%F 0 0 %F %F %F cm', ($w * $this->k), ($h * $this->k), ($x * $this->k), (($this->h - ($y + $h)) * $this->k)));
22986 if (count($gradient[
'stops']) > 1) {
22987 $this->Gradient($gradient[
'type'], $gradient[
'coords'], $gradient[
'stops'], array(),
false);
22989 } elseif ($svgstyle[
'fill'] !=
'none') {
22991 if ($svgstyle[
'fill-opacity'] != 1) {
22992 $this->setAlpha($this->alpha[
'CA'],
'Normal', $svgstyle[
'fill-opacity'],
false);
22994 $this->SetFillColorArray($fill_color);
22995 if ($svgstyle[
'fill-rule'] ==
'evenodd') {
23002 if ($svgstyle[
'stroke'] !=
'none') {
23003 if ($svgstyle[
'stroke-opacity'] != 1) {
23004 $this->setAlpha($svgstyle[
'stroke-opacity'],
'Normal', $this->alpha[
'ca'],
false);
23006 $stroke_style = array(
23008 'width' => $this->getHTMLUnitToUnits($svgstyle[
'stroke-width'], 0, $this->svgunit,
false),
23009 'cap' => $svgstyle[
'stroke-linecap'],
23010 'join' => $svgstyle[
'stroke-linejoin']
23012 if (isset($svgstyle[
'stroke-dasharray']) AND !empty($svgstyle[
'stroke-dasharray']) AND ($svgstyle[
'stroke-dasharray'] !=
'none')) {
23013 $stroke_style[
'dash'] = $svgstyle[
'stroke-dasharray'];
23015 $this->SetLineStyle($stroke_style);
23020 if (!empty($svgstyle[
'font'])) {
23021 if (preg_match(
'/font-family[\s]*:[\s]*([^\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23022 $font_family = $this->getFontFamilyName($regs[1]);
23024 $font_family = $svgstyle[
'font-family'];
23026 if (preg_match(
'/font-size[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23027 $font_size = trim($regs[1]);
23029 $font_size = $svgstyle[
'font-size'];
23031 if (preg_match(
'/font-style[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23032 $font_style = trim($regs[1]);
23034 $font_style = $svgstyle[
'font-style'];
23036 if (preg_match(
'/font-weight[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23037 $font_weight = trim($regs[1]);
23039 $font_weight = $svgstyle[
'font-weight'];
23041 if (preg_match(
'/font-stretch[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23042 $font_stretch = trim($regs[1]);
23044 $font_stretch = $svgstyle[
'font-stretch'];
23046 if (preg_match(
'/letter-spacing[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23047 $font_spacing = trim($regs[1]);
23049 $font_spacing = $svgstyle[
'letter-spacing'];
23052 $font_family = $this->getFontFamilyName($svgstyle[
'font-family']);
23053 $font_size = $svgstyle[
'font-size'];
23054 $font_style = $svgstyle[
'font-style'];
23055 $font_weight = $svgstyle[
'font-weight'];
23056 $font_stretch = $svgstyle[
'font-stretch'];
23057 $font_spacing = $svgstyle[
'letter-spacing'];
23059 $font_size = $this->getHTMLFontUnits($font_size, $this->svgstyles[0][
'font-size'], $prevsvgstyle[
'font-size'], $this->svgunit);
23060 $font_stretch = $this->getCSSFontStretching($font_stretch, $svgstyle[
'font-stretch']);
23061 $font_spacing = $this->getCSSFontSpacing($font_spacing, $svgstyle[
'letter-spacing']);
23062 switch ($font_style) {
23077 switch ($font_weight) {
23080 $font_style .=
'B';
23084 switch ($svgstyle[
'text-decoration']) {
23085 case 'underline': {
23086 $font_style .=
'U';
23090 $font_style .=
'O';
23093 case 'line-through': {
23094 $font_style .=
'D';
23102 $this->SetFont($font_family, $font_style, $font_size);
23103 $this->setFontStretching($font_stretch);
23104 $this->setFontSpacing($font_spacing);
23127 if ($this->state != 2) {
23136 $d = preg_replace(
'/([0-9ACHLMQSTVZ])([\-\+])/si',
'\\1 \\2',
$d);
23137 preg_match_all(
'/([ACHLMQSTVZ])[\s]*([^ACHLMQSTVZ\"]*)/si',
$d, $paths, PREG_SET_ORDER);
23144 $xmin = 2147483647;
23146 $ymin = 2147483647;
23149 $minlen = (0.01 / $this->k);
23152 foreach ($paths as $key => $val) {
23154 $cmd = trim($val[1]);
23166 if (isset($val[2])) {
23168 $rawparams = preg_split(
'/([\,\s]+)/si', trim($val[2]));
23170 foreach ($rawparams as $ck => $cp) {
23171 $params[$ck] = $this->getHTMLUnitToUnits($cp, 0, $this->svgunit,
false);
23172 if (abs($params[$ck]) < $minlen) {
23181 switch (strtoupper(
$cmd)) {
23183 foreach ($params as $ck => $cp) {
23184 if (($ck % 2) == 0) {
23185 $x = $cp + $xoffset;
23187 $y = $cp + $yoffset;
23188 if ($firstcmd OR (abs($x0 - $x) >= $minlen) OR (abs($y0 - $y) >= $minlen)) {
23190 $this->_outPoint($x, $y);
23193 $this->_outLine($x, $y);
23198 $xmin = min($xmin, $x);
23199 $ymin = min($ymin, $y);
23200 $xmax = max($xmax, $x);
23201 $ymax = max($ymax, $y);
23211 foreach ($params as $ck => $cp) {
23212 if (($ck % 2) == 0) {
23213 $x = $cp + $xoffset;
23215 $y = $cp + $yoffset;
23216 if ((abs($x0 - $x) >= $minlen) OR (abs($y0 - $y) >= $minlen)) {
23217 $this->_outLine($x, $y);
23221 $xmin = min($xmin, $x);
23222 $ymin = min($ymin, $y);
23223 $xmax = max($xmax, $x);
23224 $ymax = max($ymax, $y);
23234 foreach ($params as $ck => $cp) {
23235 $x = $cp + $xoffset;
23236 if ((abs($x0 - $x) >= $minlen) OR (abs($y0 - $y) >= $minlen)) {
23237 $this->_outLine($x, $y);
23241 $xmin = min($xmin, $x);
23242 $xmax = max($xmax, $x);
23250 foreach ($params as $ck => $cp) {
23251 $y = $cp + $yoffset;
23252 if ((abs($x0 - $x) >= $minlen) OR (abs($y0 - $y) >= $minlen)) {
23253 $this->_outLine($x, $y);
23257 $ymin = min($ymin, $y);
23258 $ymax = max($ymax, $y);
23266 foreach ($params as $ck => $cp) {
23267 $params[$ck] = $cp;
23268 if ((($ck + 1) % 6) == 0) {
23269 $x1 = $params[($ck - 5)] + $xoffset;
23270 $y1 = $params[($ck - 4)] + $yoffset;
23271 $x2 = $params[($ck - 3)] + $xoffset;
23272 $y2 = $params[($ck - 2)] + $yoffset;
23273 $x = $params[($ck - 1)] + $xoffset;
23274 $y = $params[($ck)] + $yoffset;
23275 $this->_outCurve($x1, $y1, $x2, $y2, $x, $y);
23276 $xmin = min($xmin, $x, $x1, $x2);
23277 $ymin = min($ymin, $y, $y1, $y2);
23278 $xmax = max($xmax, $x, $x1, $x2);
23279 $ymax = max($ymax, $y, $y1, $y2);
23289 foreach ($params as $ck => $cp) {
23290 $params[$ck] = $cp;
23291 if ((($ck + 1) % 4) == 0) {
23292 if (($key > 0) AND ((strtoupper($paths[($key - 1)][1]) ==
'C') OR (strtoupper($paths[($key - 1)][1]) ==
'S'))) {
23293 $x1 = (2 * $x) - $x2;
23294 $y1 = (2 * $y) - $y2;
23299 $x2 = $params[($ck - 3)] + $xoffset;
23300 $y2 = $params[($ck - 2)] + $yoffset;
23301 $x = $params[($ck - 1)] + $xoffset;
23302 $y = $params[($ck)] + $yoffset;
23303 $this->_outCurve($x1, $y1, $x2, $y2, $x, $y);
23304 $xmin = min($xmin, $x, $x1, $x2);
23305 $ymin = min($ymin, $y, $y1, $y2);
23306 $xmax = max($xmax, $x, $x1, $x2);
23307 $ymax = max($ymax, $y, $y1, $y2);
23317 foreach ($params as $ck => $cp) {
23318 $params[$ck] = $cp;
23319 if ((($ck + 1) % 4) == 0) {
23321 $x1 = $params[($ck - 3)] + $xoffset;
23322 $y1 = $params[($ck - 2)] + $yoffset;
23323 $xa = ($x + (2 * $x1)) / 3;
23324 $ya = ($y + (2 * $y1)) / 3;
23325 $x = $params[($ck - 1)] + $xoffset;
23326 $y = $params[($ck)] + $yoffset;
23327 $xb = ($x + (2 * $x1)) / 3;
23328 $yb = ($y + (2 * $y1)) / 3;
23329 $this->_outCurve($xa, $ya, $xb, $yb, $x, $y);
23330 $xmin = min($xmin, $x, $xa, $xb);
23331 $ymin = min($ymin, $y, $ya, $yb);
23332 $xmax = max($xmax, $x, $xa, $xb);
23333 $ymax = max($ymax, $y, $ya, $yb);
23343 foreach ($params as $ck => $cp) {
23344 $params[$ck] = $cp;
23345 if (($ck % 2) != 0) {
23346 if (($key > 0) AND ((strtoupper($paths[($key - 1)][1]) ==
'Q') OR (strtoupper($paths[($key - 1)][1]) ==
'T'))) {
23347 $x1 = (2 * $x) - $x1;
23348 $y1 = (2 * $y) - $y1;
23354 $xa = ($x + (2 * $x1)) / 3;
23355 $ya = ($y + (2 * $y1)) / 3;
23356 $x = $params[($ck - 1)] + $xoffset;
23357 $y = $params[($ck)] + $yoffset;
23358 $xb = ($x + (2 * $x1)) / 3;
23359 $yb = ($y + (2 * $y1)) / 3;
23360 $this->_outCurve($xa, $ya, $xb, $yb, $x, $y);
23361 $xmin = min($xmin, $x, $xa, $xb);
23362 $ymin = min($ymin, $y, $ya, $yb);
23363 $xmax = max($xmax, $x, $xa, $xb);
23364 $ymax = max($ymax, $y, $ya, $yb);
23374 foreach ($params as $ck => $cp) {
23375 $params[$ck] = $cp;
23376 if ((($ck + 1) % 7) == 0) {
23379 $rx = abs($params[($ck - 6)]);
23380 $ry = abs($params[($ck - 5)]);
23381 $ang = -$rawparams[($ck - 4)];
23382 $angle = deg2rad($ang);
23383 $fa = $rawparams[($ck - 3)];
23384 $fs = $rawparams[($ck - 2)];
23385 $x = $params[($ck - 1)] + $xoffset;
23386 $y = $params[$ck] + $yoffset;
23387 if ((abs($x0 - $x) < $minlen) AND (abs($y0 - $y) < $minlen)) {
23389 $xmin = min($xmin, $x);
23390 $ymin = min($ymin, $y);
23391 $xmax = max($xmax, $x);
23392 $ymax = max($ymax, $y);
23394 $cos_ang = cos($angle);
23395 $sin_ang = sin($angle);
23396 $a = (($x0 - $x) / 2);
23397 $b = (($y0 - $y) / 2);
23398 $xa = ($a * $cos_ang) - ($b * $sin_ang);
23399 $ya = ($a * $sin_ang) + ($b * $cos_ang);
23404 $delta = ($xa2 / $rx2) + ($ya2 / $ry2);
23406 $rx *= sqrt($delta);
23407 $ry *= sqrt($delta);
23411 $numerator = (($rx2 * $ry2) - ($rx2 * $ya2) - ($ry2 * $xa2));
23412 if ($numerator < 0) {
23415 $root = sqrt($numerator / (($rx2 * $ya2) + ($ry2 * $xa2)));
23420 $cax = $root * (($rx * $ya) / $ry);
23421 $cay = -$root * (($ry * $xa) / $rx);
23423 $cx = ($cax * $cos_ang) - ($cay * $sin_ang) + (($x0 + $x) / 2);
23424 $cy = ($cax * $sin_ang) + ($cay * $cos_ang) + (($y0 + $y) / 2);
23428 if (($fs == 0) AND ($dang > 0)) {
23429 $dang -= (2 * M_PI);
23430 } elseif (($fs == 1) AND ($dang < 0)) {
23431 $dang += (2 * M_PI);
23433 $angf = $angs - $dang;
23434 if ((($fs == 0) AND ($angs > $angf)) OR (($fs == 1) AND ($angs < $angf))) {
23440 $angs = round(rad2deg($angs), 6);
23441 $angf = round(rad2deg($angf), 6);
23443 if (($angs < 0) AND ($angf < 0)) {
23448 if (($key == 0) AND (isset($paths[($key + 1)][1])) AND (trim($paths[($key + 1)][1]) ==
'z')) {
23451 list($axmin, $aymin, $axmax, $aymax) = $this->_outellipticalarc($cx, $cy, $rx, $ry, $ang, $angs, $angf, $pie, 2,
false, ($fs == 0),
true);
23452 $xmin = min($xmin, $x, $axmin);
23453 $ymin = min($ymin, $y, $aymin);
23454 $xmax = max($xmax, $x, $axmax);
23455 $ymax = max($ymax, $y, $aymax);
23475 return array($xmin, $ymin, ($xmax - $xmin), ($ymax - $ymin));
23490 if ($this->svgclipmode) {
23491 $this->svgclippaths[$this->svgclipid][] = array(
'name' => $name,
'attribs' => $attribs,
'tm' => $this->svgcliptm[$this->svgclipid]);
23494 if ($this->svgdefsmode AND !in_array($name, array(
'clipPath',
'linearGradient',
'radialGradient',
'stop'))) {
23495 if (!isset($attribs[
'id'])) {
23496 $attribs[
'id'] =
'DF_'.(count($this->svgdefs) + 1);
23498 $this->svgdefs[$attribs[
'id']] = array(
'name' => $name,
'attribs' => $attribs);
23502 if ($parser ==
'clip-path') {
23507 $prev_svgstyle = $this->svgstyles[(count($this->svgstyles) - 1)];
23508 $svgstyle = $this->svgstyles[0];
23509 if ($clipping AND !isset($attribs[
'fill']) AND (!isset($attribs[
'style']) OR (!preg_match(
'/[;\"\s]{1}fill[\s]*:[\s]*([^;\"]*)/si', $attribs[
'style'], $attrval)))) {
23511 $attribs[
'fill'] =
'none';
23515 $attribs[
'style'] =
';'.$attribs[
'style'];
23517 foreach ($prev_svgstyle as $key => $val) {
23520 $svgstyle[$key] = $val;
23524 if ($attribs[$key] ==
'inherit') {
23525 $svgstyle[$key] = $val;
23527 $svgstyle[$key] = $attribs[$key];
23531 $attrval = array();
23532 if (preg_match(
'/[;\"\s]{1}'.$key.
'[\s]*:[\s]*([^;\"]*)/si', $attribs[
'style'], $attrval) AND isset($attrval[1])) {
23533 if ($attrval[1] ==
'inherit') {
23534 $svgstyle[$key] = $val;
23536 $svgstyle[$key] = $attrval[1];
23542 if (!empty($ctm)) {
23546 $tm = array(1,0,0,1,0,0);
23548 if (isset($attribs[
'transform']) AND !empty($attribs[
'transform'])) {
23551 $svgstyle[
'transfmatrix'] = $tm;
23552 $invisible =
false;
23553 if (($svgstyle[
'visibility'] ==
'hidden') OR ($svgstyle[
'visibility'] ==
'collapse') OR ($svgstyle[
'display'] ==
'none')) {
23560 $this->svgdefsmode =
true;
23568 $this->svgclipmode =
true;
23569 if (!isset($attribs[
'id'])) {
23570 $attribs[
'id'] =
'CP_'.(count($this->svgcliptm) + 1);
23572 $this->svgclipid = $attribs[
'id'];
23573 $this->svgclippaths[$this->svgclipid] = array();
23574 $this->svgcliptm[$this->svgclipid] = $tm;
23583 array_push($this->svgstyles, $svgstyle);
23584 $this->StartTransform();
23585 $this->SVGTransform($tm);
23586 $this->setSVGStyles($svgstyle, $prev_svgstyle);
23589 case 'linearGradient': {
23590 if ($this->pdfa_mode) {
23593 if (!isset($attribs[
'id'])) {
23594 $attribs[
'id'] =
'GR_'.(count($this->svggradients) + 1);
23596 $this->svggradientid = $attribs[
'id'];
23597 $this->svggradients[$this->svggradientid] = array();
23598 $this->svggradients[$this->svggradientid][
'type'] = 2;
23599 $this->svggradients[$this->svggradientid][
'stops'] = array();
23600 if (isset($attribs[
'gradientUnits'])) {
23601 $this->svggradients[$this->svggradientid][
'gradientUnits'] = $attribs[
'gradientUnits'];
23603 $this->svggradients[$this->svggradientid][
'gradientUnits'] =
'objectBoundingBox';
23606 if (((!isset($attribs[
'x1'])) AND (!isset($attribs[
'y1'])) AND (!isset($attribs[
'x2'])) AND (!isset($attribs[
'y2'])))
23607 OR ((isset($attribs[
'x1']) AND (substr($attribs[
'x1'], -1) ==
'%'))
23608 OR (isset($attribs[
'y1']) AND (substr($attribs[
'y1'], -1) ==
'%'))
23609 OR (isset($attribs[
'x2']) AND (substr($attribs[
'x2'], -1) ==
'%'))
23610 OR (isset($attribs[
'y2']) AND (substr($attribs[
'y2'], -1) ==
'%')))) {
23611 $this->svggradients[$this->svggradientid][
'mode'] =
'percentage';
23613 $this->svggradients[$this->svggradientid][
'mode'] =
'measure';
23615 $x1 = (isset($attribs[
'x1'])?$attribs[
'x1']:
'0');
23616 $y1 = (isset($attribs[
'y1'])?$attribs[
'y1']:
'0');
23617 $x2 = (isset($attribs[
'x2'])?$attribs[
'x2']:
'100');
23618 $y2 = (isset($attribs[
'y2'])?$attribs[
'y2']:
'0');
23619 if (isset($attribs[
'gradientTransform'])) {
23622 $this->svggradients[$this->svggradientid][
'coords'] = array($x1, $y1, $x2, $y2);
23623 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
23625 $this->svggradients[$this->svggradientid][
'xref'] = substr($attribs[
'xlink:href'], 1);
23629 case 'radialGradient': {
23630 if ($this->pdfa_mode) {
23633 if (!isset($attribs[
'id'])) {
23634 $attribs[
'id'] =
'GR_'.(count($this->svggradients) + 1);
23636 $this->svggradientid = $attribs[
'id'];
23637 $this->svggradients[$this->svggradientid] = array();
23638 $this->svggradients[$this->svggradientid][
'type'] = 3;
23639 $this->svggradients[$this->svggradientid][
'stops'] = array();
23640 if (isset($attribs[
'gradientUnits'])) {
23641 $this->svggradients[$this->svggradientid][
'gradientUnits'] = $attribs[
'gradientUnits'];
23643 $this->svggradients[$this->svggradientid][
'gradientUnits'] =
'objectBoundingBox';
23646 if (((!isset($attribs[
'cx'])) AND (!isset($attribs[
'cy'])))
23647 OR ((isset($attribs[
'cx']) AND (substr($attribs[
'cx'], -1) ==
'%'))
23648 OR (isset($attribs[
'cy']) AND (substr($attribs[
'cy'], -1) ==
'%')) )) {
23649 $this->svggradients[$this->svggradientid][
'mode'] =
'percentage';
23651 $this->svggradients[$this->svggradientid][
'mode'] =
'measure';
23653 $cx = (isset($attribs[
'cx']) ? $attribs[
'cx'] : 0.5);
23654 $cy = (isset($attribs[
'cy']) ? $attribs[
'cy'] : 0.5);
23655 $fx = (isset($attribs[
'fx']) ? $attribs[
'fx'] : $cx);
23656 $fy = (isset($attribs[
'fy']) ? $attribs[
'fy'] : $cy);
23657 $r = (isset($attribs[
'r']) ? $attribs[
'r'] : 0.5);
23658 if (isset($attribs[
'gradientTransform'])) {
23661 $this->svggradients[$this->svggradientid][
'coords'] = array($cx, $cy, $fx, $fy, $r);
23662 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
23664 $this->svggradients[$this->svggradientid][
'xref'] = substr($attribs[
'xlink:href'], 1);
23670 if (substr($attribs[
'offset'], -1) ==
'%') {
23671 $offset = floatval(substr($attribs[
'offset'], -1)) / 100;
23673 $offset = floatval($attribs[
'offset']);
23679 $opacity = isset($svgstyle[
'stop-opacity'])?$svgstyle[
'stop-opacity']:1;
23680 $this->svggradients[$this->svggradientid][
'stops'][] = array(
'offset' => $offset,
'color' => $stop_color,
'opacity' => $opacity);
23688 if (isset($attribs[
'd'])) {
23689 $d = trim($attribs[
'd']);
23692 $this->SVGTransform($tm);
23693 $this->SVGPath(
$d,
'CNZ');
23695 $this->StartTransform();
23696 $this->SVGTransform($tm);
23697 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, 0, 0, 1, 1,
'SVGPath', array(
$d,
'CNZ'));
23698 if (!empty($obstyle)) {
23699 $this->SVGPath(
$d, $obstyle);
23701 $this->StopTransform();
23712 $x = (isset($attribs[
'x'])?$this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false):0);
23713 $y = (isset($attribs[
'y'])?$this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false):0);
23714 $w = (isset($attribs[
'width'])?$this->getHTMLUnitToUnits($attribs[
'width'], 0, $this->svgunit,
false):0);
23715 $h = (isset($attribs[
'height'])?$this->getHTMLUnitToUnits($attribs[
'height'], 0, $this->svgunit,
false):0);
23716 $rx = (isset($attribs[
'rx'])?$this->getHTMLUnitToUnits($attribs[
'rx'], 0, $this->svgunit,
false):0);
23717 $ry = (isset($attribs[
'ry'])?$this->getHTMLUnitToUnits($attribs[
'ry'], 0, $this->svgunit,
false):$rx);
23719 $this->SVGTransform($tm);
23720 $this->RoundedRectXY($x, $y, $w, $h, $rx, $ry,
'1111',
'CNZ', array(), array());
23722 $this->StartTransform();
23723 $this->SVGTransform($tm);
23724 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'RoundedRectXY', array($x, $y, $w, $h, $rx, $ry,
'1111',
'CNZ'));
23725 if (!empty($obstyle)) {
23726 $this->RoundedRectXY($x, $y, $w, $h, $rx, $ry,
'1111', $obstyle, array(), array());
23728 $this->StopTransform();
23736 $r = (isset($attribs[
'r']) ? $this->getHTMLUnitToUnits($attribs[
'r'], 0, $this->svgunit,
false) : 0);
23737 $cx = (isset($attribs[
'cx']) ? $this->getHTMLUnitToUnits($attribs[
'cx'], 0, $this->svgunit,
false) : (isset($attribs[
'x']) ? $this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false) : 0));
23738 $cy = (isset($attribs[
'cy']) ? $this->getHTMLUnitToUnits($attribs[
'cy'], 0, $this->svgunit,
false) : (isset($attribs[
'y']) ? $this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false) : 0));
23744 $this->SVGTransform($tm);
23745 $this->Circle($cx, $cy, $r, 0, 360,
'CNZ', array(), array(), 8);
23747 $this->StartTransform();
23748 $this->SVGTransform($tm);
23749 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'Circle', array($cx, $cy, $r, 0, 360,
'CNZ'));
23750 if (!empty($obstyle)) {
23751 $this->Circle($cx, $cy, $r, 0, 360, $obstyle, array(), array(), 8);
23753 $this->StopTransform();
23761 $rx = (isset($attribs[
'rx']) ? $this->getHTMLUnitToUnits($attribs[
'rx'], 0, $this->svgunit,
false) : 0);
23762 $ry = (isset($attribs[
'ry']) ? $this->getHTMLUnitToUnits($attribs[
'ry'], 0, $this->svgunit,
false) : 0);
23763 $cx = (isset($attribs[
'cx']) ? $this->getHTMLUnitToUnits($attribs[
'cx'], 0, $this->svgunit,
false) : (isset($attribs[
'x']) ? $this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false) : 0));
23764 $cy = (isset($attribs[
'cy']) ? $this->getHTMLUnitToUnits($attribs[
'cy'], 0, $this->svgunit,
false) : (isset($attribs[
'y']) ? $this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false) : 0));
23770 $this->SVGTransform($tm);
23771 $this->Ellipse($cx, $cy, $rx, $ry, 0, 0, 360,
'CNZ', array(), array(), 8);
23773 $this->StartTransform();
23774 $this->SVGTransform($tm);
23775 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'Ellipse', array($cx, $cy, $rx, $ry, 0, 0, 360,
'CNZ'));
23776 if (!empty($obstyle)) {
23777 $this->Ellipse($cx, $cy, $rx, $ry, 0, 0, 360, $obstyle, array(), array(), 8);
23779 $this->StopTransform();
23787 $x1 = (isset($attribs[
'x1'])?$this->getHTMLUnitToUnits($attribs[
'x1'], 0, $this->svgunit,
false):0);
23788 $y1 = (isset($attribs[
'y1'])?$this->getHTMLUnitToUnits($attribs[
'y1'], 0, $this->svgunit,
false):0);
23789 $x2 = (isset($attribs[
'x2'])?$this->getHTMLUnitToUnits($attribs[
'x2'], 0, $this->svgunit,
false):0);
23790 $y2 = (isset($attribs[
'y2'])?$this->getHTMLUnitToUnits($attribs[
'y2'], 0, $this->svgunit,
false):0);
23793 $w = abs($x2 - $x1);
23794 $h = abs($y2 - $y1);
23796 $this->StartTransform();
23797 $this->SVGTransform($tm);
23798 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'Line', array($x1, $y1, $x2, $y2));
23799 $this->Line($x1, $y1, $x2, $y2);
23800 $this->StopTransform();
23809 $points = (isset($attribs[
'points'])?$attribs[
'points']:
'0 0');
23810 $points = trim($points);
23812 $points = preg_split(
'/[\,\s]+/si', $points);
23813 if (count($points) < 4) {
23817 $xmin = 2147483647;
23819 $ymin = 2147483647;
23821 foreach ($points as $key => $val) {
23822 $p[$key] = $this->getHTMLUnitToUnits($val, 0, $this->svgunit,
false);
23823 if (($key % 2) == 0) {
23825 $xmin = min($xmin, $p[$key]);
23826 $xmax = max($xmax, $p[$key]);
23829 $ymin = min($ymin, $p[$key]);
23830 $ymax = max($ymax, $p[$key]);
23835 $w = ($xmax - $xmin);
23836 $h = ($ymax - $ymin);
23837 if ($name ==
'polyline') {
23838 $this->StartTransform();
23839 $this->SVGTransform($tm);
23840 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'PolyLine', array($p,
'CNZ'));
23841 if (!empty($obstyle)) {
23842 $this->PolyLine($p, $obstyle, array(), array());
23844 $this->StopTransform();
23847 $this->SVGTransform($tm);
23848 $this->Polygon($p,
'CNZ', array(), array(),
true);
23850 $this->StartTransform();
23851 $this->SVGTransform($tm);
23852 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'Polygon', array($p,
'CNZ'));
23853 if (!empty($obstyle)) {
23854 $this->Polygon($p, $obstyle, array(), array(),
true);
23856 $this->StopTransform();
23866 if (!isset($attribs[
'xlink:href']) OR empty($attribs[
'xlink:href'])) {
23869 $x = (isset($attribs[
'x'])?$this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false):0);
23870 $y = (isset($attribs[
'y'])?$this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false):0);
23871 $w = (isset($attribs[
'width'])?$this->getHTMLUnitToUnits($attribs[
'width'], 0, $this->svgunit,
false):0);
23872 $h = (isset($attribs[
'height'])?$this->getHTMLUnitToUnits($attribs[
'height'], 0, $this->svgunit,
false):0);
23873 $img = $attribs[
'xlink:href'];
23875 $this->StartTransform();
23876 $this->SVGTransform($tm);
23877 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h);
23878 if (preg_match(
'/^data:image\/[^;]+;base64,/',
$img, $m) > 0) {
23880 $img =
'@'.base64_decode(substr(
$img, strlen($m[0])));
23887 if ((
$img[0] ==
'/') AND !empty($_SERVER[
'DOCUMENT_ROOT']) AND ($_SERVER[
'DOCUMENT_ROOT'] !=
'/')) {
23888 $findroot = strpos(
$img, $_SERVER[
'DOCUMENT_ROOT']);
23889 if (($findroot ===
false) OR ($findroot > 1)) {
23890 if (substr($_SERVER[
'DOCUMENT_ROOT'], -1) ==
'/') {
23891 $img = substr($_SERVER[
'DOCUMENT_ROOT'], 0, -1).$img;
23893 $img = $_SERVER[
'DOCUMENT_ROOT'].$img;
23898 $testscrtype = @parse_url(
$img);
23899 if (!isset($testscrtype[
'query']) OR empty($testscrtype[
'query'])) {
23901 $img = str_replace(K_PATH_URL, K_PATH_MAIN,
$img);
23906 if (($imgtype ==
'eps') OR ($imgtype ==
'ai')) {
23907 $this->ImageEps(
$img, $x, $y, $w, $h);
23908 } elseif ($imgtype ==
'svg') {
23909 $this->ImageSVG(
$img, $x, $y, $w, $h);
23911 $this->Image(
$img, $x, $y, $w, $h);
23913 $this->StopTransform();
23921 $this->svgtextmode[
'invisible'] = $invisible;
23925 array_push($this->svgstyles, $svgstyle);
23926 if (isset($attribs[
'x'])) {
23927 $x = $this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false);
23928 } elseif ($name ==
'tspan') {
23933 if (isset($attribs[
'dx'])) {
23934 $x += $this->getHTMLUnitToUnits($attribs[
'dx'], 0, $this->svgunit,
false);
23936 if (isset($attribs[
'y'])) {
23937 $y = $this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false);
23938 } elseif ($name ==
'tspan') {
23943 if (isset($attribs[
'dy'])) {
23944 $y += $this->getHTMLUnitToUnits($attribs[
'dy'], 0, $this->svgunit,
false);
23946 $svgstyle[
'text-color'] = $svgstyle[
'fill'];
23947 $this->svgtext =
'';
23948 if (isset($svgstyle[
'text-anchor'])) {
23949 $this->svgtextmode[
'text-anchor'] = $svgstyle[
'text-anchor'];
23951 $this->svgtextmode[
'text-anchor'] =
'start';
23953 if (isset($svgstyle[
'direction'])) {
23954 if ($svgstyle[
'direction'] ==
'rtl') {
23955 $this->svgtextmode[
'rtl'] =
true;
23957 $this->svgtextmode[
'rtl'] =
false;
23960 $this->svgtextmode[
'rtl'] =
false;
23962 if (isset($svgstyle[
'stroke']) AND ($svgstyle[
'stroke'] !=
'none') AND isset($svgstyle[
'stroke-width']) AND ($svgstyle[
'stroke-width'] > 0)) {
23963 $this->svgtextmode[
'stroke'] = $this->getHTMLUnitToUnits($svgstyle[
'stroke-width'], 0, $this->svgunit,
false);
23965 $this->svgtextmode[
'stroke'] =
false;
23967 $this->StartTransform();
23968 $this->SVGTransform($tm);
23969 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, 1, 1);
23976 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
23977 $svgdefid = substr($attribs[
'xlink:href'], 1);
23978 if (isset($this->svgdefs[$svgdefid])) {
23979 $use = $this->svgdefs[$svgdefid];
23980 if (isset($attribs[
'xlink:href'])) {
23981 unset($attribs[
'xlink:href']);
23983 if (isset($attribs[
'id'])) {
23984 unset($attribs[
'id']);
23986 $attribs = array_merge($attribs, $use[
'attribs']);
23987 $this->startSVGElementHandler($parser, $use[
'name'], $attribs);
24009 $this->svgdefsmode =
false;
24014 $this->svgclipmode =
false;
24019 array_pop($this->svgstyles);
24020 $this->StopTransform();
24025 if ($this->svgtextmode[
'invisible']) {
24031 $text = $this->svgtext;
24033 $textlen = $this->GetStringWidth($text);
24034 if ($this->svgtextmode[
'text-anchor'] !=
'start') {
24036 if ($this->svgtextmode[
'text-anchor'] ==
'end') {
24037 if ($this->svgtextmode[
'rtl']) {
24038 $this->x += $textlen;
24040 $this->x -= $textlen;
24042 } elseif ($this->svgtextmode[
'text-anchor'] ==
'middle') {
24043 if ($this->svgtextmode[
'rtl']) {
24044 $this->x += ($textlen / 2);
24046 $this->x -= ($textlen / 2);
24050 $textrendermode = $this->textrendermode;
24051 $textstrokewidth = $this->textstrokewidth;
24052 $this->setTextRenderingMode($this->svgtextmode[
'stroke'],
true,
false);
24053 if ($name ==
'text') {
24058 $this->Cell($textlen, 0, $text, 0, 0,
'',
false,
'', 0,
false,
'L',
'T');
24059 if ($name ==
'text') {
24065 $this->textrendermode = $textrendermode;
24066 $this->textstrokewidth = $textstrokewidth;
24067 $this->svgtext =
'';
24068 $this->StopTransform();
24069 array_pop($this->svgstyles);
24087 $this->svgtext .= $data;