111 require_once(dirname(__FILE__).
'/tcpdf_autoconfig.php');
113 require_once(dirname(__FILE__).
'/include/tcpdf_font_data.php');
115 require_once(dirname(__FILE__).
'/include/tcpdf_fonts.php');
117 require_once(dirname(__FILE__).
'/include/tcpdf_colors.php');
119 require_once(dirname(__FILE__).
'/include/tcpdf_images.php');
121 require_once(dirname(__FILE__).
'/include/tcpdf_static.php');
288 protected $cell_margin = array(
'T' => 0,
'R' => 0,
'B' => 0,
'L' => 0);
690 protected $txtshadow = array(
'enabled'=>
false,
'depth_w'=>0,
'depth_h'=>0,
'color'=>
false,
'opacity'=>1,
'blend_mode'=>
'Normal');
1331 protected $default_form_prop = array(
'lineWidth'=>1,
'borderStyle'=>
'solid',
'fillColor'=>array(255, 255, 255),
'strokeColor'=>array(128, 128, 128));
1450 protected $colxshift = array(
'x' => 0,
's' => array(
'H' => 0,
'V' => 0),
'p' => array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0));
1674 'alignment-baseline' =>
'auto',
1675 'baseline-shift' =>
'baseline',
1677 'clip-path' =>
'none',
1678 'clip-rule' =>
'nonzero',
1680 'color-interpolation' =>
'sRGB',
1681 'color-interpolation-filters' =>
'linearRGB',
1682 'color-profile' =>
'auto',
1683 'color-rendering' =>
'auto',
1685 'direction' =>
'ltr',
1686 'display' =>
'inline',
1687 'dominant-baseline' =>
'auto',
1688 'enable-background' =>
'accumulate',
1690 'fill-opacity' => 1,
1691 'fill-rule' =>
'nonzero',
1693 'flood-color' =>
'black',
1694 'flood-opacity' => 1,
1696 'font-family' =>
'helvetica',
1697 'font-size' =>
'medium',
1698 'font-size-adjust' =>
'none',
1699 'font-stretch' =>
'normal',
1700 'font-style' =>
'normal',
1701 'font-variant' =>
'normal',
1702 'font-weight' =>
'normal',
1703 'glyph-orientation-horizontal' =>
'0deg',
1704 'glyph-orientation-vertical' =>
'auto',
1705 'image-rendering' =>
'auto',
1706 'kerning' =>
'auto',
1707 'letter-spacing' =>
'normal',
1708 'lighting-color' =>
'white',
1710 'marker-end' =>
'none',
1711 'marker-mid' =>
'none',
1712 'marker-start' =>
'none',
1715 'overflow' =>
'auto',
1716 'pointer-events' =>
'visiblePainted',
1717 'shape-rendering' =>
'auto',
1718 'stop-color' =>
'black',
1719 'stop-opacity' => 1,
1721 'stroke-dasharray' =>
'none',
1722 'stroke-dashoffset' => 0,
1723 'stroke-linecap' =>
'butt',
1724 'stroke-linejoin' =>
'miter',
1725 'stroke-miterlimit' => 4,
1726 'stroke-opacity' => 1,
1727 'stroke-width' => 1,
1728 'text-anchor' =>
'start',
1729 'text-decoration' =>
'none',
1730 'text-rendering' =>
'auto',
1731 'unicode-bidi' =>
'normal',
1732 'visibility' =>
'visible',
1733 'word-spacing' =>
'normal',
1734 'writing-mode' =>
'lr-tb',
1735 'text-color' =>
'black',
1736 'transfmatrix' => array(1, 0, 0, 1, 0, 0)
1780 protected $overprint = array(
'OP' =>
false,
'op' =>
false,
'OPM' => 0);
1788 protected $alpha = array(
'CA' => 1,
'ca' => 1,
'BM' =>
'/Normal',
'AIS' =>
false);
1795 protected $page_boxes = array(
'MediaBox',
'CropBox',
'BleedBox',
'TrimBox',
'ArtBox');
1833 if (function_exists(
'mb_internal_encoding') AND mb_internal_encoding()) {
1834 $this->internal_encoding = mb_internal_encoding();
1835 mb_internal_encoding(
'ASCII');
1837 $this->font_obj_ids = array();
1838 $this->page_obj_id = array();
1839 $this->form_obj_id = array();
1841 $this->pdfa_mode = $pdfa;
1842 $this->force_srgb =
false;
1844 $this->diskcache =
$diskcache ?
true :
false;
1847 $this->tmprtl =
false;
1851 $this->isunicode = $unicode;
1853 $this->transfmrk[0] = array();
1854 $this->pagedim = array();
1857 $this->pages = array();
1859 $this->fonts = array();
1860 $this->FontFiles = array();
1861 $this->diffs = array();
1862 $this->images = array();
1863 $this->links = array();
1864 $this->gradients = array();
1865 $this->InFooter =
false;
1868 $this->FontStyle =
'';
1869 $this->FontSizePt = 12;
1870 $this->underline =
false;
1871 $this->overline =
false;
1872 $this->linethrough =
false;
1873 $this->DrawColor =
'0 G';
1874 $this->FillColor =
'0 g';
1875 $this->TextColor =
'0 g';
1876 $this->ColorFlag =
false;
1877 $this->pdflayers = array();
1879 $this->encrypted =
false;
1880 $this->last_enc_key =
'';
1882 $this->CoreFonts = array(
1883 'courier'=>
'Courier',
1884 'courierB'=>
'Courier-Bold',
1885 'courierI'=>
'Courier-Oblique',
1886 'courierBI'=>
'Courier-BoldOblique',
1887 'helvetica'=>
'Helvetica',
1888 'helveticaB'=>
'Helvetica-Bold',
1889 'helveticaI'=>
'Helvetica-Oblique',
1890 'helveticaBI'=>
'Helvetica-BoldOblique',
1891 'times'=>
'Times-Roman',
1892 'timesB'=>
'Times-Bold',
1893 'timesI'=>
'Times-Italic',
1894 'timesBI'=>
'Times-BoldItalic',
1896 'zapfdingbats'=>
'ZapfDingbats'
1908 $cpadding = $margin / 10;
1913 $this->LineWidth = 0.57 /
$this->k;
1914 $this->linestyleWidth = sprintf(
'%F w', ($this->LineWidth * $this->k));
1915 $this->linestyleCap =
'0 J';
1916 $this->linestyleJoin =
'0 j';
1917 $this->linestyleDash =
'[] 0 d';
1926 $this->tcpdflink =
true;
1928 $this->HREF = array();
1930 $this->fgcolor = array(
'R' => 0,
'G' => 0,
'B' => 0);
1931 $this->strokecolor = array(
'R' => 0,
'G' => 0,
'B' => 0);
1932 $this->bgcolor = array(
'R' => 255,
'G' => 255,
'B' => 255);
1933 $this->extgstates = array();
1936 $this->sign =
false;
1937 $this->ur[
'enabled'] =
false;
1938 $this->ur[
'document'] =
'/FullSave';
1939 $this->ur[
'annots'] =
'/Create/Delete/Modify/Copy/Import/Export';
1940 $this->ur[
'form'] =
'/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate';
1941 $this->ur[
'signature'] =
'/Modify';
1942 $this->ur[
'ef'] =
'/Create/Delete/Modify/Import';
1943 $this->ur[
'formex'] =
'';
1944 $this->signature_appearance = array(
'page' => 1,
'rect' =>
'0 0 0 0',
'name' =>
'Signature');
1945 $this->empty_signature_appearance = array();
1947 $this->jpeg_quality = 75;
1951 $this->
SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
1952 $this->
setHeaderFont(array($this->FontFamily, $this->FontStyle, $this->FontSizePt));
1953 $this->
setFooterFont(array($this->FontFamily, $this->FontStyle, $this->FontSizePt));
1955 if ($this->isunicode AND (@preg_match(
'/\pL/u',
'a') == 1)) {
1966 $this->default_form_prop = array(
'lineWidth'=>1,
'borderStyle'=>
'solid',
'fillColor'=>array(255, 255, 255),
'strokeColor'=>array(128, 128, 128));
1968 $serformat = (is_array($format) ? serialize($format) : $format);
1971 $this->doc_creation_timestamp = time();
1975 $this->header_xobj_autoreset =
false;
1976 $this->custom_xmp =
'';
1986 if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
1987 mb_internal_encoding($this->internal_encoding);
2000 $unit = strtolower($unit);
2011 $this->k = $this->dpi / 25.4;
2016 $this->k = $this->dpi / 2.54;
2026 $this->
Error(
'Incorrect unit: '.$unit);
2030 $this->pdfunit = $unit;
2031 if (isset($this->CurOrientation)) {
2092 if (!empty($format) AND isset($this->pagedim[$this->page])) {
2094 unset($this->pagedim[$this->page]);
2096 if (is_string($format)) {
2099 $this->fwPt = $pf[0];
2100 $this->fhPt = $pf[1];
2103 if (isset($format[
'MediaBox'])) {
2104 $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);
2105 $this->fwPt = (($format[
'MediaBox'][
'urx'] - $format[
'MediaBox'][
'llx']) * $this->k);
2106 $this->fhPt = (($format[
'MediaBox'][
'ury'] - $format[
'MediaBox'][
'lly']) * $this->k);
2108 if (isset($format[0]) AND is_numeric($format[0]) AND isset($format[1]) AND is_numeric($format[1])) {
2109 $pf = array(($format[0] * $this->k), ($format[1] * $this->k));
2111 if (!isset($format[
'format'])) {
2113 $format[
'format'] =
'A4';
2117 $this->fwPt = $pf[0];
2118 $this->fhPt = $pf[1];
2119 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'MediaBox', 0, 0, $this->fwPt, $this->fhPt,
true, $this->k, $this->pagedim);
2122 if (isset($format[
'CropBox'])) {
2123 $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);
2126 if (isset($format[
'BleedBox'])) {
2127 $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);
2130 if (isset($format[
'TrimBox'])) {
2131 $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);
2134 if (isset($format[
'ArtBox'])) {
2135 $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);
2138 if (isset($format[
'BoxColorInfo'])) {
2139 $this->pagedim[
$this->page][
'BoxColorInfo'] = $format[
'BoxColorInfo'];
2141 if (isset($format[
'Rotate']) AND (($format[
'Rotate'] % 90) == 0)) {
2143 $this->pagedim[
$this->page][
'Rotate'] = intval($format[
'Rotate']);
2145 if (isset($format[
'PZ'])) {
2147 $this->pagedim[
$this->page][
'PZ'] = floatval($format[
'PZ']);
2149 if (isset($format[
'trans'])) {
2151 if (isset($format[
'trans'][
'Dur'])) {
2153 $this->pagedim[
$this->page][
'trans'][
'Dur'] = floatval($format[
'trans'][
'Dur']);
2155 $stansition_styles = array(
'Split',
'Blinds',
'Box',
'Wipe',
'Dissolve',
'Glitter',
'R',
'Fly',
'Push',
'Cover',
'Uncover',
'Fade');
2156 if (isset($format[
'trans'][
'S']) AND in_array($format[
'trans'][
'S'], $stansition_styles)) {
2158 $this->pagedim[
$this->page][
'trans'][
'S'] = $format[
'trans'][
'S'];
2159 $valid_effect = array(
'Split',
'Blinds');
2160 $valid_vals = array(
'H',
'V');
2161 if (isset($format[
'trans'][
'Dm']) AND in_array($format[
'trans'][
'S'], $valid_effect) AND in_array($format[
'trans'][
'Dm'], $valid_vals)) {
2162 $this->pagedim[
$this->page][
'trans'][
'Dm'] = $format[
'trans'][
'Dm'];
2164 $valid_effect = array(
'Split',
'Box',
'Fly');
2165 $valid_vals = array(
'I',
'O');
2166 if (isset($format[
'trans'][
'M']) AND in_array($format[
'trans'][
'S'], $valid_effect) AND in_array($format[
'trans'][
'M'], $valid_vals)) {
2167 $this->pagedim[
$this->page][
'trans'][
'M'] = $format[
'trans'][
'M'];
2169 $valid_effect = array(
'Wipe',
'Glitter',
'Fly',
'Cover',
'Uncover',
'Push');
2170 if (isset($format[
'trans'][
'Di']) AND in_array($format[
'trans'][
'S'], $valid_effect)) {
2171 if (((($format[
'trans'][
'Di'] == 90) OR ($format[
'trans'][
'Di'] == 180)) AND ($format[
'trans'][
'S'] ==
'Wipe'))
2172 OR (($format[
'trans'][
'Di'] == 315) AND ($format[
'trans'][
'S'] ==
'Glitter'))
2173 OR (($format[
'trans'][
'Di'] == 0) OR ($format[
'trans'][
'Di'] == 270))) {
2174 $this->pagedim[
$this->page][
'trans'][
'Di'] = intval($format[
'trans'][
'Di']);
2177 if (isset($format[
'trans'][
'SS']) AND ($format[
'trans'][
'S'] ==
'Fly')) {
2178 $this->pagedim[
$this->page][
'trans'][
'SS'] = floatval($format[
'trans'][
'SS']);
2180 if (isset($format[
'trans'][
'B']) AND ($format[
'trans'][
'B'] ===
true) AND ($format[
'trans'][
'S'] ==
'Fly')) {
2181 $this->pagedim[
$this->page][
'trans'][
'B'] =
'true';
2186 if (isset($format[
'trans'][
'D'])) {
2188 $this->pagedim[
$this->page][
'trans'][
'D'] = floatval($format[
'trans'][
'D']);
2206 if (!isset($this->pagedim[$this->page][
'MediaBox'])) {
2208 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'MediaBox', 0, 0, $this->fwPt, $this->fhPt,
true, $this->k, $this->pagedim);
2210 if (!isset($this->pagedim[$this->page][
'CropBox'])) {
2212 $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);
2214 if (!isset($this->pagedim[$this->page][
'BleedBox'])) {
2216 $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);
2218 if (!isset($this->pagedim[$this->page][
'TrimBox'])) {
2220 $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);
2222 if (!isset($this->pagedim[$this->page][
'ArtBox'])) {
2224 $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);
2226 if (!isset($this->pagedim[$this->page][
'Rotate'])) {
2230 if (!isset($this->pagedim[$this->page][
'PZ'])) {
2234 if ($this->fwPt > $this->fhPt) {
2236 $default_orientation =
'L';
2239 $default_orientation =
'P';
2241 $valid_orientations = array(
'P',
'L');
2242 if (empty($orientation)) {
2243 $orientation = $default_orientation;
2245 $orientation = strtoupper($orientation{0});
2247 if (in_array($orientation, $valid_orientations) AND ($orientation != $default_orientation)) {
2248 $this->CurOrientation = $orientation;
2252 $this->CurOrientation = $default_orientation;
2256 if ((abs($this->pagedim[$this->page][
'MediaBox'][
'urx'] - $this->hPt) < $this->feps) AND (abs($this->pagedim[$this->page][
'MediaBox'][
'ury'] - $this->wPt) < $this->feps)){
2260 $this->w = ($this->wPt /
$this->k);
2261 $this->h = ($this->hPt /
$this->k);
2263 if (isset($this->AutoPageBreak)) {
2266 $autopagebreak =
true;
2270 if (isset($this->bMargin)) {
2274 $bottommargin = 2 * 28.35 /
$this->k;
2284 $this->pagedim[
$this->page][
'bm'] = $bottommargin;
2287 $this->pagedim[
$this->page][
'pb'] = $autopagebreak;
2311 $this->re_spaces = $re;
2312 $re_parts = explode(
'/', $re);
2314 $this->re_space = array();
2315 if (isset($re_parts[1]) AND !empty($re_parts[1])) {
2316 $this->re_space[
'p'] = $re_parts[1];
2318 $this->re_space[
'p'] =
'[\s]';
2321 if (isset($re_parts[2]) AND !empty($re_parts[2])) {
2322 $this->re_space[
'm'] = $re_parts[2];
2324 $this->re_space[
'm'] =
'';
2335 public function setRTL($enable, $resetx=
true) {
2336 $enable = $enable ?
true :
false;
2337 $resetx = ($resetx AND ($enable != $this->rtl));
2338 $this->rtl = $enable;
2339 $this->tmprtl =
false;
2363 switch (strtoupper($mode)) {
2384 $this->tmprtl = $newmode;
2394 return ($this->rtl OR ($this->tmprtl ==
'R'));
2417 $height += ($this->cell_padding[
'T'] + $this->cell_padding[
'B']);
2419 return round($height, 3);
2449 $this->imgscale = $scale;
2473 if (empty($pagenum)) {
2476 return $this->pagedim[$pagenum];
2489 if (empty($pagenum)) {
2492 return $this->pagedim[$pagenum][
'w'];
2505 if (empty($pagenum)) {
2508 return $this->pagedim[$pagenum][
'h'];
2521 if (empty($pagenum)) {
2524 return $this->pagedim[$pagenum][
'bm'];
2548 public function SetMargins($left, $top, $right=-1, $keepmargins=
false) {
2550 $this->lMargin = $left;
2551 $this->tMargin = $top;
2555 $this->rMargin = $right;
2572 $this->lMargin = $margin;
2573 if (($this->page > 0) AND ($this->x < $margin)) {
2587 $this->tMargin = $margin;
2588 if (($this->page > 0) AND ($this->y < $margin)) {
2601 $this->rMargin = $margin;
2602 if (($this->page > 0) AND ($this->x > ($this->w - $margin))) {
2603 $this->x = $this->w - $margin;
2616 $this->cell_padding[
'L'] = $pad;
2617 $this->cell_padding[
'T'] = $pad;
2618 $this->cell_padding[
'R'] = $pad;
2619 $this->cell_padding[
'B'] = $pad;
2634 if (($left !==
'') AND ($left >= 0)) {
2635 $this->cell_padding[
'L'] = $left;
2637 if (($top !==
'') AND ($top >= 0)) {
2638 $this->cell_padding[
'T'] = $top;
2640 if (($right !==
'') AND ($right >= 0)) {
2641 $this->cell_padding[
'R'] = $right;
2643 if (($bottom !==
'') AND ($bottom >= 0)) {
2644 $this->cell_padding[
'B'] = $bottom;
2670 if (($left !==
'') AND ($left >= 0)) {
2671 $this->cell_margin[
'L'] = $left;
2673 if (($top !==
'') AND ($top >= 0)) {
2674 $this->cell_margin[
'T'] = $top;
2676 if (($right !==
'') AND ($right >= 0)) {
2677 $this->cell_margin[
'R'] = $right;
2679 if (($bottom !==
'') AND ($bottom >= 0)) {
2680 $this->cell_margin[
'B'] = $bottom;
2706 if (is_string($brd)) {
2708 $slen = strlen($brd);
2710 for ($i = 0; $i < $slen; ++$i) {
2711 $newbrd[$brd[$i]] =
true;
2714 } elseif (($brd === 1) OR ($brd ===
true) OR (is_numeric($brd) AND (intval($brd) > 0))) {
2715 $brd = array(
'LRTB' =>
true);
2717 if (!is_array($brd)) {
2723 if (isset($brd[
'mode'])) {
2724 $mode = $brd[
'mode'];
2725 unset($brd[
'mode']);
2730 foreach ($brd as $border => $style) {
2732 if (is_array($style) AND isset($style[
'width'])) {
2734 $line_width = $style[
'width'];
2748 $adj = ($line_width / 2);
2753 if ((strpos($border,
'T') !==
false) AND ($this->cell_padding[
'T'] < $adj)) {
2754 $this->cell_padding[
'T'] = $adj;
2756 if ((strpos($border,
'R') !==
false) AND ($this->cell_padding[
'R'] < $adj)) {
2757 $this->cell_padding[
'R'] = $adj;
2759 if ((strpos($border,
'B') !==
false) AND ($this->cell_padding[
'B'] < $adj)) {
2760 $this->cell_padding[
'B'] = $adj;
2762 if ((strpos($border,
'L') !==
false) AND ($this->cell_padding[
'L'] < $adj)) {
2763 $this->cell_padding[
'L'] = $adj;
2766 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']));
2778 $this->AutoPageBreak = $auto ?
true :
false;
2779 $this->bMargin = $margin;
2780 $this->PageBreakTrigger = $this->h - $margin;
2802 if (($zoom ==
'fullpage') OR ($zoom ==
'fullwidth') OR ($zoom ==
'real') OR ($zoom ==
'default') OR (!is_string($zoom))) {
2803 $this->ZoomMode = $zoom;
2805 $this->
Error(
'Incorrect zoom display mode: '.$zoom);
2819 if (function_exists(
'gzcompress')) {
2820 $this->compress =
$compress ?
true :
false;
2822 $this->compress =
false;
2833 $this->force_srgb = $mode ?
true :
false;
2844 $this->docinfounicode = $unicode ?
true :
false;
2912 die(
'<strong>TCPDF ERROR: </strong>'.$msg);
2914 throw new Exception(
'TCPDF ERROR: '.$msg);
2939 if ($this->state == 3) {
2942 if ($this->page == 0) {
2946 if ($this->tcpdflink) {
2950 $this->lastpage(
true);
2953 $this->y = $this->h - (1 /
$this->k);
2959 $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";
2960 $lnk =
"\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67";
2961 $this->
Cell(0, 0, $msg, 0, 0,
'L', 0, $lnk, 0,
false,
'D',
'B');
2982 public function setPage($pnum, $resetmargins=
false) {
2983 if (($pnum == $this->page) AND ($this->state == 2)) {
2986 if (($pnum > 0) AND ($pnum <= $this->numpages)) {
2991 $this->page = $pnum;
2996 $this->tMargin = $this->pagedim[
$this->page][
'tm'];
2997 $this->bMargin = $this->pagedim[
$this->page][
'bm'];
2998 $this->original_lMargin = $this->pagedim[
$this->page][
'olm'];
2999 $this->original_rMargin = $this->pagedim[
$this->page][
'orm'];
3000 $this->AutoPageBreak = $this->pagedim[
$this->page][
'pb'];
3001 $this->CurOrientation = $this->pagedim[
$this->page][
'or'];
3005 if ($resetmargins) {
3006 $this->lMargin = $this->pagedim[
$this->page][
'olm'];
3007 $this->rMargin = $this->pagedim[
$this->page][
'orm'];
3008 $this->
SetY($this->tMargin);
3011 if ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$oldpage][
'olm']) {
3013 $this->lMargin += $deltam;
3014 $this->rMargin -= $deltam;
3018 $this->
Error(
'Wrong page number on setPage() function: '.$pnum);
3064 public function addTOCPage($orientation=
'', $format=
'', $keepmargins=
false) {
3065 $this->
AddPage($orientation, $format, $keepmargins,
true);
3089 public function AddPage($orientation=
'', $format=
'', $keepmargins=
false,
$tocpage=
false) {
3090 if ($this->inxobj) {
3094 if (!isset($this->original_lMargin) OR $keepmargins) {
3097 if (!isset($this->original_rMargin) OR $keepmargins) {
3115 if (($this->page == 0) OR ($this->numpages > $this->page) OR (!$this->pageopen[$this->page])) {
3125 $this->tocpage =
false;
3141 $this->tocpage =
true;
3144 if ($this->tocpage) {
3148 foreach ($tmpoutlines as $key => $outline) {
3149 if ($outline[
'p'] > $this->numpages) {
3150 $this->outlines[$key][
'p'] = ($outline[
'p'] + 1);
3155 foreach ($tmpdests as $key => $dest) {
3156 if ($dest[
'p'] > $this->numpages) {
3157 $this->dests[$key][
'p'] = ($dest[
'p'] + 1);
3162 foreach ($tmplinks as $key => $link) {
3163 if ($link[0] > $this->numpages) {
3164 $this->links[$key][0] = ($link[0] + 1);
3168 if ($this->numpages > $this->page) {
3170 $this->
setPage($this->page + 1);
3171 $this->
SetY($this->tMargin);
3175 if ($this->state == 0) {
3227 if (isset($this->footerlen[
$page])) {
3228 $this->cntmrk[
$page] = $this->pagelen[
$page] - $this->footerlen[
$page];
3230 $this->cntmrk[
$page] = $this->pagelen[
$page];
3244 public function setHeaderData($ln=
'', $lw=0, $ht=
'', $hs=
'', $tc=array(0,0,0), $lc=array(0,0,0)) {
3245 $this->header_logo = $ln;
3246 $this->header_logo_width = $lw;
3247 $this->header_title = $ht;
3248 $this->header_string = $hs;
3249 $this->header_text_color = $tc;
3250 $this->header_line_color = $lc;
3260 $this->footer_text_color = $tc;
3261 $this->footer_line_color = $lc;
3289 $this->header_margin = $hm;
3309 $this->footer_margin = $fm;
3327 $this->print_header = $val ?
true :
false;
3336 $this->print_footer = $val ?
true :
false;
3362 $this->header_xobjid =
false;
3371 $this->header_xobj_autoreset = $val ?
true :
false;
3380 if ($this->header_xobjid ===
false) {
3382 $this->header_xobjid = $this->
startTemplate($this->w, $this->tMargin);
3391 if (($headerdata[
'logo']) AND ($headerdata[
'logo'] !=
K_BLANK_IMAGE)) {
3393 if (($imgtype ==
'eps') OR ($imgtype ==
'ai')) {
3394 $this->
ImageEps(K_PATH_IMAGES.$headerdata[
'logo'],
'',
'', $headerdata[
'logo_width']);
3395 } elseif ($imgtype ==
'svg') {
3396 $this->
ImageSVG(K_PATH_IMAGES.$headerdata[
'logo'],
'',
'', $headerdata[
'logo_width']);
3398 $this->
Image(K_PATH_IMAGES.$headerdata[
'logo'],
'',
'', $headerdata[
'logo_width']);
3404 $cell_height = $this->
getCellHeight($headerfont[2] / $this->k);
3407 $header_x = $this->original_rMargin + ($headerdata[
'logo_width'] * 1.1);
3409 $header_x = $this->original_lMargin + ($headerdata[
'logo_width'] * 1.1);
3411 $cw = $this->w - $this->original_lMargin - $this->original_rMargin - ($headerdata[
'logo_width'] * 1.1);
3414 $this->
SetFont($headerfont[0],
'B', $headerfont[2] + 1);
3415 $this->
SetX($header_x);
3416 $this->
Cell($cw, $cell_height, $headerdata[
'title'], 0, 1,
'', 0,
'', 0);
3418 $this->
SetFont($headerfont[0], $headerfont[1], $headerfont[2]);
3419 $this->
SetX($header_x);
3420 $this->
MultiCell($cw, $cell_height, $headerdata[
'string'], 0,
'', 0, 1,
'',
'',
true, 0,
false,
true, 0,
'T',
false);
3422 $this->
SetLineStyle(array(
'width' => 0.85 / $this->k,
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $headerdata[
'line_color']));
3423 $this->
SetY((2.835 / $this->k) + max($imgy, $this->y));
3425 $this->
SetX($this->original_rMargin);
3427 $this->
SetX($this->original_lMargin);
3429 $this->
Cell(($this->w - $this->original_lMargin - $this->original_rMargin), 0,
'',
'T', 0,
'C');
3435 if (!$this->header_xobj_autoreset AND $this->booklet AND (($this->page % 2) == 0)) {
3440 $x = $this->w + $dx;
3444 $this->
printTemplate($this->header_xobjid,
$x, 0, 0, 0,
'',
'',
false);
3445 if ($this->header_xobj_autoreset) {
3447 $this->header_xobjid =
false;
3461 $this->
SetLineStyle(array(
'width' => $line_width,
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $this->footer_line_color));
3465 $this->
Ln($line_width);
3466 $barcode_width = round(($this->w - $this->original_lMargin - $this->original_rMargin) / 3);
3468 'position' => $this->rtl?
'R':
'L',
3469 'align' => $this->rtl?
'R':
'L',
3472 'cellfitalign' =>
'',
3475 'fgcolor' => array(0,0,0),
3479 $this->
write1DBarcode(
$barcode,
'C128',
'', $cur_y + $line_width,
'', (($this->footer_margin / 3) - $line_width), 0.3, $style,
'');
3481 $w_page = isset($this->l[
'w_page']) ? $this->l[
'w_page'].
' ' :
'';
3482 if (empty($this->pagegroups)) {
3483 $pagenumtxt = $w_page.$this->getAliasNumPage().
' / '.$this->
getAliasNbPages();
3485 $pagenumtxt = $w_page.$this->getPageNumGroupAlias().
' / '.$this->
getPageGroupAlias();
3487 $this->
SetY($cur_y);
3490 $this->
SetX($this->original_rMargin);
3491 $this->
Cell(0, 0, $pagenumtxt,
'T', 0,
'L');
3493 $this->
SetX($this->original_lMargin);
3504 if (!$this->print_header OR ($this->state != 2)) {
3507 $this->InHeader =
true;
3519 $this->
SetXY($this->original_rMargin, $this->header_margin);
3521 $this->
SetXY($this->original_lMargin, $this->header_margin);
3523 $this->
SetFont($this->header_font[0], $this->header_font[1], $this->header_font[2]);
3527 $this->
SetXY($this->original_rMargin, $this->tMargin);
3529 $this->
SetXY($this->original_lMargin, $this->tMargin);
3533 $this->thead = $temp_thead;
3534 $this->theadMargins = $temp_theadMargins;
3536 $this->InHeader =
false;
3545 if ($this->state != 2) {
3548 $this->InFooter =
true;
3554 if ($this->print_footer) {
3556 $this->current_column = 0;
3557 $this->num_columns = 1;
3568 $this->
SetXY($this->original_rMargin, $footer_y);
3570 $this->
SetXY($this->original_lMargin, $footer_y);
3572 $this->
SetFont($this->footer_font[0], $this->footer_font[1], $this->footer_font[2]);
3576 $this->
SetXY($this->original_rMargin, $this->tMargin);
3578 $this->
SetXY($this->original_lMargin, $this->tMargin);
3582 $this->thead = $temp_thead;
3583 $this->theadMargins = $temp_theadMargins;
3587 $this->current_column = $gvars[
'current_column'];
3588 $this->num_columns = $gvars[
'num_columns'];
3591 $this->InFooter =
false;
3601 return (($this->InHeader ===
false) AND ($this->InFooter ===
false));
3610 if ($this->num_columns > 1) {
3614 if (isset($this->theadMargins[
'top'])) {
3616 $this->tMargin = $this->theadMargins[
'top'];
3625 $this->lMargin = $this->theadMargins[
'lmargin'] + ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$this->theadMargins[
'page']][
'olm']);
3626 $this->rMargin = $this->theadMargins[
'rmargin'] + ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$this->theadMargins[
'page']][
'orm']);
3627 $this->cell_padding = $this->theadMargins[
'cell_padding'];
3634 if ($this->theadMargins[
'cell']) {
3636 $this->x -= $this->cell_padding[
'R'];
3638 $this->x += $this->cell_padding[
'L'];
3642 if (!empty($this->theadMargins[
'gvars'])) {
3645 $this->rMargin = $gvars[
'rMargin'];
3646 $this->lMargin = $gvars[
'lMargin'];
3649 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
3652 if (!isset($this->theadMargins[
'top'])) {
3656 if (!isset($this->columns[0][
'th'])) {
3657 $this->columns[0][
'th'] = array();
3659 $this->columns[0][
'th'][
'\''.$this->page.
'\''] =
$this->y;
3663 $this->lMargin = $prev_lMargin;
3664 $this->rMargin = $prev_rMargin;
3665 $this->cell_padding = $prev_cell_padding;
3704 if (!isset($this->spot_colors[$name])) {
3705 $i = (1 + count($this->spot_colors));
3706 $this->spot_colors[$name] = array(
'C' => $c,
'M' => $m,
'Y' =>
$y,
'K' =>
$k,
'name' => $name,
'i' => $i);
3721 if ($spotcolor ===
false) {
3722 $this->
Error(
'Undefined spot color: '.$name.
', you must add it using the AddSpotColor() method.');
3724 $tint = (max(0, min(100, $tint)) / 100);
3725 $pdfcolor = sprintf(
'/CS%d ', $this->spot_colors[$name][
'i']);
3728 $pdfcolor .= sprintf(
'CS %F SCN', $tint);
3729 $this->DrawColor = $pdfcolor;
3730 $this->strokecolor = $spotcolor;
3734 $pdfcolor .= sprintf(
'cs %F scn', $tint);
3735 $this->FillColor = $pdfcolor;
3736 $this->bgcolor = $spotcolor;
3740 $pdfcolor .= sprintf(
'cs %F scn', $tint);
3741 $this->TextColor = $pdfcolor;
3742 $this->fgcolor = $spotcolor;
3747 if ($this->state == 2) {
3748 $this->
_out($pdfcolor);
3750 if ($this->inxobj) {
3752 $this->xobjects[
$this->xobjid][
'spot_colors'][$name] = $this->spot_colors[$name];
3805 if (is_array($color)) {
3806 $color = array_values($color);
3808 $c = isset($color[0]) ? $color[0] : -1;
3810 $m = isset($color[1]) ? $color[1] : -1;
3812 $y = isset($color[2]) ? $color[2] : -1;
3814 $k = isset($color[3]) ? $color[3] : -1;
3816 $name = isset($color[4]) ? $color[4] :
'';
3818 return $this->
setColor($type, $c, $m,
$y,
$k, $ret, $name);
3879 public function setColor($type, $col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=
false, $name=
'') {
3881 if (!is_numeric($col1)) {
3884 if (!is_numeric($col2)) {
3887 if (!is_numeric($col3)) {
3890 if (!is_numeric($col4)) {
3895 if (($col2 == -1) AND ($col3 == -1) AND ($col4 == -1)) {
3897 $col1 = max(0, min(255, $col1));
3898 $intcolor = array(
'G' => $col1);
3899 $pdfcolor = sprintf(
'%F ', ($col1 / 255));
3901 } elseif ($col4 == -1) {
3903 $col1 = max(0, min(255, $col1));
3904 $col2 = max(0, min(255, $col2));
3905 $col3 = max(0, min(255, $col3));
3906 $intcolor = array(
'R' => $col1,
'G' => $col2,
'B' => $col3);
3907 $pdfcolor = sprintf(
'%F %F %F ', ($col1 / 255), ($col2 / 255), ($col3 / 255));
3910 $col1 = max(0, min(100, $col1));
3911 $col2 = max(0, min(100, $col2));
3912 $col3 = max(0, min(100, $col3));
3913 $col4 = max(0, min(100, $col4));
3916 $intcolor = array(
'C' => $col1,
'M' => $col2,
'Y' => $col3,
'K' => $col4);
3917 $pdfcolor = sprintf(
'%F %F %F %F ', ($col1 / 100), ($col2 / 100), ($col3 / 100), ($col4 / 100));
3921 $intcolor = array(
'C' => $col1,
'M' => $col2,
'Y' => $col3,
'K' => $col4,
'name' => $name);
3922 $this->
AddSpotColor($name, $col1, $col2, $col3, $col4);
3928 $pdfcolor .= strtoupper($suffix);
3929 $this->DrawColor = $pdfcolor;
3930 $this->strokecolor = $intcolor;
3934 $pdfcolor .= $suffix;
3935 $this->FillColor = $pdfcolor;
3936 $this->bgcolor = $intcolor;
3940 $pdfcolor .= $suffix;
3941 $this->TextColor = $pdfcolor;
3942 $this->fgcolor = $intcolor;
3947 if (($type !=
'text') AND ($this->state == 2)) {
3949 $this->
_out($pdfcolor);
3969 public function SetDrawColor($col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=
false, $name=
'') {
3970 return $this->
setColor(
'draw', $col1, $col2, $col3, $col4, $ret, $name);
3986 public function SetFillColor($col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=
false, $name=
'') {
3987 return $this->
setColor(
'fill', $col1, $col2, $col3, $col4, $ret, $name);
4003 public function SetTextColor($col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=
false, $name=
'') {
4004 return $this->
setColor(
'text', $col1, $col2, $col3, $col4, $ret, $name);
4019 public function GetStringWidth($s, $fontname=
'', $fontstyle=
'', $fontsize=0, $getarray=
false) {
4020 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);
4041 $this->
SetFont($fontname, $fontstyle, $fontsize,
'',
'default',
false);
4049 foreach ($sa as $ck => $char) {
4051 $cw = $this->
GetCharWidth($char, isset($sa[($ck + 1)]));
4057 $this->
SetFont($prev_FontFamily, $prev_FontStyle, $prev_FontSizePt,
'',
'default',
false);
4077 if (($this->font_spacing < 0) OR (($this->font_spacing > 0) AND $notlast)) {
4081 if ($this->font_stretching != 100) {
4083 $chw *= ($this->font_stretching / 100);
4101 if (isset($this->CurrentFont[
'cw'][$char])) {
4102 $w = $this->CurrentFont[
'cw'][$char];
4103 } elseif (isset($this->CurrentFont[
'dw'])) {
4105 $w = $this->CurrentFont[
'dw'];
4106 } elseif (isset($this->CurrentFont[
'cw'][32])) {
4108 $w = $this->CurrentFont[
'cw'][32];
4136 while (($file = readdir($fontsdir)) !==
false) {
4137 if (substr($file, -4) ==
'.php') {
4138 array_push($this->fontlist, strtolower(basename($file,
'.php')));
4141 closedir($fontsdir);
4173 public function addTTFfont($fontfile, $fonttype=
'', $enc=
'', $flags=32, $outpath=
'', $platid=3, $encid=1, $addcbbox=
false) {
4190 public function AddFont($family, $style=
'', $fontfile=
'', $subset=
'default') {
4191 if ($subset ===
'default') {
4194 if ($this->pdfa_mode) {
4201 $this->
Error(
'Empty font family');
4205 if (substr($family, -1) ==
'I') {
4207 $family = substr($family, 0, -1);
4209 if (substr($family, -1) ==
'B') {
4211 $family = substr($family, 0, -1);
4214 $family = strtolower($family);
4215 if ((!$this->isunicode) AND ($family ==
'arial')) {
4216 $family =
'helvetica';
4218 if (($family ==
'symbol') OR ($family ==
'zapfdingbats')) {
4221 if ($this->pdfa_mode AND (isset($this->CoreFonts[$family]))) {
4223 $family =
'pdfa'.$family;
4225 $tempstyle = strtoupper($style);
4228 if (strpos($tempstyle,
'U') !==
false) {
4229 $this->underline =
true;
4231 $this->underline =
false;
4234 if (strpos($tempstyle,
'D') !==
false) {
4235 $this->linethrough =
true;
4237 $this->linethrough =
false;
4240 if (strpos($tempstyle,
'O') !==
false) {
4241 $this->overline =
true;
4243 $this->overline =
false;
4246 if (strpos($tempstyle,
'B') !==
false) {
4250 if (strpos($tempstyle,
'I') !==
false) {
4254 $fontkey = $family.$style;
4255 $font_style = $style.($this->underline ?
'U' :
'').($this->linethrough ?
'D' :
'').($this->overline ?
'O' :
'');
4256 $fontdata = array(
'fontkey' => $fontkey,
'family' => $family,
'style' => $font_style);
4259 if ($fb !==
false) {
4260 if ($this->inxobj) {
4262 $this->xobjects[
$this->xobjid][
'fonts'][$fontkey] = $fb[
'i'];
4269 $fontdir = dirname($fontfile);
4277 $missing_style =
false;
4281 $tmp_fontfile = str_replace(
' ',
'', $family).strtolower($style).
'.php';
4284 $missing_style =
true;
4286 $tmp_fontfile = str_replace(
' ',
'', $family).
'.php';
4294 $this->
Error(
'Could not include font definition file: '.$family.
'');
4297 if ((!isset($type)) OR (!isset($cw))) {
4298 $this->
Error(
'The font definition file has a bad format: '.$fontfile.
'');
4308 $cidinfo = array(
'Registry'=>
'Adobe',
'Ordering'=>
'Identity',
'Supplement'=>0);
4309 $cidinfo[
'uni2cid'] = array();
4328 if (isset($desc[
'MissingWidth']) AND ($desc[
'MissingWidth'] > 0)) {
4329 $dw = $desc[
'MissingWidth'];
4330 } elseif (isset($cw[32])) {
4337 if ($type ==
'core') {
4338 $name = $this->CoreFonts[$fontkey];
4340 } elseif (($type ==
'TrueType') OR ($type ==
'Type1')) {
4342 } elseif ($type ==
'TrueTypeUnicode') {
4343 $enc =
'Identity-H';
4344 } elseif ($type ==
'cidfont0') {
4345 if ($this->pdfa_mode) {
4346 $this->
Error(
'All fonts must be embedded in PDF/A mode!');
4349 $this->
Error(
'Unknow font type: '.$type.
'');
4352 if (!isset($name) OR empty($name)) {
4356 if (($type !=
'core') AND $missing_style) {
4358 $styles = array(
'' =>
'',
'B' =>
',Bold',
'I' =>
',Italic',
'BI' =>
',BoldItalic');
4359 $name .= $styles[$bistyle];
4361 if (strpos($bistyle,
'B') !==
false) {
4362 if (isset($desc[
'StemV'])) {
4364 $desc[
'StemV'] = round($desc[
'StemV'] * 1.75);
4367 $desc[
'StemV'] = 123;
4371 if (strpos($bistyle,
'I') !==
false) {
4372 if (isset($desc[
'ItalicAngle'])) {
4373 $desc[
'ItalicAngle'] -= 11;
4375 $desc[
'ItalicAngle'] = -11;
4377 if (isset($desc[
'Flags'])) {
4378 $desc[
'Flags'] |= 64;
4380 $desc[
'Flags'] = 64;
4385 if (!isset($cbbox)) {
4389 $subsetchars = array_fill(0, 255,
true);
4390 $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));
4391 if ($this->inxobj) {
4395 if (isset($diff) AND (!empty($diff))) {
4398 $nb = count($this->diffs);
4399 for ($i=1; $i <= $nb; ++$i) {
4400 if ($this->diffs[$i] == $diff) {
4407 $this->diffs[$d] = $diff;
4412 if (!isset($this->FontFiles[$file])) {
4413 if ((strcasecmp($type,
'TrueType') == 0) OR (strcasecmp($type,
'TrueTypeUnicode') == 0)) {
4414 $this->FontFiles[$file] = array(
'length1' => $originalsize,
'fontdir' => $fontdir,
'subset' => $subset,
'fontkeys' => array($fontkey));
4415 } elseif ($type !=
'core') {
4416 $this->FontFiles[$file] = array(
'length1' => $size1,
'length2' => $size2,
'fontdir' => $fontdir,
'subset' => $subset,
'fontkeys' => array($fontkey));
4420 $this->FontFiles[$file][
'subset'] = ($this->FontFiles[$file][
'subset'] AND $subset);
4421 if (!in_array($fontkey, $this->FontFiles[$file][
'fontkeys'])) {
4422 $this->FontFiles[$file][
'fontkeys'][] = $fontkey;
4446 public function SetFont($family, $style=
'', $size=null, $fontfile=
'', $subset=
'default', $out=
true) {
4448 if ($size === null) {
4455 $fontdata = $this->
AddFont($family, $style, $fontfile, $subset);
4456 $this->FontFamily = $fontdata[
'family'];
4457 $this->FontStyle = $fontdata[
'style'];
4458 if (isset($this->CurrentFont[
'fontkey']) AND isset($this->CurrentFont[
'subsetchars'])) {
4460 $this->
setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
4462 $this->CurrentFont = $this->
getFontBuffer($fontdata[
'fontkey']);
4476 $this->FontSizePt = $size;
4478 $this->FontSize = $size /
$this->k;
4480 if (isset($this->CurrentFont[
'desc'][
'FontBBox'])) {
4481 $bbox = explode(
' ', substr($this->CurrentFont[
'desc'][
'FontBBox'], 1, -1));
4482 $font_height = ((intval($bbox[3]) - intval($bbox[1])) * $size / 1000);
4484 $font_height = $size * 1.219;
4486 if (isset($this->CurrentFont[
'desc'][
'Ascent']) AND ($this->CurrentFont[
'desc'][
'Ascent'] > 0)) {
4487 $font_ascent = ($this->CurrentFont[
'desc'][
'Ascent'] * $size / 1000);
4489 if (isset($this->CurrentFont[
'desc'][
'Descent']) AND ($this->CurrentFont[
'desc'][
'Descent'] <= 0)) {
4490 $font_descent = (- $this->CurrentFont[
'desc'][
'Descent'] * $size / 1000);
4492 if (!isset($font_ascent) AND !isset($font_descent)) {
4494 $font_ascent = 0.76 * $font_height;
4495 $font_descent = $font_height - $font_ascent;
4496 } elseif (!isset($font_descent)) {
4497 $font_descent = $font_height - $font_ascent;
4498 } elseif (!isset($font_ascent)) {
4499 $font_ascent = $font_height - $font_descent;
4501 $this->FontAscent = ($font_ascent /
$this->k);
4502 $this->FontDescent = ($font_descent /
$this->k);
4503 if ($out AND ($this->page > 0) AND (isset($this->CurrentFont[
'i'])) AND ($this->state == 2)) {
4504 $this->
_out(sprintf(
'BT /F%d %F Tf ET', $this->CurrentFont[
'i'], $this->FontSizePt));
4516 if (isset($this->CurrentFont[
'desc'][
'FontBBox'])) {
4517 $tmpbbox = explode(
' ', substr($this->CurrentFont[
'desc'][
'FontBBox'], 1, -1));
4518 $fbbox = array_map(array($this,
'getAbsFontMeasure'), $tmpbbox);
4521 if (isset($this->CurrentFont[
'desc'][
'MaxWidth'])) {
4522 $maxw = $this->
getAbsFontMeasure(intval($this->CurrentFont[
'desc'][
'MaxWidth']));
4525 if (isset($this->CurrentFont[
'desc'][
'MissingWidth'])) {
4526 $maxw = max($maxw, $this->CurrentFont[
'desc'][
'MissingWidth']);
4528 if (isset($this->CurrentFont[
'desc'][
'AvgWidth'])) {
4529 $maxw = max($maxw, $this->CurrentFont[
'desc'][
'AvgWidth']);
4531 if (isset($this->CurrentFont[
'dw'])) {
4532 $maxw = max($maxw, $this->CurrentFont[
'dw']);
4534 foreach ($this->CurrentFont[
'cw'] as $char =>
$w) {
4535 $maxw = max($maxw,
$w);
4542 $fbbox = array(0, (0 - $this->FontDescent), $maxw, $this->FontAscent);
4554 return ($s * $this->FontSize / 1000);
4564 if (isset($this->CurrentFont[
'cbbox'][$char])) {
4565 return array_map(array($this,
'getAbsFontMeasure'), $this->CurrentFont[
'cbbox'][intval($char)]);
4581 $fontdata = $this->
AddFont($font, $style);
4583 if (isset($fontinfo[
'desc'][
'Descent']) AND ($fontinfo[
'desc'][
'Descent'] <= 0)) {
4584 $descent = (- $fontinfo[
'desc'][
'Descent'] * $size / 1000);
4586 $descent = (1.219 * 0.24 * $size);
4588 return ($descent / $this->k);
4602 $fontdata = $this->
AddFont($font, $style);
4604 if (isset($fontinfo[
'desc'][
'Ascent']) AND ($fontinfo[
'desc'][
'Ascent'] > 0)) {
4605 $ascent = ($fontinfo[
'desc'][
'Ascent'] * $size / 1000);
4607 $ascent = 1.219 * 0.76 * $size;
4609 return ($ascent / $this->k);
4622 if (is_string($char)) {
4629 return (isset($this->CurrentFont[
'cw'][intval($char)]));
4633 $fontdata = $this->
AddFont($font, $style);
4635 return (isset($fontinfo[
'cw'][intval($char)]));
4655 $fontdata = $this->
AddFont($font, $style);
4658 foreach ($uniarr as
$k => $chr) {
4659 if (!isset($fontinfo[
'cw'][$chr])) {
4661 if (isset($subs[$chr])) {
4663 if (is_array($subs[$chr])) {
4664 foreach($subs[$chr] as $s) {
4665 if (isset($fontinfo[
'cw'][$s])) {
4670 } elseif (isset($fontinfo[
'cw'][$subs[$chr]])) {
4671 $uniarr[
$k] = $subs[$chr];
4686 $this->default_monospaced_font = $font;
4698 $n = count($this->links) + 1;
4699 $this->links[
$n] = array(0, 0);
4719 $this->links[$link] = array(
$page,
$y);
4753 if ($this->inxobj) {
4755 $this->xobjects[
$this->xobjid][
'annotations'][] = array(
'x' =>
$x,
'y' =>
$y,
'w' =>
$w,
'h' =>
$h,
'text' => $text,
'opt' => $opt,
'spaces' => $spaces);
4767 if (isset($this->transfmatrix) AND !empty($this->transfmatrix)) {
4768 for ($i=$this->transfmatrix_key; $i > 0; --$i) {
4769 $maxid = count($this->transfmatrix[$i]) - 1;
4770 for ($j=$maxid; $j >= 0; --$j) {
4771 $ctm = $this->transfmatrix[$i][$j];
4772 if (isset($ctm[
'a'])) {
4774 $y = ($this->h -
$y) * $this->k;
4780 $x1 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4781 $y1 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4785 $x2 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4786 $y2 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4790 $x3 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4791 $y3 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4795 $x4 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4796 $y4 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4798 $x = min($x1, $x2, $x3, $x4);
4799 $y = max($y1, $y2, $y3, $y4);
4800 $w = (max($x1, $x2, $x3, $x4) -
$x) / $this->k;
4801 $h = (
$y - min($y1, $y2, $y3, $y4)) / $this->k;
4808 if ($this->page <= 0) {
4813 if (!isset($this->PageAnnots[
$page])) {
4814 $this->PageAnnots[
$page] = array();
4816 $this->PageAnnots[
$page][] = array(
'n' => ++$this->n,
'x' =>
$x,
'y' =>
$y,
'w' =>
$w,
'h' =>
$h,
'txt' => $text,
'opt' => $opt,
'numspaces' => $spaces);
4817 if (!$this->pdfa_mode) {
4820 AND (!isset($this->embeddedfiles[basename($opt[
'FS'])]))) {
4821 $this->embeddedfiles[basename($opt[
'FS'])] = array(
'f' => ++$this->n,
'n' => ++$this->n,
'file' => $opt[
'FS']);
4825 if (isset($opt[
'mk'][
'i']) AND @file_exists($opt[
'mk'][
'i'])) {
4826 $this->
Image($opt[
'mk'][
'i'],
'',
'', 10, 10,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
4828 if (isset($opt[
'mk'][
'ri']) AND @file_exists($opt[
'mk'][
'ri'])) {
4829 $this->
Image($opt[
'mk'][
'ri'],
'',
'', 0, 0,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
4831 if (isset($opt[
'mk'][
'ix']) AND @file_exists($opt[
'mk'][
'ix'])) {
4832 $this->
Image($opt[
'mk'][
'ix'],
'',
'', 0, 0,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
4843 if ($this->pdfa_mode) {
4847 reset($this->embeddedfiles);
4848 foreach ($this->embeddedfiles as $filename => $filedata) {
4850 if ($data !== FALSE) {
4851 $rawsize = strlen($data);
4854 $this->efnames[$filename] = $filedata[
'f'].
' 0 R';
4856 $out = $this->
_getobj($filedata[
'f']).
"\n";
4857 $out .=
'<</Type /Filespec /F '.$this->_datastring($filename, $filedata[
'f']).
' /EF <</F '.$filedata[
'n'].
' 0 R>> >>';
4858 $out .=
"\n".
'endobj';
4862 if ($this->compress) {
4863 $data = gzcompress($data);
4864 $filter =
' /Filter /FlateDecode';
4867 $out = $this->
_getobj($filedata[
'n']).
"\n";
4868 $out .=
'<< /Type /EmbeddedFile'.$filter.
' /Length '.strlen($stream).
' /Params <</Size '.$rawsize.
'>> >>';
4869 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
4870 $out .=
"\n".
'endobj';
4900 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) {
4905 $this->
Cell(0, 0, $txt, $border, $ln, $align, $fill, $link, $stretch, $ignore_min_height, $calign, $valign);
4921 if ($this->num_columns > 1) {
4923 if ($this->current_column < ($this->num_columns - 1)) {
4926 } elseif ($this->AutoPageBreak) {
4956 $this->
AddPage($this->CurOrientation);
4958 $oldpage = $this->page - 1;
4960 if ($this->pagedim[$this->page][
'orm'] != $this->pagedim[$oldpage][
'orm']) {
4961 $this->x =
$x - ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$oldpage][
'orm']);
4966 if ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$oldpage][
'olm']) {
4967 $this->x =
$x + ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$oldpage][
'olm']);
4975 if ($current_page != $this->page) {
5001 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') {
5005 if (!$ignore_min_height) {
5007 if (
$h < $min_cell_height) {
5008 $h = $min_cell_height;
5011 $this->
checkPageBreak(
$h + $this->cell_margin[
'T'] + $this->cell_margin[
'B']);
5013 if ($this->txtshadow[
'enabled']) {
5022 $this->x += $this->txtshadow[
'depth_w'];
5023 $this->y += $this->txtshadow[
'depth_h'];
5027 if ($this->txtshadow[
'opacity'] !=
$alpha[
'CA']) {
5028 $this->
setAlpha($this->txtshadow[
'opacity'], $this->txtshadow[
'blend_mode']);
5030 if ($this->state == 2) {
5031 $this->
_out($this->
getCellCode(
$w,
$h, $txt, $border, $ln, $align, $fill, $link, $stretch,
true, $calign, $valign));
5039 if ($this->txtshadow[
'opacity'] !=
$alpha[
'CA']) {
5043 if ($this->state == 2) {
5044 $this->
_out($this->
getCellCode(
$w,
$h, $txt, $border, $ln, $align, $fill, $link, $stretch,
true, $calign, $valign));
5046 $this->cell_padding = $prev_cell_padding;
5047 $this->cell_margin = $prev_cell_margin;
5070 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') {
5078 if (!$ignore_min_height) {
5080 if (
$h < $min_cell_height) {
5081 $h = $min_cell_height;
5088 $x = $this->x - $this->cell_margin[
'R'];
5090 $x = $this->x + $this->cell_margin[
'L'];
5092 $y = $this->y + $this->cell_margin[
'T'];
5102 $y -= $this->cell_padding[
'T'];
5153 $y -= (
$h - $this->cell_padding[
'B']);
5187 $yt =
$y + $this->cell_padding[
'T'];
5208 $w = $this->w - $this->rMargin -
$x;
5213 if (is_string($border) AND (strlen($border) == 4)) {
5217 if ($fill OR ($border == 1)) {
5219 $op = ($border == 1) ?
'B' :
'f';
5228 $s .= sprintf(
'%F %F %F %F re %s ', $xk, (($this->h -
$y) *
$k), (
$w * $k), (-
$h * $k), $op);
5234 if ($this->isunicode) {
5235 if (($this->CurrentFont[
'type'] ==
'core') OR ($this->CurrentFont[
'type'] ==
'TrueType') OR ($this->CurrentFont[
'type'] ==
'Type1')) {
5239 $unicode =
TCPDF_FONTS::utf8Bidi($unicode,
'', $this->tmprtl, $this->isunicode, $this->CurrentFont);
5243 $numchars = count($unicode);
5245 $longtail = array(0x0e1b, 0x0e1d, 0x0e1f);
5247 $lowtail = array(0x0e0e, 0x0e0f);
5249 $upvowel = array(0x0e31, 0x0e34, 0x0e35, 0x0e36, 0x0e37);
5251 $tonemark = array(0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c);
5253 $lowvowel = array(0x0e38, 0x0e39, 0x0e3a);
5255 for ($i = 0; $i < $numchars; $i++) {
5256 if (($unicode[$i] >= 0x0e00) && ($unicode[$i] <= 0x0e5b)) {
5257 $ch0 = $unicode[$i];
5258 $ch1 = ($i > 0) ? $unicode[($i - 1)] : 0;
5259 $ch2 = ($i > 1) ? $unicode[($i - 2)] : 0;
5260 $chn = ($i < ($numchars - 1)) ? $unicode[($i + 1)] : 0;
5261 if (in_array($ch0, $tonemark)) {
5262 if ($chn == 0x0e33) {
5264 if (in_array($ch1, $longtail)) {
5266 $output[] = $this->
replaceChar($ch0, (0xf713 + $ch0 - 0x0e48));
5271 } elseif (in_array($ch1, $longtail) OR (in_array($ch2, $longtail) AND in_array($ch1, $lowvowel))) {
5273 $output[] = $this->
replaceChar($ch0, (0xf705 + $ch0 - 0x0e48));
5274 } elseif (in_array($ch1, $upvowel)) {
5275 if (in_array($ch2, $longtail)) {
5277 $output[] = $this->
replaceChar($ch0, (0xf713 + $ch0 - 0x0e48));
5284 $output[] = $this->
replaceChar($ch0, (0xf70a + $ch0 - 0x0e48));
5286 } elseif (($ch0 == 0x0e33) AND (in_array($ch1, $longtail) OR (in_array($ch2, $longtail) AND in_array($ch1, $tonemark)))) {
5290 $this->CurrentFont[
'subsetchars'][0xf711] =
true;
5292 $this->CurrentFont[
'subsetchars'][0x0e32] =
true;
5296 } elseif (in_array($ch1, $longtail)) {
5297 if ($ch0 == 0x0e31) {
5300 } elseif (in_array($ch0, $upvowel)) {
5302 $output[] = $this->
replaceChar($ch0, (0xf701 + $ch0 - 0x0e34));
5303 } elseif ($ch0 == 0x0e47) {
5310 } elseif (in_array($ch1, $lowtail) AND in_array($ch0, $lowvowel)) {
5312 $output[] = $this->
replaceChar($ch0, (0xf718 + $ch0 - 0x0e38));
5313 } elseif (($ch0 == 0x0e0d) AND in_array($chn, $lowvowel)) {
5316 } elseif (($ch0 == 0x0e10) AND in_array($chn, $lowvowel)) {
5324 $output[] = $unicode[$i];
5329 $this->
setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
5344 $ratio = ((
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / $width);
5347 if (($ratio < 1) OR (($ratio > 1) AND (($stretch % 2) == 0))) {
5351 $this->font_spacing += (
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'] - $width) / (max(($this->
GetNumChars($txt) - 1), 1) * ($this->font_stretching / 100));
5354 $this->font_stretching *= $ratio;
5357 $width =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
5362 if ($this->font_stretching != 100) {
5364 $rs .= sprintf(
'BT %F Tz ET ', $this->font_stretching);
5366 if ($this->font_spacing != 0) {
5368 $rs .= sprintf(
'BT %F Tc ET ', ($this->font_spacing * $this->k));
5370 if ($this->ColorFlag AND ($this->textrendermode < 4)) {
5371 $s .=
'q '.$this->TextColor.
' ';
5374 $s .= sprintf(
'BT %d Tr %F w ET ', $this->textrendermode, ($this->textstrokewidth * $this->k));
5376 $ns = substr_count($txt, chr(32));
5379 if (($align ==
'J') AND ($ns > 0)) {
5384 $spacewidth = -1000 * (
$w - $width - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1) / ($this->FontSize?$this->FontSize:1);
5385 if ($this->font_stretching != 100) {
5387 $spacewidth /= ($this->font_stretching / 100);
5390 $txt2 = str_replace(chr(0).chr(32),
') '.sprintf(
'%F', $spacewidth).
' (', $txt2);
5391 $unicode_justification =
true;
5396 $spacewidth = ((
$w - $width - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1)) * $this->k;
5397 if ($this->font_stretching != 100) {
5399 $spacewidth /= ($this->font_stretching / 100);
5402 $rs .= sprintf(
'BT %F Tw ET ', $spacewidth);
5404 $width =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
5407 $txt2 = str_replace(
"\r",
' ', $txt2);
5410 $dx = (
$w - $width) / 2;
5415 $dx = $this->cell_padding[
'R'];
5417 $dx =
$w - $width - $this->cell_padding[
'R'];
5423 $dx =
$w - $width - $this->cell_padding[
'L'];
5425 $dx = $this->cell_padding[
'L'];
5432 $dx = $this->cell_padding[
'R'];
5434 $dx = $this->cell_padding[
'L'];
5440 $xdx =
$x - $dx - $width;
5446 $s .= sprintf(
'BT %F %F Td [(%s)] TJ ET', $xdk, (($this->h - $basefonty) * $k), $txt2);
5447 if (isset($uniblock)) {
5451 $spw = ((
$w - $txwidth - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1));
5452 foreach ($uniblock as $uk => $uniarr) {
5453 if (($uk % 2) == 0) {
5455 if ($spacewidth != 0) {
5457 $xshift += (count(array_keys($uniarr, 32)) * $spw);
5464 $s .= sprintf(
' BT %F %F Td [(%s)] TJ ET', ($xdk + ($xshift * $k)), $ty, $topchr);
5468 if ($this->underline) {
5469 $s .=
' '.$this->_dounderlinew($xdx, $basefonty, $width);
5471 if ($this->linethrough) {
5472 $s .=
' '.$this->_dolinethroughw($xdx, $basefonty, $width);
5474 if ($this->overline) {
5475 $s .=
' '.$this->_dooverlinew($xdx, $basefonty, $width);
5477 if ($this->ColorFlag AND ($this->textrendermode < 4)) {
5481 $this->
Link($xdx, $yt, $width, ($this->FontAscent + $this->FontDescent), $link, $ns);
5488 if ($this->font_spacing != 0) {
5490 $rs .=
' BT 0 Tc ET';
5492 if ($this->font_stretching != 100) {
5494 $rs .=
' BT 100 Tz ET';
5499 $rs .=
' BT 0 Tw ET';
5502 $this->font_stretching = $prev_font_stretching;
5503 $this->font_spacing = $prev_font_spacing;
5507 $this->y =
$y +
$h + $this->cell_margin[
'B'];
5518 $this->x =
$x -
$w - $this->cell_margin[
'L'];
5520 $this->x =
$x +
$w + $this->cell_margin[
'R'];
5523 $gstyles =
''.$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' '.$this->FillColor.
"\n";
5525 $this->cell_padding = $prev_cell_padding;
5526 $this->cell_margin = $prev_cell_margin;
5541 $this->CurrentFont[
'subsetchars'][$newchar] =
true;
5567 $brd = array(
'LRTB' =>
true);
5576 $xeR = (
$x +
$w) * $k;
5578 $yeL = (($this->h - (
$y +
$h)) *
$k);
5579 $yeT = (($this->h -
$y) *
$k);
5584 if (is_string($brd)) {
5586 $slen = strlen($brd);
5588 for ($i = 0; $i < $slen; ++$i) {
5589 $newbrd[$brd[$i]] = array(
'cap' =>
'square',
'join' =>
'miter');
5593 if (isset($brd[
'mode'])) {
5594 $mode = $brd[
'mode'];
5595 unset($brd[
'mode']);
5599 foreach ($brd as $border => $style) {
5600 if (is_array($style) AND !empty($style)) {
5602 $prev_style = $this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' ';
5607 $off = (($this->LineWidth / 2) *
$k);
5621 $off = ($this->LineWidth / 2) *
$k;
5648 if (strlen($border) == 4) {
5649 $s .= sprintf(
'%F %F %F %F re S ', $xT, $yT, (
$w *
$k), (-
$h * $k));
5650 } elseif (strlen($border) == 3) {
5651 if (strpos($border,
'B') ===
false) {
5652 $s .= sprintf(
'%F %F m ', $xL, $yL);
5653 $s .= sprintf(
'%F %F l ', $xT, $yT);
5654 $s .= sprintf(
'%F %F l ', $xR, $yR);
5655 $s .= sprintf(
'%F %F l ', $xB, $yB);
5657 } elseif (strpos($border,
'L') ===
false) {
5658 $s .= sprintf(
'%F %F m ', $xT, $yT);
5659 $s .= sprintf(
'%F %F l ', $xR, $yR);
5660 $s .= sprintf(
'%F %F l ', $xB, $yB);
5661 $s .= sprintf(
'%F %F l ', $xL, $yL);
5663 } elseif (strpos($border,
'T') ===
false) {
5664 $s .= sprintf(
'%F %F m ', $xR, $yR);
5665 $s .= sprintf(
'%F %F l ', $xB, $yB);
5666 $s .= sprintf(
'%F %F l ', $xL, $yL);
5667 $s .= sprintf(
'%F %F l ', $xT, $yT);
5669 } elseif (strpos($border,
'R') ===
false) {
5670 $s .= sprintf(
'%F %F m ', $xB, $yB);
5671 $s .= sprintf(
'%F %F l ', $xL, $yL);
5672 $s .= sprintf(
'%F %F l ', $xT, $yT);
5673 $s .= sprintf(
'%F %F l ', $xR, $yR);
5676 } elseif (strlen($border) == 2) {
5677 if ((strpos($border,
'L') !==
false) AND (strpos($border,
'T') !==
false)) {
5678 $s .= sprintf(
'%F %F m ', $xL, $yL);
5679 $s .= sprintf(
'%F %F l ', $xT, $yT);
5680 $s .= sprintf(
'%F %F l ', $xR, $yR);
5682 } elseif ((strpos($border,
'T') !==
false) AND (strpos($border,
'R') !==
false)) {
5683 $s .= sprintf(
'%F %F m ', $xT, $yT);
5684 $s .= sprintf(
'%F %F l ', $xR, $yR);
5685 $s .= sprintf(
'%F %F l ', $xB, $yB);
5687 } elseif ((strpos($border,
'R') !==
false) AND (strpos($border,
'B') !==
false)) {
5688 $s .= sprintf(
'%F %F m ', $xR, $yR);
5689 $s .= sprintf(
'%F %F l ', $xB, $yB);
5690 $s .= sprintf(
'%F %F l ', $xL, $yL);
5692 } elseif ((strpos($border,
'B') !==
false) AND (strpos($border,
'L') !==
false)) {
5693 $s .= sprintf(
'%F %F m ', $xB, $yB);
5694 $s .= sprintf(
'%F %F l ', $xL, $yL);
5695 $s .= sprintf(
'%F %F l ', $xT, $yT);
5697 } elseif ((strpos($border,
'L') !==
false) AND (strpos($border,
'R') !==
false)) {
5698 $s .= sprintf(
'%F %F m ', $xL, $yL);
5699 $s .= sprintf(
'%F %F l ', $xT, $yT);
5701 $s .= sprintf(
'%F %F m ', $xR, $yR);
5702 $s .= sprintf(
'%F %F l ', $xB, $yB);
5704 } elseif ((strpos($border,
'T') !==
false) AND (strpos($border,
'B') !==
false)) {
5705 $s .= sprintf(
'%F %F m ', $xT, $yT);
5706 $s .= sprintf(
'%F %F l ', $xR, $yR);
5708 $s .= sprintf(
'%F %F m ', $xB, $yB);
5709 $s .= sprintf(
'%F %F l ', $xL, $yL);
5713 if (strpos($border,
'L') !==
false) {
5714 $s .= sprintf(
'%F %F m ', $xL, $yL);
5715 $s .= sprintf(
'%F %F l ', $xT, $yT);
5717 } elseif (strpos($border,
'T') !==
false) {
5718 $s .= sprintf(
'%F %F m ', $xT, $yT);
5719 $s .= sprintf(
'%F %F l ', $xR, $yR);
5721 } elseif (strpos($border,
'R') !==
false) {
5722 $s .= sprintf(
'%F %F m ', $xR, $yR);
5723 $s .= sprintf(
'%F %F l ', $xB, $yB);
5725 } elseif (strpos($border,
'B') !==
false) {
5726 $s .= sprintf(
'%F %F m ', $xB, $yB);
5727 $s .= sprintf(
'%F %F l ', $xL, $yL);
5731 if (is_array($style) AND !empty($style)) {
5733 $s .=
"\n".$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
"\n";
5764 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) {
5771 $this->cell_padding[
'T'] = 0;
5772 $this->cell_padding[
'B'] = 0;
5784 if ((
$h > 0) AND $this->
inPageBody() AND ((
$y +
$h + $mc_margin[
'T'] + $mc_margin[
'B']) > $this->PageBreakTrigger)) {
5786 $newh = ($this->PageBreakTrigger -
$y);
5787 $resth = (
$h - $newh);
5802 $oy =
$y + $mc_margin[
'T'];
5804 $ox = ($this->w -
$x - $mc_margin[
'R']);
5806 $ox = (
$x + $mc_margin[
'L']);
5813 $w = ($this->x - $this->lMargin - $mc_margin[
'L']);
5815 $w = ($this->w - $this->x - $this->rMargin - $mc_margin[
'R']);
5822 $this->rMargin = ($this->w -
$this->x);
5823 $this->lMargin = ($this->x -
$w);
5826 $this->rMargin = ($this->w - $this->x -
$w);
5832 $this->y += $mc_padding[
'T'];
5835 $this->
writeHTML($txt,
true,
false, $reseth,
true, $align);
5842 $text_height = $this->
getStringHeight(
$w, $txt, $reseth, $autopadding, $mc_padding, $border);
5847 $prev_text_height = $text_height;
5849 while ($maxit > 0) {
5850 $fmid = (($fmax + $fmin) / 2);
5853 $text_height = $this->
getStringHeight(
$w, $txt, $reseth, $autopadding, $mc_padding, $border);
5854 if (($text_height == $maxh) OR (($text_height < $maxh) AND ($fmin >= ($fmax - 0.01)))) {
5856 } elseif ($text_height < $maxh) {
5865 if ($text_height < $maxh) {
5866 if ($valign ==
'M') {
5868 $this->y += (($maxh - $text_height) / 2);
5869 } elseif ($valign ==
'B') {
5871 $this->y += ($maxh - $text_height);
5875 $nl = $this->
Write($this->lasth, $txt,
'', 0, $align,
true, $stretch,
false,
true, $maxh, 0, $mc_margin);
5883 $this->y += $mc_padding[
'B'];
5890 $skip = ($endpage - $startpage);
5892 while ($tmpresth > 0) {
5897 if ($this->num_columns > 1) {
5909 if ($this->num_columns == 0) {
5910 $this->num_columns = 1;
5914 $this->check_page_regions =
false;
5923 if ($this->num_columns < 2) {
5929 if (
$page > $startpage) {
5930 if (($this->rtl) AND ($this->pagedim[
$page][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
5931 $this->x -= ($this->pagedim[
$page][
'orm'] - $this->pagedim[$startpage][
'orm']);
5932 } elseif ((!$this->rtl) AND ($this->pagedim[
$page][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
5933 $this->x += ($this->pagedim[
$page][
'olm'] - $this->pagedim[$startpage][
'olm']);
5936 if ($startpage == $endpage) {
5938 for ($column = $startcolumn; $column <= $endcolumn; ++$column) {
5941 $this->x -= $mc_margin[
'R'];
5943 $this->x += $mc_margin[
'L'];
5945 if ($startcolumn == $endcolumn) {
5947 $h = max(
$h, ($currentY - $oy));
5949 } elseif ($column == $startcolumn) {
5950 $cborder = $border_start;
5953 } elseif ($column == $endcolumn) {
5954 $cborder = $border_end;
5960 $cborder = $border_middle;
5964 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
5966 } elseif (
$page == $startpage) {
5970 $this->x -= $mc_margin[
'R'];
5972 $this->x += $mc_margin[
'L'];
5974 if ($column == $startcolumn) {
5975 $cborder = $border_start;
5979 $cborder = $border_middle;
5983 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
5985 } elseif (
$page == $endpage) {
5986 for ($column = 0; $column <= $endcolumn; ++$column) {
5989 $this->x -= $mc_margin[
'R'];
5991 $this->x += $mc_margin[
'L'];
5993 if ($column == $endcolumn) {
5995 $cborder = $border_end;
6002 $cborder = $border_middle;
6006 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6012 $this->x -= $mc_margin[
'R'];
6014 $this->x += $mc_margin[
'L'];
6016 $cborder = $border_middle;
6019 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6022 if ($cborder OR $fill) {
6023 $offsetlen = strlen($ccode);
6025 if ($this->inxobj) {
6027 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
6028 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
6029 $pagemark = $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey];
6030 $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey] += $offsetlen;
6036 $pstart = substr($pagebuff, 0, $pagemark);
6037 $pend = substr($pagebuff, $pagemark);
6038 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
6040 if (end($this->transfmrk[$this->page]) !==
false) {
6041 $pagemarkkey = key($this->transfmrk[$this->page]);
6042 $pagemark = $this->transfmrk[
$this->page][$pagemarkkey];
6043 $this->transfmrk[
$this->page][$pagemarkkey] += $offsetlen;
6044 } elseif ($this->InFooter) {
6052 $pstart = substr($pagebuff, 0, $pagemark);
6053 $pend = substr($pagebuff, $pagemark);
6061 $currentY = $this->
GetY();
6063 if ($this->num_columns > 1) {
6069 if ($this->page > $startpage) {
6071 $dl = ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$startpage][
'olm']);
6072 $dr = ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$startpage][
'orm']);
6073 if (($dl != 0) OR ($dr != 0)) {
6074 $this->lMargin += $dl;
6075 $this->rMargin += $dr;
6081 $this->
SetY($currentY + $mc_margin[
'B']);
6083 $this->
SetX(
$x +
$w + $mc_margin[
'L'] + $mc_margin[
'R']);
6089 $this->
SetX(
$x +
$w + $mc_margin[
'L'] + $mc_margin[
'R']);
6092 $this->cell_padding = $prev_cell_padding;
6093 $this->cell_margin = $prev_cell_margin;
6112 public function getNumLines($txt,
$w=0, $reseth=
false, $autopadding=
true, $cellpadding=
'', $border=0) {
6113 if ($txt === NULL) {
6123 if (is_array($cellpadding)) {
6124 $this->cell_padding = $cellpadding;
6134 $wmax =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
6143 $length = count($chars);
6144 $lastSeparator = -1;
6145 for ($i = 0; $i < $length; ++$i) {
6147 $charWidth = $charsWidth[$i];
6152 AND ($i > 0) AND ($i < ($length - 1))
6153 AND @preg_match(
'/[\p{L}]/'.$this->re_space[
'm'],
TCPDF_FONTS::unichr($chars[($i - 1)], $this->isunicode))
6154 AND @preg_match(
'/[\p{L}]/'.$this->re_space[
'm'],
TCPDF_FONTS::unichr($chars[($i + 1)], $this->isunicode))
6158 $lastSeparator = $i;
6160 if ((($sum + $charWidth) > $wmax) OR ($c == 10)) {
6163 $lastSeparator = -1;
6165 } elseif ($lastSeparator != -1) {
6166 $i = $lastSeparator;
6167 $lastSeparator = -1;
6176 if ($chars[($length - 1)] == 10) {
6179 $this->cell_padding = $prev_cell_padding;
6180 $this->lasth = $prev_lasth;
6231 public function getStringHeight(
$w, $txt, $reseth=
false, $autopadding=
true, $cellpadding=
'', $border=0) {
6235 if (is_array($cellpadding)) {
6236 $this->cell_padding = $cellpadding;
6239 $lines = $this->
getNumLines($txt,
$w, $reseth, $autopadding, $cellpadding, $border);
6240 $height = $this->
getCellHeight(($lines * $this->FontSize), $autopadding);
6241 $this->cell_padding = $prev_cell_padding;
6242 $this->lasth = $prev_lasth;
6264 public function Write(
$h, $txt, $link=
'', $fill=
false, $align=
'', $ln=
false, $stretch=0, $firstline=
false, $firstblock=
false, $maxh=0, $wadj=0, $margin=
'') {
6267 if (strlen($txt) == 0) {
6271 if ($margin ===
'') {
6276 $s = str_replace(
"\r",
'', $txt);
6295 array_walk($chrw, array($this,
'getRawCharWidth'));
6296 $maxchwidth = max($chrw);
6300 $nb = count($chars);
6302 $shy_replacement = 45;
6305 $shy_replacement_width = $this->
GetCharWidth($shy_replacement);
6307 $maxy = $this->y + $maxh -
$h - $this->cell_padding[
'T'] - $this->cell_padding[
'B'];
6317 $wmax = (
$w - $wadj);
6319 $wmax -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
6321 if ((!$firstline) AND (($chrwidth > $wmax) OR ($maxchwidth > $wmax))) {
6338 if (($maxh > 0) AND ($this->y >= $maxy) ) {
6345 if ($align ==
'J') {
6357 $tmparr = array_slice($chars, $j, ($i - $j));
6359 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6364 $this->endlinex = $startx - $linew;
6366 $this->endlinex = $startx + $linew;
6378 if (!empty($tmpstr) OR ($this->y < ($this->PageBreakTrigger - $row_height))) {
6379 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $talign, $fill, $link, $stretch);
6383 $this->cell_padding = $tmpcellpadding;
6392 if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND ($this->
inPageBody())) {
6395 $this->x -= $margin[
'R'];
6397 $this->x += $margin[
'L'];
6399 $this->lMargin += $margin[
'L'];
6400 $this->rMargin += $margin[
'R'];
6403 $wmax = (
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R']);
6414 AND ($i < ($nb - 1))
6415 AND @preg_match(
'/[\p{L}]/'.$this->re_space[
'm'],
TCPDF_FONTS::unichr($pc, $this->isunicode))
6416 AND @preg_match(
'/[\p{L}]/'.$this->re_space[
'm'],
TCPDF_FONTS::unichr($chars[($i + 1)], $this->isunicode))
6423 if (($c == 173) OR ($c == 45)) {
6426 $tmp_shy_replacement_width = 0;
6427 $tmp_shy_replacement_char =
'';
6429 $tmp_shy_replacement_width = $shy_replacement_width;
6430 $tmp_shy_replacement_char = $shy_replacement_char;
6444 if ((
$l > $wmax) OR (($c == 173) AND ((
$l + $tmp_shy_replacement_width) > $wmax)) ) {
6448 if (($this->rtl AND ($this->x <= ($this->w - $this->rMargin - $this->cell_padding[
'R'] - $margin[
'R'] - $chrwidth)))
6449 OR ((!$this->rtl) AND ($this->x >= ($this->lMargin + $this->cell_padding[
'L'] + $margin[
'L'] + $chrwidth)))) {
6461 $tmparr = array_slice($chars, $j, ($i - $j));
6463 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6468 $this->endlinex = $startx - $linew;
6470 $this->endlinex = $startx + $linew;
6481 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $align, $fill, $link, $stretch);
6484 $this->cell_padding = $tmpcellpadding;
6492 if ($this->rtl AND (!$firstblock) AND ($sep < $i)) {
6500 if (isset($nextstr[0]) AND ($this->
GetStringWidth($nextstr[0]) > $pw)) {
6505 $tmparr = array_slice($chars, $j, ($i - $j));
6507 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6512 $this->endlinex = ($startx - $linew);
6514 $this->endlinex = ($startx + $linew);
6525 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $align, $fill, $link, $stretch);
6528 $this->cell_padding = $tmpcellpadding;
6537 $shy_width = $tmp_shy_replacement_width;
6539 $shy_char_left = $tmp_shy_replacement_char;
6540 $shy_char_right =
'';
6542 $shy_char_left =
'';
6543 $shy_char_right = $tmp_shy_replacement_char;
6547 $shy_char_left =
'';
6548 $shy_char_right =
'';
6553 $tmparr = array_slice($chars, $j, (($sep + $endspace) - $j));
6555 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6560 $this->endlinex = $startx - $linew - $shy_width;
6562 $this->endlinex = $startx + $linew + $shy_width;
6574 $this->
Cell(
$w,
$h, $shy_char_left.$tmpstr.$shy_char_right, 0, 1, $align, $fill, $link, $stretch);
6577 if ($chars[$sep] == 45) {
6581 $this->cell_padding = $tmpcellpadding;
6591 if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND ($this->
inPageBody())) {
6594 $this->x -= $margin[
'R'];
6596 $this->x += $margin[
'L'];
6598 $this->lMargin += $margin[
'L'];
6599 $this->rMargin += $margin[
'R'];
6602 $wmax =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
6647 $tmparr = array_slice($chars, $j, ($nb - $j));
6649 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6654 $this->endlinex = $startx - $linew;
6656 $this->endlinex = $startx + $linew;
6667 $this->
Cell(
$w,
$h, $tmpstr, 0, $ln, $align, $fill, $link, $stretch);
6670 $this->cell_padding = $tmpcellpadding;
6689 return ($this->x - $this->lMargin);
6691 return ($this->w - $this->rMargin - $this->x);
6722 if ($fitonpage OR $this->AutoPageBreak) {
6723 $ratio_wh = (
$w /
$h);
6724 if (
$h > ($this->PageBreakTrigger - $this->tMargin)) {
6726 $w = (
$h * $ratio_wh);
6733 $h = (
$w / $ratio_wh);
6745 $x += ($this->x - $prev_x);
6747 $this->newline =
true;
6751 $ratio_wh = (
$w /
$h);
6753 $h = $this->PageBreakTrigger -
$y;
6754 $w = (
$h * $ratio_wh);
6756 if ((!$this->rtl) AND ((
$x +
$w) > ($this->w - $this->rMargin))) {
6757 $w = $this->w - $this->rMargin -
$x;
6758 $h = (
$w / $ratio_wh);
6759 } elseif (($this->rtl) AND ((
$x -
$w) < ($this->lMargin))) {
6761 $h = (
$w / $ratio_wh);
6801 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()) {
6802 if ($this->state != 2) {
6816 if ($file[0] ===
'@') {
6818 $imgdata = substr($file, 1);
6820 if ($file{0} ===
'*') {
6822 $file = substr($file, 1);
6826 if (!@file_exists($file)) {
6828 $file = str_replace(
' ',
'%20', $file);
6830 if (@file_exists($file)) {
6832 $imsize = @getimagesize($file);
6834 if ($imsize === FALSE) {
6838 if (isset($imgdata) AND ($imgdata !== FALSE) AND (strpos($file,
'__tcpdf_img') === FALSE)) {
6840 $original_file = $file;
6842 $fp = fopen($file,
'w');
6843 fwrite($fp, $imgdata);
6846 $imsize = @getimagesize($file);
6847 if ($imsize === FALSE) {
6849 $file = $original_file;
6851 $this->cached_files[] = $file;
6854 if ($imsize === FALSE) {
6855 if ((
$w > 0) AND (
$h > 0)) {
6859 $imsize = array($pw, $ph);
6861 $this->
Error(
'[Image] Unable to get the size of the image: '.$file);
6865 $filehash = md5($this->file_id.$file);
6867 list($pixw, $pixh) = $imsize;
6869 if ((
$w <= 0) AND (
$h <= 0)) {
6873 } elseif (
$w <= 0) {
6874 $w =
$h * $pixw / $pixh;
6875 } elseif (
$h <= 0) {
6876 $h =
$w * $pixh / $pixw;
6877 } elseif (($fitbox !==
false) AND (
$w > 0) AND (
$h > 0)) {
6878 if (strlen($fitbox) !== 2) {
6883 if (((
$w * $pixh) / (
$h * $pixw)) < 1) {
6887 $h =
$w * $pixh / $pixw;
6889 $hdiff = ($oldh -
$h);
6891 switch (strtoupper($fitbox{1})) {
6908 $w =
$h * $pixw / $pixh;
6910 $wdiff = ($oldw -
$w);
6912 switch (strtoupper($fitbox{0})) {
6939 $neww = round(
$w * $this->k *
$dpi / $this->dpi);
6940 $newh = round(
$h * $this->k *
$dpi / $this->dpi);
6942 $newsize = ($neww * $newh);
6943 $pixsize = ($pixw * $pixh);
6944 if (intval($resize) == 2) {
6946 } elseif ($newsize >= $pixsize) {
6951 if (in_array($file, $this->imagekeys)) {
6955 if (strpos($file,
'__tcpdf_imgmask_') === FALSE) {
6957 $oldsize = ($info[
'w'] * $info[
'h']);
6958 if ((($oldsize < $newsize) AND ($resize)) OR (($oldsize < $pixsize) AND (!$resize))) {
6962 } elseif (($ismask ===
false) AND ($imgmask ===
false) AND (strpos($file,
'__tcpdf_imgmask_') === FALSE)) {
6964 $tempfile_plain = K_PATH_CACHE.
'__tcpdf_imgmask_plain_'.$filehash;
6966 $tempfile_alpha = K_PATH_CACHE.
'__tcpdf_imgmask_alpha_'.$filehash;
6968 if (in_array($tempfile_plain, $this->imagekeys)) {
6972 $oldsize = ($info[
'w'] * $info[
'h']);
6973 if ((($oldsize < $newsize) AND ($resize)) OR (($oldsize < $pixsize) AND (!$resize))) {
6978 $imgmask = $this->
Image($tempfile_alpha,
$x,
$y,
$w,
$h,
'PNG',
'',
'', $resize,
$dpi,
'',
true,
false);
6980 return $this->
Image($tempfile_plain,
$x,
$y,
$w,
$h, $type, $link, $align, $resize,
$dpi, $palign,
false, $imgmask);
6986 $type = strtolower($type);
6989 } elseif ($type ==
'jpg') {
6995 $mtd =
'_parse'.$type;
6997 $gdfunction =
'imagecreatefrom'.$type;
6999 if ((method_exists(
'TCPDF_IMAGES', $mtd)) AND (!($resize AND (function_exists($gdfunction) OR extension_loaded(
'imagick'))))) {
7001 $info = TCPDF_IMAGES::$mtd($file);
7002 if (($ismask ===
false) AND ($imgmask ===
false) AND (strpos($file,
'__tcpdf_imgmask_') === FALSE)
7003 AND (($info ===
'pngalpha') OR (isset($info[
'trns']) AND !empty($info[
'trns'])))) {
7004 return $this->
ImagePngAlpha($file,
$x,
$y, $pixw, $pixh,
$w,
$h,
'PNG', $link, $align, $resize,
$dpi, $palign, $filehash);
7007 if (($info ===
false) AND function_exists($gdfunction)) {
7010 $img = $gdfunction($file);
7011 if ($img !==
false) {
7013 $imgr = imagecreatetruecolor($neww, $newh);
7014 if (($type ==
'gif') OR ($type ==
'png')) {
7017 imagecopyresampled($imgr, $img, 0, 0, 0, 0, $neww, $newh, $pixw, $pixh);
7018 if (($type ==
'gif') OR ($type ==
'png')) {
7024 if (($type ==
'gif') OR ($type ==
'png')) {
7031 }
catch(Exception $e) {
7035 if (($info ===
false) AND extension_loaded(
'imagick')) {
7038 $img =
new Imagick();
7039 if ($type ==
'SVG') {
7042 if ($svgimg !== FALSE) {
7045 if (preg_match(
'/<svg([^>]*)>/si', $svgimg, $regs)) {
7048 if (preg_match(
'/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
7050 $owu = sprintf(
'%F', ($ow *
$dpi / 72)).$this->pdfunit;
7051 $svgtag = preg_replace(
'/[\s]+width[\s]*=[\s]*"[^"]*"/si',
' width="'.$owu.
'"', $svgtag, 1);
7056 if (preg_match(
'/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
7058 $ohu = sprintf(
'%F', ($oh *
$dpi / 72)).$this->pdfunit;
7059 $svgtag = preg_replace(
'/[\s]+height[\s]*=[\s]*"[^"]*"/si',
' height="'.$ohu.
'"', $svgtag, 1);
7064 if (!preg_match(
'/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $svgtag, $tmp)) {
7065 $vbw = ($ow * $this->imgscale *
$this->k);
7066 $vbh = ($oh * $this->imgscale *
$this->k);
7067 $vbox = sprintf(
' viewBox="0 0 %F %F" ', $vbw, $vbh);
7068 $svgtag = $vbox.$svgtag;
7070 $svgimg = preg_replace(
'/<svg([^>]*)>/si',
'<svg'.$svgtag.
'>', $svgimg, 1);
7072 $img->readImageBlob($svgimg);
7075 $img->readImage($file);
7078 $img->resizeImage($neww, $newh, 10, 1,
false);
7080 $img->setCompressionQuality($this->jpeg_quality);
7081 $img->setImageFormat(
'jpeg');
7083 $img->writeImage($tempname);
7087 }
catch(Exception $e) {
7091 if ($info ===
false) {
7098 $info[
'cs'] =
'DeviceGray';
7100 if ($imgmask !==
false) {
7101 $info[
'masked'] = $imgmask;
7103 if (!empty($exurl)) {
7104 $info[
'exurl'] = $exurl;
7107 $info[
'altimgs'] = $altimgs;
7112 $this->img_rb_y =
$y +
$h;
7115 if ($palign ==
'L') {
7117 } elseif ($palign ==
'C') {
7118 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
7119 } elseif ($palign ==
'R') {
7120 $ximg = $this->w - $this->rMargin -
$w;
7124 $this->img_rb_x = $ximg;
7126 if ($palign ==
'L') {
7128 } elseif ($palign ==
'C') {
7129 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
7130 } elseif ($palign ==
'R') {
7131 $ximg = $this->w - $this->rMargin -
$w;
7135 $this->img_rb_x = $ximg +
$w;
7137 if ($ismask OR $hidden) {
7144 $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']));
7146 if (!empty($border)) {
7154 $this->
Cell(
$w, $h,
'', $border, 0,
'', 0,
'', 0,
true);
7159 $this->
Link($ximg,
$y,
$w, $h, $link, 0);
7169 $this->y =
$y + round($h/2);
7179 $this->
SetY($this->img_rb_y);
7187 if ($this->inxobj) {
7215 protected function ImagePngAlpha($file,
$x,
$y, $wpx, $hpx,
$w,
$h, $type, $link, $align, $resize,
$dpi, $palign, $filehash=
'') {
7217 if (empty($filehash)) {
7218 $filehash = md5($this->file_id.$file);
7221 $tempfile_plain = K_PATH_CACHE.
'__tcpdf_imgmask_plain_'.$filehash;
7223 $tempfile_alpha = K_PATH_CACHE.
'__tcpdf_imgmask_alpha_'.$filehash;
7227 if (($parsed ===
false) AND extension_loaded(
'imagick')) {
7230 $img =
new Imagick();
7231 $img->readImage($file);
7235 if (method_exists($img,
'setImageAlphaChannel') AND defined(
'Imagick::ALPHACHANNEL_EXTRACT')) {
7236 $img->setImageAlphaChannel(Imagick::ALPHACHANNEL_EXTRACT);
7238 $img->separateImageChannel(8);
7239 $img->negateImage(
true);
7241 $img->setImageFormat(
'png');
7242 $img->writeImage($tempfile_alpha);
7244 if (method_exists($imga,
'setImageMatte')) {
7245 $imga->setImageMatte(
false);
7247 $imga->separateImageChannel(39);
7249 $imga->setImageFormat(
'png');
7250 $imga->writeImage($tempfile_plain);
7252 }
catch (Exception $e) {
7254 $parse_error =
'Imagick library error: '.$e->getMessage();
7258 if (($parsed ===
false) AND function_exists(
'imagecreatefrompng')) {
7261 $img = imagecreatefrompng($file);
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);
7273 imagesetpixel($imgalpha, $xpx, $ypx,
$alpha);
7276 imagepng($imgalpha, $tempfile_alpha);
7277 imagedestroy($imgalpha);
7279 $imgplain = imagecreatetruecolor($wpx, $hpx);
7280 imagecopy($imgplain, $img, 0, 0, 0, 0, $wpx, $hpx);
7281 imagepng($imgplain, $tempfile_plain);
7282 imagedestroy($imgplain);
7284 }
catch (Exception $e) {
7286 $parse_error =
'GD library error: '.$e->getMessage();
7289 if ($parsed ===
false) {
7290 if (empty($parse_error)) {
7291 $this->
Error(
'TCPDF requires the Imagick or GD extension to handle PNG images with alpha channel.');
7293 $this->
Error($parse_error);
7297 $imgmask = $this->
Image($tempfile_alpha,
$x,
$y,
$w,
$h,
'PNG',
'',
'', $resize,
$dpi,
'',
true,
false);
7299 $this->
Image($tempfile_plain,
$x,
$y,
$w,
$h, $type, $link, $align, $resize,
$dpi, $palign,
false, $imgmask);
7301 unlink($tempfile_alpha);
7302 unlink($tempfile_plain);
7313 if (!isset($this->gdgammacache[
'#'.$c])) {
7314 $colors = imagecolorsforindex($img, $c);
7316 $this->gdgammacache[
'#'.$c] = (((127 - $colors[
'alpha']) / 127) * 255);
7318 $this->gdgammacache[
'#'.$c] = (pow(($this->gdgammacache[
'#'.$c] / 255), 2.2) * 255);
7320 if (count($this->gdgammacache) > 8) {
7322 array_shift($this->gdgammacache);
7325 return $this->gdgammacache[
'#'.$c];
7337 public function Ln(
$h=
'', $cell=
false) {
7338 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'])) {
7344 $cellpadding = $this->cell_padding[
'R'];
7346 $cellpadding = $this->cell_padding[
'L'];
7352 $this->x = $this->w - $this->rMargin - $cellpadding;
7354 $this->x = $this->lMargin + $cellpadding;
7356 if (is_string(
$h)) {
7361 $this->newline =
true;
7375 return ($this->w - $this->x);
7414 if (!$rtloff AND $this->rtl) {
7416 $this->x = $this->w -
$x;
7424 $this->x = $this->w +
$x;
7430 if ($this->x > $this->w) {
7445 public function SetY(
$y, $resetx=
true, $rtloff=
false) {
7449 if (!$rtloff AND $this->rtl) {
7458 $this->y = $this->h +
$y;
7463 if ($this->y > $this->h) {
7479 $this->
SetY(
$y,
false, $rtloff);
7480 $this->
SetX(
$x, $rtloff);
7491 $this->x = floatval(
$x);
7502 $this->y = floatval(
$y);
7528 public function Output($name=
'doc.pdf', $dest=
'I') {
7531 if ($this->state < 3) {
7535 if (is_bool($dest)) {
7536 $dest = $dest ?
'D' :
'F';
7538 $dest = strtoupper($dest);
7539 if ($dest{0} !=
'F') {
7540 $name = preg_replace(
'/[\s]+/',
'_', $name);
7541 $name = preg_replace(
'/[^a-zA-Z0-9_\.-]/',
'', $name);
7548 $pdfdoc = substr($pdfdoc, 0, -1);
7550 if (isset($this->diskcache) AND $this->diskcache) {
7552 unlink($this->buffer);
7554 unset($this->buffer);
7558 $byte_range = array();
7561 $byte_range[2] = $byte_range[1] + $this->signature_max_length + 2;
7562 $byte_range[3] = strlen($pdfdoc) - $byte_range[2];
7563 $pdfdoc = substr($pdfdoc, 0, $byte_range[1]).substr($pdfdoc, $byte_range[2]);
7565 $byterange = sprintf(
'/ByteRange[0 %u %u %u]', $byte_range[1], $byte_range[2], $byte_range[3]);
7566 $byterange .= str_repeat(
' ', ($byterange_string_len - strlen($byterange)));
7570 $f = fopen($tempdoc,
'wb');
7572 $this->
Error(
'Unable to create temporary file: '.$tempdoc);
7574 $pdfdoc_length = strlen($pdfdoc);
7575 fwrite($f, $pdfdoc, $pdfdoc_length);
7579 if (empty($this->signature_data[
'extracerts'])) {
7580 openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data[
'signcert'], array($this->signature_data[
'privkey'], $this->signature_data[
'password']), array(), PKCS7_BINARY | PKCS7_DETACHED);
7582 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']);
7586 $signature = file_get_contents($tempsign);
7589 $signature = substr($signature, $pdfdoc_length);
7590 $signature = substr($signature, (strpos($signature,
"%%EOF\n\n------") + 13));
7591 $tmparr = explode(
"\n\n", $signature);
7592 $signature = $tmparr[1];
7595 $signature = base64_decode(trim($signature));
7597 $signature = current(unpack(
'H*', $signature));
7598 $signature = str_pad($signature, $this->signature_max_length,
'0');
7600 $this->diskcache =
false;
7602 $this->buffer = substr($pdfdoc, 0, $byte_range[1]).
'<'.$signature.
'>'.substr($pdfdoc, $byte_range[1]);
7603 $this->bufferlen = strlen($this->buffer);
7608 if (ob_get_contents()) {
7609 $this->
Error(
'Some data has already been output, can\'t send PDF file');
7611 if (php_sapi_name() !=
'cli') {
7613 header(
'Content-Type: application/pdf');
7614 if (headers_sent()) {
7615 $this->
Error(
'Some data has already been output to browser, can\'t send PDF file');
7617 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7619 header(
'Pragma: public');
7620 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7621 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7622 header(
'Content-Disposition: inline; filename="'.basename($name).
'"');
7631 if (ob_get_contents()) {
7632 $this->
Error(
'Some data has already been output, can\'t send PDF file');
7634 header(
'Content-Description: File Transfer');
7635 if (headers_sent()) {
7636 $this->
Error(
'Some data has already been output to browser, can\'t send PDF file');
7638 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7640 header(
'Pragma: public');
7641 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7642 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7644 if (strpos(php_sapi_name(),
'cgi') ===
false) {
7645 header(
'Content-Type: application/force-download');
7646 header(
'Content-Type: application/octet-stream',
false);
7647 header(
'Content-Type: application/download',
false);
7648 header(
'Content-Type: application/pdf',
false);
7650 header(
'Content-Type: application/pdf');
7653 header(
'Content-Disposition: attachment; filename="'.basename($name).
'"');
7654 header(
'Content-Transfer-Encoding: binary');
7662 if ($this->diskcache) {
7663 copy($this->buffer, $name);
7665 $f = fopen($name,
'wb');
7667 $this->
Error(
'Unable to create output file: '.$name);
7669 fwrite($f, $this->
getBuffer(), $this->bufferlen);
7672 if ($dest ==
'FI') {
7674 header(
'Content-Type: application/pdf');
7675 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7677 header(
'Pragma: public');
7678 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7679 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7680 header(
'Content-Disposition: inline; filename="'.basename($name).
'"');
7682 } elseif ($dest ==
'FD') {
7684 if (ob_get_contents()) {
7685 $this->
Error(
'Some data has already been output, can\'t send PDF file');
7687 header(
'Content-Description: File Transfer');
7688 if (headers_sent()) {
7689 $this->
Error(
'Some data has already been output to browser, can\'t send PDF file');
7691 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7692 header(
'Pragma: public');
7693 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7694 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7696 if (strpos(php_sapi_name(),
'cgi') ===
false) {
7697 header(
'Content-Type: application/force-download');
7698 header(
'Content-Type: application/octet-stream',
false);
7699 header(
'Content-Type: application/download',
false);
7700 header(
'Content-Type: application/pdf',
false);
7702 header(
'Content-Type: application/pdf');
7705 header(
'Content-Disposition: attachment; filename="'.basename($name).
'"');
7706 header(
'Content-Transfer-Encoding: binary');
7713 $retval =
'Content-Type: application/pdf;'.
"\r\n";
7714 $retval .=
' name="'.$name.
'"'.
"\r\n";
7715 $retval .=
'Content-Transfer-Encoding: base64'.
"\r\n";
7716 $retval .=
'Content-Disposition: attachment;'.
"\r\n";
7717 $retval .=
' filename="'.$name.
'"'.
"\r\n\r\n";
7718 $retval .= chunk_split(base64_encode($this->
getBuffer()), 76,
"\r\n");
7726 $this->
Error(
'Incorrect output destination: '.$dest);
7739 public function _destroy($destroyall=
false, $preserve_objcopy=
false) {
7740 if ($destroyall AND isset($this->diskcache) AND $this->diskcache AND (!$preserve_objcopy) AND (!
TCPDF_STATIC::empty_string($this->buffer))) {
7742 unlink($this->buffer);
7744 if ($destroyall AND !empty($this->cached_files)) {
7746 foreach ($this->cached_files as $cachefile) {
7747 if (is_file($cachefile)) {
7751 unset($this->cached_files);
7753 foreach (array_keys(get_object_vars($this)) as $val) {
7754 if ($destroyall OR (
7755 ($val !=
'internal_encoding')
7756 AND ($val !=
'state')
7757 AND ($val !=
'bufferlen')
7758 AND ($val !=
'buffer')
7759 AND ($val !=
'diskcache')
7760 AND ($val !=
'cached_files')
7761 AND ($val !=
'sign')
7762 AND ($val !=
'signature_data')
7763 AND ($val !=
'signature_max_length')
7764 AND ($val !=
'byterange_string')
7766 if ((!$preserve_objcopy OR ($val !=
'objcopy')) AND isset($this->$val)) {
7780 $this->
Error(
'Don\'t alter the locale before including class file');
7783 if (sprintf(
'%.1F', 1.0) !=
'1.0') {
7784 setlocale(LC_NUMERIC,
'C');
7797 $alias = array(
'u' => array(),
'a' => array());
7800 if ($this->isunicode) {
7818 foreach($basic_alias as
$k => $a) {
7834 foreach ($aliases as $type => $alias) {
7835 foreach ($alias as $a) {
7837 $startnum = (strpos($a,
':') + 1);
7838 $a = substr($a, 0, $startnum);
7839 if (($pos = strpos(
$page, $a)) !==
false) {
7841 $endnum = strpos(
$page,
'}', $pos);
7843 $aa = substr(
$page, $pos, ($endnum - $pos + 1));
7845 $ratio = substr(
$page, ($pos + $startnum), ($endnum - $pos - $startnum));
7846 $ratio = preg_replace(
'/[^0-9\.]/',
'', $ratio);
7847 $ratio = floatval($ratio);
7849 $chrdiff = floor(($diff + 12) * $ratio);
7850 $shift = str_repeat(
' ', $chrdiff);
7853 $chrdiff = floor(($diff + 11) * $ratio);
7854 $shift = str_repeat(
' ', $chrdiff);
7869 $this->page_boxes = array();
7870 foreach ($boxes as $box) {
7872 $this->page_boxes[] = $box;
7894 for (
$n = 1;
$n <= $num_pages; ++
$n) {
7904 if (!empty($this->pagegroups)) {
7905 if (isset($this->newpagegroup[
$n])) {
7918 $replace[] = array($ptgu, $ptg_num_chars, 9, $pnalias[2][
'u']);
7919 $replace[] = array($ptga, $ptg_num_chars, 7, $pnalias[2][
'a']);
7920 $replace[] = array($pngu, $png_num_chars, 9, $pnalias[3][
'u']);
7921 $replace[] = array($pnga, $png_num_chars, 7, $pnalias[3][
'a']);
7926 $replace[] = array($ptpu, $ptp_num_chars, 9, $pnalias[0][
'u']);
7927 $replace[] = array($ptpa, $ptp_num_chars, 7, $pnalias[0][
'a']);
7928 $replace[] = array($pnpu, $pnp_num_chars, 9, $pnalias[1][
'u']);
7929 $replace[] = array($pnpa, $pnp_num_chars, 7, $pnalias[1][
'a']);
7934 $temppage = str_replace($this->epsmarker,
'', $temppage);
7936 $this->page_obj_id[
$n] = $this->
_newobj();
7938 $out .=
' /Type /Page';
7939 $out .=
' /Parent 1 0 R';
7940 $out .=
' /LastModified '.$this->_datestring(0, $this->doc_modification_timestamp);
7941 $out .=
' /Resources 2 0 R';
7942 foreach ($this->page_boxes as $box) {
7944 $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']);
7946 if (isset($this->pagedim[
$n][
'BoxColorInfo']) AND !empty($this->pagedim[$n][
'BoxColorInfo'])) {
7947 $out .=
' /BoxColorInfo <<';
7948 foreach ($this->page_boxes as $box) {
7949 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box])) {
7950 $out .=
' /'.$box.
' <<';
7951 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'C'])) {
7952 $color = $this->pagedim[
$n][
'BoxColorInfo'][$box][
'C'];
7954 $out .= sprintf(
' %F %F %F', ($color[0] / 255), ($color[1] / 255), ($color[2] / 255));
7957 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'W'])) {
7958 $out .=
' /W '.($this->pagedim[
$n][
'BoxColorInfo'][$box][
'W'] *
$this->k);
7960 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'S'])) {
7961 $out .=
' /S /'.$this->pagedim[
$n][
'BoxColorInfo'][$box][
'S'];
7963 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'D'])) {
7964 $dashes = $this->pagedim[
$n][
'BoxColorInfo'][$box][
'D'];
7966 foreach ($dashes as $dash) {
7967 $out .= sprintf(
' %F', ($dash * $this->k));
7976 $out .=
' /Contents '.($this->n + 1).
' 0 R';
7977 $out .=
' /Rotate '.$this->pagedim[
$n][
'Rotate'];
7978 if (!$this->pdfa_mode) {
7979 $out .=
' /Group << /Type /Group /S /Transparency /CS /DeviceRGB >>';
7981 if (isset($this->pagedim[$n][
'trans']) AND !empty($this->pagedim[$n][
'trans'])) {
7983 if (isset($this->pagedim[$n][
'trans'][
'Dur'])) {
7984 $out .=
' /Dur '.$this->pagedim[
$n][
'trans'][
'Dur'];
7986 $out .=
' /Trans <<';
7987 $out .=
' /Type /Trans';
7988 if (isset($this->pagedim[$n][
'trans'][
'S'])) {
7989 $out .=
' /S /'.$this->pagedim[
$n][
'trans'][
'S'];
7991 if (isset($this->pagedim[$n][
'trans'][
'D'])) {
7992 $out .=
' /D '.$this->pagedim[
$n][
'trans'][
'D'];
7994 if (isset($this->pagedim[$n][
'trans'][
'Dm'])) {
7995 $out .=
' /Dm /'.$this->pagedim[
$n][
'trans'][
'Dm'];
7997 if (isset($this->pagedim[$n][
'trans'][
'M'])) {
7998 $out .=
' /M /'.$this->pagedim[
$n][
'trans'][
'M'];
8000 if (isset($this->pagedim[$n][
'trans'][
'Di'])) {
8001 $out .=
' /Di '.$this->pagedim[
$n][
'trans'][
'Di'];
8003 if (isset($this->pagedim[$n][
'trans'][
'SS'])) {
8004 $out .=
' /SS '.$this->pagedim[
$n][
'trans'][
'SS'];
8006 if (isset($this->pagedim[$n][
'trans'][
'B'])) {
8007 $out .=
' /B '.$this->pagedim[
$n][
'trans'][
'B'];
8012 $out .=
' /PZ '.$this->pagedim[
$n][
'PZ'];
8014 $out .=
"\n".
'endobj';
8020 $this->
_out(
'<<'.$filter.
'/Length '.strlen($p).
'>> stream'.
"\n".$p.
"\n".
'endstream'.
"\n".
'endobj');
8021 if ($this->diskcache) {
8023 unlink($this->pages[$n]);
8027 $out = $this->
_getobj(1).
"\n";
8028 $out .=
'<< /Type /Pages /Kids [';
8029 foreach($this->page_obj_id as $page_obj) {
8030 $out .=
' '.$page_obj.
' 0 R';
8032 $out .=
' ] /Count '.$num_pages.
' >>';
8033 $out .=
"\n".
'endobj';
8058 if (!(isset($this->PageAnnots[
$n]) OR ($this->sign AND isset($this->signature_data[
'cert_type'])))) {
8061 $out =
' /Annots [';
8062 if (isset($this->PageAnnots[$n])) {
8063 foreach ($this->PageAnnots[$n] as $key => $val) {
8064 if (!in_array($val[
'n'], $this->radio_groups)) {
8065 $out .=
' '.$val[
'n'].
' 0 R';
8069 if (isset($this->radiobutton_groups[$n])) {
8070 foreach ($this->radiobutton_groups[$n] as $key => $data) {
8071 if (isset($data[
'n'])) {
8072 $out .=
' '.$data[
'n'].
' 0 R';
8077 if ($this->sign AND ($n == $this->signature_appearance[
'page']) AND isset($this->signature_data[
'cert_type'])) {
8079 $out .=
' '.$this->sig_obj_id.
' 0 R';
8081 if (!empty($this->empty_signature_appearance)) {
8082 foreach ($this->empty_signature_appearance as $esa) {
8083 if ($esa[
'page'] == $n) {
8085 $out .=
' '.$esa[
'objid'].
' 0 R';
8104 if (isset($this->PageAnnots[
$n])) {
8106 foreach ($this->PageAnnots[$n] as $key => $pl) {
8107 $annot_obj_id = $this->PageAnnots[
$n][$key][
'n'];
8109 if (isset($this->radiobutton_groups[$n][$pl[
'txt']]) AND is_array($this->radiobutton_groups[$n][$pl[
'txt']])) {
8110 $radio_button_obj_id = $this->radiobutton_groups[
$n][$pl[
'txt']][
'n'];
8112 $annots .=
' /Type /Annot';
8113 $annots .=
' /Subtype /Widget';
8114 $annots .=
' /Rect [0 0 0 0]';
8115 if ($this->radiobutton_groups[$n][$pl[
'txt']][
'#readonly#']) {
8117 $annots .=
' /F 68';
8118 $annots .=
' /Ff 49153';
8121 $annots .=
' /Ff 49152';
8123 $annots .=
' /T '.$this->_datastring($pl[
'txt'], $radio_button_obj_id);
8124 if (isset($pl[
'opt'][
'tu']) AND is_string($pl[
'opt'][
'tu'])) {
8125 $annots .=
' /TU '.$this->_datastring($pl[
'opt'][
'tu'], $radio_button_obj_id);
8127 $annots .=
' /FT /Btn';
8128 $annots .=
' /Kids [';
8130 foreach ($this->radiobutton_groups[$n][$pl[
'txt']] as $key => $data) {
8131 if (isset($data[
'kid'])) {
8132 $annots .=
' '.$data[
'kid'].
' 0 R';
8133 if ($data[
'def'] !==
'Off') {
8134 $defval = $data[
'def'];
8139 if (!empty($defval)) {
8140 $annots .=
' /V /'.$defval;
8143 $this->
_out($this->
_getobj($radio_button_obj_id).
"\n".$annots.
"\n".
'endobj');
8144 $this->form_obj_id[] = $radio_button_obj_id;
8146 $this->radiobutton_groups[
$n][$pl[
'txt']] = $radio_button_obj_id;
8149 $pl[
'opt'] = array_change_key_case($pl[
'opt'], CASE_LOWER);
8151 $b = $this->pagedim[
$n][
'h'] - (($pl[
'y'] + $pl[
'h']) * $this->k);
8154 $rect = sprintf(
'%F %F %F %F', $a, $b, $a+$c, $b+$d);
8156 $annots =
'<</Type /Annot';
8157 $annots .=
' /Subtype /'.$pl[
'opt'][
'subtype'];
8158 $annots .=
' /Rect ['.$rect.
']';
8159 $ft = array(
'Btn',
'Tx',
'Ch',
'Sig');
8160 if (isset($pl[
'opt'][
'ft']) AND in_array($pl[
'opt'][
'ft'], $ft)) {
8161 $annots .=
' /FT /'.$pl[
'opt'][
'ft'];
8164 $annots .=
' /Contents '.$this->_textstring($pl[
'txt'], $annot_obj_id);
8165 $annots .=
' /P '.$this->page_obj_id[
$n].
' 0 R';
8166 $annots .=
' /NM '.$this->_datastring(sprintf(
'%04u-%04u', $n, $key), $annot_obj_id);
8167 $annots .=
' /M '.$this->_datestring($annot_obj_id, $this->doc_modification_timestamp);
8168 if (isset($pl[
'opt'][
'f'])) {
8170 if (is_array($pl[
'opt'][
'f'])) {
8171 foreach ($pl[
'opt'][
'f'] as $f) {
8172 switch (strtolower($f)) {
8205 case 'togglenoview': {
8209 case 'lockedcontents': {
8219 $fval = intval($pl[
'opt'][
'f']);
8224 if ($this->pdfa_mode) {
8228 $annots .=
' /F '.intval($fval);
8229 if (isset($pl[
'opt'][
'as']) AND is_string($pl[
'opt'][
'as'])) {
8230 $annots .=
' /AS /'.$pl[
'opt'][
'as'];
8232 if (isset($pl[
'opt'][
'ap'])) {
8234 $annots .=
' /AP <<';
8235 if (is_array($pl[
'opt'][
'ap'])) {
8236 foreach ($pl[
'opt'][
'ap'] as $apmode => $apdef) {
8238 $annots .=
' /'.strtoupper($apmode);
8239 if (is_array($apdef)) {
8241 foreach ($apdef as $apstate => $stream) {
8244 $annots .=
' /'.$apstate.
' '.$apsobjid.
' 0 R';
8250 $annots .=
' '.$apsobjid.
' 0 R';
8254 $annots .= $pl[
'opt'][
'ap'];
8258 if (isset($pl[
'opt'][
'bs']) AND (is_array($pl[
'opt'][
'bs']))) {
8259 $annots .=
' /BS <<';
8260 $annots .=
' /Type /Border';
8261 if (isset($pl[
'opt'][
'bs'][
'w'])) {
8262 $annots .=
' /W '.intval($pl[
'opt'][
'bs'][
'w']);
8264 $bstyles = array(
'S',
'D',
'B',
'I',
'U');
8265 if (isset($pl[
'opt'][
'bs'][
's']) AND in_array($pl[
'opt'][
'bs'][
's'], $bstyles)) {
8266 $annots .=
' /S /'.$pl[
'opt'][
'bs'][
's'];
8268 if (isset($pl[
'opt'][
'bs'][
'd']) AND (is_array($pl[
'opt'][
'bs'][
'd']))) {
8270 foreach ($pl[
'opt'][
'bs'][
'd'] as $cord) {
8271 $annots .=
' '.intval($cord);
8277 $annots .=
' /Border [';
8278 if (isset($pl[
'opt'][
'border']) AND (count($pl[
'opt'][
'border']) >= 3)) {
8279 $annots .= intval($pl[
'opt'][
'border'][0]).
' ';
8280 $annots .= intval($pl[
'opt'][
'border'][1]).
' ';
8281 $annots .= intval($pl[
'opt'][
'border'][2]);
8282 if (isset($pl[
'opt'][
'border'][3]) AND is_array($pl[
'opt'][
'border'][3])) {
8284 foreach ($pl[
'opt'][
'border'][3] as $dash) {
8285 $annots .= intval($dash).
' ';
8294 if (isset($pl[
'opt'][
'be']) AND (is_array($pl[
'opt'][
'be']))) {
8295 $annots .=
' /BE <<';
8296 $bstyles = array(
'S',
'C');
8297 if (isset($pl[
'opt'][
'be'][
's']) AND in_array($pl[
'opt'][
'be'][
's'], $bstyles)) {
8298 $annots .=
' /S /'.$pl[
'opt'][
'bs'][
's'];
8300 $annots .=
' /S /S';
8302 if (isset($pl[
'opt'][
'be'][
'i']) AND ($pl[
'opt'][
'be'][
'i'] >= 0) AND ($pl[
'opt'][
'be'][
'i'] <= 2)) {
8303 $annots .=
' /I '.sprintf(
' %F', $pl[
'opt'][
'be'][
'i']);
8307 if (isset($pl[
'opt'][
'c']) AND (is_array($pl[
'opt'][
'c'])) AND !empty($pl[
'opt'][
'c'])) {
8308 $annots .=
' /C '.TCPDF_COLORS::getColorStringFromArray($pl[
'opt'][
'c']);
8312 $markups = array(
'text',
'freetext',
'line',
'square',
'circle',
'polygon',
'polyline',
'highlight',
'underline',
'squiggly',
'strikeout',
'stamp',
'caret',
'ink',
'fileattachment',
'sound');
8313 if (in_array(strtolower($pl[
'opt'][
'subtype']), $markups)) {
8315 if (isset($pl[
'opt'][
't']) AND is_string($pl[
'opt'][
't'])) {
8316 $annots .=
' /T '.$this->_textstring($pl[
'opt'][
't'], $annot_obj_id);
8319 if (isset($pl[
'opt'][
'ca'])) {
8320 $annots .=
' /CA '.sprintf(
'%F', floatval($pl[
'opt'][
'ca']));
8322 if (isset($pl[
'opt'][
'rc'])) {
8323 $annots .=
' /RC '.$this->_textstring($pl[
'opt'][
'rc'], $annot_obj_id);
8325 $annots .=
' /CreationDate '.$this->_datestring($annot_obj_id, $this->doc_creation_timestamp);
8327 if (isset($pl[
'opt'][
'subj'])) {
8328 $annots .=
' /Subj '.$this->_textstring($pl[
'opt'][
'subj'], $annot_obj_id);
8334 $lineendings = array(
'Square',
'Circle',
'Diamond',
'OpenArrow',
'ClosedArrow',
'None',
'Butt',
'ROpenArrow',
'RClosedArrow',
'Slash');
8336 switch (strtolower($pl[
'opt'][
'subtype'])) {
8338 if (isset($pl[
'opt'][
'open'])) {
8339 $annots .=
' /Open '. (strtolower($pl[
'opt'][
'open']) ==
'true' ?
'true' :
'false');
8341 $iconsapp = array(
'Comment',
'Help',
'Insert',
'Key',
'NewParagraph',
'Note',
'Paragraph');
8342 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8343 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8345 $annots .=
' /Name /Note';
8347 $statemodels = array(
'Marked',
'Review');
8348 if (isset($pl[
'opt'][
'statemodel']) AND in_array($pl[
'opt'][
'statemodel'], $statemodels)) {
8349 $annots .=
' /StateModel /'.$pl[
'opt'][
'statemodel'];
8351 $pl[
'opt'][
'statemodel'] =
'Marked';
8352 $annots .=
' /StateModel /'.$pl[
'opt'][
'statemodel'];
8354 if ($pl[
'opt'][
'statemodel'] ==
'Marked') {
8355 $states = array(
'Accepted',
'Unmarked');
8357 $states = array(
'Accepted',
'Rejected',
'Cancelled',
'Completed',
'None');
8359 if (isset($pl[
'opt'][
'state']) AND in_array($pl[
'opt'][
'state'], $states)) {
8360 $annots .=
' /State /'.$pl[
'opt'][
'state'];
8362 if ($pl[
'opt'][
'statemodel'] ==
'Marked') {
8363 $annots .=
' /State /Unmarked';
8365 $annots .=
' /State /None';
8371 if (is_string($pl[
'txt'])) {
8372 if ($pl[
'txt'][0] ==
'#') {
8374 $annots .=
' /Dest /'.TCPDF_STATIC::encodeNameObject(substr($pl[
'txt'], 1));
8375 } elseif ($pl[
'txt'][0] ==
'%') {
8377 $filename = basename(substr($pl[
'txt'], 1));
8378 $annots .=
' /A << /S /GoToE /D [0 /Fit] /NewWindow true /T << /R /C /P '.($n - 1).
' /A '.$this->embeddedfiles[$filename][
'a'].
' >> >>';
8379 } elseif ($pl[
'txt'][0] ==
'*') {
8381 $filename = basename(substr($pl[
'txt'], 1));
8382 $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});';
8383 $annots .=
' /A << /S /JavaScript /JS '.$this->_textstring($jsa, $annot_obj_id).
'>>';
8386 $annots .=
' /A <</S /URI /URI '.$this->_datastring($this->
unhtmlentities($pl[
'txt']), $annot_obj_id).
'>>';
8388 } elseif (isset($this->links[$pl[
'txt']])) {
8390 $l = $this->links[$pl[
'txt']];
8391 if (isset($this->page_obj_id[(
$l[0])])) {
8392 $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)));
8395 $hmodes = array(
'N',
'I',
'O',
'P');
8396 if (isset($pl[
'opt'][
'h']) AND in_array($pl[
'opt'][
'h'], $hmodes)) {
8397 $annots .=
' /H /'.$pl[
'opt'][
'h'];
8399 $annots .=
' /H /I';
8406 if (isset($pl[
'opt'][
'da']) AND !empty($pl[
'opt'][
'da'])) {
8407 $annots .=
' /DA ('.$pl[
'opt'][
'da'].
')';
8409 if (isset($pl[
'opt'][
'q']) AND ($pl[
'opt'][
'q'] >= 0) AND ($pl[
'opt'][
'q'] <= 2)) {
8410 $annots .=
' /Q '.intval($pl[
'opt'][
'q']);
8412 if (isset($pl[
'opt'][
'rc'])) {
8413 $annots .=
' /RC '.$this->_textstring($pl[
'opt'][
'rc'], $annot_obj_id);
8415 if (isset($pl[
'opt'][
'ds'])) {
8416 $annots .=
' /DS '.$this->_textstring($pl[
'opt'][
'ds'], $annot_obj_id);
8418 if (isset($pl[
'opt'][
'cl']) AND is_array($pl[
'opt'][
'cl'])) {
8419 $annots .=
' /CL [';
8420 foreach ($pl[
'opt'][
'cl'] as $cl) {
8421 $annots .= sprintf(
'%F ', $cl * $this->k);
8425 $tfit = array(
'FreeText',
'FreeTextCallout',
'FreeTextTypeWriter');
8426 if (isset($pl[
'opt'][
'it']) AND in_array($pl[
'opt'][
'it'], $tfit)) {
8427 $annots .=
' /IT /'.$pl[
'opt'][
'it'];
8429 if (isset($pl[
'opt'][
'rd']) AND is_array($pl[
'opt'][
'rd'])) {
8431 $r = $pl[
'opt'][
'rd'][1] *
$this->k;
8432 $t = $pl[
'opt'][
'rd'][2] *
$this->k;
8433 $b = $pl[
'opt'][
'rd'][3] *
$this->k;
8434 $annots .=
' /RD ['.sprintf(
'%F %F %F %F',
$l, $r, $t, $b).
']';
8436 if (isset($pl[
'opt'][
'le']) AND in_array($pl[
'opt'][
'le'], $lineendings)) {
8437 $annots .=
' /LE /'.$pl[
'opt'][
'le'];
8480 case 'fileattachment': {
8481 if ($this->pdfa_mode) {
8485 if (!isset($pl[
'opt'][
'fs'])) {
8488 $filename = basename($pl[
'opt'][
'fs']);
8489 if (isset($this->embeddedfiles[$filename][
'f'])) {
8490 $annots .=
' /FS '.$this->embeddedfiles[$filename][
'f'].
' 0 R';
8491 $iconsapp = array(
'Graph',
'Paperclip',
'PushPin',
'Tag');
8492 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8493 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8495 $annots .=
' /Name /PushPin';
8498 $this->embeddedfiles[$filename][
'a'] = $key;
8503 if (!isset($pl[
'opt'][
'fs'])) {
8506 $filename = basename($pl[
'opt'][
'fs']);
8507 if (isset($this->embeddedfiles[$filename][
'f'])) {
8510 $annots .=
' /Sound '.$this->embeddedfiles[$filename][
'f'].
' 0 R';
8511 $iconsapp = array(
'Speaker',
'Mic');
8512 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8513 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8515 $annots .=
' /Name /Speaker';
8524 $hmode = array(
'N',
'I',
'O',
'P',
'T');
8525 if (isset($pl[
'opt'][
'h']) AND in_array($pl[
'opt'][
'h'], $hmode)) {
8526 $annots .=
' /H /'.$pl[
'opt'][
'h'];
8528 if (isset($pl[
'opt'][
'mk']) AND (is_array($pl[
'opt'][
'mk'])) AND !empty($pl[
'opt'][
'mk'])) {
8529 $annots .=
' /MK <<';
8530 if (isset($pl[
'opt'][
'mk'][
'r'])) {
8531 $annots .=
' /R '.$pl[
'opt'][
'mk'][
'r'];
8533 if (isset($pl[
'opt'][
'mk'][
'bc']) AND (is_array($pl[
'opt'][
'mk'][
'bc']))) {
8534 $annots .=
' /BC '.TCPDF_COLORS::getColorStringFromArray($pl[
'opt'][
'mk'][
'bc']);
8536 if (isset($pl[
'opt'][
'mk'][
'bg']) AND (is_array($pl[
'opt'][
'mk'][
'bg']))) {
8537 $annots .=
' /BG '.TCPDF_COLORS::getColorStringFromArray($pl[
'opt'][
'mk'][
'bg']);
8539 if (isset($pl[
'opt'][
'mk'][
'ca'])) {
8540 $annots .=
' /CA '.$pl[
'opt'][
'mk'][
'ca'];
8542 if (isset($pl[
'opt'][
'mk'][
'rc'])) {
8543 $annots .=
' /RC '.$pl[
'opt'][
'mk'][
'rc'];
8545 if (isset($pl[
'opt'][
'mk'][
'ac'])) {
8546 $annots .=
' /AC '.$pl[
'opt'][
'mk'][
'ac'];
8548 if (isset($pl[
'opt'][
'mk'][
'i'])) {
8550 if ($info !==
false) {
8551 $annots .=
' /I '.$info[
'n'].
' 0 R';
8554 if (isset($pl[
'opt'][
'mk'][
'ri'])) {
8556 if ($info !==
false) {
8557 $annots .=
' /RI '.$info[
'n'].
' 0 R';
8560 if (isset($pl[
'opt'][
'mk'][
'ix'])) {
8562 if ($info !==
false) {
8563 $annots .=
' /IX '.$info[
'n'].
' 0 R';
8566 if (isset($pl[
'opt'][
'mk'][
'if']) AND (is_array($pl[
'opt'][
'mk'][
'if'])) AND !empty($pl[
'opt'][
'mk'][
'if'])) {
8567 $annots .=
' /IF <<';
8568 $if_sw = array(
'A',
'B',
'S',
'N');
8569 if (isset($pl[
'opt'][
'mk'][
'if'][
'sw']) AND in_array($pl[
'opt'][
'mk'][
'if'][
'sw'], $if_sw)) {
8570 $annots .=
' /SW /'.$pl[
'opt'][
'mk'][
'if'][
'sw'];
8572 $if_s = array(
'A',
'P');
8573 if (isset($pl[
'opt'][
'mk'][
'if'][
's']) AND in_array($pl[
'opt'][
'mk'][
'if'][
's'], $if_s)) {
8574 $annots .=
' /S /'.$pl[
'opt'][
'mk'][
'if'][
's'];
8576 if (isset($pl[
'opt'][
'mk'][
'if'][
'a']) AND (is_array($pl[
'opt'][
'mk'][
'if'][
'a'])) AND !empty($pl[
'opt'][
'mk'][
'if'][
'a'])) {
8577 $annots .= sprintf(
' /A [%F %F]', $pl[
'opt'][
'mk'][
'if'][
'a'][0], $pl[
'opt'][
'mk'][
'if'][
'a'][1]);
8579 if (isset($pl[
'opt'][
'mk'][
'if'][
'fb']) AND ($pl[
'opt'][
'mk'][
'if'][
'fb'])) {
8580 $annots .=
' /FB true';
8584 if (isset($pl[
'opt'][
'mk'][
'tp']) AND ($pl[
'opt'][
'mk'][
'tp'] >= 0) AND ($pl[
'opt'][
'mk'][
'tp'] <= 6)) {
8585 $annots .=
' /TP '.intval($pl[
'opt'][
'mk'][
'tp']);
8590 if (isset($this->radiobutton_groups[$n][$pl[
'txt']])) {
8592 $annots .=
' /Parent '.$this->radiobutton_groups[
$n][$pl[
'txt']].
' 0 R';
8594 if (isset($pl[
'opt'][
't']) AND is_string($pl[
'opt'][
't'])) {
8595 $annots .=
' /T '.$this->_datastring($pl[
'opt'][
't'], $annot_obj_id);
8597 if (isset($pl[
'opt'][
'tu']) AND is_string($pl[
'opt'][
'tu'])) {
8598 $annots .=
' /TU '.$this->_datastring($pl[
'opt'][
'tu'], $annot_obj_id);
8600 if (isset($pl[
'opt'][
'tm']) AND is_string($pl[
'opt'][
'tm'])) {
8601 $annots .=
' /TM '.$this->_datastring($pl[
'opt'][
'tm'], $annot_obj_id);
8603 if (isset($pl[
'opt'][
'ff'])) {
8604 if (is_array($pl[
'opt'][
'ff'])) {
8607 foreach($pl[
'opt'][
'ff'] as $val) {
8608 $flag += 1 << ($val - 1);
8611 $flag = intval($pl[
'opt'][
'ff']);
8613 $annots .=
' /Ff '.$flag;
8615 if (isset($pl[
'opt'][
'maxlen'])) {
8616 $annots .=
' /MaxLen '.intval($pl[
'opt'][
'maxlen']);
8618 if (isset($pl[
'opt'][
'v'])) {
8620 if (is_array($pl[
'opt'][
'v'])) {
8621 foreach ($pl[
'opt'][
'v'] AS $optval) {
8622 if (is_float($optval)) {
8623 $optval = sprintf(
'%F', $optval);
8625 $annots .=
' '.$optval;
8628 $annots .=
' '.$this->_textstring($pl[
'opt'][
'v'], $annot_obj_id);
8631 if (isset($pl[
'opt'][
'dv'])) {
8633 if (is_array($pl[
'opt'][
'dv'])) {
8634 foreach ($pl[
'opt'][
'dv'] AS $optval) {
8635 if (is_float($optval)) {
8636 $optval = sprintf(
'%F', $optval);
8638 $annots .=
' '.$optval;
8641 $annots .=
' '.$this->_textstring($pl[
'opt'][
'dv'], $annot_obj_id);
8644 if (isset($pl[
'opt'][
'rv'])) {
8646 if (is_array($pl[
'opt'][
'rv'])) {
8647 foreach ($pl[
'opt'][
'rv'] AS $optval) {
8648 if (is_float($optval)) {
8649 $optval = sprintf(
'%F', $optval);
8651 $annots .=
' '.$optval;
8654 $annots .=
' '.$this->_textstring($pl[
'opt'][
'rv'], $annot_obj_id);
8657 if (isset($pl[
'opt'][
'a']) AND !empty($pl[
'opt'][
'a'])) {
8658 $annots .=
' /A << '.$pl[
'opt'][
'a'].
' >>';
8660 if (isset($pl[
'opt'][
'aa']) AND !empty($pl[
'opt'][
'aa'])) {
8661 $annots .=
' /AA << '.$pl[
'opt'][
'aa'].
' >>';
8663 if (isset($pl[
'opt'][
'da']) AND !empty($pl[
'opt'][
'da'])) {
8664 $annots .=
' /DA ('.$pl[
'opt'][
'da'].
')';
8666 if (isset($pl[
'opt'][
'q']) AND ($pl[
'opt'][
'q'] >= 0) AND ($pl[
'opt'][
'q'] <= 2)) {
8667 $annots .=
' /Q '.intval($pl[
'opt'][
'q']);
8669 if (isset($pl[
'opt'][
'opt']) AND (is_array($pl[
'opt'][
'opt'])) AND !empty($pl[
'opt'][
'opt'])) {
8670 $annots .=
' /Opt [';
8671 foreach($pl[
'opt'][
'opt'] AS $copt) {
8672 if (is_array($copt)) {
8673 $annots .=
' ['.$this->_textstring($copt[0], $annot_obj_id).
' '.$this->
_textstring($copt[1], $annot_obj_id).
']';
8675 $annots .=
' '.$this->_textstring($copt, $annot_obj_id);
8680 if (isset($pl[
'opt'][
'ti'])) {
8681 $annots .=
' /TI '.intval($pl[
'opt'][
'ti']);
8683 if (isset($pl[
'opt'][
'i']) AND (is_array($pl[
'opt'][
'i'])) AND !empty($pl[
'opt'][
'i'])) {
8685 foreach($pl[
'opt'][
'i'] AS $copt) {
8686 $annots .= intval($copt).
' ';
8695 case 'printermark': {
8713 $this->
_out($this->
_getobj($annot_obj_id).
"\n".$annots.
"\n".
'endobj');
8714 if ($formfield AND !isset($this->radiobutton_groups[$n][$pl[
'txt']])) {
8716 $this->form_obj_id[] = $annot_obj_id;
8733 $stream = trim($stream);
8735 $this->xobjects[
'AX'.$this->n] = array(
'n' => $this->n);
8737 $out .=
' /Type /XObject';
8738 $out .=
' /Subtype /Form';
8739 $out .=
' /FormType 1';
8740 if ($this->compress) {
8741 $stream = gzcompress($stream);
8742 $out .=
' /Filter /FlateDecode';
8744 $rect = sprintf(
'%F %F',
$w,
$h);
8745 $out .=
' /BBox [0 0 '.$rect.
']';
8746 $out .=
' /Matrix [1 0 0 1 0 0]';
8747 $out .=
' /Resources 2 0 R';
8749 $out .=
' /Length '.strlen($stream);
8751 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
8752 $out .=
"\n".
'endobj';
8764 foreach ($this->diffs as $diff) {
8767 $this->
_out(
'<< /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.
'] >>'.
"\n".
'endobj');
8771 foreach ($this->FontFiles as $file => $info) {
8775 $font = file_get_contents($fontfile);
8776 $compressed = (substr($file, -2) ==
'.z');
8777 if ((!$compressed) AND (isset($info[
'length2']))) {
8778 $header = (ord($font{0}) == 128);
8781 $font = substr($font, 6);
8783 if ($header AND (ord($font[$info[
'length1']]) == 128)) {
8785 $font = substr($font, 0, $info[
'length1']).substr($font, ($info[
'length1'] + 6));
8787 } elseif ($info[
'subset'] AND ((!$compressed) OR ($compressed AND function_exists(
'gzcompress')))) {
8790 $font = gzuncompress($font);
8793 $subsetchars = array();
8794 foreach ($info[
'fontkeys'] as $fontkey) {
8796 $subsetchars += $fontinfo[
'subsetchars'];
8801 $info[
'length1'] = strlen($font);
8804 $font = gzcompress($font);
8808 $this->FontFiles[$file][
'n'] =
$this->n;
8810 $out =
'<< /Length '.strlen($stream);
8812 $out .=
' /Filter /FlateDecode';
8814 $out .=
' /Length1 '.$info[
'length1'];
8815 if (isset($info[
'length2'])) {
8816 $out .=
' /Length2 '.$info[
'length2'].
' /Length3 0';
8819 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
8820 $out .=
"\n".
'endobj';
8825 foreach ($this->fontkeys as
$k) {
8828 $type = $font[
'type'];
8829 $name = $font[
'name'];
8830 if ($type ==
'core') {
8832 $out = $this->
_getobj($this->font_obj_ids[$k]).
"\n";
8833 $out .=
'<</Type /Font';
8834 $out .=
' /Subtype /Type1';
8835 $out .=
' /BaseFont /'.$name;
8836 $out .=
' /Name /F'.$font[
'i'];
8837 if ((strtolower($name) !=
'symbol') AND (strtolower($name) !=
'zapfdingbats')) {
8838 $out .=
' /Encoding /WinAnsiEncoding';
8840 if ($k ==
'helvetica') {
8842 $this->annotation_fonts[
$k] = $font[
'i'];
8845 $out .=
"\n".
'endobj';
8847 } elseif (($type ==
'Type1') OR ($type ==
'TrueType')) {
8849 $out = $this->
_getobj($this->font_obj_ids[$k]).
"\n";
8850 $out .=
'<</Type /Font';
8851 $out .=
' /Subtype /'.$type;
8852 $out .=
' /BaseFont /'.$name;
8853 $out .=
' /Name /F'.$font[
'i'];
8854 $out .=
' /FirstChar 32 /LastChar 255';
8855 $out .=
' /Widths '.($this->n + 1).
' 0 R';
8856 $out .=
' /FontDescriptor '.($this->n + 2).
' 0 R';
8858 if (isset($font[
'diff'])) {
8859 $out .=
' /Encoding '.($nf + $font[
'diff']).
' 0 R';
8861 $out .=
' /Encoding /WinAnsiEncoding';
8865 $out .=
"\n".
'endobj';
8870 for ($i = 32; $i < 256; ++$i) {
8871 if (isset($font[
'cw'][$i])) {
8872 $s .= $font[
'cw'][$i].
' ';
8874 $s .= $font[
'dw'].
' ';
8878 $s .=
"\n".
'endobj';
8882 $s =
'<</Type /FontDescriptor /FontName /'.$name;
8883 foreach ($font[
'desc'] as $fdk => $fdv) {
8884 if (is_float($fdv)) {
8885 $fdv = sprintf(
'%F', $fdv);
8887 $s .=
' /'.$fdk.
' '.$fdv.
'';
8890 $s .=
' /FontFile'.($type ==
'Type1' ?
'' :
'2').
' '.$this->FontFiles[$font[
'file']][
'n'].
' 0 R';
8893 $s .=
"\n".
'endobj';
8897 $mtd =
'_put'.strtolower($type);
8898 if (!method_exists($this, $mtd)) {
8899 $this->
Error(
'Unsupported font type: '.$type);
8916 if ($font[
'subset']) {
8918 $subtag = sprintf(
'%06u', $font[
'i']);
8919 $subtag = strtr($subtag,
'0123456789',
'ABCDEFGHIJ');
8920 $fontname .= $subtag.
'+';
8922 $fontname .= $font[
'name'];
8925 $out = $this->
_getobj($this->font_obj_ids[$font[
'fontkey']]).
"\n";
8926 $out .=
'<< /Type /Font';
8927 $out .=
' /Subtype /Type0';
8928 $out .=
' /BaseFont /'.$fontname;
8929 $out .=
' /Name /F'.$font[
'i'];
8930 $out .=
' /Encoding /'.$font[
'enc'];
8931 $out .=
' /ToUnicode '.($this->n + 1).
' 0 R';
8932 $out .=
' /DescendantFonts ['.($this->n + 2).
' 0 R]';
8934 $out .=
"\n".
'endobj';
8943 $this->
_out(
'<<'.$filter.
'/Length '.strlen($stream).
'>> stream'.
"\n".$stream.
"\n".
'endstream'.
"\n".
'endobj');
8947 $out =
'<< /Type /Font';
8948 $out .=
' /Subtype /CIDFontType2';
8949 $out .=
' /BaseFont /'.$fontname;
8951 $cidinfo =
'/Registry '.$this->_datastring($font[
'cidinfo'][
'Registry'], $oid);
8952 $cidinfo .=
' /Ordering '.$this->_datastring($font[
'cidinfo'][
'Ordering'], $oid);
8953 $cidinfo .=
' /Supplement '.$font[
'cidinfo'][
'Supplement'];
8954 $out .=
' /CIDSystemInfo << '.$cidinfo.
' >>';
8955 $out .=
' /FontDescriptor '.($this->n + 1).
' 0 R';
8956 $out .=
' /DW '.$font[
'dw'];
8957 $out .=
"\n".TCPDF_FONTS::_putfontwidths($font, 0);
8959 $out .=
"\n".
'/CIDToGIDMap '.($this->n + 2).
' 0 R';
8962 $out .=
"\n".
'endobj';
8967 $out =
'<< /Type /FontDescriptor';
8968 $out .=
' /FontName /'.$fontname;
8969 foreach ($font[
'desc'] as $key => $value) {
8970 if (is_float($value)) {
8971 $value = sprintf(
'%F', $value);
8973 $out .=
' /'.$key.
' '.$value;
8978 $out .=
' /FontFile2 '.$this->FontFiles[$font[
'file']][
'n'].
' 0 R';
8979 $fontdir = $this->FontFiles[$font[
'file']][
'fontdir'];
8982 $out .=
"\n".
'endobj';
8989 $ctgfile = strtolower($font[
'ctg']);
8993 $this->
Error(
'Font file not found: '.$ctgfile);
8995 $stream = $this->
_getrawstream(file_get_contents($fontfile));
8996 $out =
'<< /Length '.strlen($stream).
'';
8997 if (substr($fontfile, -2) ==
'.z') {
9001 $out .=
' /Filter /FlateDecode';
9004 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
9005 $out .=
"\n".
'endobj';
9020 if (!isset($font[
'cw'][1])) {
9023 if (isset($font[
'cidinfo'][
'uni2cid'])) {
9025 $uni2cid = $font[
'cidinfo'][
'uni2cid'];
9027 foreach ($font[
'cw'] as $uni => $width) {
9028 if (isset($uni2cid[$uni])) {
9029 $cw[($uni2cid[$uni] + $cidoffset)] = $width;
9030 } elseif ($uni < 256) {
9034 $font = array_merge($font, array(
'cw' => $cw));
9036 $name = $font[
'name'];
9037 $enc = $font[
'enc'];
9039 $longname = $name.
'-'.$enc;
9043 $out = $this->
_getobj($this->font_obj_ids[$font[
'fontkey']]).
"\n";
9044 $out .=
'<</Type /Font';
9045 $out .=
' /Subtype /Type0';
9046 $out .=
' /BaseFont /'.$longname;
9047 $out .=
' /Name /F'.$font[
'i'];
9049 $out .=
' /Encoding /'.$enc;
9051 $out .=
' /DescendantFonts ['.($this->n + 1).
' 0 R]';
9053 $out .=
"\n".
'endobj';
9056 $out =
'<</Type /Font';
9057 $out .=
' /Subtype /CIDFontType0';
9058 $out .=
' /BaseFont /'.$name;
9059 $cidinfo =
'/Registry '.$this->_datastring($font[
'cidinfo'][
'Registry'], $oid);
9060 $cidinfo .=
' /Ordering '.$this->_datastring($font[
'cidinfo'][
'Ordering'], $oid);
9061 $cidinfo .=
' /Supplement '.$font[
'cidinfo'][
'Supplement'];
9062 $out .=
' /CIDSystemInfo <<'.$cidinfo.
'>>';
9063 $out .=
' /FontDescriptor '.($this->n + 1).
' 0 R';
9064 $out .=
' /DW '.$font[
'dw'];
9065 $out .=
"\n".TCPDF_FONTS::_putfontwidths($font, $cidoffset);
9067 $out .=
"\n".
'endobj';
9070 $s =
'<</Type /FontDescriptor /FontName /'.$name;
9071 foreach ($font[
'desc'] as
$k => $v) {
9072 if (
$k !=
'Style') {
9074 $v = sprintf(
'%F', $v);
9076 $s .=
' /'.$k.
' '.$v.
'';
9080 $s .=
"\n".
'endobj';
9090 foreach ($this->imagekeys as $file) {
9093 if ((!$this->pdfa_mode) AND isset($info[
'altimgs']) AND !empty($info[
'altimgs'])) {
9096 foreach ($info[
'altimgs'] as $altimage) {
9097 if (isset($this->xobjects[
'I'.$altimage[0]][
'n'])) {
9098 $out .=
' << /Image '.$this->xobjects[
'I'.$altimage[0]][
'n'].
' 0 R';
9099 $out .=
' /DefaultForPrinting';
9100 if ($altimage[1] ===
true) {
9109 $out .=
"\n".
'endobj';
9114 $this->xobjects[
'I'.$info[
'i']] = array(
'n' => $oid);
9116 $out =
'<</Type /XObject';
9117 $out .=
' /Subtype /Image';
9118 $out .=
' /Width '.$info[
'w'];
9119 $out .=
' /Height '.$info[
'h'];
9120 if (array_key_exists(
'masked', $info)) {
9121 $out .=
' /SMask '.($this->n - 1).
' 0 R';
9125 if (isset($info[
'icc']) AND ($info[
'icc'] !==
false)) {
9128 $out .=
' /ColorSpace [/ICCBased '.($this->n + 1).
' 0 R]';
9129 } elseif ($info[
'cs'] ==
'Indexed') {
9131 $out .=
' /ColorSpace [/Indexed /DeviceRGB '.((strlen($info[
'pal']) / 3) - 1).
' '.($this->n + 1).
' 0 R]';
9134 $out .=
' /ColorSpace /'.$info[
'cs'];
9136 if ($info[
'cs'] ==
'DeviceCMYK') {
9137 $out .=
' /Decode [1 0 1 0 1 0 1 0]';
9139 $out .=
' /BitsPerComponent '.$info[
'bpc'];
9140 if (isset($altoid) AND ($altoid > 0)) {
9142 $out .=
' /Alternates '.$altoid.
' 0 R';
9144 if (isset($info[
'exurl']) AND !empty($info[
'exurl'])) {
9146 $out .=
' /Length 0';
9147 $out .=
' /F << /FS /URL /F '.$this->_datastring($info[
'exurl'], $oid).
' >>';
9148 if (isset($info[
'f'])) {
9149 $out .=
' /FFilter /'.$info[
'f'];
9152 $out .=
' stream'.
"\n".
'endstream';
9154 if (isset($info[
'f'])) {
9155 $out .=
' /Filter /'.$info[
'f'];
9157 if (isset($info[
'parms'])) {
9158 $out .=
' '.$info[
'parms'];
9160 if (isset($info[
'trns']) AND is_array($info[
'trns'])) {
9162 $count_info = count($info[
'trns']);
9163 for ($i=0; $i < $count_info; ++$i) {
9164 $trns .= $info[
'trns'][$i].
' '.$info[
'trns'][$i].
' ';
9166 $out .=
' /Mask ['.$trns.
']';
9169 $out .=
' /Length '.strlen($stream).
' >>';
9170 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
9172 $out .=
"\n".
'endobj';
9179 $this->
_out(
'<</N '.$info[
'ch'].
' /Alternate /'.$info[
'cs'].
' '.$filter.
'/Length '.strlen($icc).
'>> stream'.
"\n".$icc.
"\n".
'endstream'.
"\n".
'endobj');
9180 } elseif ($info[
'cs'] ==
'Indexed') {
9185 $this->
_out(
'<<'.$filter.
'/Length '.strlen($pal).
'>> stream'.
"\n".$pal.
"\n".
'endstream'.
"\n".
'endobj');
9198 foreach ($this->xobjects as $key => $data) {
9199 if (isset($data[
'outdata'])) {
9200 $stream = str_replace($this->epsmarker,
'', trim($data[
'outdata']));
9201 $out = $this->
_getobj($data[
'n']).
"\n";
9203 $out .=
' /Type /XObject';
9204 $out .=
' /Subtype /Form';
9205 $out .=
' /FormType 1';
9206 if ($this->compress) {
9207 $stream = gzcompress($stream);
9208 $out .=
' /Filter /FlateDecode';
9210 $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));
9211 $out .=
' /Matrix [1 0 0 1 0 0]';
9212 $out .=
' /Resources <<';
9213 $out .=
' /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]';
9214 if (!$this->pdfa_mode) {
9216 if (isset($data[
'extgstates']) AND !empty($data[
'extgstates'])) {
9217 $out .=
' /ExtGState <<';
9218 foreach ($data[
'extgstates'] as
$k => $extgstate) {
9219 if (isset($this->extgstates[
$k][
'name'])) {
9220 $out .=
' /'.$this->extgstates[
$k][
'name'];
9224 $out .=
' '.$this->extgstates[
$k][
'n'].
' 0 R';
9228 if (isset($data[
'gradients']) AND !empty($data[
'gradients'])) {
9231 foreach ($data[
'gradients'] as $id => $grad) {
9233 $gp .=
' /p'.$id.
' '.$this->gradients[$id][
'pattern'].
' 0 R';
9235 $gs .=
' /Sh'.$id.
' '.$this->gradients[$id][
'id'].
' 0 R';
9237 $out .=
' /Pattern <<'.$gp.
' >>';
9238 $out .=
' /Shading <<'.$gs.
' >>';
9242 if (isset($data[
'spot_colors']) AND !empty($data[
'spot_colors'])) {
9243 $out .=
' /ColorSpace <<';
9244 foreach ($data[
'spot_colors'] as $name => $color) {
9245 $out .=
' /CS'.$color[
'i'].
' '.$this->spot_colors[$name][
'n'].
' 0 R';
9250 if (!empty($data[
'fonts'])) {
9251 $out .=
' /Font <<';
9252 foreach ($data[
'fonts'] as $fontkey => $fontid) {
9253 $out .=
' /F'.$fontid.
' '.$this->font_obj_ids[$fontkey].
' 0 R';
9258 if (!empty($data[
'images']) OR !empty($data[
'xobjects'])) {
9259 $out .=
' /XObject <<';
9260 foreach ($data[
'images'] as $imgid) {
9261 $out .=
' /I'.$imgid.
' '.$this->xobjects[
'I'.$imgid][
'n'].
' 0 R';
9263 foreach ($data[
'xobjects'] as $sub_id => $sub_objid) {
9264 $out .=
' /'.$sub_id.
' '.$sub_objid[
'n'].
' 0 R';
9269 if (isset($data[
'group']) AND ($data[
'group'] !==
false)) {
9271 $out .=
' /Group << /Type /Group /S /Transparency';
9272 if (is_array($data[
'group'])) {
9273 if (isset($data[
'group'][
'CS']) AND !empty($data[
'group'][
'CS'])) {
9274 $out .=
' /CS /'.$data[
'group'][
'CS'];
9276 if (isset($data[
'group'][
'I'])) {
9277 $out .=
' /I /'.($data[
'group'][
'I']===
true?
'true':
'false');
9279 if (isset($data[
'group'][
'K'])) {
9280 $out .=
' /K /'.($data[
'group'][
'K']===
true?
'true':
'false');
9286 $out .=
' /Length '.strlen($stream);
9288 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
9289 $out .=
"\n".
'endobj';
9301 foreach ($this->spot_colors as $name => $color) {
9303 $this->spot_colors[$name][
'n'] =
$this->n;
9304 $out =
'[/Separation /'.str_replace(
' ',
'#20', $name);
9305 $out .=
' /DeviceCMYK <<';
9306 $out .=
' /Range [0 1 0 1 0 1 0 1] /C0 [0 0 0 0]';
9307 $out .=
' '.sprintf(
'/C1 [%F %F %F %F] ', ($color[
'C'] / 100), ($color[
'M'] / 100), ($color[
'Y'] / 100), ($color[
'K'] / 100));
9308 $out .=
' /FunctionType 2 /Domain [0 1] /N 1>>]';
9309 $out .=
"\n".
'endobj';
9322 foreach ($this->xobjects as $id => $objid) {
9323 $out .=
' /'.$id.
' '.$objid[
'n'].
' 0 R';
9333 $out = $this->
_getobj(2).
"\n";
9334 $out .=
'<< /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]';
9335 $out .=
' /Font <<';
9336 foreach ($this->fontkeys as $fontkey) {
9338 $out .=
' /F'.$font[
'i'].
' '.$font[
'n'].
' 0 R';
9341 $out .=
' /XObject <<';
9345 if (!empty($this->pdflayers)) {
9346 $out .=
' /Properties <<';
9347 foreach ($this->pdflayers as $layer) {
9348 $out .=
' /'.$layer[
'layer'].
' '.$layer[
'objid'].
' 0 R';
9352 if (!$this->pdfa_mode) {
9354 if (isset($this->extgstates) AND !empty($this->extgstates)) {
9355 $out .=
' /ExtGState <<';
9356 foreach ($this->extgstates as
$k => $extgstate) {
9357 if (isset($extgstate[
'name'])) {
9358 $out .=
' /'.$extgstate[
'name'];
9362 $out .=
' '.$extgstate[
'n'].
' 0 R';
9366 if (isset($this->gradients) AND !empty($this->gradients)) {
9369 foreach ($this->gradients as $id => $grad) {
9371 $gp .=
' /p'.$id.
' '.$grad[
'pattern'].
' 0 R';
9373 $gs .=
' /Sh'.$id.
' '.$grad[
'id'].
' 0 R';
9375 $out .=
' /Pattern <<'.$gp.
' >>';
9376 $out .=
' /Shading <<'.$gs.
' >>';
9380 if (isset($this->spot_colors) AND !empty($this->spot_colors)) {
9381 $out .=
' /ColorSpace <<';
9382 foreach ($this->spot_colors as $color) {
9383 $out .=
' /CS'.$color[
'i'].
' '.$color[
'n'].
' 0 R';
9388 $out .=
"\n".
'endobj';
9424 if ($this->docinfounicode) {
9425 $this->isunicode =
true;
9429 $out .=
' /Title '.$this->_textstring($this->title, $oid);
9433 $out .=
' /Author '.$this->_textstring($this->author, $oid);
9437 $out .=
' /Subject '.$this->_textstring($this->subject, $oid);
9441 $out .=
' /Keywords '.$this->_textstring($this->keywords, $oid);
9445 $out .=
' /Creator '.$this->_textstring($this->creator, $oid);
9448 $this->isunicode = $prev_isunicode;
9452 $out .=
' /CreationDate '.$this->_datestring(0, $this->doc_creation_timestamp);
9454 $out .=
' /ModDate '.$this->_datestring(0, $this->doc_modification_timestamp);
9456 $out .=
' /Trapped /False';
9458 $out .=
"\n".
'endobj';
9471 $this->custom_xmp = $xmp;
9484 $this->isunicode =
true;
9486 $this->encrypted =
false;
9488 $xmp =
'<?xpacket begin="'.TCPDF_FONTS::unichr(0xfeff, $this->isunicode).
'" id="W5M0MpCehiHzreSzNTczkc9d"?>'.
"\n";
9489 $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";
9490 $xmp .=
"\t".
'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">'.
"\n";
9491 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">'.
"\n";
9492 $xmp .=
"\t\t\t".
'<dc:format>application/pdf</dc:format>'.
"\n";
9493 $xmp .=
"\t\t\t".
'<dc:title>'.
"\n";
9494 $xmp .=
"\t\t\t\t".
'<rdf:Alt>'.
"\n";
9496 $xmp .=
"\t\t\t\t".
'</rdf:Alt>'.
"\n";
9497 $xmp .=
"\t\t\t".
'</dc:title>'.
"\n";
9498 $xmp .=
"\t\t\t".
'<dc:creator>'.
"\n";
9499 $xmp .=
"\t\t\t\t".
'<rdf:Seq>'.
"\n";
9501 $xmp .=
"\t\t\t\t".
'</rdf:Seq>'.
"\n";
9502 $xmp .=
"\t\t\t".
'</dc:creator>'.
"\n";
9503 $xmp .=
"\t\t\t".
'<dc:description>'.
"\n";
9504 $xmp .=
"\t\t\t\t".
'<rdf:Alt>'.
"\n";
9506 $xmp .=
"\t\t\t\t".
'</rdf:Alt>'.
"\n";
9507 $xmp .=
"\t\t\t".
'</dc:description>'.
"\n";
9508 $xmp .=
"\t\t\t".
'<dc:subject>'.
"\n";
9509 $xmp .=
"\t\t\t\t".
'<rdf:Bag>'.
"\n";
9511 $xmp .=
"\t\t\t\t".
'</rdf:Bag>'.
"\n";
9512 $xmp .=
"\t\t\t".
'</dc:subject>'.
"\n";
9513 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9516 $doccreationdate = substr($dcdate, 0, 4).
'-'.substr($dcdate, 4, 2).
'-'.substr($dcdate, 6, 2);
9517 $doccreationdate .=
'T'.substr($dcdate, 8, 2).
':'.substr($dcdate, 10, 2).
':'.substr($dcdate, 12, 2);
9518 $doccreationdate .=
'+'.substr($dcdate, 15, 2).
':'.substr($dcdate, 18, 2);
9522 $docmoddate = substr($dmdate, 0, 4).
'-'.substr($dmdate, 4, 2).
'-'.substr($dmdate, 6, 2);
9523 $docmoddate .=
'T'.substr($dmdate, 8, 2).
':'.substr($dmdate, 10, 2).
':'.substr($dmdate, 12, 2);
9524 $docmoddate .=
'+'.substr($dmdate, 15, 2).
':'.substr($dmdate, 18, 2);
9526 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">'.
"\n";
9527 $xmp .=
"\t\t\t".
'<xmp:CreateDate>'.$doccreationdate.
'</xmp:CreateDate>'.
"\n";
9528 $xmp .=
"\t\t\t".
'<xmp:CreatorTool>'.$this->creator.
'</xmp:CreatorTool>'.
"\n";
9529 $xmp .=
"\t\t\t".
'<xmp:ModifyDate>'.$docmoddate.
'</xmp:ModifyDate>'.
"\n";
9530 $xmp .=
"\t\t\t".
'<xmp:MetadataDate>'.$doccreationdate.
'</xmp:MetadataDate>'.
"\n";
9531 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9532 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">'.
"\n";
9535 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9536 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">'.
"\n";
9537 $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);
9538 $xmp .=
"\t\t\t".
'<xmpMM:DocumentID>'.$uuid.
'</xmpMM:DocumentID>'.
"\n";
9539 $xmp .=
"\t\t\t".
'<xmpMM:InstanceID>'.$uuid.
'</xmpMM:InstanceID>'.
"\n";
9540 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9541 if ($this->pdfa_mode) {
9542 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/">'.
"\n";
9543 $xmp .=
"\t\t\t".
'<pdfaid:part>1</pdfaid:part>'.
"\n";
9544 $xmp .=
"\t\t\t".
'<pdfaid:conformance>B</pdfaid:conformance>'.
"\n";
9545 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9548 $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";
9549 $xmp .=
"\t\t\t".
'<pdfaExtension:schemas>'.
"\n";
9550 $xmp .=
"\t\t\t\t".
'<rdf:Bag>'.
"\n";
9551 $xmp .=
"\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9552 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:namespaceURI>http://ns.adobe.com/pdf/1.3/</pdfaSchema:namespaceURI>'.
"\n";
9553 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:prefix>pdf</pdfaSchema:prefix>'.
"\n";
9554 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:schema>Adobe PDF Schema</pdfaSchema:schema>'.
"\n";
9555 $xmp .=
"\t\t\t\t\t".
'</rdf:li>'.
"\n";
9556 $xmp .=
"\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9557 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:namespaceURI>http://ns.adobe.com/xap/1.0/mm/</pdfaSchema:namespaceURI>'.
"\n";
9558 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:prefix>xmpMM</pdfaSchema:prefix>'.
"\n";
9559 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:schema>XMP Media Management Schema</pdfaSchema:schema>'.
"\n";
9560 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:property>'.
"\n";
9561 $xmp .=
"\t\t\t\t\t\t\t".
'<rdf:Seq>'.
"\n";
9562 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9563 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9564 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>UUID based identifier for specific incarnation of a document</pdfaProperty:description>'.
"\n";
9565 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>InstanceID</pdfaProperty:name>'.
"\n";
9566 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>URI</pdfaProperty:valueType>'.
"\n";
9567 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9568 $xmp .=
"\t\t\t\t\t\t\t".
'</rdf:Seq>'.
"\n";
9569 $xmp .=
"\t\t\t\t\t\t".
'</pdfaSchema:property>'.
"\n";
9570 $xmp .=
"\t\t\t\t\t".
'</rdf:li>'.
"\n";
9571 $xmp .=
"\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9572 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:namespaceURI>http://www.aiim.org/pdfa/ns/id/</pdfaSchema:namespaceURI>'.
"\n";
9573 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:prefix>pdfaid</pdfaSchema:prefix>'.
"\n";
9574 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:schema>PDF/A ID Schema</pdfaSchema:schema>'.
"\n";
9575 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:property>'.
"\n";
9576 $xmp .=
"\t\t\t\t\t\t\t".
'<rdf:Seq>'.
"\n";
9577 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9578 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9579 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>Part of PDF/A standard</pdfaProperty:description>'.
"\n";
9580 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>part</pdfaProperty:name>'.
"\n";
9581 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>Integer</pdfaProperty:valueType>'.
"\n";
9582 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9583 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9584 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9585 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>Amendment of PDF/A standard</pdfaProperty:description>'.
"\n";
9586 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>amd</pdfaProperty:name>'.
"\n";
9587 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>Text</pdfaProperty:valueType>'.
"\n";
9588 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9589 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9590 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9591 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>Conformance level of PDF/A standard</pdfaProperty:description>'.
"\n";
9592 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>conformance</pdfaProperty:name>'.
"\n";
9593 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>Text</pdfaProperty:valueType>'.
"\n";
9594 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9595 $xmp .=
"\t\t\t\t\t\t\t".
'</rdf:Seq>'.
"\n";
9596 $xmp .=
"\t\t\t\t\t\t".
'</pdfaSchema:property>'.
"\n";
9597 $xmp .=
"\t\t\t\t\t".
'</rdf:li>'.
"\n";
9598 $xmp .=
"\t\t\t\t".
'</rdf:Bag>'.
"\n";
9599 $xmp .=
"\t\t\t".
'</pdfaExtension:schemas>'.
"\n";
9600 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9601 $xmp .=
"\t".
'</rdf:RDF>'.
"\n";
9603 $xmp .=
'</x:xmpmeta>'.
"\n";
9604 $xmp .=
'<?xpacket end="w"?>';
9605 $out =
'<< /Type /Metadata /Subtype /XML /Length '.strlen($xmp).
' >> stream'.
"\n".$xmp.
"\n".
'endstream'.
"\n".
'endobj';
9607 $this->isunicode = $prev_isunicode;
9608 $this->encrypted = $prev_encrypted;
9622 if ($this->pdfa_mode OR $this->force_srgb) {
9624 $icc = file_get_contents(dirname(__FILE__).
'/include/sRGB.icc');
9626 if ($this->compress) {
9627 $filter =
' /Filter /FlateDecode';
9628 $icc = gzcompress($icc);
9631 $this->
_out(
'<</N 3 '.$filter.
'/Length '.strlen($icc).
'>> stream'.
"\n".$icc.
"\n".
'endstream'.
"\n".
'endobj');
9635 $out =
'<< /Type /Catalog';
9636 $out .=
' /Version /'.$this->PDFVersion;
9638 $out .=
' /Pages 1 0 R';
9640 $out .=
' /Names <<';
9641 if ((!$this->pdfa_mode) AND !empty($this->n_js)) {
9642 $out .=
' /JavaScript '.$this->n_js;
9644 if (!empty($this->efnames)) {
9645 $out .=
' /EmbeddedFiles <</Names [';
9646 foreach ($this->efnames AS $fn => $fref) {
9647 $out .=
' '.$this->_datastring($fn).
' '.$fref;
9652 if (!empty($this->dests)) {
9653 $out .=
' /Dests '.($this->n_dests).
' 0 R';
9657 $out .=
' /PageLayout /'.$this->LayoutMode;
9660 $out .=
' /PageMode /'.$this->PageMode;
9662 if (count($this->outlines) > 0) {
9663 $out .=
' /Outlines '.$this->OutlineRoot.
' 0 R';
9664 $out .=
' /PageMode /UseOutlines';
9667 if ($this->ZoomMode ==
'fullpage') {
9668 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /Fit]';
9669 } elseif ($this->ZoomMode ==
'fullwidth') {
9670 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /FitH null]';
9671 } elseif ($this->ZoomMode ==
'real') {
9672 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /XYZ null null 1]';
9673 } elseif (!is_string($this->ZoomMode)) {
9674 $out .= sprintf(
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /XYZ null null %F]', ($this->ZoomMode / 100));
9678 $out .=
' /Metadata '.$xmpobj.
' 0 R';
9681 if (isset($this->l[
'a_meta_language'])) {
9682 $out .=
' /Lang '.$this->_textstring($this->l[
'a_meta_language'], $oid);
9686 if ($this->pdfa_mode OR $this->force_srgb) {
9687 $out .=
' /OutputIntents [<<';
9688 $out .=
' /Type /OutputIntent';
9689 $out .=
' /S /GTS_PDFA1';
9690 $out .=
' /OutputCondition '.$this->_textstring(
'sRGB IEC61966-2.1', $oid);
9691 $out .=
' /OutputConditionIdentifier '.$this->_textstring(
'sRGB IEC61966-2.1', $oid);
9692 $out .=
' /RegistryName '.$this->_textstring(
'http://www.color.org', $oid);
9693 $out .=
' /Info '.$this->_textstring(
'sRGB IEC61966-2.1', $oid);
9694 $out .=
' /DestOutputProfile '.$iccobj.
' 0 R';
9698 if (!empty($this->pdflayers)) {
9700 $lyrobjs_print =
'';
9702 foreach ($this->pdflayers as $layer) {
9703 $lyrobjs .=
' '.$layer[
'objid'].
' 0 R';
9704 if ($layer[
'print']) {
9705 $lyrobjs_print .=
' '.$layer[
'objid'].
' 0 R';
9707 if ($layer[
'view']) {
9708 $lyrobjs_view .=
' '.$layer[
'objid'].
' 0 R';
9711 $out .=
' /OCProperties << /OCGs ['.$lyrobjs.
']';
9713 $out .=
' /Name '.$this->_textstring(
'Layers', $oid);
9714 $out .=
' /Creator '.$this->_textstring(
'TCPDF', $oid);
9715 $out .=
' /BaseState /ON';
9716 $out .=
' /ON ['.$lyrobjs_print.
']';
9717 $out .=
' /OFF ['.$lyrobjs_view.
']';
9718 $out .=
' /Intent /View';
9720 $out .=
' << /Event /Print /OCGs ['.$lyrobjs.
'] /Category [/Print] >>';
9721 $out .=
' << /Event /View /OCGs ['.$lyrobjs.
'] /Category [/View] >>';
9723 $out .=
' /Order ['.$lyrobjs.
']';
9724 $out .=
' /ListMode /AllPages';
9731 if (!empty($this->form_obj_id)
9732 OR ($this->sign AND isset($this->signature_data[
'cert_type']))
9733 OR !empty($this->empty_signature_appearance)) {
9734 $out .=
' /AcroForm <<';
9736 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9738 $objrefs .= $this->sig_obj_id.
' 0 R';
9740 if (!empty($this->empty_signature_appearance)) {
9741 foreach ($this->empty_signature_appearance as $esa) {
9743 $objrefs .=
' '.$esa[
'objid'].
' 0 R';
9746 if (!empty($this->form_obj_id)) {
9747 foreach($this->form_obj_id as $objid) {
9748 $objrefs .=
' '.$objid.
' 0 R';
9751 $out .=
' /Fields ['.$objrefs.
']';
9753 $out .=
' /NeedAppearances false';
9754 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9755 if ($this->signature_data[
'cert_type'] > 0) {
9756 $out .=
' /SigFlags 3';
9758 $out .=
' /SigFlags 1';
9762 if (isset($this->annotation_fonts) AND !empty($this->annotation_fonts)) {
9764 $out .=
' /Font <<';
9765 foreach ($this->annotation_fonts as $fontkey => $fontid) {
9766 $out .=
' /F'.$fontid.
' '.$this->font_obj_ids[$fontkey].
' 0 R';
9771 $out .=
' /DA (/F'.$font[
'i'].
' 0 Tf 0 g)';
9772 $out .=
' /Q '.(($this->rtl)?
'2':
'0');
9776 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9777 if ($this->signature_data[
'cert_type'] > 0) {
9778 $out .=
' /Perms << /DocMDP '.($this->sig_obj_id + 1).
' 0 R >>';
9780 $out .=
' /Perms << /UR3 '.($this->sig_obj_id + 1).
' 0 R >>';
9789 $out .=
"\n".
'endobj';
9803 $out =
' /ViewerPreferences <<';
9805 $out .=
' /Direction /R2L';
9807 $out .=
' /Direction /L2R';
9809 if (isset($vp[
'HideToolbar']) AND ($vp[
'HideToolbar'])) {
9810 $out .=
' /HideToolbar true';
9812 if (isset($vp[
'HideMenubar']) AND ($vp[
'HideMenubar'])) {
9813 $out .=
' /HideMenubar true';
9815 if (isset($vp[
'HideWindowUI']) AND ($vp[
'HideWindowUI'])) {
9816 $out .=
' /HideWindowUI true';
9818 if (isset($vp[
'FitWindow']) AND ($vp[
'FitWindow'])) {
9819 $out .=
' /FitWindow true';
9821 if (isset($vp[
'CenterWindow']) AND ($vp[
'CenterWindow'])) {
9822 $out .=
' /CenterWindow true';
9824 if (isset($vp[
'DisplayDocTitle']) AND ($vp[
'DisplayDocTitle'])) {
9825 $out .=
' /DisplayDocTitle true';
9827 if (isset($vp[
'NonFullScreenPageMode'])) {
9828 $out .=
' /NonFullScreenPageMode /'.$vp[
'NonFullScreenPageMode'];
9830 if (isset($vp[
'ViewArea'])) {
9831 $out .=
' /ViewArea /'.$vp[
'ViewArea'];
9833 if (isset($vp[
'ViewClip'])) {
9834 $out .=
' /ViewClip /'.$vp[
'ViewClip'];
9836 if (isset($vp[
'PrintArea'])) {
9837 $out .=
' /PrintArea /'.$vp[
'PrintArea'];
9839 if (isset($vp[
'PrintClip'])) {
9840 $out .=
' /PrintClip /'.$vp[
'PrintClip'];
9842 if (isset($vp[
'PrintScaling'])) {
9843 $out .=
' /PrintScaling /'.$vp[
'PrintScaling'];
9846 $out .=
' /Duplex /'.$vp[
'Duplex'];
9848 if (isset($vp[
'PickTrayByPDFSize'])) {
9849 if ($vp[
'PickTrayByPDFSize']) {
9850 $out .=
' /PickTrayByPDFSize true';
9852 $out .=
' /PickTrayByPDFSize false';
9855 if (isset($vp[
'PrintPageRange'])) {
9856 $PrintPageRangeNum =
'';
9857 foreach ($vp[
'PrintPageRange'] as
$k => $v) {
9858 $PrintPageRangeNum .=
' '.($v - 1).
'';
9860 $out .=
' /PrintPageRange ['.substr($PrintPageRangeNum,1).
']';
9862 if (isset($vp[
'NumCopies'])) {
9863 $out .=
' /NumCopies '.intval($vp[
'NumCopies']);
9874 $this->
_out(
'%PDF-'.$this->PDFVersion);
9875 $this->
_out(
'%'.chr(0xe2).chr(0xe3).chr(0xcf).chr(0xd3));
9883 if (isset($this->CurrentFont[
'fontkey']) AND isset($this->CurrentFont[
'subsetchars'])) {
9885 $this->
setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
9892 if (!empty($this->empty_signature_appearance)) {
9893 foreach ($this->empty_signature_appearance as $key => $esa) {
9895 $out = $this->
_getobj($esa[
'objid']).
"\n";
9896 $out .=
'<< /Type /Annot';
9897 $out .=
' /Subtype /Widget';
9898 $out .=
' /Rect ['.$esa[
'rect'].
']';
9899 $out .=
' /P '.$this->page_obj_id[($esa[
'page'])].
' 0 R';
9901 $out .=
' /FT /Sig';
9902 $signame = $esa[
'name'].sprintf(
' [%03d]', ($key + 1));
9903 $out .=
' /T '.$this->_textstring($signame, $esa[
'objid']);
9906 $out .=
"\n".
'endobj';
9911 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9913 $out = $this->
_getobj($this->sig_obj_id).
"\n";
9914 $out .=
'<< /Type /Annot';
9915 $out .=
' /Subtype /Widget';
9916 $out .=
' /Rect ['.$this->signature_appearance[
'rect'].
']';
9917 $out .=
' /P '.$this->page_obj_id[($this->signature_appearance[
'page'])].
' 0 R';
9919 $out .=
' /FT /Sig';
9920 $out .=
' /T '.$this->_textstring($this->signature_appearance[
'name'], $this->sig_obj_id);
9922 $out .=
' /V '.($this->sig_obj_id + 1).
' 0 R';
9924 $out .=
"\n".
'endobj';
9936 $this->
_out(
'xref');
9937 $this->
_out(
'0 '.($this->n + 1));
9938 $this->
_out(
'0000000000 65535 f ');
9939 $freegen = ($this->n + 2);
9941 if (!isset($this->offsets[$i]) AND ($i > 1)) {
9942 $this->
_out(sprintf(
'0000000000 %05d f ', $freegen));
9945 $this->
_out(sprintf(
'%010d 00000 n ', $this->offsets[$i]));
9949 $out =
'trailer'.
"\n";
9951 $out .=
' /Size '.($this->n + 1);
9952 $out .=
' /Root '.$objid_catalog.
' 0 R';
9953 $out .=
' /Info '.$objid_info.
' 0 R';
9954 if ($this->encrypted) {
9955 $out .=
' /Encrypt '.$this->encryptdata[
'objid'].
' 0 R';
9957 $out .=
' /ID [ <'.$this->file_id.
'> <'.$this->file_id.
'> ]';
9960 $this->
_out(
'startxref');
9962 $this->
_out(
'%%EOF');
9964 if ($this->diskcache) {
9966 foreach ($this->imagekeys as $key) {
9968 unlink($this->images[$key]);
9970 foreach ($this->fontkeys as $key) {
9972 unlink($this->fonts[$key]);
9992 if (isset($this->CurOrientation)) {
9994 } elseif ($this->fwPt > $this->fhPt) {
10003 $this->pagedim[
$this->page] = $this->pagedim[($this->page - 1)];
10014 if (isset($this->newpagegroup[$this->page])) {
10016 $this->currpagegroup = $this->newpagegroup[
$this->page];
10018 } elseif (isset($this->currpagegroup) AND ($this->currpagegroup > 0)) {
10050 if ($objid ===
'') {
10056 return $objid.
' 0 obj';
10081 return sprintf(
'%F %F %F %F re f',
$x * $this->k, ((($this->h -
$y) * $this->k) + $linew),
$w * $this->k, $linew);
10106 return sprintf(
'%F %F %F %F re f',
$x * $this->k, ((($this->h -
$y) * $this->k) + $linew + ($this->FontSizePt / 3)),
$w * $this->k, $linew);
10132 return sprintf(
'%F %F %F %F re f',
$x * $this->k, (($this->h -
$y + $this->FontAscent) * $this->k) - $linew,
$w * $this->k, $linew);
10158 if (is_string($time)) {
10161 $this->doc_creation_timestamp = intval($time);
10171 if (is_string($time)) {
10174 $this->doc_modification_timestamp = intval($time);
10206 if ((empty($timestamp)) OR ($timestamp < 0)) {
10220 if ($this->isunicode) {
10236 if ($this->isunicode) {
10237 if (($this->CurrentFont[
'type'] ==
'core') OR ($this->CurrentFont[
'type'] ==
'TrueType') OR ($this->CurrentFont[
'type'] ==
'Type1')) {
10291 if ($this->state == 2) {
10292 if ($this->inxobj) {
10295 } elseif ((!$this->InFooter) AND isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) {
10298 $page = substr($pagebuff, 0, -$this->footerlen[$this->page]);
10299 $footer = substr($pagebuff, -$this->footerlen[$this->page]);
10302 $this->footerpos[
$this->page] += strlen($s.
"\n");
10307 } elseif ($this->state > 0) {
10320 $this->header_font = $font;
10340 $this->footer_font = $font;
10360 $this->l = $language;
10361 if (isset($this->l[
'a_meta_dir'])) {
10362 $this->rtl = $this->l[
'a_meta_dir']==
'rtl' ?
true :
false;
10364 $this->rtl =
false;
10373 if ($this->state < 3) {
10391 public function addHtmlLink($url, $name, $fill=
false, $firstline=
false, $color=
'', $style=-1, $firstblock=
false) {
10392 if (isset($url[1]) AND ($url[0] ==
'#') AND is_numeric($url[1])) {
10394 $lnkdata = explode(
',', $url);
10395 if (isset($lnkdata[0])) {
10396 $page = intval(substr($lnkdata[0], 1));
10400 if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
10401 $lnky = floatval($lnkdata[1]);
10412 if (empty($color)) {
10417 if ($style == -1) {
10418 $this->
SetFont(
'', $this->FontStyle.$this->htmlLinkFontStyle);
10420 $this->
SetFont(
'', $this->FontStyle.$style);
10422 $ret = $this->
Write($this->lasth, $name, $url, $fill,
'',
false, 0, $firstline, $firstblock, 0);
10424 $this->
SetFont(
'', $prevstyle);
10437 return ($px / ($this->imgscale * $this->k));
10448 return @html_entity_decode($text_to_convert, ENT_QUOTES, $this->encoding);
10463 $objkey = $this->encryptdata[
'key'].pack(
'VXxx',
$n);
10464 if ($this->encryptdata[
'mode'] == 2) {
10466 $objkey .=
"\x73\x41\x6C\x54";
10469 $objkey = substr($objkey, 0, 16);
10483 if (!$this->encrypted) {
10486 switch ($this->encryptdata[
'mode']) {
10511 if (!$this->encrypted) {
10514 $this->encryptdata[
'objid'] = $this->
_newobj();
10516 if (!isset($this->encryptdata[
'Filter']) OR empty($this->encryptdata[
'Filter'])) {
10517 $this->encryptdata[
'Filter'] =
'Standard';
10519 $out .=
' /Filter /'.$this->encryptdata[
'Filter'];
10520 if (isset($this->encryptdata[
'SubFilter']) AND !empty($this->encryptdata[
'SubFilter'])) {
10521 $out .=
' /SubFilter /'.$this->encryptdata[
'SubFilter'];
10523 if (!isset($this->encryptdata[
'V']) OR empty($this->encryptdata[
'V'])) {
10524 $this->encryptdata[
'V'] = 1;
10527 $out .=
' /V '.$this->encryptdata[
'V'];
10528 if (isset($this->encryptdata[
'Length']) AND !empty($this->encryptdata[
'Length'])) {
10530 $out .=
' /Length '.$this->encryptdata[
'Length'];
10532 $out .=
' /Length 40';
10534 if ($this->encryptdata[
'V'] >= 4) {
10535 if (!isset($this->encryptdata[
'StmF']) OR empty($this->encryptdata[
'StmF'])) {
10536 $this->encryptdata[
'StmF'] =
'Identity';
10538 if (!isset($this->encryptdata[
'StrF']) OR empty($this->encryptdata[
'StrF'])) {
10540 $this->encryptdata[
'StrF'] =
'Identity';
10543 if (isset($this->encryptdata[
'CF']) AND !empty($this->encryptdata[
'CF'])) {
10545 $out .=
' /'.$this->encryptdata[
'StmF'].
' <<';
10546 $out .=
' /Type /CryptFilter';
10547 if (isset($this->encryptdata[
'CF'][
'CFM']) AND !empty($this->encryptdata[
'CF'][
'CFM'])) {
10549 $out .=
' /CFM /'.$this->encryptdata[
'CF'][
'CFM'];
10550 if ($this->encryptdata[
'pubkey']) {
10551 $out .=
' /Recipients [';
10552 foreach ($this->encryptdata[
'Recipients'] as $rec) {
10553 $out .=
' <'.$rec.
'>';
10556 if (isset($this->encryptdata[
'CF'][
'EncryptMetadata']) AND (!$this->encryptdata[
'CF'][
'EncryptMetadata'])) {
10557 $out .=
' /EncryptMetadata false';
10559 $out .=
' /EncryptMetadata true';
10563 $out .=
' /CFM /None';
10565 if (isset($this->encryptdata[
'CF'][
'AuthEvent']) AND !empty($this->encryptdata[
'CF'][
'AuthEvent'])) {
10567 $out .=
' /AuthEvent /'.$this->encryptdata[
'CF'][
'AuthEvent'];
10569 $out .=
' /AuthEvent /DocOpen';
10571 if (isset($this->encryptdata[
'CF'][
'Length']) AND !empty($this->encryptdata[
'CF'][
'Length'])) {
10573 $out .=
' /Length '.$this->encryptdata[
'CF'][
'Length'];
10578 $out .=
' /StmF /'.$this->encryptdata[
'StmF'];
10580 $out .=
' /StrF /'.$this->encryptdata[
'StrF'];
10581 if (isset($this->encryptdata[
'EFF']) AND !empty($this->encryptdata[
'EFF'])) {
10583 $out .=
' /EFF /'.$this->encryptdata[
''];
10587 if ($this->encryptdata[
'pubkey']) {
10588 if (($this->encryptdata[
'V'] < 4) AND isset($this->encryptdata[
'Recipients']) AND !empty($this->encryptdata[
'Recipients'])) {
10589 $out .=
' /Recipients [';
10590 foreach ($this->encryptdata[
'Recipients'] as $rec) {
10591 $out .=
' <'.$rec.
'>';
10597 if ($this->encryptdata[
'V'] == 5) {
10599 $out .=
' /OE ('.TCPDF_STATIC::_escape($this->encryptdata[
'OE']).
')';
10600 $out .=
' /UE ('.TCPDF_STATIC::_escape($this->encryptdata[
'UE']).
')';
10601 $out .=
' /Perms ('.TCPDF_STATIC::_escape($this->encryptdata[
'perms']).
')';
10602 } elseif ($this->encryptdata[
'V'] == 4) {
10604 } elseif ($this->encryptdata[
'V'] < 2) {
10609 $out .=
' /O ('.TCPDF_STATIC::_escape($this->encryptdata[
'O']).
')';
10610 $out .=
' /U ('.TCPDF_STATIC::_escape($this->encryptdata[
'U']).
')';
10611 $out .=
' /P '.$this->encryptdata[
'P'];
10612 if (isset($this->encryptdata[
'EncryptMetadata']) AND (!$this->encryptdata[
'EncryptMetadata'])) {
10613 $out .=
' /EncryptMetadata false';
10615 $out .=
' /EncryptMetadata true';
10619 $out .=
"\n".
'endobj';
10631 if ($this->encryptdata[
'mode'] == 0) {
10633 } elseif ($this->encryptdata[
'mode'] < 3) {
10635 $enc =
TCPDF_STATIC::_RC4($this->encryptdata[
'key'], $tmp, $this->last_enc_key, $this->last_enc_key_c);
10636 $len = strlen($tmp);
10637 for ($i = 1; $i <= 19; ++$i) {
10639 for ($j = 0; $j < $len; ++$j) {
10640 $ek .= chr(ord($this->encryptdata[
'key'][$j]) ^ $i);
10644 $enc .= str_repeat(
"\x00", 16);
10645 return substr($enc, 0, 32);
10646 } elseif ($this->encryptdata[
'mode'] == 3) {
10649 $this->encryptdata[
'UVS'] = substr($seed, 0, 8);
10651 $this->encryptdata[
'UKS'] = substr($seed, 8, 16);
10652 return hash(
'sha256', $this->encryptdata[
'user_password'].$this->encryptdata[
'UVS'],
true).$this->encryptdata[
'UVS'].$this->encryptdata[
'UKS'];
10664 $hashkey = hash(
'sha256', $this->encryptdata[
'user_password'].$this->encryptdata[
'UKS'],
true);
10665 $iv = str_repeat(
"\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
10666 return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $hashkey, $this->encryptdata[
'key'], MCRYPT_MODE_CBC, $iv);
10677 if ($this->encryptdata[
'mode'] < 3) {
10679 if ($this->encryptdata[
'mode'] > 0) {
10680 for ($i = 0; $i < 50; ++$i) {
10684 $owner_key = substr($tmp, 0, ($this->encryptdata[
'Length'] / 8));
10685 $enc =
TCPDF_STATIC::_RC4($owner_key, $this->encryptdata[
'user_password'], $this->last_enc_key, $this->last_enc_key_c);
10686 if ($this->encryptdata[
'mode'] > 0) {
10687 $len = strlen($owner_key);
10688 for ($i = 1; $i <= 19; ++$i) {
10690 for ($j = 0; $j < $len; ++$j) {
10691 $ek .= chr(ord($owner_key[$j]) ^ $i);
10697 } elseif ($this->encryptdata[
'mode'] == 3) {
10700 $this->encryptdata[
'OVS'] = substr($seed, 0, 8);
10702 $this->encryptdata[
'OKS'] = substr($seed, 8, 16);
10703 return hash(
'sha256', $this->encryptdata[
'owner_password'].$this->encryptdata[
'OVS'].$this->encryptdata[
'U'],
true).$this->encryptdata[
'OVS'].$this->encryptdata[
'OKS'];
10715 $hashkey = hash(
'sha256', $this->encryptdata[
'owner_password'].$this->encryptdata[
'OKS'].$this->encryptdata[
'U'],
true);
10716 $iv = str_repeat(
"\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
10717 return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $hashkey, $this->encryptdata[
'key'], MCRYPT_MODE_CBC, $iv);
10731 foreach ($psw_array as $c) {
10734 return substr($psw, 0, 127);
10744 $keybytelen = ($this->encryptdata[
'Length'] / 8);
10745 if (!$this->encryptdata[
'pubkey']) {
10746 if ($this->encryptdata[
'mode'] == 3) {
10750 $this->encryptdata[
'user_password'] = $this->
_fixAES256Password($this->encryptdata[
'user_password']);
10751 $this->encryptdata[
'owner_password'] = $this->
_fixAES256Password($this->encryptdata[
'owner_password']);
10753 $this->encryptdata[
'U'] = $this->
_Uvalue();
10755 $this->encryptdata[
'UE'] = $this->
_UEvalue();
10757 $this->encryptdata[
'O'] = $this->
_Ovalue();
10759 $this->encryptdata[
'OE'] = $this->
_OEvalue();
10761 $this->encryptdata[
'P'] = $this->encryptdata[
'protection'];
10764 $perms .= chr(255).chr(255).chr(255).chr(255);
10765 if (isset($this->encryptdata[
'CF'][
'EncryptMetadata']) AND (!$this->encryptdata[
'CF'][
'EncryptMetadata'])) {
10772 $iv = str_repeat(
"\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB));
10773 $this->encryptdata[
'perms'] = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->encryptdata[
'key'], $perms, MCRYPT_MODE_ECB, $iv);
10777 $this->encryptdata[
'owner_password'] = substr($this->encryptdata[
'owner_password'].TCPDF_STATIC::$enc_padding, 0, 32);
10779 $this->encryptdata[
'O'] = $this->
_Ovalue();
10783 $tmp =
TCPDF_STATIC::_md5_16($this->encryptdata[
'user_password'].$this->encryptdata[
'O'].$permissions.$this->encryptdata[
'fileid']);
10784 if ($this->encryptdata[
'mode'] > 0) {
10785 for ($i = 0; $i < 50; ++$i) {
10789 $this->encryptdata[
'key'] = substr($tmp, 0, $keybytelen);
10791 $this->encryptdata[
'U'] = $this->
_Uvalue();
10793 $this->encryptdata[
'P'] = $this->encryptdata[
'protection'];
10798 $recipient_bytes =
'';
10799 foreach ($this->encryptdata[
'pubkeys'] as $pubkey) {
10801 if (isset($pubkey[
'p'])) {
10804 $pkprotection = $this->encryptdata[
'protection'];
10809 $envelope = $seed.$pkpermissions;
10812 $f = fopen($tempkeyfile,
'wb');
10814 $this->
Error(
'Unable to create temporary key file: '.$tempkeyfile);
10816 $envelope_length = strlen($envelope);
10817 fwrite($f, $envelope, $envelope_length);
10820 if (!openssl_pkcs7_encrypt($tempkeyfile, $tempencfile, $pubkey[
'c'], array(), PKCS7_BINARY | PKCS7_DETACHED)) {
10821 $this->
Error(
'Unable to encrypt the file: '.$tempkeyfile);
10823 unlink($tempkeyfile);
10825 $signature = file_get_contents($tempencfile,
false, null, $envelope_length);
10826 unlink($tempencfile);
10828 $signature = substr($signature, strpos($signature,
'Content-Disposition'));
10829 $tmparr = explode(
"\n\n", $signature);
10830 $signature = trim($tmparr[1]);
10833 $signature = base64_decode($signature);
10835 $hexsignature = current(unpack(
'H*', $signature));
10837 $this->encryptdata[
'Recipients'][] = $hexsignature;
10839 $recipient_bytes .= $signature;
10842 if ($this->encryptdata[
'mode'] == 3) {
10843 $this->encryptdata[
'key'] = substr(hash(
'sha256', $seed.$recipient_bytes,
true), 0, $keybytelen);
10845 $this->encryptdata[
'key'] = substr(sha1($seed.$recipient_bytes,
true), 0, $keybytelen);
10864 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) {
10865 if ($this->pdfa_mode) {
10870 if (($pubkeys !== null) AND (is_array($pubkeys))) {
10872 $this->encryptdata[
'pubkeys'] = $pubkeys;
10877 if (!function_exists(
'openssl_pkcs7_encrypt')) {
10878 $this->
Error(
'Public-Key Security requires openssl library.');
10881 $this->encryptdata[
'pubkey'] =
true;
10882 $this->encryptdata[
'Filter'] =
'Adobe.PubSec';
10883 $this->encryptdata[
'StmF'] =
'DefaultCryptFilter';
10884 $this->encryptdata[
'StrF'] =
'DefaultCryptFilter';
10887 $this->encryptdata[
'pubkey'] =
false;
10888 $this->encryptdata[
'Filter'] =
'Standard';
10889 $this->encryptdata[
'StmF'] =
'StdCF';
10890 $this->encryptdata[
'StrF'] =
'StdCF';
10893 if (!extension_loaded(
'mcrypt')) {
10894 $this->
Error(
'AES encryption requires mcrypt library (http://www.php.net/manual/en/mcrypt.requirements.php).');
10896 if (mcrypt_get_cipher_name(MCRYPT_RIJNDAEL_128) ===
false) {
10897 $this->
Error(
'AES encryption requires MCRYPT_RIJNDAEL_128 cypher.');
10899 if (($mode == 3) AND !function_exists(
'hash')) {
10901 $this->
Error(
'AES 256 encryption requires HASH Message Digest Framework (http://www.php.net/manual/en/book.hash.php).');
10904 if ($owner_pass === null) {
10907 $this->encryptdata[
'user_password'] = $user_pass;
10908 $this->encryptdata[
'owner_password'] = $owner_pass;
10909 $this->encryptdata[
'mode'] = $mode;
10912 $this->encryptdata[
'V'] = 1;
10913 $this->encryptdata[
'Length'] = 40;
10914 $this->encryptdata[
'CF'][
'CFM'] =
'V2';
10918 $this->encryptdata[
'V'] = 2;
10919 $this->encryptdata[
'Length'] = 128;
10920 $this->encryptdata[
'CF'][
'CFM'] =
'V2';
10921 if ($this->encryptdata[
'pubkey']) {
10922 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s4';
10923 $this->encryptdata[
'Recipients'] = array();
10928 $this->encryptdata[
'V'] = 4;
10929 $this->encryptdata[
'Length'] = 128;
10930 $this->encryptdata[
'CF'][
'CFM'] =
'AESV2';
10931 $this->encryptdata[
'CF'][
'Length'] = 128;
10932 if ($this->encryptdata[
'pubkey']) {
10933 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s5';
10934 $this->encryptdata[
'Recipients'] = array();
10939 $this->encryptdata[
'V'] = 5;
10940 $this->encryptdata[
'Length'] = 256;
10941 $this->encryptdata[
'CF'][
'CFM'] =
'AESV3';
10942 $this->encryptdata[
'CF'][
'Length'] = 256;
10943 if ($this->encryptdata[
'pubkey']) {
10944 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s5';
10945 $this->encryptdata[
'Recipients'] = array();
10950 $this->encrypted =
true;
10968 if ($this->state != 2) {
10972 if ($this->inxobj) {
10974 $this->xobjects[
$this->xobjid][
'transfmrk'][] = strlen($this->xobjects[$this->xobjid][
'outdata']);
10991 if ($this->state != 2) {
10995 if (isset($this->transfmatrix[$this->transfmatrix_key])) {
10996 array_pop($this->transfmatrix[$this->transfmatrix_key]);
10999 if ($this->inxobj) {
11001 array_pop($this->xobjects[$this->xobjid][
'transfmrk']);
11003 array_pop($this->transfmrk[$this->page]);
11062 if (($s_x == 0) OR ($s_y == 0)) {
11063 $this->
Error(
'Please do not use values equal to zero for scaling');
11065 $y = ($this->h -
$y) * $this->k;
11075 $tm[4] =
$x * (1 - $s_x);
11076 $tm[5] =
$y * (1 - $s_y);
11100 $this->
Scale(100, -100,
'',
$y);
11188 $y = ($this->h -
$y) * $this->k;
11192 $tm[0] = cos(deg2rad($angle));
11193 $tm[1] = sin(deg2rad($angle));
11196 $tm[4] =
$x + ($tm[1] *
$y) - ($tm[0] *
$x);
11197 $tm[5] =
$y - ($tm[0] *
$y) - ($tm[1] * $x);
11245 if (($angle_x <= -90) OR ($angle_x >= 90) OR ($angle_y <= -90) OR ($angle_y >= 90)) {
11246 $this->
Error(
'Please use values between -90 and +90 degrees for Skewing.');
11249 $y = ($this->h -
$y) * $this->k;
11253 $tm[1] = tan(deg2rad($angle_y));
11254 $tm[2] = tan(deg2rad($angle_x));
11256 $tm[4] = -$tm[2] *
$y;
11257 $tm[5] = -$tm[1] *
$x;
11270 if ($this->state != 2) {
11273 $this->
_out(sprintf(
'%F %F %F %F %F %F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
11275 $this->transfmatrix[
$this->transfmatrix_key][] = array(
'a' => $tm[0],
'b' => $tm[1],
'c' => $tm[2],
'd' => $tm[3],
'e' => $tm[4],
'f' => $tm[5]);
11277 if ($this->inxobj) {
11279 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
11280 $key = key($this->xobjects[$this->xobjid][
'transfmrk']);
11281 $this->xobjects[
$this->xobjid][
'transfmrk'][$key] = strlen($this->xobjects[$this->xobjid][
'outdata']);
11283 } elseif (end($this->transfmrk[$this->page]) !==
false) {
11284 $key = key($this->transfmrk[$this->page]);
11303 $this->LineWidth = $width;
11304 $this->linestyleWidth = sprintf(
'%F w', ($width * $this->k));
11305 if ($this->state == 2) {
11306 $this->
_out($this->linestyleWidth);
11346 if (!is_array($style)) {
11349 if (isset($style[
'width'])) {
11350 $this->LineWidth = $style[
'width'];
11351 $this->linestyleWidth = sprintf(
'%F w', ($style[
'width'] * $this->k));
11352 $s .= $this->linestyleWidth.
' ';
11354 if (isset($style[
'cap'])) {
11355 $ca = array(
'butt' => 0,
'round'=> 1,
'square' => 2);
11356 if (isset($ca[$style[
'cap']])) {
11357 $this->linestyleCap = $ca[$style[
'cap']].
' J';
11358 $s .= $this->linestyleCap.
' ';
11361 if (isset($style[
'join'])) {
11362 $ja = array(
'miter' => 0,
'round' => 1,
'bevel' => 2);
11363 if (isset($ja[$style[
'join']])) {
11364 $this->linestyleJoin = $ja[$style[
'join']].
' j';
11365 $s .= $this->linestyleJoin.
' ';
11368 if (isset($style[
'dash'])) {
11370 if ($style[
'dash']) {
11371 if (preg_match(
'/^.+,/', $style[
'dash']) > 0) {
11372 $tab = explode(
',', $style[
'dash']);
11374 $tab = array($style[
'dash']);
11377 foreach ($tab as $i => $v) {
11379 $dash_string .=
' ';
11381 $dash_string .= sprintf(
'%F', $v);
11384 if (!isset($style[
'phase']) OR !$style[
'dash']) {
11385 $style[
'phase'] = 0;
11387 $this->linestyleDash = sprintf(
'[%s] %F d', $dash_string, $style[
'phase']);
11388 $s .= $this->linestyleDash.
' ';
11390 if (isset($style[
'color'])) {
11393 if (!$ret AND ($this->state == 2)) {
11407 if ($this->state == 2) {
11408 $this->
_out(sprintf(
'%F %F m', (
$x * $this->k), (($this->h -
$y) * $this->k)));
11421 if ($this->state == 2) {
11422 $this->
_out(sprintf(
'%F %F l', (
$x * $this->k), (($this->h -
$y) * $this->k)));
11437 if ($this->state == 2) {
11438 $this->
_out(sprintf(
'%F %F %F %F re %s', (
$x * $this->k), (($this->h -
$y) * $this->k), (
$w * $this->k), (-
$h * $this->k), $op));
11455 if ($this->state == 2) {
11456 $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)));
11471 if ($this->state == 2) {
11472 $this->
_out(sprintf(
'%F %F %F %F v', ($x2 * $this->k), (($this->h - $y2) * $this->k), ($x3 * $this->k), (($this->h - $y3) * $this->k)));
11487 if ($this->state == 2) {
11488 $this->
_out(sprintf(
'%F %F %F %F y', ($x1 * $this->k), (($this->h - $y1) * $this->k), ($x3 * $this->k), (($this->h - $y3) * $this->k)));
11503 public function Line($x1, $y1, $x2, $y2, $style=array()) {
11504 if ($this->state != 2) {
11507 if (is_array($style)) {
11533 public function Rect(
$x,
$y,
$w,
$h, $style=
'', $border_style=array(), $fill_color=array()) {
11534 if ($this->state != 2) {
11537 if (empty($style)) {
11540 if (!(strpos($style,
'F') ===
false) AND !empty($fill_color)) {
11544 if (!empty($border_style)) {
11545 if (isset($border_style[
'all']) AND !empty($border_style[
'all'])) {
11548 $border_style = array();
11551 $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*' );
11552 if (isset($opnostroke[$style])) {
11553 $style = $opnostroke[$style];
11557 if (!empty($style)) {
11561 if (!empty($border_style)) {
11562 $border_style2 = array();
11563 foreach ($border_style as $line => $value) {
11564 $length = strlen($line);
11565 for ($i = 0; $i < $length; ++$i) {
11566 $border_style2[$line[$i]] = $value;
11569 $border_style = $border_style2;
11570 if (isset($border_style[
'L']) AND $border_style[
'L']) {
11573 if (isset($border_style[
'T']) AND $border_style[
'T']) {
11576 if (isset($border_style[
'R']) AND $border_style[
'R']) {
11579 if (isset($border_style[
'B']) AND $border_style[
'B']) {
11604 public function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style=
'', $line_style=array(), $fill_color=array()) {
11605 if ($this->state != 2) {
11608 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
11616 $this->
_outCurve($x1, $y1, $x2, $y2, $x3, $y3);
11634 public function Polycurve($x0, $y0, $segments, $style=
'', $line_style=array(), $fill_color=array()) {
11635 if ($this->state != 2) {
11638 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
11643 $line_style = array();
11649 foreach ($segments as $segment) {
11650 list($x1, $y1, $x2, $y2, $x3, $y3) = $segment;
11651 $this->
_outCurve($x1, $y1, $x2, $y2, $x3, $y3);
11674 public function Ellipse($x0, $y0, $rx, $ry=
'', $angle=0, $astart=0, $afinish=360, $style=
'', $line_style=array(), $fill_color=array(), $nc=2) {
11675 if ($this->state != 2) {
11681 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
11686 $line_style = array();
11691 $this->
_outellipticalarc($x0, $y0, $rx, $ry, $angle, $astart, $afinish,
false, $nc,
true,
true,
false);
11715 protected function _outellipticalarc($xc, $yc, $rx, $ry, $xang=0, $angs=0, $angf=360, $pie=
false, $nc=2, $startpoint=
true, $ccw=
true, $svg=
false) {
11716 if (($rx <= 0) OR ($ry < 0)) {
11723 $xmin = 2147483647;
11724 $ymin = 2147483647;
11731 $xang = deg2rad((
float) $xang);
11732 $angs = deg2rad((
float) $angs);
11733 $angf = deg2rad((
float) $angf);
11738 $as = atan2((sin($angs) / $ry), (cos($angs) / $rx));
11739 $af = atan2((sin($angf) / $ry), (cos($angf) / $rx));
11747 if ($ccw AND ($as > $af)) {
11750 } elseif (!$ccw AND ($as < $af)) {
11754 $total_angle = ($af - $as);
11759 $nc *= (2 * abs($total_angle) / M_PI);
11760 $nc = round($nc) + 1;
11762 $arcang = ($total_angle / $nc);
11765 $y0 = ($this->h - $yc);
11768 $alpha = sin($arcang) * ((sqrt(4 + (3 * pow(tan(($arcang) / 2), 2))) - 1) / 3);
11769 $cos_xang = cos($xang);
11770 $sin_xang = sin($xang);
11771 $cos_ang = cos($ang);
11772 $sin_ang = sin($ang);
11774 $px1 = $x0 + ($rx * $cos_xang * $cos_ang) - ($ry * $sin_xang * $sin_ang);
11775 $py1 = $y0 + ($rx * $sin_xang * $cos_ang) + ($ry * $cos_xang * $sin_ang);
11777 $qx1 = (
$alpha * ((-$rx * $cos_xang * $sin_ang) - ($ry * $sin_xang * $cos_ang)));
11778 $qy1 = (
$alpha * ((-$rx * $sin_xang * $sin_ang) + ($ry * $cos_xang * $cos_ang)));
11781 $this->
_outLine($px1, $this->h - $py1);
11782 } elseif ($startpoint) {
11784 $this->
_outPoint($px1, $this->h - $py1);
11787 for ($i = 1; $i <= $nc; ++$i) {
11789 $ang = $as + ($i * $arcang);
11793 $cos_ang = cos($ang);
11794 $sin_ang = sin($ang);
11796 $px2 = $x0 + ($rx * $cos_xang * $cos_ang) - ($ry * $sin_xang * $sin_ang);
11797 $py2 = $y0 + ($rx * $sin_xang * $cos_ang) + ($ry * $cos_xang * $sin_ang);
11799 $qx2 = (
$alpha * ((-$rx * $cos_xang * $sin_ang) - ($ry * $sin_xang * $cos_ang)));
11800 $qy2 = (
$alpha * ((-$rx * $sin_xang * $sin_ang) + ($ry * $cos_xang * $cos_ang)));
11802 $cx1 = ($px1 + $qx1);
11803 $cy1 = ($this->h - ($py1 + $qy1));
11804 $cx2 = ($px2 - $qx2);
11805 $cy2 = ($this->h - ($py2 - $qy2));
11807 $cy3 = ($this->h - $py2);
11808 $this->
_outCurve($cx1, $cy1, $cx2, $cy2, $cx3, $cy3);
11810 $xmin = min($xmin, $cx1, $cx2, $cx3);
11811 $ymin = min($ymin, $cy1, $cy2, $cy3);
11812 $xmax = max($xmax, $cx1, $cx2, $cx3);
11813 $ymax = max($ymax, $cy1, $cy2, $cy3);
11823 $xmin = min($xmin, $xc);
11824 $ymin = min($ymin, $yc);
11825 $xmax = max($xmax, $xc);
11826 $ymax = max($ymax, $yc);
11828 return array($xmin, $ymin, $xmax, $ymax);
11846 public function Circle($x0, $y0, $r, $angstr=0, $angend=360, $style=
'', $line_style=array(), $fill_color=array(), $nc=2) {
11847 $this->
Ellipse($x0, $y0, $r, $r, 0, $angstr, $angend, $style, $line_style, $fill_color, $nc);
11864 public function PolyLine($p, $style=
'', $line_style=array(), $fill_color=array()) {
11865 $this->
Polygon($p, $style, $line_style, $fill_color,
false);
11883 public function Polygon($p, $style=
'', $line_style=array(), $fill_color=array(), $closed=
true) {
11884 if ($this->state != 2) {
11891 for ($i = 0; $i < 4; ++$i) {
11892 $p[$nc + $i] = $p[$i];
11895 if (isset($line_style[0])) {
11896 $line_style[$np] = $line_style[0];
11900 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
11905 $line_style = array();
11909 if (isset($line_style[
'all'])) {
11917 for ($i = 2; $i < $nc; $i = $i + 2) {
11918 $this->
_outLine($p[$i], $p[$i + 1]);
11924 for ($i = 2; $i < $nc; $i = $i + 2) {
11925 $line_num = ($i / 2) - 1;
11926 if (isset($line_style[$line_num])) {
11927 if ($line_style[$line_num] != 0) {
11928 if (is_array($line_style[$line_num])) {
11931 $this->
_outPoint($p[$i - 2], $p[$i - 1]);
11932 $this->
_outLine($p[$i], $p[$i + 1]);
11936 $this->
_outLine($p[$i], $p[$i + 1]);
11940 $this->
_outLine($p[$i], $p[$i + 1]);
11948 for ($i = 2; $i < $nc; $i = $i + 2) {
11949 $this->
_outLine($p[$i], $p[$i + 1]);
11984 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()) {
11988 if ($draw_circle) {
11989 $this->
Circle($x0, $y0, $r, 0, 360, $circle_style, $circle_outLine_style, $circle_fill_color);
11992 for ($i = 0; $i < $ns; ++$i) {
11993 $a = $angle + ($i * 360 / $ns);
11994 $a_rad = deg2rad((
float) $a);
11995 $p[] = $x0 + ($r * sin($a_rad));
11996 $p[] = $y0 + ($r * cos($a_rad));
11998 $this->
Polygon($p, $style, $line_style, $fill_color);
12032 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()) {
12036 if ($draw_circle) {
12037 $this->
Circle($x0, $y0, $r, 0, 360, $circle_style, $circle_outLine_style, $circle_fill_color);
12040 $visited = array();
12041 for ($i = 0; $i < $nv; ++$i) {
12042 $a = $angle + ($i * 360 / $nv);
12043 $a_rad = deg2rad((
float) $a);
12044 $p2[] = $x0 + ($r * sin($a_rad));
12045 $p2[] = $y0 + ($r * cos($a_rad));
12046 $visited[] =
false;
12051 $p[] = $p2[$i * 2];
12052 $p[] = $p2[($i * 2) + 1];
12053 $visited[$i] =
true;
12056 }
while (!$visited[$i]);
12057 $this->
Polygon($p, $style, $line_style, $fill_color);
12074 public function RoundedRect(
$x,
$y,
$w,
$h, $r, $round_corner=
'1111', $style=
'', $border_style=array(), $fill_color=array()) {
12093 public function RoundedRectXY(
$x,
$y,
$w,
$h, $rx, $ry, $round_corner=
'1111', $style=
'', $border_style=array(), $fill_color=array()) {
12094 if ($this->state != 2) {
12097 if (($round_corner ==
'0000') OR (($rx == $ry) AND ($rx == 0))) {
12099 $this->
Rect(
$x,
$y,
$w,
$h, $style, $border_style, $fill_color);
12103 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
12108 $border_style = array();
12110 if ($border_style) {
12113 $MyArc = 4 / 3 * (sqrt(2) - 1);
12115 $xc =
$x +
$w - $rx;
12118 if ($round_corner[0]) {
12119 $this->
_outCurve($xc + ($rx * $MyArc), $yc - $ry, $xc + $rx, $yc - ($ry * $MyArc), $xc + $rx, $yc);
12123 $xc =
$x +
$w - $rx;
12124 $yc =
$y +
$h - $ry;
12126 if ($round_corner[1]) {
12127 $this->
_outCurve($xc + $rx, $yc + ($ry * $MyArc), $xc + ($rx * $MyArc), $yc + $ry, $xc, $yc + $ry);
12132 $yc =
$y +
$h - $ry;
12134 if ($round_corner[2]) {
12135 $this->
_outCurve($xc - ($rx * $MyArc), $yc + $ry, $xc - $rx, $yc + ($ry * $MyArc), $xc - $rx, $yc);
12142 if ($round_corner[3]) {
12143 $this->
_outCurve($xc - $rx, $yc - ($ry * $MyArc), $xc - ($rx * $MyArc), $yc - $ry, $xc, $yc - $ry);
12163 public function Arrow($x0, $y0, $x1, $y1, $head_style=0, $arm_size=5, $arm_angle=15) {
12166 $dir_angle = atan2(($y0 - $y1), ($x0 - $x1));
12167 if ($dir_angle < 0) {
12168 $dir_angle += (2 * M_PI);
12170 $arm_angle = deg2rad($arm_angle);
12173 if ($head_style > 0) {
12179 $this->
Line($x0, $y0, $sx1, $sy1);
12181 $x2L = $x1 + ($arm_size * cos($dir_angle + $arm_angle));
12182 $y2L = $y1 + ($arm_size * sin($dir_angle + $arm_angle));
12184 $x2R = $x1 + ($arm_size * cos($dir_angle - $arm_angle));
12185 $y2R = $y1 + ($arm_size * sin($dir_angle - $arm_angle));
12188 switch ($head_style) {
12192 $style = array(1, 1, 0);
12211 $this->
Polygon(array($x2L, $y2L, $x1, $y1, $x2R, $y2R), $mode, $style, array());
12236 } elseif (
$y < 0) {
12238 } elseif (
$y > $this->h) {
12243 } elseif (
$x < 0) {
12245 } elseif (
$x > $this->w) {
12248 if (empty(
$page)) {
12250 if (empty(
$page)) {
12254 $this->dests[$name] = array(
'x' =>
$x,
'y' =>
$y,
'p' =>
$page);
12276 if (empty($this->dests)) {
12279 $this->n_dests = $this->
_newobj();
12281 foreach($this->dests as $name => $o) {
12282 $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)));
12285 $out .=
"\n".
'endobj';
12318 public function Bookmark($txt, $level=0,
$y=-1,
$page=
'', $style=
'', $color=array(0,0,0),
$x=-1, $link=
'') {
12322 if (isset($this->outlines[0])) {
12323 $lastoutline = end($this->outlines);
12324 $maxlevel = $lastoutline[
'l'] + 1;
12328 if ($level > $maxlevel) {
12329 $level = $maxlevel;
12333 } elseif (
$y < 0) {
12335 } elseif (
$y > $this->h) {
12340 } elseif (
$x < 0) {
12342 } elseif (
$x > $this->w) {
12345 if (empty(
$page)) {
12347 if (empty(
$page)) {
12351 $this->outlines[] = array(
't' => $txt,
'l' => $level,
'x' =>
$x,
'y' =>
$y,
'p' =>
$page,
's' => strtoupper($style),
'c' => $color,
'u' => $link);
12361 $outline_p = array();
12362 $outline_y = array();
12363 foreach ($this->outlines as $key => $row) {
12364 $outline_p[$key] = $row[
'p'];
12365 $outline_k[$key] = $key;
12368 array_multisort($outline_p, SORT_NUMERIC, SORT_ASC, $outline_k, SORT_NUMERIC, SORT_ASC, $this->outlines);
12378 $nb = count($this->outlines);
12386 foreach ($this->outlines as $i => $o) {
12388 $parent = $lru[($o[
'l'] - 1)];
12390 $this->outlines[$i][
'parent'] = $parent;
12391 $this->outlines[$parent][
'last'] = $i;
12392 if ($o[
'l'] > $level) {
12394 $this->outlines[$parent][
'first'] = $i;
12397 $this->outlines[$i][
'parent'] = $nb;
12399 if (($o[
'l'] <= $level) AND ($i > 0)) {
12401 $prev = $lru[$o[
'l']];
12402 $this->outlines[$prev][
'next'] = $i;
12403 $this->outlines[$i][
'prev'] = $prev;
12405 $lru[$o[
'l']] = $i;
12410 $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';
12411 foreach ($this->outlines as $i => $o) {
12414 $title = preg_replace($nltags,
"\n", $o[
't']);
12419 $out =
'<</Title '.$this->_textstring(
$title, $oid);
12420 $out .=
' /Parent '.($n + $o[
'parent']).
' 0 R';
12421 if (isset($o[
'prev'])) {
12422 $out .=
' /Prev '.($n + $o[
'prev']).
' 0 R';
12424 if (isset($o[
'next'])) {
12425 $out .=
' /Next '.($n + $o[
'next']).
' 0 R';
12427 if (isset($o[
'first'])) {
12428 $out .=
' /First '.($n + $o[
'first']).
' 0 R';
12430 if (isset($o[
'last'])) {
12431 $out .=
' /Last '.($n + $o[
'last']).
' 0 R';
12433 if (isset($o[
'u']) AND !empty($o[
'u'])) {
12435 if (is_string($o[
'u'])) {
12436 if ($o[
'u'][0] ==
'#') {
12438 $out .=
' /Dest /'.TCPDF_STATIC::encodeNameObject(substr($o[
'u'], 1));
12439 } elseif ($o[
'u'][0] ==
'%') {
12441 $filename = basename(substr($o[
'u'], 1));
12442 $out .=
' /A <</S /GoToE /D [0 /Fit] /NewWindow true /T << /R /C /P '.($o[
'p'] - 1).
' /A '.$this->embeddedfiles[$filename][
'a'].
' >> >>';
12443 } elseif ($o[
'u'][0] ==
'*') {
12445 $filename = basename(substr($o[
'u'], 1));
12446 $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});';
12447 $out .=
' /A <</S /JavaScript /JS '.$this->_textstring($jsa, $oid).
'>>';
12450 $out .=
' /A <</S /URI /URI '.$this->_datastring($this->
unhtmlentities($o[
'u']), $oid).
'>>';
12452 } elseif (isset($this->links[$o[
'u']])) {
12454 $l = $this->links[$o[
'u']];
12455 if (isset($this->page_obj_id[(
$l[0])])) {
12456 $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)));
12459 } elseif (isset($this->page_obj_id[($o[
'p'])])) {
12461 $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)));
12465 if (!empty($o[
's'])) {
12467 if (strpos($o[
's'],
'B') !==
false) {
12471 if (strpos($o[
's'],
'I') !==
false) {
12475 $out .= sprintf(
' /F %d', $style);
12477 if (isset($o[
'c']) AND is_array($o[
'c']) AND (count($o[
'c']) == 3)) {
12478 $color = array_values($o[
'c']);
12479 $out .= sprintf(
' /C [%F %F %F]', ($color[0] / 255), ($color[1] / 255), ($color[2] / 255));
12482 $out .=
' /C [0.0 0.0 0.0]';
12484 $out .=
' /Count 0';
12486 $out .=
"\n".
'endobj';
12490 $this->OutlineRoot = $this->
_newobj();
12491 $this->
_out(
'<< /Type /Outlines /First '.
$n.
' 0 R /Last '.(
$n + $lru[0]).
' 0 R >>'.
"\n".
'endobj');
12504 $this->javascript .= $script;
12517 if ($this->pdfa_mode) {
12522 $this->js_objects[
$this->n] = array(
'n' => $this->n,
'js' => $script,
'onload' => $onload);
12533 if ($this->pdfa_mode OR (empty($this->javascript) AND empty($this->js_objects))) {
12536 if (strpos($this->javascript,
'this.addField') > 0) {
12537 if (!$this->ur[
'enabled']) {
12542 $jsa = sprintf(
"ftcpdfdocsaved=this.addField('%s','%s',%d,[%F,%F,%F,%F]);",
'tcpdfdocsaved',
'text', 0, 0, 1, 0, 1);
12543 $jsb =
"getField('tcpdfdocsaved').value='saved';";
12544 $this->javascript = $jsa.
"\n".$this->javascript.
"\n".$jsb;
12547 $this->n_js =
'<< /Names [';
12548 if (!empty($this->javascript)) {
12549 $this->n_js .=
' (EmbeddedJS) '.($this->n + 1).
' 0 R';
12551 if (!empty($this->js_objects)) {
12552 foreach ($this->js_objects as $key => $val) {
12553 if ($val[
'onload']) {
12554 $this->n_js .=
' (JS'.$key.
') '.$key.
' 0 R';
12558 $this->n_js .=
' ] >>';
12560 if (!empty($this->javascript)) {
12562 $out =
'<< /S /JavaScript';
12563 $out .=
' /JS '.$this->_textstring($this->javascript, $obj_id);
12565 $out .=
"\n".
'endobj';
12569 if (!empty($this->js_objects)) {
12570 foreach ($this->js_objects as $key => $val) {
12571 $out = $this->
_getobj($key).
"\n".
' << /S /JavaScript /JS '.$this->_textstring($val[
'js'], $key).
' >>'.
"\n".
'endobj';
12595 $this->javascript .=
"if (getField('tcpdfdocsaved').value != 'saved') {";
12597 $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";
12598 $this->javascript .=
'f'.$name.
'.textSize='.$this->FontSizePt.
";\n";
12599 while (list($key, $val) = each($prop)) {
12600 if (strcmp(substr($key, -5),
'Color') == 0) {
12603 $val =
"'".$val.
"'";
12605 $this->javascript .=
'f'.$name.
'.'.$key.
'='.$val.
";\n";
12612 $this->javascript .=
'}';
12627 $this->default_form_prop = $prop;
12673 $this->annotation_fonts[$this->CurrentFont[
'fontkey']] = $this->CurrentFont[
'i'];
12674 $fontstyle = sprintf(
'/F%d %F Tf %s', $this->CurrentFont[
'i'], $this->FontSizePt, $this->TextColor);
12675 $popt[
'da'] = $fontstyle;
12677 $popt[
'ap'] = array();
12678 $popt[
'ap'][
'n'] =
'/Tx BMC q '.$fontstyle.
' ';
12680 if (isset($prop[
'value']) AND !empty($prop[
'value'])) {
12681 $text = $prop[
'value'];
12682 } elseif (isset($opt[
'v']) AND !empty($opt[
'v'])) {
12687 if (isset($popt[
'q'])) {
12688 switch ($popt[
'q']) {
12707 $this->
MultiCell(
$w,
$h, $text, 0, $align,
false, 0, 0, 0,
true, 0,
false,
true, 0,
'T',
false);
12710 $popt[
'ap'][
'n'] .= $this->xobjects[$tmpid][
'outdata'];
12711 unset($this->xobjects[$tmpid]);
12712 $popt[
'ap'][
'n'] .=
'Q EMC';
12714 $opt = array_merge($popt, $opt);
12718 $opt[
'Subtype'] =
'Widget';
12733 unset($opt[
'mk'][
'ca']);
12734 unset($opt[
'mk'][
'rc']);
12735 unset($opt[
'mk'][
'ac']);
12736 unset($opt[
'mk'][
'i']);
12737 unset($opt[
'mk'][
'ri']);
12738 unset($opt[
'mk'][
'ix']);
12739 unset($opt[
'mk'][
'if']);
12744 unset($opt[
'mk'][
'tp']);
12776 public function RadioButton($name,
$w, $prop=array(), $opt=array(), $onvalue=
'On', $checked=
false,
$x=
'',
$y=
'', $js=
false) {
12793 $defval = $onvalue;
12798 $font =
'zapfdingbats';
12799 if ($this->pdfa_mode) {
12801 $font =
'pdfa'.$font;
12806 if (!isset($this->radiobutton_groups[$this->page])) {
12807 $this->radiobutton_groups[
$this->page] = array();
12809 if (!isset($this->radiobutton_groups[$this->page][$name])) {
12810 $this->radiobutton_groups[
$this->page][$name] = array();
12815 $kid = ($this->n + 1);
12817 $this->radiobutton_groups[
$this->page][$name][] = array(
'kid' => $kid,
'def' => $defval);
12820 $prop[
'NoToggleToOff'] =
'true';
12821 $prop[
'Radio'] =
'true';
12822 $prop[
'borderStyle'] =
'inset';
12826 $this->annotation_fonts[$tmpfont[
'fontkey']] = $tmpfont[
'i'];
12827 $fontstyle = sprintf(
'/F%d %F Tf %s', $tmpfont[
'i'], $this->FontSizePt, $this->TextColor);
12828 $popt[
'da'] = $fontstyle;
12830 $popt[
'ap'] = array();
12831 $popt[
'ap'][
'n'] = array();
12833 $fy = ((
$w - ((($tmpfont[
'desc'][
'Ascent'] - $tmpfont[
'desc'][
'Descent']) * $this->FontSizePt / 1000) /
$this->k)) *
$this->k);
12834 $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);
12835 $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);
12836 if (!isset($popt[
'mk'])) {
12837 $popt[
'mk'] = array();
12839 $popt[
'mk'][
'ca'] =
'(l)';
12841 $opt = array_merge($popt, $opt);
12843 $opt[
'Subtype'] =
'Widget';
12844 $opt[
'ft'] =
'Btn';
12846 $opt[
'v'] = array(
'/'.$onvalue);
12847 $opt[
'as'] = $onvalue;
12849 $opt[
'as'] =
'Off';
12852 if (!isset($this->radiobutton_groups[$this->page][$name][
'#readonly#'])) {
12853 $this->radiobutton_groups[
$this->page][$name][
'#readonly#'] =
false;
12855 $this->radiobutton_groups[
$this->page][$name][
'#readonly#'] |= ($opt[
'f'] & 64);
12879 public function ListBox($name,
$w,
$h, $values, $prop=array(), $opt=array(),
$x=
'',
$y=
'', $js=
false) {
12891 foreach ($values as $value) {
12892 if (is_array($value)) {
12893 $s .=
',[\''.addslashes($value[1]).
'\',\
''.addslashes($value[0]).
'\']
';
12895 $s .= ',[\
''.addslashes($value).
'\',\
''.addslashes($value).
'\']
';
12898 $this->javascript .= 'f
'.$name.'.setItems(
'.substr($s, 1).');
'."\n";
12901 // get default style
12902 $prop = array_merge($this->getFormDefaultProp(), $prop);
12903 // get annotation data
12904 $popt = TCPDF_STATIC::getAnnotOptFromJSProp($prop, $this->spot_colors, $this->rtl);
12905 // set additional default values
12906 $this->annotation_fonts[$this->CurrentFont['fontkey
']] = $this->CurrentFont['i
'];
12907 $fontstyle = sprintf('/F%d %F Tf %s
', $this->CurrentFont['i
'], $this->FontSizePt, $this->TextColor);
12908 $popt['da
'] = $fontstyle;
12909 // build appearance stream
12910 $popt['ap
'] = array();
12911 $popt['ap
']['n
'] = '/Tx BMC q
'.$fontstyle.' ';
12913 foreach($values as $item) {
12914 if (is_array($item)) {
12915 $text .= $item[1]."\n";
12917 $text .= $item."\n";
12920 $tmpid = $this->startTemplate($w, $h, false);
12921 $this->MultiCell($w, $h, $text, 0, '', false, 0, 0, 0, true, 0, false, true, 0, 'T
', false);
12922 $this->endTemplate();
12924 $popt['ap
']['n
'] .= $this->xobjects[$tmpid]['outdata
'];
12925 unset($this->xobjects[$tmpid]);
12926 $popt['ap
']['n
'] .= 'Q EMC
';
12928 $opt = array_merge($popt, $opt);
12929 // set remaining annotation data
12930 $opt['Subtype
'] = 'Widget
';
12933 $opt['opt
'] = $values;
12934 unset($opt['mk
']['ca
']);
12935 unset($opt['mk
']['rc
']);
12936 unset($opt['mk
']['ac
']);
12937 unset($opt['mk
']['i
']);
12938 unset($opt['mk
']['ri
']);
12939 unset($opt['mk
']['ix
']);
12940 unset($opt['mk
']['if']);
12941 unset($opt['mk
']['tp
']);
12942 $this->Annotation($x, $y, $w, $h, $name, $opt, 0);
12965 public function ComboBox($name, $w, $h, $values, $prop=array(), $opt=array(), $x='', $y='', $js=false) {
12972 // check page for no-write regions and adapt page margins if necessary
12973 list($x, $y) = $this->checkPageRegions($h, $x, $y);
12975 $this->_addfield('combobox
', $name, $x, $y, $w, $h, $prop);
12977 foreach ($values as $value) {
12978 if (is_array($value)) {
12979 $s .= ',[\
''.addslashes($value[1]).
'\',\
''.addslashes($value[0]).
'\']
';
12981 $s .= ',[\
''.addslashes($value).
'\',\
''.addslashes($value).
'\']
';
12984 $this->javascript .= 'f
'.$name.'.setItems(
'.substr($s, 1).');
'."\n";
12987 // get default style
12988 $prop = array_merge($this->getFormDefaultProp(), $prop);
12989 $prop['Combo
'] = true;
12990 // get annotation data
12991 $popt = TCPDF_STATIC::getAnnotOptFromJSProp($prop, $this->spot_colors, $this->rtl);
12992 // set additional default options
12993 $this->annotation_fonts[$this->CurrentFont['fontkey
']] = $this->CurrentFont['i
'];
12994 $fontstyle = sprintf('/F%d %F Tf %s
', $this->CurrentFont['i
'], $this->FontSizePt, $this->TextColor);
12995 $popt['da
'] = $fontstyle;
12996 // build appearance stream
12997 $popt['ap
'] = array();
12998 $popt['ap
']['n
'] = '/Tx BMC q
'.$fontstyle.' ';
13000 foreach($values as $item) {
13001 if (is_array($item)) {
13002 $text .= $item[1]."\n";
13004 $text .= $item."\n";
13007 $tmpid = $this->startTemplate($w, $h, false);
13008 $this->MultiCell($w, $h, $text, 0, '', false, 0, 0, 0, true, 0, false, true, 0, 'T
', false);
13009 $this->endTemplate();
13011 $popt['ap
']['n
'] .= $this->xobjects[$tmpid]['outdata
'];
13012 unset($this->xobjects[$tmpid]);
13013 $popt['ap
']['n
'] .= 'Q EMC
';
13015 $opt = array_merge($popt, $opt);
13016 // set remaining annotation data
13017 $opt['Subtype
'] = 'Widget
';
13020 $opt['opt
'] = $values;
13021 unset($opt['mk
']['ca
']);
13022 unset($opt['mk
']['rc
']);
13023 unset($opt['mk
']['ac
']);
13024 unset($opt['mk
']['i
']);
13025 unset($opt['mk
']['ri
']);
13026 unset($opt['mk
']['ix
']);
13027 unset($opt['mk
']['if']);
13028 unset($opt['mk
']['tp
']);
13029 $this->Annotation($x, $y, $w, $h, $name, $opt, 0);
13052 public function CheckBox($name, $w, $checked=false, $prop=array(), $opt=array(), $onvalue='Yes
', $x='', $y='', $js=false) {
13059 // check page for no-write regions and adapt page margins if necessary
13060 list($x, $y) = $this->checkPageRegions($w, $x, $y);
13062 $this->_addfield('checkbox
', $name, $x, $y, $w, $w, $prop);
13065 if (!isset($prop['value
'])) {
13066 $prop['value
'] = array('Yes
');
13068 // get default style
13069 $prop = array_merge($this->getFormDefaultProp(), $prop);
13070 $prop['borderStyle
'] = 'inset
';
13071 // get annotation data
13072 $popt = TCPDF_STATIC::getAnnotOptFromJSProp($prop, $this->spot_colors, $this->rtl);
13073 // set additional default options
13074 $font = 'zapfdingbats
';
13075 if ($this->pdfa_mode) {
13076 // all fonts must be embedded
13077 $font = 'pdfa
'.$font;
13079 $this->AddFont($font);
13080 $tmpfont = $this->getFontBuffer($font);
13081 $this->annotation_fonts[$tmpfont['fontkey
']] = $tmpfont['i
'];
13082 $fontstyle = sprintf('/F%d %F Tf %s
', $tmpfont['i
'], $this->FontSizePt, $this->TextColor);
13083 $popt['da
'] = $fontstyle;
13084 // build appearance stream
13085 $popt['ap
'] = array();
13086 $popt['ap
']['n
'] = array();
13087 $fx = ((($w - $this->getAbsFontMeasure($tmpfont['cw
'][110])) / 2) * $this->k);
13088 $fy = (($w - ((($tmpfont['desc
']['Ascent
'] - $tmpfont['desc
']['Descent
']) * $this->FontSizePt / 1000) / $this->k)) * $this->k);
13089 $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);
13090 $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);
13092 $opt = array_merge($popt, $opt);
13094 $opt['Subtype'] = 'Widget';
13095 $opt['ft'] = 'Btn';
13100 $opt[
'opt'] = array($onvalue);
13102 $opt[
'v'] = array(
'/Yes');
13103 $opt[
'as'] =
'Yes';
13105 $opt[
'v'] = array(
'/Off');
13106 $opt[
'as'] =
'Off';
13132 public function Button($name,
$w,
$h, $caption, $action, $prop=array(), $opt=array(),
$x=
'',
$y=
'', $js=
false) {
13142 $this->
_addfield(
'button', $name, $this->x, $this->y,
$w,
$h, $prop);
13143 $this->javascript .=
'f'.$name.
".buttonSetCaption('".addslashes($caption).
"');\n";
13144 $this->javascript .=
'f'.$name.
".setAction('MouseUp','".addslashes($action).
"');\n";
13145 $this->javascript .=
'f'.$name.
".highlight='push';\n";
13146 $this->javascript .=
'f'.$name.
".print=false;\n";
13151 $prop[
'Pushbutton'] =
'true';
13152 $prop[
'highlight'] =
'push';
13153 $prop[
'display'] =
'display.noPrint';
13156 $this->annotation_fonts[$this->CurrentFont[
'fontkey']] = $this->CurrentFont[
'i'];
13157 $fontstyle = sprintf(
'/F%d %F Tf %s', $this->CurrentFont[
'i'], $this->FontSizePt, $this->TextColor);
13158 $popt[
'da'] = $fontstyle;
13160 $popt[
'ap'] = array();
13161 $popt[
'ap'][
'n'] =
'/Tx BMC q '.$fontstyle.
' ';
13165 'L' => array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' => array(231)),
13166 'R' => array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' => array(51)),
13167 'T' => array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' => array(231)),
13168 'B' => array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' => array(51)));
13170 $this->
Cell(
$w,
$h, $caption, $border, 0,
'C',
true,
'', 1,
false,
'T',
'M');
13173 $popt[
'ap'][
'n'] .= $this->xobjects[$tmpid][
'outdata'];
13174 unset($this->xobjects[$tmpid]);
13175 $popt[
'ap'][
'n'] .=
'Q EMC';
13177 if (!isset($popt[
'mk'])) {
13178 $popt[
'mk'] = array();
13180 $ann_obj_id = ($this->n + 1);
13181 if (!empty($action) AND !is_array($action)) {
13182 $ann_obj_id = ($this->n + 2);
13184 $popt[
'mk'][
'ca'] = $this->
_textstring($caption, $ann_obj_id);
13185 $popt[
'mk'][
'rc'] = $this->
_textstring($caption, $ann_obj_id);
13186 $popt[
'mk'][
'ac'] = $this->
_textstring($caption, $ann_obj_id);
13188 $opt = array_merge($popt, $opt);
13190 $opt[
'Subtype'] =
'Widget';
13191 $opt[
'ft'] =
'Btn';
13192 $opt[
't'] = $caption;
13194 if (!empty($action)) {
13195 if (is_array($action)) {
13197 $opt[
'aa'] =
'/D <<';
13198 $bmode = array(
'SubmitForm',
'ResetForm',
'ImportData');
13199 foreach ($action AS $key => $val) {
13200 if (($key ==
'S') AND in_array($val, $bmode)) {
13201 $opt[
'aa'] .=
' /S /'.$val;
13202 } elseif (($key ==
'F') AND (!empty($val))) {
13203 $opt[
'aa'] .=
' /F '.$this->_datastring($val, $ann_obj_id);
13204 } elseif (($key ==
'Fields') AND is_array($val) AND !empty($val)) {
13205 $opt[
'aa'] .=
' /Fields [';
13206 foreach ($val AS $field) {
13207 $opt[
'aa'] .=
' '.$this->_textstring($field, $ann_obj_id);
13210 } elseif (($key ==
'Flags')) {
13212 if (is_array($val)) {
13213 foreach ($val AS $flag) {
13215 case 'Include/Exclude': {
13219 case 'IncludeNoValueFields': {
13223 case 'ExportFormat': {
13227 case 'GetMethod': {
13231 case 'SubmitCoordinates': {
13239 case 'IncludeAppendSaves': {
13243 case 'IncludeAnnotations': {
13247 case 'SubmitPDF': {
13251 case 'CanonicalFormat': {
13255 case 'ExclNonUserAnnots': {
13263 case 'EmbedForm': {
13270 $ff = intval($val);
13272 $opt[
'aa'] .=
' /Flags '.$ff;
13275 $opt[
'aa'] .=
' >>';
13279 $opt[
'aa'] =
'/D '.$js_obj_id.
' 0 R';
13300 if ((!$this->sign) OR (!isset($this->signature_data[
'cert_type']))) {
13303 $sigobjid = ($this->sig_obj_id + 1);
13304 $out = $this->
_getobj($sigobjid).
"\n";
13305 $out .=
'<< /Type /Sig';
13306 $out .=
' /Filter /Adobe.PPKLite';
13307 $out .=
' /SubFilter /adbe.pkcs7.detached';
13308 $out .=
' '.TCPDF_STATIC::$byterange_string;
13309 $out .=
' /Contents<'.str_repeat(
'0', $this->signature_max_length).
'>';
13310 $out .=
' /Reference [';
13311 $out .=
' << /Type /SigRef';
13312 if ($this->signature_data[
'cert_type'] > 0) {
13313 $out .=
' /TransformMethod /DocMDP';
13314 $out .=
' /TransformParams <<';
13315 $out .=
' /Type /TransformParams';
13316 $out .=
' /P '.$this->signature_data[
'cert_type'];
13317 $out .=
' /V /1.2';
13319 $out .=
' /TransformMethod /UR3';
13320 $out .=
' /TransformParams <<';
13321 $out .=
' /Type /TransformParams';
13322 $out .=
' /V /2.2';
13324 $out .=
' /Document['.$this->ur[
'document'].
']';
13327 $out .=
' /Form['.$this->ur[
'form'].
']';
13330 $out .=
' /Signature['.$this->ur[
'signature'].
']';
13333 $out .=
' /Annots['.$this->ur[
'annots'].
']';
13336 $out .=
' /EF['.$this->ur[
'ef'].
']';
13339 $out .=
' /FormEX['.$this->ur[
'formex'].
']';
13351 $out .=
' /Name '.$this->_textstring($this->signature_data[
'info'][
'Name'], $sigobjid);
13353 if (isset($this->signature_data[
'info'][
'Location']) AND !
TCPDF_STATIC::empty_string($this->signature_data[
'info'][
'Location'])) {
13354 $out .=
' /Location '.$this->_textstring($this->signature_data[
'info'][
'Location'], $sigobjid);
13356 if (isset($this->signature_data[
'info'][
'Reason']) AND !
TCPDF_STATIC::empty_string($this->signature_data[
'info'][
'Reason'])) {
13357 $out .=
' /Reason '.$this->_textstring($this->signature_data[
'info'][
'Reason'], $sigobjid);
13359 if (isset($this->signature_data[
'info'][
'ContactInfo']) AND !
TCPDF_STATIC::empty_string($this->signature_data[
'info'][
'ContactInfo'])) {
13360 $out .=
' /ContactInfo '.$this->_textstring($this->signature_data[
'info'][
'ContactInfo'], $sigobjid);
13362 $out .=
' /M '.$this->_datestring($sigobjid, $this->doc_modification_timestamp);
13364 $out .=
"\n".
'endobj';
13387 $document=
'/FullSave',
13388 $annots=
'/Create/Delete/Modify/Copy/Import/Export',
13389 $form=
'/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate',
13390 $signature=
'/Modify',
13391 $ef=
'/Create/Delete/Modify/Import',
13393 $this->ur[
'enabled'] = $enable;
13394 $this->ur[
'document'] = $document;
13395 $this->ur[
'annots'] = $annots;
13396 $this->ur[
'form'] = $form;
13397 $this->ur[
'signature'] = $signature;
13398 $this->ur[
'ef'] = $ef;
13399 $this->ur[
'formex'] = $formex;
13400 if (!$this->sign) {
13421 public function setSignature($signing_cert=
'', $private_key=
'', $private_key_password=
'', $extracerts=
'', $cert_type=2, $info=array()) {
13426 $this->sign =
true;
13430 $this->signature_data = array();
13431 if (strlen($signing_cert) == 0) {
13432 $this->
Error(
'Please provide a certificate file and password!');
13434 if (strlen($private_key) == 0) {
13435 $private_key = $signing_cert;
13437 $this->signature_data[
'signcert'] = $signing_cert;
13438 $this->signature_data[
'privkey'] = $private_key;
13439 $this->signature_data[
'password'] = $private_key_password;
13440 $this->signature_data[
'extracerts'] = $extracerts;
13441 $this->signature_data[
'cert_type'] = $cert_type;
13442 $this->signature_data[
'info'] = $info;
13493 if ((
$page < 1) OR (
$page > $this->numpages)) {
13496 $sigapp[
'page'] = intval(
$page);
13498 if (empty($name)) {
13499 $sigapp[
'name'] =
'Signature';
13501 $sigapp[
'name'] = $name;
13504 $b = $this->pagedim[($sigapp[
'page'])][
'h'] - ((
$y +
$h) *
$this->k);
13507 $sigapp[
'rect'] = sprintf(
'%F %F %F %F', $a, $b, ($a + $c), ($b + $d));
13519 if (empty(
$page)) {
13520 $page = $this->page + 1;
13532 $this->starting_page_number = max(0, intval($num));
13545 $rep = str_repeat(
' ', $this->
GetNumChars($ref));
13552 $sdiff = sprintf(
'%F', $wdiff);
13555 $alias =
'{'.$alias;
13570 return '{'.TCPDF_STATIC::$alias_tot_pages.
'}';
13585 return '{'.TCPDF_STATIC::$alias_num_page.
'}';
13600 return '{'.TCPDF_STATIC::$alias_group_tot_pages.
'}';
13615 return '{'.TCPDF_STATIC::$alias_group_num_page.
'}';
13656 if (empty($this->pdflayers)) {
13659 foreach ($this->pdflayers as $key => $layer) {
13660 $this->pdflayers[$key][
'objid'] = $this->
_newobj();
13661 $out =
'<< /Type /OCG';
13662 $out .=
' /Name '.$this->_textstring($layer[
'name'], $this->pdflayers[$key][
'objid']);
13663 $out .=
' /Usage <<';
13664 if (isset($layer[
'print']) AND ($layer[
'print'] !== NULL)) {
13665 $out .=
' /Print <</PrintState /'.($layer[
'print']?
'ON':
'OFF').
'>>';
13667 $out .=
' /View <</ViewState /'.($layer[
'view']?
'ON':
'OFF').
'>>';
13669 $out .=
"\n".
'endobj';
13683 if ($this->state != 2) {
13686 $layer = sprintf(
'LYR%03d', (count($this->pdflayers) + 1));
13687 if (empty($name)) {
13690 $name = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $name);
13692 $this->pdflayers[] = array(
'layer' => $layer,
'name' => $name,
'print' => $print,
'view' => $view);
13693 $this->openMarkedContent =
true;
13694 $this->
_out(
'/OC /'.$layer.
' BDC');
13703 if ($this->state != 2) {
13706 if ($this->openMarkedContent) {
13708 $this->
_out(
'EMC');
13709 $this->openMarkedContent =
false;
13722 if ($this->state != 2) {
13741 $this->
Error(
'Incorrect visibility: '.$v);
13755 if ($this->pdfa_mode) {
13760 foreach ($this->extgstates as $i => $ext) {
13761 if ($ext[
'parms'] == $parms) {
13762 if ($this->inxobj) {
13770 $n = (count($this->extgstates) + 1);
13771 $this->extgstates[
$n] = array(
'parms' => $parms);
13772 if ($this->inxobj) {
13786 if ($this->pdfa_mode OR ($this->state != 2)) {
13790 $this->
_out(sprintf(
'/GS%d gs', $gs));
13799 foreach ($this->extgstates as $i => $ext) {
13800 $this->extgstates[$i][
'n'] = $this->
_newobj();
13801 $out =
'<< /Type /ExtGState';
13802 foreach ($ext[
'parms'] as
$k => $v) {
13803 if (is_float($v)) {
13804 $v = sprintf(
'%F', $v);
13805 } elseif ($v ===
true) {
13807 } elseif ($v ===
false) {
13810 $out .=
' /'.$k.
' '.$v;
13813 $out .=
"\n".
'endobj';
13828 if ($this->state != 2) {
13831 $stroking = $stroking ?
true :
false;
13834 $nonstroking = $stroking;
13836 $nonstroking = $nonstroking ?
true :
false;
13838 if (($mode != 0) AND ($mode != 1)) {
13841 $this->overprint = array(
'OP' => $stroking,
'op' => $nonstroking,
'OPM' => $mode);
13866 public function setAlpha($stroking=1, $bm=
'Normal', $nonstroking=
'', $ais=
false) {
13867 if ($this->pdfa_mode) {
13871 $stroking = floatval($stroking);
13874 $nonstroking = $stroking;
13876 $nonstroking = floatval($nonstroking);
13878 if ($bm[0] ==
'/') {
13880 $bm = substr($bm, 1);
13882 if (!in_array($bm, array(
'Normal',
'Multiply',
'Screen',
'Overlay',
'Darken',
'Lighten',
'ColorDodge',
'ColorBurn',
'HardLight',
'SoftLight',
'Difference',
'Exclusion',
'Hue',
'Saturation',
'Color',
'Luminosity'))) {
13885 $ais = $ais ?
true :
false;
13886 $this->alpha = array(
'CA' => $stroking,
'ca' => $nonstroking,
'BM' =>
'/'.$bm,
'AIS' => $ais);
13909 if (($quality < 1) OR ($quality > 100)) {
13912 $this->jpeg_quality = intval($quality);
13922 $this->default_table_columns = intval($cols);
13932 $this->cell_height_ratio =
$h;
13951 if ($this->pdfa_mode) {
13953 $this->PDFVersion =
'1.4';
13955 $this->PDFVersion = $version;
13969 $this->viewer_preferences = $preferences;
13985 public function colorRegistrationBar(
$x,
$y,
$w,
$h, $transition=
true, $vertical=
false, $colors=
'A,R,G,B,C,M,Y,K') {
13986 if (strpos($colors,
'ALLSPOT') !==
false) {
13989 foreach ($this->spot_colors as $spot_color_name => $v) {
13994 $colors = str_replace(
'ALLSPOT',
$spot_colors, $colors);
13996 $colors = str_replace(
'ALLSPOT',
'NONE', $colors);
13999 $bars = explode(
',', $colors);
14000 $numbars = count($bars);
14001 if ($numbars <= 0) {
14006 $coords = array(0, 0, 0, 1);
14007 $wb =
$w / $numbars;
14012 $coords = array(1, 0, 0, 0);
14014 $hb =
$h / $numbars;
14020 foreach ($bars as $col) {
14024 $col_a = array(255);
14030 $col_b = array(255);
14034 $col_a = array(255,255,255);
14035 $col_b = array(255,0,0);
14039 $col_a = array(255,255,255);
14040 $col_b = array(0,255,0);
14044 $col_a = array(255,255,255);
14045 $col_b = array(0,0,255);
14049 $col_a = array(0,0,0,0);
14050 $col_b = array(100,0,0,0);
14054 $col_a = array(0,0,0,0);
14055 $col_b = array(0,100,0,0);
14059 $col_a = array(0,0,0,0);
14060 $col_b = array(0,0,100,0);
14064 $col_a = array(0,0,0,0);
14065 $col_b = array(0,0,0,100);
14069 $col_a = array(255,255,255);
14070 $col_b = array(0,0,0);
14074 $col_a = array(0,0,0,0);
14075 $col_b = array(100,100,100,100);
14079 $col_a = array(0,0,0,0,
'None');
14080 $col_b = array(100,100,100,100,
'All');
14084 $col_a = array(0,0,0,0,
'None');
14085 $col_b = array(0,0,0,0,
'None');
14089 $col_a = array(0,0,0,0,
'None');
14091 if ($col_b ===
false) {
14093 $col_b = array(100,100,100,100,
'All');
14098 if ($col !=
'NONE') {
14101 $this->
LinearGradient($xb, $yb, $wb, $hb, $col_a, $col_b, $coords);
14105 $this->
Rect($xb, $yb, $wb, $hb,
'F', array());
14125 public function cropMark(
$x,
$y,
$w,
$h, $type=
'T,R,B,L', $color=array(100,100,100,100,
'All')) {
14126 $this->
SetLineStyle(array(
'width' => (0.5 / $this->k),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $color));
14127 $type = strtoupper($type);
14128 $type = preg_replace(
'/[^A-Z\-\,]*/',
'', $type);
14130 $type = str_replace(
'-',
',', $type);
14131 $type = str_replace(
'TL',
'T,L', $type);
14132 $type = str_replace(
'TR',
'T,R', $type);
14133 $type = str_replace(
'BL',
'F,L', $type);
14134 $type = str_replace(
'BR',
'F,R', $type);
14135 $type = str_replace(
'A',
'T,L', $type);
14136 $type = str_replace(
'B',
'T,R', $type);
14137 $type = str_replace(
'T,RO',
'BO', $type);
14138 $type = str_replace(
'C',
'F,L', $type);
14139 $type = str_replace(
'D',
'F,R', $type);
14140 $crops = explode(
',', strtoupper($type));
14142 $crops = array_unique($crops);
14145 foreach ($crops as $crop) {
14180 $this->
Line($x1, $y1, $x2, $y2);
14196 public function registrationMark(
$x,
$y, $r, $double=
false, $cola=array(100,100,100,100,
'All'), $colb=array(0,0,0,0,
'None')) {
14197 $line_style = array(
'width' => max((0.5 / $this->k),($r / 30)),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $cola);
14201 $this->
Circle(
$x,
$y, $r, 0, 360,
'C', $line_style, array(), 8);
14210 $this->
Circle(
$x,
$y, $ri, 0, 360,
'C', $line_style, array(), 8);
14225 $lw = max((0.5 / $this->k),($r / 8));
14243 $line_style = array(
'width' => $lw,
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => array(100,100,100,100,
'All'));
14246 $this->
Circle(
$x,
$y, $r, 0, 360,
'C', $line_style, array(), 8);
14269 $this->
Gradient(2, $coords, array(array(
'color' => $col1,
'offset' => 0,
'exponent' => 1), array(
'color' => $col2,
'offset' => 1,
'exponent' => 1)), array(),
false);
14285 public function RadialGradient(
$x,
$y,
$w,
$h, $col1=array(), $col2=array(), $coords=array(0.5,0.5,0.5,0.5,1)) {
14287 $this->
Gradient(3, $coords, array(array(
'color' => $col1,
'offset' => 0,
'exponent' => 1), array(
'color' => $col2,
'offset' => 1,
'exponent' => 1)), array(),
false);
14308 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) {
14309 if ($this->pdfa_mode OR ($this->state != 2)) {
14313 $n = count($this->gradients) + 1;
14314 $this->gradients[
$n] = array();
14315 $this->gradients[
$n][
'type'] = 6;
14316 $this->gradients[
$n][
'coords'] = array();
14317 $this->gradients[
$n][
'antialias'] = $antialias;
14318 $this->gradients[
$n][
'colors'] = array();
14319 $this->gradients[
$n][
'transparency'] =
false;
14321 if (!isset($coords[0][
'f'])) {
14323 if (!isset($col1[1])) {
14324 $col1[1] = $col1[2] = $col1[0];
14326 if (!isset($col2[1])) {
14327 $col2[1] = $col2[2] = $col2[0];
14329 if (!isset($col3[1])) {
14330 $col3[1] = $col3[2] = $col3[0];
14332 if (!isset($col4[1])) {
14333 $col4[1] = $col4[2] = $col4[0];
14335 $patch_array[0][
'f'] = 0;
14336 $patch_array[0][
'points'] = $coords;
14337 $patch_array[0][
'colors'][0][
'r'] = $col1[0];
14338 $patch_array[0][
'colors'][0][
'g'] = $col1[1];
14339 $patch_array[0][
'colors'][0][
'b'] = $col1[2];
14340 $patch_array[0][
'colors'][1][
'r'] = $col2[0];
14341 $patch_array[0][
'colors'][1][
'g'] = $col2[1];
14342 $patch_array[0][
'colors'][1][
'b'] = $col2[2];
14343 $patch_array[0][
'colors'][2][
'r'] = $col3[0];
14344 $patch_array[0][
'colors'][2][
'g'] = $col3[1];
14345 $patch_array[0][
'colors'][2][
'b'] = $col3[2];
14346 $patch_array[0][
'colors'][3][
'r'] = $col4[0];
14347 $patch_array[0][
'colors'][3][
'g'] = $col4[1];
14348 $patch_array[0][
'colors'][3][
'b'] = $col4[2];
14351 $patch_array = $coords;
14355 $this->gradients[
$n][
'stream'] =
'';
14356 $count_patch = count($patch_array);
14357 for ($i=0; $i < $count_patch; ++$i) {
14358 $this->gradients[
$n][
'stream'] .= chr($patch_array[$i][
'f']);
14359 $count_points = count($patch_array[$i][
'points']);
14360 for ($j=0; $j < $count_points; ++$j) {
14362 $patch_array[$i][
'points'][$j] = (($patch_array[$i][
'points'][$j] - $coords_min) / ($coords_max - $coords_min)) * $bpcd;
14363 if ($patch_array[$i][
'points'][$j] < 0) {
14364 $patch_array[$i][
'points'][$j] = 0;
14366 if ($patch_array[$i][
'points'][$j] > $bpcd) {
14367 $patch_array[$i][
'points'][$j] = $bpcd;
14369 $this->gradients[
$n][
'stream'] .= chr(floor($patch_array[$i][
'points'][$j] / 256));
14370 $this->gradients[
$n][
'stream'] .= chr(floor($patch_array[$i][
'points'][$j] % 256));
14372 $count_cols = count($patch_array[$i][
'colors']);
14373 for ($j=0; $j < $count_cols; ++$j) {
14375 $this->gradients[
$n][
'stream'] .= chr($patch_array[$i][
'colors'][$j][
'r']);
14376 $this->gradients[
$n][
'stream'] .= chr($patch_array[$i][
'colors'][$j][
'g']);
14377 $this->gradients[
$n][
'stream'] .= chr($patch_array[$i][
'colors'][$j][
'b']);
14381 $this->
_out(
'/Sh'.
$n.
' sh');
14384 if ($this->inxobj) {
14401 if ($this->state != 2) {
14405 $x = $this->w -
$x -
$w;
14410 $s .= sprintf(
' %F %F %F %F re W n',
$x*$this->k, ($this->h-
$y)*$this->k,
$w*$this->k, -
$h*$this->k);
14412 $s .= sprintf(
' %F 0 0 %F %F %F cm',
$w*$this->k,
$h*$this->k,
$x*$this->k, ($this->h-(
$y+
$h))*$this->k);
14427 public function Gradient($type, $coords, $stops, $background=array(), $antialias=
false) {
14428 if ($this->pdfa_mode OR ($this->state != 2)) {
14431 $n = count($this->gradients) + 1;
14432 $this->gradients[
$n] = array();
14433 $this->gradients[
$n][
'type'] = $type;
14434 $this->gradients[
$n][
'coords'] = $coords;
14435 $this->gradients[
$n][
'antialias'] = $antialias;
14436 $this->gradients[
$n][
'colors'] = array();
14437 $this->gradients[
$n][
'transparency'] =
false;
14439 $numcolspace = count($stops[0][
'color']);
14440 $bcolor = array_values($background);
14441 switch($numcolspace) {
14444 $this->gradients[
$n][
'colspace'] =
'DeviceCMYK';
14445 if (!empty($background)) {
14446 $this->gradients[
$n][
'background'] = sprintf(
'%F %F %F %F', $bcolor[0]/100, $bcolor[1]/100, $bcolor[2]/100, $bcolor[3]/100);
14451 $this->gradients[
$n][
'colspace'] =
'DeviceRGB';
14452 if (!empty($background)) {
14453 $this->gradients[
$n][
'background'] = sprintf(
'%F %F %F', $bcolor[0]/255, $bcolor[1]/255, $bcolor[2]/255);
14458 $this->gradients[
$n][
'colspace'] =
'DeviceGray';
14459 if (!empty($background)) {
14460 $this->gradients[
$n][
'background'] = sprintf(
'%F', $bcolor[0]/255);
14465 $num_stops = count($stops);
14466 $last_stop_id = $num_stops - 1;
14467 foreach ($stops as $key => $stop) {
14468 $this->gradients[
$n][
'colors'][$key] = array();
14470 if (isset($stop[
'offset'])) {
14471 $this->gradients[
$n][
'colors'][$key][
'offset'] = $stop[
'offset'];
14474 $this->gradients[
$n][
'colors'][$key][
'offset'] = 0;
14475 } elseif ($key == $last_stop_id) {
14476 $this->gradients[
$n][
'colors'][$key][
'offset'] = 1;
14478 $offsetstep = (1 - $this->gradients[
$n][
'colors'][($key - 1)][
'offset']) / ($num_stops - $key);
14479 $this->gradients[
$n][
'colors'][$key][
'offset'] = $this->gradients[
$n][
'colors'][($key - 1)][
'offset'] + $offsetstep;
14482 if (isset($stop[
'opacity'])) {
14483 $this->gradients[
$n][
'colors'][$key][
'opacity'] = $stop[
'opacity'];
14484 if ((!$this->pdfa_mode) AND ($stop[
'opacity'] < 1)) {
14485 $this->gradients[
$n][
'transparency'] =
true;
14488 $this->gradients[
$n][
'colors'][$key][
'opacity'] = 1;
14491 if (isset($stop[
'exponent'])) {
14492 $this->gradients[
$n][
'colors'][$key][
'exponent'] = $stop[
'exponent'];
14494 $this->gradients[
$n][
'colors'][$key][
'exponent'] = 1;
14497 $color = array_values($stop[
'color']);
14498 switch($numcolspace) {
14501 $this->gradients[
$n][
'colors'][$key][
'color'] = sprintf(
'%F %F %F %F', $color[0]/100, $color[1]/100, $color[2]/100, $color[3]/100);
14505 $this->gradients[
$n][
'colors'][$key][
'color'] = sprintf(
'%F %F %F', $color[0]/255, $color[1]/255, $color[2]/255);
14509 $this->gradients[
$n][
'colors'][$key][
'color'] = sprintf(
'%F', $color[0]/255);
14514 if ($this->gradients[
$n][
'transparency']) {
14516 $this->
_out(
'/TGS'.$n.
' gs');
14519 $this->
_out(
'/Sh'.$n.
' sh');
14522 if ($this->inxobj) {
14535 if ($this->pdfa_mode) {
14538 $idt = count($this->gradients);
14539 foreach ($this->gradients as $id => $grad) {
14540 if (($grad[
'type'] == 2) OR ($grad[
'type'] == 3)) {
14543 $out .=
' /FunctionType 3';
14544 $out .=
' /Domain [0 1]';
14549 $num_cols = count($grad[
'colors']);
14550 $lastcols = $num_cols - 1;
14551 for ($i = 1; $i < $num_cols; ++$i) {
14552 $functions .= ($fc + $i).
' 0 R ';
14553 if ($i < $lastcols) {
14554 $bounds .= sprintf(
'%F ', $grad[
'colors'][$i][
'offset']);
14558 $out .=
' /Functions ['.trim($functions).
']';
14559 $out .=
' /Bounds ['.trim($bounds).
']';
14560 $out .=
' /Encode ['.trim($encode).
']';
14562 $out .=
"\n".
'endobj';
14564 for ($i = 1; $i < $num_cols; ++$i) {
14567 $out .=
' /FunctionType 2';
14568 $out .=
' /Domain [0 1]';
14569 $out .=
' /C0 ['.$grad[
'colors'][($i - 1)][
'color'].
']';
14570 $out .=
' /C1 ['.$grad[
'colors'][$i][
'color'].
']';
14571 $out .=
' /N '.$grad[
'colors'][$i][
'exponent'];
14573 $out .=
"\n".
'endobj';
14577 if ($grad[
'transparency']) {
14580 $out .=
' /FunctionType 3';
14581 $out .=
' /Domain [0 1]';
14584 $num_cols = count($grad[
'colors']);
14585 for ($i = 1; $i < $num_cols; ++$i) {
14586 $functions .= ($ft + $i).
' 0 R ';
14588 $out .=
' /Functions ['.trim($functions).
']';
14589 $out .=
' /Bounds ['.trim($bounds).
']';
14590 $out .=
' /Encode ['.trim($encode).
']';
14592 $out .=
"\n".
'endobj';
14594 for ($i = 1; $i < $num_cols; ++$i) {
14597 $out .=
' /FunctionType 2';
14598 $out .=
' /Domain [0 1]';
14599 $out .=
' /C0 ['.$grad[
'colors'][($i - 1)][
'opacity'].
']';
14600 $out .=
' /C1 ['.$grad[
'colors'][$i][
'opacity'].
']';
14601 $out .=
' /N '.$grad[
'colors'][$i][
'exponent'];
14603 $out .=
"\n".
'endobj';
14610 $out =
'<< /ShadingType '.$grad[
'type'];
14611 if (isset($grad[
'colspace'])) {
14612 $out .=
' /ColorSpace /'.$grad[
'colspace'];
14614 $out .=
' /ColorSpace /DeviceRGB';
14616 if (isset($grad[
'background']) AND !empty($grad[
'background'])) {
14617 $out .=
' /Background ['.$grad[
'background'].
']';
14619 if (isset($grad[
'antialias']) AND ($grad[
'antialias'] ===
true)) {
14620 $out .=
' /AntiAlias true';
14622 if ($grad[
'type'] == 2) {
14623 $out .=
' '.sprintf(
'/Coords [%F %F %F %F]', $grad[
'coords'][0], $grad[
'coords'][1], $grad[
'coords'][2], $grad[
'coords'][3]);
14624 $out .=
' /Domain [0 1]';
14625 $out .=
' /Function '.$fc.
' 0 R';
14626 $out .=
' /Extend [true true]';
14628 } elseif ($grad[
'type'] == 3) {
14631 $out .=
' '.sprintf(
'/Coords [%F %F 0 %F %F %F]', $grad[
'coords'][0], $grad[
'coords'][1], $grad[
'coords'][2], $grad[
'coords'][3], $grad[
'coords'][4]);
14632 $out .=
' /Domain [0 1]';
14633 $out .=
' /Function '.$fc.
' 0 R';
14634 $out .=
' /Extend [true true]';
14636 } elseif ($grad[
'type'] == 6) {
14637 $out .=
' /BitsPerCoordinate 16';
14638 $out .=
' /BitsPerComponent 8';
14639 $out .=
' /Decode[0 1 0 1 0 1 0 1 0 1]';
14640 $out .=
' /BitsPerFlag 8';
14642 $out .=
' /Length '.strlen($stream);
14644 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
14646 $out .=
"\n".
'endobj';
14648 if ($grad[
'transparency']) {
14649 $shading_transparency = preg_replace(
'/\/ColorSpace \/[^\s]+/si',
'/ColorSpace /DeviceGray', $out);
14650 $shading_transparency = preg_replace(
'/\/Function [0-9]+ /si',
'/Function '.$ft.
' ', $shading_transparency);
14652 $this->gradients[$id][
'id'] =
$this->n;
14655 $out =
'<< /Type /Pattern /PatternType 2';
14656 $out .=
' /Shading '.$this->gradients[$id][
'id'].
' 0 R';
14658 $out .=
"\n".
'endobj';
14660 $this->gradients[$id][
'pattern'] =
$this->n;
14662 if ($grad[
'transparency']) {
14664 $idgs = $id + $idt;
14666 $this->
_out($shading_transparency);
14667 $this->gradients[$idgs][
'id'] =
$this->n;
14669 $out =
'<< /Type /Pattern /PatternType 2';
14670 $out .=
' /Shading '.$this->gradients[$idgs][
'id'].
' 0 R';
14672 $out .=
"\n".
'endobj';
14674 $this->gradients[$idgs][
'pattern'] =
$this->n;
14677 $this->xobjects[
'LX'.$oid] = array(
'n' => $oid);
14679 $stream =
'q /a0 gs /Pattern cs /p'.$idgs.
' scn 0 0 '.$this->wPt.
' '.$this->hPt.
' re f Q';
14680 if ($this->compress) {
14681 $filter =
' /Filter /FlateDecode';
14682 $stream = gzcompress($stream);
14685 $out =
'<< /Type /XObject /Subtype /Form /FormType 1'.$filter;
14686 $out .=
' /Length '.strlen($stream);
14687 $rect = sprintf(
'%F %F', $this->wPt, $this->hPt);
14688 $out .=
' /BBox [0 0 '.$rect.
']';
14689 $out .=
' /Group << /Type /Group /S /Transparency /CS /DeviceGray >>';
14690 $out .=
' /Resources <<';
14691 $out .=
' /ExtGState << /a0 << /ca 1 /CA 1 >> >>';
14692 $out .=
' /Pattern << /p'.$idgs.
' '.$this->gradients[$idgs][
'pattern'].
' 0 R >>';
14695 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
14696 $out .=
"\n".
'endobj';
14700 $out =
'<< /Type /Mask /S /Luminosity /G '.($this->n - 1).
' 0 R >>'.
"\n".
'endobj';
14704 $out =
'<< /Type /ExtGState /SMask '.($this->n - 1).
' 0 R /AIS false >>'.
"\n".
'endobj';
14706 $this->extgstates[] = array(
'n' => $this->n,
'name' =>
'TGS'.$id);
14726 public function PieSector($xc, $yc, $r, $a, $b, $style=
'FD', $cw=
true, $o=90) {
14727 $this->
PieSectorXY($xc, $yc, $r, $r, $a, $b, $style, $cw, $o);
14747 public function PieSectorXY($xc, $yc, $rx, $ry, $a, $b, $style=
'FD', $cw=
false, $o=0, $nc=2) {
14748 if ($this->state != 2) {
14752 $xc = ($this->w - $xc);
14756 $line_style = array();
14760 $b = (360 - $a + $o);
14761 $a = (360 - $d + $o);
14791 public function ImageEps($file,
$x=
'',
$y=
'',
$w=0,
$h=0, $link=
'', $useBoundingBox=
true, $align=
'', $palign=
'', $border=0, $fitonpage=
false, $fixoutvals=
false) {
14792 if ($this->state != 2) {
14795 if ($this->rasterize_vector_images AND (
$w > 0) AND (
$h > 0)) {
14797 return $this->
Image($file,
$x,
$y,
$w,
$h,
'EPS', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false, $fitonpage);
14808 if ($file{0} ===
'@') {
14809 $data = substr($file, 1);
14813 if ($data === FALSE) {
14814 $this->
Error(
'EPS file not found: '.$file);
14818 preg_match(
"/%%Creator:([^\r\n]+)/", $data, $regs); # find Creator
14819 if (count($regs) > 1) {
14820 $version_str = trim($regs[1]); # e.g.
"Adobe Illustrator(R) 8.0"
14821 if (strpos($version_str,
'Adobe Illustrator') !==
false) {
14822 $versexp = explode(
' ', $version_str);
14823 $version = (float)array_pop($versexp);
14824 if ($version >= 9) {
14825 $this->
Error(
'This version of Adobe Illustrator file is not supported: '.$file);
14830 $start = strpos($data,
'%!PS-Adobe');
14832 $data = substr($data, $start);
14835 preg_match(
"/%%BoundingBox:([^\r\n]+)/", $data, $regs);
14836 if (count($regs) > 1) {
14837 list($x1, $y1, $x2, $y2) = explode(
' ', trim($regs[1]));
14839 $this->
Error(
'No BoundingBox found in EPS/AI file: '.$file);
14841 $start = strpos($data,
'%%EndSetup');
14842 if ($start ===
false) {
14843 $start = strpos($data,
'%%EndProlog');
14845 if ($start ===
false) {
14846 $start = strpos($data,
'%%BoundingBox');
14848 $data = substr($data, $start);
14849 $end = strpos($data,
'%%PageTrailer');
14850 if ($end===
false) {
14851 $end = strpos($data,
'showpage');
14854 $data = substr($data, 0, $end);
14857 if ((
$w <= 0) AND (
$h <= 0)) {
14858 $w = ($x2 - $x1) /
$k;
14859 $h = ($y2 - $y1) /
$k;
14860 } elseif (
$w <= 0) {
14861 $w = ($x2-$x1) /
$k * (
$h / (($y2 - $y1) /
$k));
14862 } elseif (
$h <= 0) {
14863 $h = ($y2 - $y1) /
$k * (
$w / (($x2 - $x1) /
$k));
14867 if ($this->rasterize_vector_images) {
14869 return $this->
Image($file,
$x,
$y,
$w,
$h,
'EPS', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false, $fitonpage);
14872 $scale_x =
$w / (($x2 - $x1) /
$k);
14873 $scale_y =
$h / (($y2 - $y1) /
$k);
14875 $this->img_rb_y =
$y +
$h;
14878 if ($palign ==
'L') {
14880 } elseif ($palign ==
'C') {
14881 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
14882 } elseif ($palign ==
'R') {
14883 $ximg = $this->w - $this->rMargin -
$w;
14887 $this->img_rb_x = $ximg;
14889 if ($palign ==
'L') {
14891 } elseif ($palign ==
'C') {
14892 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
14893 } elseif ($palign ==
'R') {
14894 $ximg = $this->w - $this->rMargin -
$w;
14898 $this->img_rb_x = $ximg +
$w;
14900 if ($useBoundingBox) {
14901 $dx = $ximg *
$k - $x1;
14902 $dy =
$y *
$k - $y1;
14908 $this->
_out(
'q'.$this->epsmarker);
14910 $this->
_out(sprintf(
'%F %F %F %F %F %F cm', 1, 0, 0, 1, $dx, $dy + ($this->hPt - (2 *
$y *
$k) - ($y2 - $y1))));
14912 if (isset($scale_x)) {
14913 $this->
_out(sprintf(
'%F %F %F %F %F %F cm', $scale_x, 0, 0, $scale_y, $x1 * (1 - $scale_x), $y2 * (1 - $scale_y)));
14916 $lines = preg_split(
'/[\r\n]+/si', $data, -1, PREG_SPLIT_NO_EMPTY);
14918 $cnt = count($lines);
14919 for ($i=0; $i < $cnt; ++$i) {
14920 $line = $lines[$i];
14921 if (($line ==
'') OR ($line{0} ==
'%')) {
14924 $len = strlen($line);
14927 if (strcasecmp(
'x', substr(trim($line), -1)) == 0) {
14928 if (preg_match(
'/\([^\)]*\)/', $line, $matches) > 0) {
14930 $color_name = $matches[0];
14932 $line = str_replace(
' '.$color_name,
'', $line);
14934 $color_name = substr($color_name, 1, -1);
14937 $chunks = explode(
' ', $line);
14938 $cmd = trim(array_pop($chunks));
14940 if (($cmd ==
'Xa') OR ($cmd ==
'XA')) {
14941 $b = array_pop($chunks);
14942 $g = array_pop($chunks);
14943 $r = array_pop($chunks);
14944 $this->
_out(
''.$r.
' '.$g.
' '.$b.
' '.($cmd==
'Xa'?
'rg':
'RG'));
14955 foreach ($chunks as $key => $val) {
14956 if ((($key % 2) == 0) AND (($val < $x1) OR ($val > $x2))) {
14958 } elseif ((($key % 2) != 0) AND (($val < $y1) OR ($val > $y2))) {
14986 $this->
_out($line);
14990 if (empty($color_name)) {
14992 list($col_c, $col_m, $col_y, $col_k) = $chunks;
14993 $this->
_out(
''.$col_c.
' '.$col_m.
' '.$col_y.
' '.$col_k.
' k');
14996 list($col_c, $col_m, $col_y, $col_k, $col_t) = $chunks;
14997 $this->
AddSpotColor($color_name, ($col_c * 100), ($col_m * 100), ($col_y * 100), ($col_k * 100));
14998 $color_cmd = sprintf(
'/CS%d cs %F scn', $this->spot_colors[$color_name][
'i'], (1 - $col_t));
14999 $this->
_out($color_cmd);
15004 if (empty($color_name)) {
15006 list($col_c, $col_m, $col_y, $col_k) = $chunks;
15007 $this->
_out(
''.$col_c.
' '.$col_m.
' '.$col_y.
' '.$col_k.
' K');
15010 list($col_c, $col_m, $col_y, $col_k, $col_t) = $chunks;
15011 $this->
AddSpotColor($color_name, ($col_c * 100), ($col_m * 100), ($col_y * 100), ($col_k * 100));
15012 $color_cmd = sprintf(
'/CS%d CS %F SCN', $this->spot_colors[$color_name][
'i'], (1 - $col_t));
15013 $this->
_out($color_cmd);
15025 $line[($len - 1)] = strtolower($cmd);
15026 $this->
_out($line);
15031 $this->
_out($cmd .
'*');
15038 $max = min(($i + 5), $cnt);
15039 for ($j = ($i + 1); $j < $max; ++$j) {
15040 $isU = ($isU OR (($lines[$j] ==
'U') OR ($lines[$j] ==
'*U')));
15061 $this->
_out($this->epsmarker.
'Q');
15062 if (!empty($border)) {
15070 $this->
Cell(
$w, $h,
'', $border, 0,
'', 0,
'', 0,
true);
15075 $this->
Link($ximg,
$y,
$w, $h, $link, 0);
15085 $this->y =
$y + round($h/2);
15095 $this->
SetY($this->img_rb_y);
15111 $this->barcode = $bc;
15158 require_once(dirname(__FILE__).
'/tcpdf_barcodes_1d.php');
15163 $arrcode = $barcodeobj->getBarcodeArray();
15164 if (($arrcode ===
false) OR empty($arrcode) OR ($arrcode[
'maxw'] <= 0)) {
15165 $this->
Error(
'Error in 1D barcode string');
15167 if ($arrcode[
'maxh'] <= 0) {
15168 $arrcode[
'maxh'] = 1;
15171 if (!isset($style[
'position'])) {
15172 $style[
'position'] =
'';
15173 } elseif ($style[
'position'] ==
'S') {
15175 $style[
'position'] =
'';
15176 $style[
'stretch'] =
true;
15178 if (!isset($style[
'fitwidth'])) {
15179 if (!isset($style[
'stretch'])) {
15180 $style[
'fitwidth'] =
true;
15182 $style[
'fitwidth'] =
false;
15185 if ($style[
'fitwidth']) {
15187 $style[
'stretch'] =
false;
15189 if (!isset($style[
'stretch'])) {
15190 if ((
$w ===
'') OR (
$w <= 0)) {
15191 $style[
'stretch'] =
false;
15193 $style[
'stretch'] =
true;
15196 if (!isset($style[
'fgcolor'])) {
15197 $style[
'fgcolor'] = array(0,0,0);
15199 if (!isset($style[
'bgcolor'])) {
15200 $style[
'bgcolor'] =
false;
15202 if (!isset($style[
'border'])) {
15203 $style[
'border'] =
false;
15206 if (!isset($style[
'text'])) {
15207 $style[
'text'] =
false;
15209 if ($style[
'text'] AND isset($style[
'font'])) {
15210 if (isset($style[
'fontsize'])) {
15211 $fontsize = $style[
'fontsize'];
15213 $this->
SetFont($style[
'font'],
'', $fontsize);
15215 if (!isset($style[
'stretchtext'])) {
15216 $style[
'stretchtext'] = 4;
15226 if ((
$w ===
'') OR (
$w <= 0)) {
15230 $w = $this->w - $this->rMargin -
$x;
15234 if (!isset($style[
'padding'])) {
15236 } elseif ($style[
'padding'] ===
'auto') {
15237 $padding = 10 * (
$w / ($arrcode[
'maxw'] + 20));
15239 $padding = floatval($style[
'padding']);
15242 if (!isset($style[
'hpadding'])) {
15243 $hpadding = $padding;
15244 } elseif ($style[
'hpadding'] ===
'auto') {
15245 $hpadding = 10 * (
$w / ($arrcode[
'maxw'] + 20));
15247 $hpadding = floatval($style[
'hpadding']);
15250 if (!isset($style[
'vpadding'])) {
15251 $vpadding = $padding;
15252 } elseif ($style[
'vpadding'] ===
'auto') {
15253 $vpadding = ($hpadding / 2);
15255 $vpadding = floatval($style[
'vpadding']);
15258 $max_xres = (
$w - (2 * $hpadding)) / $arrcode[
'maxw'];
15259 if ($style[
'stretch']) {
15265 if ($xres > $max_xres) {
15269 if ((isset($style[
'padding']) AND ($style[
'padding'] ===
'auto'))
15270 OR (isset($style[
'hpadding']) AND ($style[
'hpadding'] ===
'auto'))) {
15271 $hpadding = 10 * $xres;
15272 if (isset($style[
'vpadding']) AND ($style[
'vpadding'] ===
'auto')) {
15273 $vpadding = ($hpadding / 2);
15277 if ($style[
'fitwidth']) {
15279 $w = (($arrcode[
'maxw'] * $xres) + (2 * $hpadding));
15280 if (isset($style[
'cellfitalign'])) {
15281 switch ($style[
'cellfitalign']) {
15284 $x -= ($wold -
$w);
15290 $x += ($wold -
$w);
15296 $x -= (($wold -
$w) / 2);
15298 $x += (($wold -
$w) / 2);
15310 if ((
$h ===
'') OR (
$h <= 0)) {
15312 $h = (($arrcode[
'maxw'] * $xres) / 3) + (2 * $vpadding) + $text_height;
15314 $barh =
$h - $text_height - (2 * $vpadding);
15317 if ($text_height >
$h) {
15318 $fontsize = ((
$h *
$this->k) / (4 * $this->cell_height_ratio));
15320 $this->
SetFont($style[
'font'],
'', $fontsize);
15322 if ($vpadding > 0) {
15323 $vpadding = ((
$h - $text_height) / 4);
15325 $barh =
$h - $text_height - (2 * $vpadding);
15330 $this->img_rb_y =
$y +
$h;
15333 if ($style[
'position'] ==
'L') {
15335 } elseif ($style[
'position'] ==
'C') {
15336 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15337 } elseif ($style[
'position'] ==
'R') {
15338 $xpos = $this->w - $this->rMargin -
$w;
15342 $this->img_rb_x = $xpos;
15344 if ($style[
'position'] ==
'L') {
15346 } elseif ($style[
'position'] ==
'C') {
15347 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15348 } elseif ($style[
'position'] ==
'R') {
15349 $xpos = $this->w - $this->rMargin -
$w;
15353 $this->img_rb_x = $xpos +
$w;
15355 $xpos_rect = $xpos;
15356 if (!isset($style[
'align'])) {
15357 $style[
'align'] =
'C';
15359 switch ($style[
'align']) {
15361 $xpos = $xpos_rect + $hpadding;
15365 $xpos = $xpos_rect + (
$w - ($arrcode[
'maxw'] * $xres)) - $hpadding;
15370 $xpos = $xpos_rect + ((
$w - ($arrcode[
'maxw'] * $xres)) / 2);
15374 $xpos_text = $xpos;
15377 $this->rtl =
false;
15379 if ($style[
'bgcolor']) {
15380 $this->
Rect($xpos_rect,
$y,
$w, $h, $style[
'border'] ?
'DF' :
'F',
'', $style[
'bgcolor']);
15381 } elseif ($style[
'border']) {
15382 $this->
Rect($xpos_rect,
$y,
$w, $h,
'D');
15388 foreach ($arrcode[
'bcode'] as
$k => $v) {
15389 $bw = ($v[
'w'] * $xres);
15392 $ypos =
$y + $vpadding + ($v[
'p'] * $barh / $arrcode[
'maxh']);
15393 $this->
Rect($xpos, $ypos, $bw, ($v[
'h'] * $barh / $arrcode[
'maxh']),
'F', array(), $style[
'fgcolor']);
15398 if ($style[
'text']) {
15400 $label = $style[
'label'];
15404 $txtwidth = ($arrcode[
'maxw'] * $xres);
15406 $style[
'stretchtext'] = 2;
15409 $this->x = $xpos_text;
15410 $this->y =
$y + $vpadding + $barh;
15413 $this->
Cell($txtwidth,
'', $label, 0, 0,
'C',
false,
'', $style[
'stretchtext'],
false,
'T',
'T');
15414 $this->cell_padding = $cellpadding;
15417 $this->rtl = $tempRTL;
15428 $this->y =
$y + round($h / 2);
15438 $this->
SetY($this->img_rb_y);
15477 require_once(dirname(__FILE__).
'/tcpdf_barcodes_2d.php');
15482 $arrcode = $barcodeobj->getBarcodeArray();
15483 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)) {
15484 $this->
Error(
'Error in 2D barcode string');
15487 if (!isset($style[
'position'])) {
15488 $style[
'position'] =
'';
15490 if (!isset($style[
'fgcolor'])) {
15491 $style[
'fgcolor'] = array(0,0,0);
15493 if (!isset($style[
'bgcolor'])) {
15494 $style[
'bgcolor'] =
false;
15496 if (!isset($style[
'border'])) {
15497 $style[
'border'] =
false;
15500 if (!isset($style[
'padding'])) {
15501 $style[
'padding'] = 0;
15502 } elseif ($style[
'padding'] ===
'auto') {
15503 $style[
'padding'] = 4;
15505 if (!isset($style[
'hpadding'])) {
15506 $style[
'hpadding'] = $style[
'padding'];
15507 } elseif ($style[
'hpadding'] ===
'auto') {
15508 $style[
'hpadding'] = 4;
15510 if (!isset($style[
'vpadding'])) {
15511 $style[
'vpadding'] = $style[
'padding'];
15512 } elseif ($style[
'vpadding'] ===
'auto') {
15513 $style[
'vpadding'] = 4;
15515 $hpad = (2 * $style[
'hpadding']);
15516 $vpad = (2 * $style[
'vpadding']);
15518 if (!isset($style[
'module_width'])) {
15519 $style[
'module_width'] = 1;
15521 if (!isset($style[
'module_height'])) {
15522 $style[
'module_height'] = 1;
15533 $rows = $arrcode[
'num_rows'];
15534 $cols = $arrcode[
'num_cols'];
15535 if (($rows <= 0) || ($cols <= 0)){
15536 $this->
Error(
'Error in 2D barcode string');
15539 $mw = $style[
'module_width'];
15540 $mh = $style[
'module_height'];
15541 if (($mw <= 0) OR ($mh <= 0)) {
15542 $this->
Error(
'Error in 2D barcode string');
15548 $maxw = $this->w - $this->rMargin -
$x;
15551 $ratioHW = ((($rows * $mh) + $hpad) / (($cols * $mw) + $vpad));
15552 $ratioWH = ((($cols * $mw) + $vpad) / (($rows * $mh) + $hpad));
15554 if (($maxw * $ratioHW) > $maxh) {
15555 $maxw = $maxh * $ratioWH;
15557 if (($maxh * $ratioWH) > $maxw) {
15558 $maxh = $maxw * $ratioHW;
15569 if (((
$w ===
'') OR (
$w <= 0)) AND ((
$h ===
'') OR (
$h <= 0))) {
15570 $w = ($cols + $hpad) * ($mw / $this->k);
15571 $h = ($rows + $vpad) * ($mh / $this->k);
15572 } elseif ((
$w ===
'') OR (
$w <= 0)) {
15573 $w =
$h * $ratioWH;
15574 } elseif ((
$h ===
'') OR (
$h <= 0)) {
15575 $h =
$w * $ratioHW;
15578 $bw = (
$w * $cols) / ($cols + $hpad);
15579 $bh = (
$h * $rows) / ($rows + $vpad);
15584 if (($cw / $ch) > ($mw / $mh)) {
15586 $cw = $ch * $mw / $mh;
15588 $style[
'hpadding'] = (
$w - $bw) / (2 * $cw);
15591 $ch = $cw * $mh / $mw;
15593 $style[
'vpadding'] = (
$h - $bh) / (2 * $ch);
15599 $this->img_rb_y =
$y +
$h;
15602 if ($style[
'position'] ==
'L') {
15604 } elseif ($style[
'position'] ==
'C') {
15605 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15606 } elseif ($style[
'position'] ==
'R') {
15607 $xpos = $this->w - $this->rMargin -
$w;
15611 $this->img_rb_x = $xpos;
15613 if ($style[
'position'] ==
'L') {
15615 } elseif ($style[
'position'] ==
'C') {
15616 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15617 } elseif ($style[
'position'] ==
'R') {
15618 $xpos = $this->w - $this->rMargin -
$w;
15622 $this->img_rb_x = $xpos +
$w;
15624 $xstart = $xpos + ($style[
'hpadding'] * $cw);
15625 $ystart =
$y + ($style[
'vpadding'] * $ch);
15628 $this->rtl =
false;
15630 if ($style[
'bgcolor']) {
15631 $this->
Rect($xpos,
$y,
$w, $h, $style[
'border'] ?
'DF' :
'F',
'', $style[
'bgcolor']);
15632 } elseif ($style[
'border']) {
15633 $this->
Rect($xpos,
$y,
$w, $h,
'D');
15639 for ($r = 0; $r < $rows; ++$r) {
15642 for ($c = 0; $c < $cols; ++$c) {
15643 if ($arrcode[
'bcode'][$r][$c] == 1) {
15645 $this->
Rect($xr, $ystart, $cw, $ch,
'F', array(), $style[
'fgcolor']);
15652 $this->rtl = $tempRTL;
15663 $this->y =
$y + round($h/2);
15673 $this->
SetY($this->img_rb_y);
15704 'left' => $this->lMargin,
15705 'right' => $this->rMargin,
15706 'top' => $this->tMargin,
15707 'bottom' => $this->bMargin,
15708 'header' => $this->header_margin,
15709 'footer' => $this->footer_margin,
15710 'cell' => $this->cell_padding,
15711 'padding_left' => $this->cell_padding[
'L'],
15712 'padding_top' => $this->cell_padding[
'T'],
15713 'padding_right' => $this->cell_padding[
'R'],
15714 'padding_bottom' => $this->cell_padding[
'B']
15731 'left' => $this->original_lMargin,
15732 'right' => $this->original_rMargin
15789 public function fixHTMLCode($html, $default_css=
'', $tagvs=
'', $tidy_options=
'') {
15801 if ($width ==
'thin') {
15803 } elseif ($width ==
'medium') {
15805 } elseif ($width ==
'thick') {
15821 switch (strtolower($style)) {
15857 $bprop = preg_split(
'/[\s]+/', trim($cssborder));
15859 switch (count($bprop)) {
15861 $width = $bprop[0];
15862 $style = $bprop[1];
15863 $color = $bprop[2];
15868 $style = $bprop[0];
15869 $color = $bprop[1];
15874 $style = $bprop[0];
15885 if ($style ==
'none') {
15888 $border[
'cap'] =
'square';
15889 $border[
'join'] =
'miter';
15891 if ($border[
'dash'] < 0) {
15908 $padding = preg_split(
'/[\s]+/', trim($csspadding));
15910 switch (count($padding)) {
15962 $margin = preg_split(
'/[\s]+/', trim($cssmargin));
15964 switch (count($margin)) {
16016 $space = preg_split(
'/[\s]+/', trim($cssbspace));
16017 $border_spacing = array();
16018 switch (count($space)) {
16020 $border_spacing[
'H'] = $space[0];
16021 $border_spacing[
'V'] = $space[1];
16025 $border_spacing[
'H'] = $space[0];
16026 $border_spacing[
'V'] = $space[0];
16030 return array(
'H' => 0,
'V' => 0);
16036 $border_spacing[
'H'] = $this->
getHTMLUnitToUnits($border_spacing[
'H'], $width,
'px',
false);
16037 $border_spacing[
'V'] = $this->
getHTMLUnitToUnits($border_spacing[
'V'], $width,
'px',
false);
16038 return $border_spacing;
16051 $spacing = trim($spacing);
16052 switch ($spacing) {
16058 if ($parent ==
'normal') {
16082 $stretch = trim($stretch);
16083 switch ($stretch) {
16084 case 'ultra-condensed': {
16088 case 'extra-condensed': {
16092 case 'condensed': {
16096 case 'semi-condensed': {
16104 case 'semi-expanded': {
16112 case 'extra-expanded': {
16116 case 'ultra-expanded': {
16121 $val = ($parent + 10);
16125 $val = ($parent - 10);
16129 if ($parent ==
'normal') {
16157 $size = ($refsize - 4);
16161 $size = ($refsize - 3);
16165 $size = ($refsize - 2);
16173 $size = ($refsize + 2);
16177 $size = ($refsize + 4);
16181 $size = ($refsize + 6);
16185 $size = ($parent_size - 3);
16189 $size = ($parent_size + 3);
16210 $matches = array();
16211 if (preg_match_all(
'/<cssarray>([^<]*)<\/cssarray>/isU', $html, $matches) > 0) {
16212 if (isset($matches[1][0])) {
16213 $css = array_merge($css, unserialize($this->
unhtmlentities($matches[1][0])));
16215 $html = preg_replace(
'/<cssarray>(.*?)<\/cssarray>/isU',
'', $html);
16218 $matches = array();
16219 if (preg_match_all(
'/<link([^>]*)>/isU', $html, $matches) > 0) {
16220 foreach ($matches[1] as $key => $link) {
16222 if (preg_match(
'/type[\s]*=[\s]*"text\/css"/', $link, $type)) {
16224 preg_match(
'/media[\s]*=[\s]*"([^"]*)"/', $link, $type);
16227 if (empty($type) OR (isset($type[1]) AND (($type[1] ==
'all') OR ($type[1] ==
'print')))) {
16229 if (preg_match(
'/href[\s]*=[\s]*"([^"]*)"/', $link, $type) > 0) {
16232 if (($cssdata !== FALSE) AND (strlen($cssdata) > 0)) {
16241 $matches = array();
16242 if (preg_match_all(
'/<style([^>]*)>([^<]*)<\/style>/isU', $html, $matches) > 0) {
16243 foreach ($matches[1] as $key => $media) {
16245 preg_match(
'/media[\s]*=[\s]*"([^"]*)"/', $media, $type);
16248 if (empty($type) OR (isset($type[1]) AND (($type[1] ==
'all') OR ($type[1] ==
'print')))) {
16249 $cssdata = $matches[2][$key];
16255 $csstagarray =
'<cssarray>'.htmlentities(serialize($css)).
'</cssarray>';
16257 $html = preg_replace(
'/<head([^>]*)>(.*?)<\/head>/siU',
'', $html);
16258 $html = preg_replace(
'/<style([^>]*)>([^<]*)<\/style>/isU',
'', $html);
16260 $blocktags = array(
'blockquote',
'br',
'dd',
'dl',
'div',
'dt',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'hr',
'li',
'ol',
'p',
'pre',
'ul',
'tcpdf',
'table',
'tr',
'td');
16262 $selfclosingtags = array(
'area',
'base',
'basefont',
'br',
'hr',
'input',
'img',
'link',
'meta');
16264 $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>');
16266 $html = preg_replace(
'/<pre/',
'<xre', $html);
16267 $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);
16268 $html = preg_replace(
'@(\r\n|\r)@',
"\n", $html);
16269 $repTable = array(
"\t" =>
' ',
"\0" =>
' ',
"\x0B" =>
' ',
"\\" =>
"\\\\");
16270 $html = strtr($html, $repTable);
16272 while (($offset < strlen($html)) AND ($pos = strpos($html,
'</pre>', $offset)) !==
false) {
16273 $html_a = substr($html, 0, $offset);
16274 $html_b = substr($html, $offset, ($pos - $offset + 6));
16275 while (preg_match(
"'<xre([^>]*)>(.*?)\n(.*?)</pre>'si", $html_b)) {
16277 $html_b = preg_replace(
"'<xre([^>]*)>(.*?)\n(.*?)</pre>'si",
"<xre\\1>\\2<br />\\3</pre>", $html_b);
16279 while (preg_match(
"'<xre([^>]*)>(.*?)".$this->re_space[
'p'].
"(.*?)</pre>'".$this->re_space[
'm'], $html_b)) {
16281 $html_b = preg_replace(
"'<xre([^>]*)>(.*?)".$this->re_space[
'p'].
"(.*?)</pre>'".$this->re_space[
'm'],
"<xre\\1>\\2 \\3</pre>", $html_b);
16283 $html = $html_a.$html_b.substr($html, $pos + 6);
16284 $offset = strlen($html_a.$html_b);
16287 while (($offset < strlen($html)) AND ($pos = strpos($html,
'</textarea>', $offset)) !==
false) {
16288 $html_a = substr($html, 0, $offset);
16289 $html_b = substr($html, $offset, ($pos - $offset + 11));
16290 while (preg_match(
"'<textarea([^>]*)>(.*?)\n(.*?)</textarea>'si", $html_b)) {
16292 $html_b = preg_replace(
"'<textarea([^>]*)>(.*?)\n(.*?)</textarea>'si",
"<textarea\\1>\\2<TBR>\\3</textarea>", $html_b);
16293 $html_b = preg_replace(
"'<textarea([^>]*)>(.*?)[\"](.*?)</textarea>'si",
"<textarea\\1>\\2''\\3</textarea>", $html_b);
16295 $html = $html_a.$html_b.substr($html, $pos + 11);
16296 $offset = strlen($html_a.$html_b);
16298 $html = preg_replace(
'/([\s]*)<option/si',
'<option', $html);
16299 $html = preg_replace(
'/<\/option>([\s]*)/si',
'</option>', $html);
16301 while (($offset < strlen($html)) AND ($pos = strpos($html,
'</option>', $offset)) !==
false) {
16302 $html_a = substr($html, 0, $offset);
16303 $html_b = substr($html, $offset, ($pos - $offset + 9));
16304 while (preg_match(
"'<option([^>]*)>(.*?)</option>'si", $html_b)) {
16305 $html_b = preg_replace(
"'<option([\s]+)value=\"([^\"]*)\"([^>]*)>(.*?)</option>'si",
"\\2#!TaB!#\\4#!NwL!#", $html_b);
16306 $html_b = preg_replace(
"'<option([^>]*)>(.*?)</option>'si",
"\\2#!NwL!#", $html_b);
16308 $html = $html_a.$html_b.substr($html, $pos + 9);
16309 $offset = strlen($html_a.$html_b);
16311 if (preg_match(
"'</select'si", $html)) {
16312 $html = preg_replace(
"'<select([^>]*)>'si",
"<select\\1 opt=\"", $html);
16313 $html = preg_replace(
"'#!NwL!#</select>'si",
"\" />", $html);
16315 $html = str_replace(
"\n",
' ', $html);
16317 $html = str_replace(
'<TBR>',
"\n", $html);
16319 $html = preg_replace(
'/[\s]+<\/(table|tr|ul|ol|dl)>/',
'</\\1>', $html);
16320 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<\/(td|th|li|dt|dd)>/'.$this->re_space[
'm'],
'</\\1>', $html);
16321 $html = preg_replace(
'/[\s]+<(tr|td|th|li|dt|dd)/',
'<\\1', $html);
16322 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<(ul|ol|dl|br)/'.$this->re_space[
'm'],
'<\\1', $html);
16323 $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);
16324 $html = preg_replace(
'/<\/(td|th)>/',
'<marker style="font-size:0"/></\\1>', $html);
16325 $html = preg_replace(
'/<\/table>([\s]*)<marker style="font-size:0"\/>/',
'</table>', $html);
16326 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<img/'.$this->re_space[
'm'], chr(32).
'<img', $html);
16327 $html = preg_replace(
'/<img([^>]*)>[\s]+([^<])/xi',
'<img\\1> \\2', $html);
16328 $html = preg_replace(
'/<img([^>]*)>/xi',
'<img\\1><span><marker style="font-size:0"/></span>', $html);
16329 $html = preg_replace(
'/<xre/',
'<pre', $html);
16330 $html = preg_replace(
'/<textarea([^>]*)>([^<]*)<\/textarea>/xi',
'<textarea\\1 value="\\2" />', $html);
16331 $html = preg_replace(
'/<li([^>]*)><\/li>/',
'<li\\1> </li>', $html);
16332 $html = preg_replace(
'/<li([^>]*)>'.$this->re_space[
'p'].
'*<img/'.$this->re_space[
'm'],
'<li\\1><font size="1"> </font><img', $html);
16333 $html = preg_replace(
'/<([^>\/]*)>[\s]/',
'<\\1> ', $html);
16334 $html = preg_replace(
'/[\s]<\/([^>]*)>/',
' </\\1>', $html);
16335 $html = preg_replace(
'/<su([bp])/',
'<zws/><su\\1', $html);
16336 $html = preg_replace(
'/<\/su([bp])>/',
'</su\\1><zws/>', $html);
16337 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+/'.$this->re_space[
'm'], chr(32), $html);
16341 $html = preg_replace(
'/<li><br([^>]*)>/',
'<li> <br\\1>', $html);
16343 $html = preg_replace(
'/^<img/',
'<span style="font-size:0"><br /></span> <img', $html, 1);
16345 $tagpattern =
'/(<[^>]+>)/';
16347 $a = preg_split($tagpattern, $html, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
16349 $maxel = count($a);
16354 $dom[$key] = array();
16357 $dom[$key][
'tag'] =
false;
16358 $dom[$key][
'block'] =
false;
16359 $dom[$key][
'value'] =
'';
16360 $dom[$key][
'parent'] = 0;
16361 $dom[$key][
'hide'] =
false;
16368 $dom[$key][
'fill'] = (($this->textrendermode % 2) == 0);
16369 $dom[$key][
'clip'] = ($this->textrendermode > 3);
16371 $dom[$key][
'bgcolor'] =
false;
16374 $dom[$key][
'align'] =
'';
16375 $dom[$key][
'listtype'] =
'';
16376 $dom[$key][
'text-indent'] = 0;
16377 $dom[$key][
'text-transform'] =
'';
16378 $dom[$key][
'border'] = array();
16379 $dom[$key][
'dir'] = $this->rtl?
'rtl':
'ltr';
16383 array_push($level, 0);
16384 while ($elkey < $maxel) {
16385 $dom[$key] = array();
16386 $element = $a[$elkey];
16387 $dom[$key][
'elkey'] = $elkey;
16388 if (preg_match($tagpattern, $element)) {
16390 $element = substr($element, 1, -1);
16392 preg_match(
'/[\/]?([a-zA-Z0-9]*)/', $element, $tag);
16393 $tagname = strtolower($tag[1]);
16395 if ($tagname ==
'thead') {
16396 if ($element{0} ==
'/') {
16404 $dom[$key][
'tag'] =
true;
16405 $dom[$key][
'value'] = $tagname;
16406 if (in_array($dom[$key][
'value'], $blocktags)) {
16407 $dom[$key][
'block'] =
true;
16409 $dom[$key][
'block'] =
false;
16411 if ($element{0} ==
'/') {
16413 $dom[$key][
'opening'] =
false;
16414 $dom[$key][
'parent'] = end($level);
16416 $dom[$key][
'hide'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'hide'];
16417 $dom[$key][
'fontname'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontname'];
16418 $dom[$key][
'fontstyle'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontstyle'];
16419 $dom[$key][
'fontsize'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontsize'];
16420 $dom[$key][
'font-stretch'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'font-stretch'];
16421 $dom[$key][
'letter-spacing'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'letter-spacing'];
16422 $dom[$key][
'stroke'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'stroke'];
16423 $dom[$key][
'fill'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fill'];
16424 $dom[$key][
'clip'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'clip'];
16425 $dom[$key][
'line-height'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'line-height'];
16426 $dom[$key][
'bgcolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'bgcolor'];
16427 $dom[$key][
'fgcolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fgcolor'];
16428 $dom[$key][
'strokecolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'strokecolor'];
16429 $dom[$key][
'align'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'align'];
16430 $dom[$key][
'text-transform'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'text-transform'];
16431 $dom[$key][
'dir'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'dir'];
16432 if (isset($dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'listtype'])) {
16433 $dom[$key][
'listtype'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'listtype'];
16436 if (($dom[$key][
'value'] ==
'tr') AND (!isset($dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'cols']))) {
16437 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'cols'] = $dom[($dom[$key][
'parent'])][
'cols'];
16439 if (($dom[$key][
'value'] ==
'td') OR ($dom[$key][
'value'] ==
'th')) {
16440 $dom[($dom[$key][
'parent'])][
'content'] = $csstagarray;
16441 for ($i = ($dom[$key][
'parent'] + 1); $i < $key; ++$i) {
16442 $dom[($dom[$key][
'parent'])][
'content'] .= $a[$dom[$i][
'elkey']];
16446 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'<table',
'<table nested="true"', $dom[($dom[$key][
'parent'])][
'content']);
16448 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'<thead>',
'', $dom[($dom[$key][
'parent'])][
'content']);
16449 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'</thead>',
'', $dom[($dom[$key][
'parent'])][
'content']);
16452 if (($dom[$key][
'value'] ==
'tr') AND ($dom[($dom[$key][
'parent'])][
'thead'] ===
true)) {
16454 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'thead'] = $csstagarray.$a[$dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'elkey']];
16456 for ($i = $dom[$key][
'parent']; $i <= $key; ++$i) {
16457 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'thead'] .= $a[$dom[$i][
'elkey']];
16459 if (!isset($dom[($dom[$key][
'parent'])][
'attribute'])) {
16460 $dom[($dom[$key][
'parent'])][
'attribute'] = array();
16463 $dom[($dom[$key][
'parent'])][
'attribute'][
'nobr'] =
'true';
16467 $dom[($dom[$key][
'parent'])][
'thead'] = str_replace(
' nobr="true"',
'', $dom[($dom[$key][
'parent'])][
'thead']);
16468 $dom[($dom[$key][
'parent'])][
'thead'] .=
'</tablehead>';
16472 $dom[$key][
'opening'] =
true;
16473 $dom[$key][
'parent'] = end($level);
16474 if ((substr($element, -1, 1) ==
'/') OR (in_array($dom[$key][
'value'], $selfclosingtags))) {
16476 $dom[$key][
'self'] =
true;
16479 array_push($level, $key);
16480 $dom[$key][
'self'] =
false;
16485 $parentkey = $dom[$key][
'parent'];
16486 $dom[$key][
'hide'] = $dom[$parentkey][
'hide'];
16487 $dom[$key][
'fontname'] = $dom[$parentkey][
'fontname'];
16488 $dom[$key][
'fontstyle'] = $dom[$parentkey][
'fontstyle'];
16489 $dom[$key][
'fontsize'] = $dom[$parentkey][
'fontsize'];
16490 $dom[$key][
'font-stretch'] = $dom[$parentkey][
'font-stretch'];
16491 $dom[$key][
'letter-spacing'] = $dom[$parentkey][
'letter-spacing'];
16492 $dom[$key][
'stroke'] = $dom[$parentkey][
'stroke'];
16493 $dom[$key][
'fill'] = $dom[$parentkey][
'fill'];
16494 $dom[$key][
'clip'] = $dom[$parentkey][
'clip'];
16495 $dom[$key][
'line-height'] = $dom[$parentkey][
'line-height'];
16496 $dom[$key][
'bgcolor'] = $dom[$parentkey][
'bgcolor'];
16497 $dom[$key][
'fgcolor'] = $dom[$parentkey][
'fgcolor'];
16498 $dom[$key][
'strokecolor'] = $dom[$parentkey][
'strokecolor'];
16499 $dom[$key][
'align'] = $dom[$parentkey][
'align'];
16500 $dom[$key][
'listtype'] = $dom[$parentkey][
'listtype'];
16501 $dom[$key][
'text-indent'] = $dom[$parentkey][
'text-indent'];
16502 $dom[$key][
'text-transform'] = $dom[$parentkey][
'text-transform'];
16503 $dom[$key][
'border'] = array();
16504 $dom[$key][
'dir'] = $dom[$parentkey][
'dir'];
16507 preg_match_all(
'/([^=\s]*)[\s]*=[\s]*"([^"]*)"/', $element, $attr_array, PREG_PATTERN_ORDER);
16508 $dom[$key][
'attribute'] = array();
16509 while (list($id, $name) = each($attr_array[1])) {
16510 $dom[$key][
'attribute'][strtolower($name)] = $attr_array[2][$id];
16512 if (!empty($css)) {
16518 if (isset($dom[$key][
'attribute'][
'style']) AND !empty($dom[$key][
'attribute'][
'style'])) {
16520 preg_match_all(
'/([^;:\s]*):([^;]*)/', $dom[$key][
'attribute'][
'style'], $style_array, PREG_PATTERN_ORDER);
16521 $dom[$key][
'style'] = array();
16522 while (list($id, $name) = each($style_array[1])) {
16524 $dom[$key][
'style'][strtolower($name)] = trim($style_array[2][$id]);
16528 if (isset($dom[$key][
'style'][
'direction'])) {
16529 $dom[$key][
'dir'] = $dom[$key][
'style'][
'direction'];
16532 if (isset($dom[$key][
'style'][
'display'])) {
16533 $dom[$key][
'hide'] = (trim(strtolower($dom[$key][
'style'][
'display'])) ==
'none');
16536 if (isset($dom[$key][
'style'][
'font-family'])) {
16537 $dom[$key][
'fontname'] = $this->
getFontFamilyName($dom[$key][
'style'][
'font-family']);
16540 if (isset($dom[$key][
'style'][
'list-style-type'])) {
16541 $dom[$key][
'listtype'] = trim(strtolower($dom[$key][
'style'][
'list-style-type']));
16542 if ($dom[$key][
'listtype'] ==
'inherit') {
16543 $dom[$key][
'listtype'] = $dom[$parentkey][
'listtype'];
16547 if (isset($dom[$key][
'style'][
'text-indent'])) {
16548 $dom[$key][
'text-indent'] = $this->
getHTMLUnitToUnits($dom[$key][
'style'][
'text-indent']);
16549 if ($dom[$key][
'text-indent'] ==
'inherit') {
16550 $dom[$key][
'text-indent'] = $dom[$parentkey][
'text-indent'];
16554 if (isset($dom[$key][
'style'][
'text-transform'])) {
16555 $dom[$key][
'text-transform'] = $dom[$key][
'style'][
'text-transform'];
16558 if (isset($dom[$key][
'style'][
'font-size'])) {
16559 $fsize = trim($dom[$key][
'style'][
'font-size']);
16560 $dom[$key][
'fontsize'] = $this->
getHTMLFontUnits($fsize, $dom[0][
'fontsize'], $dom[$parentkey][
'fontsize'],
'pt');
16563 if (isset($dom[$key][
'style'][
'font-stretch'])) {
16564 $dom[$key][
'font-stretch'] = $this->
getCSSFontStretching($dom[$key][
'style'][
'font-stretch'], $dom[$parentkey][
'font-stretch']);
16567 if (isset($dom[$key][
'style'][
'letter-spacing'])) {
16568 $dom[$key][
'letter-spacing'] = $this->
getCSSFontSpacing($dom[$key][
'style'][
'letter-spacing'], $dom[$parentkey][
'letter-spacing']);
16571 if (isset($dom[$key][
'style'][
'line-height'])) {
16572 $lineheight = trim($dom[$key][
'style'][
'line-height']);
16573 switch ($lineheight) {
16576 $dom[$key][
'line-height'] = $dom[0][
'line-height'];
16580 $dom[$key][
'line-height'] = $dom[$parentkey][
'line-height'];
16583 if (is_numeric($lineheight)) {
16585 $lineheight = ($lineheight * 100).
'%';
16588 if (substr($lineheight, -1) !==
'%') {
16589 $dom[$key][
'line-height'] = (($dom[$key][
'line-height'] - $this->cell_padding[
'T'] - $this->cell_padding[
'B']) / $dom[$key][
'fontsize']);
16595 if (isset($dom[$key][
'style'][
'font-weight'])) {
16596 if (strtolower($dom[$key][
'style'][
'font-weight']{0}) ==
'n') {
16597 if (strpos($dom[$key][
'fontstyle'],
'B') !==
false) {
16598 $dom[$key][
'fontstyle'] = str_replace(
'B',
'', $dom[$key][
'fontstyle']);
16600 } elseif (strtolower($dom[$key][
'style'][
'font-weight']{0}) ==
'b') {
16601 $dom[$key][
'fontstyle'] .=
'B';
16604 if (isset($dom[$key][
'style'][
'font-style']) AND (strtolower($dom[$key][
'style'][
'font-style']{0}) ==
'i')) {
16605 $dom[$key][
'fontstyle'] .=
'I';
16610 } elseif ($dom[$key][
'value'] ==
'a') {
16614 if (isset($dom[$key][
'style'][
'background-color']) AND (!
TCPDF_STATIC::empty_string($dom[$key][
'style'][
'background-color']))) {
16618 if (isset($dom[$key][
'style'][
'text-decoration'])) {
16619 $decors = explode(
' ', strtolower($dom[$key][
'style'][
'text-decoration']));
16620 foreach ($decors as $dec) {
16623 if ($dec{0} ==
'u') {
16625 $dom[$key][
'fontstyle'] .=
'U';
16626 } elseif ($dec{0} ==
'l') {
16628 $dom[$key][
'fontstyle'] .=
'D';
16629 } elseif ($dec{0} ==
'o') {
16631 $dom[$key][
'fontstyle'] .=
'O';
16635 } elseif ($dom[$key][
'value'] ==
'a') {
16639 if (isset($dom[$key][
'style'][
'width'])) {
16640 $dom[$key][
'width'] = $dom[$key][
'style'][
'width'];
16643 if (isset($dom[$key][
'style'][
'height'])) {
16644 $dom[$key][
'height'] = $dom[$key][
'style'][
'height'];
16647 if (isset($dom[$key][
'style'][
'text-align'])) {
16648 $dom[$key][
'align'] = strtoupper($dom[$key][
'style'][
'text-align']{0});
16651 if (isset($dom[$key][
'style'][
'border'])) {
16653 if (!empty($borderstyle)) {
16654 $dom[$key][
'border'][
'LTRB'] = $borderstyle;
16657 if (isset($dom[$key][
'style'][
'border-color'])) {
16658 $brd_colors = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-color']));
16659 if (isset($brd_colors[3])) {
16662 if (isset($brd_colors[1])) {
16665 if (isset($brd_colors[0])) {
16668 if (isset($brd_colors[2])) {
16672 if (isset($dom[$key][
'style'][
'border-width'])) {
16673 $brd_widths = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-width']));
16674 if (isset($brd_widths[3])) {
16677 if (isset($brd_widths[1])) {
16680 if (isset($brd_widths[0])) {
16683 if (isset($brd_widths[2])) {
16687 if (isset($dom[$key][
'style'][
'border-style'])) {
16688 $brd_styles = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-style']));
16689 if (isset($brd_styles[3]) AND ($brd_styles[3]!=
'none')) {
16690 $dom[$key][
'border'][
'L'][
'cap'] =
'square';
16691 $dom[$key][
'border'][
'L'][
'join'] =
'miter';
16693 if ($dom[$key][
'border'][
'L'][
'dash'] < 0) {
16694 $dom[$key][
'border'][
'L'] = array();
16697 if (isset($brd_styles[1])) {
16698 $dom[$key][
'border'][
'R'][
'cap'] =
'square';
16699 $dom[$key][
'border'][
'R'][
'join'] =
'miter';
16701 if ($dom[$key][
'border'][
'R'][
'dash'] < 0) {
16702 $dom[$key][
'border'][
'R'] = array();
16705 if (isset($brd_styles[0])) {
16706 $dom[$key][
'border'][
'T'][
'cap'] =
'square';
16707 $dom[$key][
'border'][
'T'][
'join'] =
'miter';
16709 if ($dom[$key][
'border'][
'T'][
'dash'] < 0) {
16710 $dom[$key][
'border'][
'T'] = array();
16713 if (isset($brd_styles[2])) {
16714 $dom[$key][
'border'][
'B'][
'cap'] =
'square';
16715 $dom[$key][
'border'][
'B'][
'join'] =
'miter';
16717 if ($dom[$key][
'border'][
'B'][
'dash'] < 0) {
16718 $dom[$key][
'border'][
'B'] = array();
16722 $cellside = array(
'L' =>
'left',
'R' =>
'right',
'T' =>
'top',
'B' =>
'bottom');
16723 foreach ($cellside as $bsk => $bsv) {
16724 if (isset($dom[$key][
'style'][
'border-'.$bsv])) {
16726 if (!empty($borderstyle)) {
16727 $dom[$key][
'border'][$bsk] = $borderstyle;
16730 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-color'])) {
16733 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-width'])) {
16734 $dom[$key][
'border'][$bsk][
'width'] = $this->
getCSSBorderWidth($dom[$key][
'style'][
'border-'.$bsv.
'-width']);
16736 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-style'])) {
16737 $dom[$key][
'border'][$bsk][
'dash'] = $this->
getCSSBorderDashStyle($dom[$key][
'style'][
'border-'.$bsv.
'-style']);
16738 if ($dom[$key][
'border'][$bsk][
'dash'] < 0) {
16739 $dom[$key][
'border'][$bsk] = array();
16744 if (isset($dom[$key][
'style'][
'padding'])) {
16745 $dom[$key][
'padding'] = $this->
getCSSPadding($dom[$key][
'style'][
'padding']);
16749 foreach ($cellside as $psk => $psv) {
16750 if (isset($dom[$key][
'style'][
'padding-'.$psv])) {
16751 $dom[$key][
'padding'][$psk] = $this->
getHTMLUnitToUnits($dom[$key][
'style'][
'padding-'.$psv], 0,
'px',
false);
16755 if (isset($dom[$key][
'style'][
'margin'])) {
16756 $dom[$key][
'margin'] = $this->
getCSSMargin($dom[$key][
'style'][
'margin']);
16760 foreach ($cellside as $psk => $psv) {
16761 if (isset($dom[$key][
'style'][
'margin-'.$psv])) {
16762 $dom[$key][
'margin'][$psk] = $this->
getHTMLUnitToUnits(str_replace(
'auto',
'0', $dom[$key][
'style'][
'margin-'.$psv]), 0,
'px',
false);
16766 if (isset($dom[$key][
'style'][
'border-spacing'])) {
16767 $dom[$key][
'border-spacing'] = $this->
getCSSBorderMargin($dom[$key][
'style'][
'border-spacing']);
16770 if (isset($dom[$key][
'style'][
'page-break-inside']) AND ($dom[$key][
'style'][
'page-break-inside'] ==
'avoid')) {
16771 $dom[$key][
'attribute'][
'nobr'] =
'true';
16774 if (isset($dom[$key][
'style'][
'page-break-before'])) {
16775 if ($dom[$key][
'style'][
'page-break-before'] ==
'always') {
16776 $dom[$key][
'attribute'][
'pagebreak'] =
'true';
16777 } elseif ($dom[$key][
'style'][
'page-break-before'] ==
'left') {
16778 $dom[$key][
'attribute'][
'pagebreak'] =
'left';
16779 } elseif ($dom[$key][
'style'][
'page-break-before'] ==
'right') {
16780 $dom[$key][
'attribute'][
'pagebreak'] =
'right';
16784 if (isset($dom[$key][
'style'][
'page-break-after'])) {
16785 if ($dom[$key][
'style'][
'page-break-after'] ==
'always') {
16786 $dom[$key][
'attribute'][
'pagebreakafter'] =
'true';
16787 } elseif ($dom[$key][
'style'][
'page-break-after'] ==
'left') {
16788 $dom[$key][
'attribute'][
'pagebreakafter'] =
'left';
16789 } elseif ($dom[$key][
'style'][
'page-break-after'] ==
'right') {
16790 $dom[$key][
'attribute'][
'pagebreakafter'] =
'right';
16794 if (isset($dom[$key][
'attribute'][
'display'])) {
16795 $dom[$key][
'hide'] = (trim(strtolower($dom[$key][
'attribute'][
'display'])) ==
'none');
16797 if (isset($dom[$key][
'attribute'][
'border']) AND ($dom[$key][
'attribute'][
'border'] != 0)) {
16798 $borderstyle = $this->
getCSSBorderStyle($dom[$key][
'attribute'][
'border'].
' solid black');
16799 if (!empty($borderstyle)) {
16800 $dom[$key][
'border'][
'LTRB'] = $borderstyle;
16804 if ($dom[$key][
'value'] ==
'font') {
16806 if (isset($dom[$key][
'attribute'][
'face'])) {
16807 $dom[$key][
'fontname'] = $this->
getFontFamilyName($dom[$key][
'attribute'][
'face']);
16810 if (isset($dom[$key][
'attribute'][
'size'])) {
16812 if ($dom[$key][
'attribute'][
'size']{0} ==
'+') {
16813 $dom[$key][
'fontsize'] = $dom[($dom[$key][
'parent'])][
'fontsize'] + intval(substr($dom[$key][
'attribute'][
'size'], 1));
16814 } elseif ($dom[$key][
'attribute'][
'size']{0} ==
'-') {
16815 $dom[$key][
'fontsize'] = $dom[($dom[$key][
'parent'])][
'fontsize'] - intval(substr($dom[$key][
'attribute'][
'size'], 1));
16817 $dom[$key][
'fontsize'] = intval($dom[$key][
'attribute'][
'size']);
16820 $dom[$key][
'fontsize'] = intval($dom[$key][
'attribute'][
'size']);
16825 if ((($dom[$key][
'value'] ==
'ul') OR ($dom[$key][
'value'] ==
'ol') OR ($dom[$key][
'value'] ==
'dl'))
16828 $dom[$key][
'align'] =
'R';
16830 $dom[$key][
'align'] =
'L';
16833 if (($dom[$key][
'value'] ==
'small') OR ($dom[$key][
'value'] ==
'sup') OR ($dom[$key][
'value'] ==
'sub')) {
16834 if (!isset($dom[$key][
'attribute'][
'size']) AND !isset($dom[$key][
'style'][
'font-size'])) {
16835 $dom[$key][
'fontsize'] = $dom[$key][
'fontsize'] *
K_SMALL_RATIO;
16838 if (($dom[$key][
'value'] ==
'strong') OR ($dom[$key][
'value'] ==
'b')) {
16839 $dom[$key][
'fontstyle'] .=
'B';
16841 if (($dom[$key][
'value'] ==
'em') OR ($dom[$key][
'value'] ==
'i')) {
16842 $dom[$key][
'fontstyle'] .=
'I';
16844 if ($dom[$key][
'value'] ==
'u') {
16845 $dom[$key][
'fontstyle'] .=
'U';
16847 if (($dom[$key][
'value'] ==
'del') OR ($dom[$key][
'value'] ==
's') OR ($dom[$key][
'value'] ==
'strike')) {
16848 $dom[$key][
'fontstyle'] .=
'D';
16850 if (!isset($dom[$key][
'style'][
'text-decoration']) AND ($dom[$key][
'value'] ==
'a')) {
16853 if (($dom[$key][
'value'] ==
'pre') OR ($dom[$key][
'value'] ==
'tt')) {
16856 if (!empty($dom[$key][
'value']) AND ($dom[$key][
'value']{0} ==
'h') AND (intval($dom[$key][
'value']{1}) > 0) AND (intval($dom[$key][
'value']{1}) < 7)) {
16858 if (!isset($dom[$key][
'attribute'][
'size']) AND !isset($dom[$key][
'style'][
'font-size'])) {
16859 $headsize = (4 - intval($dom[$key][
'value']{1})) * 2;
16860 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'] + $headsize;
16862 if (!isset($dom[$key][
'style'][
'font-weight'])) {
16863 $dom[$key][
'fontstyle'] .=
'B';
16866 if (($dom[$key][
'value'] ==
'table')) {
16867 $dom[$key][
'rows'] = 0;
16868 $dom[$key][
'trids'] = array();
16869 $dom[$key][
'thead'] =
'';
16871 if (($dom[$key][
'value'] ==
'tr')) {
16872 $dom[$key][
'cols'] = 0;
16874 $dom[$key][
'thead'] =
true;
16877 $dom[$key][
'thead'] =
false;
16879 ++$dom[($dom[$key][
'parent'])][
'rows'];
16881 array_push($dom[($dom[$key][
'parent'])][
'trids'], $key);
16884 if (($dom[$key][
'value'] ==
'th') OR ($dom[$key][
'value'] ==
'td')) {
16885 if (isset($dom[$key][
'attribute'][
'colspan'])) {
16886 $colspan = intval($dom[$key][
'attribute'][
'colspan']);
16890 $dom[$key][
'attribute'][
'colspan'] = $colspan;
16891 $dom[($dom[$key][
'parent'])][
'cols'] += $colspan;
16894 if (isset($dom[$key][
'attribute'][
'dir'])) {
16895 $dom[$key][
'dir'] = $dom[$key][
'attribute'][
'dir'];
16900 } elseif (!isset($dom[$key][
'style'][
'color']) AND ($dom[$key][
'value'] ==
'a')) {
16908 if (isset($dom[$key][
'attribute'][
'strokecolor']) AND (!
TCPDF_STATIC::empty_string($dom[$key][
'attribute'][
'strokecolor']))) {
16912 if (isset($dom[$key][
'attribute'][
'width'])) {
16913 $dom[$key][
'width'] = $dom[$key][
'attribute'][
'width'];
16916 if (isset($dom[$key][
'attribute'][
'height'])) {
16917 $dom[$key][
'height'] = $dom[$key][
'attribute'][
'height'];
16920 if (isset($dom[$key][
'attribute'][
'align']) AND (!
TCPDF_STATIC::empty_string($dom[$key][
'attribute'][
'align'])) AND ($dom[$key][
'value'] !==
'img')) {
16921 $dom[$key][
'align'] = strtoupper($dom[$key][
'attribute'][
'align']{0});
16924 if (isset($dom[$key][
'attribute'][
'stroke'])) {
16926 $dom[$key][
'stroke'] = $this->
getHTMLUnitToUnits($dom[$key][
'attribute'][
'stroke'], $dom[$key][
'fontsize'],
'pt',
true);
16928 if (isset($dom[$key][
'attribute'][
'fill'])) {
16930 if ($dom[$key][
'attribute'][
'fill'] ==
'true') {
16931 $dom[$key][
'fill'] =
true;
16933 $dom[$key][
'fill'] =
false;
16936 if (isset($dom[$key][
'attribute'][
'clip'])) {
16938 if ($dom[$key][
'attribute'][
'clip'] ==
'true') {
16939 $dom[$key][
'clip'] =
true;
16941 $dom[$key][
'clip'] =
false;
16947 $dom[$key][
'tag'] =
false;
16948 $dom[$key][
'block'] =
false;
16949 $dom[$key][
'parent'] = end($level);
16950 $dom[$key][
'dir'] = $dom[$dom[$key][
'parent']][
'dir'];
16951 if (!empty($dom[$dom[$key][
'parent']][
'text-transform'])) {
16953 if (function_exists(
'mb_convert_case')) {
16954 $ttm = array(
'capitalize' => MB_CASE_TITLE,
'uppercase' => MB_CASE_UPPER,
'lowercase' => MB_CASE_LOWER);
16955 if (isset($ttm[$dom[$dom[$key][
'parent']][
'text-transform']])) {
16956 $element = mb_convert_case($element, $ttm[$dom[$dom[$key][
'parent']][
'text-transform']], $this->encoding);
16958 } elseif (!$this->isunicode) {
16959 switch ($dom[$dom[$key][
'parent']][
'text-transform']) {
16960 case 'capitalize': {
16961 $element = ucwords(strtolower($element));
16964 case 'uppercase': {
16965 $element = strtoupper($element);
16968 case 'lowercase': {
16969 $element = strtolower($element);
16975 $dom[$key][
'value'] = stripslashes($this->
unhtmlentities($element));
16991 $spacestr = chr(32);
16993 $spacestr = chr(0).chr(32);
17032 public function writeHTMLCell(
$w,
$h,
$x,
$y, $html=
'', $border=0, $ln=0, $fill=
false, $reseth=
true, $align=
'', $autopadding=
true) {
17033 return $this->
MultiCell(
$w,
$h, $html, $border, $align, $fill, $ln,
$x,
$y, $reseth, 0,
true, $autopadding, 0,
'T',
false);
17049 public function writeHTML($html, $ln=
true, $fill=
false, $reseth=
false, $cell=
false, $align=
'') {
17060 $curfontascent = $this->
getFontAscent($curfontname, $curfontstyle, $curfontsize);
17061 $curfontdescent = $this->
getFontDescent($curfontname, $curfontstyle, $curfontsize);
17064 $this->newline =
true;
17068 $maxbottomliney = 0;
17074 $this_method_vars = array();
17076 $fontaligned =
false;
17077 $reverse_dir =
false;
17078 $this->premode =
false;
17079 if ($this->inxobj) {
17081 $pask = count($this->xobjects[$this->xobjid][
'annotations']);
17082 } elseif (isset($this->PageAnnots[$this->page])) {
17083 $pask = count($this->PageAnnots[$this->page]);
17087 if ($this->inxobj) {
17089 $startlinepos = strlen($this->xobjects[$this->xobjid][
'outdata']);
17090 } elseif (!$this->InFooter) {
17091 if (isset($this->footerlen[$this->page])) {
17108 $w -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
17111 $this->x -= $this->cell_padding[
'R'];
17112 $this->lMargin += $this->cell_padding[
'R'];
17114 $this->x += $this->cell_padding[
'L'];
17115 $this->rMargin += $this->cell_padding[
'L'];
17118 if ($this->customlistindent >= 0) {
17123 $this->listindentlevel = 0;
17130 $this->listnum = 0;
17131 $this->listordered = array();
17132 $this->listcount = array();
17133 $this->lispacer =
'';
17139 $maxel = count($dom);
17141 while ($key < $maxel) {
17142 if ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND $dom[$key][
'hide']) {
17144 $hidden_node_key = $key;
17145 if ($dom[$key][
'self']) {
17150 while (($key < $maxel) AND (!$dom[$key][
'tag'] OR $dom[$key][
'opening'] OR ($dom[$key][
'parent'] != $hidden_node_key))) {
17157 if ($dom[$key][
'tag'] AND isset($dom[$key][
'attribute'][
'pagebreak'])) {
17159 if (($dom[$key][
'attribute'][
'pagebreak'] ==
'true') OR ($dom[$key][
'attribute'][
'pagebreak'] ==
'left') OR ($dom[$key][
'attribute'][
'pagebreak'] ==
'right')) {
17162 $this->htmlvspace = ($this->PageBreakTrigger + 1);
17164 if ((($dom[$key][
'attribute'][
'pagebreak'] ==
'left') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
17165 OR (($dom[$key][
'attribute'][
'pagebreak'] ==
'right') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
17168 $this->htmlvspace = ($this->PageBreakTrigger + 1);
17171 if ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND isset($dom[$key][
'attribute'][
'nobr']) AND ($dom[$key][
'attribute'][
'nobr'] ==
'true')) {
17172 if (isset($dom[($dom[$key][
'parent'])][
'attribute'][
'nobr']) AND ($dom[($dom[$key][
'parent'])][
'attribute'][
'nobr'] ==
'true')) {
17173 $dom[$key][
'attribute'][
'nobr'] =
false;
17178 $this_method_vars[
'html'] = $html;
17179 $this_method_vars[
'ln'] = $ln;
17180 $this_method_vars[
'fill'] = $fill;
17181 $this_method_vars[
'reseth'] = $reseth;
17182 $this_method_vars[
'cell'] = $cell;
17183 $this_method_vars[
'align'] = $align;
17184 $this_method_vars[
'gvars'] = $gvars;
17185 $this_method_vars[
'prevPage'] = $prevPage;
17186 $this_method_vars[
'prev_cell_margin'] = $prev_cell_margin;
17187 $this_method_vars[
'prev_cell_padding'] = $prev_cell_padding;
17188 $this_method_vars[
'prevlMargin'] = $prevlMargin;
17189 $this_method_vars[
'prevrMargin'] = $prevrMargin;
17190 $this_method_vars[
'curfontname'] = $curfontname;
17191 $this_method_vars[
'curfontstyle'] = $curfontstyle;
17192 $this_method_vars[
'curfontsize'] = $curfontsize;
17193 $this_method_vars[
'curfontascent'] = $curfontascent;
17194 $this_method_vars[
'curfontdescent'] = $curfontdescent;
17195 $this_method_vars[
'curfontstretcing'] = $curfontstretcing;
17196 $this_method_vars[
'curfonttracking'] = $curfonttracking;
17197 $this_method_vars[
'minstartliney'] = $minstartliney;
17198 $this_method_vars[
'maxbottomliney'] = $maxbottomliney;
17199 $this_method_vars[
'yshift'] = $yshift;
17200 $this_method_vars[
'startlinepage'] = $startlinepage;
17201 $this_method_vars[
'startlinepos'] = $startlinepos;
17202 $this_method_vars[
'startlinex'] = $startlinex;
17203 $this_method_vars[
'startliney'] = $startliney;
17204 $this_method_vars[
'newline'] =
$newline;
17205 $this_method_vars[
'loop'] = $loop;
17206 $this_method_vars[
'curpos'] = $curpos;
17207 $this_method_vars[
'pask'] = $pask;
17208 $this_method_vars[
'lalign'] = $lalign;
17209 $this_method_vars[
'plalign'] = $plalign;
17210 $this_method_vars[
'w'] =
$w;
17211 $this_method_vars[
'prev_cell_height_ratio'] = $prev_cell_height_ratio;
17212 $this_method_vars[
'prev_listnum'] = $prev_listnum;
17213 $this_method_vars[
'prev_listordered'] = $prev_listordered;
17214 $this_method_vars[
'prev_listcount'] = $prev_listcount;
17215 $this_method_vars[
'prev_lispacer'] = $prev_lispacer;
17216 $this_method_vars[
'fontaligned'] = $fontaligned;
17217 $this_method_vars[
'key'] = $key;
17218 $this_method_vars[
'dom'] = $dom;
17222 if (($dom[$key][
'value'] ==
'tr') AND isset($dom[$key][
'thead']) AND $dom[$key][
'thead']) {
17223 if (isset($dom[$key][
'parent']) AND isset($dom[$dom[$key][
'parent']][
'thead']) AND !
TCPDF_STATIC::empty_string($dom[$dom[$key][
'parent']][
'thead'])) {
17224 $this->inthead =
true;
17226 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
17228 if (($this->y < $this->start_transaction_y) OR ($this->
checkPageBreak($this->lasth,
'',
false))) {
17233 foreach ($this_method_vars as $vkey => $vval) {
17241 if ((!$this->
checkPageBreak($this->PageBreakTrigger + 1)) AND ($this->y < $pre_y)) {
17246 $this->start_transaction_y =
$this->y;
17248 $this->thead = $tmp_thead;
17250 if (isset($dom[$dom[$key][
'parent']][
'attribute'][
'cellspacing'])) {
17251 $tmp_cellspacing = $this->
getHTMLUnitToUnits($dom[$dom[$key][
'parent']][
'attribute'][
'cellspacing'], 1,
'px');
17252 } elseif (isset($dom[$dom[$key][
'parent']][
'border-spacing'])) {
17253 $tmp_cellspacing = $dom[$dom[$key][
'parent']][
'border-spacing'][
'V'];
17255 $tmp_cellspacing = 0;
17257 $dom[$dom[$key][
'parent']][
'borderposition'][
'page'] =
$this->page;
17259 $dom[$dom[$key][
'parent']][
'borderposition'][
'y'] = $this->y + $tmp_cellspacing;
17260 $xoffset = ($this->x - $dom[$dom[$key][
'parent']][
'borderposition'][
'x']);
17261 $dom[$dom[$key][
'parent']][
'borderposition'][
'x'] += $xoffset;
17262 $dom[$dom[$key][
'parent']][
'borderposition'][
'xmax'] += $xoffset;
17264 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
17268 while ( ($key < $maxel) AND (!(
17269 ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'tr') AND (!isset($dom[$key][
'thead']) OR !$dom[$key][
'thead']))
17270 OR ($dom[$key][
'tag'] AND (!$dom[$key][
'opening']) AND ($dom[$key][
'value'] ==
'table'))) )) {
17274 if ($dom[$key][
'tag'] OR ($key == 0)) {
17275 if ((($dom[$key][
'value'] ==
'table') OR ($dom[$key][
'value'] ==
'tr')) AND (isset($dom[$key][
'align']))) {
17276 $dom[$key][
'align'] = (
$this->rtl) ?
'R' :
'L';
17279 if ((!$this->newline) AND ($dom[$key][
'value'] ==
'img') AND (isset($dom[$key][
'height'])) AND ($dom[$key][
'height'] > 0)) {
17282 $autolinebreak =
false;
17283 if (isset($dom[$key][
'width']) AND ($dom[$key][
'width'] > 0)) {
17285 if (($imgw <= ($this->w - $this->lMargin - $this->rMargin - $this->cell_padding[
'L'] - $this->cell_padding[
'R']))
17286 AND ((($this->rtl) AND (($this->x - $imgw) < ($this->lMargin + $this->cell_padding[
'L'])))
17287 OR ((!$this->rtl) AND (($this->x + $imgw) > ($this->w - $this->rMargin - $this->cell_padding[
'R']))))) {
17289 $autolinebreak =
true;
17290 $this->
Ln(
'', $cell);
17291 if ((!$dom[($key-1)][
'tag']) AND ($dom[($key-1)][
'value'] ==
' ')) {
17297 if (!$autolinebreak) {
17306 if ($this->page > $startlinepage) {
17308 if (isset($this->footerlen[$startlinepage])) {
17309 $curpos = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17313 $linebeg = substr($pagebuff, $startlinepos, ($curpos - $startlinepos));
17314 $tstart = substr($pagebuff, 0, $startlinepos);
17315 $tend = substr($this->
getPageBuffer($startlinepage), $curpos);
17319 $tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
17320 $tend = substr($pagebuff, $this->cntmrk[$this->page]);
17322 $yshift = ($minstartliney -
$this->y);
17323 if ($fontaligned) {
17324 $yshift += ($curfontsize /
$this->k);
17326 $try = sprintf(
'1 0 0 1 0 %F cm', ($yshift * $this->k));
17327 $this->
setPageBuffer($this->page, $tstart.
"\nq\n".$try.
"\n".$linebeg.
"\nQ\n".$tend);
17329 if (isset($this->PageAnnots[$this->page])) {
17330 $next_pask = count($this->PageAnnots[$this->page]);
17334 if (isset($this->PageAnnots[$startlinepage])) {
17335 foreach ($this->PageAnnots[$startlinepage] as $pak => $pac) {
17336 if ($pak >= $pask) {
17338 unset($this->PageAnnots[$startlinepage][$pak]);
17339 $npak = count($this->PageAnnots[$this->page]) - 1;
17340 $this->PageAnnots[
$this->page][$npak][
'y'] -= $yshift;
17344 $pask = $next_pask;
17348 $this->newline =
false;
17350 $this->y += (($this->
getCellHeight($curfontsize / $this->k) + $curfontascent - $curfontdescent) / 2) - $imgh;
17351 $minstartliney = min($this->y, $minstartliney);
17352 $maxbottomliney = ($startliney + $this->
getCellHeight($this->FontSize));
17354 } elseif (isset($dom[$key][
'fontname']) OR isset($dom[$key][
'fontstyle']) OR isset($dom[$key][
'fontsize']) OR isset($dom[$key][
'line-height'])) {
17356 $pfontname = $curfontname;
17357 $pfontstyle = $curfontstyle;
17358 $pfontsize = $curfontsize;
17359 $fontname = (isset($dom[$key][
'fontname']) ? $dom[$key][
'fontname'] : $curfontname);
17360 $fontstyle = (isset($dom[$key][
'fontstyle']) ? $dom[$key][
'fontstyle'] : $curfontstyle);
17361 $fontsize = (isset($dom[$key][
'fontsize']) ? $dom[$key][
'fontsize'] : $curfontsize);
17362 $fontascent = $this->
getFontAscent($fontname, $fontstyle, $fontsize);
17363 $fontdescent = $this->
getFontDescent($fontname, $fontstyle, $fontsize);
17364 if (($fontname != $curfontname) OR ($fontstyle != $curfontstyle) OR ($fontsize != $curfontsize)
17365 OR ($this->cell_height_ratio != $dom[$key][
'line-height'])
17366 OR ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'li')) ) {
17367 if (($key < ($maxel - 1)) AND (
17368 ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'li'))
17369 OR ($this->cell_height_ratio != $dom[$key][
'line-height'])
17370 OR (!$this->newline AND is_numeric($fontsize) AND is_numeric($curfontsize) AND ($fontsize >= 0) AND ($curfontsize >= 0) AND ($fontsize != $curfontsize))
17372 if ($this->page > $startlinepage) {
17374 if (isset($this->footerlen[$startlinepage])) {
17375 $curpos = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17379 $linebeg = substr($pagebuff, $startlinepos, ($curpos - $startlinepos));
17380 $tstart = substr($pagebuff, 0, $startlinepos);
17381 $tend = substr($this->
getPageBuffer($startlinepage), $curpos);
17385 $tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
17386 $tend = substr($pagebuff, $this->cntmrk[$this->page]);
17388 $yshift = ($minstartliney -
$this->y);
17389 $try = sprintf(
'1 0 0 1 0 %F cm', ($yshift * $this->k));
17390 $this->
setPageBuffer($this->page, $tstart.
"\nq\n".$try.
"\n".$linebeg.
"\nQ\n".$tend);
17392 if (isset($this->PageAnnots[$this->page])) {
17393 $next_pask = count($this->PageAnnots[$this->page]);
17397 if (isset($this->PageAnnots[$startlinepage])) {
17398 foreach ($this->PageAnnots[$startlinepage] as $pak => $pac) {
17399 if ($pak >= $pask) {
17401 unset($this->PageAnnots[$startlinepage][$pak]);
17402 $npak = count($this->PageAnnots[$this->page]) - 1;
17403 $this->PageAnnots[
$this->page][$npak][
'y'] -= $yshift;
17407 $pask = $next_pask;
17412 if (!isset($dom[$key][
'line-height'])) {
17415 if (!$dom[$key][
'block']) {
17416 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']))) {
17417 $this->y += (((($curfontsize *
$this->cell_height_ratio) - ($fontsize * $dom[$key][
'line-height'])) / $this->k) + $curfontascent - $fontascent - $curfontdescent + $fontdescent) / 2;
17419 if (($dom[$key][
'value'] !=
'sup') AND ($dom[$key][
'value'] !=
'sub')) {
17420 $current_line_align_data = array($key, $minstartliney, $maxbottomliney);
17421 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)))) {
17422 $minstartliney = min($this->y, $line_align_data[1]);
17423 $maxbottomliney = max(($this->y + $this->
getCellHeight($fontsize / $this->k)), $line_align_data[2]);
17425 $minstartliney = min($this->y, $minstartliney);
17426 $maxbottomliney = max(($this->y + $this->
getCellHeight($fontsize / $this->k)), $maxbottomliney);
17428 $line_align_data = $current_line_align_data;
17431 $this->cell_height_ratio = $dom[$key][
'line-height'];
17432 $fontaligned =
true;
17434 $this->
SetFont($fontname, $fontstyle, $fontsize);
17437 $curfontname = $fontname;
17438 $curfontstyle = $fontstyle;
17439 $curfontsize = $fontsize;
17440 $curfontascent = $fontascent;
17441 $curfontdescent = $fontdescent;
17446 $textfill = isset($dom[$key][
'fill']) ? $dom[$key][
'fill'] : (($this->textrendermode % 2) == 0);
17447 $textclip = isset($dom[$key][
'clip']) ? $dom[$key][
'clip'] : ($this->textrendermode > 3);
17449 if (isset($dom[$key][
'font-stretch']) AND ($dom[$key][
'font-stretch'] !==
false)) {
17452 if (isset($dom[$key][
'letter-spacing']) AND ($dom[$key][
'letter-spacing'] !==
false)) {
17455 if (($plalign ==
'J') AND $dom[$key][
'block']) {
17459 $curpos = $this->pagelen[$startlinepage];
17460 if (isset($dom[$key][
'bgcolor']) AND ($dom[$key][
'bgcolor'] !==
false)) {
17464 $wfill = $fill |
false;
17466 if (isset($dom[$key][
'fgcolor']) AND ($dom[$key][
'fgcolor'] !==
false)) {
17469 if (isset($dom[$key][
'strokecolor']) AND ($dom[$key][
'strokecolor'] !==
false)) {
17472 if (isset($dom[$key][
'align'])) {
17473 $lalign = $dom[$key][
'align'];
17480 if ($this->newline AND (strlen($dom[$key][
'value']) > 0) AND ($dom[$key][
'value'] !=
'td') AND ($dom[$key][
'value'] !=
'th')) {
17482 $fontaligned =
false;
17484 if (isset($startlinex)) {
17485 $yshift = ($minstartliney - $startliney);
17486 if (($yshift > 0) OR ($this->page > $startlinepage)) {
17491 $linew = abs($this->endlinex - $startlinex);
17492 if ($this->inxobj) {
17494 $pstart = substr($this->xobjects[$this->xobjid][
'outdata'], 0, $startlinepos);
17495 if (isset($opentagpos)) {
17496 $midpos = $opentagpos;
17501 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos, ($midpos - $startlinepos));
17502 $pend = substr($this->xobjects[$this->xobjid][
'outdata'], $midpos);
17504 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos);
17508 $pstart = substr($this->
getPageBuffer($startlinepage), 0, $startlinepos);
17509 if (isset($opentagpos) AND isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
17510 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17511 $midpos = min($opentagpos, $this->footerpos[$startlinepage]);
17512 } elseif (isset($opentagpos)) {
17513 $midpos = $opentagpos;
17514 } elseif (isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
17515 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17516 $midpos = $this->footerpos[$startlinepage];
17521 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos, ($midpos - $startlinepos));
17522 $pend = substr($this->
getPageBuffer($startlinepage), $midpos);
17524 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos);
17528 if ((isset($plalign) AND ((($plalign ==
'C') OR ($plalign ==
'J') OR (($plalign ==
'R') AND (!$this->rtl)) OR (($plalign ==
'L') AND ($this->rtl)))))) {
17531 if (($plalign ==
'J') AND $this->
isRTLTextDir() AND ($this->num_columns > 1)) {
17532 $tw += $this->cell_padding[
'R'];
17534 if ($this->lMargin != $prevlMargin) {
17537 if ($this->rMargin != $prevrMargin) {
17546 $pos1 = intval($pos1);
17554 if ($pos1 == $pos2) {
17555 $pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
17556 if (substr($pmid, $pos1, 4) ==
'[()]') {
17557 $linew -= $one_space_width;
17558 } elseif ($pos1 == strpos($pmid,
'[(')) {
17567 $pos1 = intval($pos1);
17575 if ($pos1 == $pos2) {
17576 $pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
17577 $linew -= $one_space_width;
17581 $mdiff = ($tw - $linew);
17582 if ($plalign ==
'C') {
17584 $t_x = -($mdiff / 2);
17586 $t_x = ($mdiff / 2);
17588 } elseif ($plalign ==
'R') {
17591 } elseif ($plalign ==
'L') {
17594 } elseif (($plalign ==
'J') AND ($plalign == $lalign)) {
17603 $pmidtemp = preg_replace(
'/[\\\][\(]/x',
'\\#!#OP#!#', $pmidtemp);
17604 $pmidtemp = preg_replace(
'/[\\\][\)]/x',
'\\#!#CP#!#', $pmidtemp);
17606 if (preg_match_all(
'/\[\(([^\)]*)\)\]/x', $pmidtemp, $lnstring, PREG_PATTERN_ORDER)) {
17608 $maxkk = count($lnstring[1]) - 1;
17609 for ($kk=0; $kk <= $maxkk; ++$kk) {
17611 $lnstring[1][$kk] = str_replace(
'#!#OP#!#',
'(', $lnstring[1][$kk]);
17612 $lnstring[1][$kk] = str_replace(
'#!#CP#!#',
')', $lnstring[1][$kk]);
17614 $lnstring[2][$kk] = substr_count($lnstring[1][$kk], $spacestr);
17616 $ns += $lnstring[2][$kk];
17617 $lnstring[3][$kk] = $ns;
17623 $spacewidth = ($mdiff / ($ns - $no)) *
$this->k;
17624 if ($this->FontSize <= 0) {
17625 $this->FontSize = 1;
17627 $spacewidthu = -1000 * ($mdiff + (($ns + $no) * $one_space_width)) / $ns / $this->FontSize;
17628 if ($this->font_spacing != 0) {
17631 $spacewidthu += $osw;
17638 $prev_epsposbeg = 0;
17643 while (preg_match(
'/([0-9\.\+\-]*)[\s](Td|cm|m|l|c|re)[\s]/x', $pmid, $strpiece, PREG_OFFSET_CAPTURE, $offset) == 1) {
17645 $stroffset = strpos($pmid,
'[(', $offset);
17646 if (($stroffset !==
false) AND ($stroffset <= $strpiece[2][1])) {
17648 $offset = strpos($pmid,
')]', $stroffset);
17649 while (($offset !==
false) AND ($pmid[($offset - 1)] ==
'\\')) {
17650 $offset = strpos($pmid,
')]', ($offset + 1));
17652 if ($offset ===
false) {
17653 $this->
Error(
'HTML Justification: malformed PDF code.');
17658 $spacew = ($spacewidth * ($nsmax - $ns));
17660 $spacew = ($spacewidth * $ns);
17662 $offset = $strpiece[2][1] + strlen($strpiece[2][0]);
17663 $epsposbeg = strpos($pmid,
'q'.$this->epsmarker, $offset);
17664 $epsposend = strpos($pmid, $this->epsmarker.
'Q', $offset) + strlen($this->epsmarker.
'Q');
17665 if ((($epsposbeg > 0) AND ($epsposend > 0) AND ($offset > $epsposbeg) AND ($offset < $epsposend))
17666 OR (($epsposbeg ===
false) AND ($epsposend > 0) AND ($offset < $epsposend))) {
17668 $trx = sprintf(
'1 0 0 1 %F 0 cm', $spacew);
17669 $epsposbeg = strpos($pmid,
'q'.$this->epsmarker, ($prev_epsposbeg - 6));
17670 $pmid_b = substr($pmid, 0, $epsposbeg);
17671 $pmid_m = substr($pmid, $epsposbeg, ($epsposend - $epsposbeg));
17672 $pmid_e = substr($pmid, $epsposend);
17673 $pmid = $pmid_b.
"\nq\n".$trx.
"\n".$pmid_m.
"\nQ\n".$pmid_e;
17674 $offset = $epsposend;
17678 $prev_epsposbeg = $epsposbeg;
17681 switch ($strpiece[2][0]) {
17687 preg_match(
'/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s]('.$strpiece[2][0].
')([\s]*)/x', $pmid, $xmatches);
17688 if (!isset($xmatches[1])) {
17691 $currentxpos = $xmatches[1];
17692 $textpos = $currentxpos;
17693 if (($strcount <= $maxkk) AND ($strpiece[2][0] ==
'Td')) {
17694 $ns = $lnstring[3][$strcount];
17696 $spacew = ($spacewidth * ($nsmax - $ns));
17701 if (preg_match(
'/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s]('.$strpiece[2][0].
')([\s]*)/x', $pmid, $pmatch) == 1) {
17702 $newpmid = sprintf(
'%F',(floatval($pmatch[1]) + $spacew)).
' '.$pmatch[2].
' x*#!#*x'.$pmatch[3].$pmatch[4];
17703 $pmid = str_replace($pmatch[0], $newpmid, $pmid);
17704 unset($pmatch, $newpmid);
17711 $this->lispacer =
'';
17714 preg_match(
'/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s](re)([\s]*)/x', $pmid, $xmatches);
17715 if (!isset($xmatches[1])) {
17718 $currentxpos = $xmatches[1];
17722 if ($currentxpos < $textpos) {
17723 $x_diff = ($spacewidth * ($nsmax - $lnstring[3][$strcount]));
17724 $w_diff = ($spacewidth * $lnstring[2][$strcount]);
17726 if ($strcount > 0) {
17727 $x_diff = ($spacewidth * ($nsmax - $lnstring[3][($strcount - 1)]));
17728 $w_diff = ($spacewidth * $lnstring[2][($strcount - 1)]);
17732 if ($currentxpos > $textpos) {
17733 if ($strcount > 0) {
17734 $x_diff = ($spacewidth * $lnstring[3][($strcount - 1)]);
17736 $w_diff = ($spacewidth * $lnstring[2][$strcount]);
17738 if ($strcount > 1) {
17739 $x_diff = ($spacewidth * $lnstring[3][($strcount - 2)]);
17741 if ($strcount > 0) {
17742 $w_diff = ($spacewidth * $lnstring[2][($strcount - 1)]);
17746 if (preg_match(
'/('.$xmatches[1].
')[\s]('.$xmatches[2].
')[\s]('.$xmatches[3].
')[\s]('.$strpiece[1][0].
')[\s](re)([\s]*)/x', $pmid, $pmatch) == 1) {
17747 $newx = sprintf(
'%F',(floatval($pmatch[1]) + $x_diff));
17748 $neww = sprintf(
'%F',(floatval($pmatch[3]) + $w_diff));
17749 $newpmid = $newx.
' '.$pmatch[2].
' '.$neww.
' '.$pmatch[4].
' x*#!#*x'.$pmatch[5].$pmatch[6];
17750 $pmid = str_replace($pmatch[0], $newpmid, $pmid);
17751 unset($pmatch, $newpmid, $newx, $neww);
17757 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);
17758 if (!isset($xmatches[1])) {
17761 $currentxpos = $xmatches[1];
17763 if (preg_match(
'/('.$xmatches[1].
')[\s]('.$xmatches[2].
')[\s]('.$xmatches[3].
')[\s]('.$xmatches[4].
')[\s]('.$xmatches[5].
')[\s]('.$strpiece[1][0].
')[\s](c)([\s]*)/x', $pmid, $pmatch) == 1) {
17764 $newx1 = sprintf(
'%F',(floatval($pmatch[1]) + $spacew));
17765 $newx2 = sprintf(
'%F',(floatval($pmatch[3]) + $spacew));
17766 $newx3 = sprintf(
'%F',(floatval($pmatch[5]) + $spacew));
17767 $newpmid = $newx1.
' '.$pmatch[2].
' '.$newx2.
' '.$pmatch[4].
' '.$newx3.
' '.$pmatch[6].
' x*#!#*x'.$pmatch[7].$pmatch[8];
17768 $pmid = str_replace($pmatch[0], $newpmid, $pmid);
17769 unset($pmatch, $newpmid, $newx1, $newx2, $newx3);
17775 $cxpos = ($currentxpos /
$this->k);
17776 $lmpos = ($this->lMargin + $this->cell_padding[
'L'] +
$this->feps);
17777 if ($this->inxobj) {
17779 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
17780 if (($pac[
'y'] >= $minstartliney) AND (($pac[
'x'] * $this->k) >= ($currentxpos - $this->feps)) AND (($pac[
'x'] * $this->k) <= ($currentxpos + $this->feps))) {
17781 if ($cxpos > $lmpos) {
17783 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17785 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17790 } elseif (isset($this->PageAnnots[$this->page])) {
17791 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
17792 if (($pac[
'y'] >= $minstartliney) AND (($pac[
'x'] * $this->k) >= ($currentxpos - $this->feps)) AND (($pac[
'x'] * $this->k) <= ($currentxpos + $this->feps))) {
17793 if ($cxpos > $lmpos) {
17795 $this->PageAnnots[
$this->page][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17797 $this->PageAnnots[
$this->page][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17805 $pmid = str_replace(
'x*#!#*x',
'', $pmid);
17808 $spacew = $spacewidthu;
17809 if ($this->font_stretching != 100) {
17811 $spacew /= ($this->font_stretching / 100);
17815 $pmid = preg_replace(
'/[\\\][\(]/x',
'\\#!#OP#!#', $pmid);
17816 $pmid = preg_replace(
'/[\\\][\)]/x',
'\\#!#CP#!#', $pmid);
17817 if (preg_match_all(
'/\[\(([^\)]*)\)\]/x', $pmid, $pamatch) > 0) {
17818 foreach($pamatch[0] as $pk => $pmatch) {
17819 $replace = $pamatch[1][$pk];
17820 $replace = str_replace(
'#!#OP#!#',
'(', $replace);
17821 $replace = str_replace(
'#!#CP#!#',
')', $replace);
17822 $newpmid =
'[('.str_replace(chr(0).chr(32),
') '.sprintf(
'%F', $spacew).
' (', $replace).
')]';
17823 $pos = strpos($pmid, $pmatch, $pos);
17824 if ($pos !== FALSE) {
17825 $pmid = substr_replace($pmid, $newpmid, $pos, strlen($pmatch));
17831 if ($this->inxobj) {
17833 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.
"\n".$pmid.
"\n".$pend;
17835 $this->
setPageBuffer($startlinepage, $pstart.
"\n".$pmid.
"\n".$pend);
17837 $endlinepos = strlen($pstart.
"\n".$pmid.
"\n");
17840 if ($this->font_stretching != 100) {
17842 $spacewidth /= ($this->font_stretching / 100);
17844 $rs = sprintf(
'%F Tw', $spacewidth);
17845 $pmid = preg_replace(
"/\[\(/x", $rs.
' [(', $pmid);
17846 if ($this->inxobj) {
17848 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n".$pend;
17850 $this->
setPageBuffer($startlinepage, $pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n".$pend);
17852 $endlinepos = strlen($pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n");
17857 if (($t_x != 0) OR ($yshift < 0)) {
17859 $trx = sprintf(
'1 0 0 1 %F %F cm', ($t_x * $this->k), ($yshift * $this->k));
17860 $pstart .=
"\nq\n".$trx.
"\n".$pmid.
"\nQ\n";
17861 $endlinepos = strlen($pstart);
17862 if ($this->inxobj) {
17865 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
17866 if ($pak >= $pask) {
17867 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'x'] += $t_x;
17868 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'y'] -= $yshift;
17874 if (isset($this->PageAnnots[$this->page])) {
17875 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
17876 if ($pak >= $pask) {
17877 $this->PageAnnots[
$this->page][$pak][
'x'] += $t_x;
17878 $this->PageAnnots[
$this->page][$pak][
'y'] -= $yshift;
17883 $this->y -= $yshift;
17887 $this->newline =
false;
17890 if ($dom[$dom[$key][
'parent']][
'value'] ==
'sup') {
17892 } elseif ($dom[$dom[$key][
'parent']][
'value'] ==
'sub') {
17893 $startliney -= (($this->FontSizePt / 0.7) /
$this->k);
17895 $minstartliney = $startliney;
17896 $maxbottomliney = ($this->y + $this->
getCellHeight($fontsize / $this->k));
17899 if (isset($endlinepos) AND (!$pbrk)) {
17900 $startlinepos = $endlinepos;
17902 if ($this->inxobj) {
17904 $startlinepos = strlen($this->xobjects[$this->xobjid][
'outdata']);
17905 } elseif (!$this->InFooter) {
17906 if (isset($this->footerlen[$this->page])) {
17916 unset($endlinepos);
17917 $plalign = $lalign;
17918 if (isset($this->PageAnnots[$this->page])) {
17919 $pask = count($this->PageAnnots[$this->page]);
17923 if (!($dom[$key][
'tag'] AND !$dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'table')
17924 AND (isset($this->emptypagemrk[$this->page]))
17925 AND ($this->emptypagemrk[$this->page] == $this->pagelen[$this->page]))) {
17926 $this->
SetFont($fontname, $fontstyle, $fontsize);
17932 if (isset($opentagpos)) {
17933 unset($opentagpos);
17935 if ($dom[$key][
'tag']) {
17936 if ($dom[$key][
'opening']) {
17938 if (isset($dom[$key][
'text-indent']) AND $dom[$key][
'block']) {
17939 $this->textindent = $dom[$key][
'text-indent'];
17940 $this->newline =
true;
17943 if (($dom[$key][
'value'] ==
'table') AND isset($dom[$key][
'cols']) AND ($dom[$key][
'cols'] > 0)) {
17948 $wtmp = $this->w - $this->rMargin -
$this->x;
17951 if (isset($dom[$key][
'attribute'][
'cellspacing'])) {
17953 $cellspacing = array(
'H' => $clsp,
'V' => $clsp);
17954 } elseif (isset($dom[$key][
'border-spacing'])) {
17955 $cellspacing = $dom[$key][
'border-spacing'];
17957 $cellspacing = array(
'H' => 0,
'V' => 0);
17960 if (isset($dom[$key][
'width'])) {
17963 $table_width = $wtmp;
17965 $table_width -= (2 * $cellspacing[
'H']);
17966 if (!$this->inthead) {
17967 $this->y += $cellspacing[
'V'];
17970 $cellspacingx = -$cellspacing[
'H'];
17972 $cellspacingx = $cellspacing[
'H'];
17975 $table_columns_width = ($table_width - ($cellspacing[
'H'] * ($dom[$key][
'cols'] - 1)));
17977 $table_min_column_width = ($table_columns_width / $dom[$key][
'cols']);
17979 $table_colwidths = array_fill(0, $dom[$key][
'cols'], $table_min_column_width);
17982 if ($dom[$key][
'value'] ==
'tr') {
17987 if (($dom[$key][
'value'] ==
'td') OR ($dom[$key][
'value'] ==
'th')) {
17988 $trid = $dom[$key][
'parent'];
17989 $table_el = $dom[$trid][
'parent'];
17990 if (!isset($dom[$table_el][
'cols'])) {
17991 $dom[$table_el][
'cols'] = $dom[$trid][
'cols'];
17995 if (isset($dom[$key][
'border']) AND !empty($dom[$key][
'border'])) {
17996 $tdborder = $dom[$key][
'border'];
17998 $colspan = intval($dom[$key][
'attribute'][
'colspan']);
17999 if ($colspan <= 0) {
18003 if (isset($dom[($dom[$trid][
'parent'])][
'attribute'][
'cellpadding'])) {
18004 $crclpd = $this->
getHTMLUnitToUnits($dom[($dom[$trid][
'parent'])][
'attribute'][
'cellpadding'], 1,
'px');
18005 $current_cell_padding = array(
'L' => $crclpd,
'T' => $crclpd,
'R' => $crclpd,
'B' => $crclpd);
18006 } elseif (isset($dom[($dom[$trid][
'parent'])][
'padding'])) {
18007 $current_cell_padding = $dom[($dom[$trid][
'parent'])][
'padding'];
18009 $current_cell_padding = array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0);
18011 $this->cell_padding = $current_cell_padding;
18012 if (isset($dom[$key][
'height'])) {
18018 if (isset($dom[$key][
'content'])) {
18019 $cell_content = stripslashes($dom[$key][
'content']);
18021 $cell_content =
' ';
18023 $tagtype = $dom[$key][
'value'];
18025 while (($key < $maxel) AND (!(($dom[$key][
'tag']) AND (!$dom[$key][
'opening']) AND ($dom[$key][
'value'] == $tagtype) AND ($dom[$key][
'parent'] == $parentid)))) {
18029 if (!isset($dom[$trid][
'startpage'])) {
18032 $this->
setPage($dom[$trid][
'startpage']);
18034 if (!isset($dom[$trid][
'startcolumn'])) {
18036 } elseif ($this->current_column != $dom[$trid][
'startcolumn']) {
18041 if (!isset($dom[$trid][
'starty'])) {
18044 $this->y = $dom[$trid][
'starty'];
18046 if (!isset($dom[$trid][
'startx'])) {
18048 $this->x += $cellspacingx;
18050 $this->x += ($cellspacingx / 2);
18052 if (isset($dom[$parentid][
'attribute'][
'rowspan'])) {
18053 $rowspan = intval($dom[$parentid][
'attribute'][
'rowspan']);
18058 if (isset($dom[$table_el][
'rowspans'])) {
18060 $rskmax = count($dom[$table_el][
'rowspans']);
18061 while ($rsk < $rskmax) {
18062 $trwsp = $dom[$table_el][
'rowspans'][$rsk];
18063 $rsstartx = $trwsp[
'startx'];
18064 $rsendx = $trwsp[
'endx'];
18066 if ($trwsp[
'startpage'] < $this->page) {
18067 if (($this->rtl) AND ($this->pagedim[$this->page][
'orm'] != $this->pagedim[$trwsp[
'startpage']][
'orm'])) {
18068 $dl = ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$trwsp[
'startpage']][
'orm']);
18071 } elseif ((!$this->rtl) AND ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$trwsp[
'startpage']][
'olm'])) {
18072 $dl = ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$trwsp[
'startpage']][
'olm']);
18077 if (($trwsp[
'rowspan'] > 0)
18078 AND ($rsstartx > ($this->x - $cellspacing[
'H'] - $current_cell_padding[
'L'] - $this->feps))
18079 AND ($rsstartx < ($this->x + $cellspacing[
'H'] + $current_cell_padding[
'R'] + $this->feps))
18080 AND (($trwsp[
'starty'] < ($this->y - $this->feps)) OR ($trwsp[
'startpage'] < $this->page) OR ($trwsp[
'startcolumn'] < $this->current_column))) {
18082 $this->x = $rsendx + $cellspacingx;
18084 $colid += $trwsp[
'colspan'];
18085 if (($trwsp[
'rowspan'] == 1)
18086 AND (isset($dom[$trid][
'endy']))
18087 AND (isset($dom[$trid][
'endpage']))
18088 AND (isset($dom[$trid][
'endcolumn']))
18089 AND ($trwsp[
'endpage'] == $dom[$trid][
'endpage'])
18090 AND ($trwsp[
'endcolumn'] == $dom[$trid][
'endcolumn'])) {
18092 $dom[$table_el][
'rowspans'][$rsk][
'endy'] = max($dom[$trid][
'endy'], $trwsp[
'endy']);
18093 $dom[$trid][
'endy'] = $dom[$table_el][
'rowspans'][$rsk][
'endy'];
18101 if (isset($dom[$parentid][
'width'])) {
18103 $cellw = $this->
getHTMLUnitToUnits($dom[$parentid][
'width'], $table_columns_width,
'px');
18104 $tmpcw = ($cellw / $colspan);
18105 for ($i = 0; $i < $colspan; ++$i) {
18106 $table_colwidths[($colid + $i)] = $tmpcw;
18111 for ($i = 0; $i < $colspan; ++$i) {
18112 $cellw += $table_colwidths[($colid + $i)];
18115 $cellw += (($colspan - 1) * $cellspacing[
'H']);
18117 $colid += $colspan;
18119 if ($rowspan > 1) {
18120 $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));
18122 $cellid = array_push($dom[$trid][
'cellpos'], array(
'startx' => $this->x));
18123 if ($rowspan > 1) {
18124 $dom[$trid][
'cellpos'][($cellid - 1)][
'rowspanid'] = ($trsid - 1);
18127 if (isset($dom[$parentid][
'bgcolor']) AND ($dom[$parentid][
'bgcolor'] !==
false)) {
18128 $dom[$trid][
'cellpos'][($cellid - 1)][
'bgcolor'] = $dom[$parentid][
'bgcolor'];
18131 if (isset($tdborder) AND !empty($tdborder)) {
18132 $dom[$trid][
'cellpos'][($cellid - 1)][
'border'] = $tdborder;
18141 $this->colxshift[
's'] = $cellspacing;
18142 $this->colxshift[
'p'] = $current_cell_padding;
18144 $this->
MultiCell($cellw, $cellh, $cell_content,
false, $lalign,
false, 2,
'',
'',
true, 0,
true,
true, 0,
'T',
false);
18146 $this->colxshift = array(
'x' => 0,
's' => array(
'H' => 0,
'V' => 0),
'p' => array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0));
18147 $this->lasth = $prevLastH;
18148 $this->cell_padding = $old_cell_padding;
18149 $dom[$trid][
'cellpos'][($cellid - 1)][
'endx'] = $this->x;
18151 if ($rowspan <= 1) {
18152 if (isset($dom[$trid][
'endy'])) {
18153 if (($this->page == $dom[$trid][
'endpage']) AND ($this->current_column == $dom[$trid][
'endcolumn'])) {
18154 $dom[$trid][
'endy'] = max($this->y, $dom[$trid][
'endy']);
18155 } elseif (($this->page > $dom[$trid][
'endpage']) OR ($this->current_column > $dom[$trid][
'endcolumn'])) {
18161 if (isset($dom[$trid][
'endpage'])) {
18162 $dom[$trid][
'endpage'] = max($this->page, $dom[$trid][
'endpage']);
18166 if (isset($dom[$trid][
'endcolumn'])) {
18167 $dom[$trid][
'endcolumn'] = max($this->current_column, $dom[$trid][
'endcolumn']);
18173 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endx'] = $this->x;
18174 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endy'] = $this->y;
18175 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endpage'] = $this->page;
18176 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endcolumn'] = $this->current_column;
18178 if (isset($dom[$table_el][
'rowspans'])) {
18180 foreach ($dom[$table_el][
'rowspans'] as
$k => $trwsp) {
18181 if ($trwsp[
'rowspan'] > 0) {
18182 if (isset($dom[$trid][
'endpage'])) {
18183 if (($trwsp[
'endpage'] == $dom[$trid][
'endpage']) AND ($trwsp[
'endcolumn'] == $dom[$trid][
'endcolumn'])) {
18184 $dom[$table_el][
'rowspans'][
$k][
'endy'] = max($dom[$trid][
'endy'], $trwsp[
'endy']);
18185 } elseif (($trwsp[
'endpage'] < $dom[$trid][
'endpage']) OR ($trwsp[
'endcolumn'] < $dom[$trid][
'endcolumn'])) {
18186 $dom[$table_el][
'rowspans'][
$k][
'endy'] = $dom[$trid][
'endy'];
18187 $dom[$table_el][
'rowspans'][
$k][
'endpage'] = $dom[$trid][
'endpage'];
18188 $dom[$table_el][
'rowspans'][
$k][
'endcolumn'] = $dom[$trid][
'endcolumn'];
18190 $dom[$trid][
'endy'] = $this->pagedim[$dom[$trid][
'endpage']][
'hk'] - $this->pagedim[$dom[$trid][
'endpage']][
'bm'];
18196 $this->x += ($cellspacingx / 2);
18199 if (!isset($opentagpos)) {
18200 if ($this->inxobj) {
18202 $opentagpos = strlen($this->xobjects[$this->xobjid][
'outdata']);
18203 } elseif (!$this->InFooter) {
18204 if (isset($this->footerlen[$this->page])) {
18218 if ($this->bordermrk[$this->page] > $old_bordermrk) {
18219 $startlinepos += ($this->bordermrk[
$this->page] - $old_bordermrk);
18221 if ($prev_numpages > $this->numpages) {
18225 } elseif (strlen($dom[$key][
'value']) > 0) {
18228 $this->
SetFont($pfontname, $pfontstyle, $pfontsize);
18231 $maxbottomliney = ($startliney + $this->
getCellHeight($this->FontSize));
18232 if (is_numeric($pfontsize) AND ($pfontsize > 0)) {
18235 $this->
SetFont($curfontname, $curfontstyle, $curfontsize);
18237 if (is_numeric($pfontsize) AND ($pfontsize > 0) AND is_numeric($curfontsize) AND ($curfontsize > 0) AND ($pfontsize != $curfontsize)) {
18238 $pfontascent = $this->
getFontAscent($pfontname, $pfontstyle, $pfontsize);
18239 $pfontdescent = $this->
getFontDescent($pfontname, $pfontstyle, $pfontsize);
18240 $this->y += ($this->
getCellHeight(($pfontsize - $curfontsize) / $this->k) + $pfontascent - $curfontascent - $pfontdescent + $curfontdescent) / 2;
18241 $minstartliney = min($this->y, $minstartliney);
18242 $maxbottomliney = max(($this->y + $this->
getCellHeight($pfontsize / $this->k)), $maxbottomliney);
18246 $this->htmlvspace = 0;
18251 if (preg_match(
'/^('.$this->re_space[
'p'].
'+)/'.$this->re_space[
'm'], $dom[$key][
'value'], $matches)) {
18252 $lsp = $matches[1];
18254 if (preg_match(
'/('.$this->re_space[
'p'].
'+)$/'.$this->re_space[
'm'], $dom[$key][
'value'], $matches)) {
18255 $rsp = $matches[1];
18257 $dom[$key][
'value'] = $rsp.$this->stringTrim($dom[$key][
'value']).$lsp;
18260 if (!$this->premode) {
18261 $prelen = strlen($dom[$key][
'value']);
18267 $dom[$key][
'value'] = $this->
stringLeftTrim($dom[$key][
'value']);
18269 $postlen = strlen($dom[$key][
'value']);
18270 if (($postlen == 0) AND ($prelen > 0)) {
18271 $dom[$key][
'trimmed_space'] =
true;
18275 $firstblock =
true;
18277 $firstblock =
false;
18279 $dom[$key][
'value'] = preg_replace(
'/^'.$this->re_space[
'p'].
'+$/'.$this->re_space[
'm'], chr(32), $dom[$key][
'value']);
18287 if (!isset($dom[$key][
'trimmed_space']) OR !$dom[$key][
'trimmed_space']) {
18289 if (!empty($this->HREF) AND (isset($this->HREF[
'url']))) {
18292 if (isset($dom[($dom[$key][
'parent'])][
'fgcolor']) AND ($dom[($dom[$key][
'parent'])][
'fgcolor'] !==
false)) {
18293 $hrefcolor = $dom[($dom[$key][
'parent'])][
'fgcolor'];
18296 if (isset($dom[($dom[$key][
'parent'])][
'fontstyle']) AND ($dom[($dom[$key][
'parent'])][
'fontstyle'] !==
false)) {
18297 $hrefstyle = $dom[($dom[$key][
'parent'])][
'fontstyle'];
18299 $strrest = $this->
addHtmlLink($this->HREF[
'url'], $dom[$key][
'value'], $wfill,
true, $hrefcolor, $hrefstyle,
true);
18305 $cwa = ($this->w - $this->rMargin -
$this->x);
18307 if (($strlinelen < $cwa) AND (isset($dom[($key + 1)])) AND ($dom[($key + 1)][
'tag']) AND (!$dom[($key + 1)][
'block'])) {
18309 $nkey = ($key + 1);
18310 $write_block =
true;
18311 $same_textdir =
true;
18315 while ($write_block AND isset($dom[$nkey])) {
18316 if ($dom[$nkey][
'tag']) {
18317 if ($dom[$nkey][
'block']) {
18319 $write_block =
false;
18321 $tmp_fontname = isset($dom[$nkey][
'fontname']) ? $dom[$nkey][
'fontname'] :
$this->FontFamily;
18322 $tmp_fontstyle = isset($dom[$nkey][
'fontstyle']) ? $dom[$nkey][
'fontstyle'] :
$this->FontStyle;
18323 $tmp_fontsize = isset($dom[$nkey][
'fontsize']) ? $dom[$nkey][
'fontsize'] :
$this->FontSizePt;
18324 $same_textdir = ($dom[$nkey][
'dir'] == $dom[$key][
'dir']);
18326 $nextstr =
TCPDF_STATIC::pregSplit(
'/'.$this->re_space[
'p'].
'+/', $this->re_space[
'm'], $dom[$nkey][
'value']);
18327 if (isset($nextstr[0]) AND $same_textdir) {
18328 $wadj += $this->
GetStringWidth($nextstr[0], $tmp_fontname, $tmp_fontstyle, $tmp_fontsize);
18329 if (isset($nextstr[1])) {
18330 $write_block =
false;
18337 if (($wadj > 0) AND (($strlinelen + $wadj) >= $cwa)) {
18340 $numblks = count($nextstr);
18341 if ($numblks > 1) {
18343 $wadj = ($cwa - $strlinelen + $this->
GetStringWidth($nextstr[($numblks - 1)]));
18350 if (($wadj > 0) AND (($this->rtl AND ($this->tmprtl ===
'L')) OR (!$this->rtl AND ($this->tmprtl ===
'R')))) {
18352 $reverse_dir =
true;
18354 $revshift = ($strlinelen + $wadj + 0.000001);
18356 $this->x += $revshift;
18358 $this->x -= $revshift;
18363 $strrest = $this->
Write($this->lasth, $dom[$key][
'value'],
'', $wfill,
'',
false, 0,
true, $firstblock, 0, $wadj);
18365 if ($reverse_dir AND ($wadj == 0)) {
18368 $reverse_dir =
false;
18372 $this->textindent = 0;
18373 if (strlen($strrest) > 0) {
18375 $this->newline =
true;
18376 if ($strrest == $dom[$key][
'value']) {
18382 $dom[$key][
'value'] = $strrest;
18385 $this->x -= $this->cell_padding[
'R'];
18387 $this->x += $this->cell_padding[
'L'];
18396 if ($this->font_spacing > 0) {
18406 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')) {
18408 if ((!$undo) AND (($this->y < $this->start_transaction_y) OR (($dom[$key][
'value'] ==
'tr') AND ($dom[($dom[$key][
'parent'])][
'endy'] < $this->start_transaction_y)))) {
18413 foreach ($this_method_vars as $vkey => $vval) {
18418 if ((!$this->
checkPageBreak($this->PageBreakTrigger + 1)) AND ($this->y < $pre_y)) {
18428 if (isset($startlinex)) {
18429 $yshift = ($minstartliney - $startliney);
18430 if (($yshift > 0) OR ($this->page > $startlinepage)) {
18435 $linew = abs($this->endlinex - $startlinex);
18436 if ($this->inxobj) {
18438 $pstart = substr($this->xobjects[$this->xobjid][
'outdata'], 0, $startlinepos);
18439 if (isset($opentagpos)) {
18440 $midpos = $opentagpos;
18445 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos, ($midpos - $startlinepos));
18446 $pend = substr($this->xobjects[$this->xobjid][
'outdata'], $midpos);
18448 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos);
18452 $pstart = substr($this->
getPageBuffer($startlinepage), 0, $startlinepos);
18453 if (isset($opentagpos) AND isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
18454 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
18455 $midpos = min($opentagpos, $this->footerpos[$startlinepage]);
18456 } elseif (isset($opentagpos)) {
18457 $midpos = $opentagpos;
18458 } elseif (isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
18459 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
18460 $midpos = $this->footerpos[$startlinepage];
18465 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos, ($midpos - $startlinepos));
18466 $pend = substr($this->
getPageBuffer($startlinepage), $midpos);
18468 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos);
18472 if ((isset($plalign) AND ((($plalign ==
'C') OR (($plalign ==
'R') AND (!$this->rtl)) OR (($plalign ==
'L') AND ($this->rtl)))))) {
18475 if ($this->lMargin != $prevlMargin) {
18478 if ($this->rMargin != $prevrMargin) {
18487 $pos1 = intval($pos1);
18495 if ($pos1 == $pos2) {
18496 $pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
18497 if (substr($pmid, $pos1, 4) ==
'[()]') {
18498 $linew -= $one_space_width;
18499 } elseif ($pos1 == strpos($pmid,
'[(')) {
18508 $pos1 = intval($pos1);
18516 if ($pos1 == $pos2) {
18517 $pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
18518 $linew -= $one_space_width;
18522 $mdiff = ($tw - $linew);
18523 if ($plalign ==
'C') {
18525 $t_x = -($mdiff / 2);
18527 $t_x = ($mdiff / 2);
18529 } elseif ($plalign ==
'R') {
18532 } elseif ($plalign ==
'L') {
18537 if (($t_x != 0) OR ($yshift < 0)) {
18539 $trx = sprintf(
'1 0 0 1 %F %F cm', ($t_x * $this->k), ($yshift * $this->k));
18540 $pstart .=
"\nq\n".$trx.
"\n".$pmid.
"\nQ\n";
18541 $endlinepos = strlen($pstart);
18542 if ($this->inxobj) {
18545 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
18546 if ($pak >= $pask) {
18547 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'x'] += $t_x;
18548 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'y'] -= $yshift;
18554 if (isset($this->PageAnnots[$this->page])) {
18555 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
18556 if ($pak >= $pask) {
18557 $this->PageAnnots[
$this->page][$pak][
'x'] += $t_x;
18558 $this->PageAnnots[
$this->page][$pak][
'y'] -= $yshift;
18563 $this->y -= $yshift;
18569 if ($this->num_columns > 1) {
18571 } elseif ($this->page > $prevPage) {
18572 $this->lMargin = $this->pagedim[
$this->page][
'olm'];
18573 $this->rMargin = $this->pagedim[
$this->page][
'orm'];
18576 $this->cell_height_ratio = $prev_cell_height_ratio;
18577 $this->listnum = $prev_listnum;
18578 $this->listordered = $prev_listordered;
18579 $this->listcount = $prev_listcount;
18580 $this->lispacer = $prev_lispacer;
18581 if ($ln AND (!($cell AND ($dom[$key-1][
'value'] ==
'table')))) {
18582 $this->
Ln($this->lasth);
18583 if ($this->y < $maxbottomliney) {
18584 $this->y = $maxbottomliney;
18600 $parent = $dom[($dom[$key][
'parent'])];
18601 $firsttag = ($key == 1);
18603 if (isset($tag[
'dir'])) {
18606 $this->tmprtl =
false;
18608 if ($tag[
'block']) {
18612 if (isset($this->tagvspaces[$tag[
'value']][0][
'h']) AND ($this->tagvspaces[$tag[
'value']][0][
'h'] >= 0)) {
18613 $cur_h = $this->tagvspaces[$tag[
'value']][0][
'h'];
18614 } elseif (isset($tag[
'fontsize'])) {
18615 $cur_h = $this->
getCellHeight($tag[
'fontsize'] / $this->k);
18619 if (isset($this->tagvspaces[$tag[
'value']][0][
'n'])) {
18620 $n = $this->tagvspaces[$tag[
'value']][0][
'n'];
18621 } elseif (preg_match(
'/[h][0-9]/', $tag[
'value']) > 0) {
18626 if ((!isset($this->tagvspaces[$tag[
'value']])) AND (in_array($tag[
'value'], array(
'div',
'dt',
'dd',
'li',
'br')))) {
18629 $hb = (
$n * $cur_h);
18631 if (($this->htmlvspace <= 0) AND (
$n > 0)) {
18632 if (isset($parent[
'fontsize'])) {
18638 if (isset($dom[($key - 1)]) AND ($dom[($key - 1)][
'value'] ==
'table')) {
18644 switch($tag[
'value']) {
18648 $dom[$key][
'rowspans'] = array();
18649 if (!isset($dom[$key][
'attribute'][
'nested']) OR ($dom[$key][
'attribute'][
'nested'] !=
'true')) {
18650 $this->htmlvspace = 0;
18654 $this->thead = $dom[$key][
'thead'];
18655 if (!isset($this->theadMargins) OR (empty($this->theadMargins))) {
18656 $this->theadMargins = array();
18661 $this->theadMargins[
'cell'] = $cell;
18668 if (isset($tag[
'attribute'][
'cellpadding'])) {
18671 } elseif (isset($tag[
'padding'])) {
18672 $this->cell_padding = $tag[
'padding'];
18674 if (isset($tag[
'attribute'][
'cellspacing'])) {
18676 } elseif (isset($tag[
'border-spacing'])) {
18677 $cs = $tag[
'border-spacing'][
'V'];
18680 if ($this->
checkPageBreak(((2 * $cp) + (2 * $cs) + $this->lasth),
'',
false) OR ($this->y < $prev_y)) {
18681 $this->inthead =
true;
18689 $dom[$key][
'cellpos'] = array();
18693 if ((isset($tag[
'height'])) AND ($tag[
'height'] !=
'')) {
18703 $wtmp -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
18705 if ((isset($tag[
'width'])) AND ($tag[
'width'] !=
'')) {
18714 $this->
addHTMLVertSpace(($hrHeight / 2), 0, $cell, !isset($dom[($key + 1)]));
18718 if (array_key_exists(
'href', $tag[
'attribute'])) {
18719 $this->HREF[
'url'] = $tag[
'attribute'][
'href'];
18724 if (!empty($tag[
'attribute'][
'src'])) {
18725 if ($tag[
'attribute'][
'src']{0} ===
'@') {
18727 $tag[
'attribute'][
'src'] =
'@'.base64_decode(substr($tag[
'attribute'][
'src'], 1));
18733 if (!isset($tag[
'width'])) {
18736 if (!isset($tag[
'height'])) {
18737 $tag[
'height'] = 0;
18742 $tag[
'attribute'][
'align'] =
'bottom';
18744 switch($tag[
'attribute'][
'align']) {
18766 $imglink = $this->HREF[
'url'];
18767 if ($imglink{0} ==
'#') {
18769 $lnkdata = explode(
',', $imglink);
18770 if (isset($lnkdata[0])) {
18771 $page = intval(substr($lnkdata[0], 1));
18775 if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
18776 $lnky = floatval($lnkdata[1]);
18786 if (isset($tag[
'border']) AND !empty($tag[
'border'])) {
18788 $border = $tag[
'border'];
18791 if (isset($tag[
'width'])) {
18795 if (isset($tag[
'height'])) {
18798 if (($type ==
'eps') OR ($type ==
'ai')) {
18799 $this->
ImageEps($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih, $imglink,
true, $align,
'', $border,
true);
18800 } elseif ($type ==
'svg') {
18801 $this->
ImageSVG($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih, $imglink, $align,
'', $border,
true);
18803 $this->
Image($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih,
'', $imglink, $align,
false, 300,
'',
false,
false, $border,
false,
false,
true);
18811 $this->y = (($this->img_rb_y + $prevy - ($tag[
'fontsize'] /
$this->k)) / 2) ;
18815 $this->y = $this->img_rb_y - ($tag[
'fontsize'] /
$this->k);
18824 if ($this->listnum == 1) {
18848 if ($tag[
'value'] ==
'ol') {
18853 if (isset($tag[
'attribute'][
'start'])) {
18854 $this->listcount[
$this->listnum] = intval($tag[
'attribute'][
'start']) - 1;
18866 if ($this->listnum == 1) {
18879 if ($this->listordered[$this->listnum]) {
18882 $this->lispacer = $parent[
'attribute'][
'type'];
18884 $this->lispacer = $parent[
'listtype'];
18888 $this->lispacer =
'#';
18891 if (isset($tag[
'attribute'][
'value'])) {
18892 $this->listcount[
$this->listnum] = intval($tag[
'attribute'][
'value']);
18897 $this->lispacer = $parent[
'attribute'][
'type'];
18899 $this->lispacer = $parent[
'listtype'];
18903 $this->lispacer =
'!';
18908 case 'blockquote': {
18932 $this->premode =
true;
18936 $this->
SetXY($this->
GetX(), $this->
GetY() - ((0.7 * $this->FontSizePt) / $this->k));
18940 $this->
SetXY($this->
GetX(), $this->
GetY() + ((0.3 * $this->FontSizePt) / $this->k));
18954 if (isset($tag[
'attribute'][
'action'])) {
18955 $this->form_action = $tag[
'attribute'][
'action'];
18957 $this->
Error(
'Please explicitly set action attribute path!');
18959 if (isset($tag[
'attribute'][
'enctype'])) {
18960 $this->form_enctype = $tag[
'attribute'][
'enctype'];
18962 $this->form_enctype =
'application/x-www-form-urlencoded';
18964 if (isset($tag[
'attribute'][
'method'])) {
18965 $this->form_mode = $tag[
'attribute'][
'method'];
18967 $this->form_mode =
'post';
18973 $name = $tag[
'attribute'][
'name'];
18980 $prop[
'readonly'] =
true;
18983 $value = $tag[
'attribute'][
'value'];
18986 $opt[
'maxlen'] = intval($tag[
'attribute'][
'maxlength']);
18990 $w = intval($tag[
'attribute'][
'size']) * $this->
GetStringWidth(chr(32)) * 2;
18994 if (isset($tag[
'attribute'][
'checked']) AND (($tag[
'attribute'][
'checked'] ==
'checked') OR ($tag[
'attribute'][
'checked'] ==
'true'))) {
18999 if (isset($tag[
'align'])) {
19000 switch ($tag[
'align']) {
19015 switch ($tag[
'attribute'][
'type']) {
19017 if (isset($value)) {
19018 $opt[
'v'] = $value;
19020 $this->
TextField($name,
$w,
$h, $prop, $opt,
'',
'',
false);
19024 if (isset($value)) {
19025 $opt[
'v'] = $value;
19027 $prop[
'password'] =
'true';
19028 $this->
TextField($name,
$w,
$h, $prop, $opt,
'',
'',
false);
19032 if (!isset($value)) {
19035 $this->
CheckBox($name,
$w, $checked, $prop, $opt, $value,
'',
'',
false);
19039 if (!isset($value)) {
19042 $this->
RadioButton($name,
$w, $prop, $opt, $value, $checked,
'',
'',
false);
19046 if (!isset($value)) {
19051 $prop = array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>array(196, 196, 196),
'strokeColor'=>array(255, 255, 255));
19053 $action[
'S'] =
'SubmitForm';
19055 if ($this->form_enctype !=
'FDF') {
19056 $action[
'Flags'] = array(
'ExportFormat');
19058 if ($this->form_mode ==
'get') {
19059 $action[
'Flags'] = array(
'GetMethod');
19061 $this->
Button($name,
$w,
$h, $value, $action, $prop, $opt,
'',
'',
false);
19065 if (!isset($value)) {
19070 $prop = array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>array(196, 196, 196),
'strokeColor'=>array(255, 255, 255));
19071 $this->
Button($name,
$w,
$h, $value, array(
'S'=>
'ResetForm'), $prop, $opt,
'',
'',
false);
19075 $prop[
'fileSelect'] =
'true';
19076 $this->
TextField($name,
$w,
$h, $prop, $opt,
'',
'',
false);
19077 if (!isset($value)) {
19082 $prop = array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>array(196, 196, 196),
'strokeColor'=>array(255, 255, 255));
19083 $jsaction =
'var f=this.getField(\''.$name.
'\'); f.browseForFileToSubmit();
';
19084 $this->Button('FB_
'.$name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false);
19088 if (isset($value)) {
19089 $opt['v
'] = $value;
19091 $opt['f
'] = array('invisible
', 'hidden
');
19092 $this->TextField($name, 0, 0, $prop, $opt, '', '', false);
19096 // THIS TYPE MUST BE FIXED
19097 if (isset($tag['attribute
']['src
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['src
'])) {
19098 $img = $tag['attribute
']['src
'];
19103 //$opt['mk
'] = array('i
'=>$img, 'tp
'=>1, 'if'=>array('sw
'=>'A
', 's
'=>'A
', 'fb
'=>false));
19104 if (isset($tag['attribute
']['onclick
']) AND !empty($tag['attribute
']['onclick
'])) {
19105 $jsaction = $tag['attribute
']['onclick
'];
19109 $this->Button($name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false);
19113 if (!isset($value)) {
19116 $w = $this->GetStringWidth($value) * 1.5;
19118 $prop = array('lineWidth
'=>1, 'borderStyle
'=>'beveled
', 'fillColor
'=>array(196, 196, 196), 'strokeColor
'=>array(255, 255, 255));
19119 if (isset($tag['attribute
']['onclick
']) AND !empty($tag['attribute
']['onclick
'])) {
19120 $jsaction = $tag['attribute
']['onclick
'];
19124 $this->Button($name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false);
19133 if (isset($tag['attribute
']['readonly
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['readonly
'])) {
19134 $prop['readonly
'] = true;
19136 if (isset($tag['attribute
']['name
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['name
'])) {
19137 $name = $tag['attribute
']['name
'];
19141 if (isset($tag['attribute
']['value
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['value
'])) {
19142 $opt['v
'] = $tag['attribute
']['value
'];
19144 if (isset($tag['attribute
']['cols
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['cols
'])) {
19145 $w = intval($tag['attribute
']['cols
']) * $this->GetStringWidth(chr(32)) * 2;
19149 if (isset($tag['attribute
']['rows
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['rows
'])) {
19150 $h = intval($tag['attribute
']['rows
']) * $this->getCellHeight($this->FontSize);
19154 $prop['multiline
'] = 'true';
19155 $this->TextField($name, $w, $h, $prop, $opt, '', '', false);
19159 $h = $this->getCellHeight($this->FontSize);
19160 if (isset($tag['attribute
']['size
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['size
'])) {
19161 $h *= ($tag['attribute
']['size
'] + 1);
19165 if (isset($tag['attribute
']['name
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['name
'])) {
19166 $name = $tag['attribute
']['name
'];
19171 if (isset($tag['attribute
']['opt
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['opt
'])) {
19172 $options = explode('#!NwL!#
', $tag['attribute
']['opt
']);
19174 foreach ($options as $val) {
19175 if (strpos($val, '#!TaB!#
') !== false) {
19176 $opts = explode('#!TaB!#
', $val);
19178 $w = max($w, $this->GetStringWidth($opts[1]));
19181 $w = max($w, $this->GetStringWidth($val));
19188 if (isset($tag['attribute
']['multiple
']) AND ($tag['attribute
']['multiple
']='multiple
')) {
19189 $prop['multipleSelection
'] = 'true';
19190 $this->ListBox($name, $w, $h, $values, $prop, $opt, '', '', false);
19192 $this->ComboBox($name, $w, $h, $values, $prop, $opt, '', '', false);
19198 // Special tag used to call TCPDF methods
19199 if (isset($tag['attribute
']['method
'])) {
19200 $tcpdf_method = $tag['attribute
']['method
'];
19201 if (method_exists($this, $tcpdf_method)) {
19202 if (isset($tag['attribute
']['params
']) AND (!empty($tag['attribute
']['params
']))) {
19203 $params = unserialize(urldecode($tag['attribute
']['params
']));
19204 call_user_func_array(array($this, $tcpdf_method), $params);
19206 $this->$tcpdf_method();
19208 $this->newline = true;
19218 // define tags that support borders and background colors
19219 $bordertags = array('blockquote
','br
','dd
','dl
','div
','dt
','h1
','h2
','h3
','h4
','h5
','h6
','hr
','li
','ol
','p
','pre
','ul
','tcpdf
','table
');
19220 if (in_array($tag['value
'], $bordertags)) {
19222 $dom[$key]['borderposition
'] = $this->getBorderStartPosition();
19224 if ($dom[$key]['self'] AND isset($dom[$key]['attribute
']['pagebreakafter
'])) {
19225 $pba = $dom[$key]['attribute
']['pagebreakafter
'];
19226 // check for pagebreak
19227 if (($pba == 'true') OR ($pba == 'left
') OR ($pba == 'right
')) {
19228 // add a page (or trig AcceptPageBreak() for multicolumn mode)
19229 $this->checkPageBreak($this->PageBreakTrigger + 1);
19231 if ((($pba == 'left
') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
19232 OR (($pba == 'right
') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
19233 // add a page (or trig AcceptPageBreak() for multicolumn mode)
19234 $this->checkPageBreak($this->PageBreakTrigger + 1);
19249 protected function closeHTMLTagHandler($dom, $key, $cell, $maxbottomliney=0) {
19251 $parent = $dom[($dom[$key]['parent
'])];
19252 $lasttag = ((!isset($dom[($key + 1)])) OR ((!isset($dom[($key + 2)])) AND ($dom[($key + 1)]['value
'] == 'marker
')));
19253 $in_table_head = false;
19254 // maximum x position (used to draw borders)
19260 if ($tag['block
']) {
19261 $hbz = 0; // distance from y to line bottom
19262 $hb = 0; // vertical space between block tags
19263 // calculate vertical space for block tags
19264 if (isset($this->tagvspaces[$tag['value
']][1]['h
']) AND ($this->tagvspaces[$tag['value
']][1]['h
'] >= 0)) {
19265 $pre_h = $this->tagvspaces[$tag['value
']][1]['h
'];
19266 } elseif (isset($parent['fontsize
'])) {
19267 $pre_h = $this->getCellHeight($parent['fontsize
'] / $this->k);
19269 $pre_h = $this->getCellHeight($this->FontSize);
19271 if (isset($this->tagvspaces[$tag['value
']][1]['n
'])) {
19272 $n = $this->tagvspaces[$tag['value
']][1]['n
'];
19273 } elseif (preg_match('/[h][0-9]/
', $tag['value
']) > 0) {
19278 if ((!isset($this->tagvspaces[$tag['value
']])) AND ($tag['value
'] == 'div
')) {
19281 $hb = ($n * $pre_h);
19283 if ($maxbottomliney > $this->PageBreakTrigger) {
19284 $hbz = $this->getCellHeight($this->FontSize);
19285 } elseif ($this->y < $maxbottomliney) {
19286 $hbz = ($maxbottomliney - $this->y);
19290 switch($tag['value
']) {
19292 $table_el = $dom[($dom[$key]['parent
'])]['parent
'];
19293 if (!isset($parent['endy
'])) {
19294 $dom[($dom[$key]['parent
'])]['endy
'] = $this->y;
19295 $parent['endy
'] = $this->y;
19297 if (!isset($parent['endpage
'])) {
19298 $dom[($dom[$key]['parent
'])]['endpage
'] = $this->page;
19299 $parent['endpage
'] = $this->page;
19301 if (!isset($parent['endcolumn
'])) {
19302 $dom[($dom[$key]['parent
'])]['endcolumn
'] = $this->current_column;
19303 $parent['endcolumn
'] = $this->current_column;
19305 // update row-spanned cells
19306 if (isset($dom[$table_el]['rowspans
'])) {
19307 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) {
19308 $dom[$table_el]['rowspans
'][$k]['rowspan
'] -= 1;
19309 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) {
19310 if (($dom[$table_el]['rowspans
'][$k]['endpage
'] == $parent['endpage
']) AND ($dom[$table_el]['rowspans
'][$k]['endcolumn
'] == $parent['endcolumn
'])) {
19311 $dom[($dom[$key]['parent
'])]['endy
'] = max($dom[$table_el]['rowspans
'][$k]['endy
'], $parent['endy
']);
19312 } elseif (($dom[$table_el]['rowspans
'][$k]['endpage
'] > $parent['endpage
']) OR ($dom[$table_el]['rowspans
'][$k]['endcolumn
'] > $parent['endcolumn
'])) {
19313 $dom[($dom[$key]['parent
'])]['endy
'] = $dom[$table_el]['rowspans
'][$k]['endy
'];
19314 $dom[($dom[$key]['parent
'])]['endpage
'] = $dom[$table_el]['rowspans
'][$k]['endpage
'];
19315 $dom[($dom[$key]['parent
'])]['endcolumn
'] = $dom[$table_el]['rowspans
'][$k]['endcolumn
'];
19319 // report new endy and endpage to the rowspanned cells
19320 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) {
19321 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) {
19322 $dom[$table_el]['rowspans
'][$k]['endpage
'] = max($dom[$table_el]['rowspans
'][$k]['endpage
'], $dom[($dom[$key]['parent
'])]['endpage
']);
19323 $dom[($dom[$key]['parent
'])]['endpage
'] = $dom[$table_el]['rowspans
'][$k]['endpage
'];
19324 $dom[$table_el]['rowspans
'][$k]['endcolumn
'] = max($dom[$table_el]['rowspans
'][$k]['endcolumn
'], $dom[($dom[$key]['parent
'])]['endcolumn
']);
19325 $dom[($dom[$key]['parent
'])]['endcolumn
'] = $dom[$table_el]['rowspans
'][$k]['endcolumn
'];
19326 $dom[$table_el]['rowspans
'][$k]['endy
'] = max($dom[$table_el]['rowspans
'][$k]['endy
'], $dom[($dom[$key]['parent
'])]['endy
']);
19327 $dom[($dom[$key]['parent
'])]['endy
'] = $dom[$table_el]['rowspans
'][$k]['endy
'];
19330 // update remaining rowspanned cells
19331 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) {
19332 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) {
19333 $dom[$table_el]['rowspans
'][$k]['endpage
'] = $dom[($dom[$key]['parent
'])]['endpage
'];
19334 $dom[$table_el]['rowspans
'][$k]['endcolumn
'] = $dom[($dom[$key]['parent
'])]['endcolumn
'];
19335 $dom[$table_el]['rowspans
'][$k]['endy
'] = $dom[($dom[$key]['parent
'])]['endy
'];
19339 $this->setPage($dom[($dom[$key]['parent
'])]['endpage
']);
19340 if ($this->num_columns > 1) {
19341 $this->selectColumn($dom[($dom[$key]['parent
'])]['endcolumn
']);
19343 $this->y = $dom[($dom[$key]['parent
'])]['endy
'];
19344 if (isset($dom[$table_el]['attribute
']['cellspacing
'])) {
19345 $this->y += $this->getHTMLUnitToUnits($dom[$table_el]['attribute
']['cellspacing
'], 1, 'px
');
19346 } elseif (isset($dom[$table_el]['border-spacing
'])) {
19347 $this->y += $dom[$table_el]['border-spacing
']['V
'];
19349 $this->Ln(0, $cell);
19350 if ($this->current_column == $parent['startcolumn
']) {
19351 $this->x = $parent['startx
'];
19353 // account for booklet mode
19354 if ($this->page > $parent['startpage
']) {
19355 if (($this->rtl) AND ($this->pagedim[$this->page]['orm
'] != $this->pagedim[$parent['startpage
']]['orm
'])) {
19356 $this->x -= ($this->pagedim[$this->page]['orm
'] - $this->pagedim[$parent['startpage
']]['orm
']);
19357 } elseif ((!$this->rtl) AND ($this->pagedim[$this->page]['olm
'] != $this->pagedim[$parent['startpage
']]['olm
'])) {
19358 $this->x += ($this->pagedim[$this->page]['olm
'] - $this->pagedim[$parent['startpage
']]['olm
']);
19364 // closing tag used for the thead part
19365 $in_table_head = true;
19366 $this->inthead = false;
19368 $table_el = $parent;
19369 // set default border
19370 if (isset($table_el['attribute
']['border
']) AND ($table_el['attribute
']['border
'] > 0)) {
19371 // set default border
19372 $border = array('LTRB
' => array('width
' => $this->getCSSBorderWidth($table_el['attribute
']['border
']), 'cap
'=>'square
', 'join
'=>'miter
', 'dash
'=> 0, 'color
'=>array(0,0,0)));
19376 $default_border = $border;
19377 // fix bottom line alignment of last line before page break
19378 foreach ($dom[($dom[$key]['parent
'])]['trids
'] as $j => $trkey) {
19379 // update row-spanned cells
19380 if (isset($dom[($dom[$key]['parent
'])]['rowspans
'])) {
19381 foreach ($dom[($dom[$key]['parent
'])]['rowspans
'] as $k => $trwsp) {
19382 if (isset($prevtrkey) AND ($trwsp['trid
'] == $prevtrkey) AND ($trwsp['mrowspan
'] > 0)) {
19383 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['trid
'] = $trkey;
19385 if ($dom[($dom[$key]['parent
'])]['rowspans
'][$k]['trid
'] == $trkey) {
19386 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['mrowspan
'] -= 1;
19390 if (isset($prevtrkey) AND ($dom[$trkey]['startpage
'] > $dom[$prevtrkey]['endpage
'])) {
19391 $pgendy = $this->pagedim[$dom[$prevtrkey]['endpage
']]['hk
'] - $this->pagedim[$dom[$prevtrkey]['endpage
']]['bm
'];
19392 $dom[$prevtrkey]['endy
'] = $pgendy;
19393 // update row-spanned cells
19394 if (isset($dom[($dom[$key]['parent
'])]['rowspans
'])) {
19395 foreach ($dom[($dom[$key]['parent
'])]['rowspans
'] as $k => $trwsp) {
19396 if (($trwsp['trid
'] == $trkey) AND ($trwsp['mrowspan
'] > 1) AND ($trwsp['endpage
'] == $dom[$prevtrkey]['endpage
'])) {
19397 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['endy
'] = $pgendy;
19398 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['mrowspan
'] = -1;
19403 $prevtrkey = $trkey;
19404 $table_el = $dom[($dom[$key]['parent
'])];
19407 if (count($table_el['trids
']) > 0) {
19410 foreach ($table_el['trids
'] as $j => $trkey) {
19411 $parent = $dom[$trkey];
19412 if (!isset($xmax)) {
19413 $xmax = $parent['cellpos
'][(count($parent['cellpos
']) - 1)]['endx
'];
19415 // for each cell on the row
19416 foreach ($parent['cellpos
'] as $k => $cellpos) {
19417 if (isset($cellpos['rowspanid
']) AND ($cellpos['rowspanid
'] >= 0)) {
19418 $cellpos['startx
'] = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startx
'];
19419 $cellpos['endx
'] = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endx
'];
19420 $endy = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endy
'];
19421 $startpage = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startpage
'];
19422 $endpage = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endpage
'];
19423 $startcolumn = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startcolumn
'];
19424 $endcolumn = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endcolumn
'];
19426 $endy = $parent['endy
'];
19427 $startpage = $parent['startpage
'];
19428 $endpage = $parent['endpage
'];
19429 $startcolumn = $parent['startcolumn
'];
19430 $endcolumn = $parent['endcolumn
'];
19432 if ($this->num_columns == 0) {
19433 $this->num_columns = 1;
19435 if (isset($cellpos['border
'])) {
19436 $border = $cellpos['border
'];
19438 if (isset($cellpos['bgcolor
']) AND ($cellpos['bgcolor
']) !== false) {
19439 $this->SetFillColorArray($cellpos['bgcolor
']);
19444 $x = $cellpos['startx
'];
19445 $y = $parent['starty
'];
19447 $w = abs($cellpos['endx
'] - $cellpos['startx
']);
19448 // get border modes
19449 $border_start = TCPDF_STATIC::getBorderMode($border, $position='start
', $this->opencell);
19450 $border_end = TCPDF_STATIC::getBorderMode($border, $position='end
', $this->opencell);
19451 $border_middle = TCPDF_STATIC::getBorderMode($border, $position='middle
', $this->opencell);
19452 // design borders around HTML cells.
19453 for ($page = $startpage; $page <= $endpage; ++$page) { // for each page
19455 $this->setPage($page);
19456 if ($this->num_columns < 2) {
19457 // single-column mode
19459 $this->y = $this->tMargin;
19461 // account for margin changes
19462 if ($page > $startpage) {
19463 if (($this->rtl) AND ($this->pagedim[$page]['orm
'] != $this->pagedim[$startpage]['orm
'])) {
19464 $this->x -= ($this->pagedim[$page]['orm
'] - $this->pagedim[$startpage]['orm
']);
19465 } elseif ((!$this->rtl) AND ($this->pagedim[$page]['olm
'] != $this->pagedim[$startpage]['olm
'])) {
19466 $this->x += ($this->pagedim[$page]['olm
'] - $this->pagedim[$startpage]['olm
']);
19469 if ($startpage == $endpage) { // single page
19472 for ($column = $startcolumn; $column <= $endcolumn; ++$column) { // for each column
19473 $this->selectColumn($column);
19474 if ($startcolumn == $endcolumn) { // single column
19475 $cborder = $border;
19476 $h = $endy - $parent['starty
'];
19479 } elseif ($column == $startcolumn) { // first column
19480 $cborder = $border_start;
19481 $this->y = $starty;
19483 $h = $this->h - $this->y - $this->bMargin;
19485 $deltacol = $this->x + $this->rMargin - $this->w;
19487 $deltacol = $this->x - $this->lMargin;
19489 } elseif ($column == $endcolumn) { // end column
19490 $cborder = $border_end;
19491 if (isset($this->columns[$column]['th
']['\
''.$page.
'\''])) {
19492 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19494 $this->x += $deltacol;
19497 $cborder = $border_middle;
19498 if (isset($this->columns[$column][
'th'][
'\''.
$page.
'\''])) {
19499 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19501 $this->x += $deltacol;
19504 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19506 } elseif (
$page == $startpage) {
19511 if ($column == $startcolumn) {
19512 $cborder = $border_start;
19513 $this->y = $starty;
19517 $deltacol = $this->x + $this->rMargin -
$this->w;
19522 $cborder = $border_middle;
19523 if (isset($this->columns[$column][
'th'][
'\''.
$page.
'\''])) {
19524 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19526 $this->x += $deltacol;
19529 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19531 } elseif (
$page == $endpage) {
19534 for ($column = 0; $column <= $endcolumn; ++$column) {
19536 if ($column == $endcolumn) {
19537 $cborder = $border_end;
19538 if (isset($this->columns[$column][
'th'][
'\''.
$page.
'\''])) {
19539 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19541 $this->x += $deltacol;
19544 $cborder = $border_middle;
19545 if (isset($this->columns[$column][
'th'][
'\''.
$page.
'\''])) {
19546 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19548 $this->x += $deltacol;
19551 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19558 $cborder = $border_middle;
19559 if (isset($this->columns[$column][
'th'][
'\''.
$page.
'\''])) {
19560 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
19562 $this->x += $deltacol;
19564 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19567 if ($cborder OR $fill) {
19568 $offsetlen = strlen($ccode);
19570 if ($this->inxobj) {
19572 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
19573 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
19574 $pagemark = $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey];
19575 $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey] += $offsetlen;
19581 $pstart = substr($pagebuff, 0, $pagemark);
19582 $pend = substr($pagebuff, $pagemark);
19583 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
19586 if (end($this->transfmrk[$this->page]) !==
false) {
19587 $pagemarkkey = key($this->transfmrk[$this->page]);
19588 $pagemark = $this->transfmrk[
$this->page][$pagemarkkey];
19589 } elseif ($this->InFooter) {
19595 $pstart = substr($pagebuff, 0, $pagemark);
19596 $pend = substr($pagebuff, $pagemark);
19602 $border = $default_border;
19604 if (isset($table_el[
'attribute'][
'cellspacing'])) {
19605 $this->y += $this->
getHTMLUnitToUnits($table_el[
'attribute'][
'cellspacing'], 1,
'px');
19606 } elseif (isset($table_el[
'border-spacing'])) {
19607 $this->y += $table_el[
'border-spacing'][
'V'];
19609 $this->
Ln(0, $cell);
19610 $this->x = $parent[
'startx'];
19611 if ($endpage > $startpage) {
19612 if (($this->rtl) AND ($this->pagedim[$endpage][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
19613 $this->x += ($this->pagedim[$endpage][
'orm'] - $this->pagedim[$startpage][
'orm']);
19614 } elseif ((!$this->rtl) AND ($this->pagedim[$endpage][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
19615 $this->x += ($this->pagedim[$endpage][
'olm'] - $this->pagedim[$startpage][
'olm']);
19619 if (!$in_table_head) {
19620 $this->cell_padding = $table_el[
'old_cell_padding'];
19623 if (($this->page == ($this->numpages - 1)) AND ($this->pageopen[$this->numpages])) {
19625 if (($plendiff > 0) AND ($plendiff < 60)) {
19626 $pagediff = substr($this->
getPageBuffer($this->numpages), $this->emptypagemrk[$this->numpages], $plendiff);
19627 if (substr($pagediff, 0, 5) ==
'BT /F') {
19632 if ($plendiff == 0) {
19637 if (isset($this->theadMargins[
'top'])) {
19639 $this->tMargin = $this->theadMargins[
'top'];
19641 if (!isset($table_el[
'attribute'][
'nested']) OR ($table_el[
'attribute'][
'nested'] !=
'true')) {
19644 $this->theadMargins = array();
19648 $parent = $table_el;
19656 $this->
SetXY($this->
GetX(), $this->
GetY() + ((0.7 * $parent[
'fontsize']) / $this->k));
19660 $this->
SetXY($this->
GetX(), $this->
GetY() - ((0.3 * $parent[
'fontsize']) / $this->k));
19667 case 'blockquote': {
19683 $this->premode =
false;
19688 if ($this->listnum <= 0) {
19689 $this->listnum = 0;
19698 $this->lispacer =
'';
19703 $this->lispacer =
'';
19716 $this->lispacer =
'';
19723 if ($this->listnum <= 0) {
19724 $this->listnum = 0;
19733 $this->lispacer =
'';
19748 $this->form_action =
'';
19749 $this->form_enctype =
'application/x-www-form-urlencoded';
19758 if (isset($dom[($dom[$key][
'parent'])][
'attribute'][
'pagebreakafter'])) {
19759 $pba = $dom[($dom[$key][
'parent'])][
'attribute'][
'pagebreakafter'];
19761 if (($pba ==
'true') OR ($pba ==
'left') OR ($pba == 'right')) {
19765 if ((($pba ==
'left') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
19766 OR (($pba ==
'right') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
19771 $this->tmprtl =
false;
19786 $this->Ln(0, $cell);
19787 $this->htmlvspace = 0;
19791 $this->Ln($hbz, $cell);
19792 $this->htmlvspace = 0;
19795 if ($hb < $this->htmlvspace) {
19798 $hd = $hb - $this->htmlvspace;
19799 $this->htmlvspace = $hb;
19801 $this->Ln(($hbz + $hd), $cell);
19812 $xmax = $this->lMargin;
19814 $xmax = $this->w - $this->rMargin;
19816 return array(
'page' => $this->page,
'column' => $this->current_column,
'x' => $this->x,
'y' => $this->y,
'xmax' => $xmax);
19827 if (!isset($tag[
'borderposition'])) {
19831 $prev_x = $this->x;
19832 $prev_y = $this->y;
19833 $prev_lasth = $this->lasth;
19837 if (isset($tag[
'border']) AND !empty($tag[
'border'])) {
19839 $border = $tag[
'border'];
19845 if (isset($tag[
'bgcolor']) AND ($tag[
'bgcolor'] !==
false)) {
19847 $old_bgcolor = $this->bgcolor;
19848 $this->SetFillColorArray($tag[
'bgcolor']);
19851 if (!$border AND !$fill) {
19855 if (isset($tag[
'attribute'][
'cellspacing'])) {
19856 $clsp = $this->getHTMLUnitToUnits($tag[
'attribute'][
'cellspacing'], 1,
'px');
19857 $cellspacing = array(
'H' => $clsp,
'V' => $clsp);
19858 } elseif (isset($tag[
'border-spacing'])) {
19859 $cellspacing = $tag[
'border-spacing'];
19861 $cellspacing = array(
'H' => 0,
'V' => 0);
19863 if (($tag[
'value'] !=
'table') AND (is_array($border)) AND (!empty($border))) {
19865 $border[
'mode'] =
'ext';
19868 if ($xmax >= $tag[
'borderposition'][
'x']) {
19869 $xmax = $tag[
'borderposition'][
'xmax'];
19871 $w = ($tag[
'borderposition'][
'x'] - $xmax);
19873 if ($xmax <= $tag[
'borderposition'][
'x']) {
19874 $xmax = $tag[
'borderposition'][
'xmax'];
19876 $w = ($xmax - $tag[
'borderposition'][
'x']);
19881 $w += $cellspacing[
'H'];
19882 $startpage = $tag[
'borderposition'][
'page'];
19883 $startcolumn = $tag[
'borderposition'][
'column'];
19884 $x = $tag[
'borderposition'][
'x'];
19885 $y = $tag[
'borderposition'][
'y'];
19886 $endpage = $this->page;
19887 $starty = $tag[
'borderposition'][
'y'] - $cellspacing[
'V'];
19888 $currentY = $this->y;
19891 $endcolumn = $this->current_column;
19892 if ($this->num_columns == 0) {
19893 $this->num_columns = 1;
19900 $temp_page_regions = $this->page_regions;
19901 $this->page_regions = array();
19903 for ($page = $startpage; $page <= $endpage; ++$page) {
19905 $this->setPage($page);
19906 if ($this->num_columns < 2) {
19909 $this->y = $this->tMargin;
19912 if ($page > $startpage) {
19913 if (($this->rtl) AND ($this->pagedim[$page][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
19914 $this->x -= ($this->pagedim[$page][
'orm'] - $this->pagedim[$startpage][
'orm']);
19915 } elseif ((!$this->rtl) AND ($this->pagedim[$page][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
19916 $this->x += ($this->pagedim[$page][
'olm'] - $this->pagedim[$startpage][
'olm']);
19919 if ($startpage == $endpage) {
19921 for ($column = $startcolumn; $column <= $endcolumn; ++$column) {
19922 $this->selectColumn($column);
19923 if ($startcolumn == $endcolumn) {
19924 $cborder = $border;
19925 $h = ($currentY - $y) + $cellspacing[
'V'];
19926 $this->y = $starty;
19927 } elseif ($column == $startcolumn) {
19928 $cborder = $border_start;
19929 $this->y = $starty;
19930 $h = $this->h - $this->y - $this->bMargin;
19931 } elseif ($column == $endcolumn) {
19932 $cborder = $border_end;
19933 $h = $currentY - $this->y;
19935 $cborder = $border_middle;
19936 $h = $this->h - $this->y - $this->bMargin;
19938 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19940 } elseif ($page == $startpage) {
19941 for ($column = $startcolumn; $column < $this->num_columns; ++$column) {
19942 $this->selectColumn($column);
19943 if ($column == $startcolumn) {
19944 $cborder = $border_start;
19945 $this->y = $starty;
19946 $h = $this->h - $this->y - $this->bMargin;
19948 $cborder = $border_middle;
19949 $h = $this->h - $this->y - $this->bMargin;
19951 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19953 } elseif ($page == $endpage) {
19954 for ($column = 0; $column <= $endcolumn; ++$column) {
19955 $this->selectColumn($column);
19956 if ($column == $endcolumn) {
19958 $cborder = $border_end;
19959 $h = $currentY - $this->y;
19962 $cborder = $border_middle;
19963 $h = $this->h - $this->y - $this->bMargin;
19965 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19968 for ($column = 0; $column < $this->num_columns; ++$column) {
19969 $this->selectColumn($column);
19970 $cborder = $border_middle;
19971 $h = $this->h - $this->y - $this->bMargin;
19972 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19975 if ($cborder OR $fill) {
19976 $offsetlen = strlen($ccode);
19978 if ($this->inxobj) {
19980 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
19981 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
19982 $pagemark = $this->xobjects[$this->xobjid][
'transfmrk'][$pagemarkkey];
19983 $this->xobjects[$this->xobjid][
'transfmrk'][$pagemarkkey] += $offsetlen;
19985 $pagemark = $this->xobjects[$this->xobjid][
'intmrk'];
19986 $this->xobjects[$this->xobjid][
'intmrk'] += $offsetlen;
19988 $pagebuff = $this->xobjects[$this->xobjid][
'outdata'];
19989 $pstart = substr($pagebuff, 0, $pagemark);
19990 $pend = substr($pagebuff, $pagemark);
19991 $this->xobjects[$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
19993 if (end($this->transfmrk[$this->page]) !==
false) {
19994 $pagemarkkey = key($this->transfmrk[$this->page]);
19995 $pagemark = $this->transfmrk[$this->page][$pagemarkkey];
19996 } elseif ($this->InFooter) {
19997 $pagemark = $this->footerpos[$this->page];
19999 $pagemark = $this->intmrk[$this->page];
20001 $pagebuff = $this->getPageBuffer($this->page);
20002 $pstart = substr($pagebuff, 0, $pagemark);
20003 $pend = substr($pagebuff, $pagemark);
20004 $this->setPageBuffer($this->page, $pstart.$ccode.$pend);
20005 $this->bordermrk[$this->page] += $offsetlen;
20006 $this->cntmrk[$this->page] += $offsetlen;
20011 $this->page_regions = $temp_page_regions;
20012 if (isset($old_bgcolor)) {
20014 $this->SetFillColorArray($old_bgcolor);
20017 $this->x = $prev_x;
20018 $this->y = $prev_y;
20019 $this->lasth = $prev_lasth;
20030 if (substr($symbol, 0, 4) ==
'img|') {
20031 $this->lisymbol = $symbol;
20034 $symbol = strtolower($symbol);
20035 $valid_symbols = array(
'!',
'#',
'disc',
'circle',
'square',
'1',
'decimal',
'decimal-leading-zero',
'i',
'lower-roman',
'I',
'upper-roman',
'a',
'lower-alpha',
'lower-latin',
'A',
'upper-alpha',
'upper-latin',
'lower-greek');
20036 if (in_array($symbol, $valid_symbols)) {
20037 $this->lisymbol = $symbol;
20039 $this->lisymbol =
'';
20052 $this->booklet = $booklet;
20054 $this->lMargin = $inner;
20057 $this->rMargin = $outer;
20070 $mtemp = $this->original_lMargin;
20071 $this->original_lMargin = $this->original_rMargin;
20072 $this->original_rMargin = $mtemp;
20073 $deltam = $this->original_lMargin - $this->original_rMargin;
20074 $this->lMargin += $deltam;
20075 $this->rMargin -= $deltam;
20092 $this->tagvspaces = $tagvs;
20102 return $this->customlistindent = floatval($width);
20112 $this->opencell = $isopen;
20123 $this->htmlLinkColorArray = $color;
20124 $this->htmlLinkFontStyle = $fontstyle;
20138 $supportedunits = array(
'%',
'em',
'ex',
'px',
'in',
'cm',
'mm',
'pc',
'pt');
20147 if (in_array($defaultunit, $supportedunits)) {
20148 $unit = $defaultunit;
20150 if (is_numeric($htmlval)) {
20151 $value = floatval($htmlval);
20152 } elseif (preg_match(
'/([0-9\.\-\+]+)/', $htmlval, $mnum)) {
20153 $value = floatval($mnum[1]);
20154 if (preg_match(
'/([a-z%]+)/', $htmlval, $munit)) {
20155 if (in_array($munit[1], $supportedunits)) {
20163 $retval = (($value * $refsize) / 100);
20168 $retval = ($value * $refsize);
20173 $retval = ($value * ($refsize / 2));
20178 $retval = (($value * $this->dpi) / $k);
20183 $retval = (($value / 2.54 * $this->dpi) / $k);
20188 $retval = (($value / 25.4 * $this->dpi) / $k);
20193 $retval = (($value * 12) / $k);
20198 $retval = ($value / $k);
20203 $retval = $this->pixelsToUnits($value);
20205 $retval *= $this->k;
20222 if ($this->state != 2) {
20227 $bgcolor = $this->bgcolor;
20228 $color = $this->fgcolor;
20229 $strokecolor = $this->strokecolor;
20233 $lspace = $this->GetStringWidth(
' ');
20234 if ($listtype ==
'^') {
20236 $this->lispacer =
'';
20238 } elseif ($listtype ==
'!') {
20240 $deftypes = array(
'disc',
'circle',
'square');
20241 $listtype = $deftypes[($listdepth - 1) % 3];
20242 } elseif ($listtype ==
'#') {
20244 $listtype =
'decimal';
20245 } elseif (substr($listtype, 0, 4) ==
'img|') {
20247 $img = explode(
'|', $listtype);
20250 switch ($listtype) {
20257 $lspace += (2 * $r);
20259 $this->x += $lspace;
20261 $this->x -= $lspace;
20263 $this->Circle(($this->x + $r), ($this->y + ($this->lasth / 2)), $r, 0, 360,
'F', array(), $color, 8);
20268 $lspace += (2 * $r);
20270 $this->x += $lspace;
20272 $this->x -= $lspace;
20274 $prev_line_style = $this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor;
20275 $new_line_style = array(
'width' => ($r / 3),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'phase' => 0,
'color'=>$color);
20276 $this->Circle(($this->x + $r), ($this->y + ($this->lasth / 2)), ($r * (1 - (1/6))), 0, 360,
'D', $new_line_style, array(), 8);
20277 $this->_out($prev_line_style);
20284 $this->x += $lspace;
20286 $this->x -= $lspace;
20288 $this->Rect($this->x, ($this->y + (($this->lasth - $l) / 2)), $l, $l,
'F', array(), $color);
20293 $lspace += $img[2];
20295 $this->x += $lspace;
20297 $this->x -= $lspace;
20299 $imgtype = strtolower($img[1]);
20300 $prev_y = $this->y;
20301 switch ($imgtype) {
20303 $this->ImageSVG($img[4], $this->x, ($this->y + (($this->lasth - $img[3]) / 2)), $img[2], $img[3],
'',
'T',
'', 0,
false);
20308 $this->ImageEps($img[4], $this->x, ($this->y + (($this->lasth - $img[3]) / 2)), $img[2], $img[3],
'',
true,
'T',
'', 0,
false);
20312 $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);
20316 $this->y = $prev_y;
20324 $textitem = $this->listcount[$this->listnum];
20327 case 'decimal-leading-zero': {
20328 $textitem = sprintf(
'%02d', $this->listcount[$this->listnum]);
20332 case 'lower-roman': {
20337 case 'upper-roman': {
20342 case 'lower-alpha':
20343 case 'lower-latin': {
20344 $textitem = chr(97 + $this->listcount[$this->listnum] - 1);
20348 case 'upper-alpha':
20349 case 'upper-latin': {
20350 $textitem = chr(65 + $this->listcount[$this->listnum] - 1);
20353 case 'lower-greek': {
20354 $textitem =
TCPDF_FONTS::unichr((945 + $this->listcount[$this->listnum] - 1), $this->isunicode);
20385 $textitem = $this->listcount[$this->listnum];
20390 $prev_y = $this->y;
20391 $h = $this->getCellHeight($this->FontSize);
20392 if ($this->checkPageBreak($h) OR ($this->y < $prev_y)) {
20397 $textitem =
'.'.$textitem;
20399 $textitem = $textitem.
'.';
20401 $lspace += $this->GetStringWidth($textitem);
20403 $this->x += $lspace;
20405 $this->x -= $lspace;
20407 $this->Write($this->lasth, $textitem,
'',
false,
'',
false, 0,
false);
20410 $this->lispacer =
'^';
20412 $this->SetFillColorArray($bgcolor);
20413 $this->SetDrawColorArray($strokecolor);
20414 $this->SettextColorArray($color);
20425 'FontFamily' => $this->FontFamily,
20426 'FontStyle' => $this->FontStyle,
20427 'FontSizePt' => $this->FontSizePt,
20428 'rMargin' => $this->rMargin,
20429 'lMargin' => $this->lMargin,
20430 'cell_padding' => $this->cell_padding,
20431 'cell_margin' => $this->cell_margin,
20432 'LineWidth' => $this->LineWidth,
20433 'linestyleWidth' => $this->linestyleWidth,
20434 'linestyleCap' => $this->linestyleCap,
20435 'linestyleJoin' => $this->linestyleJoin,
20436 'linestyleDash' => $this->linestyleDash,
20437 'textrendermode' => $this->textrendermode,
20438 'textstrokewidth' => $this->textstrokewidth,
20439 'DrawColor' => $this->DrawColor,
20440 'FillColor' => $this->FillColor,
20441 'TextColor' => $this->TextColor,
20442 'ColorFlag' => $this->ColorFlag,
20443 'bgcolor' => $this->bgcolor,
20444 'fgcolor' => $this->fgcolor,
20445 'htmlvspace' => $this->htmlvspace,
20446 'listindent' => $this->listindent,
20447 'listindentlevel' => $this->listindentlevel,
20448 'listnum' => $this->listnum,
20449 'listordered' => $this->listordered,
20450 'listcount' => $this->listcount,
20451 'lispacer' => $this->lispacer,
20452 'cell_height_ratio' => $this->cell_height_ratio,
20453 'font_stretching' => $this->font_stretching,
20454 'font_spacing' => $this->font_spacing,
20455 'alpha' => $this->alpha,
20457 'lasth' => $this->lasth,
20458 'tMargin' => $this->tMargin,
20459 'bMargin' => $this->bMargin,
20460 'AutoPageBreak' => $this->AutoPageBreak,
20461 'PageBreakTrigger' => $this->PageBreakTrigger,
20466 'wPt' => $this->wPt,
20467 'hPt' => $this->hPt,
20468 'fwPt' => $this->fwPt,
20469 'fhPt' => $this->fhPt,
20470 'page' => $this->page,
20471 'current_column' => $this->current_column,
20472 'num_columns' => $this->num_columns
20485 if ($this->state != 2) {
20488 $this->FontFamily = $gvars[
'FontFamily'];
20489 $this->FontStyle = $gvars[
'FontStyle'];
20490 $this->FontSizePt = $gvars[
'FontSizePt'];
20491 $this->rMargin = $gvars[
'rMargin'];
20492 $this->lMargin = $gvars[
'lMargin'];
20493 $this->cell_padding = $gvars[
'cell_padding'];
20494 $this->cell_margin = $gvars[
'cell_margin'];
20495 $this->LineWidth = $gvars[
'LineWidth'];
20496 $this->linestyleWidth = $gvars[
'linestyleWidth'];
20497 $this->linestyleCap = $gvars[
'linestyleCap'];
20498 $this->linestyleJoin = $gvars[
'linestyleJoin'];
20499 $this->linestyleDash = $gvars[
'linestyleDash'];
20500 $this->textrendermode = $gvars[
'textrendermode'];
20501 $this->textstrokewidth = $gvars[
'textstrokewidth'];
20502 $this->DrawColor = $gvars[
'DrawColor'];
20503 $this->FillColor = $gvars[
'FillColor'];
20504 $this->TextColor = $gvars[
'TextColor'];
20505 $this->ColorFlag = $gvars[
'ColorFlag'];
20506 $this->bgcolor = $gvars[
'bgcolor'];
20507 $this->fgcolor = $gvars[
'fgcolor'];
20508 $this->htmlvspace = $gvars[
'htmlvspace'];
20509 $this->listindent = $gvars[
'listindent'];
20510 $this->listindentlevel = $gvars[
'listindentlevel'];
20511 $this->listnum = $gvars[
'listnum'];
20512 $this->listordered = $gvars[
'listordered'];
20513 $this->listcount = $gvars[
'listcount'];
20514 $this->lispacer = $gvars[
'lispacer'];
20515 $this->cell_height_ratio = $gvars[
'cell_height_ratio'];
20516 $this->font_stretching = $gvars[
'font_stretching'];
20517 $this->font_spacing = $gvars[
'font_spacing'];
20518 $this->alpha = $gvars[
'alpha'];
20521 $this->lasth = $gvars[
'lasth'];
20522 $this->tMargin = $gvars[
'tMargin'];
20523 $this->bMargin = $gvars[
'bMargin'];
20524 $this->AutoPageBreak = $gvars[
'AutoPageBreak'];
20525 $this->PageBreakTrigger = $gvars[
'PageBreakTrigger'];
20526 $this->x = $gvars[
'x'];
20527 $this->y = $gvars[
'y'];
20528 $this->w = $gvars[
'w'];
20529 $this->h = $gvars[
'h'];
20530 $this->wPt = $gvars[
'wPt'];
20531 $this->hPt = $gvars[
'hPt'];
20532 $this->fwPt = $gvars[
'fwPt'];
20533 $this->fhPt = $gvars[
'fhPt'];
20534 $this->page = $gvars[
'page'];
20535 $this->current_column = $gvars[
'current_column'];
20536 $this->num_columns = $gvars[
'num_columns'];
20538 $this->_out(
''.$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' '.$this->FillColor.
'');
20540 $this->SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
20574 $f = @fopen($filename, $fmode);
20576 $this->Error(
'Unable to write cache file: '.$filename);
20582 if (!isset($this->cache_file_length[
'_'.$filename])) {
20583 $this->cache_file_length[
'_'.$filename] = strlen($data);
20585 $this->cache_file_length[
'_'.$filename] += strlen($data);
20597 return file_get_contents($filename);
20607 $this->bufferlen += strlen($data);
20608 if ($this->diskcache) {
20612 $this->writeDiskCache($this->buffer, $data,
true);
20614 $this->buffer .= $data;
20625 $this->bufferlen = strlen($data);
20626 if ($this->diskcache) {
20630 $this->writeDiskCache($this->buffer, $data,
false);
20632 $this->buffer = $data;
20643 if ($this->diskcache) {
20644 return $this->readDiskCache($this->buffer);
20646 return $this->buffer;
20659 if ($this->diskcache) {
20660 if (!isset($this->pages[$page])) {
20663 $this->writeDiskCache($this->pages[$page], $data, $append);
20666 $this->pages[$page] .= $data;
20668 $this->pages[$page] = $data;
20671 if ($append AND isset($this->pagelen[$page])) {
20672 $this->pagelen[$page] += strlen($data);
20674 $this->pagelen[$page] = strlen($data);
20686 if ($this->diskcache) {
20687 return $this->readDiskCache($this->pages[$page]);
20688 } elseif (isset($this->pages[$page])) {
20689 return $this->pages[$page];
20703 if (($data[
'i'] = array_search($image, $this->imagekeys)) === FALSE) {
20704 $this->imagekeys[$this->numimages] = $image;
20705 $data[
'i'] = $this->numimages;
20706 ++$this->numimages;
20708 if ($this->diskcache) {
20709 if (!isset($this->images[$image])) {
20712 $this->writeDiskCache($this->images[$image], serialize($data));
20714 $this->images[$image] = $data;
20728 if (!isset($this->images[$image])) {
20729 $this->setImageBuffer($image, array());
20731 if ($this->diskcache) {
20732 $tmpimg = $this->getImageBuffer($image);
20733 $tmpimg[$key] = $data;
20734 $this->writeDiskCache($this->images[$image], serialize($tmpimg));
20736 $this->images[$image][$key] = $data;
20748 if ($this->diskcache AND isset($this->images[$image])) {
20749 return unserialize($this->readDiskCache($this->images[$image]));
20750 } elseif (isset($this->images[$image])) {
20751 return $this->images[$image];
20764 if ($this->diskcache) {
20765 if (!isset($this->fonts[$font])) {
20768 $this->writeDiskCache($this->fonts[$font], serialize($data));
20770 $this->fonts[$font] = $data;
20772 if (!in_array($font, $this->fontkeys)) {
20773 $this->fontkeys[] = $font;
20776 $this->font_obj_ids[$font] = $this->n;
20777 $this->setFontSubBuffer($font,
'n', $this->n);
20790 if (!isset($this->fonts[$font])) {
20791 $this->setFontBuffer($font, array());
20793 if ($this->diskcache) {
20794 $tmpfont = $this->getFontBuffer($font);
20795 $tmpfont[$key] = $data;
20796 $this->writeDiskCache($this->fonts[$font], serialize($tmpfont));
20798 $this->fonts[$font][$key] = $data;
20810 if ($this->diskcache AND isset($this->fonts[$font])) {
20811 return unserialize($this->readDiskCache($this->fonts[$font]));
20812 } elseif (isset($this->fonts[$font])) {
20813 return $this->fonts[$font];
20827 if (($frompage > $this->numpages) OR ($frompage <= $topage)) {
20830 if ($frompage == $this->page) {
20835 $tmppage = $this->getPageBuffer($frompage);
20836 $tmppagedim = $this->pagedim[$frompage];
20837 $tmppagelen = $this->pagelen[$frompage];
20838 $tmpintmrk = $this->intmrk[$frompage];
20839 $tmpbordermrk = $this->bordermrk[$frompage];
20840 $tmpcntmrk = $this->cntmrk[$frompage];
20841 $tmppageobjects = $this->pageobjects[$frompage];
20842 if (isset($this->footerpos[$frompage])) {
20843 $tmpfooterpos = $this->footerpos[$frompage];
20845 if (isset($this->footerlen[$frompage])) {
20846 $tmpfooterlen = $this->footerlen[$frompage];
20848 if (isset($this->transfmrk[$frompage])) {
20849 $tmptransfmrk = $this->transfmrk[$frompage];
20851 if (isset($this->PageAnnots[$frompage])) {
20852 $tmpannots = $this->PageAnnots[$frompage];
20854 if (isset($this->newpagegroup) AND !empty($this->newpagegroup)) {
20855 for ($i = $frompage; $i > $topage; --$i) {
20856 if (isset($this->newpagegroup[$i]) AND (($i + $this->pagegroups[$this->newpagegroup[$i]]) > $frompage)) {
20857 --$this->pagegroups[$this->newpagegroup[$i]];
20861 for ($i = $topage; $i > 0; --$i) {
20862 if (isset($this->newpagegroup[$i]) AND (($i + $this->pagegroups[$this->newpagegroup[$i]]) > $topage)) {
20863 ++$this->pagegroups[$this->newpagegroup[$i]];
20868 for ($i = $frompage; $i > $topage; --$i) {
20871 $this->setPageBuffer($i, $this->getPageBuffer($j));
20872 $this->pagedim[$i] = $this->pagedim[$j];
20873 $this->pagelen[$i] = $this->pagelen[$j];
20874 $this->intmrk[$i] = $this->intmrk[$j];
20875 $this->bordermrk[$i] = $this->bordermrk[$j];
20876 $this->cntmrk[$i] = $this->cntmrk[$j];
20877 $this->pageobjects[$i] = $this->pageobjects[$j];
20878 if (isset($this->footerpos[$j])) {
20879 $this->footerpos[$i] = $this->footerpos[$j];
20880 } elseif (isset($this->footerpos[$i])) {
20881 unset($this->footerpos[$i]);
20883 if (isset($this->footerlen[$j])) {
20884 $this->footerlen[$i] = $this->footerlen[$j];
20885 } elseif (isset($this->footerlen[$i])) {
20886 unset($this->footerlen[$i]);
20888 if (isset($this->transfmrk[$j])) {
20889 $this->transfmrk[$i] = $this->transfmrk[$j];
20890 } elseif (isset($this->transfmrk[$i])) {
20891 unset($this->transfmrk[$i]);
20893 if (isset($this->PageAnnots[$j])) {
20894 $this->PageAnnots[$i] = $this->PageAnnots[$j];
20895 } elseif (isset($this->PageAnnots[$i])) {
20896 unset($this->PageAnnots[$i]);
20898 if (isset($this->newpagegroup[$j])) {
20899 $this->newpagegroup[$i] = $this->newpagegroup[$j];
20900 unset($this->newpagegroup[$j]);
20902 if ($this->currpagegroup == $j) {
20903 $this->currpagegroup = $i;
20906 $this->setPageBuffer($topage, $tmppage);
20907 $this->pagedim[$topage] = $tmppagedim;
20908 $this->pagelen[$topage] = $tmppagelen;
20909 $this->intmrk[$topage] = $tmpintmrk;
20910 $this->bordermrk[$topage] = $tmpbordermrk;
20911 $this->cntmrk[$topage] = $tmpcntmrk;
20912 $this->pageobjects[$topage] = $tmppageobjects;
20913 if (isset($tmpfooterpos)) {
20914 $this->footerpos[$topage] = $tmpfooterpos;
20915 } elseif (isset($this->footerpos[$topage])) {
20916 unset($this->footerpos[$topage]);
20918 if (isset($tmpfooterlen)) {
20919 $this->footerlen[$topage] = $tmpfooterlen;
20920 } elseif (isset($this->footerlen[$topage])) {
20921 unset($this->footerlen[$topage]);
20923 if (isset($tmptransfmrk)) {
20924 $this->transfmrk[$topage] = $tmptransfmrk;
20925 } elseif (isset($this->transfmrk[$topage])) {
20926 unset($this->transfmrk[$topage]);
20928 if (isset($tmpannots)) {
20929 $this->PageAnnots[$topage] = $tmpannots;
20930 } elseif (isset($this->PageAnnots[$topage])) {
20931 unset($this->PageAnnots[$topage]);
20934 $tmpoutlines = $this->outlines;
20935 foreach ($tmpoutlines as $key => $outline) {
20936 if (($outline[
'p'] >= $topage) AND ($outline[
'p'] < $frompage)) {
20937 $this->outlines[$key][
'p'] = ($outline[
'p'] + 1);
20938 } elseif ($outline[
'p'] == $frompage) {
20939 $this->outlines[$key][
'p'] = $topage;
20943 $tmpdests = $this->dests;
20944 foreach ($tmpdests as $key => $dest) {
20945 if (($dest[
'p'] >= $topage) AND ($dest[
'p'] < $frompage)) {
20946 $this->dests[$key][
'p'] = ($dest[
'p'] + 1);
20947 } elseif ($dest[
'p'] == $frompage) {
20948 $this->dests[$key][
'p'] = $topage;
20952 $tmplinks = $this->links;
20953 foreach ($tmplinks as $key => $link) {
20954 if (($link[0] >= $topage) AND ($link[0] < $frompage)) {
20955 $this->links[$key][0] = ($link[0] + 1);
20956 } elseif ($link[0] == $frompage) {
20957 $this->links[$key][0] = $topage;
20961 $jfrompage = $frompage;
20962 $jtopage = $topage;
20963 if (preg_match_all(
'/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/', $this->javascript, $pamatch) > 0) {
20964 foreach($pamatch[0] as $pk => $pmatch) {
20965 $pagenum = intval($pamatch[3][$pk]) + 1;
20966 if (($pagenum >= $jtopage) AND ($pagenum < $jfrompage)) {
20967 $newpage = ($pagenum + 1);
20968 } elseif ($pagenum == $jfrompage) {
20969 $newpage = $jtopage;
20971 $newpage = $pagenum;
20974 $newjs =
"this.addField(\'".$pamatch[1][$pk].
"\',\'".$pamatch[2][$pk].
"\',".$newpage;
20975 $this->javascript = str_replace($pmatch, $newjs, $this->javascript);
20980 $this->lastPage(
true);
20992 if (($page < 1) OR ($page > $this->numpages)) {
20996 unset($this->pages[$page]);
20997 unset($this->pagedim[$page]);
20998 unset($this->pagelen[$page]);
20999 unset($this->intmrk[$page]);
21000 unset($this->bordermrk[$page]);
21001 unset($this->cntmrk[$page]);
21002 foreach ($this->pageobjects[$page] as $oid) {
21003 if (isset($this->offsets[$oid])){
21004 unset($this->offsets[$oid]);
21007 unset($this->pageobjects[$page]);
21008 if (isset($this->footerpos[$page])) {
21009 unset($this->footerpos[$page]);
21011 if (isset($this->footerlen[$page])) {
21012 unset($this->footerlen[$page]);
21014 if (isset($this->transfmrk[$page])) {
21015 unset($this->transfmrk[$page]);
21017 if (isset($this->PageAnnots[$page])) {
21018 unset($this->PageAnnots[$page]);
21020 if (isset($this->newpagegroup) AND !empty($this->newpagegroup)) {
21021 for ($i = $page; $i > 0; --$i) {
21022 if (isset($this->newpagegroup[$i]) AND (($i + $this->pagegroups[$this->newpagegroup[$i]]) > $page)) {
21023 --$this->pagegroups[$this->newpagegroup[$i]];
21028 if (isset($this->pageopen[$page])) {
21029 unset($this->pageopen[$page]);
21031 if ($page < $this->numpages) {
21033 for ($i = $page; $i < $this->numpages; ++$i) {
21036 $this->setPageBuffer($i, $this->getPageBuffer($j));
21037 $this->pagedim[$i] = $this->pagedim[$j];
21038 $this->pagelen[$i] = $this->pagelen[$j];
21039 $this->intmrk[$i] = $this->intmrk[$j];
21040 $this->bordermrk[$i] = $this->bordermrk[$j];
21041 $this->cntmrk[$i] = $this->cntmrk[$j];
21042 $this->pageobjects[$i] = $this->pageobjects[$j];
21043 if (isset($this->footerpos[$j])) {
21044 $this->footerpos[$i] = $this->footerpos[$j];
21045 } elseif (isset($this->footerpos[$i])) {
21046 unset($this->footerpos[$i]);
21048 if (isset($this->footerlen[$j])) {
21049 $this->footerlen[$i] = $this->footerlen[$j];
21050 } elseif (isset($this->footerlen[$i])) {
21051 unset($this->footerlen[$i]);
21053 if (isset($this->transfmrk[$j])) {
21054 $this->transfmrk[$i] = $this->transfmrk[$j];
21055 } elseif (isset($this->transfmrk[$i])) {
21056 unset($this->transfmrk[$i]);
21058 if (isset($this->PageAnnots[$j])) {
21059 $this->PageAnnots[$i] = $this->PageAnnots[$j];
21060 } elseif (isset($this->PageAnnots[$i])) {
21061 unset($this->PageAnnots[$i]);
21063 if (isset($this->newpagegroup[$j])) {
21064 $this->newpagegroup[$i] = $this->newpagegroup[$j];
21065 unset($this->newpagegroup[$j]);
21067 if ($this->currpagegroup == $j) {
21068 $this->currpagegroup = $i;
21070 if (isset($this->pageopen[$j])) {
21071 $this->pageopen[$i] = $this->pageopen[$j];
21072 } elseif (isset($this->pageopen[$i])) {
21073 unset($this->pageopen[$i]);
21077 unset($this->pages[$this->numpages]);
21078 unset($this->pagedim[$this->numpages]);
21079 unset($this->pagelen[$this->numpages]);
21080 unset($this->intmrk[$this->numpages]);
21081 unset($this->bordermrk[$this->numpages]);
21082 unset($this->cntmrk[$this->numpages]);
21083 foreach ($this->pageobjects[$this->numpages] as $oid) {
21084 if (isset($this->offsets[$oid])){
21085 unset($this->offsets[$oid]);
21088 unset($this->pageobjects[$this->numpages]);
21089 if (isset($this->footerpos[$this->numpages])) {
21090 unset($this->footerpos[$this->numpages]);
21092 if (isset($this->footerlen[$this->numpages])) {
21093 unset($this->footerlen[$this->numpages]);
21095 if (isset($this->transfmrk[$this->numpages])) {
21096 unset($this->transfmrk[$this->numpages]);
21098 if (isset($this->PageAnnots[$this->numpages])) {
21099 unset($this->PageAnnots[$this->numpages]);
21101 if (isset($this->newpagegroup[$this->numpages])) {
21102 unset($this->newpagegroup[$this->numpages]);
21104 if ($this->currpagegroup == $this->numpages) {
21105 $this->currpagegroup = ($this->numpages - 1);
21107 if (isset($this->pagegroups[$this->numpages])) {
21108 unset($this->pagegroups[$this->numpages]);
21110 if (isset($this->pageopen[$this->numpages])) {
21111 unset($this->pageopen[$this->numpages]);
21115 $this->page = $this->numpages;
21117 $tmpoutlines = $this->outlines;
21118 foreach ($tmpoutlines as $key => $outline) {
21119 if ($outline[
'p'] > $page) {
21120 $this->outlines[$key][
'p'] = $outline[
'p'] - 1;
21121 } elseif ($outline[
'p'] == $page) {
21122 unset($this->outlines[$key]);
21126 $tmpdests = $this->dests;
21127 foreach ($tmpdests as $key => $dest) {
21128 if ($dest[
'p'] > $page) {
21129 $this->dests[$key][
'p'] = $dest[
'p'] - 1;
21130 } elseif ($dest[
'p'] == $page) {
21131 unset($this->dests[$key]);
21135 $tmplinks = $this->links;
21136 foreach ($tmplinks as $key => $link) {
21137 if ($link[0] > $page) {
21138 $this->links[$key][0] = $link[0] - 1;
21139 } elseif ($link[0] == $page) {
21140 unset($this->links[$key]);
21145 if (preg_match_all(
'/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/', $this->javascript, $pamatch) > 0) {
21146 foreach($pamatch[0] as $pk => $pmatch) {
21147 $pagenum = intval($pamatch[3][$pk]) + 1;
21148 if ($pagenum >= $jpage) {
21149 $newpage = ($pagenum - 1);
21150 } elseif ($pagenum == $jpage) {
21153 $newpage = $pagenum;
21156 $newjs =
"this.addField(\'".$pamatch[1][$pk].
"\',\'".$pamatch[2][$pk].
"\',".$newpage;
21157 $this->javascript = str_replace($pmatch, $newjs, $this->javascript);
21162 if ($this->numpages > 0) {
21163 $this->lastPage(
true);
21178 $page = $this->page;
21180 if (($page < 1) OR ($page > $this->numpages)) {
21187 $this->page = $this->numpages;
21188 $this->setPageBuffer($this->page, $this->getPageBuffer($page));
21189 $this->pagedim[$this->page] = $this->pagedim[$page];
21190 $this->pagelen[$this->page] = $this->pagelen[$page];
21191 $this->intmrk[$this->page] = $this->intmrk[$page];
21192 $this->bordermrk[$this->page] = $this->bordermrk[$page];
21193 $this->cntmrk[$this->page] = $this->cntmrk[$page];
21194 $this->pageobjects[$this->page] = $this->pageobjects[$page];
21195 $this->pageopen[$this->page] =
false;
21196 if (isset($this->footerpos[$page])) {
21197 $this->footerpos[$this->page] = $this->footerpos[$page];
21199 if (isset($this->footerlen[$page])) {
21200 $this->footerlen[$this->page] = $this->footerlen[$page];
21202 if (isset($this->transfmrk[$page])) {
21203 $this->transfmrk[$this->page] = $this->transfmrk[$page];
21205 if (isset($this->PageAnnots[$page])) {
21206 $this->PageAnnots[$this->page] = $this->PageAnnots[$page];
21208 if (isset($this->newpagegroup[$page])) {
21210 $this->newpagegroup[$this->page] =
sizeof($this->newpagegroup) + 1;
21211 $this->currpagegroup = $this->newpagegroup[$this->page];
21212 $this->pagegroups[$this->currpagegroup] = 1;
21213 } elseif (isset($this->currpagegroup) AND ($this->currpagegroup > 0)) {
21214 ++$this->pagegroups[$this->currpagegroup];
21217 $tmpoutlines = $this->outlines;
21218 foreach ($tmpoutlines as $key => $outline) {
21219 if ($outline[
'p'] == $page) {
21220 $this->outlines[] = array(
't' => $outline[
't'],
'l' => $outline[
'l'],
'x' => $outline[
'x'],
'y' => $outline[
'y'],
'p' => $this->page,
's' => $outline[
's'],
'c' => $outline[
'c']);
21224 $tmplinks = $this->links;
21225 foreach ($tmplinks as $key => $link) {
21226 if ($link[0] == $page) {
21227 $this->links[] = array($this->page, $link[1]);
21231 $this->lastPage(
true);
21252 public function addTOC($page=
'', $numbersfont=
'', $filler=
'.', $toc_name=
'TOC', $style=
'', $color=array(0,0,0)) {
21253 $fontsize = $this->FontSizePt;
21254 $fontfamily = $this->FontFamily;
21255 $fontstyle = $this->FontStyle;
21256 $w = $this->w - $this->lMargin - $this->rMargin;
21257 $spacer = $this->GetStringWidth(chr(32)) * 4;
21258 $lmargin = $this->lMargin;
21259 $rmargin = $this->rMargin;
21260 $x_start = $this->GetX();
21261 $page_first = $this->page;
21262 $current_page = $this->page;
21263 $page_fill_start =
false;
21264 $page_fill_end =
false;
21265 $current_column = $this->current_column;
21267 $numbersfont = $this->default_monospaced_font;
21280 $this->SetFont($numbersfont, $fontstyle, $fontsize);
21281 $numwidth = $this->GetStringWidth(
'00000');
21283 foreach ($this->outlines as $key => $outline) {
21285 if (($this->page > $page_first) AND ($outline[
'p'] >= $this->numpages)) {
21286 $outline[
'p'] += ($this->page - $page_first);
21295 if ($outline[
'l'] == 0) {
21296 $this->SetFont($fontfamily, $outline[
's'].
'B', $fontsize);
21298 $this->SetFont($fontfamily, $outline[
's'], $fontsize - $outline[
'l']);
21300 $this->SetTextColorArray($outline[
'c']);
21302 $this->checkPageBreak(2 * $this->getCellHeight($this->FontSize));
21304 if (($this->page == $current_page) AND ($this->current_column == $current_column)) {
21305 $this->lMargin = $lmargin;
21306 $this->rMargin = $rmargin;
21308 if ($this->current_column != $current_column) {
21310 $x_start = $this->w - $this->columns[$this->current_column][
'x'];
21312 $x_start = $this->columns[$this->current_column][
'x'];
21315 $lmargin = $this->lMargin;
21316 $rmargin = $this->rMargin;
21317 $current_page = $this->page;
21318 $current_column = $this->current_column;
21320 $this->SetX($x_start);
21321 $indent = ($spacer * $outline[
'l']);
21323 $this->x -= $indent;
21324 $this->rMargin = $this->w - $this->x;
21326 $this->x += $indent;
21327 $this->lMargin = $this->x;
21329 $link = $this->AddLink();
21330 $this->SetLink($link, $outline[
'y'], $outline[
'p']);
21333 $txt =
' '.$outline[
't'];
21335 $txt = $outline[
't'].
' ';
21337 $this->Write(0, $txt, $link,
false, $aligntext,
false, 0,
false,
false, 0, $numwidth,
'');
21339 $tw = $this->x - $this->lMargin;
21341 $tw = $this->w - $this->rMargin - $this->x;
21343 $this->SetFont($numbersfont, $fontstyle, $fontsize);
21345 $pagenum = $outline[
'p'];
21348 $pagenum =
'{#'.($outline[
'p']).
'}';
21349 if ($this->isUnicodeFont()) {
21350 $pagenum =
'{'.$pagenum.
'}';
21352 $maxpage = max($maxpage, $outline[
'p']);
21354 $fw = ($tw - $this->GetStringWidth($pagenum.$filler));
21355 $wfiller = $this->GetStringWidth($filler);
21356 if ($wfiller > 0) {
21357 $numfills = floor($fw / $wfiller);
21361 if ($numfills > 0) {
21362 $rowfill = str_repeat($filler, $numfills);
21367 $pagenum = $pagenum.$gap.$rowfill;
21369 $pagenum = $rowfill.$gap.$pagenum;
21372 $this->Cell($tw, 0, $pagenum, 0, 1, $alignnum, 0, $link, 0);
21374 $page_last = $this->getPage();
21375 $numpages = ($page_last - $page_first + 1);
21377 if ($this->booklet) {
21379 $page_fill_start = ((($page_first % 2) == 0) XOR (($page % 2) == 0));
21380 $page_fill_end = (!((($numpages % 2) == 0) XOR ($page_fill_start)));
21381 if ($page_fill_start) {
21387 if ($page_fill_end) {
21394 $maxpage = max($maxpage, $page_last);
21396 for ($p = $page_first; $p <= $page_last; ++$p) {
21398 $temppage = $this->getPageBuffer($p);
21399 for ($n = 1; $n <= $maxpage; ++$n) {
21403 $pnalias = $this->getInternalPageNumberAliases($a);
21405 if (($n >= $page) AND ($n <= $this->numpages)) {
21406 $np = $n + $numpages;
21413 foreach ($pnalias[
'u'] as $u) {
21414 $sfill = str_repeat($filler, max(0, (strlen($u) - strlen($nu.
' '))));
21416 $nr = $nu.TCPDF_FONTS::UTF8ToUTF16BE(
' '.$sfill,
false, $this->isunicode, $this->CurrentFont);
21420 $temppage = str_replace($u, $nr, $temppage);
21422 foreach ($pnalias[
'a'] as $a) {
21423 $sfill = str_repeat($filler, max(0, (strlen($a) - strlen($na.
' '))));
21425 $nr = $na.
' '.$sfill;
21427 $nr = $sfill.
' '.$na;
21429 $temppage = str_replace($a, $nr, $temppage);
21433 $this->setPageBuffer($p, $temppage);
21436 $this->Bookmark($toc_name, 0, 0, $page_first, $style, $color);
21437 if ($page_fill_start) {
21438 $this->movePage($page_last, $page_first);
21440 for ($i = 0; $i < $numpages; ++$i) {
21441 $this->movePage($page_last, $page);
21462 public function addHTMLTOC($page=
'', $toc_name=
'TOC', $templates=array(), $correct_align=
true, $style=
'', $color=array(0,0,0)) {
21464 $prev_htmlLinkColorArray = $this->htmlLinkColorArray;
21465 $prev_htmlLinkFontStyle = $this->htmlLinkFontStyle;
21467 $this->htmlLinkColorArray = array();
21468 $this->htmlLinkFontStyle =
'';
21469 $page_first = $this->getPage();
21470 $page_fill_start =
false;
21471 $page_fill_end =
false;
21473 $current_font = $this->FontFamily;
21474 foreach ($templates as $level => $html) {
21475 $dom = $this->getHtmlDomArray($html);
21476 foreach ($dom as $key => $value) {
21477 if ($value[
'value'] ==
'#TOC_PAGE_NUMBER#') {
21478 $this->SetFont($dom[($key - 1)][
'fontname']);
21479 $templates[
'F'.$level] = $this->isUnicodeFont();
21483 $this->SetFont($current_font);
21485 foreach ($this->outlines as $key => $outline) {
21487 $row = $templates[$outline[
'l']];
21489 $pagenum = $outline[
'p'];
21492 $pagenum =
'{#'.($outline[
'p']).
'}';
21493 if ($templates[
'F'.$outline[
'l']]) {
21494 $pagenum =
'{'.$pagenum.
'}';
21496 $maxpage = max($maxpage, $outline[
'p']);
21499 $row = str_replace(
'#TOC_DESCRIPTION#', $outline[
't'], $row);
21500 $row = str_replace(
'#TOC_PAGE_NUMBER#', $pagenum, $row);
21502 $row =
'<a href="#'.$outline[
'p'].
','.$outline[
'y'].
'">'.$row.
'</a>';
21504 $this->writeHTML($row,
false,
false,
true,
false,
'');
21507 $this->htmlLinkColorArray = $prev_htmlLinkColorArray;
21508 $this->htmlLinkFontStyle = $prev_htmlLinkFontStyle;
21510 $page_last = $this->getPage();
21511 $numpages = ($page_last - $page_first + 1);
21513 if ($this->booklet) {
21515 $page_fill_start = ((($page_first % 2) == 0) XOR (($page % 2) == 0));
21516 $page_fill_end = (!((($numpages % 2) == 0) XOR ($page_fill_start)));
21517 if ($page_fill_start) {
21523 if ($page_fill_end) {
21530 $maxpage = max($maxpage, $page_last);
21532 for ($p = $page_first; $p <= $page_last; ++$p) {
21534 $temppage = $this->getPageBuffer($p);
21535 for ($n = 1; $n <= $maxpage; ++$n) {
21539 $pnalias = $this->getInternalPageNumberAliases($a);
21542 $np = $n + $numpages;
21549 foreach ($pnalias[
'u'] as $u) {
21550 if ($correct_align) {
21551 $sfill = str_repeat($filler, (strlen($u) - strlen($nu.
' ')));
21553 $nr = $nu.TCPDF_FONTS::UTF8ToUTF16BE(
' '.$sfill,
false, $this->isunicode, $this->CurrentFont);
21560 $temppage = str_replace($u, $nr, $temppage);
21562 foreach ($pnalias[
'a'] as $a) {
21563 if ($correct_align) {
21564 $sfill = str_repeat($filler, (strlen($a) - strlen($na.
' ')));
21566 $nr = $na.
' '.$sfill;
21568 $nr = $sfill.
' '.$na;
21573 $temppage = str_replace($a, $nr, $temppage);
21577 $this->setPageBuffer($p, $temppage);
21580 $this->Bookmark($toc_name, 0, 0, $page_first, $style, $color);
21581 if ($page_fill_start) {
21582 $this->movePage($page_last, $page_first);
21584 for ($i = 0; $i < $numpages; ++$i) {
21585 $this->movePage($page_last, $page);
21596 if (isset($this->objcopy)) {
21598 $this->commitTransaction();
21601 $this->start_transaction_page = $this->page;
21602 $this->start_transaction_y = $this->y;
21613 if (isset($this->objcopy)) {
21614 $this->objcopy->_destroy(
true,
true);
21615 unset($this->objcopy);
21627 if (isset($this->objcopy)) {
21628 if (isset($this->objcopy->diskcache) AND $this->objcopy->diskcache) {
21630 foreach ($this->objcopy->cache_file_length as $file => $length) {
21631 $file = substr($file, 1);
21632 $handle = fopen($file,
'r+');
21633 ftruncate($handle, $length);
21636 $this->_destroy(
true,
true);
21638 $objvars = get_object_vars($this->objcopy);
21639 foreach ($objvars as $key => $value) {
21640 $this->$key = $value;
21643 return $this->objcopy;
21659 $this->columns = array();
21660 if ($numcols < 2) {
21662 $this->columns = array();
21665 $maxwidth = ($this->w - $this->original_lMargin - $this->original_rMargin) / $numcols;
21666 if (($width == 0) OR ($width > $maxwidth)) {
21667 $width = $maxwidth;
21673 $space = (($this->w - $this->original_lMargin - $this->original_rMargin - ($numcols * $width)) / ($numcols - 1));
21675 for ($i = 0; $i < $numcols; ++$i) {
21676 $this->columns[$i] = array(
'w' => $width,
's' => $space,
'y' => $y);
21679 $this->num_columns = $numcols;
21680 $this->current_column = 0;
21681 $this->column_start_page = $this->page;
21682 $this->selectColumn(0);
21691 $this->lMargin = $this->original_lMargin;
21692 $this->rMargin = $this->original_rMargin;
21693 $this->setEqualColumns();
21704 $this->columns = $columns;
21705 $this->num_columns = count($columns);
21706 $this->current_column = 0;
21707 $this->column_start_page = $this->page;
21708 $this->selectColumn(0);
21718 if (is_string($col)) {
21719 $col = $this->current_column;
21720 } elseif ($col >= $this->num_columns) {
21723 $xshift = array(
'x' => 0,
's' => array(
'H' => 0,
'V' => 0),
'p' => array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0));
21724 $enable_thead =
false;
21725 if ($this->num_columns > 1) {
21726 if ($col != $this->current_column) {
21728 if ($this->column_start_page == $this->page) {
21729 $this->y = $this->columns[$col][
'y'];
21731 $this->y = $this->tMargin;
21734 if (($this->page > $this->maxselcol[
'page']) OR (($this->page == $this->maxselcol[
'page']) AND ($col > $this->maxselcol[
'column']))) {
21735 $enable_thead =
true;
21736 $this->maxselcol[
'page'] = $this->page;
21737 $this->maxselcol[
'column'] = $col;
21740 $xshift = $this->colxshift;
21742 $listindent = ($this->listindentlevel * $this->listindent);
21745 for ($i = 0; $i < $col; ++$i) {
21746 $colpos += ($this->columns[$i][
'w'] + $this->columns[$i][
's']);
21749 $x = $this->w - $this->original_rMargin - $colpos;
21750 $this->rMargin = ($this->w - $x + $listindent);
21751 $this->lMargin = ($x - $this->columns[$col][
'w']);
21752 $this->x = $x - $listindent;
21754 $x = $this->original_lMargin + $colpos;
21755 $this->lMargin = ($x + $listindent);
21756 $this->rMargin = ($this->w - $x - $this->columns[$col][
'w']);
21757 $this->x = $x + $listindent;
21759 $this->columns[$col][
'x'] = $x;
21761 $this->current_column = $col;
21763 $this->newline =
true;
21766 if ($enable_thead) {
21768 $this->writeHTML($this->thead,
false,
false,
false,
false,
'');
21769 $this->y += $xshift[
's'][
'V'];
21771 if (!isset($this->columns[$col][
'th'])) {
21772 $this->columns[$col][
'th'] = array();
21774 $this->columns[$col][
'th'][
'\''.$this->page.
'\''] = $this->y;
21776 } elseif (isset($this->columns[$col][
'th'][
'\''.$this->page.
'\''])) {
21777 $this->y = $this->columns[$col][
'th'][
'\''.$this->page.
'\''];
21782 $this->rMargin += $xshift[
'x'];
21783 $this->x -= ($xshift[
'x'] + $xshift[
'p'][
'R']);
21785 $this->lMargin += $xshift[
'x'];
21786 $this->x += $xshift[
'x'] + $xshift[
'p'][
'L'];
21797 return $this->current_column;
21807 return $this->num_columns;
21824 if ($fill ===
true) {
21826 if ($clip ===
true) {
21828 $textrendermode = 6;
21831 $textrendermode = 2;
21833 $textstrokewidth = $stroke;
21835 if ($clip ===
true) {
21837 $textrendermode = 4;
21840 $textrendermode = 0;
21845 if ($clip ===
true) {
21847 $textrendermode = 5;
21850 $textrendermode = 1;
21852 $textstrokewidth = $stroke;
21854 if ($clip ===
true) {
21856 $textrendermode = 7;
21859 $textrendermode = 3;
21863 $this->textrendermode = $textrendermode;
21864 $this->textstrokewidth = $stroke;
21873 public function setTextShadow($params=array(
'enabled'=>
false,
'depth_w'=>0,
'depth_h'=>0,
'color'=>
false,
'opacity'=>1,
'blend_mode'=>
'Normal')) {
21874 if (isset($params[
'enabled'])) {
21875 $this->txtshadow[
'enabled'] = $params[
'enabled']?
true:
false;
21877 $this->txtshadow[
'enabled'] =
false;
21879 if (isset($params[
'depth_w'])) {
21880 $this->txtshadow[
'depth_w'] = floatval($params[
'depth_w']);
21882 $this->txtshadow[
'depth_w'] = 0;
21884 if (isset($params[
'depth_h'])) {
21885 $this->txtshadow[
'depth_h'] = floatval($params[
'depth_h']);
21887 $this->txtshadow[
'depth_h'] = 0;
21889 if (isset($params[
'color']) AND ($params[
'color'] !==
false) AND is_array($params[
'color'])) {
21890 $this->txtshadow[
'color'] = $params[
'color'];
21892 $this->txtshadow[
'color'] = $this->strokecolor;
21894 if (isset($params[
'opacity'])) {
21895 $this->txtshadow[
'opacity'] = min(1, max(0, floatval($params[
'opacity'])));
21897 $this->txtshadow[
'opacity'] = 1;
21899 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'))) {
21900 $this->txtshadow[
'blend_mode'] = $params[
'blend_mode'];
21902 $this->txtshadow[
'blend_mode'] =
'Normal';
21904 if ((($this->txtshadow[
'depth_w'] == 0) AND ($this->txtshadow[
'depth_h'] == 0)) OR ($this->txtshadow[
'opacity'] == 0)) {
21905 $this->txtshadow[
'enabled'] =
false;
21916 return $this->txtshadow;
21933 protected function hyphenateWord($word, $patterns, $dictionary=array(), $leftmin=1, $rightmin=2, $charmin=1, $charmax=8) {
21934 $hyphenword = array();
21935 $numchars = count($word);
21936 if ($numchars <= $charmin) {
21941 $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})(\]?)$/';
21942 if (preg_match($pattern, $word_string) > 0) {
21946 $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})(\]?)$/';
21947 if (preg_match($pattern, $word_string) > 0) {
21951 if (isset($dictionary[$word_string])) {
21955 $tmpword = array_merge(array(95), $word, array(95));
21956 $tmpnumchars = $numchars + 2;
21957 $maxpos = $tmpnumchars - $charmin;
21958 for ($pos = 0; $pos < $maxpos; ++$pos) {
21959 $imax = min(($tmpnumchars - $pos), $charmax);
21960 for ($i = $charmin; $i <= $imax; ++$i) {
21962 if (isset($patterns[$subword])) {
21964 $pattern_length = count($pattern);
21966 for ($j = 0; $j < $pattern_length; ++$j) {
21968 if (($pattern[$j] >= 48) AND ($pattern[$j] <= 57)) {
21972 $zero = $pos + $j - $digits;
21974 if (!isset($hyphenword[$zero]) OR ($hyphenword[$zero] != $pattern[$j])) {
21984 $maxpos = $numchars - $rightmin;
21985 for ($i = $leftmin; $i <= $maxpos; ++$i) {
21986 if (isset($hyphenword[$i]) AND (($hyphenword[$i] % 2) != 0)) {
21988 array_splice($word, $i + $inserted, 0, 173);
22009 public function hyphenateText($text, $patterns, $dictionary=array(), $leftmin=1, $rightmin=2, $charmin=1, $charmax=8) {
22010 $text = $this->unhtmlentities($text);
22014 if (!is_array($patterns)) {
22020 foreach ($unichars as $char) {
22028 $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
22032 if (chr($char) ==
'<') {
22035 } elseif ($intag AND (chr($char) ==
'>')) {
22043 $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
22056 $this->rasterize_vector_images = $mode;
22067 if ($this->pdfa_mode) {
22068 $this->font_subsetting =
false;
22070 $this->font_subsetting = $enable ?
true :
false;
22082 return $this->font_subsetting;
22095 return preg_replace(
'/^'.$this->re_space[
'p'].
'+/'.$this->re_space[
'm'], $replace, $str);
22108 return preg_replace(
'/'.$this->re_space[
'p'].
'+$/'.$this->re_space[
'm'], $replace, $str);
22121 $str = $this->stringLeftTrim($str, $replace);
22122 $str = $this->stringRightTrim($str, $replace);
22134 return (($this->CurrentFont[
'type'] ==
'TrueTypeUnicode') OR ($this->CurrentFont[
'type'] ==
'cidfont0'));
22147 $fontfamily = preg_replace(
'/[^a-z0-9_\,]/',
'', strtolower($fontfamily));
22149 $fontslist = preg_split(
'/[,]/', $fontfamily);
22151 foreach ($fontslist as $font) {
22153 $font = preg_replace(
'/italic$/',
'I', $font);
22154 $font = preg_replace(
'/oblique$/',
'I', $font);
22155 $font = preg_replace(
'/bold([I]?)$/',
'B\\1', $font);
22157 $pattern = array();
22158 $replacement = array();
22159 $pattern[] =
'/^serif|^cursive|^fantasy|^timesnewroman/';
22160 $replacement[] =
'times';
22161 $pattern[] =
'/^sansserif/';
22162 $replacement[] =
'helvetica';
22163 $pattern[] =
'/^monospace/';
22164 $replacement[] =
'courier';
22165 $font = preg_replace($pattern, $replacement, $font);
22166 if (in_array(strtolower($font), $this->fontlist) OR in_array($font, $this->fontkeys)) {
22171 return $this->CurrentFont[
'fontkey'];
22189 if ($this->inxobj) {
22193 $this->inxobj =
true;
22196 $this->xobjid =
'XT'.$this->n;
22198 $this->xobjects[$this->xobjid] = array(
'n' => $this->n);
22200 $this->xobjects[$this->xobjid][
'gvars'] = $this->getGraphicVars();
22202 $this->xobjects[$this->xobjid][
'intmrk'] = 0;
22203 $this->xobjects[$this->xobjid][
'transfmrk'] = array();
22204 $this->xobjects[$this->xobjid][
'outdata'] =
'';
22205 $this->xobjects[$this->xobjid][
'xobjects'] = array();
22206 $this->xobjects[$this->xobjid][
'images'] = array();
22207 $this->xobjects[$this->xobjid][
'fonts'] = array();
22208 $this->xobjects[$this->xobjid][
'annotations'] = array();
22209 $this->xobjects[$this->xobjid][
'extgstates'] = array();
22210 $this->xobjects[$this->xobjid][
'gradients'] = array();
22211 $this->xobjects[$this->xobjid][
'spot_colors'] = array();
22213 $this->num_columns = 1;
22214 $this->current_column = 0;
22215 $this->SetAutoPageBreak(
false);
22216 if (($w ===
'') OR ($w <= 0)) {
22217 $w = $this->w - $this->lMargin - $this->rMargin;
22219 if (($h ===
'') OR ($h <= 0)) {
22220 $h = $this->h - $this->tMargin - $this->bMargin;
22222 $this->xobjects[$this->xobjid][
'x'] = 0;
22223 $this->xobjects[$this->xobjid][
'y'] = 0;
22224 $this->xobjects[$this->xobjid][
'w'] = $w;
22225 $this->xobjects[$this->xobjid][
'h'] = $h;
22228 $this->wPt = $this->w * $this->k;
22229 $this->hPt = $this->h * $this->k;
22230 $this->fwPt = $this->wPt;
22231 $this->fhPt = $this->hPt;
22234 $this->lMargin = 0;
22235 $this->rMargin = 0;
22236 $this->tMargin = 0;
22237 $this->bMargin = 0;
22239 $this->xobjects[$this->xobjid][
'group'] = $group;
22240 return $this->xobjid;
22254 if (!$this->inxobj) {
22258 $this->inxobj =
false;
22260 $this->setGraphicVars($this->xobjects[$this->xobjid][
'gvars'],
true);
22261 return $this->xobjid;
22282 public function printTemplate($id, $x=
'', $y=
'', $w=0, $h=0, $align=
'', $palign=
'', $fitonpage=
false) {
22283 if ($this->state != 2) {
22286 if (!isset($this->xobjects[$id])) {
22287 $this->Error(
'The XObject Template \''.$id.
'\' doesn\
't exist!');
22289 if ($this->inxobj) {
22290 if ($id == $this->xobjid) {
22292 $this->endTemplate();
22295 $this->xobjects[$this->xobjid][
'xobjects'][$id] = $this->xobjects[$id];
22306 list($x, $y) = $this->checkPageRegions($h, $x, $y);
22307 $ow = $this->xobjects[$id][
'w'];
22311 $oh = $this->xobjects[$id][
'h'];
22316 if (($w <= 0) AND ($h <= 0)) {
22319 } elseif ($w <= 0) {
22320 $w = $h * $ow / $oh;
22321 } elseif ($h <= 0) {
22322 $h = $w * $oh / $ow;
22325 list($w, $h, $x, $y) = $this->fitBlock($w, $h, $x, $y, $fitonpage);
22330 if ($palign ==
'L') {
22331 $xt = $this->lMargin;
22332 } elseif ($palign ==
'C') {
22333 $xt = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
22334 } elseif ($palign ==
'R') {
22335 $xt = $this->w - $this->rMargin - $w;
22341 if ($palign ==
'L') {
22342 $xt = $this->lMargin;
22343 } elseif ($palign ==
'C') {
22344 $xt = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
22345 } elseif ($palign ==
'R') {
22346 $xt = $this->w - $this->rMargin - $w;
22353 $this->StartTransform();
22362 $tm[4] = $xt * $this->k;
22363 $tm[5] = ($this->h - $h - $y) * $this->k;
22364 $this->Transform($tm);
22366 $this->_out(
'/'.$id.
' Do');
22367 $this->StopTransform();
22369 if (!empty($this->xobjects[$id][
'annotations'])) {
22370 foreach ($this->xobjects[$id][
'annotations'] as $annot) {
22373 $ax = ($coordlt[4] / $this->k);
22374 $ay = ($this->h - $h - ($coordlt[5] / $this->k));
22376 $aw = ($coordrb[4] / $this->k) - $ax;
22377 $ah = ($this->h - $h - ($coordrb[5] / $this->k)) - $ay;
22378 $this->Annotation($ax, $ay, $aw, $ah, $annot[
'text'], $annot[
'opt'], $annot[
'spaces']);
22389 $this->y = $y + round($h/2);
22399 $this->SetY($rb_y);
22416 $this->font_stretching = $perc;
22427 return $this->font_stretching;
22438 $this->font_spacing = $spacing;
22449 return $this->font_spacing;
22461 return $this->page_regions;
22477 $this->page_regions = array();
22479 foreach ($regions as $data) {
22480 $this->addPageRegion($data);
22496 if (!isset($region[
'page']) OR empty($region[
'page'])) {
22497 $region[
'page'] = $this->page;
22499 if (isset($region[
'xt']) AND isset($region[
'xb']) AND ($region[
'xt'] > 0) AND ($region[
'xb'] > 0)
22500 AND isset($region[
'yt']) AND isset($region[
'yb']) AND ($region[
'yt'] >= 0) AND ($region[
'yt'] < $region[
'yb'])
22501 AND isset($region[
'side']) AND (($region[
'side'] ==
'L') OR ($region[
'side'] ==
'R'))) {
22502 $this->page_regions[] = $region;
22515 if (isset($this->page_regions[$key])) {
22516 unset($this->page_regions[$key]);
22540 if (!$this->check_page_regions OR empty($this->page_regions)) {
22542 return array($x, $y);
22545 $h = $this->getCellHeight($this->FontSize);
22548 if ($this->checkPageBreak($h, $y)) {
22553 if ($this->num_columns > 1) {
22555 $this->lMargin = ($this->columns[$this->current_column][
'x'] - $this->columns[$this->current_column][
'w']);
22557 $this->rMargin = ($this->w - $this->columns[$this->current_column][
'x'] - $this->columns[$this->current_column][
'w']);
22561 $this->lMargin = max($this->clMargin, $this->original_lMargin);
22563 $this->rMargin = max($this->crMargin, $this->original_rMargin);
22567 foreach ($this->page_regions as $regid => $regdata) {
22568 if ($regdata[
'page'] == $this->page) {
22570 if (($y > ($regdata[
'yt'] - $h)) AND ($y <= $regdata[
'yb'])) {
22572 $minv = ($regdata[
'xb'] - $regdata[
'xt']) / ($regdata[
'yb'] - $regdata[
'yt']);
22573 $yt = max($y, $regdata[
'yt']);
22574 $yb = min(($yt + $h), $regdata[
'yb']);
22575 $xt = (($yt - $regdata[
'yt']) * $minv) + $regdata[
'xt'];
22576 $xb = (($yb - $regdata[
'yt']) * $minv) + $regdata[
'xt'];
22577 if ($regdata[
'side'] ==
'L') {
22578 $new_margin = max($xt, $xb);
22579 if ($this->lMargin < $new_margin) {
22582 $this->lMargin = max(0, $new_margin);
22584 if ($x < $new_margin) {
22587 if ($new_margin > ($this->w - $this->rMargin)) {
22589 $y = $regdata[
'yb'] - $h;
22593 } elseif ($regdata[
'side'] ==
'R') {
22594 $new_margin = min($xt, $xb);
22595 if (($this->w - $this->rMargin) > $new_margin) {
22598 $this->rMargin = max(0, ($this->w - $new_margin));
22600 if ($x > $new_margin) {
22603 if ($new_margin > $this->lMargin) {
22605 $y = $regdata[
'yb'] - $h;
22613 return array($x, $y);
22635 public function ImageSVG($file, $x=
'', $y=
'', $w=0, $h=0, $link=
'', $align=
'', $palign=
'', $border=0, $fitonpage=
false) {
22636 if ($this->state != 2) {
22640 $this->svggradients = array();
22641 $this->svggradientid = 0;
22642 $this->svgdefsmode =
false;
22643 $this->svgdefs = array();
22644 $this->svgclipmode =
false;
22645 $this->svgclippaths = array();
22646 $this->svgcliptm = array();
22647 $this->svgclipid = 0;
22648 $this->svgtext =
'';
22649 $this->svgtextmode = array();
22650 if ($this->rasterize_vector_images AND ($w > 0) AND ($h > 0)) {
22652 return $this->Image($file, $x, $y, $w, $h,
'SVG', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false,
false);
22654 if ($file{0} ===
'@') {
22655 $this->svgdir =
'';
22656 $svgdata = substr($file, 1);
22658 $this->svgdir = dirname($file);
22661 if ($svgdata === FALSE) {
22662 $this->Error(
'SVG file not found: '.$file);
22671 list($x, $y) = $this->checkPageRegions($h, $x, $y);
22677 $aspect_ratio_align =
'xMidYMid';
22678 $aspect_ratio_ms =
'meet';
22681 preg_match(
'/<svg([^>]*)>/si', $svgdata, $regs);
22682 if (isset($regs[1]) AND !empty($regs[1])) {
22684 if (preg_match(
'/[\s]+x[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22685 $ox = $this->getHTMLUnitToUnits($tmp[1], 0, $this->svgunit,
false);
22688 if (preg_match(
'/[\s]+y[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22689 $oy = $this->getHTMLUnitToUnits($tmp[1], 0, $this->svgunit,
false);
22692 if (preg_match(
'/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22693 $ow = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit,
false);
22696 if (preg_match(
'/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22697 $oh = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit,
false);
22700 $view_box = array();
22701 if (preg_match(
'/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.\-]+)[\s]+([0-9\.\-]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $regs[1], $tmp)) {
22702 if (count($tmp) == 5) {
22704 foreach ($tmp as $key => $val) {
22705 $view_box[$key] = $this->getHTMLUnitToUnits($val, 0, $this->svgunit,
false);
22707 $ox = $view_box[0];
22708 $oy = $view_box[1];
22712 if (preg_match(
'/[\s]+preserveAspectRatio[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22713 $aspect_ratio = preg_split(
'/[\s]+/si', $tmp[1]);
22714 switch (count($aspect_ratio)) {
22716 $aspect_ratio_align = $aspect_ratio[1];
22717 $aspect_ratio_ms = $aspect_ratio[2];
22721 $aspect_ratio_align = $aspect_ratio[0];
22722 $aspect_ratio_ms = $aspect_ratio[1];
22726 $aspect_ratio_align = $aspect_ratio[0];
22727 $aspect_ratio_ms =
'meet';
22741 if (($w <= 0) AND ($h <= 0)) {
22745 } elseif ($w <= 0) {
22746 $w = $h * $ow / $oh;
22747 } elseif ($h <= 0) {
22748 $h = $w * $oh / $ow;
22751 list($w, $h, $x, $y) = $this->fitBlock($w, $h, $x, $y, $fitonpage);
22752 if ($this->rasterize_vector_images) {
22754 return $this->Image($file, $x, $y, $w, $h,
'SVG', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false,
false);
22757 $this->img_rb_y = $y + $h;
22760 if ($palign ==
'L') {
22761 $ximg = $this->lMargin;
22762 } elseif ($palign ==
'C') {
22763 $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
22764 } elseif ($palign ==
'R') {
22765 $ximg = $this->w - $this->rMargin - $w;
22769 $this->img_rb_x = $ximg;
22771 if ($palign ==
'L') {
22772 $ximg = $this->lMargin;
22773 } elseif ($palign ==
'C') {
22774 $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
22775 } elseif ($palign ==
'R') {
22776 $ximg = $this->w - $this->rMargin - $w;
22780 $this->img_rb_x = $ximg + $w;
22783 $gvars = $this->getGraphicVars();
22785 $svgoffset_x = ($ximg - $ox) * $this->k;
22786 $svgoffset_y = -($y - $oy) * $this->k;
22787 if (isset($view_box[2]) AND ($view_box[2] > 0) AND ($view_box[3] > 0)) {
22788 $ow = $view_box[2];
22789 $oh = $view_box[3];
22798 $svgscale_x = $w / $ow;
22799 $svgscale_y = $h / $oh;
22801 if ($aspect_ratio_align !=
'none') {
22803 $svgscale_old_x = $svgscale_x;
22804 $svgscale_old_y = $svgscale_y;
22806 if ($aspect_ratio_ms ==
'slice') {
22808 if ($svgscale_x > $svgscale_y) {
22809 $svgscale_y = $svgscale_x;
22810 } elseif ($svgscale_x < $svgscale_y) {
22811 $svgscale_x = $svgscale_y;
22815 if ($svgscale_x < $svgscale_y) {
22816 $svgscale_y = $svgscale_x;
22817 } elseif ($svgscale_x > $svgscale_y) {
22818 $svgscale_x = $svgscale_y;
22822 switch (substr($aspect_ratio_align, 1, 3)) {
22828 $svgoffset_x += (($w * $this->k) - ($ow * $this->k * $svgscale_x));
22833 $svgoffset_x += ((($w * $this->k) - ($ow * $this->k * $svgscale_x)) / 2);
22838 switch (substr($aspect_ratio_align, 5)) {
22844 $svgoffset_y -= (($h * $this->k) - ($oh * $this->k * $svgscale_y));
22849 $svgoffset_y -= ((($h * $this->k) - ($oh * $this->k * $svgscale_y)) / 2);
22855 $page_break_mode = $this->AutoPageBreak;
22856 $page_break_margin = $this->getBreakMargin();
22857 $cell_padding = $this->cell_padding;
22858 $this->SetCellPadding(0);
22859 $this->SetAutoPageBreak(
false);
22861 $this->_out(
'q'.$this->epsmarker);
22863 $this->Rect($x, $y, $w, $h,
'CNZ', array(), array());
22865 $e = $ox * $this->k * (1 - $svgscale_x);
22866 $f = ($this->h - $oy) * $this->k * (1 - $svgscale_y);
22867 $this->_out(sprintf(
'%F %F %F %F %F %F cm', $svgscale_x, 0, 0, $svgscale_y, ($e + $svgoffset_x), ($f + $svgoffset_y)));
22869 $this->parser = xml_parser_create(
'UTF-8');
22871 xml_set_object($this->parser, $this);
22873 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
22875 xml_set_element_handler($this->parser,
'startSVGElementHandler',
'endSVGElementHandler');
22877 xml_set_character_data_handler($this->parser,
'segSVGContentHandler');
22879 if (!xml_parse($this->parser, $svgdata)) {
22880 $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));
22881 $this->Error($error_message);
22884 xml_parser_free($this->parser);
22886 $this->_out($this->epsmarker.
'Q');
22888 $this->setGraphicVars($gvars);
22889 $this->lasth = $gvars[
'lasth'];
22890 if (!empty($border)) {
22898 $this->Cell($w, $h,
'', $border, 0,
'', 0,
'', 0,
true);
22903 $this->Link($ximg, $y, $w, $h, $link, 0);
22909 $this->x = $this->img_rb_x;
22913 $this->y = $y + round($h/2);
22914 $this->x = $this->img_rb_x;
22918 $this->y = $this->img_rb_y;
22919 $this->x = $this->img_rb_x;
22923 $this->SetY($this->img_rb_y);
22928 $this->x = $gvars[
'x'];
22929 $this->y = $gvars[
'y'];
22930 $this->page = $gvars[
'page'];
22931 $this->current_column = $gvars[
'current_column'];
22932 $this->tMargin = $gvars[
'tMargin'];
22933 $this->bMargin = $gvars[
'bMargin'];
22934 $this->w = $gvars[
'w'];
22935 $this->h = $gvars[
'h'];
22936 $this->wPt = $gvars[
'wPt'];
22937 $this->hPt = $gvars[
'hPt'];
22938 $this->fwPt = $gvars[
'fwPt'];
22939 $this->fhPt = $gvars[
'fhPt'];
22943 $this->endlinex = $this->img_rb_x;
22945 $this->SetAutoPageBreak($page_break_mode, $page_break_margin);
22946 $this->cell_padding = $cell_padding;
22961 $e = $this->getHTMLUnitToUnits($tm[4], 1, $this->svgunit,
false) * $this->k;
22962 $f = -$this->getHTMLUnitToUnits($tm[5], 1, $this->svgunit,
false) * $this->k;
22964 $y = $this->h * $this->k;
22965 $e = ($x * (1 - $a)) - ($y * $c) + $e;
22966 $f = ($y * (1 - $d)) - ($x * $b) + $f;
22967 return array($a, $b, $c, $d, $e, $f);
22977 $this->Transform($this->convertSVGtMatrix($tm));
22995 protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1, $clip_function=
'', $clip_params=array()) {
22996 if ($this->state != 2) {
23000 $minlen = (0.01 / $this->k);
23001 if (!isset($svgstyle[
'opacity'])) {
23006 if (preg_match(
'/url\([\s]*\#([^\)]*)\)/si', $svgstyle[
'clip-path'], $regs)) {
23007 $clip_path = $this->svgclippaths[$regs[1]];
23008 foreach ($clip_path as $cp) {
23009 $this->startSVGElementHandler(
'clip-path', $cp[
'name'], $cp[
'attribs'], $cp[
'tm']);
23013 if ($svgstyle[
'opacity'] != 1) {
23014 $this->setAlpha($svgstyle[
'opacity'],
'Normal', $svgstyle[
'opacity'],
false);
23018 $this->SetFillColorArray($fill_color);
23021 $this->SetTextColorArray($text_color);
23023 if (preg_match(
'/rect\(([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)\)/si', $svgstyle[
'clip'], $regs)) {
23024 $top = (isset($regs[1])?$this->getHTMLUnitToUnits($regs[1], 0, $this->svgunit,
false):0);
23025 $right = (isset($regs[2])?$this->getHTMLUnitToUnits($regs[2], 0, $this->svgunit,
false):0);
23026 $bottom = (isset($regs[3])?$this->getHTMLUnitToUnits($regs[3], 0, $this->svgunit,
false):0);
23027 $left = (isset($regs[4])?$this->getHTMLUnitToUnits($regs[4], 0, $this->svgunit,
false):0);
23030 $cw = $w - $left - $right;
23031 $ch = $h - $top - $bottom;
23032 if ($svgstyle[
'clip-rule'] ==
'evenodd') {
23033 $clip_rule =
'CNZ';
23035 $clip_rule =
'CEO';
23037 $this->Rect($cx, $cy, $cw, $ch, $clip_rule, array(), array());
23041 if (preg_match(
'/url\([\s]*\#([^\)]*)\)/si', $svgstyle[
'fill'], $regs)) {
23043 $gradient = $this->svggradients[$regs[1]];
23044 if (isset($gradient[
'xref'])) {
23046 $newgradient = $this->svggradients[$gradient[
'xref']];
23047 $newgradient[
'coords'] = $gradient[
'coords'];
23048 $newgradient[
'mode'] = $gradient[
'mode'];
23049 $newgradient[
'gradientUnits'] = $gradient[
'gradientUnits'];
23050 if (isset($gradient[
'gradientTransform'])) {
23051 $newgradient[
'gradientTransform'] = $gradient[
'gradientTransform'];
23053 $gradient = $newgradient;
23056 $this->_outSaveGraphicsState();
23058 if (!empty($clip_function) AND method_exists($this, $clip_function)) {
23059 $bbox = call_user_func_array(array($this, $clip_function), $clip_params);
23060 if (is_array($bbox) AND (count($bbox) == 4)) {
23061 list($x, $y, $w, $h) = $bbox;
23064 if ($gradient[
'mode'] ==
'measure') {
23065 if (isset($gradient[
'gradientTransform']) AND !empty($gradient[
'gradientTransform'])) {
23066 $gtm = $gradient[
'gradientTransform'];
23068 $xa = ($gtm[0] * $gradient[
'coords'][0]) + ($gtm[2] * $gradient[
'coords'][1]) + $gtm[4];
23069 $ya = ($gtm[1] * $gradient[
'coords'][0]) + ($gtm[3] * $gradient[
'coords'][1]) + $gtm[5];
23070 $xb = ($gtm[0] * $gradient[
'coords'][2]) + ($gtm[2] * $gradient[
'coords'][3]) + $gtm[4];
23071 $yb = ($gtm[1] * $gradient[
'coords'][2]) + ($gtm[3] * $gradient[
'coords'][3]) + $gtm[5];
23072 if (isset($gradient[
'coords'][4])) {
23073 $gradient[
'coords'][4] = sqrt(pow(($gtm[0] * $gradient[
'coords'][4]), 2) + pow(($gtm[1] * $gradient[
'coords'][4]), 2));
23075 $gradient[
'coords'][0] = $xa;
23076 $gradient[
'coords'][1] = $ya;
23077 $gradient[
'coords'][2] = $xb;
23078 $gradient[
'coords'][3] = $yb;
23081 $gradient[
'coords'][0] = $this->getHTMLUnitToUnits($gradient[
'coords'][0], 0, $this->svgunit,
false);
23082 $gradient[
'coords'][1] = $this->getHTMLUnitToUnits($gradient[
'coords'][1], 0, $this->svgunit,
false);
23083 $gradient[
'coords'][2] = $this->getHTMLUnitToUnits($gradient[
'coords'][2], 0, $this->svgunit,
false);
23084 $gradient[
'coords'][3] = $this->getHTMLUnitToUnits($gradient[
'coords'][3], 0, $this->svgunit,
false);
23085 if (isset($gradient[
'coords'][4])) {
23086 $gradient[
'coords'][4] = $this->getHTMLUnitToUnits($gradient[
'coords'][4], 0, $this->svgunit,
false);
23088 if ($w <= $minlen) {
23091 if ($h <= $minlen) {
23095 if ($gradient[
'gradientUnits'] ==
'objectBoundingBox') {
23097 $gradient[
'coords'][0] += $x;
23098 $gradient[
'coords'][1] += $y;
23099 $gradient[
'coords'][2] += $x;
23100 $gradient[
'coords'][3] += $y;
23103 $gradient[
'coords'][0] = (($gradient[
'coords'][0] - $x) / $w);
23104 $gradient[
'coords'][1] = (($gradient[
'coords'][1] - $y) / $h);
23105 $gradient[
'coords'][2] = (($gradient[
'coords'][2] - $x) / $w);
23106 $gradient[
'coords'][3] = (($gradient[
'coords'][3] - $y) / $h);
23107 if (isset($gradient[
'coords'][4])) {
23108 $gradient[
'coords'][4] /= $w;
23110 } elseif ($gradient[
'mode'] ==
'percentage') {
23111 foreach($gradient[
'coords'] as $key => $val) {
23112 $gradient[
'coords'][$key] = (intval($val) / 100);
23114 $gradient[
'coords'][$key] = 0;
23115 } elseif ($val > 1) {
23116 $gradient[
'coords'][$key] = 1;
23120 if (($gradient[
'type'] == 2) AND ($gradient[
'coords'][0] == $gradient[
'coords'][2]) AND ($gradient[
'coords'][1] == $gradient[
'coords'][3])) {
23122 $gradient[
'coords'][0] = 1;
23123 $gradient[
'coords'][1] = 0;
23124 $gradient[
'coords'][2] = 0.999;
23125 $gradient[
'coords'][3] = 0;
23128 $tmp = $gradient[
'coords'][1];
23129 $gradient[
'coords'][1] = $gradient[
'coords'][3];
23130 $gradient[
'coords'][3] = $tmp;
23132 if ($gradient[
'type'] == 3) {
23134 $cy = $this->h - $y - ($gradient[
'coords'][1] * ($w + $h));
23135 $this->_out(sprintf(
'%F 0 0 %F %F %F cm', ($w * $this->k), ($w * $this->k), ($x * $this->k), ($cy * $this->k)));
23137 $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)));
23139 if (count($gradient[
'stops']) > 1) {
23140 $this->Gradient($gradient[
'type'], $gradient[
'coords'], $gradient[
'stops'], array(),
false);
23142 } elseif ($svgstyle[
'fill'] !=
'none') {
23144 if ($svgstyle[
'fill-opacity'] != 1) {
23145 $this->setAlpha($this->alpha[
'CA'],
'Normal', $svgstyle[
'fill-opacity'],
false);
23147 $this->SetFillColorArray($fill_color);
23148 if ($svgstyle[
'fill-rule'] ==
'evenodd') {
23155 if ($svgstyle[
'stroke'] !=
'none') {
23156 if ($svgstyle[
'stroke-opacity'] != 1) {
23157 $this->setAlpha($svgstyle[
'stroke-opacity'],
'Normal', $this->alpha[
'ca'],
false);
23159 $stroke_style = array(
23161 'width' => $this->getHTMLUnitToUnits($svgstyle[
'stroke-width'], 0, $this->svgunit,
false),
23162 'cap' => $svgstyle[
'stroke-linecap'],
23163 'join' => $svgstyle[
'stroke-linejoin']
23165 if (isset($svgstyle[
'stroke-dasharray']) AND !empty($svgstyle[
'stroke-dasharray']) AND ($svgstyle[
'stroke-dasharray'] !=
'none')) {
23166 $stroke_style[
'dash'] = $svgstyle[
'stroke-dasharray'];
23168 $this->SetLineStyle($stroke_style);
23173 if (!empty($svgstyle[
'font'])) {
23174 if (preg_match(
'/font-family[\s]*:[\s]*([^\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23175 $font_family = $this->getFontFamilyName($regs[1]);
23177 $font_family = $svgstyle[
'font-family'];
23179 if (preg_match(
'/font-size[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23180 $font_size = trim($regs[1]);
23182 $font_size = $svgstyle[
'font-size'];
23184 if (preg_match(
'/font-style[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23185 $font_style = trim($regs[1]);
23187 $font_style = $svgstyle[
'font-style'];
23189 if (preg_match(
'/font-weight[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23190 $font_weight = trim($regs[1]);
23192 $font_weight = $svgstyle[
'font-weight'];
23194 if (preg_match(
'/font-stretch[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23195 $font_stretch = trim($regs[1]);
23197 $font_stretch = $svgstyle[
'font-stretch'];
23199 if (preg_match(
'/letter-spacing[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23200 $font_spacing = trim($regs[1]);
23202 $font_spacing = $svgstyle[
'letter-spacing'];
23205 $font_family = $this->getFontFamilyName($svgstyle[
'font-family']);
23206 $font_size = $svgstyle[
'font-size'];
23207 $font_style = $svgstyle[
'font-style'];
23208 $font_weight = $svgstyle[
'font-weight'];
23209 $font_stretch = $svgstyle[
'font-stretch'];
23210 $font_spacing = $svgstyle[
'letter-spacing'];
23212 $font_size = $this->getHTMLFontUnits($font_size, $this->svgstyles[0][
'font-size'], $prevsvgstyle[
'font-size'], $this->svgunit);
23213 $font_stretch = $this->getCSSFontStretching($font_stretch, $svgstyle[
'font-stretch']);
23214 $font_spacing = $this->getCSSFontSpacing($font_spacing, $svgstyle[
'letter-spacing']);
23215 switch ($font_style) {
23230 switch ($font_weight) {
23233 $font_style .=
'B';
23237 switch ($svgstyle[
'text-decoration']) {
23238 case 'underline': {
23239 $font_style .=
'U';
23243 $font_style .=
'O';
23246 case 'line-through': {
23247 $font_style .=
'D';
23255 $this->SetFont($font_family, $font_style, $font_size);
23256 $this->setFontStretching($font_stretch);
23257 $this->setFontSpacing($font_spacing);
23280 if ($this->state != 2) {
23289 $d = preg_replace(
'/([0-9ACHLMQSTVZ])([\-\+])/si',
'\\1 \\2', $d);
23290 preg_match_all(
'/([ACHLMQSTVZ])[\s]*([^ACHLMQSTVZ\"]*)/si', $d, $paths, PREG_SET_ORDER);
23297 $xmin = 2147483647;
23299 $ymin = 2147483647;
23302 $minlen = (0.01 / $this->k);
23305 foreach ($paths as $key => $val) {
23307 $cmd = trim($val[1]);
23308 if (strtolower($cmd) == $cmd) {
23319 if (isset($val[2])) {
23321 $rawparams = preg_split(
'/([\,\s]+)/si', trim($val[2]));
23323 foreach ($rawparams as $ck => $cp) {
23324 $params[$ck] = $this->getHTMLUnitToUnits($cp, 0, $this->svgunit,
false);
23325 if (abs($params[$ck]) < $minlen) {
23334 switch (strtoupper($cmd)) {
23336 foreach ($params as $ck => $cp) {
23337 if (($ck % 2) == 0) {
23338 $x = $cp + $xoffset;
23340 $y = $cp + $yoffset;
23341 if ($firstcmd OR (abs($x0 - $x) >= $minlen) OR (abs($y0 - $y) >= $minlen)) {
23343 $this->_outPoint($x, $y);
23346 $this->_outLine($x, $y);
23351 $xmin = min($xmin, $x);
23352 $ymin = min($ymin, $y);
23353 $xmax = max($xmax, $x);
23354 $ymax = max($ymax, $y);
23364 foreach ($params as $ck => $cp) {
23365 if (($ck % 2) == 0) {
23366 $x = $cp + $xoffset;
23368 $y = $cp + $yoffset;
23369 if ((abs($x0 - $x) >= $minlen) OR (abs($y0 - $y) >= $minlen)) {
23370 $this->_outLine($x, $y);
23374 $xmin = min($xmin, $x);
23375 $ymin = min($ymin, $y);
23376 $xmax = max($xmax, $x);
23377 $ymax = max($ymax, $y);
23387 foreach ($params as $ck => $cp) {
23388 $x = $cp + $xoffset;
23389 if ((abs($x0 - $x) >= $minlen) OR (abs($y0 - $y) >= $minlen)) {
23390 $this->_outLine($x, $y);
23394 $xmin = min($xmin, $x);
23395 $xmax = max($xmax, $x);
23403 foreach ($params as $ck => $cp) {
23404 $y = $cp + $yoffset;
23405 if ((abs($x0 - $x) >= $minlen) OR (abs($y0 - $y) >= $minlen)) {
23406 $this->_outLine($x, $y);
23410 $ymin = min($ymin, $y);
23411 $ymax = max($ymax, $y);
23419 foreach ($params as $ck => $cp) {
23420 $params[$ck] = $cp;
23421 if ((($ck + 1) % 6) == 0) {
23422 $x1 = $params[($ck - 5)] + $xoffset;
23423 $y1 = $params[($ck - 4)] + $yoffset;
23424 $x2 = $params[($ck - 3)] + $xoffset;
23425 $y2 = $params[($ck - 2)] + $yoffset;
23426 $x = $params[($ck - 1)] + $xoffset;
23427 $y = $params[($ck)] + $yoffset;
23428 $this->_outCurve($x1, $y1, $x2, $y2, $x, $y);
23429 $xmin = min($xmin, $x, $x1, $x2);
23430 $ymin = min($ymin, $y, $y1, $y2);
23431 $xmax = max($xmax, $x, $x1, $x2);
23432 $ymax = max($ymax, $y, $y1, $y2);
23442 foreach ($params as $ck => $cp) {
23443 $params[$ck] = $cp;
23444 if ((($ck + 1) % 4) == 0) {
23445 if (($key > 0) AND ((strtoupper($paths[($key - 1)][1]) ==
'C') OR (strtoupper($paths[($key - 1)][1]) ==
'S'))) {
23446 $x1 = (2 * $x) - $x2;
23447 $y1 = (2 * $y) - $y2;
23452 $x2 = $params[($ck - 3)] + $xoffset;
23453 $y2 = $params[($ck - 2)] + $yoffset;
23454 $x = $params[($ck - 1)] + $xoffset;
23455 $y = $params[($ck)] + $yoffset;
23456 $this->_outCurve($x1, $y1, $x2, $y2, $x, $y);
23457 $xmin = min($xmin, $x, $x1, $x2);
23458 $ymin = min($ymin, $y, $y1, $y2);
23459 $xmax = max($xmax, $x, $x1, $x2);
23460 $ymax = max($ymax, $y, $y1, $y2);
23470 foreach ($params as $ck => $cp) {
23471 $params[$ck] = $cp;
23472 if ((($ck + 1) % 4) == 0) {
23474 $x1 = $params[($ck - 3)] + $xoffset;
23475 $y1 = $params[($ck - 2)] + $yoffset;
23476 $xa = ($x + (2 * $x1)) / 3;
23477 $ya = ($y + (2 * $y1)) / 3;
23478 $x = $params[($ck - 1)] + $xoffset;
23479 $y = $params[($ck)] + $yoffset;
23480 $xb = ($x + (2 * $x1)) / 3;
23481 $yb = ($y + (2 * $y1)) / 3;
23482 $this->_outCurve($xa, $ya, $xb, $yb, $x, $y);
23483 $xmin = min($xmin, $x, $xa, $xb);
23484 $ymin = min($ymin, $y, $ya, $yb);
23485 $xmax = max($xmax, $x, $xa, $xb);
23486 $ymax = max($ymax, $y, $ya, $yb);
23496 foreach ($params as $ck => $cp) {
23497 $params[$ck] = $cp;
23498 if (($ck % 2) != 0) {
23499 if (($key > 0) AND ((strtoupper($paths[($key - 1)][1]) ==
'Q') OR (strtoupper($paths[($key - 1)][1]) ==
'T'))) {
23500 $x1 = (2 * $x) - $x1;
23501 $y1 = (2 * $y) - $y1;
23507 $xa = ($x + (2 * $x1)) / 3;
23508 $ya = ($y + (2 * $y1)) / 3;
23509 $x = $params[($ck - 1)] + $xoffset;
23510 $y = $params[($ck)] + $yoffset;
23511 $xb = ($x + (2 * $x1)) / 3;
23512 $yb = ($y + (2 * $y1)) / 3;
23513 $this->_outCurve($xa, $ya, $xb, $yb, $x, $y);
23514 $xmin = min($xmin, $x, $xa, $xb);
23515 $ymin = min($ymin, $y, $ya, $yb);
23516 $xmax = max($xmax, $x, $xa, $xb);
23517 $ymax = max($ymax, $y, $ya, $yb);
23527 foreach ($params as $ck => $cp) {
23528 $params[$ck] = $cp;
23529 if ((($ck + 1) % 7) == 0) {
23532 $rx = abs($params[($ck - 6)]);
23533 $ry = abs($params[($ck - 5)]);
23534 $ang = -$rawparams[($ck - 4)];
23535 $angle = deg2rad($ang);
23536 $fa = $rawparams[($ck - 3)];
23537 $fs = $rawparams[($ck - 2)];
23538 $x = $params[($ck - 1)] + $xoffset;
23539 $y = $params[$ck] + $yoffset;
23540 if ((abs($x0 - $x) < $minlen) AND (abs($y0 - $y) < $minlen)) {
23542 $xmin = min($xmin, $x);
23543 $ymin = min($ymin, $y);
23544 $xmax = max($xmax, $x);
23545 $ymax = max($ymax, $y);
23547 $cos_ang = cos($angle);
23548 $sin_ang = sin($angle);
23549 $a = (($x0 - $x) / 2);
23550 $b = (($y0 - $y) / 2);
23551 $xa = ($a * $cos_ang) - ($b * $sin_ang);
23552 $ya = ($a * $sin_ang) + ($b * $cos_ang);
23557 $delta = ($xa2 / $rx2) + ($ya2 / $ry2);
23559 $rx *= sqrt($delta);
23560 $ry *= sqrt($delta);
23564 $numerator = (($rx2 * $ry2) - ($rx2 * $ya2) - ($ry2 * $xa2));
23565 if ($numerator < 0) {
23568 $root = sqrt($numerator / (($rx2 * $ya2) + ($ry2 * $xa2)));
23573 $cax = $root * (($rx * $ya) / $ry);
23574 $cay = -$root * (($ry * $xa) / $rx);
23576 $cx = ($cax * $cos_ang) - ($cay * $sin_ang) + (($x0 + $x) / 2);
23577 $cy = ($cax * $sin_ang) + ($cay * $cos_ang) + (($y0 + $y) / 2);
23581 if (($fs == 0) AND ($dang > 0)) {
23582 $dang -= (2 * M_PI);
23583 } elseif (($fs == 1) AND ($dang < 0)) {
23584 $dang += (2 * M_PI);
23586 $angf = $angs - $dang;
23587 if ((($fs == 0) AND ($angs > $angf)) OR (($fs == 1) AND ($angs < $angf))) {
23593 $angs = round(rad2deg($angs), 6);
23594 $angf = round(rad2deg($angf), 6);
23596 if (($angs < 0) AND ($angf < 0)) {
23601 if (($key == 0) AND (isset($paths[($key + 1)][1])) AND (trim($paths[($key + 1)][1]) ==
'z')) {
23604 list($axmin, $aymin, $axmax, $aymax) = $this->_outellipticalarc($cx, $cy, $rx, $ry, $ang, $angs, $angf, $pie, 2,
false, ($fs == 0),
true);
23605 $xmin = min($xmin, $x, $axmin);
23606 $ymin = min($ymin, $y, $aymin);
23607 $xmax = max($xmax, $x, $axmax);
23608 $ymax = max($ymax, $y, $aymax);
23628 return array($xmin, $ymin, ($xmax - $xmin), ($ymax - $ymin));
23643 if ($this->svgclipmode) {
23644 $this->svgclippaths[$this->svgclipid][] = array(
'name' => $name,
'attribs' => $attribs,
'tm' => $this->svgcliptm[$this->svgclipid]);
23647 if ($this->svgdefsmode AND !in_array($name, array(
'clipPath',
'linearGradient',
'radialGradient',
'stop'))) {
23648 if (isset($attribs[
'id'])) {
23649 $attribs[
'child_elements'] = array();
23650 $this->svgdefs[$attribs[
'id']] = array(
'name' => $name,
'attribs' => $attribs);
23653 if (end($this->svgdefs) !== FALSE) {
23654 $last_svgdefs_id = key($this->svgdefs);
23655 if (isset($this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'])) {
23656 $attribs[
'id'] =
'DF_'.(count($this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements']) + 1);
23657 $this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'][$attribs[
'id']] = array(
'name' => $name,
'attribs' => $attribs);
23664 if ($parser ==
'clip-path') {
23669 $prev_svgstyle = $this->svgstyles[max(0,(count($this->svgstyles) - 1))];
23670 $svgstyle = $this->svgstyles[0];
23671 if ($clipping AND !isset($attribs[
'fill']) AND (!isset($attribs[
'style']) OR (!preg_match(
'/[;\"\s]{1}fill[\s]*:[\s]*([^;\"]*)/si', $attribs[
'style'], $attrval)))) {
23673 $attribs[
'fill'] =
'none';
23677 $attribs[
'style'] =
';'.$attribs[
'style'];
23679 foreach ($prev_svgstyle as $key => $val) {
23682 $svgstyle[$key] = $val;
23686 if ($attribs[$key] ==
'inherit') {
23687 $svgstyle[$key] = $val;
23689 $svgstyle[$key] = $attribs[$key];
23693 $attrval = array();
23694 if (preg_match(
'/[;\"\s]{1}'.$key.
'[\s]*:[\s]*([^;\"]*)/si', $attribs[
'style'], $attrval) AND isset($attrval[1])) {
23695 if ($attrval[1] ==
'inherit') {
23696 $svgstyle[$key] = $val;
23698 $svgstyle[$key] = $attrval[1];
23704 if (!empty($ctm)) {
23707 $tm = array(1,0,0,1,0,0);
23709 if (isset($attribs[
'transform']) AND !empty($attribs[
'transform'])) {
23712 $svgstyle[
'transfmatrix'] = $tm;
23713 $invisible =
false;
23714 if (($svgstyle[
'visibility'] ==
'hidden') OR ($svgstyle[
'visibility'] ==
'collapse') OR ($svgstyle[
'display'] ==
'none')) {
23721 $this->svgdefsmode =
true;
23729 $this->svgclipmode =
true;
23730 if (!isset($attribs[
'id'])) {
23731 $attribs[
'id'] =
'CP_'.(count($this->svgcliptm) + 1);
23733 $this->svgclipid = $attribs[
'id'];
23734 $this->svgclippaths[$this->svgclipid] = array();
23735 $this->svgcliptm[$this->svgclipid] = $tm;
23744 array_push($this->svgstyles, $svgstyle);
23745 $this->StartTransform();
23746 $x = (isset($attribs[
'x'])?$attribs[
'x']:0);
23747 $y = (isset($attribs[
'y'])?$attribs[
'y']:0);
23751 $this->SVGTransform($tm);
23752 $this->setSVGStyles($svgstyle, $prev_svgstyle);
23755 case 'linearGradient': {
23756 if ($this->pdfa_mode) {
23759 if (!isset($attribs[
'id'])) {
23760 $attribs[
'id'] =
'GR_'.(count($this->svggradients) + 1);
23762 $this->svggradientid = $attribs[
'id'];
23763 $this->svggradients[$this->svggradientid] = array();
23764 $this->svggradients[$this->svggradientid][
'type'] = 2;
23765 $this->svggradients[$this->svggradientid][
'stops'] = array();
23766 if (isset($attribs[
'gradientUnits'])) {
23767 $this->svggradients[$this->svggradientid][
'gradientUnits'] = $attribs[
'gradientUnits'];
23769 $this->svggradients[$this->svggradientid][
'gradientUnits'] =
'objectBoundingBox';
23772 if (((!isset($attribs[
'x1'])) AND (!isset($attribs[
'y1'])) AND (!isset($attribs[
'x2'])) AND (!isset($attribs[
'y2'])))
23773 OR ((isset($attribs[
'x1']) AND (substr($attribs[
'x1'], -1) ==
'%'))
23774 OR (isset($attribs[
'y1']) AND (substr($attribs[
'y1'], -1) ==
'%'))
23775 OR (isset($attribs[
'x2']) AND (substr($attribs[
'x2'], -1) ==
'%'))
23776 OR (isset($attribs[
'y2']) AND (substr($attribs[
'y2'], -1) ==
'%')))) {
23777 $this->svggradients[$this->svggradientid][
'mode'] =
'percentage';
23779 $this->svggradients[$this->svggradientid][
'mode'] =
'measure';
23781 $x1 = (isset($attribs[
'x1'])?$attribs[
'x1']:
'0');
23782 $y1 = (isset($attribs[
'y1'])?$attribs[
'y1']:
'0');
23783 $x2 = (isset($attribs[
'x2'])?$attribs[
'x2']:
'100');
23784 $y2 = (isset($attribs[
'y2'])?$attribs[
'y2']:
'0');
23785 if (isset($attribs[
'gradientTransform'])) {
23788 $this->svggradients[$this->svggradientid][
'coords'] = array($x1, $y1, $x2, $y2);
23789 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
23791 $this->svggradients[$this->svggradientid][
'xref'] = substr($attribs[
'xlink:href'], 1);
23795 case 'radialGradient': {
23796 if ($this->pdfa_mode) {
23799 if (!isset($attribs[
'id'])) {
23800 $attribs[
'id'] =
'GR_'.(count($this->svggradients) + 1);
23802 $this->svggradientid = $attribs[
'id'];
23803 $this->svggradients[$this->svggradientid] = array();
23804 $this->svggradients[$this->svggradientid][
'type'] = 3;
23805 $this->svggradients[$this->svggradientid][
'stops'] = array();
23806 if (isset($attribs[
'gradientUnits'])) {
23807 $this->svggradients[$this->svggradientid][
'gradientUnits'] = $attribs[
'gradientUnits'];
23809 $this->svggradients[$this->svggradientid][
'gradientUnits'] =
'objectBoundingBox';
23812 if (((!isset($attribs[
'cx'])) AND (!isset($attribs[
'cy'])))
23813 OR ((isset($attribs[
'cx']) AND (substr($attribs[
'cx'], -1) ==
'%'))
23814 OR (isset($attribs[
'cy']) AND (substr($attribs[
'cy'], -1) ==
'%')) )) {
23815 $this->svggradients[$this->svggradientid][
'mode'] =
'percentage';
23817 $this->svggradients[$this->svggradientid][
'mode'] =
'measure';
23819 $cx = (isset($attribs[
'cx']) ? $attribs[
'cx'] : 0.5);
23820 $cy = (isset($attribs[
'cy']) ? $attribs[
'cy'] : 0.5);
23821 $fx = (isset($attribs[
'fx']) ? $attribs[
'fx'] : $cx);
23822 $fy = (isset($attribs[
'fy']) ? $attribs[
'fy'] : $cy);
23823 $r = (isset($attribs[
'r']) ? $attribs[
'r'] : 0.5);
23824 if (isset($attribs[
'gradientTransform'])) {
23827 $this->svggradients[$this->svggradientid][
'coords'] = array($cx, $cy, $fx, $fy, $r);
23828 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
23830 $this->svggradients[$this->svggradientid][
'xref'] = substr($attribs[
'xlink:href'], 1);
23836 if (substr($attribs[
'offset'], -1) ==
'%') {
23837 $offset = floatval(substr($attribs[
'offset'], -1)) / 100;
23839 $offset = floatval($attribs[
'offset']);
23845 $opacity = isset($svgstyle[
'stop-opacity'])?$svgstyle[
'stop-opacity']:1;
23846 $this->svggradients[$this->svggradientid][
'stops'][] = array(
'offset' => $offset,
'color' => $stop_color,
'opacity' => $opacity);
23854 if (isset($attribs[
'd'])) {
23855 $d = trim($attribs[
'd']);
23857 $x = (isset($attribs[
'x'])?$attribs[
'x']:0);
23858 $y = (isset($attribs[
'y'])?$attribs[
'y']:0);
23859 $w = (isset($attribs[
'width'])?$attribs[
'width']:1);
23860 $h = (isset($attribs[
'height'])?$attribs[
'height']:1);
23863 $this->SVGTransform($tm);
23864 $this->SVGPath($d,
'CNZ');
23866 $this->StartTransform();
23867 $this->SVGTransform($tm);
23868 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'SVGPath', array($d,
'CNZ'));
23869 if (!empty($obstyle)) {
23870 $this->SVGPath($d, $obstyle);
23872 $this->StopTransform();
23883 $x = (isset($attribs[
'x'])?$this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false):0);
23884 $y = (isset($attribs[
'y'])?$this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false):0);
23885 $w = (isset($attribs[
'width'])?$this->getHTMLUnitToUnits($attribs[
'width'], 0, $this->svgunit,
false):0);
23886 $h = (isset($attribs[
'height'])?$this->getHTMLUnitToUnits($attribs[
'height'], 0, $this->svgunit,
false):0);
23887 $rx = (isset($attribs[
'rx'])?$this->getHTMLUnitToUnits($attribs[
'rx'], 0, $this->svgunit,
false):0);
23888 $ry = (isset($attribs[
'ry'])?$this->getHTMLUnitToUnits($attribs[
'ry'], 0, $this->svgunit,
false):$rx);
23890 $this->SVGTransform($tm);
23891 $this->RoundedRectXY($x, $y, $w, $h, $rx, $ry,
'1111',
'CNZ', array(), array());
23893 $this->StartTransform();
23894 $this->SVGTransform($tm);
23895 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'RoundedRectXY', array($x, $y, $w, $h, $rx, $ry,
'1111',
'CNZ'));
23896 if (!empty($obstyle)) {
23897 $this->RoundedRectXY($x, $y, $w, $h, $rx, $ry,
'1111', $obstyle, array(), array());
23899 $this->StopTransform();
23907 $r = (isset($attribs[
'r']) ? $this->getHTMLUnitToUnits($attribs[
'r'], 0, $this->svgunit,
false) : 0);
23908 $cx = (isset($attribs[
'cx']) ? $this->getHTMLUnitToUnits($attribs[
'cx'], 0, $this->svgunit,
false) : (isset($attribs[
'x']) ? $this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false) : 0));
23909 $cy = (isset($attribs[
'cy']) ? $this->getHTMLUnitToUnits($attribs[
'cy'], 0, $this->svgunit,
false) : (isset($attribs[
'y']) ? $this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false) : 0));
23915 $this->SVGTransform($tm);
23916 $this->Circle($cx, $cy, $r, 0, 360,
'CNZ', array(), array(), 8);
23918 $this->StartTransform();
23919 $this->SVGTransform($tm);
23920 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'Circle', array($cx, $cy, $r, 0, 360,
'CNZ'));
23921 if (!empty($obstyle)) {
23922 $this->Circle($cx, $cy, $r, 0, 360, $obstyle, array(), array(), 8);
23924 $this->StopTransform();
23932 $rx = (isset($attribs[
'rx']) ? $this->getHTMLUnitToUnits($attribs[
'rx'], 0, $this->svgunit,
false) : 0);
23933 $ry = (isset($attribs[
'ry']) ? $this->getHTMLUnitToUnits($attribs[
'ry'], 0, $this->svgunit,
false) : 0);
23934 $cx = (isset($attribs[
'cx']) ? $this->getHTMLUnitToUnits($attribs[
'cx'], 0, $this->svgunit,
false) : (isset($attribs[
'x']) ? $this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false) : 0));
23935 $cy = (isset($attribs[
'cy']) ? $this->getHTMLUnitToUnits($attribs[
'cy'], 0, $this->svgunit,
false) : (isset($attribs[
'y']) ? $this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false) : 0));
23941 $this->SVGTransform($tm);
23942 $this->Ellipse($cx, $cy, $rx, $ry, 0, 0, 360,
'CNZ', array(), array(), 8);
23944 $this->StartTransform();
23945 $this->SVGTransform($tm);
23946 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'Ellipse', array($cx, $cy, $rx, $ry, 0, 0, 360,
'CNZ'));
23947 if (!empty($obstyle)) {
23948 $this->Ellipse($cx, $cy, $rx, $ry, 0, 0, 360, $obstyle, array(), array(), 8);
23950 $this->StopTransform();
23958 $x1 = (isset($attribs[
'x1'])?$this->getHTMLUnitToUnits($attribs[
'x1'], 0, $this->svgunit,
false):0);
23959 $y1 = (isset($attribs[
'y1'])?$this->getHTMLUnitToUnits($attribs[
'y1'], 0, $this->svgunit,
false):0);
23960 $x2 = (isset($attribs[
'x2'])?$this->getHTMLUnitToUnits($attribs[
'x2'], 0, $this->svgunit,
false):0);
23961 $y2 = (isset($attribs[
'y2'])?$this->getHTMLUnitToUnits($attribs[
'y2'], 0, $this->svgunit,
false):0);
23964 $w = abs($x2 - $x1);
23965 $h = abs($y2 - $y1);
23967 $this->StartTransform();
23968 $this->SVGTransform($tm);
23969 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'Line', array($x1, $y1, $x2, $y2));
23970 $this->Line($x1, $y1, $x2, $y2);
23971 $this->StopTransform();
23980 $points = (isset($attribs[
'points'])?$attribs[
'points']:
'0 0');
23981 $points = trim($points);
23983 $points = preg_split(
'/[\,\s]+/si', $points);
23984 if (count($points) < 4) {
23988 $xmin = 2147483647;
23990 $ymin = 2147483647;
23992 foreach ($points as $key => $val) {
23993 $p[$key] = $this->getHTMLUnitToUnits($val, 0, $this->svgunit,
false);
23994 if (($key % 2) == 0) {
23996 $xmin = min($xmin, $p[$key]);
23997 $xmax = max($xmax, $p[$key]);
24000 $ymin = min($ymin, $p[$key]);
24001 $ymax = max($ymax, $p[$key]);
24006 $w = ($xmax - $xmin);
24007 $h = ($ymax - $ymin);
24008 if ($name ==
'polyline') {
24009 $this->StartTransform();
24010 $this->SVGTransform($tm);
24011 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'PolyLine', array($p,
'CNZ'));
24012 if (!empty($obstyle)) {
24013 $this->PolyLine($p, $obstyle, array(), array());
24015 $this->StopTransform();
24018 $this->SVGTransform($tm);
24019 $this->Polygon($p,
'CNZ', array(), array(),
true);
24021 $this->StartTransform();
24022 $this->SVGTransform($tm);
24023 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h,
'Polygon', array($p,
'CNZ'));
24024 if (!empty($obstyle)) {
24025 $this->Polygon($p, $obstyle, array(), array(),
true);
24027 $this->StopTransform();
24037 if (!isset($attribs[
'xlink:href']) OR empty($attribs[
'xlink:href'])) {
24040 $x = (isset($attribs[
'x'])?$this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false):0);
24041 $y = (isset($attribs[
'y'])?$this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false):0);
24042 $w = (isset($attribs[
'width'])?$this->getHTMLUnitToUnits($attribs[
'width'], 0, $this->svgunit,
false):0);
24043 $h = (isset($attribs[
'height'])?$this->getHTMLUnitToUnits($attribs[
'height'], 0, $this->svgunit,
false):0);
24044 $img = $attribs[
'xlink:href'];
24046 $this->StartTransform();
24047 $this->SVGTransform($tm);
24048 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h);
24049 if (preg_match(
'/^data:image\/[^;]+;base64,/', $img, $m) > 0) {
24051 $img =
'@'.base64_decode(substr($img, strlen($m[0])));
24056 $img = $this->svgdir.
'/'.$img;
24058 if (($img[0] ==
'/') AND !empty(
$_SERVER[
'DOCUMENT_ROOT']) AND (
$_SERVER[
'DOCUMENT_ROOT'] !=
'/')) {
24059 $findroot = strpos($img,
$_SERVER[
'DOCUMENT_ROOT']);
24060 if (($findroot ===
false) OR ($findroot > 1)) {
24061 if (substr(
$_SERVER[
'DOCUMENT_ROOT'], -1) ==
'/') {
24062 $img = substr(
$_SERVER[
'DOCUMENT_ROOT'], 0, -1).$img;
24064 $img =
$_SERVER[
'DOCUMENT_ROOT'].$img;
24068 $img = urldecode($img);
24069 $testscrtype = @parse_url($img);
24070 if (!isset($testscrtype[
'query']) OR empty($testscrtype[
'query'])) {
24072 $img = str_replace(K_PATH_URL, K_PATH_MAIN, $img);
24077 if (($imgtype ==
'eps') OR ($imgtype ==
'ai')) {
24078 $this->ImageEps($img, $x, $y, $w, $h);
24079 } elseif ($imgtype ==
'svg') {
24080 $this->ImageSVG($img, $x, $y, $w, $h);
24082 $this->Image($img, $x, $y, $w, $h);
24084 $this->StopTransform();
24092 $this->svgtextmode[
'invisible'] = $invisible;
24096 array_push($this->svgstyles, $svgstyle);
24097 if (isset($attribs[
'x'])) {
24098 $x = $this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false);
24099 } elseif ($name ==
'tspan') {
24104 if (isset($attribs[
'dx'])) {
24105 $x += $this->getHTMLUnitToUnits($attribs[
'dx'], 0, $this->svgunit,
false);
24107 if (isset($attribs[
'y'])) {
24108 $y = $this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false);
24109 } elseif ($name ==
'tspan') {
24114 if (isset($attribs[
'dy'])) {
24115 $y += $this->getHTMLUnitToUnits($attribs[
'dy'], 0, $this->svgunit,
false);
24117 $svgstyle[
'text-color'] = $svgstyle[
'fill'];
24118 $this->svgtext =
'';
24119 if (isset($svgstyle[
'text-anchor'])) {
24120 $this->svgtextmode[
'text-anchor'] = $svgstyle[
'text-anchor'];
24122 $this->svgtextmode[
'text-anchor'] =
'start';
24124 if (isset($svgstyle[
'direction'])) {
24125 if ($svgstyle[
'direction'] ==
'rtl') {
24126 $this->svgtextmode[
'rtl'] =
true;
24128 $this->svgtextmode[
'rtl'] =
false;
24131 $this->svgtextmode[
'rtl'] =
false;
24133 if (isset($svgstyle[
'stroke']) AND ($svgstyle[
'stroke'] !=
'none') AND isset($svgstyle[
'stroke-width']) AND ($svgstyle[
'stroke-width'] > 0)) {
24134 $this->svgtextmode[
'stroke'] = $this->getHTMLUnitToUnits($svgstyle[
'stroke-width'], 0, $this->svgunit,
false);
24136 $this->svgtextmode[
'stroke'] =
false;
24138 $this->StartTransform();
24139 $this->SVGTransform($tm);
24140 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, 1, 1);
24147 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
24148 $svgdefid = substr($attribs[
'xlink:href'], 1);
24149 if (isset($this->svgdefs[$svgdefid])) {
24150 $use = $this->svgdefs[$svgdefid];
24151 if (isset($attribs[
'xlink:href'])) {
24152 unset($attribs[
'xlink:href']);
24154 if (isset($attribs[
'id'])) {
24155 unset($attribs[
'id']);
24157 if (isset($use[
'attribs'][
'x']) AND isset($attribs[
'x'])) {
24158 $attribs[
'x'] += $use[
'attribs'][
'x'];
24160 if (isset($use[
'attribs'][
'y']) AND isset($attribs[
'y'])) {
24161 $attribs[
'y'] += $use[
'attribs'][
'y'];
24163 if (empty($attribs[
'style'])) {
24164 $attribs[
'style'] =
'';
24166 if (!empty($use[
'attribs'][
'style'])) {
24168 $attribs[
'style'] = str_replace(
';;',
';',
';'.$use[
'attribs'][
'style'].$attribs[
'style']);
24170 $attribs = array_merge($use[
'attribs'], $attribs);
24171 $this->startSVGElementHandler(
'use-tag', $use[
'name'], $attribs);
24182 if (!empty($attribs[
'child_elements'])) {
24183 $child_elements = $attribs[
'child_elements'];
24184 unset($attribs[
'child_elements']);
24185 foreach($child_elements as $child_element) {
24186 if (empty($child_element[
'attribs'][
'closing_tag'])) {
24187 $this->startSVGElementHandler(
'child-tag', $child_element[
'name'], $child_element[
'attribs']);
24189 if (isset($child_element[
'attribs'][
'content'])) {
24190 $this->svgtext = $child_element[
'attribs'][
'content'];
24192 $this->endSVGElementHandler(
'child-tag', $child_element[
'name']);
24207 if ($this->svgdefsmode AND !in_array($name, array(
'defs',
'clipPath',
'linearGradient',
'radialGradient',
'stop'))) {;
24208 if (end($this->svgdefs) !== FALSE) {
24209 $last_svgdefs_id = key($this->svgdefs);
24210 if (isset($this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'])) {
24211 foreach($this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'] as $child_element) {
24212 if (isset($child_element[
'attribs'][
'id']) AND ($child_element[
'name'] == $name)) {
24213 $this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'][$child_element[
'attribs'][
'id'].
'_CLOSE'] = array(
'name' => $name,
'attribs' => array(
'closing_tag' => TRUE,
'content' => $this->svgtext));
24217 if ($this->svgdefs[$last_svgdefs_id][
'name'] == $name) {
24218 $this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'][$last_svgdefs_id.
'_CLOSE'] = array(
'name' => $name,
'attribs' => array(
'closing_tag' => TRUE,
'content' => $this->svgtext));
24227 $this->svgdefsmode =
false;
24232 $this->svgclipmode =
false;
24237 array_pop($this->svgstyles);
24238 $this->StopTransform();
24243 if ($this->svgtextmode[
'invisible']) {
24249 $text = $this->svgtext;
24251 $textlen = $this->GetStringWidth($text);
24252 if ($this->svgtextmode[
'text-anchor'] !=
'start') {
24254 if ($this->svgtextmode[
'text-anchor'] ==
'end') {
24255 if ($this->svgtextmode[
'rtl']) {
24256 $this->x += $textlen;
24258 $this->x -= $textlen;
24260 } elseif ($this->svgtextmode[
'text-anchor'] ==
'middle') {
24261 if ($this->svgtextmode[
'rtl']) {
24262 $this->x += ($textlen / 2);
24264 $this->x -= ($textlen / 2);
24268 $textrendermode = $this->textrendermode;
24269 $textstrokewidth = $this->textstrokewidth;
24270 $this->setTextRenderingMode($this->svgtextmode[
'stroke'],
true,
false);
24271 if ($name ==
'text') {
24276 $this->Cell($textlen, 0, $text, 0, 0,
'',
false,
'', 0,
false,
'L',
'T');
24277 if ($name ==
'text') {
24283 $this->textrendermode = $textrendermode;
24284 $this->textstrokewidth = $textstrokewidth;
24285 $this->svgtext =
'';
24286 $this->StopTransform();
24287 if (!$this->svgdefsmode) {
24288 array_pop($this->svgstyles);
24307 $this->svgtext .= $data;