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');
690 protected $txtshadow =
array(
'enabled'=>
false,
'depth_w'=>0,
'depth_h'=>0,
'color'=>
false,
'opacity'=>1,
'blend_mode'=>
'Normal');
1681 'alignment-baseline' =>
'auto',
1682 'baseline-shift' =>
'baseline',
1684 'clip-path' =>
'none',
1685 'clip-rule' =>
'nonzero',
1687 'color-interpolation' =>
'sRGB',
1688 'color-interpolation-filters' =>
'linearRGB',
1689 'color-profile' =>
'auto',
1690 'color-rendering' =>
'auto',
1692 'direction' =>
'ltr',
1693 'display' =>
'inline',
1694 'dominant-baseline' =>
'auto',
1695 'enable-background' =>
'accumulate',
1697 'fill-opacity' => 1,
1698 'fill-rule' =>
'nonzero',
1700 'flood-color' =>
'black',
1701 'flood-opacity' => 1,
1703 'font-family' =>
'helvetica',
1704 'font-size' =>
'medium',
1705 'font-size-adjust' =>
'none',
1706 'font-stretch' =>
'normal',
1707 'font-style' =>
'normal',
1708 'font-variant' =>
'normal',
1709 'font-weight' =>
'normal',
1710 'glyph-orientation-horizontal' =>
'0deg',
1711 'glyph-orientation-vertical' =>
'auto',
1712 'image-rendering' =>
'auto',
1713 'kerning' =>
'auto',
1714 'letter-spacing' =>
'normal',
1715 'lighting-color' =>
'white',
1717 'marker-end' =>
'none',
1718 'marker-mid' =>
'none',
1719 'marker-start' =>
'none',
1722 'overflow' =>
'auto',
1723 'pointer-events' =>
'visiblePainted',
1724 'shape-rendering' =>
'auto',
1725 'stop-color' =>
'black',
1726 'stop-opacity' => 1,
1728 'stroke-dasharray' =>
'none',
1729 'stroke-dashoffset' => 0,
1730 'stroke-linecap' =>
'butt',
1731 'stroke-linejoin' =>
'miter',
1732 'stroke-miterlimit' => 4,
1733 'stroke-opacity' => 1,
1734 'stroke-width' => 1,
1735 'text-anchor' =>
'start',
1736 'text-decoration' =>
'none',
1737 'text-rendering' =>
'auto',
1738 'unicode-bidi' =>
'normal',
1739 'visibility' =>
'visible',
1740 'word-spacing' =>
'normal',
1741 'writing-mode' =>
'lr-tb',
1742 'text-color' =>
'black',
1743 'transfmatrix' =>
array(1, 0, 0, 1, 0, 0)
1795 protected $alpha =
array(
'CA' => 1,
'ca' => 1,
'BM' =>
'/Normal',
'AIS' =>
false);
1838 public function __construct($orientation=
'P', $unit=
'mm', $format=
'A4', $unicode=
true,
$encoding=
'UTF-8', $diskcache=
false, $pdfa=
false) {
1840 if (function_exists(
'mb_internal_encoding') AND mb_internal_encoding()) {
1841 $this->internal_encoding = mb_internal_encoding();
1842 mb_internal_encoding(
'ASCII');
1845 $serformat = (is_array($format) ? json_encode($format) : $format);
1847 $this->font_obj_ids =
array();
1848 $this->page_obj_id =
array();
1849 $this->form_obj_id =
array();
1851 $this->pdfa_mode = $pdfa;
1852 $this->force_srgb =
false;
1855 $this->tmprtl =
false;
1859 $this->isunicode = $unicode;
1861 $this->transfmrk[0] =
array();
1862 $this->pagedim =
array();
1865 $this->pages =
array();
1868 $this->FontFiles =
array();
1869 $this->diffs =
array();
1871 $this->links =
array();
1872 $this->gradients =
array();
1873 $this->InFooter =
false;
1876 $this->FontStyle =
'';
1877 $this->FontSizePt = 12;
1878 $this->underline =
false;
1879 $this->overline =
false;
1880 $this->linethrough =
false;
1881 $this->DrawColor =
'0 G';
1882 $this->FillColor =
'0 g';
1883 $this->TextColor =
'0 g';
1884 $this->ColorFlag =
false;
1885 $this->pdflayers =
array();
1887 $this->encrypted =
false;
1888 $this->last_enc_key =
'';
1890 $this->CoreFonts =
array(
1891 'courier'=>
'Courier',
1892 'courierB'=>
'Courier-Bold',
1893 'courierI'=>
'Courier-Oblique',
1894 'courierBI'=>
'Courier-BoldOblique',
1895 'helvetica'=>
'Helvetica',
1896 'helveticaB'=>
'Helvetica-Bold',
1897 'helveticaI'=>
'Helvetica-Oblique',
1898 'helveticaBI'=>
'Helvetica-BoldOblique',
1899 'times'=>
'Times-Roman',
1900 'timesB'=>
'Times-Bold',
1901 'timesI'=>
'Times-Italic',
1902 'timesBI'=>
'Times-BoldItalic',
1904 'zapfdingbats'=>
'ZapfDingbats' 1916 $cpadding = $margin / 10;
1921 $this->LineWidth = 0.57 /
$this->k;
1922 $this->linestyleWidth = sprintf(
'%F w', ($this->LineWidth * $this->k));
1923 $this->linestyleCap =
'0 J';
1924 $this->linestyleJoin =
'0 j';
1925 $this->linestyleDash =
'[] 0 d';
1934 $this->tcpdflink =
true;
1936 $this->HREF =
array();
1938 $this->fgcolor =
array(
'R' => 0,
'G' => 0,
'B' => 0);
1939 $this->strokecolor =
array(
'R' => 0,
'G' => 0,
'B' => 0);
1940 $this->bgcolor =
array(
'R' => 255,
'G' => 255,
'B' => 255);
1941 $this->extgstates =
array();
1944 $this->sign =
false;
1945 $this->tsa_timestamp =
false;
1946 $this->tsa_data =
array();
1947 $this->signature_appearance =
array(
'page' => 1,
'rect' =>
'0 0 0 0',
'name' =>
'Signature');
1948 $this->empty_signature_appearance =
array();
1950 $this->ur[
'enabled'] =
false;
1951 $this->ur[
'document'] =
'/FullSave';
1952 $this->ur[
'annots'] =
'/Create/Delete/Modify/Copy/Import/Export';
1953 $this->ur[
'form'] =
'/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate';
1954 $this->ur[
'signature'] =
'/Modify';
1955 $this->ur[
'ef'] =
'/Create/Delete/Modify/Import';
1956 $this->ur[
'formex'] =
'';
1958 $this->jpeg_quality = 75;
1962 $this->
SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
1966 if ($this->isunicode AND (@preg_match(
'/\pL/u',
'a') == 1)) {
1978 $this->default_form_prop =
array(
'lineWidth'=>1,
'borderStyle'=>
'solid',
'fillColor'=>
array(255, 255, 255),
'strokeColor'=>
array(128, 128, 128));
1980 $this->doc_creation_timestamp =
time();
1984 $this->header_xobj_autoreset =
false;
1985 $this->custom_xmp =
'';
1988 register_shutdown_function(
array($this,
'_destroy'),
true);
1998 if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
1999 mb_internal_encoding($this->internal_encoding);
2012 $unit = strtolower($unit);
2023 $this->k = $this->dpi / 25.4;
2028 $this->k = $this->dpi / 2.54;
2038 $this->
Error(
'Incorrect unit: '.$unit);
2042 $this->pdfunit = $unit;
2043 if (isset($this->CurOrientation)) {
2104 if (!empty($format) AND isset($this->pagedim[$this->page])) {
2106 unset($this->pagedim[$this->page]);
2108 if (is_string($format)) {
2111 $this->fwPt = $pf[0];
2112 $this->fhPt = $pf[1];
2115 if (isset($format[
'MediaBox'])) {
2116 $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);
2117 $this->fwPt = (($format[
'MediaBox'][
'urx'] - $format[
'MediaBox'][
'llx']) * $this->k);
2118 $this->fhPt = (($format[
'MediaBox'][
'ury'] - $format[
'MediaBox'][
'lly']) * $this->k);
2120 if (isset($format[0]) AND is_numeric($format[0]) AND isset($format[1]) AND is_numeric($format[1])) {
2121 $pf =
array(($format[0] * $this->k), ($format[1] * $this->k));
2123 if (!isset($format[
'format'])) {
2125 $format[
'format'] =
'A4';
2129 $this->fwPt = $pf[0];
2130 $this->fhPt = $pf[1];
2131 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'MediaBox', 0, 0, $this->fwPt, $this->fhPt,
true, $this->k, $this->pagedim);
2134 if (isset($format[
'CropBox'])) {
2135 $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);
2138 if (isset($format[
'BleedBox'])) {
2139 $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);
2142 if (isset($format[
'TrimBox'])) {
2143 $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);
2146 if (isset($format[
'ArtBox'])) {
2147 $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);
2150 if (isset($format[
'BoxColorInfo'])) {
2151 $this->pagedim[
$this->page][
'BoxColorInfo'] = $format[
'BoxColorInfo'];
2153 if (isset($format[
'Rotate']) AND (($format[
'Rotate'] % 90) == 0)) {
2155 $this->pagedim[
$this->page][
'Rotate'] = intval($format[
'Rotate']);
2157 if (isset($format[
'PZ'])) {
2159 $this->pagedim[
$this->page][
'PZ'] = floatval($format[
'PZ']);
2161 if (isset($format[
'trans'])) {
2163 if (isset($format[
'trans'][
'Dur'])) {
2165 $this->pagedim[
$this->page][
'trans'][
'Dur'] = floatval($format[
'trans'][
'Dur']);
2167 $stansition_styles =
array(
'Split',
'Blinds',
'Box',
'Wipe',
'Dissolve',
'Glitter',
'R',
'Fly',
'Push',
'Cover',
'Uncover',
'Fade');
2168 if (isset($format[
'trans'][
'S']) AND in_array($format[
'trans'][
'S'], $stansition_styles)) {
2170 $this->pagedim[
$this->page][
'trans'][
'S'] = $format[
'trans'][
'S'];
2171 $valid_effect =
array(
'Split',
'Blinds');
2172 $valid_vals =
array(
'H',
'V');
2173 if (isset($format[
'trans'][
'Dm']) AND in_array($format[
'trans'][
'S'], $valid_effect) AND in_array($format[
'trans'][
'Dm'], $valid_vals)) {
2174 $this->pagedim[
$this->page][
'trans'][
'Dm'] = $format[
'trans'][
'Dm'];
2176 $valid_effect =
array(
'Split',
'Box',
'Fly');
2177 $valid_vals =
array(
'I',
'O');
2178 if (isset($format[
'trans'][
'M']) AND in_array($format[
'trans'][
'S'], $valid_effect) AND in_array($format[
'trans'][
'M'], $valid_vals)) {
2179 $this->pagedim[
$this->page][
'trans'][
'M'] = $format[
'trans'][
'M'];
2181 $valid_effect =
array(
'Wipe',
'Glitter',
'Fly',
'Cover',
'Uncover',
'Push');
2182 if (isset($format[
'trans'][
'Di']) AND in_array($format[
'trans'][
'S'], $valid_effect)) {
2183 if (((($format[
'trans'][
'Di'] == 90) OR ($format[
'trans'][
'Di'] == 180)) AND ($format[
'trans'][
'S'] ==
'Wipe'))
2184 OR (($format[
'trans'][
'Di'] == 315) AND ($format[
'trans'][
'S'] ==
'Glitter'))
2185 OR (($format[
'trans'][
'Di'] == 0) OR ($format[
'trans'][
'Di'] == 270))) {
2186 $this->pagedim[
$this->page][
'trans'][
'Di'] = intval($format[
'trans'][
'Di']);
2189 if (isset($format[
'trans'][
'SS']) AND ($format[
'trans'][
'S'] ==
'Fly')) {
2190 $this->pagedim[
$this->page][
'trans'][
'SS'] = floatval($format[
'trans'][
'SS']);
2192 if (isset($format[
'trans'][
'B']) AND ($format[
'trans'][
'B'] ===
true) AND ($format[
'trans'][
'S'] ==
'Fly')) {
2193 $this->pagedim[
$this->page][
'trans'][
'B'] =
'true';
2198 if (isset($format[
'trans'][
'D'])) {
2200 $this->pagedim[
$this->page][
'trans'][
'D'] = floatval($format[
'trans'][
'D']);
2218 if (!isset($this->pagedim[$this->page][
'MediaBox'])) {
2220 $this->pagedim =
TCPDF_STATIC::setPageBoxes($this->page,
'MediaBox', 0, 0, $this->fwPt, $this->fhPt,
true, $this->k, $this->pagedim);
2222 if (!isset($this->pagedim[$this->page][
'CropBox'])) {
2224 $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);
2226 if (!isset($this->pagedim[$this->page][
'BleedBox'])) {
2228 $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);
2230 if (!isset($this->pagedim[$this->page][
'TrimBox'])) {
2232 $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);
2234 if (!isset($this->pagedim[$this->page][
'ArtBox'])) {
2236 $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);
2238 if (!isset($this->pagedim[$this->page][
'Rotate'])) {
2242 if (!isset($this->pagedim[$this->page][
'PZ'])) {
2246 if ($this->fwPt > $this->fhPt) {
2248 $default_orientation =
'L';
2251 $default_orientation =
'P';
2253 $valid_orientations =
array(
'P',
'L');
2254 if (empty($orientation)) {
2255 $orientation = $default_orientation;
2257 $orientation = strtoupper($orientation[0]);
2259 if (in_array($orientation, $valid_orientations) AND ($orientation != $default_orientation)) {
2260 $this->CurOrientation = $orientation;
2264 $this->CurOrientation = $default_orientation;
2268 if ((abs($this->pagedim[$this->page][
'MediaBox'][
'urx'] - $this->hPt) < $this->feps) AND (abs($this->pagedim[$this->page][
'MediaBox'][
'ury'] - $this->wPt) < $this->feps)){
2272 $this->w = ($this->wPt /
$this->k);
2273 $this->h = ($this->hPt /
$this->k);
2275 if (isset($this->AutoPageBreak)) {
2278 $autopagebreak =
true;
2282 if (isset($this->bMargin)) {
2286 $bottommargin = 2 * 28.35 /
$this->k;
2296 $this->pagedim[
$this->page][
'bm'] = $bottommargin;
2299 $this->pagedim[
$this->page][
'pb'] = $autopagebreak;
2324 $this->re_spaces = $re;
2325 $re_parts = explode(
'/', $re);
2327 $this->re_space =
array();
2328 if (isset($re_parts[1]) AND !empty($re_parts[1])) {
2329 $this->re_space[
'p'] = $re_parts[1];
2331 $this->re_space[
'p'] =
'[\s]';
2334 if (isset($re_parts[2]) AND !empty($re_parts[2])) {
2335 $this->re_space[
'm'] = $re_parts[2];
2337 $this->re_space[
'm'] =
'';
2348 public function setRTL($enable, $resetx=
true) {
2349 $enable = $enable ? true :
false;
2350 $resetx = ($resetx AND ($enable != $this->rtl));
2351 $this->rtl = $enable;
2352 $this->tmprtl =
false;
2376 switch (strtoupper($mode)) {
2397 $this->tmprtl = $newmode;
2407 return ($this->rtl OR ($this->tmprtl ==
'R'));
2430 $height += ($this->cell_padding[
'T'] + $this->cell_padding[
'B']);
2432 return round($height, 6);
2462 $this->imgscale = $scale;
2486 if (empty($pagenum)) {
2489 return $this->pagedim[$pagenum];
2502 if (empty($pagenum)) {
2505 return $this->pagedim[$pagenum][
'w'];
2518 if (empty($pagenum)) {
2521 return $this->pagedim[$pagenum][
'h'];
2534 if (empty($pagenum)) {
2537 return $this->pagedim[$pagenum][
'bm'];
2561 public function SetMargins($left, $top, $right=-1, $keepmargins=
false) {
2563 $this->lMargin = $left;
2564 $this->tMargin = $top;
2568 $this->rMargin = $right;
2585 $this->lMargin = $margin;
2586 if (($this->page > 0) AND ($this->x < $margin)) {
2600 $this->tMargin = $margin;
2601 if (($this->page > 0) AND ($this->y < $margin)) {
2614 $this->rMargin = $margin;
2615 if (($this->page > 0) AND ($this->x > ($this->w - $margin))) {
2616 $this->x = $this->w - $margin;
2629 $this->cell_padding[
'L'] = $pad;
2630 $this->cell_padding[
'T'] = $pad;
2631 $this->cell_padding[
'R'] = $pad;
2632 $this->cell_padding[
'B'] = $pad;
2647 if (($left !==
'') AND ($left >= 0)) {
2648 $this->cell_padding[
'L'] = $left;
2650 if (($top !==
'') AND ($top >= 0)) {
2651 $this->cell_padding[
'T'] = $top;
2653 if (($right !==
'') AND ($right >= 0)) {
2654 $this->cell_padding[
'R'] = $right;
2656 if (($bottom !==
'') AND ($bottom >= 0)) {
2657 $this->cell_padding[
'B'] = $bottom;
2683 if (($left !==
'') AND ($left >= 0)) {
2684 $this->cell_margin[
'L'] = $left;
2686 if (($top !==
'') AND ($top >= 0)) {
2687 $this->cell_margin[
'T'] = $top;
2689 if (($right !==
'') AND ($right >= 0)) {
2690 $this->cell_margin[
'R'] = $right;
2692 if (($bottom !==
'') AND ($bottom >= 0)) {
2693 $this->cell_margin[
'B'] = $bottom;
2719 if (is_string($brd)) {
2721 $slen = strlen($brd);
2723 for ($i = 0; $i < $slen; ++$i) {
2724 $newbrd[$brd[$i]] =
true;
2727 } elseif (($brd === 1) OR ($brd ===
true) OR (is_numeric($brd) AND (intval($brd) > 0))) {
2728 $brd =
array(
'LRTB' =>
true);
2730 if (!is_array($brd)) {
2736 if (isset($brd[
'mode'])) {
2737 $mode = $brd[
'mode'];
2738 unset($brd[
'mode']);
2747 $line_width =
$style[
'width'];
2761 $adj = ($line_width / 2);
2766 if ((strpos(
$border,
'T') !==
false) AND ($this->cell_padding[
'T'] < $adj)) {
2767 $this->cell_padding[
'T'] = $adj;
2769 if ((strpos(
$border,
'R') !==
false) AND ($this->cell_padding[
'R'] < $adj)) {
2770 $this->cell_padding[
'R'] = $adj;
2772 if ((strpos(
$border,
'B') !==
false) AND ($this->cell_padding[
'B'] < $adj)) {
2773 $this->cell_padding[
'B'] = $adj;
2775 if ((strpos(
$border,
'L') !==
false) AND ($this->cell_padding[
'L'] < $adj)) {
2776 $this->cell_padding[
'L'] = $adj;
2779 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']));
2791 $this->AutoPageBreak = $auto ? true :
false;
2792 $this->bMargin = $margin;
2793 $this->PageBreakTrigger = $this->h - $margin;
2815 if (($zoom ==
'fullpage') OR ($zoom ==
'fullwidth') OR ($zoom ==
'real') OR ($zoom ==
'default') OR (!is_string($zoom))) {
2816 $this->ZoomMode = $zoom;
2818 $this->
Error(
'Incorrect zoom display mode: '.$zoom);
2832 if (function_exists(
'gzcompress')) {
2833 $this->compress =
$compress ? true :
false;
2835 $this->compress =
false;
2846 $this->force_srgb = $mode ? true :
false;
2857 $this->docinfounicode = $unicode ? true :
false;
2925 die(
'<strong>TCPDF ERROR: </strong>'.$msg);
2927 throw new Exception(
'TCPDF ERROR: '.$msg);
2952 if ($this->state == 3) {
2955 if ($this->page == 0) {
2959 if ($this->tcpdflink) {
2963 $this->lastpage(
true);
2966 $this->y = $this->h - (1 /
$this->k);
2972 $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";
2973 $lnk =
"\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67";
2974 $this->
Cell(0, 0, $msg, 0, 0,
'L', 0, $lnk, 0,
false,
'D',
'B');
2995 public function setPage($pnum, $resetmargins=
false) {
2996 if (($pnum == $this->page) AND ($this->state == 2)) {
2999 if (($pnum > 0) AND ($pnum <= $this->numpages)) {
3004 $this->page = $pnum;
3009 $this->tMargin = $this->pagedim[
$this->page][
'tm'];
3010 $this->bMargin = $this->pagedim[
$this->page][
'bm'];
3011 $this->original_lMargin = $this->pagedim[
$this->page][
'olm'];
3012 $this->original_rMargin = $this->pagedim[
$this->page][
'orm'];
3013 $this->AutoPageBreak = $this->pagedim[
$this->page][
'pb'];
3014 $this->CurOrientation = $this->pagedim[
$this->page][
'or'];
3018 if ($resetmargins) {
3019 $this->lMargin = $this->pagedim[
$this->page][
'olm'];
3020 $this->rMargin = $this->pagedim[
$this->page][
'orm'];
3021 $this->
SetY($this->tMargin);
3024 if ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$oldpage][
'olm']) {
3026 $this->lMargin += $deltam;
3027 $this->rMargin -= $deltam;
3031 $this->
Error(
'Wrong page number on setPage() function: '.$pnum);
3077 public function addTOCPage($orientation=
'', $format=
'', $keepmargins=
false) {
3078 $this->
AddPage($orientation, $format, $keepmargins,
true);
3102 public function AddPage($orientation=
'', $format=
'', $keepmargins=
false,
$tocpage=
false) {
3103 if ($this->inxobj) {
3107 if (!isset($this->original_lMargin) OR $keepmargins) {
3110 if (!isset($this->original_rMargin) OR $keepmargins) {
3128 if (($this->page == 0) OR ($this->numpages > $this->page) OR (!$this->pageopen[$this->page])) {
3138 $this->tocpage =
false;
3154 $this->tocpage =
true;
3157 if ($this->tocpage) {
3161 foreach ($tmpoutlines as $key => $outline) {
3162 if (!$outline[
'f'] AND ($outline[
'p'] > $this->numpages)) {
3163 $this->outlines[$key][
'p'] = ($outline[
'p'] + 1);
3168 foreach ($tmpdests as $key => $dest) {
3169 if (!$dest[
'f'] AND ($dest[
'p'] > $this->numpages)) {
3170 $this->dests[$key][
'p'] = ($dest[
'p'] + 1);
3175 foreach ($tmplinks as $key => $link) {
3176 if (!$link[
'f'] AND ($link[
'p'] > $this->numpages)) {
3177 $this->links[$key][
'p'] = ($link[
'p'] + 1);
3181 if ($this->numpages > $this->page) {
3183 $this->
setPage($this->page + 1);
3184 $this->
SetY($this->tMargin);
3188 if ($this->state == 0) {
3240 if (isset($this->footerlen[
$page])) {
3241 $this->cntmrk[
$page] = $this->pagelen[
$page] - $this->footerlen[
$page];
3243 $this->cntmrk[
$page] = $this->pagelen[
$page];
3258 $this->header_logo = $ln;
3259 $this->header_logo_width = $lw;
3260 $this->header_title = $ht;
3261 $this->header_string = $hs;
3262 $this->header_text_color = $tc;
3263 $this->header_line_color = $lc;
3273 $this->footer_text_color = $tc;
3274 $this->footer_line_color = $lc;
3302 $this->header_margin = $hm;
3322 $this->footer_margin = $fm;
3340 $this->print_header = $val ? true :
false;
3349 $this->print_footer = $val ? true :
false;
3375 $this->header_xobjid =
false;
3384 $this->header_xobj_autoreset = $val ? true :
false;
3393 if ($this->header_xobjid ===
false) {
3395 $this->header_xobjid = $this->
startTemplate($this->w, $this->tMargin);
3404 if (($headerdata[
'logo']) AND ($headerdata[
'logo'] !=
K_BLANK_IMAGE)) {
3406 if (($imgtype ==
'eps') OR ($imgtype ==
'ai')) {
3408 } elseif ($imgtype ==
'svg') {
3417 $cell_height = $this->
getCellHeight($headerfont[2] / $this->k);
3420 $header_x = $this->original_rMargin + ($headerdata[
'logo_width'] * 1.1);
3422 $header_x = $this->original_lMargin + ($headerdata[
'logo_width'] * 1.1);
3424 $cw = $this->w - $this->original_lMargin - $this->original_rMargin - ($headerdata[
'logo_width'] * 1.1);
3427 $this->
SetFont($headerfont[0],
'B', $headerfont[2] + 1);
3428 $this->
SetX($header_x);
3429 $this->
Cell($cw, $cell_height, $headerdata[
'title'], 0, 1,
'', 0,
'', 0);
3431 $this->
SetFont($headerfont[0], $headerfont[1], $headerfont[2]);
3432 $this->
SetX($header_x);
3433 $this->
MultiCell($cw, $cell_height, $headerdata[
'string'], 0,
'', 0, 1,
'',
'',
true, 0,
false,
true, 0,
'T',
false);
3435 $this->
SetLineStyle(
array(
'width' => 0.85 / $this->k,
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $headerdata[
'line_color']));
3436 $this->
SetY((2.835 / $this->k) + max($imgy, $this->y));
3438 $this->
SetX($this->original_rMargin);
3440 $this->
SetX($this->original_lMargin);
3442 $this->
Cell(($this->w - $this->original_lMargin - $this->original_rMargin), 0,
'',
'T', 0,
'C');
3448 if (!$this->header_xobj_autoreset AND $this->booklet AND (($this->page % 2) == 0)) {
3453 $x = $this->w + $dx;
3457 $this->
printTemplate($this->header_xobjid,
$x, 0, 0, 0,
'',
'',
false);
3458 if ($this->header_xobj_autoreset) {
3460 $this->header_xobjid =
false;
3474 $this->
SetLineStyle(
array(
'width' => $line_width,
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $this->footer_line_color));
3478 $this->
Ln($line_width);
3479 $barcode_width = round(($this->w - $this->original_lMargin - $this->original_rMargin) / 3);
3481 'position' => $this->rtl?
'R':
'L',
3482 'align' => $this->rtl?
'R':
'L',
3485 'cellfitalign' =>
'',
3488 'fgcolor' =>
array(0,0,0),
3494 $w_page = isset($this->l[
'w_page']) ? $this->l[
'w_page'].
' ' :
'';
3495 if (empty($this->pagegroups)) {
3496 $pagenumtxt = $w_page.$this->getAliasNumPage().
' / '.$this->
getAliasNbPages();
3498 $pagenumtxt = $w_page.$this->getPageNumGroupAlias().
' / '.$this->
getPageGroupAlias();
3500 $this->
SetY($cur_y);
3503 $this->
SetX($this->original_rMargin);
3504 $this->
Cell(0, 0, $pagenumtxt,
'T', 0,
'L');
3506 $this->
SetX($this->original_lMargin);
3517 if (!$this->print_header OR ($this->state != 2)) {
3520 $this->InHeader =
true;
3532 $this->
SetXY($this->original_rMargin, $this->header_margin);
3534 $this->
SetXY($this->original_lMargin, $this->header_margin);
3536 $this->
SetFont($this->header_font[0], $this->header_font[1], $this->header_font[2]);
3540 $this->
SetXY($this->original_rMargin, $this->tMargin);
3542 $this->
SetXY($this->original_lMargin, $this->tMargin);
3546 $this->thead = $temp_thead;
3547 $this->theadMargins = $temp_theadMargins;
3549 $this->InHeader =
false;
3558 if ($this->state != 2) {
3561 $this->InFooter =
true;
3567 if ($this->print_footer) {
3569 $this->current_column = 0;
3570 $this->num_columns = 1;
3581 $this->
SetXY($this->original_rMargin, $footer_y);
3583 $this->
SetXY($this->original_lMargin, $footer_y);
3585 $this->
SetFont($this->footer_font[0], $this->footer_font[1], $this->footer_font[2]);
3589 $this->
SetXY($this->original_rMargin, $this->tMargin);
3591 $this->
SetXY($this->original_lMargin, $this->tMargin);
3595 $this->thead = $temp_thead;
3596 $this->theadMargins = $temp_theadMargins;
3600 $this->current_column = $gvars[
'current_column'];
3601 $this->num_columns = $gvars[
'num_columns'];
3604 $this->InFooter =
false;
3614 return (($this->InHeader ===
false) AND ($this->InFooter ===
false));
3623 if ($this->num_columns > 1) {
3627 if (isset($this->theadMargins[
'top'])) {
3629 $this->tMargin = $this->theadMargins[
'top'];
3638 $this->lMargin = $this->theadMargins[
'lmargin'] + ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$this->theadMargins[
'page']][
'olm']);
3639 $this->rMargin = $this->theadMargins[
'rmargin'] + ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$this->theadMargins[
'page']][
'orm']);
3640 $this->cell_padding = $this->theadMargins[
'cell_padding'];
3647 if ($this->theadMargins[
'cell']) {
3649 $this->x -= $this->cell_padding[
'R'];
3651 $this->x += $this->cell_padding[
'L'];
3655 if (!empty($this->theadMargins[
'gvars'])) {
3658 $this->rMargin = $gvars[
'rMargin'];
3659 $this->lMargin = $gvars[
'lMargin'];
3662 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
3665 if (!isset($this->theadMargins[
'top'])) {
3669 if (!isset($this->
columns[0][
'th'])) {
3676 $this->lMargin = $prev_lMargin;
3677 $this->rMargin = $prev_rMargin;
3678 $this->cell_padding = $prev_cell_padding;
3717 if (!isset($this->spot_colors[$name])) {
3718 $i = (1 + count($this->spot_colors));
3719 $this->spot_colors[$name] =
array(
'C' => $c,
'M' => $m,
'Y' =>
$y,
'K' =>
$k,
'name' => $name,
'i' => $i);
3734 if ($spotcolor ===
false) {
3735 $this->
Error(
'Undefined spot color: '.$name.
', you must add it using the AddSpotColor() method.');
3737 $tint = (max(0, min(100, $tint)) / 100);
3738 $pdfcolor = sprintf(
'/CS%d ', $this->spot_colors[$name][
'i']);
3741 $pdfcolor .= sprintf(
'CS %F SCN', $tint);
3742 $this->DrawColor = $pdfcolor;
3743 $this->strokecolor = $spotcolor;
3747 $pdfcolor .= sprintf(
'cs %F scn', $tint);
3748 $this->FillColor = $pdfcolor;
3749 $this->bgcolor = $spotcolor;
3753 $pdfcolor .= sprintf(
'cs %F scn', $tint);
3754 $this->TextColor = $pdfcolor;
3755 $this->fgcolor = $spotcolor;
3760 if ($this->state == 2) {
3761 $this->
_out($pdfcolor);
3763 if ($this->inxobj) {
3765 $this->xobjects[
$this->xobjid][
'spot_colors'][$name] = $this->spot_colors[$name];
3818 if (is_array($color)) {
3819 $color = array_values($color);
3821 $c = isset($color[0]) ? $color[0] : -1;
3823 $m = isset($color[1]) ? $color[1] : -1;
3825 $y = isset($color[2]) ? $color[2] : -1;
3827 $k = isset($color[3]) ? $color[3] : -1;
3829 $name = isset($color[4]) ? $color[4] :
'';
3892 public function setColor($type, $col1=0, $col2=-1, $col3=-1, $col4=-1,
$ret=
false, $name=
'') {
3894 if (!is_numeric($col1)) {
3897 if (!is_numeric($col2)) {
3900 if (!is_numeric($col3)) {
3903 if (!is_numeric($col4)) {
3908 if (($col2 == -1) AND ($col3 == -1) AND ($col4 == -1)) {
3910 $col1 = max(0, min(255, $col1));
3911 $intcolor =
array(
'G' => $col1);
3912 $pdfcolor = sprintf(
'%F ', ($col1 / 255));
3914 } elseif ($col4 == -1) {
3916 $col1 = max(0, min(255, $col1));
3917 $col2 = max(0, min(255, $col2));
3918 $col3 = max(0, min(255, $col3));
3919 $intcolor =
array(
'R' => $col1,
'G' => $col2,
'B' => $col3);
3920 $pdfcolor = sprintf(
'%F %F %F ', ($col1 / 255), ($col2 / 255), ($col3 / 255));
3923 $col1 = max(0, min(100, $col1));
3924 $col2 = max(0, min(100, $col2));
3925 $col3 = max(0, min(100, $col3));
3926 $col4 = max(0, min(100, $col4));
3929 $intcolor =
array(
'C' => $col1,
'M' => $col2,
'Y' => $col3,
'K' => $col4);
3930 $pdfcolor = sprintf(
'%F %F %F %F ', ($col1 / 100), ($col2 / 100), ($col3 / 100), ($col4 / 100));
3934 $intcolor =
array(
'C' => $col1,
'M' => $col2,
'Y' => $col3,
'K' => $col4,
'name' => $name);
3935 $this->
AddSpotColor($name, $col1, $col2, $col3, $col4);
3941 $pdfcolor .= strtoupper($suffix);
3942 $this->DrawColor = $pdfcolor;
3943 $this->strokecolor = $intcolor;
3947 $pdfcolor .= $suffix;
3948 $this->FillColor = $pdfcolor;
3949 $this->bgcolor = $intcolor;
3953 $pdfcolor .= $suffix;
3954 $this->TextColor = $pdfcolor;
3955 $this->fgcolor = $intcolor;
3960 if (($type !=
'text') AND ($this->state == 2)) {
3962 $this->
_out($pdfcolor);
3983 return $this->
setColor(
'draw', $col1, $col2, $col3, $col4,
$ret, $name);
4000 return $this->
setColor(
'fill', $col1, $col2, $col3, $col4,
$ret, $name);
4017 return $this->
setColor(
'text', $col1, $col2, $col3, $col4,
$ret, $name);
4032 public function GetStringWidth($s, $fontname=
'', $fontstyle=
'', $fontsize=0, $getarray=
false) {
4033 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);
4054 $this->
SetFont($fontname, $fontstyle, $fontsize,
'',
'default',
false);
4062 foreach ($sa as $ck => $char) {
4064 $cw = $this->
GetCharWidth($char, isset($sa[($ck + 1)]));
4070 $this->
SetFont($prev_FontFamily, $prev_FontStyle, $prev_FontSizePt,
'',
'default',
false);
4090 if (($this->font_spacing < 0) OR (($this->font_spacing > 0) AND $notlast)) {
4094 if ($this->font_stretching != 100) {
4096 $chw *= ($this->font_stretching / 100);
4114 if (isset($this->CurrentFont[
'cw'][$char])) {
4115 $w = $this->CurrentFont[
'cw'][$char];
4116 } elseif (isset($this->CurrentFont[
'dw'])) {
4118 $w = $this->CurrentFont[
'dw'];
4119 } elseif (isset($this->CurrentFont[
'cw'][32])) {
4121 $w = $this->CurrentFont[
'cw'][32];
4149 while ((
$file = readdir($fontsdir)) !==
false) {
4150 if (substr(
$file, -4) ==
'.php') {
4151 array_push($this->fontlist, strtolower(basename(
$file,
'.php')));
4154 closedir($fontsdir);
4172 if ($subset ===
'default') {
4175 if ($this->pdfa_mode) {
4182 $this->
Error(
'Empty font family');
4186 if (substr($family, -1) ==
'I') {
4188 $family = substr($family, 0, -1);
4190 if (substr($family, -1) ==
'B') {
4192 $family = substr($family, 0, -1);
4195 $family = strtolower($family);
4196 if ((!$this->isunicode) AND ($family ==
'arial')) {
4197 $family =
'helvetica';
4199 if (($family ==
'symbol') OR ($family ==
'zapfdingbats')) {
4202 if ($this->pdfa_mode AND (isset($this->CoreFonts[$family]))) {
4204 $family =
'pdfa'.$family;
4206 $tempstyle = strtoupper(
$style);
4209 if (strpos($tempstyle,
'U') !==
false) {
4210 $this->underline =
true;
4212 $this->underline =
false;
4215 if (strpos($tempstyle,
'D') !==
false) {
4216 $this->linethrough =
true;
4218 $this->linethrough =
false;
4221 if (strpos($tempstyle,
'O') !==
false) {
4222 $this->overline =
true;
4224 $this->overline =
false;
4227 if (strpos($tempstyle,
'B') !==
false) {
4231 if (strpos($tempstyle,
'I') !==
false) {
4235 $fontkey = $family.$style;
4236 $font_style =
$style.($this->underline ?
'U' :
'').($this->linethrough ?
'D' :
'').($this->overline ?
'O' :
'');
4237 $fontdata =
array(
'fontkey' => $fontkey,
'family' => $family,
'style' => $font_style);
4240 if ($fb !==
false) {
4241 if ($this->inxobj) {
4243 $this->xobjects[
$this->xobjid][
'fonts'][$fontkey] = $fb[
'i'];
4250 $fontdir = dirname($fontfile);
4258 $missing_style =
false;
4262 $tmp_fontfile = str_replace(
' ',
'', $family).strtolower(
$style).
'.php';
4265 $missing_style =
true;
4267 $tmp_fontfile = str_replace(
' ',
'', $family).
'.php';
4275 $this->
Error(
'Could not include font definition file: '.$family.
'');
4278 if ((!isset($type)) OR (!isset($cw))) {
4279 $this->
Error(
'The font definition file has a bad format: '.$fontfile.
'');
4289 $cidinfo =
array(
'Registry'=>
'Adobe',
'Ordering'=>
'Identity',
'Supplement'=>0);
4290 $cidinfo[
'uni2cid'] =
array();
4309 if (isset($desc[
'MissingWidth']) AND ($desc[
'MissingWidth'] > 0)) {
4310 $dw = $desc[
'MissingWidth'];
4311 } elseif (isset($cw[32])) {
4318 if ($type ==
'core') {
4319 $name = $this->CoreFonts[$fontkey];
4321 } elseif (($type ==
'TrueType') OR ($type ==
'Type1')) {
4323 } elseif ($type ==
'TrueTypeUnicode') {
4324 $enc =
'Identity-H';
4325 } elseif ($type ==
'cidfont0') {
4326 if ($this->pdfa_mode) {
4327 $this->
Error(
'All fonts must be embedded in PDF/A mode!');
4330 $this->
Error(
'Unknow font type: '.$type.
'');
4333 if (!isset($name) OR empty($name)) {
4337 if (($type !=
'core') AND $missing_style) {
4339 $styles =
array(
'' =>
'',
'B' =>
',Bold',
'I' =>
',Italic',
'BI' =>
',BoldItalic');
4342 if (strpos($bistyle,
'B') !==
false) {
4343 if (isset($desc[
'StemV'])) {
4345 $desc[
'StemV'] = round($desc[
'StemV'] * 1.75);
4348 $desc[
'StemV'] = 123;
4352 if (strpos($bistyle,
'I') !==
false) {
4353 if (isset($desc[
'ItalicAngle'])) {
4354 $desc[
'ItalicAngle'] -= 11;
4356 $desc[
'ItalicAngle'] = -11;
4358 if (isset($desc[
'Flags'])) {
4359 $desc[
'Flags'] |= 64;
4361 $desc[
'Flags'] = 64;
4366 if (!isset($cbbox)) {
4370 $subsetchars = array_fill(0, 255,
true);
4371 $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));
4372 if ($this->inxobj) {
4376 if (isset($diff) AND (!empty($diff))) {
4379 $nb = count($this->diffs);
4380 for ($i=1; $i <= $nb; ++$i) {
4381 if ($this->diffs[$i] == $diff) {
4388 $this->diffs[
$d] = $diff;
4393 if (!isset($this->FontFiles[
$file])) {
4394 if ((strcasecmp($type,
'TrueType') == 0) OR (strcasecmp($type,
'TrueTypeUnicode') == 0)) {
4395 $this->FontFiles[
$file] =
array(
'length1' => $originalsize,
'fontdir' => $fontdir,
'subset' => $subset,
'fontkeys' =>
array($fontkey));
4396 } elseif ($type !=
'core') {
4397 $this->FontFiles[
$file] =
array(
'length1' => $size1,
'length2' => $size2,
'fontdir' => $fontdir,
'subset' => $subset,
'fontkeys' =>
array($fontkey));
4401 $this->FontFiles[
$file][
'subset'] = ($this->FontFiles[
$file][
'subset'] AND $subset);
4402 if (!in_array($fontkey, $this->FontFiles[$file][
'fontkeys'])) {
4403 $this->FontFiles[
$file][
'fontkeys'][] = $fontkey;
4429 if (
$size === null) {
4436 $fontdata = $this->
AddFont($family,
$style, $fontfile, $subset);
4437 $this->FontFamily = $fontdata[
'family'];
4438 $this->FontStyle = $fontdata[
'style'];
4439 if (isset($this->CurrentFont[
'fontkey']) AND isset($this->CurrentFont[
'subsetchars'])) {
4441 $this->
setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
4443 $this->CurrentFont = $this->
getFontBuffer($fontdata[
'fontkey']);
4457 $this->FontSizePt =
$size;
4461 if (isset($this->CurrentFont[
'desc'][
'FontBBox'])) {
4462 $bbox = explode(
' ', substr($this->CurrentFont[
'desc'][
'FontBBox'], 1, -1));
4463 $font_height = ((intval($bbox[3]) - intval($bbox[1])) *
$size / 1000);
4465 $font_height =
$size * 1.219;
4467 if (isset($this->CurrentFont[
'desc'][
'Ascent']) AND ($this->CurrentFont[
'desc'][
'Ascent'] > 0)) {
4468 $font_ascent = ($this->CurrentFont[
'desc'][
'Ascent'] *
$size / 1000);
4470 if (isset($this->CurrentFont[
'desc'][
'Descent']) AND ($this->CurrentFont[
'desc'][
'Descent'] <= 0)) {
4471 $font_descent = (- $this->CurrentFont[
'desc'][
'Descent'] *
$size / 1000);
4473 if (!isset($font_ascent) AND !isset($font_descent)) {
4475 $font_ascent = 0.76 * $font_height;
4476 $font_descent = $font_height - $font_ascent;
4477 } elseif (!isset($font_descent)) {
4478 $font_descent = $font_height - $font_ascent;
4479 } elseif (!isset($font_ascent)) {
4480 $font_ascent = $font_height - $font_descent;
4482 $this->FontAscent = ($font_ascent /
$this->k);
4483 $this->FontDescent = ($font_descent /
$this->k);
4484 if (
$out AND ($this->page > 0) AND (isset($this->CurrentFont[
'i'])) AND ($this->state == 2)) {
4485 $this->
_out(sprintf(
'BT /F%d %F Tf ET', $this->CurrentFont[
'i'], $this->FontSizePt));
4497 if (isset($this->CurrentFont[
'desc'][
'FontBBox'])) {
4498 $tmpbbox = explode(
' ', substr($this->CurrentFont[
'desc'][
'FontBBox'], 1, -1));
4499 $fbbox = array_map(
array($this,
'getAbsFontMeasure'), $tmpbbox);
4502 if (isset($this->CurrentFont[
'desc'][
'MaxWidth'])) {
4503 $maxw = $this->
getAbsFontMeasure(intval($this->CurrentFont[
'desc'][
'MaxWidth']));
4506 if (isset($this->CurrentFont[
'desc'][
'MissingWidth'])) {
4507 $maxw = max($maxw, $this->CurrentFont[
'desc'][
'MissingWidth']);
4509 if (isset($this->CurrentFont[
'desc'][
'AvgWidth'])) {
4510 $maxw = max($maxw, $this->CurrentFont[
'desc'][
'AvgWidth']);
4512 if (isset($this->CurrentFont[
'dw'])) {
4513 $maxw = max($maxw, $this->CurrentFont[
'dw']);
4515 foreach ($this->CurrentFont[
'cw'] as $char =>
$w) {
4516 $maxw = max($maxw,
$w);
4523 $fbbox =
array(0, (0 - $this->FontDescent), $maxw, $this->FontAscent);
4535 return ($s * $this->FontSize / 1000);
4546 if (isset($this->CurrentFont[
'cw'][$c])) {
4549 if (isset($this->CurrentFont[
'cbbox'][$c])) {
4550 $result = $this->CurrentFont[
'cbbox'][$c];
4552 return array_map(
array($this,
'getAbsFontMeasure'),
$result);
4570 if (isset($fontinfo[
'desc'][
'Descent']) AND ($fontinfo[
'desc'][
'Descent'] <= 0)) {
4571 $descent = (- $fontinfo[
'desc'][
'Descent'] *
$size / 1000);
4573 $descent = (1.219 * 0.24 *
$size);
4575 return ($descent / $this->k);
4591 if (isset($fontinfo[
'desc'][
'Ascent']) AND ($fontinfo[
'desc'][
'Ascent'] > 0)) {
4592 $ascent = ($fontinfo[
'desc'][
'Ascent'] *
$size / 1000);
4594 $ascent = 1.219 * 0.76 *
$size;
4596 return ($ascent / $this->k);
4609 if (is_string($char)) {
4616 return (isset($this->CurrentFont[
'cw'][intval($char)]));
4622 return (isset($fontinfo[
'cw'][intval($char)]));
4645 foreach ($uniarr as
$k => $chr) {
4646 if (!isset($fontinfo[
'cw'][$chr])) {
4648 if (isset($subs[$chr])) {
4650 if (is_array($subs[$chr])) {
4651 foreach($subs[$chr] as $s) {
4652 if (isset($fontinfo[
'cw'][$s])) {
4657 } elseif (isset($fontinfo[
'cw'][$subs[$chr]])) {
4658 $uniarr[
$k] = $subs[$chr];
4673 $this->default_monospaced_font = $font;
4685 $n = count($this->links) + 1;
4686 $this->links[
$n] =
array(
'p' => 0,
'y' => 0,
'f' =>
false);
4712 $this->links[$link] =
array(
'p' =>
$page,
'y' =>
$y,
'f' => $fixed);
4746 if ($this->inxobj) {
4748 $this->xobjects[
$this->xobjid][
'annotations'][] =
array(
'x' =>
$x,
'y' =>
$y,
'w' =>
$w,
'h' =>
$h,
'text' =>
$text,
'opt' => $opt,
'spaces' => $spaces);
4760 if (isset($this->transfmatrix) AND !empty($this->transfmatrix)) {
4761 for ($i=$this->transfmatrix_key; $i > 0; --$i) {
4762 $maxid = count($this->transfmatrix[$i]) - 1;
4763 for ($j=$maxid; $j >= 0; --$j) {
4764 $ctm = $this->transfmatrix[$i][$j];
4765 if (isset($ctm[
'a'])) {
4767 $y = ($this->h -
$y) * $this->k;
4773 $x1 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4774 $y1 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4778 $x2 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4779 $y2 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4783 $x3 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4784 $y3 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4788 $x4 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
4789 $y4 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
4791 $x = min($x1, $x2, $x3, $x4);
4792 $y = max($y1, $y2, $y3, $y4);
4793 $w = (max($x1, $x2, $x3, $x4) -
$x) / $this->k;
4794 $h = (
$y - min($y1, $y2, $y3, $y4)) / $this->k;
4801 if ($this->page <= 0) {
4806 if (!isset($this->PageAnnots[
$page])) {
4809 $this->PageAnnots[
$page][] =
array(
'n' => ++$this->
n,
'x' =>
$x,
'y' =>
$y,
'w' =>
$w,
'h' =>
$h,
'txt' =>
$text,
'opt' => $opt,
'numspaces' => $spaces);
4810 if (!$this->pdfa_mode) {
4813 AND (!isset($this->embeddedfiles[basename($opt[
'FS'])]))) {
4814 $this->embeddedfiles[basename($opt[
'FS'])] =
array(
'f' => ++$this->
n,
'n' => ++$this->
n,
'file' => $opt[
'FS']);
4818 if (isset($opt[
'mk'][
'i']) AND @file_exists($opt[
'mk'][
'i'])) {
4819 $this->
Image($opt[
'mk'][
'i'],
'',
'', 10, 10,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
4821 if (isset($opt[
'mk'][
'ri']) AND @file_exists($opt[
'mk'][
'ri'])) {
4822 $this->
Image($opt[
'mk'][
'ri'],
'',
'', 0, 0,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
4824 if (isset($opt[
'mk'][
'ix']) AND @file_exists($opt[
'mk'][
'ix'])) {
4825 $this->
Image($opt[
'mk'][
'ix'],
'',
'', 0, 0,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
4836 if ($this->pdfa_mode) {
4840 reset($this->embeddedfiles);
4841 foreach ($this->embeddedfiles as
$filename => $filedata) {
4843 if (
$data !== FALSE) {
4844 $rawsize = strlen(
$data);
4847 $this->efnames[
$filename] = $filedata[
'f'].
' 0 R';
4850 $out .=
'<</Type /Filespec /F '.$this->_datastring(
$filename, $filedata[
'f']).
' /EF <</F '.$filedata[
'n'].
' 0 R>> >>';
4851 $out .=
"\n".
'endobj';
4855 if ($this->compress) {
4857 $filter =
' /Filter /FlateDecode';
4861 $out .=
'<< /Type /EmbeddedFile'.$filter.
' /Length '.strlen($stream).
' /Params <</Size '.$rawsize.
'>> >>';
4862 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
4863 $out .=
"\n".
'endobj';
4893 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) {
4898 $this->
Cell(0, 0,
$txt,
$border, $ln, $align, $fill, $link, $stretch, $ignore_min_height, $calign, $valign);
4914 if ($this->num_columns > 1) {
4916 if ($this->current_column < ($this->num_columns - 1)) {
4919 } elseif ($this->AutoPageBreak) {
4949 $this->
AddPage($this->CurOrientation);
4951 $oldpage = $this->page - 1;
4953 if ($this->pagedim[$this->page][
'orm'] != $this->pagedim[$oldpage][
'orm']) {
4954 $this->x =
$x - ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$oldpage][
'orm']);
4959 if ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$oldpage][
'olm']) {
4960 $this->x =
$x + ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$oldpage][
'olm']);
4968 if ($current_page != $this->page) {
4994 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') {
4998 if (!$ignore_min_height) {
5000 if (
$h < $min_cell_height) {
5001 $h = $min_cell_height;
5004 $this->
checkPageBreak(
$h + $this->cell_margin[
'T'] + $this->cell_margin[
'B']);
5006 if ($this->txtshadow[
'enabled']) {
5015 $this->x += $this->txtshadow[
'depth_w'];
5016 $this->y += $this->txtshadow[
'depth_h'];
5020 if ($this->txtshadow[
'opacity'] !=
$alpha[
'CA']) {
5021 $this->
setAlpha($this->txtshadow[
'opacity'], $this->txtshadow[
'blend_mode']);
5023 if ($this->state == 2) {
5024 $this->
_out($this->
getCellCode(
$w,
$h,
$txt,
$border, $ln, $align, $fill, $link, $stretch,
true, $calign, $valign));
5032 if ($this->txtshadow[
'opacity'] !=
$alpha[
'CA']) {
5036 if ($this->state == 2) {
5037 $this->
_out($this->
getCellCode(
$w,
$h,
$txt,
$border, $ln, $align, $fill, $link, $stretch,
true, $calign, $valign));
5039 $this->cell_padding = $prev_cell_padding;
5040 $this->cell_margin = $prev_cell_margin;
5063 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') {
5071 if (!$ignore_min_height) {
5073 if (
$h < $min_cell_height) {
5074 $h = $min_cell_height;
5081 $x = $this->x - $this->cell_margin[
'R'];
5083 $x = $this->x + $this->cell_margin[
'L'];
5085 $y = $this->y + $this->cell_margin[
'T'];
5095 $y -= $this->cell_padding[
'T'];
5146 $y -= (
$h - $this->cell_padding[
'B']);
5180 $yt =
$y + $this->cell_padding[
'T'];
5201 $w = $this->w - $this->rMargin -
$x;
5210 if ($fill OR (
$border == 1)) {
5212 $op = (
$border == 1) ?
'B' :
'f';
5221 $s .= sprintf(
'%F %F %F %F re %s ', $xk, (($this->h -
$y) *
$k), (
$w * $k), (-
$h * $k), $op);
5227 if ($this->isunicode) {
5228 if (($this->CurrentFont[
'type'] ==
'core') OR ($this->CurrentFont[
'type'] ==
'TrueType') OR ($this->CurrentFont[
'type'] ==
'Type1')) {
5232 $unicode =
TCPDF_FONTS::utf8Bidi($unicode,
'', $this->tmprtl, $this->isunicode, $this->CurrentFont);
5236 $numchars = count($unicode);
5238 $longtail =
array(0x0e1b, 0x0e1d, 0x0e1f);
5240 $lowtail =
array(0x0e0e, 0x0e0f);
5242 $upvowel =
array(0x0e31, 0x0e34, 0x0e35, 0x0e36, 0x0e37);
5244 $tonemark =
array(0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c);
5246 $lowvowel =
array(0x0e38, 0x0e39, 0x0e3a);
5248 for ($i = 0; $i < $numchars; $i++) {
5249 if (($unicode[$i] >= 0x0e00) && ($unicode[$i] <= 0x0e5b)) {
5250 $ch0 = $unicode[$i];
5251 $ch1 = ($i > 0) ? $unicode[($i - 1)] : 0;
5252 $ch2 = ($i > 1) ? $unicode[($i - 2)] : 0;
5253 $chn = ($i < ($numchars - 1)) ? $unicode[($i + 1)] : 0;
5254 if (in_array($ch0, $tonemark)) {
5255 if ($chn == 0x0e33) {
5257 if (in_array($ch1, $longtail)) {
5264 } elseif (in_array($ch1, $longtail) OR (in_array($ch2, $longtail) AND in_array($ch1, $lowvowel))) {
5267 } elseif (in_array($ch1, $upvowel)) {
5268 if (in_array($ch2, $longtail)) {
5279 } elseif (($ch0 == 0x0e33) AND (in_array($ch1, $longtail) OR (in_array($ch2, $longtail) AND in_array($ch1, $tonemark)))) {
5283 $this->CurrentFont[
'subsetchars'][0xf711] =
true;
5285 $this->CurrentFont[
'subsetchars'][0x0e32] =
true;
5289 } elseif (in_array($ch1, $longtail)) {
5290 if ($ch0 == 0x0e31) {
5293 } elseif (in_array($ch0, $upvowel)) {
5296 } elseif ($ch0 == 0x0e47) {
5303 } elseif (in_array($ch1, $lowtail) AND in_array($ch0, $lowvowel)) {
5306 } elseif (($ch0 == 0x0e0d) AND in_array($chn, $lowvowel)) {
5309 } elseif (($ch0 == 0x0e10) AND in_array($chn, $lowvowel)) {
5322 $this->
setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
5337 $ratio = ((
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / $width);
5340 if (($ratio < 1) OR (($ratio > 1) AND (($stretch % 2) == 0))) {
5344 $this->font_spacing += (
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'] - $width) / (max(($this->
GetNumChars(
$txt) - 1), 1) * ($this->font_stretching / 100));
5347 $this->font_stretching *= $ratio;
5350 $width =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
5355 if ($this->font_stretching != 100) {
5357 $rs .= sprintf(
'BT %F Tz ET ', $this->font_stretching);
5359 if ($this->font_spacing != 0) {
5361 $rs .= sprintf(
'BT %F Tc ET ', ($this->font_spacing * $this->k));
5363 if ($this->ColorFlag AND ($this->textrendermode < 4)) {
5364 $s .=
'q '.$this->TextColor.
' ';
5367 $s .= sprintf(
'BT %d Tr %F w ET ', $this->textrendermode, ($this->textstrokewidth * $this->k));
5369 $ns = substr_count(
$txt, chr(32));
5372 if (($align ==
'J') AND ($ns > 0)) {
5377 $spacewidth = -1000 * (
$w - $width - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1) / ($this->FontSize?$this->FontSize:1);
5378 if ($this->font_stretching != 100) {
5380 $spacewidth /= ($this->font_stretching / 100);
5383 $txt2 = str_replace(chr(0).chr(32),
') '.sprintf(
'%F', $spacewidth).
' (', $txt2);
5384 $unicode_justification =
true;
5389 $spacewidth = ((
$w - $width - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1)) * $this->k;
5390 if ($this->font_stretching != 100) {
5392 $spacewidth /= ($this->font_stretching / 100);
5395 $rs .= sprintf(
'BT %F Tw ET ', $spacewidth);
5397 $width =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
5400 $txt2 = str_replace(
"\r",
' ', $txt2);
5403 $dx = (
$w - $width) / 2;
5408 $dx = $this->cell_padding[
'R'];
5410 $dx =
$w - $width - $this->cell_padding[
'R'];
5416 $dx =
$w - $width - $this->cell_padding[
'L'];
5418 $dx = $this->cell_padding[
'L'];
5425 $dx = $this->cell_padding[
'R'];
5427 $dx = $this->cell_padding[
'L'];
5433 $xdx =
$x - $dx - $width;
5439 $s .= sprintf(
'BT %F %F Td [(%s)] TJ ET', $xdk, (($this->h - $basefonty) * $k), $txt2);
5440 if (isset($uniblock)) {
5444 $spw = ((
$w - $txwidth - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1));
5445 foreach ($uniblock as $uk => $uniarr) {
5446 if (($uk % 2) == 0) {
5448 if ($spacewidth != 0) {
5450 $xshift += (count(array_keys($uniarr, 32)) * $spw);
5457 $s .= sprintf(
' BT %F %F Td [(%s)] TJ ET', ($xdk + ($xshift * $k)), $ty, $topchr);
5461 if ($this->underline) {
5462 $s .=
' '.$this->_dounderlinew($xdx, $basefonty, $width);
5464 if ($this->linethrough) {
5465 $s .=
' '.$this->_dolinethroughw($xdx, $basefonty, $width);
5467 if ($this->overline) {
5468 $s .=
' '.$this->_dooverlinew($xdx, $basefonty, $width);
5470 if ($this->ColorFlag AND ($this->textrendermode < 4)) {
5474 $this->
Link($xdx, $yt, $width, ($this->FontAscent + $this->FontDescent), $link, $ns);
5481 if ($this->font_spacing != 0) {
5483 $rs .=
' BT 0 Tc ET';
5485 if ($this->font_stretching != 100) {
5487 $rs .=
' BT 100 Tz ET';
5492 $rs .=
' BT 0 Tw ET';
5495 $this->font_stretching = $prev_font_stretching;
5496 $this->font_spacing = $prev_font_spacing;
5500 $this->y =
$y +
$h + $this->cell_margin[
'B'];
5511 $this->x =
$x -
$w - $this->cell_margin[
'L'];
5513 $this->x =
$x +
$w + $this->cell_margin[
'R'];
5516 $gstyles =
''.$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' '.$this->FillColor.
"\n";
5518 $this->cell_padding = $prev_cell_padding;
5519 $this->cell_margin = $prev_cell_margin;
5534 $this->CurrentFont[
'subsetchars'][$newchar] =
true;
5560 $brd =
array(
'LRTB' =>
true);
5569 $xeR = (
$x +
$w) * $k;
5571 $yeL = (($this->h - (
$y +
$h)) *
$k);
5572 $yeT = (($this->h -
$y) *
$k);
5577 if (is_string($brd)) {
5579 $slen = strlen($brd);
5581 for ($i = 0; $i < $slen; ++$i) {
5582 $newbrd[$brd[$i]] =
array(
'cap' =>
'square',
'join' =>
'miter');
5586 if (isset($brd[
'mode'])) {
5587 $mode = $brd[
'mode'];
5588 unset($brd[
'mode']);
5595 $prev_style = $this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' ';
5600 $off = (($this->LineWidth / 2) *
$k);
5614 $off = ($this->LineWidth / 2) *
$k;
5642 $s .= sprintf(
'%F %F %F %F re S ', $xT, $yT, (
$w *
$k), (-
$h * $k));
5643 } elseif (strlen(
$border) == 3) {
5644 if (strpos(
$border,
'B') ===
false) {
5645 $s .= sprintf(
'%F %F m ', $xL, $yL);
5646 $s .= sprintf(
'%F %F l ', $xT, $yT);
5647 $s .= sprintf(
'%F %F l ', $xR, $yR);
5648 $s .= sprintf(
'%F %F l ', $xB, $yB);
5650 } elseif (strpos(
$border,
'L') ===
false) {
5651 $s .= sprintf(
'%F %F m ', $xT, $yT);
5652 $s .= sprintf(
'%F %F l ', $xR, $yR);
5653 $s .= sprintf(
'%F %F l ', $xB, $yB);
5654 $s .= sprintf(
'%F %F l ', $xL, $yL);
5656 } elseif (strpos(
$border,
'T') ===
false) {
5657 $s .= sprintf(
'%F %F m ', $xR, $yR);
5658 $s .= sprintf(
'%F %F l ', $xB, $yB);
5659 $s .= sprintf(
'%F %F l ', $xL, $yL);
5660 $s .= sprintf(
'%F %F l ', $xT, $yT);
5662 } elseif (strpos(
$border,
'R') ===
false) {
5663 $s .= sprintf(
'%F %F m ', $xB, $yB);
5664 $s .= sprintf(
'%F %F l ', $xL, $yL);
5665 $s .= sprintf(
'%F %F l ', $xT, $yT);
5666 $s .= sprintf(
'%F %F l ', $xR, $yR);
5669 } elseif (strlen(
$border) == 2) {
5670 if ((strpos(
$border,
'L') !==
false) AND (strpos(
$border,
'T') !==
false)) {
5671 $s .= sprintf(
'%F %F m ', $xL, $yL);
5672 $s .= sprintf(
'%F %F l ', $xT, $yT);
5673 $s .= sprintf(
'%F %F l ', $xR, $yR);
5675 } elseif ((strpos(
$border,
'T') !==
false) AND (strpos(
$border,
'R') !==
false)) {
5676 $s .= sprintf(
'%F %F m ', $xT, $yT);
5677 $s .= sprintf(
'%F %F l ', $xR, $yR);
5678 $s .= sprintf(
'%F %F l ', $xB, $yB);
5680 } elseif ((strpos(
$border,
'R') !==
false) AND (strpos(
$border,
'B') !==
false)) {
5681 $s .= sprintf(
'%F %F m ', $xR, $yR);
5682 $s .= sprintf(
'%F %F l ', $xB, $yB);
5683 $s .= sprintf(
'%F %F l ', $xL, $yL);
5685 } elseif ((strpos(
$border,
'B') !==
false) AND (strpos(
$border,
'L') !==
false)) {
5686 $s .= sprintf(
'%F %F m ', $xB, $yB);
5687 $s .= sprintf(
'%F %F l ', $xL, $yL);
5688 $s .= sprintf(
'%F %F l ', $xT, $yT);
5690 } elseif ((strpos(
$border,
'L') !==
false) AND (strpos(
$border,
'R') !==
false)) {
5691 $s .= sprintf(
'%F %F m ', $xL, $yL);
5692 $s .= sprintf(
'%F %F l ', $xT, $yT);
5694 $s .= sprintf(
'%F %F m ', $xR, $yR);
5695 $s .= sprintf(
'%F %F l ', $xB, $yB);
5697 } elseif ((strpos(
$border,
'T') !==
false) AND (strpos(
$border,
'B') !==
false)) {
5698 $s .= sprintf(
'%F %F m ', $xT, $yT);
5699 $s .= sprintf(
'%F %F l ', $xR, $yR);
5701 $s .= sprintf(
'%F %F m ', $xB, $yB);
5702 $s .= sprintf(
'%F %F l ', $xL, $yL);
5706 if (strpos(
$border,
'L') !==
false) {
5707 $s .= sprintf(
'%F %F m ', $xL, $yL);
5708 $s .= sprintf(
'%F %F l ', $xT, $yT);
5710 } elseif (strpos(
$border,
'T') !==
false) {
5711 $s .= sprintf(
'%F %F m ', $xT, $yT);
5712 $s .= sprintf(
'%F %F l ', $xR, $yR);
5714 } elseif (strpos(
$border,
'R') !==
false) {
5715 $s .= sprintf(
'%F %F m ', $xR, $yR);
5716 $s .= sprintf(
'%F %F l ', $xB, $yB);
5718 } elseif (strpos(
$border,
'B') !==
false) {
5719 $s .= sprintf(
'%F %F m ', $xB, $yB);
5720 $s .= sprintf(
'%F %F l ', $xL, $yL);
5726 $s .=
"\n".$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
"\n";
5757 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) {
5764 $this->cell_padding[
'T'] = 0;
5765 $this->cell_padding[
'B'] = 0;
5777 if ((
$h > 0) AND $this->
inPageBody() AND ((
$y +
$h + $mc_margin[
'T'] + $mc_margin[
'B']) > $this->PageBreakTrigger)) {
5779 $newh = ($this->PageBreakTrigger -
$y);
5780 $resth = (
$h - $newh);
5795 $oy =
$y + $mc_margin[
'T'];
5797 $ox = ($this->w -
$x - $mc_margin[
'R']);
5799 $ox = (
$x + $mc_margin[
'L']);
5806 $w = ($this->x - $this->lMargin - $mc_margin[
'L']);
5808 $w = ($this->w - $this->x - $this->rMargin - $mc_margin[
'R']);
5815 $this->rMargin = ($this->w -
$this->x);
5816 $this->lMargin = ($this->x -
$w);
5819 $this->rMargin = ($this->w - $this->x -
$w);
5825 $this->y += $mc_padding[
'T'];
5834 $tobottom = ($this->h - $this->y - $this->bMargin - $this->cell_padding[
'T'] - $this->cell_padding[
'B']);
5835 $h = $maxh = max(min(
$h, $tobottom), min($maxh, $tobottom));
5841 if ($fitcell AND ($text_height > $maxh) AND ($this->FontSizePt > 1)) {
5846 $maxit = (2 * min(100, max(10, intval($fmax))));
5847 while ($maxit >= 0) {
5848 $fmid = (($fmax + $fmin) / 2);
5852 $diff = ($maxh - $text_height);
5854 if ($diff <= $diff_epsilon) {
5873 if ($text_height < $maxh) {
5874 if ($valign ==
'M') {
5876 $this->y += (($maxh - $text_height) / 2);
5877 } elseif ($valign ==
'B') {
5879 $this->y += ($maxh - $text_height);
5883 $nl = $this->
Write($this->lasth,
$txt,
'', 0, $align,
true, $stretch,
false,
true, $maxh, 0, $mc_margin);
5891 $this->y += $mc_padding[
'B'];
5898 $skip = ($endpage - $startpage);
5900 while ($tmpresth > 0) {
5905 if ($this->num_columns > 1) {
5917 if ($this->num_columns == 0) {
5918 $this->num_columns = 1;
5922 $this->check_page_regions =
false;
5931 if ($this->num_columns < 2) {
5937 if (
$page > $startpage) {
5938 if (($this->rtl) AND ($this->pagedim[
$page][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
5939 $this->x -= ($this->pagedim[
$page][
'orm'] - $this->pagedim[$startpage][
'orm']);
5940 } elseif ((!$this->rtl) AND ($this->pagedim[
$page][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
5941 $this->x += ($this->pagedim[
$page][
'olm'] - $this->pagedim[$startpage][
'olm']);
5944 if ($startpage == $endpage) {
5949 $this->x -= $mc_margin[
'R'];
5951 $this->x += $mc_margin[
'L'];
5953 if ($startcolumn == $endcolumn) {
5955 $h = max(
$h, ($currentY - $oy));
5957 } elseif (
$column == $startcolumn) {
5958 $cborder = $border_start;
5961 } elseif (
$column == $endcolumn) {
5962 $cborder = $border_end;
5968 $cborder = $border_middle;
5972 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
5974 } elseif (
$page == $startpage) {
5978 $this->x -= $mc_margin[
'R'];
5980 $this->x += $mc_margin[
'L'];
5982 if (
$column == $startcolumn) {
5983 $cborder = $border_start;
5987 $cborder = $border_middle;
5991 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
5993 } elseif (
$page == $endpage) {
5997 $this->x -= $mc_margin[
'R'];
5999 $this->x += $mc_margin[
'L'];
6003 $cborder = $border_end;
6010 $cborder = $border_middle;
6014 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6020 $this->x -= $mc_margin[
'R'];
6022 $this->x += $mc_margin[
'L'];
6024 $cborder = $border_middle;
6027 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6030 if ($cborder OR $fill) {
6031 $offsetlen = strlen($ccode);
6033 if ($this->inxobj) {
6035 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
6036 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
6037 $pagemark = $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey];
6038 $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey] += $offsetlen;
6044 $pstart = substr($pagebuff, 0, $pagemark);
6045 $pend = substr($pagebuff, $pagemark);
6046 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
6048 if (end($this->transfmrk[$this->page]) !==
false) {
6049 $pagemarkkey = key($this->transfmrk[$this->page]);
6050 $pagemark = $this->transfmrk[
$this->page][$pagemarkkey];
6051 $this->transfmrk[
$this->page][$pagemarkkey] += $offsetlen;
6052 } elseif ($this->InFooter) {
6060 $pstart = substr($pagebuff, 0, $pagemark);
6061 $pend = substr($pagebuff, $pagemark);
6069 $currentY = $this->
GetY();
6071 if ($this->num_columns > 1) {
6077 if ($this->page > $startpage) {
6079 $dl = ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$startpage][
'olm']);
6080 $dr = ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$startpage][
'orm']);
6081 if (($dl != 0) OR ($dr != 0)) {
6082 $this->lMargin += $dl;
6083 $this->rMargin += $dr;
6089 $this->
SetY($currentY + $mc_margin[
'B']);
6091 $this->
SetX(
$x +
$w + $mc_margin[
'L'] + $mc_margin[
'R']);
6097 $this->
SetX(
$x +
$w + $mc_margin[
'L'] + $mc_margin[
'R']);
6100 $this->cell_padding = $prev_cell_padding;
6101 $this->cell_margin = $prev_cell_margin;
6121 if (
$txt === NULL) {
6131 if (is_array($cellpadding)) {
6132 $this->cell_padding = $cellpadding;
6142 $wmax =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
6151 $length = count($chars);
6152 $lastSeparator = -1;
6153 for ($i = 0; $i < $length; ++$i) {
6155 $charWidth = $charsWidth[$i];
6160 AND ($i > 0) AND ($i < ($length - 1))
6161 AND @preg_match(
'/[\p{L}]/'.$this->re_space[
'm'],
TCPDF_FONTS::unichr($chars[($i - 1)], $this->isunicode))
6162 AND @preg_match(
'/[\p{L}]/'.$this->re_space[
'm'],
TCPDF_FONTS::unichr($chars[($i + 1)], $this->isunicode))
6166 $lastSeparator = $i;
6168 if ((($sum + $charWidth) > $wmax) OR ($c == 10)) {
6171 $lastSeparator = -1;
6173 } elseif ($lastSeparator != -1) {
6174 $i = $lastSeparator;
6175 $lastSeparator = -1;
6184 if ($chars[($length - 1)] == 10) {
6187 $this->cell_padding = $prev_cell_padding;
6188 $this->lasth = $prev_lasth;
6243 if (is_array($cellpadding)) {
6244 $this->cell_padding = $cellpadding;
6248 $height = $this->
getCellHeight(($lines * $this->FontSize), $autopadding);
6249 $this->cell_padding = $prev_cell_padding;
6250 $this->lasth = $prev_lasth;
6272 public function Write(
$h,
$txt, $link=
'', $fill=
false, $align=
'', $ln=
false, $stretch=0, $firstline=
false, $firstblock=
false, $maxh=0, $wadj=0, $margin=
'') {
6275 if (strlen(
$txt) == 0) {
6279 if ($margin ===
'') {
6284 $s = str_replace(
"\r",
'',
$txt);
6303 array_walk($chrw,
array($this,
'getRawCharWidth'));
6304 $maxchwidth = max($chrw);
6308 $nb = count($chars);
6310 $shy_replacement = 45;
6313 $shy_replacement_width = $this->
GetCharWidth($shy_replacement);
6323 $wmax = (
$w - $wadj);
6325 $wmax -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
6327 if ((!$firstline) AND (($chrwidth > $wmax) OR ($maxchwidth > $wmax))) {
6334 $maxy = $this->y + $maxh - max($row_height,
$h);
6348 if (($maxh > 0) AND ($this->y > $maxy) ) {
6355 if ($align ==
'J') {
6367 $tmparr = array_slice($chars, $j, ($i - $j));
6369 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6374 $this->endlinex = $startx - $linew;
6376 $this->endlinex = $startx + $linew;
6388 if (!empty($tmpstr) OR ($this->y < ($this->PageBreakTrigger - $row_height))) {
6389 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $talign, $fill, $link, $stretch);
6393 $this->cell_padding = $tmpcellpadding;
6403 if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND ($this->
inPageBody())) {
6406 $this->x -= $margin[
'R'];
6408 $this->x += $margin[
'L'];
6410 $this->lMargin += $margin[
'L'];
6411 $this->rMargin += $margin[
'R'];
6414 $wmax = (
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R']);
6425 AND ($i < ($nb - 1))
6426 AND @preg_match(
'/[\p{L}]/'.$this->re_space[
'm'],
TCPDF_FONTS::unichr($pc, $this->isunicode))
6427 AND @preg_match(
'/[\p{L}]/'.$this->re_space[
'm'],
TCPDF_FONTS::unichr($chars[($i + 1)], $this->isunicode))
6435 if (($c == 173) OR ($c == 45)) {
6439 $tmp_shy_replacement_width = 0;
6440 $tmp_shy_replacement_char =
'';
6442 $tmp_shy_replacement_width = $shy_replacement_width;
6443 $tmp_shy_replacement_char = $shy_replacement_char;
6457 if ((
$l > $wmax) OR (($c == 173) AND ((
$l + $tmp_shy_replacement_width) >= $wmax))) {
6458 if (($c == 173) AND ((
$l + $tmp_shy_replacement_width) > $wmax)) {
6465 if (($this->rtl AND ($this->x <= ($this->w - $this->rMargin - $this->cell_padding[
'R'] - $margin[
'R'] - $chrwidth)))
6466 OR ((!$this->rtl) AND ($this->x >= ($this->lMargin + $this->cell_padding[
'L'] + $margin[
'L'] + $chrwidth)))) {
6478 $tmparr = array_slice($chars, $j, ($i - $j));
6480 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6485 $this->endlinex = $startx - $linew;
6487 $this->endlinex = $startx + $linew;
6498 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $align, $fill, $link, $stretch);
6501 $this->cell_padding = $tmpcellpadding;
6509 if ($this->rtl AND (!$firstblock) AND ($sep < $i)) {
6517 if (isset($nextstr[0]) AND ($this->
GetStringWidth($nextstr[0]) > $pw)) {
6522 $tmparr = array_slice($chars, $j, ($i - $j));
6524 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6529 $this->endlinex = ($startx - $linew);
6531 $this->endlinex = ($startx + $linew);
6542 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $align, $fill, $link, $stretch);
6545 $this->cell_padding = $tmpcellpadding;
6554 $shy_width = $tmp_shy_replacement_width;
6556 $shy_char_left = $tmp_shy_replacement_char;
6557 $shy_char_right =
'';
6559 $shy_char_left =
'';
6560 $shy_char_right = $tmp_shy_replacement_char;
6564 $shy_char_left =
'';
6565 $shy_char_right =
'';
6570 $tmparr = array_slice($chars, $j, (($sep + $endspace) - $j));
6572 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6577 $this->endlinex = $startx - $linew - $shy_width;
6579 $this->endlinex = $startx + $linew + $shy_width;
6591 $this->
Cell(
$w,
$h, $shy_char_left.$tmpstr.$shy_char_right, 0, 1, $align, $fill, $link, $stretch);
6594 if ($chars[$sep] == 45) {
6598 $this->cell_padding = $tmpcellpadding;
6608 if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND ($this->
inPageBody())) {
6611 $this->x -= $margin[
'R'];
6613 $this->x += $margin[
'L'];
6615 $this->lMargin += $margin[
'L'];
6616 $this->rMargin += $margin[
'R'];
6619 $wmax =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
6664 $tmparr = array_slice($chars, $j, ($nb - $j));
6666 $tmparr =
TCPDF_FONTS::utf8Bidi($tmparr, $tmpstr, $this->tmprtl, $this->isunicode, $this->CurrentFont);
6671 $this->endlinex = $startx - $linew;
6673 $this->endlinex = $startx + $linew;
6684 $this->
Cell(
$w,
$h, $tmpstr, 0, $ln, $align, $fill, $link, $stretch);
6687 $this->cell_padding = $tmpcellpadding;
6706 return ($this->x - $this->lMargin);
6708 return ($this->w - $this->rMargin - $this->x);
6739 if ($fitonpage OR $this->AutoPageBreak) {
6740 $ratio_wh = (
$w /
$h);
6741 if (
$h > ($this->PageBreakTrigger - $this->tMargin)) {
6743 $w = (
$h * $ratio_wh);
6750 $h = (
$w / $ratio_wh);
6762 $x += ($this->x - $prev_x);
6764 $this->newline =
true;
6772 $ratio_wh = (
$w /
$h);
6780 $h = $this->PageBreakTrigger -
$y;
6781 $w = (
$h * $ratio_wh);
6783 if ((!$this->rtl) AND ((
$x +
$w) > ($this->w - $this->rMargin))) {
6784 $w = $this->w - $this->rMargin -
$x;
6785 $h = (
$w / $ratio_wh);
6786 } elseif (($this->rtl) AND ((
$x -
$w) < ($this->lMargin))) {
6788 $h = (
$w / $ratio_wh);
6828 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()) {
6829 if ($this->state != 2) {
6832 if (strcmp(
$x,
'') === 0) {
6835 if (strcmp(
$y,
'') === 0) {
6843 if (
$file[0] ===
'@') {
6847 if (
$file[0] ===
'*') {
6853 if (!@file_exists(
$file)) {
6855 $tfile = str_replace(
' ',
'%20',
$file);
6856 if (@file_exists($tfile)) {
6860 if (($imsize = @getimagesize(
$file)) === FALSE) {
6861 if (in_array(
$file, $this->imagekeys)) {
6865 } elseif (strpos(
$file,
'__tcpdf_'.$this->file_id.
'_img') === FALSE) {
6872 $original_file =
$file;
6876 $this->
Error(
'Unable to write file: '.
$file);
6881 $imsize = @getimagesize(
$file);
6882 if ($imsize === FALSE) {
6884 $file = $original_file;
6887 if ($imsize === FALSE) {
6888 if ((
$w > 0) AND (
$h > 0)) {
6892 $imsize =
array($pw, $ph);
6894 $this->
Error(
'[Image] Unable to get the size of the image: '.
$file);
6898 $filehash = md5(
$file);
6900 list($pixw, $pixh) = $imsize;
6902 if ((
$w <= 0) AND (
$h <= 0)) {
6906 } elseif (
$w <= 0) {
6907 $w =
$h * $pixw / $pixh;
6908 } elseif (
$h <= 0) {
6909 $h =
$w * $pixh / $pixw;
6910 } elseif (($fitbox !==
false) AND (
$w > 0) AND (
$h > 0)) {
6911 if (strlen($fitbox) !== 2) {
6916 if (((
$w * $pixh) / (
$h * $pixw)) < 1) {
6920 $h =
$w * $pixh / $pixw;
6922 $hdiff = ($oldh -
$h);
6924 switch (strtoupper($fitbox[1])) {
6941 $w =
$h * $pixw / $pixh;
6943 $wdiff = ($oldw -
$w);
6945 switch (strtoupper($fitbox[0])) {
6972 $neww = round(
$w * $this->k *
$dpi / $this->dpi);
6973 $newh = round(
$h * $this->k *
$dpi / $this->dpi);
6975 $newsize = ($neww * $newh);
6976 $pixsize = ($pixw * $pixh);
6977 if (intval($resize) == 2) {
6979 } elseif ($newsize >= $pixsize) {
6984 if (in_array(
$file, $this->imagekeys)) {
6988 if (strpos(
$file,
'__tcpdf_'.$this->file_id.
'_imgmask_') === FALSE) {
6991 if ((($oldsize < $newsize) AND ($resize)) OR (($oldsize < $pixsize) AND (!$resize))) {
6995 } elseif (($ismask ===
false) AND ($imgmask ===
false) AND (strpos(
$file,
'__tcpdf_'.$this->file_id.
'_imgmask_') === FALSE)) {
6997 $tempfile_plain =
K_PATH_CACHE.
'__tcpdf_'.$this->file_id.
'_imgmask_plain_'.$filehash;
6999 $tempfile_alpha =
K_PATH_CACHE.
'__tcpdf_'.$this->file_id.
'_imgmask_alpha_'.$filehash;
7001 if (in_array($tempfile_plain, $this->imagekeys)) {
7006 if ((($oldsize < $newsize) AND ($resize)) OR (($oldsize < $pixsize) AND (!$resize))) {
7011 $imgmask = $this->
Image($tempfile_alpha,
$x,
$y,
$w,
$h,
'PNG',
'',
'', $resize,
$dpi,
'',
true,
false);
7013 return $this->
Image($tempfile_plain,
$x,
$y,
$w,
$h, $type, $link, $align, $resize,
$dpi, $palign,
false, $imgmask);
7019 $type = strtolower($type);
7022 } elseif ($type ==
'jpg') {
7028 $mtd =
'_parse'.$type;
7030 $gdfunction =
'imagecreatefrom'.$type;
7032 if ((method_exists(
'TCPDF_IMAGES', $mtd)) AND (!($resize AND (function_exists($gdfunction) OR extension_loaded(
'imagick'))))) {
7035 if (($ismask ===
false) AND ($imgmask ===
false) AND (strpos(
$file,
'__tcpdf_'.$this->file_id.
'_imgmask_') === FALSE)
7036 AND ((
$info ===
'pngalpha') OR (isset(
$info[
'trns']) AND !empty(
$info[
'trns'])))) {
7037 return $this->
ImagePngAlpha(
$file,
$x,
$y, $pixw, $pixh,
$w,
$h,
'PNG', $link, $align, $resize,
$dpi, $palign, $filehash);
7040 if ((
$info ===
false) AND function_exists($gdfunction)) {
7044 if (
$img !==
false) {
7046 $imgr = imagecreatetruecolor($neww, $newh);
7047 if (($type ==
'gif') OR ($type ==
'png')) {
7050 imagecopyresampled($imgr,
$img, 0, 0, 0, 0, $neww, $newh, $pixw, $pixh);
7053 if (($type ==
'gif') OR ($type ==
'png')) {
7063 if ((
$info ===
false) AND extension_loaded(
'imagick')) {
7066 $img =
new Imagick();
7067 if ($type ==
'svg') {
7068 if (
$file[0] ===
'@') {
7070 $svgimg = substr(
$file, 1);
7075 if ($svgimg !== FALSE) {
7078 if (preg_match(
'/<svg([^>]*)>/si', $svgimg, $regs)) {
7081 if (preg_match(
'/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
7083 $owu = sprintf(
'%F', ($ow *
$dpi / 72)).$this->pdfunit;
7084 $svgtag = preg_replace(
'/[\s]+width[\s]*=[\s]*"[^"]*"/si',
' width="'.$owu.
'"', $svgtag, 1);
7089 if (preg_match(
'/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
7091 $ohu = sprintf(
'%F', ($oh *
$dpi / 72)).$this->pdfunit;
7092 $svgtag = preg_replace(
'/[\s]+height[\s]*=[\s]*"[^"]*"/si',
' height="'.$ohu.
'"', $svgtag, 1);
7097 if (!preg_match(
'/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $svgtag, $tmp)) {
7098 $vbw = ($ow * $this->imgscale *
$this->k);
7099 $vbh = ($oh * $this->imgscale *
$this->k);
7100 $vbox = sprintf(
' viewBox="0 0 %F %F" ', $vbw, $vbh);
7101 $svgtag = $vbox.$svgtag;
7103 $svgimg = preg_replace(
'/<svg([^>]*)>/si',
'<svg'.$svgtag.
'>', $svgimg, 1);
7105 $img->readImageBlob($svgimg);
7111 $img->resizeImage($neww, $newh, 10, 1,
false);
7113 $img->setCompressionQuality($this->jpeg_quality);
7114 $img->setImageFormat(
'jpeg');
7116 $img->writeImage($tempname);
7124 if (
$info ===
false) {
7131 $info[
'cs'] =
'DeviceGray';
7133 if ($imgmask !==
false) {
7134 $info[
'masked'] = $imgmask;
7136 if (!empty($exurl)) {
7137 $info[
'exurl'] = $exurl;
7140 $info[
'altimgs'] = $altimgs;
7145 $this->img_rb_y =
$y +
$h;
7148 if ($palign ==
'L') {
7150 } elseif ($palign ==
'C') {
7151 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
7152 } elseif ($palign ==
'R') {
7153 $ximg = $this->w - $this->rMargin -
$w;
7157 $this->img_rb_x = $ximg;
7159 if ($palign ==
'L') {
7161 } elseif ($palign ==
'C') {
7162 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
7163 } elseif ($palign ==
'R') {
7164 $ximg = $this->w - $this->rMargin -
$w;
7168 $this->img_rb_x = $ximg +
$w;
7170 if ($ismask OR $hidden) {
7177 $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']));
7192 $this->
Link($ximg,
$y,
$w, $h, $link, 0);
7202 $this->y =
$y + round($h/2);
7212 $this->
SetY($this->img_rb_y);
7220 if ($this->inxobj) {
7248 protected function ImagePngAlpha(
$file,
$x,
$y, $wpx, $hpx,
$w,
$h, $type, $link, $align, $resize,
$dpi, $palign, $filehash=
'') {
7250 if (empty($filehash)) {
7251 $filehash = md5(
$file);
7254 $tempfile_plain =
K_PATH_CACHE.
'__tcpdf_'.$this->file_id.
'_imgmask_plain_'.$filehash;
7256 $tempfile_alpha =
K_PATH_CACHE.
'__tcpdf_'.$this->file_id.
'_imgmask_alpha_'.$filehash;
7260 if (($parsed ===
false) AND extension_loaded(
'imagick')) {
7263 $img =
new Imagick();
7268 if (method_exists(
$img,
'setImageAlphaChannel') AND
defined(
'Imagick::ALPHACHANNEL_EXTRACT')) {
7269 $img->setImageAlphaChannel(Imagick::ALPHACHANNEL_EXTRACT);
7271 $img->separateImageChannel(8);
7272 $img->negateImage(
true);
7274 $img->setImageFormat(
'png');
7275 $img->writeImage($tempfile_alpha);
7277 if (method_exists($imga,
'setImageMatte')) {
7278 $imga->setImageMatte(
false);
7280 $imga->separateImageChannel(39);
7282 $imga->setImageFormat(
'png');
7283 $imga->writeImage($tempfile_plain);
7287 $parse_error =
'Imagick library error: '.$e->getMessage();
7291 if (($parsed ===
false) AND function_exists(
'imagecreatefrompng')) {
7295 $imgalpha = imagecreate($wpx, $hpx);
7297 for ($c = 0; $c < 256; ++$c) {
7298 ImageColorAllocate($imgalpha, $c, $c, $c);
7301 for ($xpx = 0; $xpx < $wpx; ++$xpx) {
7302 for ($ypx = 0; $ypx < $hpx; ++$ypx) {
7303 $color = imagecolorat(
$img, $xpx, $ypx);
7306 imagesetpixel($imgalpha, $xpx, $ypx,
$alpha);
7309 imagepng($imgalpha, $tempfile_alpha);
7310 imagedestroy($imgalpha);
7312 $imgplain = imagecreatetruecolor($wpx, $hpx);
7313 imagecopy($imgplain,
$img, 0, 0, 0, 0, $wpx, $hpx);
7314 imagepng($imgplain, $tempfile_plain);
7315 imagedestroy($imgplain);
7319 $parse_error =
'GD library error: '.$e->getMessage();
7322 if ($parsed ===
false) {
7323 if (empty($parse_error)) {
7324 $this->
Error(
'TCPDF requires the Imagick or GD extension to handle PNG images with alpha channel.');
7326 $this->
Error($parse_error);
7330 $imgmask = $this->
Image($tempfile_alpha,
$x,
$y,
$w,
$h,
'PNG',
'',
'', $resize,
$dpi,
'',
true,
false);
7332 $this->
Image($tempfile_plain,
$x,
$y,
$w,
$h, $type, $link, $align, $resize,
$dpi, $palign,
false, $imgmask);
7343 if (!isset($this->gdgammacache[
'#'.$c])) {
7344 $colors = imagecolorsforindex(
$img, $c);
7346 $this->gdgammacache[
'#'.$c] = (((127 - $colors[
'alpha']) / 127) * 255);
7348 $this->gdgammacache[
'#'.$c] = (pow(($this->gdgammacache[
'#'.$c] / 255), 2.2) * 255);
7350 if (count($this->gdgammacache) > 8) {
7352 array_shift($this->gdgammacache);
7355 return $this->gdgammacache[
'#'.$c];
7367 public function Ln(
$h=
'', $cell=
false) {
7368 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'])) {
7374 $cellpadding = $this->cell_padding[
'R'];
7376 $cellpadding = $this->cell_padding[
'L'];
7382 $this->x = $this->w - $this->rMargin - $cellpadding;
7384 $this->x = $this->lMargin + $cellpadding;
7386 if (is_string(
$h)) {
7390 $this->newline =
true;
7404 return ($this->w - $this->x);
7443 if (!$rtloff AND $this->rtl) {
7445 $this->x = $this->w -
$x;
7453 $this->x = $this->w +
$x;
7459 if ($this->x > $this->w) {
7474 public function SetY(
$y, $resetx=
true, $rtloff=
false) {
7478 if (!$rtloff AND $this->rtl) {
7487 $this->y = $this->h +
$y;
7492 if ($this->y > $this->h) {
7508 $this->
SetY(
$y,
false, $rtloff);
7509 $this->
SetX(
$x, $rtloff);
7520 $this->x = floatval(
$x);
7531 $this->y = floatval(
$y);
7558 public function Output($name=
'doc.pdf', $dest=
'I') {
7561 if ($this->state < 3) {
7565 if (is_bool($dest)) {
7566 $dest = $dest ?
'D' :
'F';
7568 $dest = strtoupper($dest);
7569 if ($dest[0] !=
'F') {
7570 $name = preg_replace(
'/[\s]+/',
'_', $name);
7571 $name = preg_replace(
'/[^a-zA-Z0-9_\.-]/',
'', $name);
7578 $pdfdoc = substr($pdfdoc, 0, -1);
7582 $byte_range =
array();
7585 $byte_range[2] = $byte_range[1] + $this->signature_max_length + 2;
7586 $byte_range[3] = strlen($pdfdoc) - $byte_range[2];
7587 $pdfdoc = substr($pdfdoc, 0, $byte_range[1]).substr($pdfdoc, $byte_range[2]);
7589 $byterange = sprintf(
'/ByteRange[0 %u %u %u]', $byte_range[1], $byte_range[2], $byte_range[3]);
7590 $byterange .= str_repeat(
' ', ($byterange_string_len - strlen($byterange)));
7596 $this->
Error(
'Unable to create temporary file: '.$tempdoc);
7598 $pdfdoc_length = strlen($pdfdoc);
7599 fwrite($f, $pdfdoc, $pdfdoc_length);
7603 if (empty($this->signature_data[
'extracerts'])) {
7604 openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data[
'signcert'],
array($this->signature_data[
'privkey'], $this->signature_data[
'password']),
array(), PKCS7_BINARY | PKCS7_DETACHED);
7606 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']);
7609 $signature = file_get_contents($tempsign);
7611 $signature = substr($signature, $pdfdoc_length);
7612 $signature = substr($signature, (strpos($signature,
"%%EOF\n\n------") + 13));
7613 $tmparr = explode(
"\n\n", $signature);
7614 $signature = $tmparr[1];
7616 $signature = base64_decode(trim($signature));
7618 $signature = $this->
applyTSA($signature);
7620 $signature = current(unpack(
'H*', $signature));
7621 $signature = str_pad($signature, $this->signature_max_length,
'0');
7623 $this->buffer = substr($pdfdoc, 0, $byte_range[1]).
'<'.$signature.
'>'.substr($pdfdoc, $byte_range[1]);
7624 $this->bufferlen = strlen($this->buffer);
7629 if (ob_get_contents()) {
7630 $this->
Error(
'Some data has already been output, can\'t send PDF file');
7632 if (php_sapi_name() !=
'cli') {
7634 header(
'Content-Type: application/pdf');
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');
7643 header(
'Content-Disposition: inline; filename="'.basename($name).
'"');
7652 if (ob_get_contents()) {
7653 $this->
Error(
'Some data has already been output, can\'t send PDF file');
7655 header(
'Content-Description: File Transfer');
7656 if (headers_sent()) {
7657 $this->
Error(
'Some data has already been output to browser, can\'t send PDF file');
7659 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7661 header(
'Pragma: public');
7662 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7663 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7665 if (strpos(php_sapi_name(),
'cgi') ===
false) {
7666 header(
'Content-Type: application/force-download');
7667 header(
'Content-Type: application/octet-stream',
false);
7668 header(
'Content-Type: application/download',
false);
7669 header(
'Content-Type: application/pdf',
false);
7671 header(
'Content-Type: application/pdf');
7674 header(
'Content-Disposition: attachment; filename="'.basename($name).
'"');
7675 header(
'Content-Transfer-Encoding: binary');
7685 $this->
Error(
'Unable to create output file: '.$name);
7687 fwrite($f, $this->
getBuffer(), $this->bufferlen);
7689 if ($dest ==
'FI') {
7691 header(
'Content-Type: application/pdf');
7692 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7694 header(
'Pragma: public');
7695 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7696 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7697 header(
'Content-Disposition: inline; filename="'.basename($name).
'"');
7699 } elseif ($dest ==
'FD') {
7701 if (ob_get_contents()) {
7702 $this->
Error(
'Some data has already been output, can\'t send PDF file');
7704 header(
'Content-Description: File Transfer');
7705 if (headers_sent()) {
7706 $this->
Error(
'Some data has already been output to browser, can\'t send PDF file');
7708 header(
'Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
7709 header(
'Pragma: public');
7710 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7711 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7713 if (strpos(php_sapi_name(),
'cgi') ===
false) {
7714 header(
'Content-Type: application/force-download');
7715 header(
'Content-Type: application/octet-stream',
false);
7716 header(
'Content-Type: application/download',
false);
7717 header(
'Content-Type: application/pdf',
false);
7719 header(
'Content-Type: application/pdf');
7722 header(
'Content-Disposition: attachment; filename="'.basename($name).
'"');
7723 header(
'Content-Transfer-Encoding: binary');
7730 $retval =
'Content-Type: application/pdf;'.
"\r\n";
7731 $retval .=
' name="'.$name.
'"'.
"\r\n";
7732 $retval .=
'Content-Transfer-Encoding: base64'.
"\r\n";
7733 $retval .=
'Content-Disposition: attachment;'.
"\r\n";
7734 $retval .=
' filename="'.$name.
'"'.
"\r\n\r\n";
7735 $retval .= chunk_split(base64_encode($this->
getBuffer()), 76,
"\r\n");
7743 $this->
Error(
'Incorrect output destination: '.$dest);
7756 public function _destroy($destroyall=
false, $preserve_objcopy=
false) {
7757 if ($destroyall AND !$preserve_objcopy) {
7759 $tmpfiles = glob(
K_PATH_CACHE.
'__tcpdf_'.$this->file_id.
'_*');
7760 if (!empty($tmpfiles)) {
7761 array_map(
'unlink', $tmpfiles);
7766 'internal_encoding',
7773 'signature_max_length',
7778 foreach (array_keys(get_object_vars($this)) as $val) {
7779 if ($destroyall OR !in_array($val, $preserve)) {
7780 if ((!$preserve_objcopy OR ($val !=
'objcopy')) AND ($val !=
'file_id') AND isset($this->$val)) {
7794 $this->
Error(
'Don\'t alter the locale before including class file');
7797 if (sprintf(
'%.1F', 1.0) !=
'1.0') {
7798 setlocale(LC_NUMERIC,
'C');
7814 if ($this->isunicode) {
7832 foreach($basic_alias as
$k => $a) {
7848 foreach ($aliases as $type => $alias) {
7849 foreach ($alias as $a) {
7851 $startnum = (strpos($a,
':') + 1);
7852 $a = substr($a, 0, $startnum);
7853 if (($pos = strpos(
$page, $a)) !==
false) {
7855 $endnum = strpos(
$page,
'}', $pos);
7857 $aa = substr(
$page, $pos, ($endnum - $pos + 1));
7859 $ratio = substr(
$page, ($pos + $startnum), ($endnum - $pos - $startnum));
7860 $ratio = preg_replace(
'/[^0-9\.]/',
'', $ratio);
7861 $ratio = floatval($ratio);
7863 $chrdiff = floor(($diff + 12) * $ratio);
7864 $shift = str_repeat(
' ', $chrdiff);
7867 $chrdiff = floor(($diff + 11) * $ratio);
7868 $shift = str_repeat(
' ', $chrdiff);
7883 $this->page_boxes =
array();
7884 foreach ($boxes as $box) {
7886 $this->page_boxes[] = $box;
7908 for (
$n = 1;
$n <= $num_pages; ++
$n) {
7918 if (!empty($this->pagegroups)) {
7919 if (isset($this->newpagegroup[
$n])) {
7932 $replace[] =
array($ptgu, $ptg_num_chars, 9, $pnalias[2][
'u']);
7933 $replace[] =
array($ptga, $ptg_num_chars, 7, $pnalias[2][
'a']);
7934 $replace[] =
array($pngu, $png_num_chars, 9, $pnalias[3][
'u']);
7935 $replace[] =
array($pnga, $png_num_chars, 7, $pnalias[3][
'a']);
7940 $replace[] =
array($ptpu, $ptp_num_chars, 9, $pnalias[0][
'u']);
7941 $replace[] =
array($ptpa, $ptp_num_chars, 7, $pnalias[0][
'a']);
7942 $replace[] =
array($pnpu, $pnp_num_chars, 9, $pnalias[1][
'u']);
7943 $replace[] =
array($pnpa, $pnp_num_chars, 7, $pnalias[1][
'a']);
7948 $temppage = str_replace($this->epsmarker,
'', $temppage);
7950 $this->page_obj_id[
$n] = $this->
_newobj();
7952 $out .=
' /Type /Page';
7953 $out .=
' /Parent 1 0 R';
7954 if (empty($this->signature_data[
'approval']) OR ($this->signature_data[
'approval'] !=
'A')) {
7955 $out .=
' /LastModified '.$this->_datestring(0, $this->doc_modification_timestamp);
7957 $out .=
' /Resources 2 0 R';
7958 foreach ($this->page_boxes as $box) {
7960 $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']);
7962 if (isset($this->pagedim[
$n][
'BoxColorInfo']) AND !empty($this->pagedim[$n][
'BoxColorInfo'])) {
7963 $out .=
' /BoxColorInfo <<';
7964 foreach ($this->page_boxes as $box) {
7965 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box])) {
7966 $out .=
' /'.$box.
' <<';
7967 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'C'])) {
7968 $color = $this->pagedim[
$n][
'BoxColorInfo'][$box][
'C'];
7970 $out .= sprintf(
' %F %F %F', ($color[0] / 255), ($color[1] / 255), ($color[2] / 255));
7973 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'W'])) {
7974 $out .=
' /W '.($this->pagedim[
$n][
'BoxColorInfo'][$box][
'W'] *
$this->k);
7976 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'S'])) {
7977 $out .=
' /S /'.$this->pagedim[
$n][
'BoxColorInfo'][$box][
'S'];
7979 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'D'])) {
7980 $dashes = $this->pagedim[
$n][
'BoxColorInfo'][$box][
'D'];
7982 foreach ($dashes as $dash) {
7983 $out .= sprintf(
' %F', ($dash * $this->k));
7992 $out .=
' /Contents '.($this->n + 1).
' 0 R';
7993 $out .=
' /Rotate '.$this->pagedim[
$n][
'Rotate'];
7994 if (!$this->pdfa_mode) {
7995 $out .=
' /Group << /Type /Group /S /Transparency /CS /DeviceRGB >>';
7997 if (isset($this->pagedim[$n][
'trans']) AND !empty($this->pagedim[$n][
'trans'])) {
7999 if (isset($this->pagedim[$n][
'trans'][
'Dur'])) {
8000 $out .=
' /Dur '.$this->pagedim[
$n][
'trans'][
'Dur'];
8002 $out .=
' /Trans <<';
8003 $out .=
' /Type /Trans';
8004 if (isset($this->pagedim[$n][
'trans'][
'S'])) {
8005 $out .=
' /S /'.$this->pagedim[
$n][
'trans'][
'S'];
8007 if (isset($this->pagedim[$n][
'trans'][
'D'])) {
8008 $out .=
' /D '.$this->pagedim[
$n][
'trans'][
'D'];
8010 if (isset($this->pagedim[$n][
'trans'][
'Dm'])) {
8011 $out .=
' /Dm /'.$this->pagedim[
$n][
'trans'][
'Dm'];
8013 if (isset($this->pagedim[$n][
'trans'][
'M'])) {
8014 $out .=
' /M /'.$this->pagedim[
$n][
'trans'][
'M'];
8016 if (isset($this->pagedim[$n][
'trans'][
'Di'])) {
8017 $out .=
' /Di '.$this->pagedim[
$n][
'trans'][
'Di'];
8019 if (isset($this->pagedim[$n][
'trans'][
'SS'])) {
8020 $out .=
' /SS '.$this->pagedim[
$n][
'trans'][
'SS'];
8022 if (isset($this->pagedim[$n][
'trans'][
'B'])) {
8023 $out .=
' /B '.$this->pagedim[
$n][
'trans'][
'B'];
8028 $out .=
' /PZ '.$this->pagedim[
$n][
'PZ'];
8030 $out .=
"\n".
'endobj';
8036 $this->
_out(
'<<'.$filter.
'/Length '.strlen($p).
'>> stream'.
"\n".$p.
"\n".
'endstream'.
"\n".
'endobj');
8040 $out .=
'<< /Type /Pages /Kids [';
8041 foreach($this->page_obj_id as $page_obj) {
8042 $out .=
' '.$page_obj.
' 0 R';
8044 $out .=
' ] /Count '.$num_pages.
' >>';
8045 $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).
'>>';
8385 $parsedUrl = parse_url($pl[
'txt']);
8386 if (empty($parsedUrl[
'scheme']) AND (strtolower(substr($parsedUrl[
'path'], -4)) ==
'.pdf')) {
8389 if (!empty($parsedUrl[
'fragment'])) {
8391 $tmp = explode(
'=', $parsedUrl[
'fragment']);
8392 $dest =
'('.((count($tmp) == 2) ? $tmp[1] : $tmp[0]).
')';
8394 $annots .=
' /A <</S /GoToR /D '.$dest.
' /F '.$this->
_datastring($this->
unhtmlentities($parsedUrl[
'path']), $annot_obj_id).
' /NewWindow true>>';
8397 $annots .=
' /A <</S /URI /URI '.$this->_datastring($this->
unhtmlentities($pl[
'txt']), $annot_obj_id).
'>>';
8400 } elseif (isset($this->links[$pl[
'txt']])) {
8402 $l = $this->links[$pl[
'txt']];
8403 if (isset($this->page_obj_id[(
$l[
'p'])])) {
8404 $annots .= sprintf(
' /Dest [%u 0 R /XYZ 0 %F null]', $this->page_obj_id[(
$l[
'p'])], ($this->pagedim[
$l[
'p']][
'h'] - (
$l[
'y'] * $this->k)));
8407 $hmodes =
array(
'N',
'I',
'O',
'P');
8408 if (isset($pl[
'opt'][
'h']) AND in_array($pl[
'opt'][
'h'], $hmodes)) {
8409 $annots .=
' /H /'.$pl[
'opt'][
'h'];
8411 $annots .=
' /H /I';
8418 if (isset($pl[
'opt'][
'da']) AND !empty($pl[
'opt'][
'da'])) {
8419 $annots .=
' /DA ('.$pl[
'opt'][
'da'].
')';
8421 if (isset($pl[
'opt'][
'q']) AND ($pl[
'opt'][
'q'] >= 0) AND ($pl[
'opt'][
'q'] <= 2)) {
8422 $annots .=
' /Q '.intval($pl[
'opt'][
'q']);
8424 if (isset($pl[
'opt'][
'rc'])) {
8425 $annots .=
' /RC '.$this->_textstring($pl[
'opt'][
'rc'], $annot_obj_id);
8427 if (isset($pl[
'opt'][
'ds'])) {
8428 $annots .=
' /DS '.$this->_textstring($pl[
'opt'][
'ds'], $annot_obj_id);
8430 if (isset($pl[
'opt'][
'cl']) AND is_array($pl[
'opt'][
'cl'])) {
8431 $annots .=
' /CL [';
8432 foreach ($pl[
'opt'][
'cl'] as $cl) {
8433 $annots .= sprintf(
'%F ', $cl * $this->k);
8437 $tfit =
array(
'FreeText',
'FreeTextCallout',
'FreeTextTypeWriter');
8438 if (isset($pl[
'opt'][
'it']) AND in_array($pl[
'opt'][
'it'], $tfit)) {
8439 $annots .=
' /IT /'.$pl[
'opt'][
'it'];
8441 if (isset($pl[
'opt'][
'rd']) AND is_array($pl[
'opt'][
'rd'])) {
8445 $b = $pl[
'opt'][
'rd'][3] *
$this->k;
8446 $annots .=
' /RD ['.sprintf(
'%F %F %F %F',
$l,
$r,
$t, $b).
']';
8448 if (isset($pl[
'opt'][
'le']) AND in_array($pl[
'opt'][
'le'], $lineendings)) {
8449 $annots .=
' /LE /'.$pl[
'opt'][
'le'];
8492 case 'fileattachment': {
8493 if ($this->pdfa_mode) {
8497 if (!isset($pl[
'opt'][
'fs'])) {
8501 if (isset($this->embeddedfiles[
$filename][
'f'])) {
8502 $annots .=
' /FS '.$this->embeddedfiles[
$filename][
'f'].
' 0 R';
8503 $iconsapp =
array(
'Graph',
'Paperclip',
'PushPin',
'Tag');
8504 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8505 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8507 $annots .=
' /Name /PushPin';
8510 $this->embeddedfiles[
$filename][
'a'] = $key;
8515 if (!isset($pl[
'opt'][
'fs'])) {
8519 if (isset($this->embeddedfiles[
$filename][
'f'])) {
8522 $annots .=
' /Sound '.$this->embeddedfiles[
$filename][
'f'].
' 0 R';
8523 $iconsapp =
array(
'Speaker',
'Mic');
8524 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8525 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8527 $annots .=
' /Name /Speaker';
8536 $hmode =
array(
'N',
'I',
'O',
'P',
'T');
8537 if (isset($pl[
'opt'][
'h']) AND in_array($pl[
'opt'][
'h'], $hmode)) {
8538 $annots .=
' /H /'.$pl[
'opt'][
'h'];
8540 if (isset($pl[
'opt'][
'mk']) AND (is_array($pl[
'opt'][
'mk'])) AND !empty($pl[
'opt'][
'mk'])) {
8541 $annots .=
' /MK <<';
8542 if (isset($pl[
'opt'][
'mk'][
'r'])) {
8543 $annots .=
' /R '.$pl[
'opt'][
'mk'][
'r'];
8545 if (isset($pl[
'opt'][
'mk'][
'bc']) AND (is_array($pl[
'opt'][
'mk'][
'bc']))) {
8546 $annots .=
' /BC '.TCPDF_COLORS::getColorStringFromArray($pl[
'opt'][
'mk'][
'bc']);
8548 if (isset($pl[
'opt'][
'mk'][
'bg']) AND (is_array($pl[
'opt'][
'mk'][
'bg']))) {
8549 $annots .=
' /BG '.TCPDF_COLORS::getColorStringFromArray($pl[
'opt'][
'mk'][
'bg']);
8551 if (isset($pl[
'opt'][
'mk'][
'ca'])) {
8552 $annots .=
' /CA '.$pl[
'opt'][
'mk'][
'ca'];
8554 if (isset($pl[
'opt'][
'mk'][
'rc'])) {
8555 $annots .=
' /RC '.$pl[
'opt'][
'mk'][
'rc'];
8557 if (isset($pl[
'opt'][
'mk'][
'ac'])) {
8558 $annots .=
' /AC '.$pl[
'opt'][
'mk'][
'ac'];
8560 if (isset($pl[
'opt'][
'mk'][
'i'])) {
8562 if (
$info !==
false) {
8563 $annots .=
' /I '.$info[
'n'].
' 0 R';
8566 if (isset($pl[
'opt'][
'mk'][
'ri'])) {
8568 if (
$info !==
false) {
8569 $annots .=
' /RI '.$info[
'n'].
' 0 R';
8572 if (isset($pl[
'opt'][
'mk'][
'ix'])) {
8574 if (
$info !==
false) {
8575 $annots .=
' /IX '.$info[
'n'].
' 0 R';
8578 if (isset($pl[
'opt'][
'mk'][
'if']) AND (is_array($pl[
'opt'][
'mk'][
'if'])) AND !empty($pl[
'opt'][
'mk'][
'if'])) {
8579 $annots .=
' /IF <<';
8580 $if_sw =
array(
'A',
'B',
'S',
'N');
8581 if (isset($pl[
'opt'][
'mk'][
'if'][
'sw']) AND in_array($pl[
'opt'][
'mk'][
'if'][
'sw'], $if_sw)) {
8582 $annots .=
' /SW /'.$pl[
'opt'][
'mk'][
'if'][
'sw'];
8584 $if_s =
array(
'A',
'P');
8585 if (isset($pl[
'opt'][
'mk'][
'if'][
's']) AND in_array($pl[
'opt'][
'mk'][
'if'][
's'], $if_s)) {
8586 $annots .=
' /S /'.$pl[
'opt'][
'mk'][
'if'][
's'];
8588 if (isset($pl[
'opt'][
'mk'][
'if'][
'a']) AND (is_array($pl[
'opt'][
'mk'][
'if'][
'a'])) AND !empty($pl[
'opt'][
'mk'][
'if'][
'a'])) {
8589 $annots .= sprintf(
' /A [%F %F]', $pl[
'opt'][
'mk'][
'if'][
'a'][0], $pl[
'opt'][
'mk'][
'if'][
'a'][1]);
8591 if (isset($pl[
'opt'][
'mk'][
'if'][
'fb']) AND ($pl[
'opt'][
'mk'][
'if'][
'fb'])) {
8592 $annots .=
' /FB true';
8596 if (isset($pl[
'opt'][
'mk'][
'tp']) AND ($pl[
'opt'][
'mk'][
'tp'] >= 0) AND ($pl[
'opt'][
'mk'][
'tp'] <= 6)) {
8597 $annots .=
' /TP '.intval($pl[
'opt'][
'mk'][
'tp']);
8602 if (isset($this->radiobutton_groups[$n][$pl[
'txt']])) {
8604 $annots .=
' /Parent '.$this->radiobutton_groups[
$n][$pl[
'txt']].
' 0 R';
8606 if (isset($pl[
'opt'][
't']) AND is_string($pl[
'opt'][
't'])) {
8607 $annots .=
' /T '.$this->_datastring($pl[
'opt'][
't'], $annot_obj_id);
8609 if (isset($pl[
'opt'][
'tu']) AND is_string($pl[
'opt'][
'tu'])) {
8610 $annots .=
' /TU '.$this->_datastring($pl[
'opt'][
'tu'], $annot_obj_id);
8612 if (isset($pl[
'opt'][
'tm']) AND is_string($pl[
'opt'][
'tm'])) {
8613 $annots .=
' /TM '.$this->_datastring($pl[
'opt'][
'tm'], $annot_obj_id);
8615 if (isset($pl[
'opt'][
'ff'])) {
8616 if (is_array($pl[
'opt'][
'ff'])) {
8619 foreach($pl[
'opt'][
'ff'] as $val) {
8620 $flag += 1 << ($val - 1);
8623 $flag = intval($pl[
'opt'][
'ff']);
8625 $annots .=
' /Ff '.$flag;
8627 if (isset($pl[
'opt'][
'maxlen'])) {
8628 $annots .=
' /MaxLen '.intval($pl[
'opt'][
'maxlen']);
8630 if (isset($pl[
'opt'][
'v'])) {
8632 if (is_array($pl[
'opt'][
'v'])) {
8633 foreach ($pl[
'opt'][
'v'] AS $optval) {
8634 if (is_float($optval)) {
8635 $optval = sprintf(
'%F', $optval);
8637 $annots .=
' '.$optval;
8640 $annots .=
' '.$this->_textstring($pl[
'opt'][
'v'], $annot_obj_id);
8643 if (isset($pl[
'opt'][
'dv'])) {
8645 if (is_array($pl[
'opt'][
'dv'])) {
8646 foreach ($pl[
'opt'][
'dv'] AS $optval) {
8647 if (is_float($optval)) {
8648 $optval = sprintf(
'%F', $optval);
8650 $annots .=
' '.$optval;
8653 $annots .=
' '.$this->_textstring($pl[
'opt'][
'dv'], $annot_obj_id);
8656 if (isset($pl[
'opt'][
'rv'])) {
8658 if (is_array($pl[
'opt'][
'rv'])) {
8659 foreach ($pl[
'opt'][
'rv'] AS $optval) {
8660 if (is_float($optval)) {
8661 $optval = sprintf(
'%F', $optval);
8663 $annots .=
' '.$optval;
8666 $annots .=
' '.$this->_textstring($pl[
'opt'][
'rv'], $annot_obj_id);
8669 if (isset($pl[
'opt'][
'a']) AND !empty($pl[
'opt'][
'a'])) {
8670 $annots .=
' /A << '.$pl[
'opt'][
'a'].
' >>';
8672 if (isset($pl[
'opt'][
'aa']) AND !empty($pl[
'opt'][
'aa'])) {
8673 $annots .=
' /AA << '.$pl[
'opt'][
'aa'].
' >>';
8675 if (isset($pl[
'opt'][
'da']) AND !empty($pl[
'opt'][
'da'])) {
8676 $annots .=
' /DA ('.$pl[
'opt'][
'da'].
')';
8678 if (isset($pl[
'opt'][
'q']) AND ($pl[
'opt'][
'q'] >= 0) AND ($pl[
'opt'][
'q'] <= 2)) {
8679 $annots .=
' /Q '.intval($pl[
'opt'][
'q']);
8681 if (isset($pl[
'opt'][
'opt']) AND (is_array($pl[
'opt'][
'opt'])) AND !empty($pl[
'opt'][
'opt'])) {
8682 $annots .=
' /Opt [';
8683 foreach($pl[
'opt'][
'opt'] AS $copt) {
8684 if (is_array($copt)) {
8685 $annots .=
' ['.$this->_textstring($copt[0], $annot_obj_id).
' '.$this->
_textstring($copt[1], $annot_obj_id).
']';
8687 $annots .=
' '.$this->_textstring($copt, $annot_obj_id);
8692 if (isset($pl[
'opt'][
'ti'])) {
8693 $annots .=
' /TI '.intval($pl[
'opt'][
'ti']);
8695 if (isset($pl[
'opt'][
'i']) AND (is_array($pl[
'opt'][
'i'])) AND !empty($pl[
'opt'][
'i'])) {
8697 foreach($pl[
'opt'][
'i'] AS $copt) {
8698 $annots .= intval($copt).
' ';
8707 case 'printermark': {
8725 $this->
_out($this->
_getobj($annot_obj_id).
"\n".$annots.
"\n".
'endobj');
8726 if ($formfield AND !isset($this->radiobutton_groups[$n][$pl[
'txt']])) {
8728 $this->form_obj_id[] = $annot_obj_id;
8745 $stream = trim($stream);
8747 $this->xobjects[
'AX'.$this->n] =
array(
'n' => $this->
n);
8749 $out .=
' /Type /XObject';
8750 $out .=
' /Subtype /Form';
8751 $out .=
' /FormType 1';
8752 if ($this->compress) {
8753 $stream = gzcompress($stream);
8754 $out .=
' /Filter /FlateDecode';
8756 $rect = sprintf(
'%F %F',
$w,
$h);
8757 $out .=
' /BBox [0 0 '.$rect.
']';
8758 $out .=
' /Matrix [1 0 0 1 0 0]';
8759 $out .=
' /Resources 2 0 R';
8761 $out .=
' /Length '.strlen($stream);
8763 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
8764 $out .=
"\n".
'endobj';
8776 foreach ($this->diffs as $diff) {
8779 $this->
_out(
'<< /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.
'] >>'.
"\n".
'endobj');
8783 foreach ($this->FontFiles as
$file =>
$info) {
8787 $font = file_get_contents($fontfile);
8788 $compressed = (substr(
$file, -2) ==
'.z');
8789 if ((!$compressed) AND (isset(
$info[
'length2']))) {
8790 $header = (ord($font[0]) == 128);
8793 $font = substr($font, 6);
8795 if (
$header AND (ord($font[
$info[
'length1']]) == 128)) {
8797 $font = substr($font, 0, $info[
'length1']).substr($font, ($info[
'length1'] + 6));
8799 } elseif (
$info[
'subset'] AND ((!$compressed) OR ($compressed AND function_exists(
'gzcompress')))) {
8802 $font = gzuncompress($font);
8805 $subsetchars =
array();
8806 foreach (
$info[
'fontkeys'] as $fontkey) {
8808 $subsetchars += $fontinfo[
'subsetchars'];
8813 $info[
'length1'] = strlen($font);
8816 $font = gzcompress($font);
8822 $out =
'<< /Length '.strlen($stream);
8824 $out .=
' /Filter /FlateDecode';
8826 $out .=
' /Length1 '.$info[
'length1'];
8827 if (isset(
$info[
'length2'])) {
8828 $out .=
' /Length2 '.$info[
'length2'].
' /Length3 0';
8831 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
8832 $out .=
"\n".
'endobj';
8837 foreach ($this->fontkeys as
$k) {
8840 $type = $font[
'type'];
8841 $name = $font[
'name'];
8842 if ($type ==
'core') {
8844 $out = $this->
_getobj($this->font_obj_ids[$k]).
"\n";
8845 $out .=
'<</Type /Font';
8846 $out .=
' /Subtype /Type1';
8847 $out .=
' /BaseFont /'.$name;
8848 $out .=
' /Name /F'.$font[
'i'];
8849 if ((strtolower($name) !=
'symbol') AND (strtolower($name) !=
'zapfdingbats')) {
8850 $out .=
' /Encoding /WinAnsiEncoding';
8852 if ($k ==
'helvetica') {
8854 $this->annotation_fonts[
$k] = $font[
'i'];
8857 $out .=
"\n".
'endobj';
8859 } elseif (($type ==
'Type1') OR ($type ==
'TrueType')) {
8861 $out = $this->
_getobj($this->font_obj_ids[$k]).
"\n";
8862 $out .=
'<</Type /Font';
8863 $out .=
' /Subtype /'.$type;
8864 $out .=
' /BaseFont /'.$name;
8865 $out .=
' /Name /F'.$font[
'i'];
8866 $out .=
' /FirstChar 32 /LastChar 255';
8867 $out .=
' /Widths '.($this->n + 1).
' 0 R';
8868 $out .=
' /FontDescriptor '.($this->n + 2).
' 0 R';
8870 if (isset($font[
'diff'])) {
8871 $out .=
' /Encoding '.($nf + $font[
'diff']).
' 0 R';
8873 $out .=
' /Encoding /WinAnsiEncoding';
8877 $out .=
"\n".
'endobj';
8882 for ($i = 32; $i < 256; ++$i) {
8883 if (isset($font[
'cw'][$i])) {
8884 $s .= $font[
'cw'][$i].
' ';
8886 $s .= $font[
'dw'].
' ';
8890 $s .=
"\n".
'endobj';
8894 $s =
'<</Type /FontDescriptor /FontName /'.$name;
8895 foreach ($font[
'desc'] as $fdk => $fdv) {
8896 if (is_float($fdv)) {
8897 $fdv = sprintf(
'%F', $fdv);
8899 $s .=
' /'.$fdk.
' '.$fdv.
'';
8902 $s .=
' /FontFile'.($type ==
'Type1' ?
'' :
'2').
' '.$this->FontFiles[$font[
'file']][
'n'].
' 0 R';
8905 $s .=
"\n".
'endobj';
8909 $mtd =
'_put'.strtolower($type);
8910 if (!method_exists($this, $mtd)) {
8911 $this->
Error(
'Unsupported font type: '.$type);
8928 if ($font[
'subset']) {
8930 $subtag = sprintf(
'%06u', $font[
'i']);
8931 $subtag = strtr($subtag,
'0123456789',
'ABCDEFGHIJ');
8932 $fontname .= $subtag.
'+';
8934 $fontname .= $font[
'name'];
8937 $out = $this->
_getobj($this->font_obj_ids[$font[
'fontkey']]).
"\n";
8938 $out .=
'<< /Type /Font';
8939 $out .=
' /Subtype /Type0';
8940 $out .=
' /BaseFont /'.$fontname;
8941 $out .=
' /Name /F'.$font[
'i'];
8942 $out .=
' /Encoding /'.$font[
'enc'];
8943 $out .=
' /ToUnicode '.($this->n + 1).
' 0 R';
8944 $out .=
' /DescendantFonts ['.($this->n + 2).
' 0 R]';
8946 $out .=
"\n".
'endobj';
8955 $this->
_out(
'<<'.$filter.
'/Length '.strlen($stream).
'>> stream'.
"\n".$stream.
"\n".
'endstream'.
"\n".
'endobj');
8959 $out =
'<< /Type /Font';
8960 $out .=
' /Subtype /CIDFontType2';
8961 $out .=
' /BaseFont /'.$fontname;
8963 $cidinfo =
'/Registry '.$this->_datastring($font[
'cidinfo'][
'Registry'], $oid);
8964 $cidinfo .=
' /Ordering '.$this->_datastring($font[
'cidinfo'][
'Ordering'], $oid);
8965 $cidinfo .=
' /Supplement '.$font[
'cidinfo'][
'Supplement'];
8966 $out .=
' /CIDSystemInfo << '.$cidinfo.
' >>';
8967 $out .=
' /FontDescriptor '.($this->n + 1).
' 0 R';
8968 $out .=
' /DW '.$font[
'dw'];
8969 $out .=
"\n".TCPDF_FONTS::_putfontwidths($font, 0);
8971 $out .=
"\n".
'/CIDToGIDMap '.($this->
n + 2).
' 0 R';
8974 $out .=
"\n".
'endobj';
8979 $out =
'<< /Type /FontDescriptor';
8980 $out .=
' /FontName /'.$fontname;
8981 foreach ($font[
'desc'] as $key => $value) {
8982 if (is_float($value)) {
8983 $value = sprintf(
'%F', $value);
8985 $out .=
' /'.$key.
' '.$value;
8990 $out .=
' /FontFile2 '.$this->FontFiles[$font[
'file']][
'n'].
' 0 R';
8991 $fontdir = $this->FontFiles[$font[
'file']][
'fontdir'];
8994 $out .=
"\n".
'endobj';
9001 $ctgfile = strtolower($font[
'ctg']);
9005 $this->
Error(
'Font file not found: '.$ctgfile);
9007 $stream = $this->
_getrawstream(file_get_contents($fontfile));
9008 $out =
'<< /Length '.strlen($stream).
'';
9009 if (substr($fontfile, -2) ==
'.z') {
9013 $out .=
' /Filter /FlateDecode';
9016 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
9017 $out .=
"\n".
'endobj';
9032 if (!isset($font[
'cw'][1])) {
9035 if (isset($font[
'cidinfo'][
'uni2cid'])) {
9037 $uni2cid = $font[
'cidinfo'][
'uni2cid'];
9039 foreach ($font[
'cw'] as $uni => $width) {
9040 if (isset($uni2cid[$uni])) {
9041 $cw[($uni2cid[$uni] + $cidoffset)] = $width;
9042 } elseif ($uni < 256) {
9046 $font = array_merge($font,
array(
'cw' => $cw));
9048 $name = $font[
'name'];
9049 $enc = $font[
'enc'];
9051 $longname = $name.
'-'.$enc;
9055 $out = $this->
_getobj($this->font_obj_ids[$font[
'fontkey']]).
"\n";
9056 $out .=
'<</Type /Font';
9057 $out .=
' /Subtype /Type0';
9058 $out .=
' /BaseFont /'.$longname;
9059 $out .=
' /Name /F'.$font[
'i'];
9061 $out .=
' /Encoding /'.$enc;
9063 $out .=
' /DescendantFonts ['.($this->n + 1).
' 0 R]';
9065 $out .=
"\n".
'endobj';
9068 $out =
'<</Type /Font';
9069 $out .=
' /Subtype /CIDFontType0';
9070 $out .=
' /BaseFont /'.$name;
9071 $cidinfo =
'/Registry '.$this->_datastring($font[
'cidinfo'][
'Registry'], $oid);
9072 $cidinfo .=
' /Ordering '.$this->_datastring($font[
'cidinfo'][
'Ordering'], $oid);
9073 $cidinfo .=
' /Supplement '.$font[
'cidinfo'][
'Supplement'];
9074 $out .=
' /CIDSystemInfo <<'.$cidinfo.
'>>';
9075 $out .=
' /FontDescriptor '.($this->n + 1).
' 0 R';
9076 $out .=
' /DW '.$font[
'dw'];
9077 $out .=
"\n".TCPDF_FONTS::_putfontwidths($font, $cidoffset);
9079 $out .=
"\n".
'endobj';
9082 $s =
'<</Type /FontDescriptor /FontName /'.$name;
9083 foreach ($font[
'desc'] as
$k => $v) {
9084 if (
$k !=
'Style') {
9086 $v = sprintf(
'%F', $v);
9088 $s .=
' /'.$k.
' '.$v.
'';
9092 $s .=
"\n".
'endobj';
9102 foreach ($this->imagekeys as
$file) {
9105 if ((!$this->pdfa_mode) AND isset(
$info[
'altimgs']) AND !empty(
$info[
'altimgs'])) {
9108 foreach (
$info[
'altimgs'] as $altimage) {
9109 if (isset($this->xobjects[
'I'.$altimage[0]][
'n'])) {
9110 $out .=
' << /Image '.$this->xobjects[
'I'.$altimage[0]][
'n'].
' 0 R';
9111 $out .=
' /DefaultForPrinting';
9112 if ($altimage[1] ===
true) {
9121 $out .=
"\n".
'endobj';
9126 $this->xobjects[
'I'.$info[
'i']] =
array(
'n' => $oid);
9128 $out =
'<</Type /XObject';
9129 $out .=
' /Subtype /Image';
9130 $out .=
' /Width '.$info[
'w'];
9131 $out .=
' /Height '.$info[
'h'];
9132 if (array_key_exists(
'masked',
$info)) {
9133 $out .=
' /SMask '.($this->n - 1).
' 0 R';
9137 if (isset(
$info[
'icc']) AND (
$info[
'icc'] !==
false)) {
9140 $out .=
' /ColorSpace [/ICCBased '.($this->n + 1).
' 0 R]';
9141 } elseif (
$info[
'cs'] ==
'Indexed') {
9143 $out .=
' /ColorSpace [/Indexed /DeviceRGB '.((strlen(
$info[
'pal']) / 3) - 1).
' '.($this->
n + 1).
' 0 R]';
9146 $out .=
' /ColorSpace /'.$info[
'cs'];
9148 if (
$info[
'cs'] ==
'DeviceCMYK') {
9149 $out .=
' /Decode [1 0 1 0 1 0 1 0]';
9151 $out .=
' /BitsPerComponent '.$info[
'bpc'];
9152 if (isset($altoid) AND ($altoid > 0)) {
9154 $out .=
' /Alternates '.$altoid.
' 0 R';
9156 if (isset(
$info[
'exurl']) AND !empty(
$info[
'exurl'])) {
9158 $out .=
' /Length 0';
9159 $out .=
' /F << /FS /URL /F '.$this->_datastring(
$info[
'exurl'], $oid).
' >>';
9160 if (isset(
$info[
'f'])) {
9161 $out .=
' /FFilter /'.$info[
'f'];
9164 $out .=
' stream'.
"\n".
'endstream';
9166 if (isset(
$info[
'f'])) {
9167 $out .=
' /Filter /'.$info[
'f'];
9169 if (isset(
$info[
'parms'])) {
9170 $out .=
' '.$info[
'parms'];
9172 if (isset(
$info[
'trns']) AND is_array(
$info[
'trns'])) {
9174 $count_info = count(
$info[
'trns']);
9175 if (
$info[
'cs'] ==
'Indexed') {
9176 $maxval =(pow(2,
$info[
'bpc']) - 1);
9177 for ($i = 0; $i < $count_info; ++$i) {
9178 if ((
$info[
'trns'][$i] != 0) AND (
$info[
'trns'][$i] != $maxval)) {
9182 } elseif (empty($trns) AND (
$info[
'trns'][$i] == 0)) {
9184 $trns .= $i.
' '.$i.
' ';
9189 for ($i = 0; $i < $count_info; ++$i) {
9190 if (
$info[
'trns'][$i] == 0) {
9191 $trns .=
$info[
'trns'][$i].
' '.
$info[
'trns'][$i].
' ';
9196 if (!empty($trns)) {
9197 $out .=
' /Mask ['.$trns.
']';
9201 $out .=
' /Length '.strlen($stream).
' >>';
9202 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
9204 $out .=
"\n".
'endobj';
9211 $this->
_out(
'<</N '.
$info[
'ch'].
' /Alternate /'.
$info[
'cs'].
' '.$filter.
'/Length '.strlen($icc).
'>> stream'.
"\n".$icc.
"\n".
'endstream'.
"\n".
'endobj');
9212 } elseif (
$info[
'cs'] ==
'Indexed') {
9217 $this->
_out(
'<<'.$filter.
'/Length '.strlen($pal).
'>> stream'.
"\n".$pal.
"\n".
'endstream'.
"\n".
'endobj');
9230 foreach ($this->xobjects as $key =>
$data) {
9231 if (isset(
$data[
'outdata'])) {
9232 $stream = str_replace($this->epsmarker,
'', trim(
$data[
'outdata']));
9235 $out .=
' /Type /XObject';
9236 $out .=
' /Subtype /Form';
9237 $out .=
' /FormType 1';
9238 if ($this->compress) {
9239 $stream = gzcompress($stream);
9240 $out .=
' /Filter /FlateDecode';
9242 $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));
9243 $out .=
' /Matrix [1 0 0 1 0 0]';
9244 $out .=
' /Resources <<';
9245 $out .=
' /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]';
9246 if (!$this->pdfa_mode) {
9248 if (isset(
$data[
'extgstates']) AND !empty(
$data[
'extgstates'])) {
9249 $out .=
' /ExtGState <<';
9250 foreach (
$data[
'extgstates'] as
$k => $extgstate) {
9251 if (isset($this->extgstates[
$k][
'name'])) {
9252 $out .=
' /'.$this->extgstates[
$k][
'name'];
9256 $out .=
' '.$this->extgstates[
$k][
'n'].
' 0 R';
9260 if (isset(
$data[
'gradients']) AND !empty(
$data[
'gradients'])) {
9263 foreach (
$data[
'gradients'] as $id => $grad) {
9265 $gp .=
' /p'.$id.
' '.$this->gradients[$id][
'pattern'].
' 0 R';
9267 $gs .=
' /Sh'.$id.
' '.$this->gradients[$id][
'id'].
' 0 R';
9269 $out .=
' /Pattern <<'.$gp.
' >>';
9270 $out .=
' /Shading <<'.$gs.
' >>';
9274 if (isset(
$data[
'spot_colors']) AND !empty(
$data[
'spot_colors'])) {
9275 $out .=
' /ColorSpace <<';
9276 foreach (
$data[
'spot_colors'] as $name => $color) {
9277 $out .=
' /CS'.$color[
'i'].
' '.$this->spot_colors[$name][
'n'].
' 0 R';
9282 if (!empty(
$data[
'fonts'])) {
9283 $out .=
' /Font <<';
9284 foreach (
$data[
'fonts'] as $fontkey => $fontid) {
9285 $out .=
' /F'.$fontid.
' '.$this->font_obj_ids[$fontkey].
' 0 R';
9290 if (!empty(
$data[
'images']) OR !empty(
$data[
'xobjects'])) {
9291 $out .=
' /XObject <<';
9292 foreach (
$data[
'images'] as $imgid) {
9293 $out .=
' /I'.$imgid.
' '.$this->xobjects[
'I'.$imgid][
'n'].
' 0 R';
9295 foreach (
$data[
'xobjects'] as $sub_id => $sub_objid) {
9296 $out .=
' /'.$sub_id.
' '.$sub_objid[
'n'].
' 0 R';
9301 if (isset(
$data[
'group']) AND (
$data[
'group'] !==
false)) {
9303 $out .=
' /Group << /Type /Group /S /Transparency';
9304 if (is_array(
$data[
'group'])) {
9305 if (isset(
$data[
'group'][
'CS']) AND !empty(
$data[
'group'][
'CS'])) {
9306 $out .=
' /CS /'.$data[
'group'][
'CS'];
9308 if (isset(
$data[
'group'][
'I'])) {
9309 $out .=
' /I /'.($data[
'group'][
'I']===
true?
'true':
'false');
9311 if (isset(
$data[
'group'][
'K'])) {
9312 $out .=
' /K /'.($data[
'group'][
'K']===
true?
'true':
'false');
9318 $out .=
' /Length '.strlen($stream);
9320 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
9321 $out .=
"\n".
'endobj';
9333 foreach ($this->spot_colors as $name => $color) {
9335 $this->spot_colors[$name][
'n'] =
$this->n;
9336 $out =
'[/Separation /'.str_replace(
' ',
'#20', $name);
9337 $out .=
' /DeviceCMYK <<';
9338 $out .=
' /Range [0 1 0 1 0 1 0 1] /C0 [0 0 0 0]';
9339 $out .=
' '.sprintf(
'/C1 [%F %F %F %F] ', ($color[
'C'] / 100), ($color[
'M'] / 100), ($color[
'Y'] / 100), ($color[
'K'] / 100));
9340 $out .=
' /FunctionType 2 /Domain [0 1] /N 1>>]';
9341 $out .=
"\n".
'endobj';
9354 foreach ($this->xobjects as $id => $objid) {
9355 $out .=
' /'.$id.
' '.$objid[
'n'].
' 0 R';
9366 $out .=
'<< /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]';
9367 $out .=
' /Font <<';
9368 foreach ($this->fontkeys as $fontkey) {
9370 $out .=
' /F'.$font[
'i'].
' '.$font[
'n'].
' 0 R';
9373 $out .=
' /XObject <<';
9377 if (!empty($this->pdflayers)) {
9378 $out .=
' /Properties <<';
9379 foreach ($this->pdflayers as $layer) {
9380 $out .=
' /'.$layer[
'layer'].
' '.$layer[
'objid'].
' 0 R';
9384 if (!$this->pdfa_mode) {
9386 if (isset($this->extgstates) AND !empty($this->extgstates)) {
9387 $out .=
' /ExtGState <<';
9388 foreach ($this->extgstates as
$k => $extgstate) {
9389 if (isset($extgstate[
'name'])) {
9390 $out .=
' /'.$extgstate[
'name'];
9394 $out .=
' '.$extgstate[
'n'].
' 0 R';
9398 if (isset($this->gradients) AND !empty($this->gradients)) {
9401 foreach ($this->gradients as $id => $grad) {
9403 $gp .=
' /p'.$id.
' '.$grad[
'pattern'].
' 0 R';
9405 $gs .=
' /Sh'.$id.
' '.$grad[
'id'].
' 0 R';
9407 $out .=
' /Pattern <<'.$gp.
' >>';
9408 $out .=
' /Shading <<'.$gs.
' >>';
9412 if (isset($this->spot_colors) AND !empty($this->spot_colors)) {
9413 $out .=
' /ColorSpace <<';
9414 foreach ($this->spot_colors as $color) {
9415 $out .=
' /CS'.$color[
'i'].
' '.$color[
'n'].
' 0 R';
9420 $out .=
"\n".
'endobj';
9456 if ($this->docinfounicode) {
9457 $this->isunicode =
true;
9461 $out .=
' /Title '.$this->_textstring($this->title, $oid);
9465 $out .=
' /Author '.$this->_textstring($this->author, $oid);
9469 $out .=
' /Subject '.$this->_textstring($this->subject, $oid);
9473 $out .=
' /Keywords '.$this->_textstring($this->keywords, $oid);
9477 $out .=
' /Creator '.$this->_textstring($this->creator, $oid);
9480 $this->isunicode = $prev_isunicode;
9484 $out .=
' /CreationDate '.$this->_datestring(0, $this->doc_creation_timestamp);
9486 $out .=
' /ModDate '.$this->_datestring(0, $this->doc_modification_timestamp);
9488 $out .=
' /Trapped /False';
9490 $out .=
"\n".
'endobj';
9503 $this->custom_xmp = $xmp;
9516 $this->isunicode =
true;
9518 $this->encrypted =
false;
9520 $xmp =
'<?xpacket begin="'.TCPDF_FONTS::unichr(0xfeff, $this->isunicode).
'" id="W5M0MpCehiHzreSzNTczkc9d"?>'.
"\n";
9521 $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";
9522 $xmp .=
"\t".
'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">'.
"\n";
9523 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">'.
"\n";
9524 $xmp .=
"\t\t\t".
'<dc:format>application/pdf</dc:format>'.
"\n";
9525 $xmp .=
"\t\t\t".
'<dc:title>'.
"\n";
9526 $xmp .=
"\t\t\t\t".
'<rdf:Alt>'.
"\n";
9528 $xmp .=
"\t\t\t\t".
'</rdf:Alt>'.
"\n";
9529 $xmp .=
"\t\t\t".
'</dc:title>'.
"\n";
9530 $xmp .=
"\t\t\t".
'<dc:creator>'.
"\n";
9531 $xmp .=
"\t\t\t\t".
'<rdf:Seq>'.
"\n";
9533 $xmp .=
"\t\t\t\t".
'</rdf:Seq>'.
"\n";
9534 $xmp .=
"\t\t\t".
'</dc:creator>'.
"\n";
9535 $xmp .=
"\t\t\t".
'<dc:description>'.
"\n";
9536 $xmp .=
"\t\t\t\t".
'<rdf:Alt>'.
"\n";
9538 $xmp .=
"\t\t\t\t".
'</rdf:Alt>'.
"\n";
9539 $xmp .=
"\t\t\t".
'</dc:description>'.
"\n";
9540 $xmp .=
"\t\t\t".
'<dc:subject>'.
"\n";
9541 $xmp .=
"\t\t\t\t".
'<rdf:Bag>'.
"\n";
9543 $xmp .=
"\t\t\t\t".
'</rdf:Bag>'.
"\n";
9544 $xmp .=
"\t\t\t".
'</dc:subject>'.
"\n";
9545 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9548 $doccreationdate = substr($dcdate, 0, 4).
'-'.substr($dcdate, 4, 2).
'-'.substr($dcdate, 6, 2);
9549 $doccreationdate .=
'T'.substr($dcdate, 8, 2).
':'.substr($dcdate, 10, 2).
':'.substr($dcdate, 12, 2);
9550 $doccreationdate .= substr($dcdate, 14, 3).
':'.substr($dcdate, 18, 2);
9554 $docmoddate = substr($dmdate, 0, 4).
'-'.substr($dmdate, 4, 2).
'-'.substr($dmdate, 6, 2);
9555 $docmoddate .=
'T'.substr($dmdate, 8, 2).
':'.substr($dmdate, 10, 2).
':'.substr($dmdate, 12, 2);
9556 $docmoddate .= substr($dmdate, 14, 3).
':'.substr($dmdate, 18, 2);
9558 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">'.
"\n";
9559 $xmp .=
"\t\t\t".
'<xmp:CreateDate>'.$doccreationdate.
'</xmp:CreateDate>'.
"\n";
9560 $xmp .=
"\t\t\t".
'<xmp:CreatorTool>'.$this->creator.
'</xmp:CreatorTool>'.
"\n";
9561 $xmp .=
"\t\t\t".
'<xmp:ModifyDate>'.$docmoddate.
'</xmp:ModifyDate>'.
"\n";
9562 $xmp .=
"\t\t\t".
'<xmp:MetadataDate>'.$doccreationdate.
'</xmp:MetadataDate>'.
"\n";
9563 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9564 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">'.
"\n";
9567 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9568 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">'.
"\n";
9569 $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);
9570 $xmp .=
"\t\t\t".
'<xmpMM:DocumentID>'.$uuid.
'</xmpMM:DocumentID>'.
"\n";
9571 $xmp .=
"\t\t\t".
'<xmpMM:InstanceID>'.$uuid.
'</xmpMM:InstanceID>'.
"\n";
9572 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9573 if ($this->pdfa_mode) {
9574 $xmp .=
"\t\t".
'<rdf:Description rdf:about="" xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/">'.
"\n";
9575 $xmp .=
"\t\t\t".
'<pdfaid:part>1</pdfaid:part>'.
"\n";
9576 $xmp .=
"\t\t\t".
'<pdfaid:conformance>B</pdfaid:conformance>'.
"\n";
9577 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9580 $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";
9581 $xmp .=
"\t\t\t".
'<pdfaExtension:schemas>'.
"\n";
9582 $xmp .=
"\t\t\t\t".
'<rdf:Bag>'.
"\n";
9583 $xmp .=
"\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9584 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:namespaceURI>http://ns.adobe.com/pdf/1.3/</pdfaSchema:namespaceURI>'.
"\n";
9585 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:prefix>pdf</pdfaSchema:prefix>'.
"\n";
9586 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:schema>Adobe PDF Schema</pdfaSchema:schema>'.
"\n";
9587 $xmp .=
"\t\t\t\t\t".
'</rdf:li>'.
"\n";
9588 $xmp .=
"\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9589 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:namespaceURI>http://ns.adobe.com/xap/1.0/mm/</pdfaSchema:namespaceURI>'.
"\n";
9590 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:prefix>xmpMM</pdfaSchema:prefix>'.
"\n";
9591 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:schema>XMP Media Management Schema</pdfaSchema:schema>'.
"\n";
9592 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:property>'.
"\n";
9593 $xmp .=
"\t\t\t\t\t\t\t".
'<rdf:Seq>'.
"\n";
9594 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9595 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9596 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>UUID based identifier for specific incarnation of a document</pdfaProperty:description>'.
"\n";
9597 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>InstanceID</pdfaProperty:name>'.
"\n";
9598 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>URI</pdfaProperty:valueType>'.
"\n";
9599 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9600 $xmp .=
"\t\t\t\t\t\t\t".
'</rdf:Seq>'.
"\n";
9601 $xmp .=
"\t\t\t\t\t\t".
'</pdfaSchema:property>'.
"\n";
9602 $xmp .=
"\t\t\t\t\t".
'</rdf:li>'.
"\n";
9603 $xmp .=
"\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9604 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:namespaceURI>http://www.aiim.org/pdfa/ns/id/</pdfaSchema:namespaceURI>'.
"\n";
9605 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:prefix>pdfaid</pdfaSchema:prefix>'.
"\n";
9606 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:schema>PDF/A ID Schema</pdfaSchema:schema>'.
"\n";
9607 $xmp .=
"\t\t\t\t\t\t".
'<pdfaSchema:property>'.
"\n";
9608 $xmp .=
"\t\t\t\t\t\t\t".
'<rdf:Seq>'.
"\n";
9609 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9610 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9611 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>Part of PDF/A standard</pdfaProperty:description>'.
"\n";
9612 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>part</pdfaProperty:name>'.
"\n";
9613 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>Integer</pdfaProperty:valueType>'.
"\n";
9614 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9615 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9616 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9617 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>Amendment of PDF/A standard</pdfaProperty:description>'.
"\n";
9618 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>amd</pdfaProperty:name>'.
"\n";
9619 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>Text</pdfaProperty:valueType>'.
"\n";
9620 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9621 $xmp .=
"\t\t\t\t\t\t\t\t".
'<rdf:li rdf:parseType="Resource">'.
"\n";
9622 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:category>internal</pdfaProperty:category>'.
"\n";
9623 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:description>Conformance level of PDF/A standard</pdfaProperty:description>'.
"\n";
9624 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:name>conformance</pdfaProperty:name>'.
"\n";
9625 $xmp .=
"\t\t\t\t\t\t\t\t\t".
'<pdfaProperty:valueType>Text</pdfaProperty:valueType>'.
"\n";
9626 $xmp .=
"\t\t\t\t\t\t\t\t".
'</rdf:li>'.
"\n";
9627 $xmp .=
"\t\t\t\t\t\t\t".
'</rdf:Seq>'.
"\n";
9628 $xmp .=
"\t\t\t\t\t\t".
'</pdfaSchema:property>'.
"\n";
9629 $xmp .=
"\t\t\t\t\t".
'</rdf:li>'.
"\n";
9630 $xmp .=
"\t\t\t\t".
'</rdf:Bag>'.
"\n";
9631 $xmp .=
"\t\t\t".
'</pdfaExtension:schemas>'.
"\n";
9632 $xmp .=
"\t\t".
'</rdf:Description>'.
"\n";
9633 $xmp .=
"\t".
'</rdf:RDF>'.
"\n";
9635 $xmp .=
'</x:xmpmeta>'.
"\n";
9636 $xmp .=
'<?xpacket end="w"?>';
9637 $out =
'<< /Type /Metadata /Subtype /XML /Length '.strlen($xmp).
' >> stream'.
"\n".$xmp.
"\n".
'endstream'.
"\n".
'endobj';
9639 $this->isunicode = $prev_isunicode;
9640 $this->encrypted = $prev_encrypted;
9654 if ($this->pdfa_mode OR $this->force_srgb) {
9656 $icc = file_get_contents(dirname(__FILE__).
'/include/sRGB.icc');
9658 if ($this->compress) {
9659 $filter =
' /Filter /FlateDecode';
9660 $icc = gzcompress($icc);
9663 $this->
_out(
'<</N 3 '.$filter.
'/Length '.strlen($icc).
'>> stream'.
"\n".$icc.
"\n".
'endstream'.
"\n".
'endobj');
9667 $out =
'<< /Type /Catalog';
9668 $out .=
' /Version /'.$this->PDFVersion;
9670 $out .=
' /Pages 1 0 R';
9672 $out .=
' /Names <<';
9673 if ((!$this->pdfa_mode) AND !empty($this->n_js)) {
9674 $out .=
' /JavaScript '.$this->n_js;
9676 if (!empty($this->efnames)) {
9677 $out .=
' /EmbeddedFiles <</Names [';
9678 foreach ($this->efnames AS $fn => $fref) {
9679 $out .=
' '.$this->_datastring($fn).
' '.$fref;
9684 if (!empty($this->dests)) {
9685 $out .=
' /Dests '.($this->n_dests).
' 0 R';
9689 $out .=
' /PageLayout /'.$this->LayoutMode;
9692 $out .=
' /PageMode /'.$this->PageMode;
9694 if (count($this->outlines) > 0) {
9695 $out .=
' /Outlines '.$this->OutlineRoot.
' 0 R';
9696 $out .=
' /PageMode /UseOutlines';
9699 if ($this->ZoomMode ==
'fullpage') {
9700 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /Fit]';
9701 } elseif ($this->ZoomMode ==
'fullwidth') {
9702 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /FitH null]';
9703 } elseif ($this->ZoomMode ==
'real') {
9704 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /XYZ null null 1]';
9705 } elseif (!is_string($this->ZoomMode)) {
9706 $out .= sprintf(
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /XYZ null null %F]', ($this->ZoomMode / 100));
9710 $out .=
' /Metadata '.$xmpobj.
' 0 R';
9713 if (isset($this->l[
'a_meta_language'])) {
9714 $out .=
' /Lang '.$this->_textstring($this->l[
'a_meta_language'], $oid);
9718 if ($this->pdfa_mode OR $this->force_srgb) {
9719 $out .=
' /OutputIntents [<<';
9720 $out .=
' /Type /OutputIntent';
9721 $out .=
' /S /GTS_PDFA1';
9722 $out .=
' /OutputCondition '.$this->_textstring(
'sRGB IEC61966-2.1', $oid);
9723 $out .=
' /OutputConditionIdentifier '.$this->_textstring(
'sRGB IEC61966-2.1', $oid);
9724 $out .=
' /RegistryName '.$this->_textstring(
'http://www.color.org', $oid);
9725 $out .=
' /Info '.$this->_textstring(
'sRGB IEC61966-2.1', $oid);
9726 $out .=
' /DestOutputProfile '.$iccobj.
' 0 R';
9730 if (!empty($this->pdflayers)) {
9734 foreach ($this->pdflayers as $layer) {
9735 $layer_obj_ref =
' '.$layer[
'objid'].
' 0 R';
9736 $lyrobjs .= $layer_obj_ref;
9737 if ($layer[
'view'] ===
false) {
9738 $lyrobjs_off .= $layer_obj_ref;
9740 if ($layer[
'lock']) {
9741 $lyrobjs_lock .= $layer_obj_ref;
9744 $out .=
' /OCProperties << /OCGs ['.$lyrobjs.
']';
9746 $out .=
' /Name '.$this->_textstring(
'Layers', $oid);
9747 $out .=
' /Creator '.$this->_textstring(
'TCPDF', $oid);
9748 $out .=
' /BaseState /ON';
9749 $out .=
' /OFF ['.$lyrobjs_off.
']';
9750 $out .=
' /Locked ['.$lyrobjs_lock.
']';
9751 $out .=
' /Intent /View';
9753 $out .=
' << /Event /Print /OCGs ['.$lyrobjs.
'] /Category [/Print] >>';
9754 $out .=
' << /Event /View /OCGs ['.$lyrobjs.
'] /Category [/View] >>';
9756 $out .=
' /Order ['.$lyrobjs.
']';
9757 $out .=
' /ListMode /AllPages';
9764 if (!empty($this->form_obj_id)
9765 OR ($this->sign AND isset($this->signature_data[
'cert_type']))
9766 OR !empty($this->empty_signature_appearance)) {
9767 $out .=
' /AcroForm <<';
9769 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9771 $objrefs .= $this->sig_obj_id.
' 0 R';
9773 if (!empty($this->empty_signature_appearance)) {
9774 foreach ($this->empty_signature_appearance as $esa) {
9776 $objrefs .=
' '.$esa[
'objid'].
' 0 R';
9779 if (!empty($this->form_obj_id)) {
9780 foreach($this->form_obj_id as $objid) {
9781 $objrefs .=
' '.$objid.
' 0 R';
9784 $out .=
' /Fields ['.$objrefs.
']';
9786 if (empty($this->signature_data[
'approval']) OR ($this->signature_data[
'approval'] !=
'A')) {
9787 $out .=
' /NeedAppearances false';
9789 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9790 if ($this->signature_data[
'cert_type'] > 0) {
9791 $out .=
' /SigFlags 3';
9793 $out .=
' /SigFlags 1';
9797 if (isset($this->annotation_fonts) AND !empty($this->annotation_fonts)) {
9799 $out .=
' /Font <<';
9800 foreach ($this->annotation_fonts as $fontkey => $fontid) {
9801 $out .=
' /F'.$fontid.
' '.$this->font_obj_ids[$fontkey].
' 0 R';
9806 $out .=
' /DA (/F'.$font[
'i'].
' 0 Tf 0 g)';
9807 $out .=
' /Q '.(($this->rtl)?
'2':
'0');
9811 if ($this->sign AND isset($this->signature_data[
'cert_type'])
9812 AND (empty($this->signature_data[
'approval']) OR ($this->signature_data[
'approval'] !=
'A'))) {
9813 if ($this->signature_data[
'cert_type'] > 0) {
9814 $out .=
' /Perms << /DocMDP '.($this->sig_obj_id + 1).
' 0 R >>';
9816 $out .=
' /Perms << /UR3 '.($this->sig_obj_id + 1).
' 0 R >>';
9825 $out .=
"\n".
'endobj';
9839 $out =
' /ViewerPreferences <<';
9841 $out .=
' /Direction /R2L';
9843 $out .=
' /Direction /L2R';
9845 if (isset($vp[
'HideToolbar']) AND ($vp[
'HideToolbar'])) {
9846 $out .=
' /HideToolbar true';
9848 if (isset($vp[
'HideMenubar']) AND ($vp[
'HideMenubar'])) {
9849 $out .=
' /HideMenubar true';
9851 if (isset($vp[
'HideWindowUI']) AND ($vp[
'HideWindowUI'])) {
9852 $out .=
' /HideWindowUI true';
9854 if (isset($vp[
'FitWindow']) AND ($vp[
'FitWindow'])) {
9855 $out .=
' /FitWindow true';
9857 if (isset($vp[
'CenterWindow']) AND ($vp[
'CenterWindow'])) {
9858 $out .=
' /CenterWindow true';
9860 if (isset($vp[
'DisplayDocTitle']) AND ($vp[
'DisplayDocTitle'])) {
9861 $out .=
' /DisplayDocTitle true';
9863 if (isset($vp[
'NonFullScreenPageMode'])) {
9864 $out .=
' /NonFullScreenPageMode /'.$vp[
'NonFullScreenPageMode'];
9866 if (isset($vp[
'ViewArea'])) {
9867 $out .=
' /ViewArea /'.$vp[
'ViewArea'];
9869 if (isset($vp[
'ViewClip'])) {
9870 $out .=
' /ViewClip /'.$vp[
'ViewClip'];
9872 if (isset($vp[
'PrintArea'])) {
9873 $out .=
' /PrintArea /'.$vp[
'PrintArea'];
9875 if (isset($vp[
'PrintClip'])) {
9876 $out .=
' /PrintClip /'.$vp[
'PrintClip'];
9878 if (isset($vp[
'PrintScaling'])) {
9879 $out .=
' /PrintScaling /'.$vp[
'PrintScaling'];
9882 $out .=
' /Duplex /'.$vp[
'Duplex'];
9884 if (isset($vp[
'PickTrayByPDFSize'])) {
9885 if ($vp[
'PickTrayByPDFSize']) {
9886 $out .=
' /PickTrayByPDFSize true';
9888 $out .=
' /PickTrayByPDFSize false';
9891 if (isset($vp[
'PrintPageRange'])) {
9892 $PrintPageRangeNum =
'';
9893 foreach ($vp[
'PrintPageRange'] as
$k => $v) {
9894 $PrintPageRangeNum .=
' '.($v - 1).
'';
9896 $out .=
' /PrintPageRange ['.substr($PrintPageRangeNum,1).
']';
9898 if (isset($vp[
'NumCopies'])) {
9899 $out .=
' /NumCopies '.intval($vp[
'NumCopies']);
9910 $this->
_out(
'%PDF-'.$this->PDFVersion);
9911 $this->
_out(
'%'.chr(0xe2).chr(0xe3).chr(0xcf).chr(0xd3));
9919 if (isset($this->CurrentFont[
'fontkey']) AND isset($this->CurrentFont[
'subsetchars'])) {
9921 $this->
setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
9928 if (!empty($this->empty_signature_appearance)) {
9929 foreach ($this->empty_signature_appearance as $key => $esa) {
9932 $out .=
'<< /Type /Annot';
9933 $out .=
' /Subtype /Widget';
9934 $out .=
' /Rect ['.$esa[
'rect'].
']';
9935 $out .=
' /P '.$this->page_obj_id[($esa[
'page'])].
' 0 R';
9937 $out .=
' /FT /Sig';
9938 $signame = $esa[
'name'].sprintf(
' [%03d]', ($key + 1));
9939 $out .=
' /T '.$this->_textstring($signame, $esa[
'objid']);
9942 $out .=
"\n".
'endobj';
9947 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
9950 $out .=
'<< /Type /Annot';
9951 $out .=
' /Subtype /Widget';
9952 $out .=
' /Rect ['.$this->signature_appearance[
'rect'].
']';
9953 $out .=
' /P '.$this->page_obj_id[($this->signature_appearance[
'page'])].
' 0 R';
9955 $out .=
' /FT /Sig';
9956 $out .=
' /T '.$this->_textstring($this->signature_appearance[
'name'], $this->sig_obj_id);
9958 $out .=
' /V '.($this->sig_obj_id + 1).
' 0 R';
9960 $out .=
"\n".
'endobj';
9972 $this->
_out(
'xref');
9973 $this->
_out(
'0 '.($this->
n + 1));
9974 $this->
_out(
'0000000000 65535 f ');
9975 $freegen = ($this->
n + 2);
9977 if (!isset($this->offsets[$i]) AND ($i > 1)) {
9978 $this->
_out(sprintf(
'0000000000 %05d f ', $freegen));
9981 $this->
_out(sprintf(
'%010d 00000 n ', $this->offsets[$i]));
9985 $out =
'trailer'.
"\n";
9987 $out .=
' /Size '.($this->n + 1);
9988 $out .=
' /Root '.$objid_catalog.
' 0 R';
9989 $out .=
' /Info '.$objid_info.
' 0 R';
9990 if ($this->encrypted) {
9991 $out .=
' /Encrypt '.$this->encryptdata[
'objid'].
' 0 R';
9993 $out .=
' /ID [ <'.$this->file_id.
'> <'.$this->file_id.
'> ]';
9996 $this->
_out(
'startxref');
9998 $this->
_out(
'%%EOF');
10017 if (isset($this->CurOrientation)) {
10019 } elseif ($this->fwPt > $this->fhPt) {
10021 $orientation =
'L';
10024 $orientation =
'P';
10028 $this->pagedim[
$this->page] = $this->pagedim[($this->page - 1)];
10039 if (isset($this->newpagegroup[$this->page])) {
10041 $this->currpagegroup = $this->newpagegroup[
$this->page];
10043 } elseif (isset($this->currpagegroup) AND ($this->currpagegroup > 0)) {
10075 if ($objid ===
'') {
10081 return $objid.
' 0 obj';
10106 return sprintf(
'%F %F %F %F re f',
$x * $this->k, ((($this->h -
$y) * $this->k) + $linew),
$w * $this->k, $linew);
10131 return sprintf(
'%F %F %F %F re f',
$x * $this->k, ((($this->h -
$y) * $this->k) + $linew + ($this->FontSizePt / 3)),
$w * $this->k, $linew);
10157 return sprintf(
'%F %F %F %F re f',
$x * $this->k, (($this->h -
$y + $this->FontAscent) * $this->k) - $linew,
$w * $this->k, $linew);
10183 if (is_string($time)) {
10186 $this->doc_creation_timestamp = intval($time);
10196 if (is_string($time)) {
10199 $this->doc_modification_timestamp = intval($time);
10245 if ($this->isunicode) {
10274 if ($this->state == 2) {
10275 if ($this->inxobj) {
10278 } elseif ((!$this->InFooter) AND isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) {
10281 $page = substr($pagebuff, 0, -$this->footerlen[$this->page]);
10282 $footer = substr($pagebuff, -$this->footerlen[$this->page]);
10285 $this->footerpos[
$this->page] += strlen($s.
"\n");
10290 } elseif ($this->state > 0) {
10303 $this->header_font = $font;
10323 $this->footer_font = $font;
10343 $this->l = $language;
10344 if (isset($this->l[
'a_meta_dir'])) {
10345 $this->rtl = $this->l[
'a_meta_dir']==
'rtl' ? true :
false;
10347 $this->rtl =
false;
10356 if ($this->state < 3) {
10375 if (isset(
$url[1]) AND (
$url[0] ==
'#') AND is_numeric(
$url[1])) {
10377 $lnkdata = explode(
',',
$url);
10378 if (isset($lnkdata[0]) ) {
10379 $page = substr($lnkdata[0], 1);
10380 if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
10381 $lnky = floatval($lnkdata[1]);
10392 if (empty($color)) {
10398 $this->
SetFont(
'', $this->FontStyle.$this->htmlLinkFontStyle);
10400 $this->
SetFont(
'', $this->FontStyle.$style);
10402 $ret = $this->
Write($this->lasth, $name,
$url, $fill,
'',
false, 0, $firstline, $firstblock, 0);
10404 $this->
SetFont(
'', $prevstyle);
10417 return (
$px / ($this->imgscale * $this->k));
10428 return @html_entity_decode($text_to_convert, ENT_QUOTES, $this->encoding);
10443 $objkey = $this->encryptdata[
'key'].pack(
'VXxx',
$n);
10444 if ($this->encryptdata[
'mode'] == 2) {
10446 $objkey .=
"\x73\x41\x6C\x54";
10449 $objkey = substr($objkey, 0, 16);
10463 if (!$this->encrypted) {
10466 switch ($this->encryptdata[
'mode']) {
10491 if (!$this->encrypted) {
10494 $this->encryptdata[
'objid'] = $this->
_newobj();
10496 if (!isset($this->encryptdata[
'Filter']) OR empty($this->encryptdata[
'Filter'])) {
10497 $this->encryptdata[
'Filter'] =
'Standard';
10499 $out .=
' /Filter /'.$this->encryptdata[
'Filter'];
10500 if (isset($this->encryptdata[
'SubFilter']) AND !empty($this->encryptdata[
'SubFilter'])) {
10501 $out .=
' /SubFilter /'.$this->encryptdata[
'SubFilter'];
10503 if (!isset($this->encryptdata[
'V']) OR empty($this->encryptdata[
'V'])) {
10504 $this->encryptdata[
'V'] = 1;
10507 $out .=
' /V '.$this->encryptdata[
'V'];
10508 if (isset($this->encryptdata[
'Length']) AND !empty($this->encryptdata[
'Length'])) {
10510 $out .=
' /Length '.$this->encryptdata[
'Length'];
10512 $out .=
' /Length 40';
10514 if ($this->encryptdata[
'V'] >= 4) {
10515 if (!isset($this->encryptdata[
'StmF']) OR empty($this->encryptdata[
'StmF'])) {
10516 $this->encryptdata[
'StmF'] =
'Identity';
10518 if (!isset($this->encryptdata[
'StrF']) OR empty($this->encryptdata[
'StrF'])) {
10520 $this->encryptdata[
'StrF'] =
'Identity';
10523 if (isset($this->encryptdata[
'CF']) AND !empty($this->encryptdata[
'CF'])) {
10525 $out .=
' /'.$this->encryptdata[
'StmF'].
' <<';
10526 $out .=
' /Type /CryptFilter';
10527 if (isset($this->encryptdata[
'CF'][
'CFM']) AND !empty($this->encryptdata[
'CF'][
'CFM'])) {
10529 $out .=
' /CFM /'.$this->encryptdata[
'CF'][
'CFM'];
10530 if ($this->encryptdata[
'pubkey']) {
10531 $out .=
' /Recipients [';
10532 foreach ($this->encryptdata[
'Recipients'] as $rec) {
10533 $out .=
' <'.$rec.
'>';
10536 if (isset($this->encryptdata[
'CF'][
'EncryptMetadata']) AND (!$this->encryptdata[
'CF'][
'EncryptMetadata'])) {
10537 $out .=
' /EncryptMetadata false';
10539 $out .=
' /EncryptMetadata true';
10543 $out .=
' /CFM /None';
10545 if (isset($this->encryptdata[
'CF'][
'AuthEvent']) AND !empty($this->encryptdata[
'CF'][
'AuthEvent'])) {
10547 $out .=
' /AuthEvent /'.$this->encryptdata[
'CF'][
'AuthEvent'];
10549 $out .=
' /AuthEvent /DocOpen';
10551 if (isset($this->encryptdata[
'CF'][
'Length']) AND !empty($this->encryptdata[
'CF'][
'Length'])) {
10553 $out .=
' /Length '.$this->encryptdata[
'CF'][
'Length'];
10558 $out .=
' /StmF /'.$this->encryptdata[
'StmF'];
10560 $out .=
' /StrF /'.$this->encryptdata[
'StrF'];
10561 if (isset($this->encryptdata[
'EFF']) AND !empty($this->encryptdata[
'EFF'])) {
10563 $out .=
' /EFF /'.$this->encryptdata[
''];
10567 if ($this->encryptdata[
'pubkey']) {
10568 if (($this->encryptdata[
'V'] < 4) AND isset($this->encryptdata[
'Recipients']) AND !empty($this->encryptdata[
'Recipients'])) {
10569 $out .=
' /Recipients [';
10570 foreach ($this->encryptdata[
'Recipients'] as $rec) {
10571 $out .=
' <'.$rec.
'>';
10577 if ($this->encryptdata[
'V'] == 5) {
10579 $out .=
' /OE ('.TCPDF_STATIC::_escape($this->encryptdata[
'OE']).
')';
10580 $out .=
' /UE ('.TCPDF_STATIC::_escape($this->encryptdata[
'UE']).
')';
10581 $out .=
' /Perms ('.TCPDF_STATIC::_escape($this->encryptdata[
'perms']).
')';
10582 } elseif ($this->encryptdata[
'V'] == 4) {
10584 } elseif ($this->encryptdata[
'V'] < 2) {
10589 $out .=
' /O ('.TCPDF_STATIC::_escape($this->encryptdata[
'O']).
')';
10590 $out .=
' /U ('.TCPDF_STATIC::_escape($this->encryptdata[
'U']).
')';
10591 $out .=
' /P '.$this->encryptdata[
'P'];
10592 if (isset($this->encryptdata[
'EncryptMetadata']) AND (!$this->encryptdata[
'EncryptMetadata'])) {
10593 $out .=
' /EncryptMetadata false';
10595 $out .=
' /EncryptMetadata true';
10599 $out .=
"\n".
'endobj';
10611 if ($this->encryptdata[
'mode'] == 0) {
10613 } elseif ($this->encryptdata[
'mode'] < 3) {
10615 $enc =
TCPDF_STATIC::_RC4($this->encryptdata[
'key'], $tmp, $this->last_enc_key, $this->last_enc_key_c);
10616 $len = strlen($tmp);
10617 for ($i = 1; $i <= 19; ++$i) {
10619 for ($j = 0; $j < $len; ++$j) {
10620 $ek .= chr(ord($this->encryptdata[
'key'][$j]) ^ $i);
10624 $enc .= str_repeat(
"\x00", 16);
10625 return substr($enc, 0, 32);
10626 } elseif ($this->encryptdata[
'mode'] == 3) {
10629 $this->encryptdata[
'UVS'] = substr($seed, 0, 8);
10631 $this->encryptdata[
'UKS'] = substr($seed, 8, 16);
10632 return hash(
'sha256', $this->encryptdata[
'user_password'].$this->encryptdata[
'UVS'],
true).$this->encryptdata[
'UVS'].$this->encryptdata[
'UKS'];
10644 $hashkey = hash(
'sha256', $this->encryptdata[
'user_password'].$this->encryptdata[
'UKS'],
true);
10656 if ($this->encryptdata[
'mode'] < 3) {
10658 if ($this->encryptdata[
'mode'] > 0) {
10659 for ($i = 0; $i < 50; ++$i) {
10663 $owner_key = substr($tmp, 0, ($this->encryptdata[
'Length'] / 8));
10664 $enc =
TCPDF_STATIC::_RC4($owner_key, $this->encryptdata[
'user_password'], $this->last_enc_key, $this->last_enc_key_c);
10665 if ($this->encryptdata[
'mode'] > 0) {
10666 $len = strlen($owner_key);
10667 for ($i = 1; $i <= 19; ++$i) {
10669 for ($j = 0; $j < $len; ++$j) {
10670 $ek .= chr(ord($owner_key[$j]) ^ $i);
10676 } elseif ($this->encryptdata[
'mode'] == 3) {
10679 $this->encryptdata[
'OVS'] = substr($seed, 0, 8);
10681 $this->encryptdata[
'OKS'] = substr($seed, 8, 16);
10682 return hash(
'sha256', $this->encryptdata[
'owner_password'].$this->encryptdata[
'OVS'].$this->encryptdata[
'U'],
true).$this->encryptdata[
'OVS'].$this->encryptdata[
'OKS'];
10694 $hashkey = hash(
'sha256', $this->encryptdata[
'owner_password'].$this->encryptdata[
'OKS'].$this->encryptdata[
'U'],
true);
10709 foreach ($psw_array as $c) {
10712 return substr($psw, 0, 127);
10722 $keybytelen = ($this->encryptdata[
'Length'] / 8);
10723 if (!$this->encryptdata[
'pubkey']) {
10724 if ($this->encryptdata[
'mode'] == 3) {
10728 $this->encryptdata[
'user_password'] = $this->
_fixAES256Password($this->encryptdata[
'user_password']);
10729 $this->encryptdata[
'owner_password'] = $this->
_fixAES256Password($this->encryptdata[
'owner_password']);
10731 $this->encryptdata[
'U'] = $this->
_Uvalue();
10733 $this->encryptdata[
'UE'] = $this->
_UEvalue();
10735 $this->encryptdata[
'O'] = $this->
_Ovalue();
10737 $this->encryptdata[
'OE'] = $this->
_OEvalue();
10739 $this->encryptdata[
'P'] = $this->encryptdata[
'protection'];
10742 $perms .= chr(255).chr(255).chr(255).chr(255);
10743 if (isset($this->encryptdata[
'CF'][
'EncryptMetadata']) AND (!$this->encryptdata[
'CF'][
'EncryptMetadata'])) {
10754 $this->encryptdata[
'owner_password'] = substr($this->encryptdata[
'owner_password'].TCPDF_STATIC::$enc_padding, 0, 32);
10756 $this->encryptdata[
'O'] = $this->
_Ovalue();
10760 $tmp =
TCPDF_STATIC::_md5_16($this->encryptdata[
'user_password'].$this->encryptdata[
'O'].$permissions.$this->encryptdata[
'fileid']);
10761 if ($this->encryptdata[
'mode'] > 0) {
10762 for ($i = 0; $i < 50; ++$i) {
10766 $this->encryptdata[
'key'] = substr($tmp, 0, $keybytelen);
10768 $this->encryptdata[
'U'] = $this->
_Uvalue();
10770 $this->encryptdata[
'P'] = $this->encryptdata[
'protection'];
10775 $recipient_bytes =
'';
10776 foreach ($this->encryptdata[
'pubkeys'] as $pubkey) {
10778 if (isset($pubkey[
'p'])) {
10781 $pkprotection = $this->encryptdata[
'protection'];
10786 $envelope = $seed.$pkpermissions;
10791 $this->
Error(
'Unable to create temporary key file: '.$tempkeyfile);
10793 $envelope_length = strlen($envelope);
10794 fwrite($f, $envelope, $envelope_length);
10797 if (!openssl_pkcs7_encrypt($tempkeyfile, $tempencfile, $pubkey[
'c'],
array(), PKCS7_BINARY | PKCS7_DETACHED)) {
10798 $this->
Error(
'Unable to encrypt the file: '.$tempkeyfile);
10801 $signature = file_get_contents($tempencfile,
false, null, $envelope_length);
10803 $signature = substr($signature, strpos($signature,
'Content-Disposition'));
10804 $tmparr = explode(
"\n\n", $signature);
10805 $signature = trim($tmparr[1]);
10808 $signature = base64_decode($signature);
10810 $hexsignature = current(unpack(
'H*', $signature));
10812 $this->encryptdata[
'Recipients'][] = $hexsignature;
10814 $recipient_bytes .= $signature;
10817 if ($this->encryptdata[
'mode'] == 3) {
10818 $this->encryptdata[
'key'] = substr(hash(
'sha256', $seed.$recipient_bytes,
true), 0, $keybytelen);
10820 $this->encryptdata[
'key'] = substr(sha1($seed.$recipient_bytes,
true), 0, $keybytelen);
10839 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) {
10840 if ($this->pdfa_mode) {
10845 if (($pubkeys !== null) AND (is_array($pubkeys))) {
10847 $this->encryptdata[
'pubkeys'] = $pubkeys;
10852 if (!function_exists(
'openssl_pkcs7_encrypt')) {
10853 $this->
Error(
'Public-Key Security requires openssl library.');
10856 $this->encryptdata[
'pubkey'] =
true;
10857 $this->encryptdata[
'Filter'] =
'Adobe.PubSec';
10858 $this->encryptdata[
'StmF'] =
'DefaultCryptFilter';
10859 $this->encryptdata[
'StrF'] =
'DefaultCryptFilter';
10862 $this->encryptdata[
'pubkey'] =
false;
10863 $this->encryptdata[
'Filter'] =
'Standard';
10864 $this->encryptdata[
'StmF'] =
'StdCF';
10865 $this->encryptdata[
'StrF'] =
'StdCF';
10868 if (!extension_loaded(
'openssl') && !extension_loaded(
'mcrypt')) {
10869 $this->
Error(
'AES encryption requires openssl or mcrypt extension (http://www.php.net/manual/en/mcrypt.requirements.php).');
10871 if (extension_loaded(
'openssl') && !in_array(
'aes-256-cbc', openssl_get_cipher_methods())) {
10872 $this->
Error(
'AES encryption requires openssl/aes-256-cbc cypher.');
10874 if (extension_loaded(
'mcrypt') && mcrypt_get_cipher_name(MCRYPT_RIJNDAEL_128) ===
false) {
10875 $this->
Error(
'AES encryption requires MCRYPT_RIJNDAEL_128 cypher.');
10877 if (($mode == 3) AND !function_exists(
'hash')) {
10879 $this->
Error(
'AES 256 encryption requires HASH Message Digest Framework (http://www.php.net/manual/en/book.hash.php).');
10882 if ($owner_pass === null) {
10885 $this->encryptdata[
'user_password'] = $user_pass;
10886 $this->encryptdata[
'owner_password'] = $owner_pass;
10887 $this->encryptdata[
'mode'] = $mode;
10890 $this->encryptdata[
'V'] = 1;
10891 $this->encryptdata[
'Length'] = 40;
10892 $this->encryptdata[
'CF'][
'CFM'] =
'V2';
10896 $this->encryptdata[
'V'] = 2;
10897 $this->encryptdata[
'Length'] = 128;
10898 $this->encryptdata[
'CF'][
'CFM'] =
'V2';
10899 if ($this->encryptdata[
'pubkey']) {
10900 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s4';
10901 $this->encryptdata[
'Recipients'] =
array();
10906 $this->encryptdata[
'V'] = 4;
10907 $this->encryptdata[
'Length'] = 128;
10908 $this->encryptdata[
'CF'][
'CFM'] =
'AESV2';
10909 $this->encryptdata[
'CF'][
'Length'] = 128;
10910 if ($this->encryptdata[
'pubkey']) {
10911 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s5';
10912 $this->encryptdata[
'Recipients'] =
array();
10917 $this->encryptdata[
'V'] = 5;
10918 $this->encryptdata[
'Length'] = 256;
10919 $this->encryptdata[
'CF'][
'CFM'] =
'AESV3';
10920 $this->encryptdata[
'CF'][
'Length'] = 256;
10921 if ($this->encryptdata[
'pubkey']) {
10922 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s5';
10923 $this->encryptdata[
'Recipients'] =
array();
10928 $this->encrypted =
true;
10946 if ($this->state != 2) {
10950 if ($this->inxobj) {
10952 $this->xobjects[
$this->xobjid][
'transfmrk'][] = strlen($this->xobjects[$this->xobjid][
'outdata']);
10969 if ($this->state != 2) {
10973 if (isset($this->transfmatrix[$this->transfmatrix_key])) {
10974 array_pop($this->transfmatrix[$this->transfmatrix_key]);
10977 if ($this->inxobj) {
10979 array_pop($this->xobjects[$this->xobjid][
'transfmrk']);
10981 array_pop($this->transfmrk[$this->page]);
11040 if (($s_x == 0) OR ($s_y == 0)) {
11041 $this->
Error(
'Please do not use values equal to zero for scaling');
11043 $y = ($this->h -
$y) * $this->k;
11053 $tm[4] =
$x * (1 - $s_x);
11054 $tm[5] =
$y * (1 - $s_y);
11078 $this->
Scale(100, -100,
'',
$y);
11166 $y = ($this->h -
$y) * $this->k;
11170 $tm[0] = cos(deg2rad(
$angle));
11171 $tm[1] = sin(deg2rad(
$angle));
11174 $tm[4] =
$x + ($tm[1] *
$y) - ($tm[0] *
$x);
11175 $tm[5] =
$y - ($tm[0] *
$y) - ($tm[1] * $x);
11223 if (($angle_x <= -90) OR ($angle_x >= 90) OR ($angle_y <= -90) OR ($angle_y >= 90)) {
11224 $this->
Error(
'Please use values between -90 and +90 degrees for Skewing.');
11227 $y = ($this->h -
$y) * $this->k;
11231 $tm[1] = tan(deg2rad($angle_y));
11232 $tm[2] = tan(deg2rad($angle_x));
11234 $tm[4] = -$tm[2] *
$y;
11235 $tm[5] = -$tm[1] *
$x;
11248 if ($this->state != 2) {
11251 $this->
_out(sprintf(
'%F %F %F %F %F %F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
11253 $this->transfmatrix[
$this->transfmatrix_key][] =
array(
'a' => $tm[0],
'b' => $tm[1],
'c' => $tm[2],
'd' => $tm[3],
'e' => $tm[4],
'f' => $tm[5]);
11255 if ($this->inxobj) {
11257 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
11258 $key = key($this->xobjects[$this->xobjid][
'transfmrk']);
11259 $this->xobjects[
$this->xobjid][
'transfmrk'][$key] = strlen($this->xobjects[$this->xobjid][
'outdata']);
11261 } elseif (end($this->transfmrk[$this->page]) !==
false) {
11262 $key = key($this->transfmrk[$this->page]);
11281 $this->LineWidth = $width;
11282 $this->linestyleWidth = sprintf(
'%F w', ($width * $this->k));
11283 if ($this->state == 2) {
11284 $this->
_out($this->linestyleWidth);
11324 if (!is_array(
$style)) {
11327 if (isset(
$style[
'width'])) {
11328 $this->LineWidth =
$style[
'width'];
11329 $this->linestyleWidth = sprintf(
'%F w', (
$style[
'width'] * $this->k));
11330 $s .= $this->linestyleWidth.
' ';
11332 if (isset(
$style[
'cap'])) {
11333 $ca =
array(
'butt' => 0,
'round'=> 1,
'square' => 2);
11334 if (isset($ca[
$style[
'cap']])) {
11335 $this->linestyleCap = $ca[$style[
'cap']].
' J';
11336 $s .= $this->linestyleCap.
' ';
11339 if (isset(
$style[
'join'])) {
11340 $ja =
array(
'miter' => 0,
'round' => 1,
'bevel' => 2);
11341 if (isset($ja[
$style[
'join']])) {
11342 $this->linestyleJoin = $ja[$style[
'join']].
' j';
11343 $s .= $this->linestyleJoin.
' ';
11346 if (isset(
$style[
'dash'])) {
11349 if (preg_match(
'/^.+,/',
$style[
'dash']) > 0) {
11355 foreach (
$tab as $i => $v) {
11357 $dash_string .=
' ';
11359 $dash_string .= sprintf(
'%F', $v);
11365 $this->linestyleDash = sprintf(
'[%s] %F d', $dash_string,
$style[
'phase']);
11366 $s .= $this->linestyleDash.
' ';
11368 if (isset(
$style[
'color'])) {
11371 if (!
$ret AND ($this->state == 2)) {
11385 if ($this->state == 2) {
11386 $this->
_out(sprintf(
'%F %F m', (
$x * $this->k), (($this->h -
$y) * $this->k)));
11399 if ($this->state == 2) {
11400 $this->
_out(sprintf(
'%F %F l', (
$x * $this->k), (($this->h -
$y) * $this->k)));
11415 if ($this->state == 2) {
11416 $this->
_out(sprintf(
'%F %F %F %F re %s', (
$x * $this->k), (($this->h -
$y) * $this->k), (
$w * $this->k), (-
$h * $this->k), $op));
11433 if ($this->state == 2) {
11434 $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)));
11449 if ($this->state == 2) {
11450 $this->
_out(sprintf(
'%F %F %F %F v', ($x2 * $this->k), (($this->h - $y2) * $this->k), ($x3 * $this->k), (($this->h - $y3) * $this->k)));
11465 if ($this->state == 2) {
11466 $this->
_out(sprintf(
'%F %F %F %F y', ($x1 * $this->k), (($this->h - $y1) * $this->k), ($x3 * $this->k), (($this->h - $y3) * $this->k)));
11482 if ($this->state != 2) {
11512 if ($this->state != 2) {
11518 if (!(strpos(
$style,
'F') ===
false) AND !empty($fill_color)) {
11529 $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*' );
11530 if (isset($opnostroke[
$style])) {
11531 $style = $opnostroke[
$style];
11540 $border_style2 =
array();
11542 $length = strlen($line);
11543 for ($i = 0; $i < $length; ++$i) {
11544 $border_style2[$line[$i]] = $value;
11551 if (isset($border_style[
'T']) AND $border_style[
'T']) {
11554 if (isset($border_style[
'R']) AND $border_style[
'R']) {
11557 if (isset($border_style[
'B']) AND $border_style[
'B']) {
11582 public function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3,
$style=
'', $line_style=
array(), $fill_color=
array()) {
11583 if ($this->state != 2) {
11586 if (!(
false === strpos(
$style,
'F')) AND isset($fill_color)) {
11594 $this->
_outCurve($x1, $y1, $x2, $y2, $x3, $y3);
11613 if ($this->state != 2) {
11616 if (!(
false === strpos(
$style,
'F')) AND isset($fill_color)) {
11621 $line_style =
array();
11627 foreach ($segments as $segment) {
11628 list($x1, $y1, $x2, $y2, $x3, $y3) = $segment;
11629 $this->
_outCurve($x1, $y1, $x2, $y2, $x3, $y3);
11652 public function Ellipse($x0, $y0, $rx, $ry=
'',
$angle=0, $astart=0, $afinish=360,
$style=
'', $line_style=
array(), $fill_color=
array(), $nc=2) {
11653 if ($this->state != 2) {
11659 if (!(
false === strpos(
$style,
'F')) AND isset($fill_color)) {
11664 $line_style =
array();
11669 $this->
_outellipticalarc($x0, $y0, $rx, $ry,
$angle, $astart, $afinish,
false, $nc,
true,
true,
false);
11693 protected function _outellipticalarc(
$xc,
$yc, $rx, $ry, $xang=0, $angs=0, $angf=360, $pie=
false, $nc=2, $startpoint=
true, $ccw=
true, $svg=
false) {
11694 if (($rx <= 0) OR ($ry < 0)) {
11701 $xmin = 2147483647;
11702 $ymin = 2147483647;
11709 $xang = deg2rad((
float) $xang);
11710 $angs = deg2rad((
float) $angs);
11711 $angf = deg2rad((
float) $angf);
11716 $as = atan2((sin($angs) / $ry), (cos($angs) / $rx));
11717 $af = atan2((sin($angf) / $ry), (cos($angf) / $rx));
11725 if ($ccw AND ($as > $af)) {
11728 } elseif (!$ccw AND ($as < $af)) {
11732 $total_angle = ($af - $as);
11737 $nc *= (2 * abs($total_angle) / M_PI);
11738 $nc = round($nc) + 1;
11740 $arcang = ($total_angle / $nc);
11743 $y0 = ($this->h -
$yc);
11746 $alpha = sin($arcang) * ((sqrt(4 + (3 * pow(tan(($arcang) / 2), 2))) - 1) / 3);
11747 $cos_xang = cos($xang);
11748 $sin_xang = sin($xang);
11749 $cos_ang = cos($ang);
11750 $sin_ang = sin($ang);
11752 $px1 = $x0 + ($rx * $cos_xang * $cos_ang) - ($ry * $sin_xang * $sin_ang);
11753 $py1 = $y0 + ($rx * $sin_xang * $cos_ang) + ($ry * $cos_xang * $sin_ang);
11755 $qx1 = (
$alpha * ((-$rx * $cos_xang * $sin_ang) - ($ry * $sin_xang * $cos_ang)));
11756 $qy1 = (
$alpha * ((-$rx * $sin_xang * $sin_ang) + ($ry * $cos_xang * $cos_ang)));
11759 $this->
_outLine($px1, $this->h - $py1);
11760 } elseif ($startpoint) {
11762 $this->
_outPoint($px1, $this->h - $py1);
11765 for ($i = 1; $i <= $nc; ++$i) {
11767 $ang = $as + ($i * $arcang);
11771 $cos_ang = cos($ang);
11772 $sin_ang = sin($ang);
11774 $px2 = $x0 + ($rx * $cos_xang * $cos_ang) - ($ry * $sin_xang * $sin_ang);
11775 $py2 = $y0 + ($rx * $sin_xang * $cos_ang) + ($ry * $cos_xang * $sin_ang);
11777 $qx2 = (
$alpha * ((-$rx * $cos_xang * $sin_ang) - ($ry * $sin_xang * $cos_ang)));
11778 $qy2 = (
$alpha * ((-$rx * $sin_xang * $sin_ang) + ($ry * $cos_xang * $cos_ang)));
11780 $cx1 = ($px1 + $qx1);
11781 $cy1 = ($this->h - ($py1 + $qy1));
11782 $cx2 = ($px2 - $qx2);
11783 $cy2 = ($this->h - ($py2 - $qy2));
11785 $cy3 = ($this->h - $py2);
11786 $this->
_outCurve($cx1, $cy1, $cx2, $cy2, $cx3, $cy3);
11788 $xmin = min($xmin, $cx1, $cx2, $cx3);
11789 $ymin = min($ymin, $cy1, $cy2, $cy3);
11790 $xmax = max($xmax, $cx1, $cx2, $cx3);
11791 $ymax = max($ymax, $cy1, $cy2, $cy3);
11801 $xmin = min($xmin,
$xc);
11802 $ymin = min($ymin,
$yc);
11803 $xmax = max($xmax,
$xc);
11804 $ymax = max($ymax,
$yc);
11806 return array($xmin, $ymin, $xmax, $ymax);
11825 $this->
Ellipse($x0, $y0,
$r,
$r, 0, $angstr, $angend,
$style, $line_style, $fill_color, $nc);
11843 $this->
Polygon($p,
$style, $line_style, $fill_color,
false);
11862 if ($this->state != 2) {
11869 for ($i = 0; $i < 4; ++$i) {
11870 $p[$nc + $i] = $p[$i];
11873 if (isset($line_style[0])) {
11874 $line_style[$np] = $line_style[0];
11878 if (!(
false === strpos(
$style,
'F')) AND isset($fill_color)) {
11883 $line_style =
array();
11887 if (isset($line_style[
'all'])) {
11895 for ($i = 2; $i < $nc; $i = $i + 2) {
11896 $this->
_outLine($p[$i], $p[$i + 1]);
11902 for ($i = 2; $i < $nc; $i = $i + 2) {
11903 $line_num = ($i / 2) - 1;
11904 if (isset($line_style[$line_num])) {
11905 if ($line_style[$line_num] != 0) {
11906 if (is_array($line_style[$line_num])) {
11909 $this->
_outPoint($p[$i - 2], $p[$i - 1]);
11910 $this->
_outLine($p[$i], $p[$i + 1]);
11914 $this->
_outLine($p[$i], $p[$i + 1]);
11918 $this->
_outLine($p[$i], $p[$i + 1]);
11926 for ($i = 2; $i < $nc; $i = $i + 2) {
11927 $this->
_outLine($p[$i], $p[$i + 1]);
11962 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()) {
11966 if ($draw_circle) {
11967 $this->
Circle($x0, $y0,
$r, 0, 360, $circle_style, $circle_outLine_style, $circle_fill_color);
11970 for ($i = 0; $i < $ns; ++$i) {
11971 $a =
$angle + ($i * 360 / $ns);
11972 $a_rad = deg2rad((
float) $a);
11973 $p[] = $x0 + (
$r * sin($a_rad));
11974 $p[] = $y0 + (
$r * cos($a_rad));
12010 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()) {
12014 if ($draw_circle) {
12015 $this->
Circle($x0, $y0,
$r, 0, 360, $circle_style, $circle_outLine_style, $circle_fill_color);
12018 $visited =
array();
12019 for ($i = 0; $i < $nv; ++$i) {
12020 $a =
$angle + ($i * 360 / $nv);
12021 $a_rad = deg2rad((
float) $a);
12022 $p2[] = $x0 + (
$r * sin($a_rad));
12023 $p2[] = $y0 + (
$r * cos($a_rad));
12024 $visited[] =
false;
12029 $p[] = $p2[$i * 2];
12030 $p[] = $p2[($i * 2) + 1];
12031 $visited[$i] =
true;
12034 }
while (!$visited[$i]);
12072 if ($this->state != 2) {
12075 if (($round_corner ==
'0000') OR (($rx == $ry) AND ($rx == 0))) {
12081 if (!(
false === strpos(
$style,
'F')) AND isset($fill_color)) {
12091 $MyArc = 4 / 3 * (sqrt(2) - 1);
12096 if ($round_corner[0]) {
12104 if ($round_corner[1]) {
12112 if ($round_corner[2]) {
12120 if ($round_corner[3]) {
12141 public function Arrow($x0, $y0, $x1, $y1, $head_style=0, $arm_size=5, $arm_angle=15) {
12144 $dir_angle = atan2(($y0 - $y1), ($x0 - $x1));
12145 if ($dir_angle < 0) {
12146 $dir_angle += (2 * M_PI);
12148 $arm_angle = deg2rad($arm_angle);
12151 if ($head_style > 0) {
12157 $this->
Line($x0, $y0, $sx1, $sy1);
12159 $x2L = $x1 + ($arm_size * cos($dir_angle + $arm_angle));
12160 $y2L = $y1 + ($arm_size * sin($dir_angle + $arm_angle));
12162 $x2R = $x1 + ($arm_size * cos($dir_angle - $arm_angle));
12163 $y2R = $y1 + ($arm_size * sin($dir_angle - $arm_angle));
12166 switch ($head_style) {
12214 } elseif (
$y < 0) {
12216 } elseif (
$y > $this->h) {
12221 } elseif (
$x < 0) {
12223 } elseif (
$x > $this->w) {
12232 if (empty(
$page)) {
12234 if (empty(
$page)) {
12238 $this->dests[$name] =
array(
'x' =>
$x,
'y' =>
$y,
'p' =>
$page,
'f' => $fixed);
12260 if (empty($this->dests)) {
12263 $this->n_dests = $this->
_newobj();
12265 foreach($this->dests as $name => $o) {
12266 $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)));
12269 $out .=
"\n".
'endobj';
12306 if (isset($this->outlines[0])) {
12307 $lastoutline = end($this->outlines);
12308 $maxlevel = $lastoutline[
'l'] + 1;
12312 if ($level > $maxlevel) {
12313 $level = $maxlevel;
12317 } elseif (
$y < 0) {
12319 } elseif (
$y > $this->h) {
12324 } elseif (
$x < 0) {
12326 } elseif (
$x > $this->w) {
12335 if (empty(
$page)) {
12337 if (empty(
$page)) {
12341 $this->outlines[] =
array(
't' =>
$txt,
'l' => $level,
'x' =>
$x,
'y' =>
$y,
'p' =>
$page,
'f' => $fixed,
's' => strtoupper(
$style),
'c' => $color,
'u' => $link);
12351 $outline_p =
array();
12352 $outline_y =
array();
12353 foreach ($this->outlines as $key =>
$row) {
12354 $outline_p[$key] =
$row[
'p'];
12355 $outline_k[$key] = $key;
12358 array_multisort($outline_p, SORT_NUMERIC, SORT_ASC, $outline_k, SORT_NUMERIC, SORT_ASC, $this->outlines);
12368 $nb = count($this->outlines);
12376 foreach ($this->outlines as $i => $o) {
12378 $parent = $lru[($o[
'l'] - 1)];
12380 $this->outlines[$i][
'parent'] = $parent;
12381 $this->outlines[$parent][
'last'] = $i;
12382 if ($o[
'l'] > $level) {
12384 $this->outlines[$parent][
'first'] = $i;
12387 $this->outlines[$i][
'parent'] = $nb;
12389 if (($o[
'l'] <= $level) AND ($i > 0)) {
12391 $prev = $lru[$o[
'l']];
12392 $this->outlines[$prev][
'next'] = $i;
12393 $this->outlines[$i][
'prev'] = $prev;
12395 $lru[$o[
'l']] = $i;
12400 $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';
12401 foreach ($this->outlines as $i => $o) {
12404 $title = preg_replace($nltags,
"\n", $o[
't']);
12409 $out =
'<</Title '.$this->_textstring(
$title, $oid);
12410 $out .=
' /Parent '.($n + $o[
'parent']).
' 0 R';
12411 if (isset($o[
'prev'])) {
12412 $out .=
' /Prev '.($n + $o[
'prev']).
' 0 R';
12414 if (isset($o[
'next'])) {
12415 $out .=
' /Next '.($n + $o[
'next']).
' 0 R';
12417 if (isset($o[
'first'])) {
12418 $out .=
' /First '.($n + $o[
'first']).
' 0 R';
12420 if (isset($o[
'last'])) {
12421 $out .=
' /Last '.($n + $o[
'last']).
' 0 R';
12423 if (isset($o[
'u']) AND !empty($o[
'u'])) {
12425 if (is_string($o[
'u'])) {
12426 if ($o[
'u'][0] ==
'#') {
12428 $out .=
' /Dest /'.TCPDF_STATIC::encodeNameObject(substr($o[
'u'], 1));
12429 } elseif ($o[
'u'][0] ==
'%') {
12431 $filename = basename(substr($o[
'u'], 1));
12432 $out .=
' /A <</S /GoToE /D [0 /Fit] /NewWindow true /T << /R /C /P '.($o[
'p'] - 1).
' /A '.$this->embeddedfiles[
$filename][
'a'].
' >> >>';
12433 } elseif ($o[
'u'][0] ==
'*') {
12435 $filename = basename(substr($o[
'u'], 1));
12436 $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});';
12437 $out .=
' /A <</S /JavaScript /JS '.$this->_textstring($jsa, $oid).
'>>';
12440 $out .=
' /A <</S /URI /URI '.$this->_datastring($this->
unhtmlentities($o[
'u']), $oid).
'>>';
12442 } elseif (isset($this->links[$o[
'u']])) {
12444 $l = $this->links[$o[
'u']];
12445 if (isset($this->page_obj_id[(
$l[
'p'])])) {
12446 $out .= sprintf(
' /Dest [%u 0 R /XYZ 0 %F null]', $this->page_obj_id[(
$l[
'p'])], ($this->pagedim[
$l[
'p']][
'h'] - (
$l[
'y'] * $this->k)));
12449 } elseif (isset($this->page_obj_id[($o[
'p'])])) {
12451 $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)));
12455 if (!empty($o[
's'])) {
12457 if (strpos($o[
's'],
'B') !==
false) {
12461 if (strpos($o[
's'],
'I') !==
false) {
12467 if (isset($o[
'c']) AND is_array($o[
'c']) AND (count($o[
'c']) == 3)) {
12468 $color = array_values($o[
'c']);
12469 $out .= sprintf(
' /C [%F %F %F]', ($color[0] / 255), ($color[1] / 255), ($color[2] / 255));
12472 $out .=
' /C [0.0 0.0 0.0]';
12474 $out .=
' /Count 0';
12476 $out .=
"\n".
'endobj';
12480 $this->OutlineRoot = $this->
_newobj();
12481 $this->
_out(
'<< /Type /Outlines /First '.
$n.
' 0 R /Last '.(
$n + $lru[0]).
' 0 R >>'.
"\n".
'endobj');
12494 $this->javascript .= $script;
12507 if ($this->pdfa_mode) {
12512 $this->js_objects[
$this->n] =
array(
'n' => $this->
n,
'js' => $script,
'onload' => $onload);
12523 if ($this->pdfa_mode OR (empty($this->javascript) AND empty($this->js_objects))) {
12526 if (strpos($this->javascript,
'this.addField') > 0) {
12527 if (!$this->ur[
'enabled']) {
12532 $jsa = sprintf(
"ftcpdfdocsaved=this.addField('%s','%s',%d,[%F,%F,%F,%F]);",
'tcpdfdocsaved',
'text', 0, 0, 1, 0, 1);
12533 $jsb =
"getField('tcpdfdocsaved').value='saved';";
12534 $this->javascript = $jsa.
"\n".$this->javascript.
"\n".$jsb;
12537 $this->n_js =
'<< /Names [';
12538 if (!empty($this->javascript)) {
12539 $this->n_js .=
' (EmbeddedJS) '.($this->n + 1).
' 0 R';
12541 if (!empty($this->js_objects)) {
12542 foreach ($this->js_objects as $key => $val) {
12543 if ($val[
'onload']) {
12544 $this->n_js .=
' (JS'.$key.
') '.$key.
' 0 R';
12548 $this->n_js .=
' ] >>';
12550 if (!empty($this->javascript)) {
12552 $out =
'<< /S /JavaScript';
12553 $out .=
' /JS '.$this->_textstring($this->javascript, $obj_id);
12555 $out .=
"\n".
'endobj';
12559 if (!empty($this->js_objects)) {
12560 foreach ($this->js_objects as $key => $val) {
12561 $out = $this->
_getobj($key).
"\n".
' << /S /JavaScript /JS '.$this->_textstring($val[
'js'], $key).
' >>'.
"\n".
'endobj';
12585 $this->javascript .=
"if (getField('tcpdfdocsaved').value != 'saved') {";
12587 $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";
12588 $this->javascript .=
'f'.$name.
'.textSize='.$this->FontSizePt.
";\n";
12589 while (list($key, $val) = each($prop)) {
12590 if (strcmp(substr($key, -5),
'Color') == 0) {
12593 $val =
"'".$val.
"'";
12595 $this->javascript .=
'f'.$name.
'.'.$key.
'='.$val.
";\n";
12602 $this->javascript .=
'}';
12617 $this->default_form_prop = $prop;
12663 $this->annotation_fonts[$this->CurrentFont[
'fontkey']] = $this->CurrentFont[
'i'];
12664 $fontstyle = sprintf(
'/F%d %F Tf %s', $this->CurrentFont[
'i'], $this->FontSizePt, $this->TextColor);
12665 $popt[
'da'] = $fontstyle;
12667 $popt[
'ap'] =
array();
12668 $popt[
'ap'][
'n'] =
'/Tx BMC q '.$fontstyle.
' ';
12670 if (isset($prop[
'value']) AND !empty($prop[
'value'])) {
12671 $text = $prop[
'value'];
12672 } elseif (isset($opt[
'v']) AND !empty($opt[
'v'])) {
12677 if (isset($popt[
'q'])) {
12678 switch ($popt[
'q']) {
12697 $this->
MultiCell(
$w,
$h,
$text, 0, $align,
false, 0, 0, 0,
true, 0,
false,
true, 0,
'T',
false);
12700 $popt[
'ap'][
'n'] .= $this->xobjects[$tmpid][
'outdata'];
12701 unset($this->xobjects[$tmpid]);
12702 $popt[
'ap'][
'n'] .=
'Q EMC';
12704 $opt = array_merge($popt, $opt);
12708 $opt[
'Subtype'] =
'Widget';
12723 unset($opt[
'mk'][
'ca']);
12724 unset($opt[
'mk'][
'rc']);
12725 unset($opt[
'mk'][
'ac']);
12726 unset($opt[
'mk'][
'i']);
12727 unset($opt[
'mk'][
'ri']);
12728 unset($opt[
'mk'][
'ix']);
12729 unset($opt[
'mk'][
'if']);
12734 unset($opt[
'mk'][
'tp']);
12783 $defval = $onvalue;
12788 $font =
'zapfdingbats';
12789 if ($this->pdfa_mode) {
12791 $font =
'pdfa'.$font;
12796 if (!isset($this->radiobutton_groups[$this->page])) {
12799 if (!isset($this->radiobutton_groups[$this->page][$name])) {
12805 $kid = ($this->
n + 1);
12807 $this->radiobutton_groups[
$this->page][$name][] =
array(
'kid' => $kid,
'def' => $defval);
12810 $prop[
'NoToggleToOff'] =
'true';
12811 $prop[
'Radio'] =
'true';
12812 $prop[
'borderStyle'] =
'inset';
12816 $this->annotation_fonts[$tmpfont[
'fontkey']] = $tmpfont[
'i'];
12817 $fontstyle = sprintf(
'/F%d %F Tf %s', $tmpfont[
'i'], $this->FontSizePt, $this->TextColor);
12818 $popt[
'da'] = $fontstyle;
12820 $popt[
'ap'] =
array();
12821 $popt[
'ap'][
'n'] =
array();
12823 $fy = ((
$w - ((($tmpfont[
'desc'][
'Ascent'] - $tmpfont[
'desc'][
'Descent']) * $this->FontSizePt / 1000) /
$this->k)) *
$this->k);
12824 $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);
12825 $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);
12826 if (!isset($popt[
'mk'])) {
12827 $popt[
'mk'] =
array();
12829 $popt[
'mk'][
'ca'] =
'(l)';
12831 $opt = array_merge($popt, $opt);
12833 $opt[
'Subtype'] =
'Widget';
12834 $opt[
'ft'] =
'Btn';
12836 $opt[
'v'] =
array(
'/'.$onvalue);
12837 $opt[
'as'] = $onvalue;
12839 $opt[
'as'] =
'Off';
12842 if (!isset($this->radiobutton_groups[$this->page][$name][
'#readonly#'])) {
12843 $this->radiobutton_groups[
$this->page][$name][
'#readonly#'] =
false;
12845 $this->radiobutton_groups[
$this->page][$name][
'#readonly#'] |= ($opt[
'f'] & 64);
12881 foreach ($values as $value) {
12882 if (is_array($value)) {
12883 $s .=
',[\''.addslashes($value[1]).
'\',\
''.addslashes($value[0]).
'\']
'; 12885 $s .= ',[\
''.addslashes($value).
'\',\
''.addslashes($value).
'\']
'; 12888 $this->javascript .= 'f
'.$name.'.setItems(
'.substr($s, 1).');
'."\n"; 12891 // get default style 12892 $prop = array_merge($this->getFormDefaultProp(), $prop); 12893 // get annotation data 12894 $popt = TCPDF_STATIC::getAnnotOptFromJSProp($prop, $this->spot_colors, $this->rtl); 12895 // set additional default values 12896 $this->annotation_fonts[$this->CurrentFont['fontkey
']] = $this->CurrentFont['i
']; 12897 $fontstyle = sprintf('/F%d %F Tf %
s', $this->CurrentFont['i
'], $this->FontSizePt, $this->TextColor); 12898 $popt['da
'] = $fontstyle; 12899 // build appearance stream 12900 $popt['ap
'] = array(); 12901 $popt['ap
']['n'] = '/Tx BMC q
'.$fontstyle.' '; 12903 foreach($values as $item) { 12904 if (is_array($item)) { 12905 $text .= $item[1]."\n"; 12907 $text .= $item."\n"; 12910 $tmpid = $this->startTemplate($w, $h, false); 12911 $this->MultiCell($w, $h, $text, 0, '', false, 0, 0, 0, true, 0, false, true, 0, 'T
', false); 12912 $this->endTemplate(); 12914 $popt['ap
']['n'] .= $this->xobjects[$tmpid]['outdata
']; 12915 unset($this->xobjects[$tmpid]); 12916 $popt['ap
']['n'] .= 'Q EMC
'; 12918 $opt = array_merge($popt, $opt); 12919 // set remaining annotation data 12920 $opt['Subtype
'] = 'Widget
'; 12923 $opt['opt
'] = $values; 12924 unset($opt['mk
']['ca
']); 12925 unset($opt['mk
']['rc
']); 12926 unset($opt['mk
']['ac
']); 12927 unset($opt['mk
']['i
']); 12928 unset($opt['mk
']['ri
']); 12929 unset($opt['mk
']['ix
']); 12930 unset($opt['mk
']['if']); 12931 unset($opt['mk
']['tp
']); 12932 $this->Annotation($x, $y, $w, $h, $name, $opt, 0); 12955 public function ComboBox($name, $w, $h, $values, $prop=array(), $opt=array(), $x='', $y='', $js=false) { 12962 // check page for no-write regions and adapt page margins if necessary 12963 list($x, $y) = $this->checkPageRegions($h, $x, $y); 12965 $this->_addfield('combobox
', $name, $x, $y, $w, $h, $prop); 12967 foreach ($values as $value) { 12968 if (is_array($value)) { 12969 $s .= ',[\
''.addslashes($value[1]).
'\',\
''.addslashes($value[0]).
'\']
'; 12971 $s .= ',[\
''.addslashes($value).
'\',\
''.addslashes($value).
'\']
'; 12974 $this->javascript .= 'f
'.$name.'.setItems(
'.substr($s, 1).');
'."\n"; 12977 // get default style 12978 $prop = array_merge($this->getFormDefaultProp(), $prop); 12979 $prop['Combo
'] = true; 12980 // get annotation data 12981 $popt = TCPDF_STATIC::getAnnotOptFromJSProp($prop, $this->spot_colors, $this->rtl); 12982 // set additional default options 12983 $this->annotation_fonts[$this->CurrentFont['fontkey
']] = $this->CurrentFont['i
']; 12984 $fontstyle = sprintf('/F%d %F Tf %
s', $this->CurrentFont['i
'], $this->FontSizePt, $this->TextColor); 12985 $popt['da
'] = $fontstyle; 12986 // build appearance stream 12987 $popt['ap
'] = array(); 12988 $popt['ap
']['n'] = '/Tx BMC q
'.$fontstyle.' '; 12990 foreach($values as $item) { 12991 if (is_array($item)) { 12992 $text .= $item[1]."\n"; 12994 $text .= $item."\n"; 12997 $tmpid = $this->startTemplate($w, $h, false); 12998 $this->MultiCell($w, $h, $text, 0, '', false, 0, 0, 0, true, 0, false, true, 0, 'T
', false); 12999 $this->endTemplate(); 13001 $popt['ap
']['n'] .= $this->xobjects[$tmpid]['outdata
']; 13002 unset($this->xobjects[$tmpid]); 13003 $popt['ap
']['n'] .= 'Q EMC
'; 13005 $opt = array_merge($popt, $opt); 13006 // set remaining annotation data 13007 $opt['Subtype
'] = 'Widget
'; 13010 $opt['opt
'] = $values; 13011 unset($opt['mk
']['ca
']); 13012 unset($opt['mk
']['rc
']); 13013 unset($opt['mk
']['ac
']); 13014 unset($opt['mk
']['i
']); 13015 unset($opt['mk
']['ri
']); 13016 unset($opt['mk
']['ix
']); 13017 unset($opt['mk
']['if']); 13018 unset($opt['mk
']['tp
']); 13019 $this->Annotation($x, $y, $w, $h, $name, $opt, 0); 13042 public function CheckBox($name, $w, $checked=false, $prop=array(), $opt=array(), $onvalue='Yes
', $x='', $y='', $js=false) { 13049 // check page for no-write regions and adapt page margins if necessary 13050 list($x, $y) = $this->checkPageRegions($w, $x, $y); 13052 $this->_addfield('checkbox
', $name, $x, $y, $w, $w, $prop); 13055 if (!isset($prop['value
'])) { 13056 $prop['value
'] = array('Yes
'); 13058 // get default style 13059 $prop = array_merge($this->getFormDefaultProp(), $prop); 13060 $prop['borderStyle
'] = 'inset
'; 13061 // get annotation data 13062 $popt = TCPDF_STATIC::getAnnotOptFromJSProp($prop, $this->spot_colors, $this->rtl); 13063 // set additional default options 13064 $font = 'zapfdingbats
'; 13065 if ($this->pdfa_mode) { 13066 // all fonts must be embedded 13067 $font = 'pdfa
'.$font; 13069 $this->AddFont($font); 13070 $tmpfont = $this->getFontBuffer($font); 13071 $this->annotation_fonts[$tmpfont['fontkey
']] = $tmpfont['i
']; 13072 $fontstyle = sprintf('/F%d %F Tf %
s', $tmpfont['i
'], $this->FontSizePt, $this->TextColor); 13073 $popt['da
'] = $fontstyle; 13074 // build appearance stream 13075 $popt['ap
'] = array(); 13076 $popt['ap
']['n'] = array(); 13077 $fx = ((($w - $this->getAbsFontMeasure($tmpfont['cw
'][110])) / 2) * $this->k); 13078 $fy = (($w - ((($tmpfont['desc
']['Ascent
'] - $tmpfont['desc
']['Descent
']) * $this->FontSizePt / 1000) / $this->k)) * $this->k); 13079 $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);
13080 $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);
13082 $opt = array_merge($popt, $opt);
13084 $opt['Subtype'] = 'Widget';
13085 $opt['ft'] = 'Btn';
13090 $opt[
'opt'] =
array($onvalue);
13092 $opt[
'v'] =
array(
'/Yes');
13093 $opt[
'as'] =
'Yes';
13095 $opt[
'v'] =
array(
'/Off');
13096 $opt[
'as'] =
'Off';
13132 $this->
_addfield(
'button', $name, $this->x, $this->y,
$w,
$h, $prop);
13133 $this->javascript .=
'f'.$name.
".buttonSetCaption('".addslashes($caption).
"');\n";
13134 $this->javascript .=
'f'.$name.
".setAction('MouseUp','".addslashes($action).
"');\n";
13135 $this->javascript .=
'f'.$name.
".highlight='push';\n";
13136 $this->javascript .=
'f'.$name.
".print=false;\n";
13141 $prop[
'Pushbutton'] =
'true';
13142 $prop[
'highlight'] =
'push';
13143 $prop[
'display'] =
'display.noPrint';
13146 $this->annotation_fonts[$this->CurrentFont[
'fontkey']] = $this->CurrentFont[
'i'];
13147 $fontstyle = sprintf(
'/F%d %F Tf %s', $this->CurrentFont[
'i'], $this->FontSizePt, $this->TextColor);
13148 $popt[
'da'] = $fontstyle;
13150 $popt[
'ap'] =
array();
13151 $popt[
'ap'][
'n'] =
'/Tx BMC q '.$fontstyle.
' ';
13155 'L' =>
array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' =>
array(231)),
13156 'R' =>
array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' =>
array(51)),
13157 'T' =>
array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' =>
array(231)),
13158 'B' =>
array(
'width' => $bw,
'cap' =>
'square',
'join' =>
'miter',
'dash' => 0,
'color' =>
array(51)));
13160 $this->
Cell(
$w,
$h, $caption,
$border, 0,
'C',
true,
'', 1,
false,
'T',
'M');
13163 $popt[
'ap'][
'n'] .= $this->xobjects[$tmpid][
'outdata'];
13164 unset($this->xobjects[$tmpid]);
13165 $popt[
'ap'][
'n'] .=
'Q EMC';
13167 if (!isset($popt[
'mk'])) {
13168 $popt[
'mk'] =
array();
13170 $ann_obj_id = ($this->
n + 1);
13171 if (!empty($action) AND !is_array($action)) {
13172 $ann_obj_id = ($this->
n + 2);
13174 $popt[
'mk'][
'ca'] = $this->
_textstring($caption, $ann_obj_id);
13175 $popt[
'mk'][
'rc'] = $this->
_textstring($caption, $ann_obj_id);
13176 $popt[
'mk'][
'ac'] = $this->
_textstring($caption, $ann_obj_id);
13178 $opt = array_merge($popt, $opt);
13180 $opt[
'Subtype'] =
'Widget';
13181 $opt[
'ft'] =
'Btn';
13182 $opt[
't'] = $caption;
13184 if (!empty($action)) {
13185 if (is_array($action)) {
13187 $opt[
'aa'] =
'/D <<';
13188 $bmode =
array(
'SubmitForm',
'ResetForm',
'ImportData');
13189 foreach ($action AS $key => $val) {
13190 if (($key ==
'S') AND in_array($val, $bmode)) {
13191 $opt[
'aa'] .=
' /S /'.$val;
13192 } elseif (($key ==
'F') AND (!empty($val))) {
13193 $opt[
'aa'] .=
' /F '.$this->_datastring($val, $ann_obj_id);
13194 } elseif (($key ==
'Fields') AND is_array($val) AND !empty($val)) {
13195 $opt[
'aa'] .=
' /Fields [';
13196 foreach ($val AS $field) {
13197 $opt[
'aa'] .=
' '.$this->_textstring($field, $ann_obj_id);
13200 } elseif (($key ==
'Flags')) {
13202 if (is_array($val)) {
13203 foreach ($val AS $flag) {
13205 case 'Include/Exclude': {
13209 case 'IncludeNoValueFields': {
13213 case 'ExportFormat': {
13217 case 'GetMethod': {
13221 case 'SubmitCoordinates': {
13229 case 'IncludeAppendSaves': {
13233 case 'IncludeAnnotations': {
13237 case 'SubmitPDF': {
13241 case 'CanonicalFormat': {
13245 case 'ExclNonUserAnnots': {
13253 case 'EmbedForm': {
13260 $ff = intval($val);
13262 $opt[
'aa'] .=
' /Flags '.$ff;
13265 $opt[
'aa'] .=
' >>';
13269 $opt[
'aa'] =
'/D '.$js_obj_id.
' 0 R';
13290 if ((!$this->sign) OR (!isset($this->signature_data[
'cert_type']))) {
13293 $sigobjid = ($this->sig_obj_id + 1);
13295 $out .=
'<< /Type /Sig';
13296 $out .=
' /Filter /Adobe.PPKLite';
13297 $out .=
' /SubFilter /adbe.pkcs7.detached';
13298 $out .=
' '.TCPDF_STATIC::$byterange_string;
13299 $out .=
' /Contents<'.str_repeat(
'0', $this->signature_max_length).
'>';
13300 if (empty($this->signature_data[
'approval']) OR ($this->signature_data[
'approval'] !=
'A')) {
13301 $out .=
' /Reference [';
13302 $out .=
' << /Type /SigRef';
13303 if ($this->signature_data[
'cert_type'] > 0) {
13304 $out .=
' /TransformMethod /DocMDP';
13305 $out .=
' /TransformParams <<';
13306 $out .=
' /Type /TransformParams';
13307 $out .=
' /P '.$this->signature_data[
'cert_type'];
13308 $out .=
' /V /1.2';
13310 $out .=
' /TransformMethod /UR3';
13311 $out .=
' /TransformParams <<';
13312 $out .=
' /Type /TransformParams';
13313 $out .=
' /V /2.2';
13315 $out .=
' /Document['.$this->ur[
'document'].
']';
13318 $out .=
' /Form['.$this->ur[
'form'].
']';
13321 $out .=
' /Signature['.$this->ur[
'signature'].
']';
13324 $out .=
' /Annots['.$this->ur[
'annots'].
']';
13327 $out .=
' /EF['.$this->ur[
'ef'].
']';
13330 $out .=
' /FormEX['.$this->ur[
'formex'].
']';
13343 $out .=
' /Name '.$this->_textstring($this->signature_data[
'info'][
'Name'], $sigobjid);
13345 if (isset($this->signature_data[
'info'][
'Location']) AND !
TCPDF_STATIC::empty_string($this->signature_data[
'info'][
'Location'])) {
13346 $out .=
' /Location '.$this->_textstring($this->signature_data[
'info'][
'Location'], $sigobjid);
13348 if (isset($this->signature_data[
'info'][
'Reason']) AND !
TCPDF_STATIC::empty_string($this->signature_data[
'info'][
'Reason'])) {
13349 $out .=
' /Reason '.$this->_textstring($this->signature_data[
'info'][
'Reason'], $sigobjid);
13351 if (isset($this->signature_data[
'info'][
'ContactInfo']) AND !
TCPDF_STATIC::empty_string($this->signature_data[
'info'][
'ContactInfo'])) {
13352 $out .=
' /ContactInfo '.$this->_textstring($this->signature_data[
'info'][
'ContactInfo'], $sigobjid);
13354 $out .=
' /M '.$this->_datestring($sigobjid, $this->doc_modification_timestamp);
13356 $out .=
"\n".
'endobj';
13379 $document=
'/FullSave',
13380 $annots=
'/Create/Delete/Modify/Copy/Import/Export',
13381 $form=
'/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate',
13382 $signature=
'/Modify',
13383 $ef=
'/Create/Delete/Modify/Import',
13385 $this->ur[
'enabled'] = $enable;
13386 $this->ur[
'document'] = $document;
13387 $this->ur[
'annots'] = $annots;
13388 $this->ur[
'form'] = $form;
13389 $this->ur[
'signature'] = $signature;
13390 $this->ur[
'ef'] = $ef;
13391 $this->ur[
'formex'] = $formex;
13392 if (!$this->sign) {
13414 public function setSignature($signing_cert=
'', $private_key=
'', $private_key_password=
'', $extracerts=
'', $cert_type=2,
$info=
array(), $approval=
'') {
13419 $this->sign =
true;
13423 $this->signature_data =
array();
13424 if (strlen($signing_cert) == 0) {
13425 $this->
Error(
'Please provide a certificate file and password!');
13427 if (strlen($private_key) == 0) {
13428 $private_key = $signing_cert;
13430 $this->signature_data[
'signcert'] = $signing_cert;
13431 $this->signature_data[
'privkey'] = $private_key;
13432 $this->signature_data[
'password'] = $private_key_password;
13433 $this->signature_data[
'extracerts'] = $extracerts;
13434 $this->signature_data[
'cert_type'] = $cert_type;
13435 $this->signature_data[
'info'] =
$info;
13436 $this->signature_data[
'approval'] = $approval;
13487 if ((
$page < 1) OR (
$page > $this->numpages)) {
13490 $sigapp[
'page'] = intval(
$page);
13492 if (empty($name)) {
13493 $sigapp[
'name'] =
'Signature';
13495 $sigapp[
'name'] = $name;
13498 $b = $this->pagedim[($sigapp[
'page'])][
'h'] - ((
$y +
$h) *
$this->k);
13501 $sigapp[
'rect'] = sprintf(
'%F %F %F %F', $a, $b, ($a + $c), ($b +
$d));
13517 public function setTimeStamp($tsa_host=
'', $tsa_username=
'', $tsa_password=
'', $tsa_cert=
'') {
13518 $this->tsa_data =
array();
13519 if (!function_exists(
'curl_init')) {
13520 $this->
Error(
'Please enable cURL PHP extension!');
13522 if (strlen($tsa_host) == 0) {
13523 $this->
Error(
'Please specify the host of Time Stamping Authority (TSA)!');
13525 $this->tsa_data[
'tsa_host'] = $tsa_host;
13526 if (is_file($tsa_username)) {
13527 $this->tsa_data[
'tsa_auth'] = $tsa_username;
13529 $this->tsa_data[
'tsa_username'] = $tsa_username;
13531 $this->tsa_data[
'tsa_password'] = $tsa_password;
13532 $this->tsa_data[
'tsa_cert'] = $tsa_cert;
13533 $this->tsa_timestamp =
true;
13546 if (!$this->tsa_timestamp) {
13561 if (empty(
$page)) {
13562 $page = $this->page + 1;
13574 $this->starting_page_number = max(0, intval($num));
13587 $rep = str_repeat(
' ', $this->
GetNumChars($ref));
13594 $sdiff = sprintf(
'%F', $wdiff);
13597 $alias =
'{'.$alias;
13612 return '{'.TCPDF_STATIC::$alias_tot_pages.
'}';
13627 return '{'.TCPDF_STATIC::$alias_num_page.
'}';
13642 return '{'.TCPDF_STATIC::$alias_group_tot_pages.
'}';
13657 return '{'.TCPDF_STATIC::$alias_group_num_page.
'}';
13698 if (empty($this->pdflayers)) {
13701 foreach ($this->pdflayers as $key => $layer) {
13702 $this->pdflayers[$key][
'objid'] = $this->
_newobj();
13703 $out =
'<< /Type /OCG';
13704 $out .=
' /Name '.$this->_textstring($layer[
'name'], $this->pdflayers[$key][
'objid']);
13705 $out .=
' /Usage <<';
13706 if (isset($layer[
'print']) AND ($layer[
'print'] !== NULL)) {
13707 $out .=
' /Print <</PrintState /'.($layer[
'print']?
'ON':
'OFF').
'>>';
13709 $out .=
' /View <</ViewState /'.($layer[
'view']?
'ON':
'OFF').
'>>';
13711 $out .=
"\n".
'endobj';
13725 public function startLayer($name=
'', $print=
true, $view=
true, $lock=
true) {
13726 if ($this->state != 2) {
13729 $layer = sprintf(
'LYR%03d', (count($this->pdflayers) + 1));
13730 if (empty($name)) {
13733 $name = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $name);
13735 $this->pdflayers[] =
array(
'layer' => $layer,
'name' => $name,
'print' => $print,
'view' => $view,
'lock' => $lock);
13736 $this->openMarkedContent =
true;
13737 $this->
_out(
'/OC /'.$layer.
' BDC');
13746 if ($this->state != 2) {
13749 if ($this->openMarkedContent) {
13751 $this->
_out(
'EMC');
13752 $this->openMarkedContent =
false;
13765 if ($this->state != 2) {
13784 $this->
Error(
'Incorrect visibility: '.$v);
13798 if ($this->pdfa_mode) {
13803 foreach ($this->extgstates as $i => $ext) {
13804 if ($ext[
'parms'] == $parms) {
13805 if ($this->inxobj) {
13813 $n = (count($this->extgstates) + 1);
13814 $this->extgstates[
$n] =
array(
'parms' => $parms);
13815 if ($this->inxobj) {
13829 if ($this->pdfa_mode OR ($this->state != 2)) {
13833 $this->
_out(sprintf(
'/GS%d gs', $gs));
13842 foreach ($this->extgstates as $i => $ext) {
13843 $this->extgstates[$i][
'n'] = $this->
_newobj();
13844 $out =
'<< /Type /ExtGState';
13845 foreach ($ext[
'parms'] as
$k => $v) {
13846 if (is_float($v)) {
13847 $v = sprintf(
'%F', $v);
13848 } elseif ($v ===
true) {
13850 } elseif ($v ===
false) {
13853 $out .=
' /'.$k.
' '.$v;
13856 $out .=
"\n".
'endobj';
13871 if ($this->state != 2) {
13874 $stroking = $stroking ? true :
false;
13877 $nonstroking = $stroking;
13879 $nonstroking = $nonstroking ? true :
false;
13881 if (($mode != 0) AND ($mode != 1)) {
13884 $this->overprint =
array(
'OP' => $stroking,
'op' => $nonstroking,
'OPM' => $mode);
13909 public function setAlpha($stroking=1, $bm=
'Normal', $nonstroking=
'', $ais=
false) {
13910 if ($this->pdfa_mode) {
13914 $stroking = floatval($stroking);
13917 $nonstroking = $stroking;
13919 $nonstroking = floatval($nonstroking);
13921 if ($bm[0] ==
'/') {
13923 $bm = substr($bm, 1);
13925 if (!in_array($bm,
array(
'Normal',
'Multiply',
'Screen',
'Overlay',
'Darken',
'Lighten',
'ColorDodge',
'ColorBurn',
'HardLight',
'SoftLight',
'Difference',
'Exclusion',
'Hue',
'Saturation',
'Color',
'Luminosity'))) {
13928 $ais = $ais ? true :
false;
13929 $this->alpha =
array(
'CA' => $stroking,
'ca' => $nonstroking,
'BM' =>
'/'.$bm,
'AIS' => $ais);
13952 if (($quality < 1) OR ($quality > 100)) {
13955 $this->jpeg_quality = intval($quality);
13965 $this->default_table_columns = intval($cols);
13975 $this->cell_height_ratio =
$h;
13994 if ($this->pdfa_mode) {
13996 $this->PDFVersion =
'1.4';
14028 public function colorRegistrationBar(
$x,
$y,
$w,
$h, $transition=
true, $vertical=
false, $colors=
'A,R,G,B,C,M,Y,K') {
14029 if (strpos($colors,
'ALLSPOT') !==
false) {
14032 foreach ($this->spot_colors as $spot_color_name => $v) {
14037 $colors = str_replace(
'ALLSPOT',
$spot_colors, $colors);
14039 $colors = str_replace(
'ALLSPOT',
'NONE', $colors);
14042 $bars = explode(
',', $colors);
14043 $numbars = count($bars);
14044 if ($numbars <= 0) {
14050 $wb =
$w / $numbars;
14057 $hb =
$h / $numbars;
14063 foreach ($bars as $col) {
14067 $col_a =
array(255);
14073 $col_b =
array(255);
14077 $col_a =
array(255,255,255);
14078 $col_b =
array(255,0,0);
14082 $col_a =
array(255,255,255);
14083 $col_b =
array(0,255,0);
14087 $col_a =
array(255,255,255);
14088 $col_b =
array(0,0,255);
14092 $col_a =
array(0,0,0,0);
14093 $col_b =
array(100,0,0,0);
14097 $col_a =
array(0,0,0,0);
14098 $col_b =
array(0,100,0,0);
14102 $col_a =
array(0,0,0,0);
14103 $col_b =
array(0,0,100,0);
14107 $col_a =
array(0,0,0,0);
14108 $col_b =
array(0,0,0,100);
14112 $col_a =
array(255,255,255);
14113 $col_b =
array(0,0,0);
14117 $col_a =
array(0,0,0,0);
14118 $col_b =
array(100,100,100,100);
14122 $col_a =
array(0,0,0,0,
'None');
14123 $col_b =
array(100,100,100,100,
'All');
14127 $col_a =
array(0,0,0,0,
'None');
14128 $col_b =
array(0,0,0,0,
'None');
14132 $col_a =
array(0,0,0,0,
'None');
14134 if ($col_b ===
false) {
14136 $col_b =
array(100,100,100,100,
'All');
14141 if ($col !=
'NONE') {
14148 $this->
Rect($xb, $yb, $wb, $hb,
'F',
array());
14168 public function cropMark(
$x,
$y,
$w,
$h, $type=
'T,R,B,L', $color=
array(100,100,100,100,
'All')) {
14169 $this->
SetLineStyle(
array(
'width' => (0.5 / $this->k),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $color));
14170 $type = strtoupper($type);
14171 $type = preg_replace(
'/[^A-Z\-\,]*/',
'', $type);
14173 $type = str_replace(
'-',
',', $type);
14174 $type = str_replace(
'TL',
'T,L', $type);
14175 $type = str_replace(
'TR',
'T,R', $type);
14176 $type = str_replace(
'BL',
'F,L', $type);
14177 $type = str_replace(
'BR',
'F,R', $type);
14178 $type = str_replace(
'A',
'T,L', $type);
14179 $type = str_replace(
'B',
'T,R', $type);
14180 $type = str_replace(
'T,RO',
'BO', $type);
14181 $type = str_replace(
'C',
'F,L', $type);
14182 $type = str_replace(
'D',
'F,R', $type);
14183 $crops = explode(
',', strtoupper($type));
14185 $crops = array_unique($crops);
14188 foreach ($crops as $crop) {
14223 $this->
Line($x1, $y1, $x2, $y2);
14239 public function registrationMark(
$x,
$y,
$r, $double=
false, $cola=
array(100,100,100,100,
'All'), $colb=
array(0,0,0,0,
'None')) {
14240 $line_style =
array(
'width' => max((0.5 / $this->k),(
$r / 30)),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $cola);
14268 $lw = max((0.5 / $this->k),(
$r / 8));
14286 $line_style =
array(
'width' => $lw,
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' =>
array(100,100,100,100,
'All'));
14328 public function RadialGradient(
$x,
$y,
$w,
$h, $col1=
array(), $col2=
array(),
$coords=
array(0.5,0.5,0.5,0.5,1)) {
14351 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) {
14352 if ($this->pdfa_mode OR ($this->state != 2)) {
14356 $n = count($this->gradients) + 1;
14357 $this->gradients[
$n] =
array();
14358 $this->gradients[
$n][
'type'] = 6;
14359 $this->gradients[
$n][
'coords'] =
array();
14360 $this->gradients[
$n][
'antialias'] = $antialias;
14361 $this->gradients[
$n][
'colors'] =
array();
14362 $this->gradients[
$n][
'transparency'] =
false;
14364 if (!isset(
$coords[0][
'f'])) {
14366 if (!isset($col1[1])) {
14367 $col1[1] = $col1[2] = $col1[0];
14369 if (!isset($col2[1])) {
14370 $col2[1] = $col2[2] = $col2[0];
14372 if (!isset($col3[1])) {
14373 $col3[1] = $col3[2] = $col3[0];
14375 if (!isset($col4[1])) {
14376 $col4[1] = $col4[2] = $col4[0];
14398 $this->gradients[
$n][
'stream'] =
'';
14400 for ($i=0; $i < $count_patch; ++$i) {
14403 for ($j=0; $j < $count_points; ++$j) {
14412 $this->gradients[
$n][
'stream'] .= chr(floor(
$patch_array[$i][
'points'][$j] / 256));
14413 $this->gradients[
$n][
'stream'] .= chr(floor(
$patch_array[$i][
'points'][$j] % 256));
14416 for ($j=0; $j < $count_cols; ++$j) {
14418 $this->gradients[
$n][
'stream'] .= chr(
$patch_array[$i][
'colors'][$j][
'r']);
14419 $this->gradients[
$n][
'stream'] .= chr(
$patch_array[$i][
'colors'][$j][
'g']);
14420 $this->gradients[
$n][
'stream'] .= chr(
$patch_array[$i][
'colors'][$j][
'b']);
14424 $this->
_out(
'/Sh'.
$n.
' sh');
14427 if ($this->inxobj) {
14444 if ($this->state != 2) {
14448 $x = $this->w -
$x -
$w;
14453 $s .= sprintf(
' %F %F %F %F re W n',
$x*$this->k, ($this->h-
$y)*$this->k,
$w*$this->k, -
$h*$this->k);
14455 $s .= sprintf(
' %F 0 0 %F %F %F cm',
$w*$this->k,
$h*$this->k,
$x*$this->k, ($this->h-(
$y+
$h))*$this->k);
14471 if ($this->pdfa_mode OR ($this->state != 2)) {
14474 $n = count($this->gradients) + 1;
14475 $this->gradients[
$n] =
array();
14476 $this->gradients[
$n][
'type'] = $type;
14477 $this->gradients[
$n][
'coords'] =
$coords;
14478 $this->gradients[
$n][
'antialias'] = $antialias;
14479 $this->gradients[
$n][
'colors'] =
array();
14480 $this->gradients[
$n][
'transparency'] =
false;
14482 $numcolspace = count($stops[0][
'color']);
14483 $bcolor = array_values($background);
14484 switch($numcolspace) {
14487 $this->gradients[
$n][
'colspace'] =
'DeviceCMYK';
14488 if (!empty($background)) {
14489 $this->gradients[
$n][
'background'] = sprintf(
'%F %F %F %F', $bcolor[0]/100, $bcolor[1]/100, $bcolor[2]/100, $bcolor[3]/100);
14494 $this->gradients[
$n][
'colspace'] =
'DeviceRGB';
14495 if (!empty($background)) {
14496 $this->gradients[
$n][
'background'] = sprintf(
'%F %F %F', $bcolor[0]/255, $bcolor[1]/255, $bcolor[2]/255);
14501 $this->gradients[
$n][
'colspace'] =
'DeviceGray';
14502 if (!empty($background)) {
14503 $this->gradients[
$n][
'background'] = sprintf(
'%F', $bcolor[0]/255);
14508 $num_stops = count($stops);
14509 $last_stop_id = $num_stops - 1;
14510 foreach ($stops as $key => $stop) {
14511 $this->gradients[
$n][
'colors'][$key] =
array();
14513 if (isset($stop[
'offset'])) {
14514 $this->gradients[
$n][
'colors'][$key][
'offset'] = $stop[
'offset'];
14517 $this->gradients[
$n][
'colors'][$key][
'offset'] = 0;
14518 } elseif ($key == $last_stop_id) {
14519 $this->gradients[
$n][
'colors'][$key][
'offset'] = 1;
14521 $offsetstep = (1 - $this->gradients[
$n][
'colors'][($key - 1)][
'offset']) / ($num_stops - $key);
14522 $this->gradients[
$n][
'colors'][$key][
'offset'] = $this->gradients[
$n][
'colors'][($key - 1)][
'offset'] + $offsetstep;
14525 if (isset($stop[
'opacity'])) {
14526 $this->gradients[
$n][
'colors'][$key][
'opacity'] = $stop[
'opacity'];
14527 if ((!$this->pdfa_mode) AND ($stop[
'opacity'] < 1)) {
14528 $this->gradients[
$n][
'transparency'] =
true;
14531 $this->gradients[
$n][
'colors'][$key][
'opacity'] = 1;
14534 if (isset($stop[
'exponent'])) {
14535 $this->gradients[
$n][
'colors'][$key][
'exponent'] = $stop[
'exponent'];
14537 $this->gradients[
$n][
'colors'][$key][
'exponent'] = 1;
14540 $color = array_values($stop[
'color']);
14541 switch($numcolspace) {
14544 $this->gradients[
$n][
'colors'][$key][
'color'] = sprintf(
'%F %F %F %F', $color[0]/100, $color[1]/100, $color[2]/100, $color[3]/100);
14548 $this->gradients[
$n][
'colors'][$key][
'color'] = sprintf(
'%F %F %F', $color[0]/255, $color[1]/255, $color[2]/255);
14552 $this->gradients[
$n][
'colors'][$key][
'color'] = sprintf(
'%F', $color[0]/255);
14557 if ($this->gradients[
$n][
'transparency']) {
14559 $this->
_out(
'/TGS'.$n.
' gs');
14562 $this->
_out(
'/Sh'.$n.
' sh');
14565 if ($this->inxobj) {
14578 if ($this->pdfa_mode) {
14581 $idt = count($this->gradients);
14582 foreach ($this->gradients as $id => $grad) {
14583 if (($grad[
'type'] == 2) OR ($grad[
'type'] == 3)) {
14586 $out .=
' /FunctionType 3';
14587 $out .=
' /Domain [0 1]';
14592 $num_cols = count($grad[
'colors']);
14593 $lastcols = $num_cols - 1;
14594 for ($i = 1; $i < $num_cols; ++$i) {
14595 $functions .= ($fc + $i).
' 0 R ';
14596 if ($i < $lastcols) {
14597 $bounds .= sprintf(
'%F ', $grad[
'colors'][$i][
'offset']);
14601 $out .=
' /Functions ['.trim($functions).
']';
14602 $out .=
' /Bounds ['.trim($bounds).
']';
14603 $out .=
' /Encode ['.trim($encode).
']';
14605 $out .=
"\n".
'endobj';
14607 for ($i = 1; $i < $num_cols; ++$i) {
14610 $out .=
' /FunctionType 2';
14611 $out .=
' /Domain [0 1]';
14612 $out .=
' /C0 ['.$grad[
'colors'][($i - 1)][
'color'].
']';
14613 $out .=
' /C1 ['.$grad[
'colors'][$i][
'color'].
']';
14614 $out .=
' /N '.$grad[
'colors'][$i][
'exponent'];
14616 $out .=
"\n".
'endobj';
14620 if ($grad[
'transparency']) {
14623 $out .=
' /FunctionType 3';
14624 $out .=
' /Domain [0 1]';
14627 $num_cols = count($grad[
'colors']);
14628 for ($i = 1; $i < $num_cols; ++$i) {
14629 $functions .= ($ft + $i).
' 0 R ';
14631 $out .=
' /Functions ['.trim($functions).
']';
14632 $out .=
' /Bounds ['.trim($bounds).
']';
14633 $out .=
' /Encode ['.trim($encode).
']';
14635 $out .=
"\n".
'endobj';
14637 for ($i = 1; $i < $num_cols; ++$i) {
14640 $out .=
' /FunctionType 2';
14641 $out .=
' /Domain [0 1]';
14642 $out .=
' /C0 ['.$grad[
'colors'][($i - 1)][
'opacity'].
']';
14643 $out .=
' /C1 ['.$grad[
'colors'][$i][
'opacity'].
']';
14644 $out .=
' /N '.$grad[
'colors'][$i][
'exponent'];
14646 $out .=
"\n".
'endobj';
14653 $out =
'<< /ShadingType '.$grad[
'type'];
14654 if (isset($grad[
'colspace'])) {
14655 $out .=
' /ColorSpace /'.$grad[
'colspace'];
14657 $out .=
' /ColorSpace /DeviceRGB';
14659 if (isset($grad[
'background']) AND !empty($grad[
'background'])) {
14660 $out .=
' /Background ['.$grad[
'background'].
']';
14662 if (isset($grad[
'antialias']) AND ($grad[
'antialias'] ===
true)) {
14663 $out .=
' /AntiAlias true';
14665 if ($grad[
'type'] == 2) {
14666 $out .=
' '.sprintf(
'/Coords [%F %F %F %F]', $grad[
'coords'][0], $grad[
'coords'][1], $grad[
'coords'][2], $grad[
'coords'][3]);
14667 $out .=
' /Domain [0 1]';
14668 $out .=
' /Function '.$fc.
' 0 R';
14669 $out .=
' /Extend [true true]';
14671 } elseif ($grad[
'type'] == 3) {
14674 $out .=
' '.sprintf(
'/Coords [%F %F 0 %F %F %F]', $grad[
'coords'][0], $grad[
'coords'][1], $grad[
'coords'][2], $grad[
'coords'][3], $grad[
'coords'][4]);
14675 $out .=
' /Domain [0 1]';
14676 $out .=
' /Function '.$fc.
' 0 R';
14677 $out .=
' /Extend [true true]';
14679 } elseif ($grad[
'type'] == 6) {
14680 $out .=
' /BitsPerCoordinate 16';
14681 $out .=
' /BitsPerComponent 8';
14682 $out .=
' /Decode[0 1 0 1 0 1 0 1 0 1]';
14683 $out .=
' /BitsPerFlag 8';
14685 $out .=
' /Length '.strlen($stream);
14687 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
14689 $out .=
"\n".
'endobj';
14691 if ($grad[
'transparency']) {
14692 $shading_transparency = preg_replace(
'/\/ColorSpace \/[^\s]+/si',
'/ColorSpace /DeviceGray',
$out);
14693 $shading_transparency = preg_replace(
'/\/Function [0-9]+ /si',
'/Function '.$ft.
' ', $shading_transparency);
14695 $this->gradients[$id][
'id'] =
$this->n;
14698 $out =
'<< /Type /Pattern /PatternType 2';
14699 $out .=
' /Shading '.$this->gradients[$id][
'id'].
' 0 R';
14701 $out .=
"\n".
'endobj';
14703 $this->gradients[$id][
'pattern'] =
$this->n;
14705 if ($grad[
'transparency']) {
14707 $idgs = $id + $idt;
14709 $this->
_out($shading_transparency);
14710 $this->gradients[$idgs][
'id'] =
$this->n;
14712 $out =
'<< /Type /Pattern /PatternType 2';
14713 $out .=
' /Shading '.$this->gradients[$idgs][
'id'].
' 0 R';
14715 $out .=
"\n".
'endobj';
14717 $this->gradients[$idgs][
'pattern'] =
$this->n;
14720 $this->xobjects[
'LX'.$oid] =
array(
'n' => $oid);
14722 $stream =
'q /a0 gs /Pattern cs /p'.$idgs.
' scn 0 0 '.$this->wPt.
' '.$this->hPt.
' re f Q';
14723 if ($this->compress) {
14724 $filter =
' /Filter /FlateDecode';
14725 $stream = gzcompress($stream);
14728 $out =
'<< /Type /XObject /Subtype /Form /FormType 1'.$filter;
14729 $out .=
' /Length '.strlen($stream);
14730 $rect = sprintf(
'%F %F', $this->wPt, $this->hPt);
14731 $out .=
' /BBox [0 0 '.$rect.
']';
14732 $out .=
' /Group << /Type /Group /S /Transparency /CS /DeviceGray >>';
14733 $out .=
' /Resources <<';
14734 $out .=
' /ExtGState << /a0 << /ca 1 /CA 1 >> >>';
14735 $out .=
' /Pattern << /p'.$idgs.
' '.$this->gradients[$idgs][
'pattern'].
' 0 R >>';
14738 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
14739 $out .=
"\n".
'endobj';
14743 $out =
'<< /Type /Mask /S /Luminosity /G '.($this->n - 1).
' 0 R >>'.
"\n".
'endobj';
14747 $out =
'<< /Type /ExtGState /SMask '.($this->n - 1).
' 0 R /AIS false >>'.
"\n".
'endobj';
14749 $this->extgstates[] =
array(
'n' => $this->
n,
'name' =>
'TGS'.$id);
14791 if ($this->state != 2) {
14799 $line_style =
array();
14803 $b = (360 - $a + $o);
14804 $a = (360 -
$d + $o);
14834 public function ImageEps(
$file,
$x=
'',
$y=
'',
$w=0,
$h=0, $link=
'', $useBoundingBox=
true, $align=
'', $palign=
'',
$border=0, $fitonpage=
false, $fixoutvals=
false) {
14835 if ($this->state != 2) {
14838 if ($this->rasterize_vector_images AND (
$w > 0) AND (
$h > 0)) {
14840 return $this->
Image(
$file,
$x,
$y,
$w,
$h,
'EPS', $link, $align,
true, 300, $palign,
false,
false,
$border,
false,
false, $fitonpage);
14851 if (
$file[0] ===
'@') {
14856 if (
$data === FALSE) {
14861 preg_match(
"/%%Creator:([^\r\n]+)/",
$data, $regs); # find Creator
14862 if (count($regs) > 1) {
14863 $version_str = trim($regs[1]); #
e.g.
"Adobe Illustrator(R) 8.0" 14864 if (strpos($version_str,
'Adobe Illustrator') !==
false) {
14865 $versexp = explode(
' ', $version_str);
14866 $version = (float)array_pop($versexp);
14868 $this->
Error(
'This version of Adobe Illustrator file is not supported: '.
$file);
14878 preg_match(
"/%%BoundingBox:([^\r\n]+)/",
$data, $regs);
14879 if (count($regs) > 1) {
14880 list($x1, $y1, $x2, $y2) = explode(
' ', trim($regs[1]));
14882 $this->
Error(
'No BoundingBox found in EPS/AI file: '.
$file);
14892 $end = strpos(
$data,
'%%PageTrailer');
14893 if ($end===
false) {
14894 $end = strpos(
$data,
'showpage');
14900 if ((
$w <= 0) AND (
$h <= 0)) {
14901 $w = ($x2 - $x1) /
$k;
14902 $h = ($y2 - $y1) /
$k;
14903 } elseif (
$w <= 0) {
14904 $w = ($x2-$x1) /
$k * (
$h / (($y2 - $y1) /
$k));
14905 } elseif (
$h <= 0) {
14906 $h = ($y2 - $y1) /
$k * (
$w / (($x2 - $x1) /
$k));
14910 if ($this->rasterize_vector_images) {
14912 return $this->
Image(
$file,
$x,
$y,
$w,
$h,
'EPS', $link, $align,
true, 300, $palign,
false,
false,
$border,
false,
false, $fitonpage);
14915 $scale_x =
$w / (($x2 - $x1) /
$k);
14916 $scale_y =
$h / (($y2 - $y1) /
$k);
14918 $this->img_rb_y =
$y +
$h;
14921 if ($palign ==
'L') {
14923 } elseif ($palign ==
'C') {
14924 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
14925 } elseif ($palign ==
'R') {
14926 $ximg = $this->w - $this->rMargin -
$w;
14930 $this->img_rb_x = $ximg;
14932 if ($palign ==
'L') {
14934 } elseif ($palign ==
'C') {
14935 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
14936 } elseif ($palign ==
'R') {
14937 $ximg = $this->w - $this->rMargin -
$w;
14941 $this->img_rb_x = $ximg +
$w;
14943 if ($useBoundingBox) {
14944 $dx = $ximg *
$k - $x1;
14945 $dy =
$y *
$k - $y1;
14951 $this->
_out(
'q'.$this->epsmarker);
14953 $this->
_out(sprintf(
'%F %F %F %F %F %F cm', 1, 0, 0, 1, $dx, $dy + ($this->hPt - (2 *
$y *
$k) - ($y2 - $y1))));
14955 if (isset($scale_x)) {
14956 $this->
_out(sprintf(
'%F %F %F %F %F %F cm', $scale_x, 0, 0, $scale_y, $x1 * (1 - $scale_x), $y2 * (1 - $scale_y)));
14959 $lines = preg_split(
'/[\r\n]+/si',
$data, -1, PREG_SPLIT_NO_EMPTY);
14961 $cnt = count($lines);
14962 for ($i=0; $i < $cnt; ++$i) {
14963 $line = $lines[$i];
14964 if (($line ==
'') OR ($line[0] ==
'%')) {
14967 $len = strlen($line);
14970 if (strcasecmp(
'x', substr(trim($line), -1)) == 0) {
14971 if (preg_match(
'/\([^\)]*\)/', $line, $matches) > 0) {
14973 $color_name = $matches[0];
14975 $line = str_replace(
' '.$color_name,
'', $line);
14977 $color_name = substr($color_name, 1, -1);
14980 $chunks = explode(
' ', $line);
14981 $cmd = trim(array_pop($chunks));
14983 if ((
$cmd ==
'Xa') OR (
$cmd ==
'XA')) {
14984 $b = array_pop($chunks);
14985 $g = array_pop($chunks);
14986 $r = array_pop($chunks);
14987 $this->
_out(
''.
$r.
' '.$g.
' '.$b.
' '.(
$cmd==
'Xa'?
'rg':
'RG'));
14998 foreach ($chunks as $key => $val) {
14999 if ((($key % 2) == 0) AND (($val < $x1) OR ($val > $x2))) {
15001 } elseif ((($key % 2) != 0) AND (($val < $y1) OR ($val > $y2))) {
15029 $this->
_out($line);
15033 if (empty($color_name)) {
15035 list($col_c, $col_m, $col_y, $col_k) = $chunks;
15036 $this->
_out(
''.$col_c.
' '.$col_m.
' '.$col_y.
' '.$col_k.
' k');
15039 list($col_c, $col_m, $col_y, $col_k, $col_t) = $chunks;
15040 $this->
AddSpotColor($color_name, ($col_c * 100), ($col_m * 100), ($col_y * 100), ($col_k * 100));
15041 $color_cmd = sprintf(
'/CS%d cs %F scn', $this->spot_colors[$color_name][
'i'], (1 - $col_t));
15042 $this->
_out($color_cmd);
15047 if (empty($color_name)) {
15049 list($col_c, $col_m, $col_y, $col_k) = $chunks;
15050 $this->
_out(
''.$col_c.
' '.$col_m.
' '.$col_y.
' '.$col_k.
' K');
15053 list($col_c, $col_m, $col_y, $col_k, $col_t) = $chunks;
15054 $this->
AddSpotColor($color_name, ($col_c * 100), ($col_m * 100), ($col_y * 100), ($col_k * 100));
15055 $color_cmd = sprintf(
'/CS%d CS %F SCN', $this->spot_colors[$color_name][
'i'], (1 - $col_t));
15056 $this->
_out($color_cmd);
15068 $line[($len - 1)] = strtolower(
$cmd);
15069 $this->
_out($line);
15081 $max = min(($i + 5), $cnt);
15082 for ($j = ($i + 1); $j < $max; ++$j) {
15083 $isU = ($isU OR (($lines[$j] ==
'U') OR ($lines[$j] ==
'*U')));
15104 $this->
_out($this->epsmarker.
'Q');
15118 $this->
Link($ximg,
$y,
$w, $h, $link, 0);
15128 $this->y =
$y + round($h/2);
15138 $this->
SetY($this->img_rb_y);
15154 $this->barcode = $bc;
15201 require_once(dirname(__FILE__).
'/tcpdf_barcodes_1d.php');
15207 if (($arrcode ===
false) OR empty($arrcode) OR ($arrcode[
'maxw'] <= 0)) {
15208 $this->
Error(
'Error in 1D barcode string');
15210 if ($arrcode[
'maxh'] <= 0) {
15211 $arrcode[
'maxh'] = 1;
15214 if (!isset(
$style[
'position'])) {
15215 $style[
'position'] =
'';
15216 } elseif (
$style[
'position'] ==
'S') {
15218 $style[
'position'] =
'';
15219 $style[
'stretch'] =
true;
15221 if (!isset(
$style[
'fitwidth'])) {
15222 if (!isset(
$style[
'stretch'])) {
15223 $style[
'fitwidth'] =
true;
15225 $style[
'fitwidth'] =
false;
15228 if (
$style[
'fitwidth']) {
15230 $style[
'stretch'] =
false;
15232 if (!isset(
$style[
'stretch'])) {
15233 if ((
$w ===
'') OR (
$w <= 0)) {
15234 $style[
'stretch'] =
false;
15236 $style[
'stretch'] =
true;
15239 if (!isset(
$style[
'fgcolor'])) {
15242 if (!isset(
$style[
'bgcolor'])) {
15243 $style[
'bgcolor'] =
false;
15245 if (!isset(
$style[
'border'])) {
15246 $style[
'border'] =
false;
15249 if (!isset(
$style[
'text'])) {
15253 if (isset(
$style[
'fontsize'])) {
15254 $fontsize =
$style[
'fontsize'];
15258 if (!isset(
$style[
'stretchtext'])) {
15259 $style[
'stretchtext'] = 4;
15269 if ((
$w ===
'') OR (
$w <= 0)) {
15273 $w = $this->w - $this->rMargin -
$x;
15277 if (!isset(
$style[
'padding'])) {
15279 } elseif (
$style[
'padding'] ===
'auto') {
15280 $padding = 10 * (
$w / ($arrcode[
'maxw'] + 20));
15282 $padding = floatval(
$style[
'padding']);
15285 if (!isset(
$style[
'hpadding'])) {
15286 $hpadding = $padding;
15287 } elseif (
$style[
'hpadding'] ===
'auto') {
15288 $hpadding = 10 * (
$w / ($arrcode[
'maxw'] + 20));
15290 $hpadding = floatval(
$style[
'hpadding']);
15293 if (!isset(
$style[
'vpadding'])) {
15294 $vpadding = $padding;
15295 } elseif (
$style[
'vpadding'] ===
'auto') {
15296 $vpadding = ($hpadding / 2);
15298 $vpadding = floatval(
$style[
'vpadding']);
15301 $max_xres = (
$w - (2 * $hpadding)) / $arrcode[
'maxw'];
15302 if (
$style[
'stretch']) {
15308 if ($xres > $max_xres) {
15312 if ((isset(
$style[
'padding']) AND (
$style[
'padding'] ===
'auto'))
15313 OR (isset(
$style[
'hpadding']) AND (
$style[
'hpadding'] ===
'auto'))) {
15314 $hpadding = 10 * $xres;
15315 if (isset(
$style[
'vpadding']) AND (
$style[
'vpadding'] ===
'auto')) {
15316 $vpadding = ($hpadding / 2);
15320 if (
$style[
'fitwidth']) {
15322 $w = (($arrcode[
'maxw'] * $xres) + (2 * $hpadding));
15323 if (isset(
$style[
'cellfitalign'])) {
15324 switch (
$style[
'cellfitalign']) {
15327 $x -= ($wold -
$w);
15333 $x += ($wold -
$w);
15339 $x -= (($wold -
$w) / 2);
15341 $x += (($wold -
$w) / 2);
15353 if ((
$h ===
'') OR (
$h <= 0)) {
15355 $h = (($arrcode[
'maxw'] * $xres) / 3) + (2 * $vpadding) + $text_height;
15357 $barh =
$h - $text_height - (2 * $vpadding);
15360 if ($text_height >
$h) {
15361 $fontsize = ((
$h *
$this->k) / (4 * $this->cell_height_ratio));
15365 if ($vpadding > 0) {
15366 $vpadding = ((
$h - $text_height) / 4);
15368 $barh =
$h - $text_height - (2 * $vpadding);
15373 $this->img_rb_y =
$y +
$h;
15376 if (
$style[
'position'] ==
'L') {
15378 } elseif (
$style[
'position'] ==
'C') {
15379 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15380 } elseif (
$style[
'position'] ==
'R') {
15381 $xpos = $this->w - $this->rMargin -
$w;
15385 $this->img_rb_x = $xpos;
15387 if (
$style[
'position'] ==
'L') {
15389 } elseif (
$style[
'position'] ==
'C') {
15390 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15391 } elseif (
$style[
'position'] ==
'R') {
15392 $xpos = $this->w - $this->rMargin -
$w;
15396 $this->img_rb_x = $xpos +
$w;
15398 $xpos_rect = $xpos;
15399 if (!isset(
$style[
'align'])) {
15402 switch (
$style[
'align']) {
15404 $xpos = $xpos_rect + $hpadding;
15408 $xpos = $xpos_rect + (
$w - ($arrcode[
'maxw'] * $xres)) - $hpadding;
15413 $xpos = $xpos_rect + ((
$w - ($arrcode[
'maxw'] * $xres)) / 2);
15417 $xpos_text = $xpos;
15420 $this->rtl =
false;
15422 if (
$style[
'bgcolor']) {
15424 } elseif (
$style[
'border']) {
15425 $this->
Rect($xpos_rect,
$y,
$w, $h,
'D');
15431 foreach ($arrcode[
'bcode'] as
$k => $v) {
15432 $bw = ($v[
'w'] * $xres);
15435 $ypos =
$y + $vpadding + ($v[
'p'] * $barh / $arrcode[
'maxh']);
15436 $this->
Rect($xpos, $ypos, $bw, ($v[
'h'] * $barh / $arrcode[
'maxh']),
'F',
array(),
$style[
'fgcolor']);
15443 $label =
$style[
'label'];
15447 $txtwidth = ($arrcode[
'maxw'] * $xres);
15449 $style[
'stretchtext'] = 2;
15452 $this->x = $xpos_text;
15453 $this->y =
$y + $vpadding + $barh;
15456 $this->
Cell($txtwidth,
'', $label, 0, 0,
'C',
false,
'',
$style[
'stretchtext'],
false,
'T',
'T');
15457 $this->cell_padding = $cellpadding;
15460 $this->rtl = $tempRTL;
15471 $this->y =
$y + round($h / 2);
15481 $this->
SetY($this->img_rb_y);
15520 require_once(dirname(__FILE__).
'/tcpdf_barcodes_2d.php');
15526 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)) {
15527 $this->
Error(
'Error in 2D barcode string');
15530 if (!isset(
$style[
'position'])) {
15531 $style[
'position'] =
'';
15533 if (!isset(
$style[
'fgcolor'])) {
15536 if (!isset(
$style[
'bgcolor'])) {
15537 $style[
'bgcolor'] =
false;
15539 if (!isset(
$style[
'border'])) {
15540 $style[
'border'] =
false;
15543 if (!isset(
$style[
'padding'])) {
15545 } elseif (
$style[
'padding'] ===
'auto') {
15548 if (!isset(
$style[
'hpadding'])) {
15550 } elseif (
$style[
'hpadding'] ===
'auto') {
15553 if (!isset(
$style[
'vpadding'])) {
15555 } elseif (
$style[
'vpadding'] ===
'auto') {
15558 $hpad = (2 *
$style[
'hpadding']);
15559 $vpad = (2 *
$style[
'vpadding']);
15561 if (!isset(
$style[
'module_width'])) {
15562 $style[
'module_width'] = 1;
15564 if (!isset(
$style[
'module_height'])) {
15565 $style[
'module_height'] = 1;
15576 $rows = $arrcode[
'num_rows'];
15577 $cols = $arrcode[
'num_cols'];
15578 if (($rows <= 0) || ($cols <= 0)){
15579 $this->
Error(
'Error in 2D barcode string');
15582 $mw =
$style[
'module_width'];
15583 $mh =
$style[
'module_height'];
15584 if (($mw <= 0) OR ($mh <= 0)) {
15585 $this->
Error(
'Error in 2D barcode string');
15591 $maxw = $this->w - $this->rMargin -
$x;
15594 $ratioHW = ((($rows * $mh) + $hpad) / (($cols * $mw) + $vpad));
15595 $ratioWH = ((($cols * $mw) + $vpad) / (($rows * $mh) + $hpad));
15597 if (($maxw * $ratioHW) > $maxh) {
15598 $maxw = $maxh * $ratioWH;
15600 if (($maxh * $ratioWH) > $maxw) {
15601 $maxh = $maxw * $ratioHW;
15612 if (((
$w ===
'') OR (
$w <= 0)) AND ((
$h ===
'') OR (
$h <= 0))) {
15613 $w = ($cols + $hpad) * ($mw / $this->k);
15614 $h = ($rows + $vpad) * ($mh / $this->k);
15615 } elseif ((
$w ===
'') OR (
$w <= 0)) {
15616 $w =
$h * $ratioWH;
15617 } elseif ((
$h ===
'') OR (
$h <= 0)) {
15618 $h =
$w * $ratioHW;
15621 $bw = (
$w * $cols) / ($cols + $hpad);
15622 $bh = (
$h * $rows) / ($rows + $vpad);
15627 if (($cw / $ch) > ($mw / $mh)) {
15629 $cw = $ch * $mw / $mh;
15631 $style[
'hpadding'] = (
$w - $bw) / (2 * $cw);
15634 $ch = $cw * $mh / $mw;
15636 $style[
'vpadding'] = (
$h - $bh) / (2 * $ch);
15642 $this->img_rb_y =
$y +
$h;
15645 if (
$style[
'position'] ==
'L') {
15647 } elseif (
$style[
'position'] ==
'C') {
15648 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15649 } elseif (
$style[
'position'] ==
'R') {
15650 $xpos = $this->w - $this->rMargin -
$w;
15654 $this->img_rb_x = $xpos;
15656 if (
$style[
'position'] ==
'L') {
15658 } elseif (
$style[
'position'] ==
'C') {
15659 $xpos = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
15660 } elseif (
$style[
'position'] ==
'R') {
15661 $xpos = $this->w - $this->rMargin -
$w;
15665 $this->img_rb_x = $xpos +
$w;
15667 $xstart = $xpos + (
$style[
'hpadding'] * $cw);
15668 $ystart =
$y + (
$style[
'vpadding'] * $ch);
15671 $this->rtl =
false;
15673 if (
$style[
'bgcolor']) {
15675 } elseif (
$style[
'border']) {
15676 $this->
Rect($xpos,
$y,
$w, $h,
'D');
15682 for (
$r = 0;
$r < $rows; ++
$r) {
15685 for ($c = 0; $c < $cols; ++$c) {
15686 if ($arrcode[
'bcode'][
$r][$c] == 1) {
15688 $this->
Rect($xr, $ystart, $cw, $ch,
'F',
array(),
$style[
'fgcolor']);
15695 $this->rtl = $tempRTL;
15706 $this->y =
$y + round($h/2);
15716 $this->
SetY($this->img_rb_y);
15747 'left' => $this->lMargin,
15748 'right' => $this->rMargin,
15749 'top' => $this->tMargin,
15750 'bottom' => $this->bMargin,
15751 'header' => $this->header_margin,
15752 'footer' => $this->footer_margin,
15753 'cell' => $this->cell_padding,
15754 'padding_left' => $this->cell_padding[
'L'],
15755 'padding_top' => $this->cell_padding[
'T'],
15756 'padding_right' => $this->cell_padding[
'R'],
15757 'padding_bottom' => $this->cell_padding[
'B']
15774 'left' => $this->original_lMargin,
15775 'right' => $this->original_rMargin
15844 if ($width ==
'thin') {
15846 } elseif ($width ==
'medium') {
15848 } elseif ($width ==
'thick') {
15864 switch (strtolower(
$style)) {
15900 $bprop = preg_split(
'/[\s]+/', trim($cssborder));
15902 switch (count($bprop)) {
15904 $width = $bprop[0];
15906 $color = $bprop[2];
15912 $color = $bprop[1];
15951 $padding = preg_split(
'/[\s]+/', trim($csspadding));
15953 switch (count($padding)) {
16005 $margin = preg_split(
'/[\s]+/', trim($cssmargin));
16007 switch (count($margin)) {
16059 $space = preg_split(
'/[\s]+/', trim($cssbspace));
16060 $border_spacing =
array();
16061 switch (count(
$space)) {
16063 $border_spacing[
'H'] =
$space[0];
16064 $border_spacing[
'V'] =
$space[1];
16068 $border_spacing[
'H'] =
$space[0];
16069 $border_spacing[
'V'] =
$space[0];
16073 return array(
'H' => 0,
'V' => 0);
16079 $border_spacing[
'H'] = $this->
getHTMLUnitToUnits($border_spacing[
'H'], $width,
'px',
false);
16080 $border_spacing[
'V'] = $this->
getHTMLUnitToUnits($border_spacing[
'V'], $width,
'px',
false);
16081 return $border_spacing;
16094 $spacing = trim($spacing);
16095 switch ($spacing) {
16101 if ($parent ==
'normal') {
16125 $stretch = trim($stretch);
16126 switch ($stretch) {
16127 case 'ultra-condensed': {
16131 case 'extra-condensed': {
16135 case 'condensed': {
16139 case 'semi-condensed': {
16147 case 'semi-expanded': {
16155 case 'extra-expanded': {
16159 case 'ultra-expanded': {
16164 $val = ($parent + 10);
16168 $val = ($parent - 10);
16172 if ($parent ==
'normal') {
16200 $size = ($refsize - 4);
16204 $size = ($refsize - 3);
16208 $size = ($refsize - 2);
16216 $size = ($refsize + 2);
16220 $size = ($refsize + 4);
16224 $size = ($refsize + 6);
16228 $size = ($parent_size - 3);
16232 $size = ($parent_size + 3);
16253 $matches =
array();
16254 if (preg_match_all(
'/<cssarray>([^<]*)<\/cssarray>/isU',
$html, $matches) > 0) {
16255 if (isset($matches[1][0])) {
16256 $css = array_merge($css, json_decode($this->
unhtmlentities($matches[1][0]),
true));
16258 $html = preg_replace(
'/<cssarray>(.*?)<\/cssarray>/isU',
'',
$html);
16261 $matches =
array();
16262 if (preg_match_all(
'/<link([^>]*)>/isU',
$html, $matches) > 0) {
16263 foreach ($matches[1] as $key => $link) {
16265 if (preg_match(
'/type[\s]*=[\s]*"text\/css"/', $link, $type)) {
16267 preg_match(
'/media[\s]*=[\s]*"([^"]*)"/', $link, $type);
16270 if (empty($type) OR (isset($type[1]) AND (($type[1] ==
'all') OR ($type[1] ==
'print')))) {
16272 if (preg_match(
'/href[\s]*=[\s]*"([^"]*)"/', $link, $type) > 0) {
16275 if (($cssdata !== FALSE) AND (strlen($cssdata) > 0)) {
16284 $matches =
array();
16285 if (preg_match_all(
'/<style([^>]*)>([^<]*)<\/style>/isU',
$html, $matches) > 0) {
16286 foreach ($matches[1] as $key => $media) {
16288 preg_match(
'/media[\s]*=[\s]*"([^"]*)"/', $media, $type);
16291 if (empty($type) OR (isset($type[1]) AND (($type[1] ==
'all') OR ($type[1] ==
'print')))) {
16292 $cssdata = $matches[2][$key];
16298 $csstagarray =
'<cssarray>'.htmlentities(json_encode($css)).
'</cssarray>';
16300 $html = preg_replace(
'/<head([^>]*)>(.*?)<\/head>/siU',
'',
$html);
16301 $html = preg_replace(
'/<style([^>]*)>([^<]*)<\/style>/isU',
'',
$html);
16303 $blocktags =
array(
'blockquote',
'br',
'dd',
'dl',
'div',
'dt',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'hr',
'li',
'ol',
'p',
'pre',
'ul',
'tcpdf',
'table',
'tr',
'td');
16305 $selfclosingtags =
array(
'area',
'base',
'basefont',
'br',
'hr',
'input',
'img',
'link',
'meta');
16307 $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>');
16309 $html = preg_replace(
'/<pre/',
'<xre',
$html);
16310 $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);
16311 $html = preg_replace(
'@(\r\n|\r)@',
"\n",
$html);
16312 $repTable =
array(
"\t" =>
' ',
"\0" =>
' ',
"\x0B" =>
' ',
"\\" =>
"\\\\");
16315 while (($offset < strlen(
$html)) AND ($pos = strpos(
$html,
'</pre>', $offset)) !==
false) {
16316 $html_a = substr(
$html, 0, $offset);
16317 $html_b = substr(
$html, $offset, ($pos - $offset + 6));
16318 while (preg_match(
"'<xre([^>]*)>(.*?)\n(.*?)</pre>'si", $html_b)) {
16320 $html_b = preg_replace(
"'<xre([^>]*)>(.*?)\n(.*?)</pre>'si",
"<xre\\1>\\2<br />\\3</pre>", $html_b);
16322 while (preg_match(
"'<xre([^>]*)>(.*?)".$this->re_space[
'p'].
"(.*?)</pre>'".$this->re_space[
'm'], $html_b)) {
16324 $html_b = preg_replace(
"'<xre([^>]*)>(.*?)".$this->re_space[
'p'].
"(.*?)</pre>'".$this->re_space[
'm'],
"<xre\\1>\\2 \\3</pre>", $html_b);
16326 $html = $html_a.$html_b.substr(
$html, $pos + 6);
16327 $offset = strlen($html_a.$html_b);
16330 while (($offset < strlen(
$html)) AND ($pos = strpos(
$html,
'</textarea>', $offset)) !==
false) {
16331 $html_a = substr(
$html, 0, $offset);
16332 $html_b = substr(
$html, $offset, ($pos - $offset + 11));
16333 while (preg_match(
"'<textarea([^>]*)>(.*?)\n(.*?)</textarea>'si", $html_b)) {
16335 $html_b = preg_replace(
"'<textarea([^>]*)>(.*?)\n(.*?)</textarea>'si",
"<textarea\\1>\\2<TBR>\\3</textarea>", $html_b);
16336 $html_b = preg_replace(
"'<textarea([^>]*)>(.*?)[\"](.*?)</textarea>'si",
"<textarea\\1>\\2''\\3</textarea>", $html_b);
16338 $html = $html_a.$html_b.substr(
$html, $pos + 11);
16339 $offset = strlen($html_a.$html_b);
16341 $html = preg_replace(
'/([\s]*)<option/si',
'<option',
$html);
16342 $html = preg_replace(
'/<\/option>([\s]*)/si',
'</option>',
$html);
16344 while (($offset < strlen(
$html)) AND ($pos = strpos(
$html,
'</option>', $offset)) !==
false) {
16345 $html_a = substr(
$html, 0, $offset);
16346 $html_b = substr(
$html, $offset, ($pos - $offset + 9));
16347 while (preg_match(
"'<option([^>]*)>(.*?)</option>'si", $html_b)) {
16348 $html_b = preg_replace(
"'<option([\s]+)value=\"([^\"]*)\"([^>]*)>(.*?)</option>'si",
"\\2#!TaB!#\\4#!NwL!#", $html_b);
16349 $html_b = preg_replace(
"'<option([^>]*)>(.*?)</option>'si",
"\\2#!NwL!#", $html_b);
16351 $html = $html_a.$html_b.substr(
$html, $pos + 9);
16352 $offset = strlen($html_a.$html_b);
16354 if (preg_match(
"'</select'si",
$html)) {
16355 $html = preg_replace(
"'<select([^>]*)>'si",
"<select\\1 opt=\"",
$html);
16356 $html = preg_replace(
"'#!NwL!#</select>'si",
"\" />",
$html);
16362 $html = preg_replace(
'/[\s]+<\/(table|tr|ul|ol|dl)>/',
'</\\1>',
$html);
16363 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<\/(td|th|li|dt|dd)>/'.$this->re_space[
'm'],
'</\\1>',
$html);
16364 $html = preg_replace(
'/[\s]+<(tr|td|th|li|dt|dd)/',
'<\\1',
$html);
16365 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<(ul|ol|dl|br)/'.$this->re_space[
'm'],
'<\\1',
$html);
16366 $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);
16367 $html = preg_replace(
'/<\/(td|th)>/',
'<marker style="font-size:0"/></\\1>',
$html);
16368 $html = preg_replace(
'/<\/table>([\s]*)<marker style="font-size:0"\/>/',
'</table>',
$html);
16369 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<img/'.$this->re_space[
'm'], chr(32).
'<img',
$html);
16370 $html = preg_replace(
'/<img([^>]*)>[\s]+([^<])/xi',
'<img\\1> \\2',
$html);
16371 $html = preg_replace(
'/<img([^>]*)>/xi',
'<img\\1><span><marker style="font-size:0"/></span>',
$html);
16372 $html = preg_replace(
'/<xre/',
'<pre',
$html);
16373 $html = preg_replace(
'/<textarea([^>]*)>([^<]*)<\/textarea>/xi',
'<textarea\\1 value="\\2" />',
$html);
16374 $html = preg_replace(
'/<li([^>]*)><\/li>/',
'<li\\1> </li>',
$html);
16375 $html = preg_replace(
'/<li([^>]*)>'.$this->re_space[
'p'].
'*<img/'.$this->re_space[
'm'],
'<li\\1><font size="1"> </font><img',
$html);
16376 $html = preg_replace(
'/<([^>\/]*)>[\s]/',
'<\\1> ',
$html);
16377 $html = preg_replace(
'/[\s]<\/([^>]*)>/',
' </\\1>',
$html);
16378 $html = preg_replace(
'/<su([bp])/',
'<zws/><su\\1',
$html);
16379 $html = preg_replace(
'/<\/su([bp])>/',
'</su\\1><zws/>',
$html);
16380 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+/'.$this->re_space[
'm'], chr(32),
$html);
16384 $html = preg_replace(
'/<li><br([^>]*)>/',
'<li> <br\\1>',
$html);
16386 $html = preg_replace(
'/^<img/',
'<span style="font-size:0"><br /></span> <img',
$html, 1);
16388 $tagpattern =
'/(<[^>]+>)/';
16390 $a = preg_split($tagpattern,
$html, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
16392 $maxel = count($a);
16397 $dom[$key] =
array();
16400 $dom[$key][
'tag'] =
false;
16401 $dom[$key][
'block'] =
false;
16402 $dom[$key][
'value'] =
'';
16403 $dom[$key][
'parent'] = 0;
16404 $dom[$key][
'hide'] =
false;
16411 $dom[$key][
'fill'] = (($this->textrendermode % 2) == 0);
16412 $dom[$key][
'clip'] = ($this->textrendermode > 3);
16414 $dom[$key][
'bgcolor'] =
false;
16417 $dom[$key][
'align'] =
'';
16418 $dom[$key][
'listtype'] =
'';
16419 $dom[$key][
'text-indent'] = 0;
16420 $dom[$key][
'text-transform'] =
'';
16421 $dom[$key][
'border'] =
array();
16422 $dom[$key][
'dir'] = $this->rtl?
'rtl':
'ltr';
16426 array_push($level, 0);
16427 while ($elkey < $maxel) {
16428 $dom[$key] =
array();
16429 $element = $a[$elkey];
16430 $dom[$key][
'elkey'] = $elkey;
16431 if (preg_match($tagpattern, $element)) {
16433 $element = substr($element, 1, -1);
16435 preg_match(
'/[\/]?([a-zA-Z0-9]*)/', $element, $tag);
16436 $tagname = strtolower($tag[1]);
16438 if ($tagname ==
'thead') {
16439 if ($element[0] ==
'/') {
16447 $dom[$key][
'tag'] =
true;
16448 $dom[$key][
'value'] = $tagname;
16449 if (in_array($dom[$key][
'value'], $blocktags)) {
16450 $dom[$key][
'block'] =
true;
16452 $dom[$key][
'block'] =
false;
16454 if ($element[0] ==
'/') {
16456 $dom[$key][
'opening'] =
false;
16457 $dom[$key][
'parent'] = end($level);
16459 $dom[$key][
'hide'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'hide'];
16460 $dom[$key][
'fontname'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontname'];
16461 $dom[$key][
'fontstyle'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontstyle'];
16462 $dom[$key][
'fontsize'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontsize'];
16463 $dom[$key][
'font-stretch'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'font-stretch'];
16464 $dom[$key][
'letter-spacing'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'letter-spacing'];
16465 $dom[$key][
'stroke'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'stroke'];
16466 $dom[$key][
'fill'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fill'];
16467 $dom[$key][
'clip'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'clip'];
16468 $dom[$key][
'line-height'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'line-height'];
16469 $dom[$key][
'bgcolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'bgcolor'];
16470 $dom[$key][
'fgcolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fgcolor'];
16471 $dom[$key][
'strokecolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'strokecolor'];
16472 $dom[$key][
'align'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'align'];
16473 $dom[$key][
'text-transform'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'text-transform'];
16474 $dom[$key][
'dir'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'dir'];
16475 if (isset($dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'listtype'])) {
16476 $dom[$key][
'listtype'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'listtype'];
16479 if (($dom[$key][
'value'] ==
'tr') AND (!isset($dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'cols']))) {
16480 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'cols'] = $dom[($dom[$key][
'parent'])][
'cols'];
16482 if (($dom[$key][
'value'] ==
'td') OR ($dom[$key][
'value'] ==
'th')) {
16483 $dom[($dom[$key][
'parent'])][
'content'] = $csstagarray;
16484 for ($i = ($dom[$key][
'parent'] + 1); $i < $key; ++$i) {
16485 $dom[($dom[$key][
'parent'])][
'content'] .= stripslashes($a[$dom[$i][
'elkey']]);
16489 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'<table',
'<table nested="true"', $dom[($dom[$key][
'parent'])][
'content']);
16491 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'<thead>',
'', $dom[($dom[$key][
'parent'])][
'content']);
16492 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'</thead>',
'', $dom[($dom[$key][
'parent'])][
'content']);
16495 if (($dom[$key][
'value'] ==
'tr') AND ($dom[($dom[$key][
'parent'])][
'thead'] ===
true)) {
16497 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'thead'] = $csstagarray.$a[$dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'elkey']];
16499 for ($i = $dom[$key][
'parent']; $i <= $key; ++$i) {
16500 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'thead'] .= $a[$dom[$i][
'elkey']];
16502 if (!isset($dom[($dom[$key][
'parent'])][
'attribute'])) {
16503 $dom[($dom[$key][
'parent'])][
'attribute'] =
array();
16506 $dom[($dom[$key][
'parent'])][
'attribute'][
'nobr'] =
'true';
16510 $dom[($dom[$key][
'parent'])][
'thead'] = str_replace(
' nobr="true"',
'', $dom[($dom[$key][
'parent'])][
'thead']);
16511 $dom[($dom[$key][
'parent'])][
'thead'] .=
'</tablehead>';
16515 $dom[$key][
'opening'] =
true;
16516 $dom[$key][
'parent'] = end($level);
16517 if ((substr($element, -1, 1) ==
'/') OR (in_array($dom[$key][
'value'], $selfclosingtags))) {
16519 $dom[$key][
'self'] =
true;
16522 array_push($level, $key);
16523 $dom[$key][
'self'] =
false;
16528 $parentkey = $dom[$key][
'parent'];
16529 $dom[$key][
'hide'] = $dom[$parentkey][
'hide'];
16530 $dom[$key][
'fontname'] = $dom[$parentkey][
'fontname'];
16531 $dom[$key][
'fontstyle'] = $dom[$parentkey][
'fontstyle'];
16532 $dom[$key][
'fontsize'] = $dom[$parentkey][
'fontsize'];
16533 $dom[$key][
'font-stretch'] = $dom[$parentkey][
'font-stretch'];
16534 $dom[$key][
'letter-spacing'] = $dom[$parentkey][
'letter-spacing'];
16535 $dom[$key][
'stroke'] = $dom[$parentkey][
'stroke'];
16536 $dom[$key][
'fill'] = $dom[$parentkey][
'fill'];
16537 $dom[$key][
'clip'] = $dom[$parentkey][
'clip'];
16538 $dom[$key][
'line-height'] = $dom[$parentkey][
'line-height'];
16539 $dom[$key][
'bgcolor'] = $dom[$parentkey][
'bgcolor'];
16540 $dom[$key][
'fgcolor'] = $dom[$parentkey][
'fgcolor'];
16541 $dom[$key][
'strokecolor'] = $dom[$parentkey][
'strokecolor'];
16542 $dom[$key][
'align'] = $dom[$parentkey][
'align'];
16543 $dom[$key][
'listtype'] = $dom[$parentkey][
'listtype'];
16544 $dom[$key][
'text-indent'] = $dom[$parentkey][
'text-indent'];
16545 $dom[$key][
'text-transform'] = $dom[$parentkey][
'text-transform'];
16546 $dom[$key][
'border'] =
array();
16547 $dom[$key][
'dir'] = $dom[$parentkey][
'dir'];
16550 preg_match_all(
'/([^=\s]*)[\s]*=[\s]*"([^"]*)"/', $element, $attr_array, PREG_PATTERN_ORDER);
16551 $dom[$key][
'attribute'] =
array();
16552 while (list($id, $name) = each($attr_array[1])) {
16553 $dom[$key][
'attribute'][strtolower($name)] = $attr_array[2][$id];
16555 if (!empty($css)) {
16561 if (isset($dom[$key][
'attribute'][
'style']) AND !empty($dom[$key][
'attribute'][
'style'])) {
16563 preg_match_all(
'/([^;:\s]*):([^;]*)/', $dom[$key][
'attribute'][
'style'], $style_array, PREG_PATTERN_ORDER);
16564 $dom[$key][
'style'] =
array();
16565 while (list($id, $name) = each($style_array[1])) {
16567 $dom[$key][
'style'][strtolower($name)] = trim($style_array[2][$id]);
16571 if (isset($dom[$key][
'style'][
'direction'])) {
16572 $dom[$key][
'dir'] = $dom[$key][
'style'][
'direction'];
16575 if (isset($dom[$key][
'style'][
'display'])) {
16576 $dom[$key][
'hide'] = (trim(strtolower($dom[$key][
'style'][
'display'])) ==
'none');
16579 if (isset($dom[$key][
'style'][
'font-family'])) {
16580 $dom[$key][
'fontname'] = $this->
getFontFamilyName($dom[$key][
'style'][
'font-family']);
16583 if (isset($dom[$key][
'style'][
'list-style-type'])) {
16584 $dom[$key][
'listtype'] = trim(strtolower($dom[$key][
'style'][
'list-style-type']));
16585 if ($dom[$key][
'listtype'] ==
'inherit') {
16586 $dom[$key][
'listtype'] = $dom[$parentkey][
'listtype'];
16590 if (isset($dom[$key][
'style'][
'text-indent'])) {
16591 $dom[$key][
'text-indent'] = $this->
getHTMLUnitToUnits($dom[$key][
'style'][
'text-indent']);
16592 if ($dom[$key][
'text-indent'] ==
'inherit') {
16593 $dom[$key][
'text-indent'] = $dom[$parentkey][
'text-indent'];
16597 if (isset($dom[$key][
'style'][
'text-transform'])) {
16598 $dom[$key][
'text-transform'] = $dom[$key][
'style'][
'text-transform'];
16601 if (isset($dom[$key][
'style'][
'font-size'])) {
16602 $fsize = trim($dom[$key][
'style'][
'font-size']);
16603 $dom[$key][
'fontsize'] = $this->
getHTMLFontUnits($fsize, $dom[0][
'fontsize'], $dom[$parentkey][
'fontsize'],
'pt');
16606 if (isset($dom[$key][
'style'][
'font-stretch'])) {
16607 $dom[$key][
'font-stretch'] = $this->
getCSSFontStretching($dom[$key][
'style'][
'font-stretch'], $dom[$parentkey][
'font-stretch']);
16610 if (isset($dom[$key][
'style'][
'letter-spacing'])) {
16611 $dom[$key][
'letter-spacing'] = $this->
getCSSFontSpacing($dom[$key][
'style'][
'letter-spacing'], $dom[$parentkey][
'letter-spacing']);
16614 if (isset($dom[$key][
'style'][
'line-height'])) {
16615 $lineheight = trim($dom[$key][
'style'][
'line-height']);
16616 switch ($lineheight) {
16619 $dom[$key][
'line-height'] = $dom[0][
'line-height'];
16623 $dom[$key][
'line-height'] = $dom[$parentkey][
'line-height'];
16626 if (is_numeric($lineheight)) {
16628 $lineheight = ($lineheight * 100).
'%';
16631 if (substr($lineheight, -1) !==
'%') {
16632 if ($dom[$key][
'fontsize'] <= 0) {
16633 $dom[$key][
'line-height'] = 1;
16635 $dom[$key][
'line-height'] = (($dom[$key][
'line-height'] - $this->cell_padding[
'T'] - $this->cell_padding[
'B']) / $dom[$key][
'fontsize']);
16642 if (isset($dom[$key][
'style'][
'font-weight'])) {
16643 if (strtolower($dom[$key][
'style'][
'font-weight'][0]) ==
'n') {
16644 if (strpos($dom[$key][
'fontstyle'],
'B') !==
false) {
16645 $dom[$key][
'fontstyle'] = str_replace(
'B',
'', $dom[$key][
'fontstyle']);
16647 } elseif (strtolower($dom[$key][
'style'][
'font-weight'][0]) ==
'b') {
16648 $dom[$key][
'fontstyle'] .=
'B';
16651 if (isset($dom[$key][
'style'][
'font-style']) AND (strtolower($dom[$key][
'style'][
'font-style'][0]) ==
'i')) {
16652 $dom[$key][
'fontstyle'] .=
'I';
16657 } elseif ($dom[$key][
'value'] ==
'a') {
16661 if (isset($dom[$key][
'style'][
'background-color']) AND (!
TCPDF_STATIC::empty_string($dom[$key][
'style'][
'background-color']))) {
16665 if (isset($dom[$key][
'style'][
'text-decoration'])) {
16666 $decors = explode(
' ', strtolower($dom[$key][
'style'][
'text-decoration']));
16667 foreach ($decors as $dec) {
16670 if ($dec[0] ==
'u') {
16672 $dom[$key][
'fontstyle'] .=
'U';
16673 } elseif ($dec[0] ==
'l') {
16675 $dom[$key][
'fontstyle'] .=
'D';
16676 } elseif ($dec[0] ==
'o') {
16678 $dom[$key][
'fontstyle'] .=
'O';
16682 } elseif ($dom[$key][
'value'] ==
'a') {
16686 if (isset($dom[$key][
'style'][
'width'])) {
16687 $dom[$key][
'width'] = $dom[$key][
'style'][
'width'];
16690 if (isset($dom[$key][
'style'][
'height'])) {
16691 $dom[$key][
'height'] = $dom[$key][
'style'][
'height'];
16694 if (isset($dom[$key][
'style'][
'text-align'])) {
16695 $dom[$key][
'align'] = strtoupper($dom[$key][
'style'][
'text-align'][0]);
16698 if (isset($dom[$key][
'style'][
'border'])) {
16700 if (!empty($borderstyle)) {
16701 $dom[$key][
'border'][
'LTRB'] = $borderstyle;
16704 if (isset($dom[$key][
'style'][
'border-color'])) {
16705 $brd_colors = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-color']));
16706 if (isset($brd_colors[3])) {
16709 if (isset($brd_colors[1])) {
16712 if (isset($brd_colors[0])) {
16715 if (isset($brd_colors[2])) {
16719 if (isset($dom[$key][
'style'][
'border-width'])) {
16720 $brd_widths = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-width']));
16721 if (isset($brd_widths[3])) {
16724 if (isset($brd_widths[1])) {
16727 if (isset($brd_widths[0])) {
16730 if (isset($brd_widths[2])) {
16734 if (isset($dom[$key][
'style'][
'border-style'])) {
16735 $brd_styles = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-style']));
16736 if (isset($brd_styles[3]) AND ($brd_styles[3]!=
'none')) {
16737 $dom[$key][
'border'][
'L'][
'cap'] =
'square';
16738 $dom[$key][
'border'][
'L'][
'join'] =
'miter';
16740 if ($dom[$key][
'border'][
'L'][
'dash'] < 0) {
16741 $dom[$key][
'border'][
'L'] =
array();
16744 if (isset($brd_styles[1])) {
16745 $dom[$key][
'border'][
'R'][
'cap'] =
'square';
16746 $dom[$key][
'border'][
'R'][
'join'] =
'miter';
16748 if ($dom[$key][
'border'][
'R'][
'dash'] < 0) {
16749 $dom[$key][
'border'][
'R'] =
array();
16752 if (isset($brd_styles[0])) {
16753 $dom[$key][
'border'][
'T'][
'cap'] =
'square';
16754 $dom[$key][
'border'][
'T'][
'join'] =
'miter';
16756 if ($dom[$key][
'border'][
'T'][
'dash'] < 0) {
16757 $dom[$key][
'border'][
'T'] =
array();
16760 if (isset($brd_styles[2])) {
16761 $dom[$key][
'border'][
'B'][
'cap'] =
'square';
16762 $dom[$key][
'border'][
'B'][
'join'] =
'miter';
16764 if ($dom[$key][
'border'][
'B'][
'dash'] < 0) {
16765 $dom[$key][
'border'][
'B'] =
array();
16769 $cellside =
array(
'L' =>
'left',
'R' =>
'right',
'T' =>
'top',
'B' =>
'bottom');
16770 foreach ($cellside as $bsk => $bsv) {
16771 if (isset($dom[$key][
'style'][
'border-'.$bsv])) {
16773 if (!empty($borderstyle)) {
16774 $dom[$key][
'border'][$bsk] = $borderstyle;
16777 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-color'])) {
16780 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-width'])) {
16781 $dom[$key][
'border'][$bsk][
'width'] = $this->
getCSSBorderWidth($dom[$key][
'style'][
'border-'.$bsv.
'-width']);
16783 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-style'])) {
16784 $dom[$key][
'border'][$bsk][
'dash'] = $this->
getCSSBorderDashStyle($dom[$key][
'style'][
'border-'.$bsv.
'-style']);
16785 if ($dom[$key][
'border'][$bsk][
'dash'] < 0) {
16786 $dom[$key][
'border'][$bsk] =
array();
16791 if (isset($dom[$key][
'style'][
'padding'])) {
16792 $dom[$key][
'padding'] = $this->
getCSSPadding($dom[$key][
'style'][
'padding']);
16796 foreach ($cellside as $psk => $psv) {
16797 if (isset($dom[$key][
'style'][
'padding-'.$psv])) {
16798 $dom[$key][
'padding'][$psk] = $this->
getHTMLUnitToUnits($dom[$key][
'style'][
'padding-'.$psv], 0,
'px',
false);
16802 if (isset($dom[$key][
'style'][
'margin'])) {
16803 $dom[$key][
'margin'] = $this->
getCSSMargin($dom[$key][
'style'][
'margin']);
16807 foreach ($cellside as $psk => $psv) {
16808 if (isset($dom[$key][
'style'][
'margin-'.$psv])) {
16809 $dom[$key][
'margin'][$psk] = $this->
getHTMLUnitToUnits(str_replace(
'auto',
'0', $dom[$key][
'style'][
'margin-'.$psv]), 0,
'px',
false);
16813 if (isset($dom[$key][
'style'][
'border-spacing'])) {
16814 $dom[$key][
'border-spacing'] = $this->
getCSSBorderMargin($dom[$key][
'style'][
'border-spacing']);
16817 if (isset($dom[$key][
'style'][
'page-break-inside']) AND ($dom[$key][
'style'][
'page-break-inside'] ==
'avoid')) {
16818 $dom[$key][
'attribute'][
'nobr'] =
'true';
16821 if (isset($dom[$key][
'style'][
'page-break-before'])) {
16822 if ($dom[$key][
'style'][
'page-break-before'] ==
'always') {
16823 $dom[$key][
'attribute'][
'pagebreak'] =
'true';
16824 } elseif ($dom[$key][
'style'][
'page-break-before'] ==
'left') {
16825 $dom[$key][
'attribute'][
'pagebreak'] =
'left';
16826 } elseif ($dom[$key][
'style'][
'page-break-before'] ==
'right') {
16827 $dom[$key][
'attribute'][
'pagebreak'] =
'right';
16831 if (isset($dom[$key][
'style'][
'page-break-after'])) {
16832 if ($dom[$key][
'style'][
'page-break-after'] ==
'always') {
16833 $dom[$key][
'attribute'][
'pagebreakafter'] =
'true';
16834 } elseif ($dom[$key][
'style'][
'page-break-after'] ==
'left') {
16835 $dom[$key][
'attribute'][
'pagebreakafter'] =
'left';
16836 } elseif ($dom[$key][
'style'][
'page-break-after'] ==
'right') {
16837 $dom[$key][
'attribute'][
'pagebreakafter'] =
'right';
16841 if (isset($dom[$key][
'attribute'][
'display'])) {
16842 $dom[$key][
'hide'] = (trim(strtolower($dom[$key][
'attribute'][
'display'])) ==
'none');
16844 if (isset($dom[$key][
'attribute'][
'border']) AND ($dom[$key][
'attribute'][
'border'] != 0)) {
16845 $borderstyle = $this->
getCSSBorderStyle($dom[$key][
'attribute'][
'border'].
' solid black');
16846 if (!empty($borderstyle)) {
16847 $dom[$key][
'border'][
'LTRB'] = $borderstyle;
16851 if ($dom[$key][
'value'] ==
'font') {
16853 if (isset($dom[$key][
'attribute'][
'face'])) {
16854 $dom[$key][
'fontname'] = $this->
getFontFamilyName($dom[$key][
'attribute'][
'face']);
16857 if (isset($dom[$key][
'attribute'][
'size'])) {
16859 if ($dom[$key][
'attribute'][
'size'][0] ==
'+') {
16860 $dom[$key][
'fontsize'] = $dom[($dom[$key][
'parent'])][
'fontsize'] + intval(substr($dom[$key][
'attribute'][
'size'], 1));
16861 } elseif ($dom[$key][
'attribute'][
'size'][0] ==
'-') {
16862 $dom[$key][
'fontsize'] = $dom[($dom[$key][
'parent'])][
'fontsize'] - intval(substr($dom[$key][
'attribute'][
'size'], 1));
16864 $dom[$key][
'fontsize'] = intval($dom[$key][
'attribute'][
'size']);
16867 $dom[$key][
'fontsize'] = intval($dom[$key][
'attribute'][
'size']);
16872 if ((($dom[$key][
'value'] ==
'ul') OR ($dom[$key][
'value'] ==
'ol') OR ($dom[$key][
'value'] ==
'dl'))
16875 $dom[$key][
'align'] =
'R';
16877 $dom[$key][
'align'] =
'L';
16880 if (($dom[$key][
'value'] ==
'small') OR ($dom[$key][
'value'] ==
'sup') OR ($dom[$key][
'value'] ==
'sub')) {
16881 if (!isset($dom[$key][
'attribute'][
'size']) AND !isset($dom[$key][
'style'][
'font-size'])) {
16882 $dom[$key][
'fontsize'] = $dom[$key][
'fontsize'] *
K_SMALL_RATIO;
16885 if (($dom[$key][
'value'] ==
'strong') OR ($dom[$key][
'value'] ==
'b')) {
16886 $dom[$key][
'fontstyle'] .=
'B';
16888 if (($dom[$key][
'value'] ==
'em') OR ($dom[$key][
'value'] ==
'i')) {
16889 $dom[$key][
'fontstyle'] .=
'I';
16891 if ($dom[$key][
'value'] ==
'u') {
16892 $dom[$key][
'fontstyle'] .=
'U';
16894 if (($dom[$key][
'value'] ==
'del') OR ($dom[$key][
'value'] ==
's') OR ($dom[$key][
'value'] ==
'strike')) {
16895 $dom[$key][
'fontstyle'] .=
'D';
16897 if (!isset($dom[$key][
'style'][
'text-decoration']) AND ($dom[$key][
'value'] ==
'a')) {
16900 if (($dom[$key][
'value'] ==
'pre') OR ($dom[$key][
'value'] ==
'tt')) {
16903 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)) {
16905 if (!isset($dom[$key][
'attribute'][
'size']) AND !isset($dom[$key][
'style'][
'font-size'])) {
16906 $headsize = (4 - intval($dom[$key][
'value']{1})) * 2;
16907 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'] + $headsize;
16909 if (!isset($dom[$key][
'style'][
'font-weight'])) {
16910 $dom[$key][
'fontstyle'] .=
'B';
16913 if (($dom[$key][
'value'] ==
'table')) {
16914 $dom[$key][
'rows'] = 0;
16915 $dom[$key][
'trids'] =
array();
16916 $dom[$key][
'thead'] =
'';
16918 if (($dom[$key][
'value'] ==
'tr')) {
16919 $dom[$key][
'cols'] = 0;
16921 $dom[$key][
'thead'] =
true;
16924 $dom[$key][
'thead'] =
false;
16926 ++$dom[($dom[$key][
'parent'])][
'rows'];
16928 array_push($dom[($dom[$key][
'parent'])][
'trids'], $key);
16931 if (($dom[$key][
'value'] ==
'th') OR ($dom[$key][
'value'] ==
'td')) {
16932 if (isset($dom[$key][
'attribute'][
'colspan'])) {
16933 $colspan = intval($dom[$key][
'attribute'][
'colspan']);
16937 $dom[$key][
'attribute'][
'colspan'] = $colspan;
16938 $dom[($dom[$key][
'parent'])][
'cols'] += $colspan;
16941 if (isset($dom[$key][
'attribute'][
'dir'])) {
16942 $dom[$key][
'dir'] = $dom[$key][
'attribute'][
'dir'];
16947 } elseif (!isset($dom[$key][
'style'][
'color']) AND ($dom[$key][
'value'] ==
'a')) {
16955 if (isset($dom[$key][
'attribute'][
'strokecolor']) AND (!
TCPDF_STATIC::empty_string($dom[$key][
'attribute'][
'strokecolor']))) {
16959 if (isset($dom[$key][
'attribute'][
'width'])) {
16960 $dom[$key][
'width'] = $dom[$key][
'attribute'][
'width'];
16963 if (isset($dom[$key][
'attribute'][
'height'])) {
16964 $dom[$key][
'height'] = $dom[$key][
'attribute'][
'height'];
16967 if (isset($dom[$key][
'attribute'][
'align']) AND (!
TCPDF_STATIC::empty_string($dom[$key][
'attribute'][
'align'])) AND ($dom[$key][
'value'] !==
'img')) {
16968 $dom[$key][
'align'] = strtoupper($dom[$key][
'attribute'][
'align'][0]);
16971 if (isset($dom[$key][
'attribute'][
'stroke'])) {
16973 $dom[$key][
'stroke'] = $this->
getHTMLUnitToUnits($dom[$key][
'attribute'][
'stroke'], $dom[$key][
'fontsize'],
'pt',
true);
16975 if (isset($dom[$key][
'attribute'][
'fill'])) {
16977 if ($dom[$key][
'attribute'][
'fill'] ==
'true') {
16978 $dom[$key][
'fill'] =
true;
16980 $dom[$key][
'fill'] =
false;
16983 if (isset($dom[$key][
'attribute'][
'clip'])) {
16985 if ($dom[$key][
'attribute'][
'clip'] ==
'true') {
16986 $dom[$key][
'clip'] =
true;
16988 $dom[$key][
'clip'] =
false;
16994 $dom[$key][
'tag'] =
false;
16995 $dom[$key][
'block'] =
false;
16996 $dom[$key][
'parent'] = end($level);
16997 $dom[$key][
'dir'] = $dom[$dom[$key][
'parent']][
'dir'];
16998 if (!empty($dom[$dom[$key][
'parent']][
'text-transform'])) {
17000 if (function_exists(
'mb_convert_case')) {
17001 $ttm =
array(
'capitalize' => MB_CASE_TITLE,
'uppercase' => MB_CASE_UPPER,
'lowercase' => MB_CASE_LOWER);
17002 if (isset($ttm[$dom[$dom[$key][
'parent']][
'text-transform']])) {
17003 $element = mb_convert_case($element, $ttm[$dom[$dom[$key][
'parent']][
'text-transform']], $this->encoding);
17005 } elseif (!$this->isunicode) {
17006 switch ($dom[$dom[$key][
'parent']][
'text-transform']) {
17007 case 'capitalize': {
17008 $element = ucwords(strtolower($element));
17011 case 'uppercase': {
17012 $element = strtoupper($element);
17015 case 'lowercase': {
17016 $element = strtolower($element);
17022 $dom[$key][
'value'] = stripslashes($this->
unhtmlentities($element));
17038 $spacestr = chr(32);
17040 $spacestr = chr(0).chr(32);
17052 return md5(strlen(
$data).$this->file_id.$data);
17062 $encoded = urlencode(json_encode(
$data));
17073 $hash = substr(
$data, 0, 32);
17074 $encoded = substr(
$data, 32);
17076 $this->
Error(
'Invalid parameters');
17078 return json_decode(urldecode($encoded),
true);
17103 public function writeHTMLCell(
$w,
$h,
$x,
$y,
$html=
'',
$border=0, $ln=0, $fill=
false, $reseth=
true, $align=
'', $autopadding=
true) {
17104 return $this->
MultiCell(
$w,
$h,
$html,
$border, $align, $fill, $ln,
$x,
$y, $reseth, 0,
true, $autopadding, 0,
'T',
false);
17120 public function writeHTML(
$html, $ln=
true, $fill=
false, $reseth=
false, $cell=
false, $align=
'') {
17131 $curfontascent = $this->
getFontAscent($curfontname, $curfontstyle, $curfontsize);
17132 $curfontdescent = $this->
getFontDescent($curfontname, $curfontstyle, $curfontsize);
17135 $this->newline =
true;
17139 $maxbottomliney = 0;
17145 $this_method_vars =
array();
17147 $fontaligned =
false;
17148 $reverse_dir =
false;
17149 $this->premode =
false;
17150 if ($this->inxobj) {
17152 $pask = count($this->xobjects[$this->xobjid][
'annotations']);
17153 } elseif (isset($this->PageAnnots[$this->page])) {
17154 $pask = count($this->PageAnnots[$this->page]);
17158 if ($this->inxobj) {
17160 $startlinepos = strlen($this->xobjects[$this->xobjid][
'outdata']);
17161 } elseif (!$this->InFooter) {
17162 if (isset($this->footerlen[$this->page])) {
17179 $w -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
17182 $this->x -= $this->cell_padding[
'R'];
17183 $this->lMargin += $this->cell_padding[
'R'];
17185 $this->x += $this->cell_padding[
'L'];
17186 $this->rMargin += $this->cell_padding[
'L'];
17189 if ($this->customlistindent >= 0) {
17194 $this->listindentlevel = 0;
17201 $this->listnum = 0;
17202 $this->listordered =
array();
17203 $this->listcount =
array();
17204 $this->lispacer =
'';
17210 $maxel = count($dom);
17212 while ($key < $maxel) {
17213 if ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND $dom[$key][
'hide']) {
17215 $hidden_node_key = $key;
17216 if ($dom[$key][
'self']) {
17221 while (($key < $maxel) AND (!$dom[$key][
'tag'] OR $dom[$key][
'opening'] OR ($dom[$key][
'parent'] != $hidden_node_key))) {
17228 if ($dom[$key][
'tag'] AND isset($dom[$key][
'attribute'][
'pagebreak'])) {
17230 if (($dom[$key][
'attribute'][
'pagebreak'] ==
'true') OR ($dom[$key][
'attribute'][
'pagebreak'] ==
'left') OR ($dom[$key][
'attribute'][
'pagebreak'] ==
'right')) {
17233 $this->htmlvspace = ($this->PageBreakTrigger + 1);
17235 if ((($dom[$key][
'attribute'][
'pagebreak'] ==
'left') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
17236 OR (($dom[$key][
'attribute'][
'pagebreak'] ==
'right') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
17239 $this->htmlvspace = ($this->PageBreakTrigger + 1);
17242 if ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND isset($dom[$key][
'attribute'][
'nobr']) AND ($dom[$key][
'attribute'][
'nobr'] ==
'true')) {
17243 if (isset($dom[($dom[$key][
'parent'])][
'attribute'][
'nobr']) AND ($dom[($dom[$key][
'parent'])][
'attribute'][
'nobr'] ==
'true')) {
17244 $dom[$key][
'attribute'][
'nobr'] =
false;
17249 $this_method_vars[
'html'] =
$html;
17250 $this_method_vars[
'ln'] = $ln;
17251 $this_method_vars[
'fill'] = $fill;
17252 $this_method_vars[
'reseth'] = $reseth;
17253 $this_method_vars[
'cell'] = $cell;
17254 $this_method_vars[
'align'] = $align;
17255 $this_method_vars[
'gvars'] = $gvars;
17256 $this_method_vars[
'prevPage'] = $prevPage;
17257 $this_method_vars[
'prev_cell_margin'] = $prev_cell_margin;
17258 $this_method_vars[
'prev_cell_padding'] = $prev_cell_padding;
17259 $this_method_vars[
'prevlMargin'] = $prevlMargin;
17260 $this_method_vars[
'prevrMargin'] = $prevrMargin;
17261 $this_method_vars[
'curfontname'] = $curfontname;
17262 $this_method_vars[
'curfontstyle'] = $curfontstyle;
17263 $this_method_vars[
'curfontsize'] = $curfontsize;
17264 $this_method_vars[
'curfontascent'] = $curfontascent;
17265 $this_method_vars[
'curfontdescent'] = $curfontdescent;
17266 $this_method_vars[
'curfontstretcing'] = $curfontstretcing;
17267 $this_method_vars[
'curfonttracking'] = $curfonttracking;
17268 $this_method_vars[
'minstartliney'] = $minstartliney;
17269 $this_method_vars[
'maxbottomliney'] = $maxbottomliney;
17270 $this_method_vars[
'yshift'] = $yshift;
17271 $this_method_vars[
'startlinepage'] = $startlinepage;
17272 $this_method_vars[
'startlinepos'] = $startlinepos;
17273 $this_method_vars[
'startlinex'] = $startlinex;
17274 $this_method_vars[
'startliney'] = $startliney;
17275 $this_method_vars[
'newline'] =
$newline;
17276 $this_method_vars[
'loop'] = $loop;
17277 $this_method_vars[
'curpos'] = $curpos;
17278 $this_method_vars[
'pask'] = $pask;
17279 $this_method_vars[
'lalign'] = $lalign;
17280 $this_method_vars[
'plalign'] = $plalign;
17281 $this_method_vars[
'w'] =
$w;
17282 $this_method_vars[
'prev_cell_height_ratio'] = $prev_cell_height_ratio;
17283 $this_method_vars[
'prev_listnum'] = $prev_listnum;
17284 $this_method_vars[
'prev_listordered'] = $prev_listordered;
17285 $this_method_vars[
'prev_listcount'] = $prev_listcount;
17286 $this_method_vars[
'prev_lispacer'] = $prev_lispacer;
17287 $this_method_vars[
'fontaligned'] = $fontaligned;
17288 $this_method_vars[
'key'] = $key;
17289 $this_method_vars[
'dom'] = $dom;
17293 if (($dom[$key][
'value'] ==
'tr') AND isset($dom[$key][
'thead']) AND $dom[$key][
'thead']) {
17294 if (isset($dom[$key][
'parent']) AND isset($dom[$dom[$key][
'parent']][
'thead']) AND !
TCPDF_STATIC::empty_string($dom[$dom[$key][
'parent']][
'thead'])) {
17295 $this->inthead =
true;
17297 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
17299 if (($this->y < $this->start_transaction_y) OR ($this->
checkPageBreak($this->lasth,
'',
false))) {
17304 foreach ($this_method_vars as $vkey => $vval) {
17312 if ((!$this->
checkPageBreak($this->PageBreakTrigger + 1)) AND ($this->y < $pre_y)) {
17317 $this->start_transaction_y =
$this->y;
17319 $this->thead = $tmp_thead;
17321 if (isset($dom[$dom[$key][
'parent']][
'attribute'][
'cellspacing'])) {
17322 $tmp_cellspacing = $this->
getHTMLUnitToUnits($dom[$dom[$key][
'parent']][
'attribute'][
'cellspacing'], 1,
'px');
17323 } elseif (isset($dom[$dom[$key][
'parent']][
'border-spacing'])) {
17324 $tmp_cellspacing = $dom[$dom[$key][
'parent']][
'border-spacing'][
'V'];
17326 $tmp_cellspacing = 0;
17328 $dom[$dom[$key][
'parent']][
'borderposition'][
'page'] =
$this->page;
17330 $dom[$dom[$key][
'parent']][
'borderposition'][
'y'] = $this->y + $tmp_cellspacing;
17331 $xoffset = ($this->x - $dom[$dom[$key][
'parent']][
'borderposition'][
'x']);
17332 $dom[$dom[$key][
'parent']][
'borderposition'][
'x'] += $xoffset;
17333 $dom[$dom[$key][
'parent']][
'borderposition'][
'xmax'] += $xoffset;
17335 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
17339 while ( ($key < $maxel) AND (!(
17340 ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'tr') AND (!isset($dom[$key][
'thead']) OR !$dom[$key][
'thead']))
17341 OR ($dom[$key][
'tag'] AND (!$dom[$key][
'opening']) AND ($dom[$key][
'value'] ==
'table'))) )) {
17345 if ($dom[$key][
'tag'] OR ($key == 0)) {
17346 if ((($dom[$key][
'value'] ==
'table') OR ($dom[$key][
'value'] ==
'tr')) AND (isset($dom[$key][
'align']))) {
17347 $dom[$key][
'align'] = (
$this->rtl) ?
'R' :
'L';
17350 if ((!$this->newline) AND ($dom[$key][
'value'] ==
'img') AND (isset($dom[$key][
'height'])) AND ($dom[$key][
'height'] > 0)) {
17352 $imgh = $this->
getHTMLUnitToUnits($dom[$key][
'height'], ($dom[$key][
'fontsize'] / $this->k),
'px');
17353 $autolinebreak =
false;
17354 if (!empty($dom[$key][
'width'])) {
17355 $imgw = $this->
getHTMLUnitToUnits($dom[$key][
'width'], ($dom[$key][
'fontsize'] / $this->k),
'px',
false);
17356 if (($imgw <= ($this->w - $this->lMargin - $this->rMargin - $this->cell_padding[
'L'] - $this->cell_padding[
'R']))
17357 AND ((($this->rtl) AND (($this->x - $imgw) < ($this->lMargin + $this->cell_padding[
'L'])))
17358 OR ((!$this->rtl) AND (($this->x + $imgw) > ($this->w - $this->rMargin - $this->cell_padding[
'R']))))) {
17360 $autolinebreak =
true;
17361 $this->
Ln(
'', $cell);
17362 if ((!$dom[($key-1)][
'tag']) AND ($dom[($key-1)][
'value'] ==
' ')) {
17368 if (!$autolinebreak) {
17377 if ($this->page > $startlinepage) {
17379 if (isset($this->footerlen[$startlinepage])) {
17380 $curpos = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17384 $linebeg = substr($pagebuff, $startlinepos, ($curpos - $startlinepos));
17385 $tstart = substr($pagebuff, 0, $startlinepos);
17386 $tend = substr($this->
getPageBuffer($startlinepage), $curpos);
17390 $tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
17391 $tend = substr($pagebuff, $this->cntmrk[$this->page]);
17393 $yshift = ($minstartliney -
$this->y);
17394 if ($fontaligned) {
17395 $yshift += ($curfontsize /
$this->k);
17397 $try = sprintf(
'1 0 0 1 0 %F cm', ($yshift * $this->k));
17398 $this->
setPageBuffer($this->page, $tstart.
"\nq\n".$try.
"\n".$linebeg.
"\nQ\n".$tend);
17400 if (isset($this->PageAnnots[$this->page])) {
17401 $next_pask = count($this->PageAnnots[$this->page]);
17405 if (isset($this->PageAnnots[$startlinepage])) {
17406 foreach ($this->PageAnnots[$startlinepage] as $pak => $pac) {
17407 if ($pak >= $pask) {
17409 unset($this->PageAnnots[$startlinepage][$pak]);
17410 $npak = count($this->PageAnnots[$this->page]) - 1;
17411 $this->PageAnnots[
$this->page][$npak][
'y'] -= $yshift;
17415 $pask = $next_pask;
17419 $this->newline =
false;
17422 $minstartliney = min($this->y, $minstartliney);
17423 $maxbottomliney = ($startliney + $this->
getCellHeight($curfontsize / $this->k));
17425 } elseif (isset($dom[$key][
'fontname']) OR isset($dom[$key][
'fontstyle']) OR isset($dom[$key][
'fontsize']) OR isset($dom[$key][
'line-height'])) {
17427 $pfontname = $curfontname;
17428 $pfontstyle = $curfontstyle;
17429 $pfontsize = $curfontsize;
17430 $fontname = (isset($dom[$key][
'fontname']) ? $dom[$key][
'fontname'] : $curfontname);
17431 $fontstyle = (isset($dom[$key][
'fontstyle']) ? $dom[$key][
'fontstyle'] : $curfontstyle);
17432 $fontsize = (isset($dom[$key][
'fontsize']) ? $dom[$key][
'fontsize'] : $curfontsize);
17433 $fontascent = $this->
getFontAscent($fontname, $fontstyle, $fontsize);
17434 $fontdescent = $this->
getFontDescent($fontname, $fontstyle, $fontsize);
17435 if (($fontname != $curfontname) OR ($fontstyle != $curfontstyle) OR ($fontsize != $curfontsize)
17436 OR ($this->cell_height_ratio != $dom[$key][
'line-height'])
17437 OR ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'li')) ) {
17438 if (($key < ($maxel - 1)) AND (
17439 ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'li'))
17440 OR ($this->cell_height_ratio != $dom[$key][
'line-height'])
17441 OR (!$this->newline AND is_numeric($fontsize) AND is_numeric($curfontsize)
17442 AND ($fontsize >= 0) AND ($curfontsize >= 0)
17443 AND (($fontsize != $curfontsize) OR ($fontstyle != $curfontstyle) OR ($fontname != $curfontname)))
17445 if ($this->page > $startlinepage) {
17447 if (isset($this->footerlen[$startlinepage])) {
17448 $curpos = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17452 $linebeg = substr($pagebuff, $startlinepos, ($curpos - $startlinepos));
17453 $tstart = substr($pagebuff, 0, $startlinepos);
17454 $tend = substr($this->
getPageBuffer($startlinepage), $curpos);
17458 $tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
17459 $tend = substr($pagebuff, $this->cntmrk[$this->page]);
17461 $yshift = ($minstartliney -
$this->y);
17462 $try = sprintf(
'1 0 0 1 0 %F cm', ($yshift * $this->k));
17463 $this->
setPageBuffer($this->page, $tstart.
"\nq\n".$try.
"\n".$linebeg.
"\nQ\n".$tend);
17465 if (isset($this->PageAnnots[$this->page])) {
17466 $next_pask = count($this->PageAnnots[$this->page]);
17470 if (isset($this->PageAnnots[$startlinepage])) {
17471 foreach ($this->PageAnnots[$startlinepage] as $pak => $pac) {
17472 if ($pak >= $pask) {
17474 unset($this->PageAnnots[$startlinepage][$pak]);
17475 $npak = count($this->PageAnnots[$this->page]) - 1;
17476 $this->PageAnnots[
$this->page][$npak][
'y'] -= $yshift;
17480 $pask = $next_pask;
17485 if (!isset($dom[$key][
'line-height'])) {
17488 if (!$dom[$key][
'block']) {
17489 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']))) {
17490 $this->y += (((($curfontsize *
$this->cell_height_ratio) - ($fontsize * $dom[$key][
'line-height'])) / $this->k) + $curfontascent - $fontascent - $curfontdescent + $fontdescent) / 2;
17492 if (($dom[$key][
'value'] !=
'sup') AND ($dom[$key][
'value'] !=
'sub')) {
17493 $current_line_align_data =
array($key, $minstartliney, $maxbottomliney);
17494 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)))) {
17495 $minstartliney = min($this->y, $line_align_data[1]);
17496 $maxbottomliney = max(($this->y + $this->
getCellHeight($fontsize / $this->k)), $line_align_data[2]);
17498 $minstartliney = min($this->y, $minstartliney);
17499 $maxbottomliney = max(($this->y + $this->
getCellHeight($fontsize / $this->k)), $maxbottomliney);
17501 $line_align_data = $current_line_align_data;
17504 $this->cell_height_ratio = $dom[$key][
'line-height'];
17505 $fontaligned =
true;
17507 $this->
SetFont($fontname, $fontstyle, $fontsize);
17510 $curfontname = $fontname;
17511 $curfontstyle = $fontstyle;
17512 $curfontsize = $fontsize;
17513 $curfontascent = $fontascent;
17514 $curfontdescent = $fontdescent;
17519 $textfill = isset($dom[$key][
'fill']) ? $dom[$key][
'fill'] : (($this->textrendermode % 2) == 0);
17520 $textclip = isset($dom[$key][
'clip']) ? $dom[$key][
'clip'] : ($this->textrendermode > 3);
17522 if (isset($dom[$key][
'font-stretch']) AND ($dom[$key][
'font-stretch'] !==
false)) {
17525 if (isset($dom[$key][
'letter-spacing']) AND ($dom[$key][
'letter-spacing'] !==
false)) {
17528 if (($plalign ==
'J') AND $dom[$key][
'block']) {
17532 $curpos = $this->pagelen[$startlinepage];
17533 if (isset($dom[$key][
'bgcolor']) AND ($dom[$key][
'bgcolor'] !==
false)) {
17537 $wfill = $fill |
false;
17539 if (isset($dom[$key][
'fgcolor']) AND ($dom[$key][
'fgcolor'] !==
false)) {
17542 if (isset($dom[$key][
'strokecolor']) AND ($dom[$key][
'strokecolor'] !==
false)) {
17545 if (isset($dom[$key][
'align'])) {
17546 $lalign = $dom[$key][
'align'];
17553 if ($this->newline AND (strlen($dom[$key][
'value']) > 0) AND ($dom[$key][
'value'] !=
'td') AND ($dom[$key][
'value'] !=
'th')) {
17555 $fontaligned =
false;
17557 if (isset($startlinex)) {
17558 $yshift = ($minstartliney - $startliney);
17559 if (($yshift > 0) OR ($this->page > $startlinepage)) {
17564 $linew = abs($this->endlinex - $startlinex);
17565 if ($this->inxobj) {
17567 $pstart = substr($this->xobjects[$this->xobjid][
'outdata'], 0, $startlinepos);
17568 if (isset($opentagpos)) {
17569 $midpos = $opentagpos;
17574 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos, ($midpos - $startlinepos));
17575 $pend = substr($this->xobjects[$this->xobjid][
'outdata'], $midpos);
17577 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos);
17581 $pstart = substr($this->
getPageBuffer($startlinepage), 0, $startlinepos);
17582 if (isset($opentagpos) AND isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
17583 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17584 $midpos = min($opentagpos, $this->footerpos[$startlinepage]);
17585 } elseif (isset($opentagpos)) {
17586 $midpos = $opentagpos;
17587 } elseif (isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
17588 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
17589 $midpos = $this->footerpos[$startlinepage];
17594 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos, ($midpos - $startlinepos));
17595 $pend = substr($this->
getPageBuffer($startlinepage), $midpos);
17597 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos);
17601 if ((isset($plalign) AND ((($plalign ==
'C') OR ($plalign ==
'J') OR (($plalign ==
'R') AND (!$this->rtl)) OR (($plalign ==
'L') AND ($this->rtl)))))) {
17604 if (($plalign ==
'J') AND $this->
isRTLTextDir() AND ($this->num_columns > 1)) {
17605 $tw += $this->cell_padding[
'R'];
17607 if ($this->lMargin != $prevlMargin) {
17610 if ($this->rMargin != $prevrMargin) {
17619 $pos1 = intval($pos1);
17627 if ($pos1 == $pos2) {
17628 $pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
17629 if (substr($pmid, $pos1, 4) ==
'[()]') {
17630 $linew -= $one_space_width;
17631 } elseif ($pos1 == strpos($pmid,
'[(')) {
17640 $pos1 = intval($pos1);
17648 if ($pos1 == $pos2) {
17649 $pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
17650 $linew -= $one_space_width;
17654 $mdiff = ($tw - $linew);
17655 if ($plalign ==
'C') {
17657 $t_x = -($mdiff / 2);
17659 $t_x = ($mdiff / 2);
17661 } elseif ($plalign ==
'R') {
17664 } elseif ($plalign ==
'L') {
17667 } elseif (($plalign ==
'J') AND ($plalign == $lalign)) {
17676 $pmidtemp = preg_replace(
'/[\\\][\(]/x',
'\\#!#OP#!#', $pmidtemp);
17677 $pmidtemp = preg_replace(
'/[\\\][\)]/x',
'\\#!#CP#!#', $pmidtemp);
17679 if (preg_match_all(
'/\[\(([^\)]*)\)\]/x', $pmidtemp, $lnstring, PREG_PATTERN_ORDER)) {
17681 $maxkk = count($lnstring[1]) - 1;
17682 for ($kk=0; $kk <= $maxkk; ++$kk) {
17684 $lnstring[1][$kk] = str_replace(
'#!#OP#!#',
'(', $lnstring[1][$kk]);
17685 $lnstring[1][$kk] = str_replace(
'#!#CP#!#',
')', $lnstring[1][$kk]);
17687 $lnstring[2][$kk] = substr_count($lnstring[1][$kk], $spacestr);
17689 $ns += $lnstring[2][$kk];
17690 $lnstring[3][$kk] = $ns;
17696 $spacewidth = ($mdiff / ($ns - $no)) *
$this->k;
17697 if ($this->FontSize <= 0) {
17698 $this->FontSize = 1;
17700 $spacewidthu = -1000 * ($mdiff + (($ns + $no) * $one_space_width)) / $ns / $this->FontSize;
17701 if ($this->font_spacing != 0) {
17704 $spacewidthu += $osw;
17711 $prev_epsposbeg = 0;
17716 while (preg_match(
'/([0-9\.\+\-]*)[\s](Td|cm|m|l|c|re)[\s]/x', $pmid, $strpiece, PREG_OFFSET_CAPTURE, $offset) == 1) {
17718 $stroffset = strpos($pmid,
'[(', $offset);
17719 if (($stroffset !==
false) AND ($stroffset <= $strpiece[2][1])) {
17721 $offset = strpos($pmid,
')]', $stroffset);
17722 while (($offset !==
false) AND ($pmid[($offset - 1)] ==
'\\')) {
17723 $offset = strpos($pmid,
')]', ($offset + 1));
17725 if ($offset ===
false) {
17726 $this->
Error(
'HTML Justification: malformed PDF code.');
17731 $spacew = ($spacewidth * ($nsmax - $ns));
17733 $spacew = ($spacewidth * $ns);
17735 $offset = $strpiece[2][1] + strlen($strpiece[2][0]);
17736 $epsposend = strpos($pmid, $this->epsmarker.
'Q', $offset);
17737 if ($epsposend !== null) {
17738 $epsposend += strlen($this->epsmarker.
'Q');
17739 $epsposbeg = strpos($pmid,
'q'.$this->epsmarker, $offset);
17740 if ($epsposbeg === null) {
17741 $epsposbeg = strpos($pmid,
'q'.$this->epsmarker, ($prev_epsposbeg - 6));
17742 $prev_epsposbeg = $epsposbeg;
17744 if (($epsposbeg > 0) AND ($epsposend > 0) AND ($offset > $epsposbeg) AND ($offset < $epsposend)) {
17746 $trx = sprintf(
'1 0 0 1 %F 0 cm', $spacew);
17747 $pmid_b = substr($pmid, 0, $epsposbeg);
17748 $pmid_m = substr($pmid, $epsposbeg, ($epsposend - $epsposbeg));
17749 $pmid_e = substr($pmid, $epsposend);
17750 $pmid = $pmid_b.
"\nq\n".$trx.
"\n".$pmid_m.
"\nQ\n".$pmid_e;
17751 $offset = $epsposend;
17757 switch ($strpiece[2][0]) {
17763 preg_match(
'/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s]('.$strpiece[2][0].
')([\s]*)/x', $pmid, $xmatches);
17764 if (!isset($xmatches[1])) {
17767 $currentxpos = $xmatches[1];
17768 $textpos = $currentxpos;
17769 if (($strcount <= $maxkk) AND ($strpiece[2][0] ==
'Td')) {
17770 $ns = $lnstring[3][$strcount];
17772 $spacew = ($spacewidth * ($nsmax - $ns));
17777 if (preg_match(
'/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s]('.$strpiece[2][0].
')([\s]*)/x', $pmid, $pmatch) == 1) {
17778 $newpmid = sprintf(
'%F',(floatval($pmatch[1]) + $spacew)).
' '.$pmatch[2].
' x*#!#*x'.$pmatch[3].$pmatch[4];
17779 $pmid = str_replace($pmatch[0], $newpmid, $pmid);
17780 unset($pmatch, $newpmid);
17787 $this->lispacer =
'';
17790 preg_match(
'/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s](re)([\s]*)/x', $pmid, $xmatches);
17791 if (!isset($xmatches[1])) {
17794 $currentxpos = $xmatches[1];
17798 if ($currentxpos < $textpos) {
17799 $x_diff = ($spacewidth * ($nsmax - $lnstring[3][$strcount]));
17800 $w_diff = ($spacewidth * $lnstring[2][$strcount]);
17802 if ($strcount > 0) {
17803 $x_diff = ($spacewidth * ($nsmax - $lnstring[3][($strcount - 1)]));
17804 $w_diff = ($spacewidth * $lnstring[2][($strcount - 1)]);
17808 if ($currentxpos > $textpos) {
17809 if ($strcount > 0) {
17810 $x_diff = ($spacewidth * $lnstring[3][($strcount - 1)]);
17812 $w_diff = ($spacewidth * $lnstring[2][$strcount]);
17814 if ($strcount > 1) {
17815 $x_diff = ($spacewidth * $lnstring[3][($strcount - 2)]);
17817 if ($strcount > 0) {
17818 $w_diff = ($spacewidth * $lnstring[2][($strcount - 1)]);
17822 if (preg_match(
'/('.$xmatches[1].
')[\s]('.$xmatches[2].
')[\s]('.$xmatches[3].
')[\s]('.$strpiece[1][0].
')[\s](re)([\s]*)/x', $pmid, $pmatch) == 1) {
17823 $newx = sprintf(
'%F',(floatval($pmatch[1]) + $x_diff));
17824 $neww = sprintf(
'%F',(floatval($pmatch[3]) + $w_diff));
17825 $newpmid = $newx.
' '.$pmatch[2].
' '.$neww.
' '.$pmatch[4].
' x*#!#*x'.$pmatch[5].$pmatch[6];
17826 $pmid = str_replace($pmatch[0], $newpmid, $pmid);
17827 unset($pmatch, $newpmid, $newx, $neww);
17833 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);
17834 if (!isset($xmatches[1])) {
17837 $currentxpos = $xmatches[1];
17839 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) {
17840 $newx1 = sprintf(
'%F',(floatval($pmatch[1]) + $spacew));
17841 $newx2 = sprintf(
'%F',(floatval($pmatch[3]) + $spacew));
17842 $newx3 = sprintf(
'%F',(floatval($pmatch[5]) + $spacew));
17843 $newpmid = $newx1.
' '.$pmatch[2].
' '.$newx2.
' '.$pmatch[4].
' '.$newx3.
' '.$pmatch[6].
' x*#!#*x'.$pmatch[7].$pmatch[8];
17844 $pmid = str_replace($pmatch[0], $newpmid, $pmid);
17845 unset($pmatch, $newpmid, $newx1, $newx2, $newx3);
17851 $cxpos = ($currentxpos /
$this->k);
17852 $lmpos = ($this->lMargin + $this->cell_padding[
'L'] +
$this->feps);
17853 if ($this->inxobj) {
17855 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
17856 if (($pac[
'y'] >= $minstartliney) AND (($pac[
'x'] * $this->k) >= ($currentxpos - $this->feps)) AND (($pac[
'x'] * $this->k) <= ($currentxpos + $this->feps))) {
17857 if ($cxpos > $lmpos) {
17859 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17861 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17866 } elseif (isset($this->PageAnnots[$this->page])) {
17867 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
17868 if (($pac[
'y'] >= $minstartliney) AND (($pac[
'x'] * $this->k) >= ($currentxpos - $this->feps)) AND (($pac[
'x'] * $this->k) <= ($currentxpos + $this->feps))) {
17869 if ($cxpos > $lmpos) {
17871 $this->PageAnnots[
$this->page][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17873 $this->PageAnnots[
$this->page][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
17881 $pmid = str_replace(
'x*#!#*x',
'', $pmid);
17884 $spacew = $spacewidthu;
17885 if ($this->font_stretching != 100) {
17887 $spacew /= ($this->font_stretching / 100);
17891 $pmid = preg_replace(
'/[\\\][\(]/x',
'\\#!#OP#!#', $pmid);
17892 $pmid = preg_replace(
'/[\\\][\)]/x',
'\\#!#CP#!#', $pmid);
17893 if (preg_match_all(
'/\[\(([^\)]*)\)\]/x', $pmid, $pamatch) > 0) {
17894 foreach($pamatch[0] as $pk => $pmatch) {
17895 $replace = $pamatch[1][$pk];
17896 $replace = str_replace(
'#!#OP#!#',
'(', $replace);
17897 $replace = str_replace(
'#!#CP#!#',
')', $replace);
17898 $newpmid =
'[('.str_replace(chr(0).chr(32),
') '.sprintf(
'%F', $spacew).
' (', $replace).
')]';
17899 $pos = strpos($pmid, $pmatch, $pos);
17900 if ($pos !== FALSE) {
17901 $pmid = substr_replace($pmid, $newpmid, $pos, strlen($pmatch));
17907 if ($this->inxobj) {
17909 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.
"\n".$pmid.
"\n".$pend;
17911 $this->
setPageBuffer($startlinepage, $pstart.
"\n".$pmid.
"\n".$pend);
17913 $endlinepos = strlen($pstart.
"\n".$pmid.
"\n");
17916 if ($this->font_stretching != 100) {
17918 $spacewidth /= ($this->font_stretching / 100);
17920 $rs = sprintf(
'%F Tw', $spacewidth);
17921 $pmid = preg_replace(
"/\[\(/x", $rs.
' [(', $pmid);
17922 if ($this->inxobj) {
17924 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n".$pend;
17926 $this->
setPageBuffer($startlinepage, $pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n".$pend);
17928 $endlinepos = strlen($pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n");
17933 if (($t_x != 0) OR ($yshift < 0)) {
17935 $trx = sprintf(
'1 0 0 1 %F %F cm', ($t_x * $this->k), ($yshift * $this->k));
17936 $pstart .=
"\nq\n".$trx.
"\n".$pmid.
"\nQ\n";
17937 $endlinepos = strlen($pstart);
17938 if ($this->inxobj) {
17941 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
17942 if ($pak >= $pask) {
17943 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'x'] += $t_x;
17944 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'y'] -= $yshift;
17950 if (isset($this->PageAnnots[$this->page])) {
17951 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
17952 if ($pak >= $pask) {
17953 $this->PageAnnots[
$this->page][$pak][
'x'] += $t_x;
17954 $this->PageAnnots[
$this->page][$pak][
'y'] -= $yshift;
17959 $this->y -= $yshift;
17963 $this->newline =
false;
17966 if ($dom[$dom[$key][
'parent']][
'value'] ==
'sup') {
17968 } elseif ($dom[$dom[$key][
'parent']][
'value'] ==
'sub') {
17969 $startliney -= (($this->FontSizePt / 0.7) /
$this->k);
17971 $minstartliney = $startliney;
17972 $maxbottomliney = ($this->y + $this->
getCellHeight($fontsize / $this->k));
17975 if (isset($endlinepos) AND (!$pbrk)) {
17976 $startlinepos = $endlinepos;
17978 if ($this->inxobj) {
17980 $startlinepos = strlen($this->xobjects[$this->xobjid][
'outdata']);
17981 } elseif (!$this->InFooter) {
17982 if (isset($this->footerlen[$this->page])) {
17992 unset($endlinepos);
17993 $plalign = $lalign;
17994 if (isset($this->PageAnnots[$this->page])) {
17995 $pask = count($this->PageAnnots[$this->page]);
17999 if (!($dom[$key][
'tag'] AND !$dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'table')
18000 AND (isset($this->emptypagemrk[$this->page]))
18001 AND ($this->emptypagemrk[$this->page] == $this->pagelen[$this->page]))) {
18002 $this->
SetFont($fontname, $fontstyle, $fontsize);
18008 if (isset($opentagpos)) {
18009 unset($opentagpos);
18011 if ($dom[$key][
'tag']) {
18012 if ($dom[$key][
'opening']) {
18014 if (isset($dom[$key][
'text-indent']) AND $dom[$key][
'block']) {
18015 $this->textindent = $dom[$key][
'text-indent'];
18016 $this->newline =
true;
18019 if (($dom[$key][
'value'] ==
'table') AND isset($dom[$key][
'cols']) AND ($dom[$key][
'cols'] > 0)) {
18024 $wtmp = $this->w - $this->rMargin -
$this->x;
18027 if (isset($dom[$key][
'attribute'][
'cellspacing'])) {
18029 $cellspacing =
array(
'H' => $clsp,
'V' => $clsp);
18030 } elseif (isset($dom[$key][
'border-spacing'])) {
18031 $cellspacing = $dom[$key][
'border-spacing'];
18033 $cellspacing =
array(
'H' => 0,
'V' => 0);
18036 if (isset($dom[$key][
'width'])) {
18039 $table_width = $wtmp;
18041 $table_width -= (2 * $cellspacing[
'H']);
18042 if (!$this->inthead) {
18043 $this->y += $cellspacing[
'V'];
18046 $cellspacingx = -$cellspacing[
'H'];
18048 $cellspacingx = $cellspacing[
'H'];
18051 $table_columns_width = ($table_width - ($cellspacing[
'H'] * ($dom[$key][
'cols'] - 1)));
18054 if ($table_columns_width == 0 || $dom[$key][
'cols'] == 0)
18056 $table_min_column_width = 1;
18060 $table_min_column_width = ($table_columns_width / $dom[$key][
'cols']);
18062 if ($dom[$key][
'cols'] != 0)
18065 $table_colwidths = array_fill(0, $dom[$key][
'cols'], $table_min_column_width);
18070 if ($dom[$key][
'value'] ==
'tr') {
18075 if (($dom[$key][
'value'] ==
'td') OR ($dom[$key][
'value'] ==
'th')) {
18076 $trid = $dom[$key][
'parent'];
18077 $table_el = $dom[$trid][
'parent'];
18078 if (!isset($dom[$table_el][
'cols'])) {
18079 $dom[$table_el][
'cols'] = $dom[$trid][
'cols'];
18083 if (isset($dom[$key][
'border']) AND !empty($dom[$key][
'border'])) {
18084 $tdborder = $dom[$key][
'border'];
18086 $colspan = intval($dom[$key][
'attribute'][
'colspan']);
18087 if ($colspan <= 0) {
18091 if (isset($dom[($dom[$trid][
'parent'])][
'attribute'][
'cellpadding'])) {
18092 $crclpd = $this->
getHTMLUnitToUnits($dom[($dom[$trid][
'parent'])][
'attribute'][
'cellpadding'], 1,
'px');
18093 $current_cell_padding =
array(
'L' => $crclpd,
'T' => $crclpd,
'R' => $crclpd,
'B' => $crclpd);
18094 } elseif (isset($dom[($dom[$trid][
'parent'])][
'padding'])) {
18095 $current_cell_padding = $dom[($dom[$trid][
'parent'])][
'padding'];
18097 $current_cell_padding =
array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0);
18099 $this->cell_padding = $current_cell_padding;
18100 if (isset($dom[$key][
'height'])) {
18106 if (isset($dom[$key][
'content'])) {
18107 $cell_content = $dom[$key][
'content'];
18109 $cell_content =
' ';
18111 $tagtype = $dom[$key][
'value'];
18113 while (($key < $maxel) AND (!(($dom[$key][
'tag']) AND (!$dom[$key][
'opening']) AND ($dom[$key][
'value'] == $tagtype) AND ($dom[$key][
'parent'] == $parentid)))) {
18117 if (!isset($dom[$trid][
'startpage'])) {
18120 $this->
setPage($dom[$trid][
'startpage']);
18122 if (!isset($dom[$trid][
'startcolumn'])) {
18124 } elseif ($this->current_column != $dom[$trid][
'startcolumn']) {
18129 if (!isset($dom[$trid][
'starty'])) {
18132 $this->y = $dom[$trid][
'starty'];
18134 if (!isset($dom[$trid][
'startx'])) {
18136 $this->x += $cellspacingx;
18138 $this->x += ($cellspacingx / 2);
18140 if (isset($dom[$parentid][
'attribute'][
'rowspan'])) {
18141 $rowspan = intval($dom[$parentid][
'attribute'][
'rowspan']);
18146 if (isset($dom[$table_el][
'rowspans'])) {
18148 $rskmax = count($dom[$table_el][
'rowspans']);
18149 while ($rsk < $rskmax) {
18150 $trwsp = $dom[$table_el][
'rowspans'][$rsk];
18151 $rsstartx = $trwsp[
'startx'];
18152 $rsendx = $trwsp[
'endx'];
18154 if ($trwsp[
'startpage'] < $this->page) {
18155 if (($this->rtl) AND ($this->pagedim[$this->page][
'orm'] != $this->pagedim[$trwsp[
'startpage']][
'orm'])) {
18156 $dl = ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$trwsp[
'startpage']][
'orm']);
18159 } elseif ((!$this->rtl) AND ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$trwsp[
'startpage']][
'olm'])) {
18160 $dl = ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$trwsp[
'startpage']][
'olm']);
18165 if (($trwsp[
'rowspan'] > 0)
18166 AND ($rsstartx > ($this->x - $cellspacing[
'H'] - $current_cell_padding[
'L'] - $this->feps))
18167 AND ($rsstartx < ($this->x + $cellspacing[
'H'] + $current_cell_padding[
'R'] + $this->feps))
18168 AND (($trwsp[
'starty'] < ($this->y - $this->feps)) OR ($trwsp[
'startpage'] < $this->page) OR ($trwsp[
'startcolumn'] < $this->current_column))) {
18170 $this->x = $rsendx + $cellspacingx;
18172 $colid += $trwsp[
'colspan'];
18173 if (($trwsp[
'rowspan'] == 1)
18174 AND (isset($dom[$trid][
'endy']))
18175 AND (isset($dom[$trid][
'endpage']))
18176 AND (isset($dom[$trid][
'endcolumn']))
18177 AND ($trwsp[
'endpage'] == $dom[$trid][
'endpage'])
18178 AND ($trwsp[
'endcolumn'] == $dom[$trid][
'endcolumn'])) {
18180 $dom[$table_el][
'rowspans'][$rsk][
'endy'] = max($dom[$trid][
'endy'], $trwsp[
'endy']);
18181 $dom[$trid][
'endy'] = $dom[$table_el][
'rowspans'][$rsk][
'endy'];
18189 if (isset($dom[$parentid][
'width'])) {
18191 $cellw = $this->
getHTMLUnitToUnits($dom[$parentid][
'width'], $table_columns_width,
'px');
18192 $tmpcw = ($cellw / $colspan);
18193 for ($i = 0; $i < $colspan; ++$i) {
18194 $table_colwidths[($colid + $i)] = $tmpcw;
18199 for ($i = 0; $i < $colspan; ++$i) {
18200 $cellw += (isset($table_colwidths[($colid + $i)]) ? $table_colwidths[($colid + $i)] : 0);
18203 $cellw += (($colspan - 1) * $cellspacing[
'H']);
18205 $colid += $colspan;
18207 if ($rowspan > 1) {
18208 $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));
18210 $cellid = array_push($dom[$trid][
'cellpos'],
array(
'startx' => $this->x));
18211 if ($rowspan > 1) {
18212 $dom[$trid][
'cellpos'][($cellid - 1)][
'rowspanid'] = ($trsid - 1);
18215 if (isset($dom[$parentid][
'bgcolor']) AND ($dom[$parentid][
'bgcolor'] !==
false)) {
18216 $dom[$trid][
'cellpos'][($cellid - 1)][
'bgcolor'] = $dom[$parentid][
'bgcolor'];
18219 if (isset($tdborder) AND !empty($tdborder)) {
18220 $dom[$trid][
'cellpos'][($cellid - 1)][
'border'] = $tdborder;
18229 $this->colxshift[
's'] = $cellspacing;
18230 $this->colxshift[
'p'] = $current_cell_padding;
18232 $this->
MultiCell($cellw, $cellh, $cell_content,
false, $lalign,
false, 2,
'',
'',
true, 0,
true,
true, 0,
'T',
false);
18234 $this->colxshift =
array(
'x' => 0,
's' =>
array(
'H' => 0,
'V' => 0),
'p' =>
array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0));
18235 $this->lasth = $prevLastH;
18236 $this->cell_padding = $old_cell_padding;
18237 $dom[$trid][
'cellpos'][($cellid - 1)][
'endx'] = $this->x;
18239 if ($rowspan <= 1) {
18240 if (isset($dom[$trid][
'endy'])) {
18241 if (($this->page == $dom[$trid][
'endpage']) AND ($this->current_column == $dom[$trid][
'endcolumn'])) {
18242 $dom[$trid][
'endy'] = max($this->y, $dom[$trid][
'endy']);
18243 } elseif (($this->page > $dom[$trid][
'endpage']) OR ($this->current_column > $dom[$trid][
'endcolumn'])) {
18249 if (isset($dom[$trid][
'endpage'])) {
18250 $dom[$trid][
'endpage'] = max($this->page, $dom[$trid][
'endpage']);
18254 if (isset($dom[$trid][
'endcolumn'])) {
18255 $dom[$trid][
'endcolumn'] = max($this->current_column, $dom[$trid][
'endcolumn']);
18261 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endx'] = $this->x;
18262 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endy'] = $this->y;
18263 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endpage'] = $this->page;
18264 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endcolumn'] = $this->current_column;
18266 if (isset($dom[$table_el][
'rowspans'])) {
18268 foreach ($dom[$table_el][
'rowspans'] as
$k => $trwsp) {
18269 if ($trwsp[
'rowspan'] > 0) {
18270 if (isset($dom[$trid][
'endpage'])) {
18271 if (($trwsp[
'endpage'] == $dom[$trid][
'endpage']) AND ($trwsp[
'endcolumn'] == $dom[$trid][
'endcolumn'])) {
18272 $dom[$table_el][
'rowspans'][
$k][
'endy'] = max($dom[$trid][
'endy'], $trwsp[
'endy']);
18273 } elseif (($trwsp[
'endpage'] < $dom[$trid][
'endpage']) OR ($trwsp[
'endcolumn'] < $dom[$trid][
'endcolumn'])) {
18274 $dom[$table_el][
'rowspans'][
$k][
'endy'] = $dom[$trid][
'endy'];
18275 $dom[$table_el][
'rowspans'][
$k][
'endpage'] = $dom[$trid][
'endpage'];
18276 $dom[$table_el][
'rowspans'][
$k][
'endcolumn'] = $dom[$trid][
'endcolumn'];
18278 $dom[$trid][
'endy'] = $this->pagedim[$dom[$trid][
'endpage']][
'hk'] - $this->pagedim[$dom[$trid][
'endpage']][
'bm'];
18284 $this->x += ($cellspacingx / 2);
18287 if (!isset($opentagpos)) {
18288 if ($this->inxobj) {
18290 $opentagpos = strlen($this->xobjects[$this->xobjid][
'outdata']);
18291 } elseif (!$this->InFooter) {
18292 if (isset($this->footerlen[$this->page])) {
18306 if ($this->bordermrk[$this->page] > $old_bordermrk) {
18307 $startlinepos += ($this->bordermrk[
$this->page] - $old_bordermrk);
18309 if ($prev_numpages > $this->numpages) {
18313 } elseif (strlen($dom[$key][
'value']) > 0) {
18316 $this->
SetFont($pfontname, $pfontstyle, $pfontsize);
18319 $maxbottomliney = ($startliney + $this->
getCellHeight($this->FontSize));
18320 if (is_numeric($pfontsize) AND ($pfontsize > 0)) {
18323 $this->
SetFont($curfontname, $curfontstyle, $curfontsize);
18325 if (is_numeric($pfontsize) AND ($pfontsize > 0) AND is_numeric($curfontsize) AND ($curfontsize > 0) AND ($pfontsize != $curfontsize)) {
18326 $pfontascent = $this->
getFontAscent($pfontname, $pfontstyle, $pfontsize);
18327 $pfontdescent = $this->
getFontDescent($pfontname, $pfontstyle, $pfontsize);
18328 $this->y += ($this->
getCellHeight(($pfontsize - $curfontsize) / $this->k) + $pfontascent - $curfontascent - $pfontdescent + $curfontdescent) / 2;
18329 $minstartliney = min($this->y, $minstartliney);
18330 $maxbottomliney = max(($this->y + $this->
getCellHeight($pfontsize / $this->k)), $maxbottomliney);
18334 $this->htmlvspace = 0;
18339 if (preg_match(
'/^('.$this->re_space[
'p'].
'+)/'.$this->re_space[
'm'], $dom[$key][
'value'], $matches)) {
18340 $lsp = $matches[1];
18342 if (preg_match(
'/('.$this->re_space[
'p'].
'+)$/'.$this->re_space[
'm'], $dom[$key][
'value'], $matches)) {
18343 $rsp = $matches[1];
18345 $dom[$key][
'value'] = $rsp.$this->stringTrim($dom[$key][
'value']).$lsp;
18348 if (!$this->premode) {
18349 $prelen = strlen($dom[$key][
'value']);
18355 $dom[$key][
'value'] = $this->
stringLeftTrim($dom[$key][
'value']);
18357 $postlen = strlen($dom[$key][
'value']);
18358 if (($postlen == 0) AND ($prelen > 0)) {
18359 $dom[$key][
'trimmed_space'] =
true;
18363 $firstblock =
true;
18365 $firstblock =
false;
18367 $dom[$key][
'value'] = preg_replace(
'/^'.$this->re_space[
'p'].
'+$/'.$this->re_space[
'm'], chr(32), $dom[$key][
'value']);
18375 if (!isset($dom[$key][
'trimmed_space']) OR !$dom[$key][
'trimmed_space']) {
18377 if (!empty($this->HREF) AND (isset($this->HREF[
'url']))) {
18380 if (isset($dom[($dom[$key][
'parent'])][
'fgcolor']) AND ($dom[($dom[$key][
'parent'])][
'fgcolor'] !==
false)) {
18381 $hrefcolor = $dom[($dom[$key][
'parent'])][
'fgcolor'];
18384 if (isset($dom[($dom[$key][
'parent'])][
'fontstyle']) AND ($dom[($dom[$key][
'parent'])][
'fontstyle'] !==
false)) {
18385 $hrefstyle = $dom[($dom[$key][
'parent'])][
'fontstyle'];
18387 $strrest = $this->
addHtmlLink($this->HREF[
'url'], $dom[$key][
'value'], $wfill,
true, $hrefcolor, $hrefstyle,
true);
18393 $cwa = ($this->w - $this->rMargin -
$this->x);
18395 if (($strlinelen < $cwa) AND (isset($dom[($key + 1)])) AND ($dom[($key + 1)][
'tag']) AND (!$dom[($key + 1)][
'block'])) {
18397 $nkey = ($key + 1);
18398 $write_block =
true;
18399 $same_textdir =
true;
18403 while ($write_block AND isset($dom[$nkey])) {
18404 if ($dom[$nkey][
'tag']) {
18405 if ($dom[$nkey][
'block']) {
18407 $write_block =
false;
18409 $tmp_fontname = isset($dom[$nkey][
'fontname']) ? $dom[$nkey][
'fontname'] :
$this->FontFamily;
18410 $tmp_fontstyle = isset($dom[$nkey][
'fontstyle']) ? $dom[$nkey][
'fontstyle'] :
$this->FontStyle;
18411 $tmp_fontsize = isset($dom[$nkey][
'fontsize']) ? $dom[$nkey][
'fontsize'] :
$this->FontSizePt;
18412 $same_textdir = ($dom[$nkey][
'dir'] == $dom[$key][
'dir']);
18414 $nextstr =
TCPDF_STATIC::pregSplit(
'/'.$this->re_space[
'p'].
'+/', $this->re_space[
'm'], $dom[$nkey][
'value']);
18415 if (isset($nextstr[0]) AND $same_textdir) {
18416 $wadj += $this->
GetStringWidth($nextstr[0], $tmp_fontname, $tmp_fontstyle, $tmp_fontsize);
18417 if (isset($nextstr[1])) {
18418 $write_block =
false;
18425 if (($wadj > 0) AND (($strlinelen + $wadj) >= $cwa)) {
18428 $numblks = count($nextstr);
18429 if ($numblks > 1) {
18431 $wadj = ($cwa - $strlinelen + $this->
GetStringWidth($nextstr[($numblks - 1)]));
18438 if (($wadj > 0) AND (($this->rtl AND ($this->tmprtl ===
'L')) OR (!$this->rtl AND ($this->tmprtl ===
'R')))) {
18440 $reverse_dir =
true;
18442 $revshift = ($strlinelen + $wadj + 0.000001);
18444 $this->x += $revshift;
18446 $this->x -= $revshift;
18451 $strrest = $this->
Write($this->lasth, $dom[$key][
'value'],
'', $wfill,
'',
false, 0,
true, $firstblock, 0, $wadj);
18453 if ($reverse_dir AND ($wadj == 0)) {
18456 $reverse_dir =
false;
18460 $this->textindent = 0;
18461 if (strlen($strrest) > 0) {
18463 $this->newline =
true;
18464 if ($strrest == $dom[$key][
'value']) {
18470 $dom[$key][
'value'] = $strrest;
18473 $this->x -= $this->cell_padding[
'R'];
18475 $this->x += $this->cell_padding[
'L'];
18484 if ($this->font_spacing > 0) {
18494 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')) {
18496 if ((!$undo) AND (($this->y < $this->start_transaction_y) OR (($dom[$key][
'value'] ==
'tr') AND ($dom[($dom[$key][
'parent'])][
'endy'] < $this->start_transaction_y)))) {
18501 foreach ($this_method_vars as $vkey => $vval) {
18504 if (!empty($dom[$key][
'thead'])) {
18505 $this->inthead =
true;
18509 if ((!$this->
checkPageBreak($this->PageBreakTrigger + 1)) AND ($this->y < $pre_y)) {
18519 if (isset($startlinex)) {
18520 $yshift = ($minstartliney - $startliney);
18521 if (($yshift > 0) OR ($this->page > $startlinepage)) {
18526 $linew = abs($this->endlinex - $startlinex);
18527 if ($this->inxobj) {
18529 $pstart = substr($this->xobjects[$this->xobjid][
'outdata'], 0, $startlinepos);
18530 if (isset($opentagpos)) {
18531 $midpos = $opentagpos;
18536 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos, ($midpos - $startlinepos));
18537 $pend = substr($this->xobjects[$this->xobjid][
'outdata'], $midpos);
18539 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos);
18543 $pstart = substr($this->
getPageBuffer($startlinepage), 0, $startlinepos);
18544 if (isset($opentagpos) AND isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
18545 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
18546 $midpos = min($opentagpos, $this->footerpos[$startlinepage]);
18547 } elseif (isset($opentagpos)) {
18548 $midpos = $opentagpos;
18549 } elseif (isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
18550 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
18551 $midpos = $this->footerpos[$startlinepage];
18556 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos, ($midpos - $startlinepos));
18557 $pend = substr($this->
getPageBuffer($startlinepage), $midpos);
18559 $pmid = substr($this->
getPageBuffer($startlinepage), $startlinepos);
18563 if ((isset($plalign) AND ((($plalign ==
'C') OR (($plalign ==
'R') AND (!$this->rtl)) OR (($plalign ==
'L') AND ($this->rtl)))))) {
18566 if ($this->lMargin != $prevlMargin) {
18569 if ($this->rMargin != $prevrMargin) {
18578 $pos1 = intval($pos1);
18586 if ($pos1 == $pos2) {
18587 $pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
18588 if (substr($pmid, $pos1, 4) ==
'[()]') {
18589 $linew -= $one_space_width;
18590 } elseif ($pos1 == strpos($pmid,
'[(')) {
18599 $pos1 = intval($pos1);
18607 if ($pos1 == $pos2) {
18608 $pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
18609 $linew -= $one_space_width;
18613 $mdiff = ($tw - $linew);
18614 if ($plalign ==
'C') {
18616 $t_x = -($mdiff / 2);
18618 $t_x = ($mdiff / 2);
18620 } elseif ($plalign ==
'R') {
18623 } elseif ($plalign ==
'L') {
18628 if (($t_x != 0) OR ($yshift < 0)) {
18630 $trx = sprintf(
'1 0 0 1 %F %F cm', ($t_x * $this->k), ($yshift * $this->k));
18631 $pstart .=
"\nq\n".$trx.
"\n".$pmid.
"\nQ\n";
18632 $endlinepos = strlen($pstart);
18633 if ($this->inxobj) {
18636 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
18637 if ($pak >= $pask) {
18638 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'x'] += $t_x;
18639 $this->xobjects[
$this->xobjid][
'annotations'][$pak][
'y'] -= $yshift;
18645 if (isset($this->PageAnnots[$this->page])) {
18646 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
18647 if ($pak >= $pask) {
18648 $this->PageAnnots[
$this->page][$pak][
'x'] += $t_x;
18649 $this->PageAnnots[
$this->page][$pak][
'y'] -= $yshift;
18654 $this->y -= $yshift;
18660 if ($this->num_columns > 1) {
18662 } elseif ($this->page > $prevPage) {
18663 $this->lMargin = $this->pagedim[
$this->page][
'olm'];
18664 $this->rMargin = $this->pagedim[
$this->page][
'orm'];
18667 $this->cell_height_ratio = $prev_cell_height_ratio;
18668 $this->listnum = $prev_listnum;
18669 $this->listordered = $prev_listordered;
18670 $this->listcount = $prev_listcount;
18671 $this->lispacer = $prev_lispacer;
18672 if ($ln AND (!($cell AND ($dom[$key-1][
'value'] ==
'table')))) {
18673 $this->
Ln($this->lasth);
18674 if (($this->y < $maxbottomliney) AND ($startlinepage == $this->page)) {
18675 $this->y = $maxbottomliney;
18691 $parent = $dom[($dom[$key][
'parent'])];
18692 $firsttag = ($key == 1);
18694 if (isset($tag[
'dir'])) {
18697 $this->tmprtl =
false;
18699 if ($tag[
'block']) {
18703 if (isset($this->tagvspaces[$tag[
'value']][0][
'h']) AND ($this->tagvspaces[$tag[
'value']][0][
'h'] >= 0)) {
18704 $cur_h = $this->tagvspaces[$tag[
'value']][0][
'h'];
18705 } elseif (isset($tag[
'fontsize'])) {
18706 $cur_h = $this->
getCellHeight($tag[
'fontsize'] / $this->k);
18710 if (isset($this->tagvspaces[$tag[
'value']][0][
'n'])) {
18711 $on = $this->tagvspaces[$tag[
'value']][0][
'n'];
18712 } elseif (preg_match(
'/[h][0-9]/', $tag[
'value']) > 0) {
18717 if ((!isset($this->tagvspaces[$tag[
'value']])) AND (in_array($tag[
'value'],
array(
'div',
'dt',
'dd',
'li',
'br',
'hr')))) {
18720 $hb = ($on * $cur_h);
18722 if (($this->htmlvspace <= 0) AND ($on > 0)) {
18723 if (isset($parent[
'fontsize'])) {
18724 $hbz = (($parent[
'fontsize'] /
$this->k) * $this->cell_height_ratio);
18729 if (isset($dom[($key - 1)]) AND ($dom[($key - 1)][
'value'] ==
'table')) {
18735 if (isset($this->tagvspaces[$tag[
'value']][1][
'h']) AND ($this->tagvspaces[$tag[
'value']][1][
'h'] >= 0)) {
18736 $pre_h = $this->tagvspaces[$tag[
'value']][1][
'h'];
18737 } elseif (isset($parent[
'fontsize'])) {
18738 $pre_h = $this->
getCellHeight($parent[
'fontsize'] / $this->k);
18742 if (isset($this->tagvspaces[$tag[
'value']][1][
'n'])) {
18743 $cn = $this->tagvspaces[$tag[
'value']][1][
'n'];
18744 } elseif (preg_match(
'/[h][0-9]/', $tag[
'value']) > 0) {
18749 if (isset($this->tagvspaces[$tag[
'value']][1])) {
18750 $hbc = ($cn * $pre_h);
18754 switch($tag[
'value']) {
18758 $dom[$key][
'rowspans'] =
array();
18759 if (!isset($dom[$key][
'attribute'][
'nested']) OR ($dom[$key][
'attribute'][
'nested'] !=
'true')) {
18760 $this->htmlvspace = 0;
18764 $this->thead = $dom[$key][
'thead'];
18765 if (!isset($this->theadMargins) OR (empty($this->theadMargins))) {
18766 $this->theadMargins =
array();
18771 $this->theadMargins[
'cell'] = $cell;
18778 if (isset($tag[
'attribute'][
'cellpadding'])) {
18781 } elseif (isset($tag[
'padding'])) {
18782 $this->cell_padding = $tag[
'padding'];
18784 if (isset($tag[
'attribute'][
'cellspacing'])) {
18786 } elseif (isset($tag[
'border-spacing'])) {
18787 $cs = $tag[
'border-spacing'][
'V'];
18790 if ($this->
checkPageBreak(((2 * $cp) + (2 * $cs) + $this->lasth),
'',
false) OR ($this->y < $prev_y)) {
18791 $this->inthead =
true;
18799 $dom[$key][
'cellpos'] =
array();
18803 if ((isset($tag[
'height'])) AND ($tag[
'height'] !=
'')) {
18808 $this->
addHTMLVertSpace($hbz, max($hb, ($hrHeight / 2)), $cell, $firsttag);
18813 $wtmp -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
18815 if ((isset($tag[
'width'])) AND ($tag[
'width'] !=
'')) {
18824 $this->
addHTMLVertSpace(max($hbc, ($hrHeight / 2)), 0, $cell, !isset($dom[($key + 1)]));
18828 if (array_key_exists(
'href', $tag[
'attribute'])) {
18829 $this->HREF[
'url'] = $tag[
'attribute'][
'href'];
18834 if (!empty($tag[
'attribute'][
'src'])) {
18835 if ($tag[
'attribute'][
'src'][0] ===
'@') {
18837 $tag[
'attribute'][
'src'] =
'@'.base64_decode(substr($tag[
'attribute'][
'src'], 1));
18843 if (!isset($tag[
'width'])) {
18846 if (!isset($tag[
'height'])) {
18847 $tag[
'height'] = 0;
18852 $tag[
'attribute'][
'align'] =
'bottom';
18854 switch($tag[
'attribute'][
'align']) {
18876 $imglink = $this->HREF[
'url'];
18877 if ($imglink[0] ==
'#') {
18879 $lnkdata = explode(
',', $imglink);
18880 if (isset($lnkdata[0])) {
18881 $page = intval(substr($lnkdata[0], 1));
18885 if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
18886 $lnky = floatval($lnkdata[1]);
18896 if (isset($tag[
'border']) AND !empty($tag[
'border'])) {
18901 if (isset($tag[
'width'])) {
18902 $iw = $this->
getHTMLUnitToUnits($tag[
'width'], ($tag[
'fontsize'] / $this->k),
'px',
false);
18905 if (isset($tag[
'height'])) {
18906 $ih = $this->
getHTMLUnitToUnits($tag[
'height'], ($tag[
'fontsize'] / $this->k),
'px',
false);
18908 if (($type ==
'eps') OR ($type ==
'ai')) {
18909 $this->
ImageEps($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih, $imglink,
true, $align,
'',
$border,
true);
18910 } elseif ($type ==
'svg') {
18911 $this->
ImageSVG($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih, $imglink, $align,
'',
$border,
true);
18913 $this->
Image($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih,
'', $imglink, $align,
false, 300,
'',
false,
false,
$border,
false,
false,
true);
18921 $this->y = (($this->img_rb_y + $prevy - ($this->
getCellHeight($tag[
'fontsize'] / $this->k))) / 2);
18934 if ($this->listnum == 1) {
18958 if ($tag[
'value'] ==
'ol') {
18963 if (isset($tag[
'attribute'][
'start'])) {
18964 $this->listcount[
$this->listnum] = intval($tag[
'attribute'][
'start']) - 1;
18976 if ($this->listnum == 1) {
18989 if ($this->listordered[$this->listnum]) {
18992 $this->lispacer = $parent[
'attribute'][
'type'];
18994 $this->lispacer = $parent[
'listtype'];
18998 $this->lispacer =
'#';
19001 if (isset($tag[
'attribute'][
'value'])) {
19002 $this->listcount[
$this->listnum] = intval($tag[
'attribute'][
'value']);
19007 $this->lispacer = $parent[
'attribute'][
'type'];
19009 $this->lispacer = $parent[
'listtype'];
19013 $this->lispacer =
'!';
19018 case 'blockquote': {
19042 $this->premode =
true;
19046 $this->
SetXY($this->
GetX(), $this->
GetY() - ((0.7 * $this->FontSizePt) / $this->k));
19050 $this->
SetXY($this->
GetX(), $this->
GetY() + ((0.3 * $this->FontSizePt) / $this->k));
19064 if (isset($tag[
'attribute'][
'action'])) {
19065 $this->form_action = $tag[
'attribute'][
'action'];
19067 $this->
Error(
'Please explicitly set action attribute path!');
19069 if (isset($tag[
'attribute'][
'enctype'])) {
19070 $this->form_enctype = $tag[
'attribute'][
'enctype'];
19072 $this->form_enctype =
'application/x-www-form-urlencoded';
19074 if (isset($tag[
'attribute'][
'method'])) {
19075 $this->form_mode = $tag[
'attribute'][
'method'];
19077 $this->form_mode =
'post';
19083 $name = $tag[
'attribute'][
'name'];
19090 $prop[
'readonly'] =
true;
19093 $value = $tag[
'attribute'][
'value'];
19096 $opt[
'maxlen'] = intval($tag[
'attribute'][
'maxlength']);
19100 $w = intval($tag[
'attribute'][
'size']) * $this->
GetStringWidth(chr(32)) * 2;
19104 if (isset($tag[
'attribute'][
'checked']) AND (($tag[
'attribute'][
'checked'] ==
'checked') OR ($tag[
'attribute'][
'checked'] ==
'true'))) {
19109 if (isset($tag[
'align'])) {
19110 switch ($tag[
'align']) {
19125 switch ($tag[
'attribute'][
'type']) {
19127 if (isset($value)) {
19128 $opt[
'v'] = $value;
19130 $this->
TextField($name,
$w,
$h, $prop, $opt,
'',
'',
false);
19134 if (isset($value)) {
19135 $opt[
'v'] = $value;
19137 $prop[
'password'] =
'true';
19138 $this->
TextField($name,
$w,
$h, $prop, $opt,
'',
'',
false);
19142 if (!isset($value)) {
19145 $this->
CheckBox($name,
$w, $checked, $prop, $opt, $value,
'',
'',
false);
19149 if (!isset($value)) {
19152 $this->
RadioButton($name,
$w, $prop, $opt, $value, $checked,
'',
'',
false);
19156 if (!isset($value)) {
19161 $prop =
array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>
array(196, 196, 196),
'strokeColor'=>
array(255, 255, 255));
19163 $action[
'S'] =
'SubmitForm';
19165 if ($this->form_enctype !=
'FDF') {
19166 $action[
'Flags'] =
array(
'ExportFormat');
19168 if ($this->form_mode ==
'get') {
19169 $action[
'Flags'] =
array(
'GetMethod');
19171 $this->
Button($name,
$w,
$h, $value, $action, $prop, $opt,
'',
'',
false);
19175 if (!isset($value)) {
19180 $prop =
array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>
array(196, 196, 196),
'strokeColor'=>
array(255, 255, 255));
19181 $this->
Button($name,
$w,
$h, $value,
array(
'S'=>
'ResetForm'), $prop, $opt,
'',
'',
false);
19185 $prop[
'fileSelect'] =
'true';
19186 $this->
TextField($name,
$w,
$h, $prop, $opt,
'',
'',
false);
19187 if (!isset($value)) {
19192 $prop =
array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>
array(196, 196, 196),
'strokeColor'=>
array(255, 255, 255));
19193 $jsaction =
'var f=this.getField(\''.$name.
'\'); f.browseForFileToSubmit();
'; 19194 $this->Button('FB_
'.$name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false); 19198 if (isset($value)) { 19199 $opt['v
'] = $value; 19201 $opt['f
'] = array('invisible
', 'hidden
'); 19202 $this->TextField($name, 0, 0, $prop, $opt, '', '', false); 19206 // THIS TYPE MUST BE FIXED 19207 if (isset($tag['attribute
']['src
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['src
'])) { 19208 $img = $tag['attribute
']['src
']; 19213 //$opt['mk
'] = array('i
'=>$img, 'tp
'=>1, 'if'=>array('sw
'=>'A
', 's'=>'A
', 'fb
'=>false)); 19214 if (isset($tag['attribute
']['onclick
']) AND !empty($tag['attribute
']['onclick
'])) { 19215 $jsaction = $tag['attribute
']['onclick
']; 19219 $this->Button($name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false); 19223 if (!isset($value)) { 19226 $w = $this->GetStringWidth($value) * 1.5; 19228 $prop = array('lineWidth
'=>1, 'borderStyle
'=>'beveled
', 'fillColor
'=>array(196, 196, 196), 'strokeColor
'=>array(255, 255, 255)); 19229 if (isset($tag['attribute
']['onclick
']) AND !empty($tag['attribute
']['onclick
'])) { 19230 $jsaction = $tag['attribute
']['onclick
']; 19234 $this->Button($name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false); 19243 if (isset($tag['attribute
']['readonly
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['readonly
'])) { 19244 $prop['readonly
'] = true; 19246 if (isset($tag['attribute
']['name
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['name
'])) { 19247 $name = $tag['attribute
']['name
']; 19251 if (isset($tag['attribute
']['value
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['value
'])) { 19252 $opt['v
'] = $tag['attribute
']['value
']; 19254 if (isset($tag['attribute
']['cols
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['cols
'])) { 19255 $w = intval($tag['attribute
']['cols
']) * $this->GetStringWidth(chr(32)) * 2; 19259 if (isset($tag['attribute
']['rows']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['rows'])) { 19260 $h = intval($tag['attribute
']['rows']) * $this->getCellHeight($this->FontSize); 19264 $prop['multiline
'] = 'true'; 19265 $this->TextField($name, $w, $h, $prop, $opt, '', '', false); 19269 $h = $this->getCellHeight($this->FontSize); 19270 if (isset($tag['attribute
']['size']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['size'])) { 19271 $h *= ($tag['attribute
']['size'] + 1); 19275 if (isset($tag['attribute
']['name
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['name
'])) { 19276 $name = $tag['attribute
']['name
']; 19281 if (isset($tag['attribute
']['opt
']) AND !TCPDF_STATIC::empty_string($tag['attribute
']['opt
'])) { 19282 $options = explode('#!NwL!#
', $tag['attribute
']['opt
']); 19284 foreach ($options as $val) { 19285 if (strpos($val, '#!TaB!#
') !== false) { 19286 $opts = explode('#!TaB!#
', $val); 19288 $w = max($w, $this->GetStringWidth($opts[1])); 19291 $w = max($w, $this->GetStringWidth($val)); 19298 if (isset($tag['attribute
']['multiple
']) AND ($tag['attribute
']['multiple
']='multiple
')) { 19299 $prop['multipleSelection
'] = 'true'; 19300 $this->ListBox($name, $w, $h, $values, $prop, $opt, '', '', false); 19302 $this->ComboBox($name, $w, $h, $values, $prop, $opt, '', '', false); 19308 // Special tag used to call TCPDF methods 19309 if (isset($tag['attribute
']['method
'])) { 19310 $tcpdf_method = $tag['attribute
']['method
']; 19311 if (method_exists($this, $tcpdf_method)) { 19312 if (isset($tag['attribute
']['params
']) AND (!empty($tag['attribute
']['params
']))) { 19313 $params = $this->unserializeTCPDFtagParameters($tag['attribute
']['params
']); 19314 call_user_func_array(array($this, $tcpdf_method), $params); 19316 $this->$tcpdf_method(); 19318 $this->newline = true; 19328 // define tags that support borders and background colors 19329 $bordertags = array('blockquote
','br
','dd
','dl
','div
','dt
','h1
','h2
','h3
','h4
','h5
','h6
','hr
','li
','ol
','p','pre
','ul
','tcpdf
','table
'); 19330 if (in_array($tag['value
'], $bordertags)) { 19332 $dom[$key]['borderposition
'] = $this->getBorderStartPosition(); 19334 if ($dom[$key]['self'] AND isset($dom[$key]['attribute
']['pagebreakafter
'])) { 19335 $pba = $dom[$key]['attribute
']['pagebreakafter
']; 19336 // check for pagebreak 19337 if (($pba == 'true') OR ($pba == 'left') OR ($pba == 'right
')) { 19338 // add a page (or trig AcceptPageBreak() for multicolumn mode) 19339 $this->checkPageBreak($this->PageBreakTrigger + 1); 19341 if ((($pba == 'left') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0)))) 19342 OR (($pba == 'right
') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) { 19343 // add a page (or trig AcceptPageBreak() for multicolumn mode) 19344 $this->checkPageBreak($this->PageBreakTrigger + 1); 19359 protected function closeHTMLTagHandler($dom, $key, $cell, $maxbottomliney=0) { 19361 $parent = $dom[($dom[$key]['parent'])]; 19362 $lasttag = ((!isset($dom[($key + 1)])) OR ((!isset($dom[($key + 2)])) AND ($dom[($key + 1)]['value
'] == 'marker
'))); 19363 $in_table_head = false; 19364 // maximum x position (used to draw borders) 19370 if ($tag['block
']) { 19371 $hbz = 0; // distance from y to line bottom 19372 $hb = 0; // vertical space between block tags 19373 // calculate vertical space for block tags 19374 if (isset($this->tagvspaces[$tag['value
']][1]['h
']) AND ($this->tagvspaces[$tag['value
']][1]['h
'] >= 0)) { 19375 $pre_h = $this->tagvspaces[$tag['value
']][1]['h
']; 19376 } elseif (isset($parent['fontsize
'])) { 19377 $pre_h = $this->getCellHeight($parent['fontsize
'] / $this->k); 19379 $pre_h = $this->getCellHeight($this->FontSize); 19381 if (isset($this->tagvspaces[$tag['value
']][1]['n'])) { 19382 $cn = $this->tagvspaces[$tag['value
']][1]['n']; 19383 } elseif (preg_match('/[h][0-9]/
', $tag['value
']) > 0) { 19388 if ((!isset($this->tagvspaces[$tag['value
']])) AND ($tag['value
'] == 'div
')) { 19391 $hb = ($cn * $pre_h); 19393 if ($maxbottomliney > $this->PageBreakTrigger) { 19394 $hbz = $this->getCellHeight($this->FontSize); 19395 } elseif ($this->y < $maxbottomliney) { 19396 $hbz = ($maxbottomliney - $this->y); 19400 switch($tag['value
']) { 19403 if (!isset($parent['endy
'])) { 19404 $dom[($dom[$key]['parent'])]['endy
'] = $this->y; 19405 $parent['endy
'] = $this->y; 19407 if (!isset($parent['endpage
'])) { 19408 $dom[($dom[$key]['parent'])]['endpage
'] = $this->page; 19409 $parent['endpage
'] = $this->page; 19411 if (!isset($parent['endcolumn
'])) { 19412 $dom[($dom[$key]['parent'])]['endcolumn
'] = $this->current_column; 19413 $parent['endcolumn
'] = $this->current_column; 19415 // update row-spanned cells 19416 if (isset($dom[$table_el]['rowspans
'])) { 19417 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) { 19418 $dom[$table_el]['rowspans
'][$k]['rowspan
'] -= 1; 19419 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) { 19420 if (($dom[$table_el]['rowspans
'][$k]['endpage
'] == $parent['endpage
']) AND ($dom[$table_el]['rowspans
'][$k]['endcolumn
'] == $parent['endcolumn
'])) { 19421 $dom[($dom[$key]['parent'])]['endy
'] = max($dom[$table_el]['rowspans
'][$k]['endy
'], $parent['endy
']); 19422 } elseif (($dom[$table_el]['rowspans
'][$k]['endpage
'] > $parent['endpage
']) OR ($dom[$table_el]['rowspans
'][$k]['endcolumn
'] > $parent['endcolumn
'])) { 19423 $dom[($dom[$key]['parent'])]['endy
'] = $dom[$table_el]['rowspans
'][$k]['endy
']; 19424 $dom[($dom[$key]['parent'])]['endpage
'] = $dom[$table_el]['rowspans
'][$k]['endpage
']; 19425 $dom[($dom[$key]['parent'])]['endcolumn
'] = $dom[$table_el]['rowspans
'][$k]['endcolumn
']; 19429 // report new endy and endpage to the rowspanned cells 19430 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) { 19431 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) { 19432 $dom[$table_el]['rowspans
'][$k]['endpage
'] = max($dom[$table_el]['rowspans
'][$k]['endpage
'], $dom[($dom[$key]['parent'])]['endpage
']); 19433 $dom[($dom[$key]['parent'])]['endpage
'] = $dom[$table_el]['rowspans
'][$k]['endpage
']; 19434 $dom[$table_el]['rowspans
'][$k]['endcolumn
'] = max($dom[$table_el]['rowspans
'][$k]['endcolumn
'], $dom[($dom[$key]['parent'])]['endcolumn
']); 19435 $dom[($dom[$key]['parent'])]['endcolumn
'] = $dom[$table_el]['rowspans
'][$k]['endcolumn
']; 19436 $dom[$table_el]['rowspans
'][$k]['endy
'] = max($dom[$table_el]['rowspans
'][$k]['endy
'], $dom[($dom[$key]['parent'])]['endy
']); 19437 $dom[($dom[$key]['parent'])]['endy
'] = $dom[$table_el]['rowspans
'][$k]['endy
']; 19440 // update remaining rowspanned cells 19441 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) { 19442 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) { 19443 $dom[$table_el]['rowspans
'][$k]['endpage
'] = $dom[($dom[$key]['parent'])]['endpage
']; 19444 $dom[$table_el]['rowspans
'][$k]['endcolumn
'] = $dom[($dom[$key]['parent'])]['endcolumn
']; 19445 $dom[$table_el]['rowspans
'][$k]['endy
'] = $dom[($dom[$key]['parent'])]['endy
']; 19449 $prev_page = $this->page; 19450 $this->setPage($dom[($dom[$key]['parent'])]['endpage
']); 19451 if ($this->num_columns > 1) { 19452 if (($prev_page < $this->page) 19453 AND ((($this->current_column == 0) AND ($dom[($dom[$key]['parent'])]['endcolumn
'] == ($this->num_columns - 1))) 19454 OR ($this->current_column == $dom[($dom[$key]['parent'])]['endcolumn
']))) { 19456 $this->selectColumn(0); 19457 $dom[($dom[$key]['parent'])]['endcolumn
'] = 0; 19458 $dom[($dom[$key]['parent'])]['endy
'] = $this->y; 19460 $this->selectColumn($dom[($dom[$key]['parent'])]['endcolumn
']); 19461 $this->y = $dom[($dom[$key]['parent'])]['endy
']; 19464 $this->y = $dom[($dom[$key]['parent'])]['endy
']; 19466 if (isset($dom[$table_el]['attribute
']['cellspacing
'])) { 19467 $this->y += $this->getHTMLUnitToUnits($dom[$table_el]['attribute
']['cellspacing
'], 1, 'px
'); 19468 } elseif (isset($dom[$table_el]['border-spacing
'])) { 19469 $this->y += $dom[$table_el]['border-spacing
']['V
']; 19471 $this->Ln(0, $cell); 19472 if ($this->current_column == $parent['startcolumn
']) { 19473 $this->x = $parent['startx
']; 19475 // account for booklet mode 19476 if ($this->page > $parent['startpage
']) { 19477 if (($this->rtl) AND ($this->pagedim[$this->page]['orm
'] != $this->pagedim[$parent['startpage
']]['orm
'])) { 19478 $this->x -= ($this->pagedim[$this->page]['orm
'] - $this->pagedim[$parent['startpage
']]['orm
']); 19479 } elseif ((!$this->rtl) AND ($this->pagedim[$this->page]['olm
'] != $this->pagedim[$parent['startpage
']]['olm
'])) { 19480 $this->x += ($this->pagedim[$this->page]['olm
'] - $this->pagedim[$parent['startpage
']]['olm
']); 19486 // closing tag used for the thead part 19487 $in_table_head = true; 19488 $this->inthead = false; 19490 $table_el = $parent; 19491 // set default border 19492 if (isset($table_el['attribute
']['border
']) AND ($table_el['attribute
']['border
'] > 0)) { 19493 // set default border 19494 $border = array('LTRB
' => array('width
' => $this->getCSSBorderWidth($table_el['attribute
']['border
']), 'cap
'=>'square
', 'join
'=>'miter
', 'dash
'=> 0, 'color'=>array(0,0,0))); 19498 $default_border = $border; 19499 // fix bottom line alignment of last line before page break 19500 foreach ($dom[($dom[$key]['parent'])]['trids
'] as $j => $trkey) { 19501 // update row-spanned cells 19502 if (isset($dom[($dom[$key]['parent'])]['rowspans
'])) { 19503 foreach ($dom[($dom[$key]['parent'])]['rowspans
'] as $k => $trwsp) { 19504 if (isset($prevtrkey) AND ($trwsp['trid
'] == $prevtrkey) AND ($trwsp['mrowspan
'] > 0)) { 19505 $dom[($dom[$key]['parent'])]['rowspans
'][$k]['trid
'] = $trkey; 19507 if ($dom[($dom[$key]['parent'])]['rowspans
'][$k]['trid
'] == $trkey) { 19508 $dom[($dom[$key]['parent'])]['rowspans
'][$k]['mrowspan
'] -= 1; 19512 if (isset($prevtrkey) AND ($dom[$trkey]['startpage
'] > $dom[$prevtrkey]['endpage
'])) { 19513 $pgendy = $this->pagedim[$dom[$prevtrkey]['endpage
']]['hk
'] - $this->pagedim[$dom[$prevtrkey]['endpage
']]['bm
']; 19514 $dom[$prevtrkey]['endy
'] = $pgendy; 19515 // update row-spanned cells 19516 if (isset($dom[($dom[$key]['parent'])]['rowspans
'])) { 19517 foreach ($dom[($dom[$key]['parent'])]['rowspans
'] as $k => $trwsp) { 19518 if (($trwsp['trid
'] == $prevtrkey) AND ($trwsp['mrowspan
'] >= 0) AND ($trwsp['endpage
'] == $dom[$prevtrkey]['endpage
'])) { 19519 $dom[($dom[$key]['parent'])]['rowspans
'][$k]['endy
'] = $pgendy; 19520 $dom[($dom[$key]['parent'])]['rowspans
'][$k]['mrowspan
'] = -1; 19525 $prevtrkey = $trkey; 19526 $table_el = $dom[($dom[$key]['parent'])]; 19529 if (count($table_el['trids
']) > 0) { 19532 foreach ($table_el['trids
'] as $j => $trkey) { 19533 $parent = $dom[$trkey]; 19534 if (!isset($xmax)) { 19535 $xmax = $parent['cellpos
'][(count($parent['cellpos
']) - 1)]['endx
']; 19537 // for each cell on the row 19538 foreach ($parent['cellpos
'] as $k => $cellpos) { 19539 if (isset($cellpos['rowspanid
']) AND ($cellpos['rowspanid
'] >= 0)) { 19540 $cellpos['startx
'] = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startx
']; 19541 $cellpos['endx
'] = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endx
']; 19542 $endy = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endy
']; 19543 $startpage = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startpage
']; 19544 $endpage = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endpage
']; 19545 $startcolumn = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startcolumn
']; 19546 $endcolumn = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endcolumn
']; 19548 $endy = $parent['endy
']; 19549 $startpage = $parent['startpage
']; 19550 $endpage = $parent['endpage
']; 19551 $startcolumn = $parent['startcolumn
']; 19552 $endcolumn = $parent['endcolumn
']; 19554 if ($this->num_columns == 0) { 19555 $this->num_columns = 1; 19557 if (isset($cellpos['border
'])) { 19558 $border = $cellpos['border
']; 19560 if (isset($cellpos['bgcolor
']) AND ($cellpos['bgcolor
']) !== false) { 19561 $this->SetFillColorArray($cellpos['bgcolor
']); 19566 $x = $cellpos['startx
']; 19567 $y = $parent['starty
']; 19569 $w = abs($cellpos['endx
'] - $cellpos['startx
']); 19570 // get border modes 19571 $border_start = TCPDF_STATIC::getBorderMode($border, $position='start
', $this->opencell); 19572 $border_end = TCPDF_STATIC::getBorderMode($border, $position='end
', $this->opencell); 19573 $border_middle = TCPDF_STATIC::getBorderMode($border, $position='middle
', $this->opencell); 19574 // design borders around HTML cells. 19575 for ($page = $startpage; $page <= $endpage; ++$page) { // for each page 19577 $this->setPage($page); 19578 if ($this->num_columns < 2) { 19579 // single-column mode 19581 $this->y = $this->tMargin; 19583 // account for margin changes 19584 if ($page > $startpage) { 19585 if (($this->rtl) AND ($this->pagedim[$page]['orm
'] != $this->pagedim[$startpage]['orm
'])) { 19586 $this->x -= ($this->pagedim[$page]['orm
'] - $this->pagedim[$startpage]['orm
']); 19587 } elseif ((!$this->rtl) AND ($this->pagedim[$page]['olm
'] != $this->pagedim[$startpage]['olm
'])) { 19588 $this->x += ($this->pagedim[$page]['olm
'] - $this->pagedim[$startpage]['olm
']); 19591 if ($startpage == $endpage) { // single page 19594 for ($column = $startcolumn; $column <= $endcolumn; ++$column) { // for each column 19595 $this->selectColumn($column); 19596 if ($startcolumn == $endcolumn) { // single column 19597 $cborder = $border; 19598 $h = $endy - $parent['starty
']; 19601 } elseif ($column == $startcolumn) { // first column 19602 $cborder = $border_start; 19603 $this->y = $starty; 19605 $h = $this->h - $this->y - $this->bMargin; 19607 $deltacol = $this->x + $this->rMargin - $this->w; 19609 $deltacol = $this->x - $this->lMargin; 19611 } elseif ($column == $endcolumn) { // end column 19612 $cborder = $border_end; 19613 if (isset($this->columns[$column]['th
']['\
''.$page.
'\''])) {
19616 $this->x += $deltacol;
19619 $cborder = $border_middle;
19623 $this->x += $deltacol;
19626 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19628 } elseif (
$page == $startpage) {
19633 if (
$column == $startcolumn) {
19634 $cborder = $border_start;
19639 $deltacol = $this->x + $this->rMargin -
$this->w;
19644 $cborder = $border_middle;
19648 $this->x += $deltacol;
19651 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19653 } elseif (
$page == $endpage) {
19659 $cborder = $border_end;
19663 $this->x += $deltacol;
19666 $cborder = $border_middle;
19670 $this->x += $deltacol;
19673 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19680 $cborder = $border_middle;
19684 $this->x += $deltacol;
19686 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
19689 if (!empty($cborder) OR !empty($fill)) {
19690 $offsetlen = strlen($ccode);
19692 if ($this->inxobj) {
19694 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
19695 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
19696 $pagemark = $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey];
19697 $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey] += $offsetlen;
19703 $pstart = substr($pagebuff, 0, $pagemark);
19704 $pend = substr($pagebuff, $pagemark);
19705 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
19708 if (end($this->transfmrk[$this->page]) !==
false) {
19709 $pagemarkkey = key($this->transfmrk[$this->page]);
19710 $pagemark = $this->transfmrk[
$this->page][$pagemarkkey];
19711 } elseif ($this->InFooter) {
19717 $pstart = substr($pagebuff, 0, $pagemark);
19718 $pend = substr($pagebuff, $pagemark);
19726 if (isset($table_el[
'attribute'][
'cellspacing'])) {
19727 $this->y += $this->
getHTMLUnitToUnits($table_el[
'attribute'][
'cellspacing'], 1,
'px');
19728 } elseif (isset($table_el[
'border-spacing'])) {
19729 $this->y += $table_el[
'border-spacing'][
'V'];
19731 $this->
Ln(0, $cell);
19732 $this->x = $parent[
'startx'];
19733 if ($endpage > $startpage) {
19734 if (($this->rtl) AND ($this->pagedim[$endpage][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
19735 $this->x += ($this->pagedim[$endpage][
'orm'] - $this->pagedim[$startpage][
'orm']);
19736 } elseif ((!$this->rtl) AND ($this->pagedim[$endpage][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
19737 $this->x += ($this->pagedim[$endpage][
'olm'] - $this->pagedim[$startpage][
'olm']);
19741 if (!$in_table_head) {
19742 $this->cell_padding = $table_el[
'old_cell_padding'];
19745 if (($this->page == ($this->numpages - 1)) AND ($this->pageopen[$this->numpages])) {
19747 if (($plendiff > 0) AND ($plendiff < 60)) {
19748 $pagediff = substr($this->
getPageBuffer($this->numpages), $this->emptypagemrk[$this->numpages], $plendiff);
19749 if (substr($pagediff, 0, 5) ==
'BT /F') {
19754 if ($plendiff == 0) {
19759 if (isset($this->theadMargins[
'top'])) {
19761 $this->tMargin = $this->theadMargins[
'top'];
19763 if (!isset($table_el[
'attribute'][
'nested']) OR ($table_el[
'attribute'][
'nested'] !=
'true')) {
19766 $this->theadMargins =
array();
19770 $parent = $table_el;
19778 $this->
SetXY($this->
GetX(), $this->
GetY() + ((0.7 * $parent[
'fontsize']) / $this->k));
19782 $this->
SetXY($this->
GetX(), $this->
GetY() - ((0.3 * $parent[
'fontsize']) / $this->k));
19789 case 'blockquote': {
19805 $this->premode =
false;
19810 if ($this->listnum <= 0) {
19811 $this->listnum = 0;
19820 $this->lispacer =
'';
19825 $this->lispacer =
'';
19838 $this->lispacer =
'';
19845 if ($this->listnum <= 0) {
19846 $this->listnum = 0;
19855 $this->lispacer =
'';
19870 $this->form_action =
'';
19871 $this->form_enctype =
'application/x-www-form-urlencoded';
19880 if (isset($dom[($dom[$key][
'parent'])][
'attribute'][
'pagebreakafter'])) {
19881 $pba = $dom[($dom[$key][
'parent'])][
'attribute'][
'pagebreakafter'];
19883 if (($pba ==
'true') OR ($pba ==
'left') OR ($pba ==
'right')) {
19887 if ((($pba ==
'left') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
19888 OR (($pba ==
'right') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
19893 $this->tmprtl =
false;
19908 $this->
Ln(0, $cell);
19909 $this->htmlvspace = 0;
19913 $this->
Ln($hbz, $cell);
19914 $this->htmlvspace = 0;
19917 if ($hb < $this->htmlvspace) {
19921 $this->htmlvspace = $hb;
19923 $this->
Ln(($hbz + $hd), $cell);
19938 return array(
'page' => $this->page,
'column' => $this->current_column,
'x' => $this->x,
'y' => $this->y,
'xmax' => $xmax);
19949 if (!isset($tag[
'borderposition'])) {
19959 if (isset($tag[
'border']) AND !empty($tag[
'border'])) {
19967 if (isset($tag[
'bgcolor']) AND ($tag[
'bgcolor'] !==
false)) {
19977 if (isset($tag[
'attribute'][
'cellspacing'])) {
19979 $cellspacing =
array(
'H' => $clsp,
'V' => $clsp);
19980 } elseif (isset($tag[
'border-spacing'])) {
19981 $cellspacing = $tag[
'border-spacing'];
19983 $cellspacing =
array(
'H' => 0,
'V' => 0);
19985 if (($tag[
'value'] !=
'table') AND (is_array(
$border)) AND (!empty(
$border))) {
19990 if ($xmax >= $tag[
'borderposition'][
'x']) {
19991 $xmax = $tag[
'borderposition'][
'xmax'];
19993 $w = ($tag[
'borderposition'][
'x'] - $xmax);
19995 if ($xmax <= $tag[
'borderposition'][
'x']) {
19996 $xmax = $tag[
'borderposition'][
'xmax'];
19998 $w = ($xmax - $tag[
'borderposition'][
'x']);
20003 $w += $cellspacing[
'H'];
20004 $startpage = $tag[
'borderposition'][
'page'];
20005 $startcolumn = $tag[
'borderposition'][
'column'];
20006 $x = $tag[
'borderposition'][
'x'];
20007 $y = $tag[
'borderposition'][
'y'];
20009 $starty = $tag[
'borderposition'][
'y'] - $cellspacing[
'V'];
20014 if ($this->num_columns == 0) {
20015 $this->num_columns = 1;
20023 $this->page_regions =
array();
20028 if ($this->num_columns < 2) {
20034 if (
$page > $startpage) {
20035 if (($this->rtl) AND ($this->pagedim[
$page][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
20036 $this->x -= ($this->pagedim[
$page][
'orm'] - $this->pagedim[$startpage][
'orm']);
20037 } elseif ((!$this->rtl) AND ($this->pagedim[
$page][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
20038 $this->x += ($this->pagedim[
$page][
'olm'] - $this->pagedim[$startpage][
'olm']);
20041 if ($startpage == $endpage) {
20045 if ($startcolumn == $endcolumn) {
20047 $h = ($currentY -
$y) + $cellspacing[
'V'];
20049 } elseif (
$column == $startcolumn) {
20050 $cborder = $border_start;
20053 } elseif (
$column == $endcolumn) {
20054 $cborder = $border_end;
20057 $cborder = $border_middle;
20060 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
20062 } elseif (
$page == $startpage) {
20065 if (
$column == $startcolumn) {
20066 $cborder = $border_start;
20070 $cborder = $border_middle;
20073 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
20075 } elseif (
$page == $endpage) {
20080 $cborder = $border_end;
20084 $cborder = $border_middle;
20087 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
20092 $cborder = $border_middle;
20094 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
20097 if ($cborder OR $fill) {
20098 $offsetlen = strlen($ccode);
20100 if ($this->inxobj) {
20102 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
20103 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
20104 $pagemark = $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey];
20105 $this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey] += $offsetlen;
20111 $pstart = substr($pagebuff, 0, $pagemark);
20112 $pend = substr($pagebuff, $pagemark);
20113 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
20115 if (end($this->transfmrk[$this->page]) !==
false) {
20116 $pagemarkkey = key($this->transfmrk[$this->page]);
20117 $pagemark = $this->transfmrk[
$this->page][$pagemarkkey];
20118 } elseif ($this->InFooter) {
20124 $pstart = substr($pagebuff, 0, $pagemark);
20125 $pend = substr($pagebuff, $pagemark);
20133 $this->page_regions = $temp_page_regions;
20134 if (isset($old_bgcolor)) {
20139 $this->x = $prev_x;
20140 $this->y = $prev_y;
20141 $this->lasth = $prev_lasth;
20152 if (substr($symbol, 0, 4) ==
'img|') {
20153 $this->lisymbol = $symbol;
20156 $symbol = strtolower($symbol);
20157 $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');
20158 if (in_array($symbol, $valid_symbols)) {
20159 $this->lisymbol = $symbol;
20161 $this->lisymbol =
'';
20176 $this->lMargin = $inner;
20179 $this->rMargin = $outer;
20194 $this->original_rMargin = $mtemp;
20196 $this->lMargin += $deltam;
20197 $this->rMargin -= $deltam;
20214 $this->tagvspaces = $tagvs;
20224 return $this->customlistindent = floatval($width);
20234 $this->opencell = $isopen;
20245 $this->htmlLinkColorArray = $color;
20246 $this->htmlLinkFontStyle = $fontstyle;
20260 $supportedunits =
array(
'%',
'em',
'ex',
'px',
'in',
'cm',
'mm',
'pc',
'pt');
20269 if (in_array($defaultunit, $supportedunits)) {
20270 $unit = $defaultunit;
20272 if (is_numeric($htmlval)) {
20273 $value = floatval($htmlval);
20274 } elseif (preg_match(
'/([0-9\.\-\+]+)/', $htmlval, $mnum)) {
20275 $value = floatval($mnum[1]);
20276 if (preg_match(
'/([a-z%]+)/', $htmlval, $munit)) {
20277 if (in_array($munit[1], $supportedunits)) {
20285 $retval = (($value * $refsize) / 100);
20290 $retval = ($value * $refsize);
20295 $retval = ($value * ($refsize / 2));
20315 $retval = (($value * 12) /
$k);
20320 $retval = ($value /
$k);
20344 if ($this->state != 2) {
20356 if ($listtype ==
'^') {
20358 $this->lispacer =
'';
20360 } elseif ($listtype ==
'!') {
20362 $deftypes =
array(
'disc',
'circle',
'square');
20363 $listtype = $deftypes[($listdepth - 1) % 3];
20364 } elseif ($listtype ==
'#') {
20366 $listtype =
'decimal';
20367 } elseif (substr($listtype, 0, 4) ==
'img|') {
20369 $img = explode(
'|', $listtype);
20372 switch ($listtype) {
20379 $lspace += (2 *
$r);
20381 $this->x += $lspace;
20383 $this->x -= $lspace;
20385 $this->
Circle(($this->x +
$r), ($this->y + ($this->lasth / 2)),
$r, 0, 360,
'F',
array(), $color, 8);
20390 $lspace += (2 *
$r);
20392 $this->x += $lspace;
20394 $this->x -= $lspace;
20396 $prev_line_style = $this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.
$this->DrawColor;
20397 $new_line_style =
array(
'width' => (
$r / 3),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'phase' => 0,
'color'=>$color);
20398 $this->
Circle(($this->x +
$r), ($this->y + ($this->lasth / 2)), (
$r * (1 - (1/6))), 0, 360,
'D', $new_line_style,
array(), 8);
20399 $this->
_out($prev_line_style);
20406 $this->x += $lspace;
20408 $this->x -= $lspace;
20410 $this->
Rect($this->x, ($this->y + (($this->lasth -
$l) / 2)),
$l,
$l,
'F',
array(), $color);
20415 $lspace +=
$img[2];
20417 $this->x += $lspace;
20419 $this->x -= $lspace;
20421 $imgtype = strtolower(
$img[1]);
20423 switch ($imgtype) {
20425 $this->
ImageSVG(
$img[4], $this->x, ($this->y + (($this->lasth -
$img[3]) / 2)),
$img[2],
$img[3],
'',
'T',
'', 0,
false);
20430 $this->
ImageEps(
$img[4], $this->x, ($this->y + (($this->lasth -
$img[3]) / 2)),
$img[2],
$img[3],
'',
true,
'T',
'', 0,
false);
20434 $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);
20438 $this->y = $prev_y;
20449 case 'decimal-leading-zero': {
20450 $textitem = sprintf(
'%02d', $this->listcount[$this->listnum]);
20454 case 'lower-roman': {
20459 case 'upper-roman': {
20464 case 'lower-alpha':
20465 case 'lower-latin': {
20466 $textitem = chr(97 + $this->listcount[$this->listnum] - 1);
20470 case 'upper-alpha':
20471 case 'upper-latin': {
20472 $textitem = chr(65 + $this->listcount[$this->listnum] - 1);
20475 case 'lower-greek': {
20476 $textitem =
TCPDF_FONTS::unichr((945 + $this->listcount[$this->listnum] - 1), $this->isunicode);
20519 $textitem =
'.'.$textitem;
20521 $textitem = $textitem.
'.';
20525 $this->x += $lspace;
20527 $this->x -= $lspace;
20529 $this->
Write($this->lasth, $textitem,
'',
false,
'',
false, 0,
false);
20532 $this->lispacer =
'^';
20536 $this->SettextColorArray($color);
20547 'FontFamily' => $this->FontFamily,
20548 'FontStyle' => $this->FontStyle,
20549 'FontSizePt' => $this->FontSizePt,
20550 'rMargin' => $this->rMargin,
20551 'lMargin' => $this->lMargin,
20552 'cell_padding' => $this->cell_padding,
20553 'cell_margin' => $this->cell_margin,
20554 'LineWidth' => $this->LineWidth,
20555 'linestyleWidth' => $this->linestyleWidth,
20556 'linestyleCap' => $this->linestyleCap,
20557 'linestyleJoin' => $this->linestyleJoin,
20558 'linestyleDash' => $this->linestyleDash,
20559 'textrendermode' => $this->textrendermode,
20560 'textstrokewidth' => $this->textstrokewidth,
20561 'DrawColor' => $this->DrawColor,
20562 'FillColor' => $this->FillColor,
20563 'TextColor' => $this->TextColor,
20564 'ColorFlag' => $this->ColorFlag,
20565 'bgcolor' => $this->bgcolor,
20566 'fgcolor' => $this->fgcolor,
20567 'htmlvspace' => $this->htmlvspace,
20568 'listindent' => $this->listindent,
20569 'listindentlevel' => $this->listindentlevel,
20570 'listnum' => $this->listnum,
20571 'listordered' => $this->listordered,
20572 'listcount' => $this->listcount,
20573 'lispacer' => $this->lispacer,
20574 'cell_height_ratio' => $this->cell_height_ratio,
20575 'font_stretching' => $this->font_stretching,
20576 'font_spacing' => $this->font_spacing,
20577 'alpha' => $this->alpha,
20579 'lasth' => $this->lasth,
20580 'tMargin' => $this->tMargin,
20581 'bMargin' => $this->bMargin,
20582 'AutoPageBreak' => $this->AutoPageBreak,
20583 'PageBreakTrigger' => $this->PageBreakTrigger,
20588 'wPt' => $this->wPt,
20589 'hPt' => $this->hPt,
20590 'fwPt' => $this->fwPt,
20591 'fhPt' => $this->fhPt,
20592 'page' => $this->page,
20593 'current_column' => $this->current_column,
20594 'num_columns' => $this->num_columns
20607 if ($this->state != 2) {
20610 $this->FontFamily = $gvars[
'FontFamily'];
20611 $this->FontStyle = $gvars[
'FontStyle'];
20612 $this->FontSizePt = $gvars[
'FontSizePt'];
20613 $this->rMargin = $gvars[
'rMargin'];
20614 $this->lMargin = $gvars[
'lMargin'];
20615 $this->cell_padding = $gvars[
'cell_padding'];
20616 $this->cell_margin = $gvars[
'cell_margin'];
20617 $this->LineWidth = $gvars[
'LineWidth'];
20618 $this->linestyleWidth = $gvars[
'linestyleWidth'];
20619 $this->linestyleCap = $gvars[
'linestyleCap'];
20620 $this->linestyleJoin = $gvars[
'linestyleJoin'];
20621 $this->linestyleDash = $gvars[
'linestyleDash'];
20622 $this->textrendermode = $gvars[
'textrendermode'];
20623 $this->textstrokewidth = $gvars[
'textstrokewidth'];
20624 $this->DrawColor = $gvars[
'DrawColor'];
20625 $this->FillColor = $gvars[
'FillColor'];
20626 $this->TextColor = $gvars[
'TextColor'];
20627 $this->ColorFlag = $gvars[
'ColorFlag'];
20628 $this->bgcolor = $gvars[
'bgcolor'];
20629 $this->fgcolor = $gvars[
'fgcolor'];
20630 $this->htmlvspace = $gvars[
'htmlvspace'];
20631 $this->listindent = $gvars[
'listindent'];
20632 $this->listindentlevel = $gvars[
'listindentlevel'];
20633 $this->listnum = $gvars[
'listnum'];
20634 $this->listordered = $gvars[
'listordered'];
20635 $this->listcount = $gvars[
'listcount'];
20636 $this->lispacer = $gvars[
'lispacer'];
20637 $this->cell_height_ratio = $gvars[
'cell_height_ratio'];
20638 $this->font_stretching = $gvars[
'font_stretching'];
20639 $this->font_spacing = $gvars[
'font_spacing'];
20640 $this->alpha = $gvars[
'alpha'];
20643 $this->lasth = $gvars[
'lasth'];
20644 $this->tMargin = $gvars[
'tMargin'];
20645 $this->bMargin = $gvars[
'bMargin'];
20646 $this->AutoPageBreak = $gvars[
'AutoPageBreak'];
20647 $this->PageBreakTrigger = $gvars[
'PageBreakTrigger'];
20648 $this->x = $gvars[
'x'];
20649 $this->y = $gvars[
'y'];
20650 $this->w = $gvars[
'w'];
20651 $this->h = $gvars[
'h'];
20652 $this->wPt = $gvars[
'wPt'];
20653 $this->hPt = $gvars[
'hPt'];
20654 $this->fwPt = $gvars[
'fwPt'];
20655 $this->fhPt = $gvars[
'fhPt'];
20656 $this->page = $gvars[
'page'];
20657 $this->current_column = $gvars[
'current_column'];
20658 $this->num_columns = $gvars[
'num_columns'];
20660 $this->
_out(
''.$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' '.$this->FillColor.
'');
20662 $this->
SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
20689 $this->bufferlen += strlen(
$data);
20690 $this->buffer .=
$data;
20700 $this->bufferlen = strlen(
$data);
20701 $this->buffer =
$data;
20728 if ($append AND isset($this->pagelen[
$page])) {
20743 if (isset($this->pages[
$page])) {
20744 return $this->pages[
$page];
20758 if ((
$data[
'i'] = array_search($image, $this->imagekeys)) === FALSE) {
20776 if (!isset($this->
images[$image])) {
20790 if (isset($this->
images[$image])) {
20791 return $this->
images[$image];
20805 if (!in_array($font, $this->fontkeys)) {
20806 $this->fontkeys[] = $font;
20809 $this->font_obj_ids[$font] =
$this->n;
20823 if (!isset($this->
fonts[$font])) {
20837 if (isset($this->
fonts[$font])) {
20838 return $this->
fonts[$font];
20852 if (($frompage > $this->numpages) OR ($frompage <= $topage)) {
20855 if ($frompage == $this->page) {
20861 $tmppagedim = $this->pagedim[$frompage];
20862 $tmppagelen = $this->pagelen[$frompage];
20863 $tmpintmrk = $this->intmrk[$frompage];
20864 $tmpbordermrk = $this->bordermrk[$frompage];
20865 $tmpcntmrk = $this->cntmrk[$frompage];
20866 $tmppageobjects = $this->pageobjects[$frompage];
20867 if (isset($this->footerpos[$frompage])) {
20868 $tmpfooterpos = $this->footerpos[$frompage];
20870 if (isset($this->footerlen[$frompage])) {
20871 $tmpfooterlen = $this->footerlen[$frompage];
20873 if (isset($this->transfmrk[$frompage])) {
20874 $tmptransfmrk = $this->transfmrk[$frompage];
20876 if (isset($this->PageAnnots[$frompage])) {
20877 $tmpannots = $this->PageAnnots[$frompage];
20879 if (isset($this->newpagegroup) AND !empty($this->newpagegroup)) {
20880 for ($i = $frompage; $i > $topage; --$i) {
20881 if (isset($this->newpagegroup[$i]) AND (($i + $this->pagegroups[$this->newpagegroup[$i]]) > $frompage)) {
20882 --$this->pagegroups[$this->newpagegroup[$i]];
20886 for ($i = $topage; $i > 0; --$i) {
20887 if (isset($this->newpagegroup[$i]) AND (($i + $this->pagegroups[$this->newpagegroup[$i]]) > $topage)) {
20888 ++$this->pagegroups[$this->newpagegroup[$i]];
20893 for ($i = $frompage; $i > $topage; --$i) {
20897 $this->pagedim[$i] = $this->pagedim[$j];
20898 $this->pagelen[$i] = $this->pagelen[$j];
20899 $this->intmrk[$i] = $this->intmrk[$j];
20900 $this->bordermrk[$i] = $this->bordermrk[$j];
20901 $this->cntmrk[$i] = $this->cntmrk[$j];
20902 $this->pageobjects[$i] = $this->pageobjects[$j];
20903 if (isset($this->footerpos[$j])) {
20904 $this->footerpos[$i] = $this->footerpos[$j];
20905 } elseif (isset($this->footerpos[$i])) {
20906 unset($this->footerpos[$i]);
20908 if (isset($this->footerlen[$j])) {
20909 $this->footerlen[$i] = $this->footerlen[$j];
20910 } elseif (isset($this->footerlen[$i])) {
20911 unset($this->footerlen[$i]);
20913 if (isset($this->transfmrk[$j])) {
20914 $this->transfmrk[$i] = $this->transfmrk[$j];
20915 } elseif (isset($this->transfmrk[$i])) {
20916 unset($this->transfmrk[$i]);
20918 if (isset($this->PageAnnots[$j])) {
20919 $this->PageAnnots[$i] = $this->PageAnnots[$j];
20920 } elseif (isset($this->PageAnnots[$i])) {
20921 unset($this->PageAnnots[$i]);
20923 if (isset($this->newpagegroup[$j])) {
20924 $this->newpagegroup[$i] = $this->newpagegroup[$j];
20925 unset($this->newpagegroup[$j]);
20927 if ($this->currpagegroup == $j) {
20928 $this->currpagegroup = $i;
20932 $this->pagedim[$topage] = $tmppagedim;
20933 $this->pagelen[$topage] = $tmppagelen;
20934 $this->intmrk[$topage] = $tmpintmrk;
20935 $this->bordermrk[$topage] = $tmpbordermrk;
20936 $this->cntmrk[$topage] = $tmpcntmrk;
20937 $this->pageobjects[$topage] = $tmppageobjects;
20938 if (isset($tmpfooterpos)) {
20939 $this->footerpos[$topage] = $tmpfooterpos;
20940 } elseif (isset($this->footerpos[$topage])) {
20941 unset($this->footerpos[$topage]);
20943 if (isset($tmpfooterlen)) {
20944 $this->footerlen[$topage] = $tmpfooterlen;
20945 } elseif (isset($this->footerlen[$topage])) {
20946 unset($this->footerlen[$topage]);
20948 if (isset($tmptransfmrk)) {
20949 $this->transfmrk[$topage] = $tmptransfmrk;
20950 } elseif (isset($this->transfmrk[$topage])) {
20951 unset($this->transfmrk[$topage]);
20953 if (isset($tmpannots)) {
20954 $this->PageAnnots[$topage] = $tmpannots;
20955 } elseif (isset($this->PageAnnots[$topage])) {
20956 unset($this->PageAnnots[$topage]);
20960 foreach ($tmpoutlines as $key => $outline) {
20961 if (!$outline[
'f']) {
20962 if (($outline[
'p'] >= $topage) AND ($outline[
'p'] < $frompage)) {
20963 $this->outlines[$key][
'p'] = ($outline[
'p'] + 1);
20964 } elseif ($outline[
'p'] == $frompage) {
20965 $this->outlines[$key][
'p'] = $topage;
20971 foreach ($tmpdests as $key => $dest) {
20973 if (($dest[
'p'] >= $topage) AND ($dest[
'p'] < $frompage)) {
20974 $this->dests[$key][
'p'] = ($dest[
'p'] + 1);
20975 } elseif ($dest[
'p'] == $frompage) {
20976 $this->dests[$key][
'p'] = $topage;
20982 foreach ($tmplinks as $key => $link) {
20984 if (($link[
'p'] >= $topage) AND ($link[
'p'] < $frompage)) {
20985 $this->links[$key][
'p'] = ($link[
'p'] + 1);
20986 } elseif ($link[
'p'] == $frompage) {
20987 $this->links[$key][
'p'] = $topage;
20992 $jfrompage = $frompage;
20993 $jtopage = $topage;
20994 if (preg_match_all(
'/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/', $this->javascript, $pamatch) > 0) {
20995 foreach($pamatch[0] as $pk => $pmatch) {
20996 $pagenum = intval($pamatch[3][$pk]) + 1;
20997 if (($pagenum >= $jtopage) AND ($pagenum < $jfrompage)) {
20998 $newpage = ($pagenum + 1);
20999 } elseif ($pagenum == $jfrompage) {
21000 $newpage = $jtopage;
21002 $newpage = $pagenum;
21005 $newjs =
"this.addField(\'".$pamatch[1][$pk].
"\',\'".$pamatch[2][$pk].
"\',".$newpage;
21006 $this->javascript = str_replace($pmatch, $newjs, $this->javascript);
21023 if ((
$page < 1) OR (
$page > $this->numpages)) {
21027 unset($this->pages[
$page]);
21028 unset($this->pagedim[$page]);
21029 unset($this->pagelen[$page]);
21030 unset($this->intmrk[$page]);
21031 unset($this->bordermrk[$page]);
21032 unset($this->cntmrk[$page]);
21033 foreach ($this->pageobjects[$page] as $oid) {
21034 if (isset($this->offsets[$oid])){
21035 unset($this->offsets[$oid]);
21038 unset($this->pageobjects[$page]);
21039 if (isset($this->footerpos[$page])) {
21040 unset($this->footerpos[$page]);
21042 if (isset($this->footerlen[$page])) {
21043 unset($this->footerlen[$page]);
21045 if (isset($this->transfmrk[$page])) {
21046 unset($this->transfmrk[$page]);
21048 if (isset($this->PageAnnots[$page])) {
21049 unset($this->PageAnnots[$page]);
21051 if (isset($this->newpagegroup) AND !empty($this->newpagegroup)) {
21052 for ($i = $page; $i > 0; --$i) {
21053 if (isset($this->newpagegroup[$i]) AND (($i + $this->pagegroups[$this->newpagegroup[$i]]) > $page)) {
21054 --$this->pagegroups[$this->newpagegroup[$i]];
21059 if (isset($this->pageopen[$page])) {
21060 unset($this->pageopen[$page]);
21062 if ($page < $this->numpages) {
21068 $this->pagedim[$i] = $this->pagedim[$j];
21069 $this->pagelen[$i] = $this->pagelen[$j];
21070 $this->intmrk[$i] = $this->intmrk[$j];
21071 $this->bordermrk[$i] = $this->bordermrk[$j];
21072 $this->cntmrk[$i] = $this->cntmrk[$j];
21073 $this->pageobjects[$i] = $this->pageobjects[$j];
21074 if (isset($this->footerpos[$j])) {
21075 $this->footerpos[$i] = $this->footerpos[$j];
21076 } elseif (isset($this->footerpos[$i])) {
21077 unset($this->footerpos[$i]);
21079 if (isset($this->footerlen[$j])) {
21080 $this->footerlen[$i] = $this->footerlen[$j];
21081 } elseif (isset($this->footerlen[$i])) {
21082 unset($this->footerlen[$i]);
21084 if (isset($this->transfmrk[$j])) {
21085 $this->transfmrk[$i] = $this->transfmrk[$j];
21086 } elseif (isset($this->transfmrk[$i])) {
21087 unset($this->transfmrk[$i]);
21089 if (isset($this->PageAnnots[$j])) {
21090 $this->PageAnnots[$i] = $this->PageAnnots[$j];
21091 } elseif (isset($this->PageAnnots[$i])) {
21092 unset($this->PageAnnots[$i]);
21094 if (isset($this->newpagegroup[$j])) {
21095 $this->newpagegroup[$i] = $this->newpagegroup[$j];
21096 unset($this->newpagegroup[$j]);
21098 if ($this->currpagegroup == $j) {
21099 $this->currpagegroup = $i;
21101 if (isset($this->pageopen[$j])) {
21102 $this->pageopen[$i] = $this->pageopen[$j];
21103 } elseif (isset($this->pageopen[$i])) {
21104 unset($this->pageopen[$i]);
21108 unset($this->pages[$this->numpages]);
21109 unset($this->pagedim[$this->numpages]);
21110 unset($this->pagelen[$this->numpages]);
21111 unset($this->intmrk[$this->numpages]);
21112 unset($this->bordermrk[$this->numpages]);
21113 unset($this->cntmrk[$this->numpages]);
21114 foreach ($this->pageobjects[$this->numpages] as $oid) {
21115 if (isset($this->offsets[$oid])){
21116 unset($this->offsets[$oid]);
21119 unset($this->pageobjects[$this->numpages]);
21120 if (isset($this->footerpos[$this->numpages])) {
21121 unset($this->footerpos[$this->numpages]);
21123 if (isset($this->footerlen[$this->numpages])) {
21124 unset($this->footerlen[$this->numpages]);
21126 if (isset($this->transfmrk[$this->numpages])) {
21127 unset($this->transfmrk[$this->numpages]);
21129 if (isset($this->PageAnnots[$this->numpages])) {
21130 unset($this->PageAnnots[$this->numpages]);
21132 if (isset($this->newpagegroup[$this->numpages])) {
21133 unset($this->newpagegroup[$this->numpages]);
21135 if ($this->currpagegroup == $this->numpages) {
21136 $this->currpagegroup = ($this->numpages - 1);
21138 if (isset($this->pagegroups[$this->numpages])) {
21139 unset($this->pagegroups[$this->numpages]);
21141 if (isset($this->pageopen[$this->numpages])) {
21142 unset($this->pageopen[$this->numpages]);
21149 foreach ($tmpoutlines as $key => $outline) {
21150 if (!$outline[
'f']) {
21151 if ($outline[
'p'] > $page) {
21152 $this->outlines[$key][
'p'] = $outline[
'p'] - 1;
21153 } elseif ($outline[
'p'] == $page) {
21154 unset($this->outlines[$key]);
21160 foreach ($tmpdests as $key => $dest) {
21162 if ($dest[
'p'] > $page) {
21163 $this->dests[$key][
'p'] = $dest[
'p'] - 1;
21164 } elseif ($dest[
'p'] == $page) {
21165 unset($this->dests[$key]);
21171 foreach ($tmplinks as $key => $link) {
21173 if ($link[
'p'] > $page) {
21174 $this->links[$key][
'p'] = $link[
'p'] - 1;
21175 } elseif ($link[
'p'] == $page) {
21176 unset($this->links[$key]);
21182 if (preg_match_all(
'/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/', $this->javascript, $pamatch) > 0) {
21183 foreach($pamatch[0] as $pk => $pmatch) {
21184 $pagenum = intval($pamatch[3][$pk]) + 1;
21185 if ($pagenum >= $jpage) {
21186 $newpage = ($pagenum - 1);
21187 } elseif ($pagenum == $jpage) {
21190 $newpage = $pagenum;
21193 $newjs =
"this.addField(\'".$pamatch[1][$pk].
"\',\'".$pamatch[2][$pk].
"\',".$newpage;
21194 $this->javascript = str_replace($pmatch, $newjs, $this->javascript);
21199 if ($this->numpages > 0) {
21217 if ((
$page < 1) OR (
$page > $this->numpages)) {
21233 if (isset($this->footerpos[
$page])) {
21236 if (isset($this->footerlen[$page])) {
21239 if (isset($this->transfmrk[$page])) {
21242 if (isset($this->PageAnnots[$page])) {
21245 if (isset($this->newpagegroup[$page])) {
21248 $this->currpagegroup = $this->newpagegroup[
$this->page];
21250 } elseif (isset($this->currpagegroup) AND ($this->currpagegroup > 0)) {
21255 foreach ($tmpoutlines as $key => $outline) {
21256 if ($outline[
'p'] == $page) {
21257 $this->outlines[] =
array(
't' => $outline[
't'],
'l' => $outline[
'l'],
'x' => $outline[
'x'],
'y' => $outline[
'y'],
'p' => $this->page,
'f' => $outline[
'f'],
's' => $outline[
's'],
'c' => $outline[
'c']);
21262 foreach ($tmplinks as $key => $link) {
21263 if ($link[
'p'] == $page) {
21264 $this->links[] =
array(
'p' => $this->page,
'y' => $link[
'y'],
'f' => $link[
'f']);
21297 $x_start = $this->
GetX();
21300 $page_fill_start =
false;
21301 $page_fill_end =
false;
21317 $this->
SetFont($numbersfont, $fontstyle, $fontsize);
21320 foreach ($this->outlines as $key => $outline) {
21322 if (($this->page > $page_first) AND ($outline[
'p'] >= $this->numpages)) {
21323 $outline[
'p'] += ($this->page - $page_first);
21332 if ($outline[
'l'] == 0) {
21333 $this->
SetFont($fontfamily, $outline[
's'].
'B', $fontsize);
21335 $this->
SetFont($fontfamily, $outline[
's'], $fontsize - $outline[
'l']);
21341 if (($this->page == $current_page) AND ($this->current_column ==
$current_column)) {
21342 $this->lMargin = $lmargin;
21343 $this->rMargin = $rmargin;
21357 $this->
SetX($x_start);
21358 $indent = ($spacer * $outline[
'l']);
21360 $this->x -= $indent;
21361 $this->rMargin = $this->w -
$this->x;
21363 $this->x += $indent;
21367 $this->
SetLink($link, $outline[
'y'], $outline[
'p']);
21370 $txt =
' '.$outline[
't'];
21372 $txt = $outline[
't'].
' ';
21374 $this->
Write(0,
$txt, $link,
false, $aligntext,
false, 0,
false,
false, 0, $numwidth,
'');
21378 $tw = $this->w - $this->rMargin -
$this->x;
21380 $this->
SetFont($numbersfont, $fontstyle, $fontsize);
21382 $pagenum = $outline[
'p'];
21385 $pagenum =
'{#'.($outline[
'p']).
'}';
21387 $pagenum =
'{'.$pagenum.
'}';
21389 $maxpage = max($maxpage, $outline[
'p']);
21393 if ($wfiller > 0) {
21394 $numfills = floor($fw / $wfiller);
21398 if ($numfills > 0) {
21399 $rowfill = str_repeat($filler, $numfills);
21404 $pagenum = $pagenum.$gap.$rowfill;
21406 $pagenum = $rowfill.$gap.$pagenum;
21409 $this->
Cell($tw, 0, $pagenum, 0, 1, $alignnum, 0, $link, 0);
21411 $page_last = $this->
getPage();
21412 $numpages = ($page_last - $page_first + 1);
21414 if ($this->booklet) {
21416 $page_fill_start = ((($page_first % 2) == 0) XOR ((
$page % 2) == 0));
21417 $page_fill_end = (!(((
$numpages % 2) == 0) XOR ($page_fill_start)));
21418 if ($page_fill_start) {
21424 if ($page_fill_end) {
21431 $maxpage = max($maxpage, $page_last);
21433 for ($p = $page_first; $p <= $page_last; ++$p) {
21436 for (
$n = 1;
$n <= $maxpage; ++
$n) {
21442 if ((
$n >=
$page) AND ($n <= $this->numpages)) {
21450 foreach ($pnalias[
'u'] as $u) {
21451 $sfill = str_repeat($filler, max(0, (strlen($u) - strlen($nu.
' '))));
21453 $nr = $nu.TCPDF_FONTS::UTF8ToUTF16BE(
' '.$sfill,
false, $this->isunicode, $this->CurrentFont);
21457 $temppage = str_replace($u, $nr, $temppage);
21459 foreach ($pnalias[
'a'] as $a) {
21460 $sfill = str_repeat($filler, max(0, (strlen($a) - strlen($na.
' '))));
21462 $nr = $na.
' '.$sfill;
21464 $nr = $sfill.
' '.$na;
21466 $temppage = str_replace($a, $nr, $temppage);
21474 if ($page_fill_start) {
21475 $this->
movePage($page_last, $page_first);
21504 $this->htmlLinkColorArray =
array();
21505 $this->htmlLinkFontStyle =
'';
21506 $page_first = $this->
getPage();
21507 $page_fill_start =
false;
21508 $page_fill_end =
false;
21511 foreach ($templates as $level =>
$html) {
21513 foreach ($dom as $key => $value) {
21514 if ($value[
'value'] ==
'#TOC_PAGE_NUMBER#') {
21515 $this->
SetFont($dom[($key - 1)][
'fontname']);
21520 $this->
SetFont($current_font);
21522 foreach ($this->outlines as $key => $outline) {
21524 $row = $templates[$outline[
'l']];
21526 $pagenum = $outline[
'p'];
21529 $pagenum =
'{#'.($outline[
'p']).
'}';
21530 if ($templates[
'F'.$outline[
'l']]) {
21531 $pagenum =
'{'.$pagenum.
'}';
21533 $maxpage = max($maxpage, $outline[
'p']);
21536 $row = str_replace(
'#TOC_DESCRIPTION#', $outline[
't'],
$row);
21537 $row = str_replace(
'#TOC_PAGE_NUMBER#', $pagenum,
$row);
21539 $row =
'<a href="#'.$outline[
'p'].
','.$outline[
'y'].
'">'.
$row.
'</a>';
21544 $this->htmlLinkColorArray = $prev_htmlLinkColorArray;
21545 $this->htmlLinkFontStyle = $prev_htmlLinkFontStyle;
21547 $page_last = $this->
getPage();
21548 $numpages = ($page_last - $page_first + 1);
21550 if ($this->booklet) {
21552 $page_fill_start = ((($page_first % 2) == 0) XOR ((
$page % 2) == 0));
21553 $page_fill_end = (!(((
$numpages % 2) == 0) XOR ($page_fill_start)));
21554 if ($page_fill_start) {
21560 if ($page_fill_end) {
21567 $maxpage = max($maxpage, $page_last);
21569 for ($p = $page_first; $p <= $page_last; ++$p) {
21572 for (
$n = 1;
$n <= $maxpage; ++
$n) {
21586 foreach ($pnalias[
'u'] as $u) {
21587 if ($correct_align) {
21588 $sfill = str_repeat($filler, (strlen($u) - strlen($nu.
' ')));
21590 $nr = $nu.TCPDF_FONTS::UTF8ToUTF16BE(
' '.$sfill,
false, $this->isunicode, $this->CurrentFont);
21597 $temppage = str_replace($u, $nr, $temppage);
21599 foreach ($pnalias[
'a'] as $a) {
21600 if ($correct_align) {
21601 $sfill = str_repeat($filler, (strlen($a) - strlen($na.
' ')));
21603 $nr = $na.
' '.$sfill;
21605 $nr = $sfill.
' '.$na;
21610 $temppage = str_replace($a, $nr, $temppage);
21618 if ($page_fill_start) {
21619 $this->
movePage($page_last, $page_first);
21633 if (isset($this->objcopy)) {
21639 $this->start_transaction_y =
$this->y;
21650 if (isset($this->objcopy)) {
21651 $this->objcopy->_destroy(
true,
true);
21652 unset($this->objcopy);
21664 if (isset($this->objcopy)) {
21667 $objvars = get_object_vars($this->objcopy);
21668 foreach ($objvars as $key => $value) {
21669 $this->$key = $value;
21689 if ($numcols < 2) {
21695 if (($width == 0) OR ($width > $maxwidth)) {
21696 $width = $maxwidth;
21702 $space = (($this->w - $this->original_lMargin - $this->original_rMargin - ($numcols * $width)) / ($numcols - 1));
21704 for ($i = 0; $i < $numcols; ++$i) {
21708 $this->num_columns = $numcols;
21709 $this->current_column = 0;
21734 $this->num_columns = count(
$columns);
21735 $this->current_column = 0;
21747 if (is_string($col)) {
21749 } elseif ($col >= $this->num_columns) {
21752 $xshift =
array(
'x' => 0,
's' =>
array(
'H' => 0,
'V' => 0),
'p' =>
array(
'L' => 0,
'T' => 0,
'R' => 0,
'B' => 0));
21753 $enable_thead =
false;
21754 if ($this->num_columns > 1) {
21755 if ($col != $this->current_column) {
21757 if ($this->column_start_page == $this->page) {
21758 $this->y = $this->
columns[$col][
'y'];
21763 if (($this->page > $this->maxselcol[
'page']) OR (($this->page == $this->maxselcol[
'page']) AND ($col > $this->maxselcol[
'column']))) {
21764 $enable_thead =
true;
21766 $this->maxselcol[
'column'] = $col;
21774 for ($i = 0; $i < $col; ++$i) {
21778 $x = $this->w - $this->original_rMargin - $colpos;
21780 $this->lMargin = (
$x - $this->
columns[$col][
'w']);
21783 $x = $this->original_lMargin + $colpos;
21785 $this->rMargin = ($this->w -
$x - $this->
columns[$col][
'w']);
21790 $this->current_column = $col;
21792 $this->newline =
true;
21795 if ($enable_thead) {
21797 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
21798 $this->y += $xshift[
's'][
'V'];
21800 if (!isset($this->
columns[$col][
'th'])) {
21805 } elseif (isset($this->
columns[$col][
'th'][
'\''.$this->page.
'\''])) {
21806 $this->y = $this->
columns[$col][
'th'][
'\''.$this->page.
'\''];
21811 $this->rMargin += $xshift[
'x'];
21812 $this->x -= ($xshift[
'x'] + $xshift[
'p'][
'R']);
21814 $this->lMargin += $xshift[
'x'];
21815 $this->x += $xshift[
'x'] + $xshift[
'p'][
'L'];
21853 if ($fill ===
true) {
21855 if ($clip ===
true) {
21864 if ($clip ===
true) {
21874 if ($clip ===
true) {
21883 if ($clip ===
true) {
21893 $this->textstrokewidth = $stroke;
21902 public function setTextShadow(
$params=
array(
'enabled'=>
false,
'depth_w'=>0,
'depth_h'=>0,
'color'=>
false,
'opacity'=>1,
'blend_mode'=>
'Normal')) {
21903 if (isset(
$params[
'enabled'])) {
21904 $this->txtshadow[
'enabled'] =
$params[
'enabled']?
true:
false;
21906 $this->txtshadow[
'enabled'] =
false;
21908 if (isset(
$params[
'depth_w'])) {
21909 $this->txtshadow[
'depth_w'] = floatval(
$params[
'depth_w']);
21911 $this->txtshadow[
'depth_w'] = 0;
21913 if (isset(
$params[
'depth_h'])) {
21914 $this->txtshadow[
'depth_h'] = floatval(
$params[
'depth_h']);
21916 $this->txtshadow[
'depth_h'] = 0;
21919 $this->txtshadow[
'color'] =
$params[
'color'];
21923 if (isset(
$params[
'opacity'])) {
21924 $this->txtshadow[
'opacity'] = min(1, max(0, floatval(
$params[
'opacity'])));
21926 $this->txtshadow[
'opacity'] = 1;
21928 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'))) {
21929 $this->txtshadow[
'blend_mode'] =
$params[
'blend_mode'];
21931 $this->txtshadow[
'blend_mode'] =
'Normal';
21933 if ((($this->txtshadow[
'depth_w'] == 0) AND ($this->txtshadow[
'depth_h'] == 0)) OR ($this->txtshadow[
'opacity'] == 0)) {
21934 $this->txtshadow[
'enabled'] =
false;
21962 protected function hyphenateWord($word, $patterns, $dictionary=
array(), $leftmin=1, $rightmin=2, $charmin=1, $charmax=8) {
21963 $hyphenword =
array();
21964 $numchars = count($word);
21965 if ($numchars <= $charmin) {
21970 $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})(\]?)$/';
21971 if (preg_match($pattern, $word_string) > 0) {
21975 $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})(\]?)$/';
21976 if (preg_match($pattern, $word_string) > 0) {
21980 if (isset($dictionary[$word_string])) {
21984 $tmpword = array_merge(
array(46), $word,
array(46));
21985 $tmpnumchars = $numchars + 2;
21986 $maxpos = $tmpnumchars - 1;
21987 for ($pos = 0; $pos < $maxpos; ++$pos) {
21988 $imax = min(($tmpnumchars - $pos), $charmax);
21989 for ($i = 1; $i <= $imax; ++$i) {
21991 if (isset($patterns[$subword])) {
21993 $pattern_length = count($pattern);
21995 for ($j = 0; $j < $pattern_length; ++$j) {
21997 if (($pattern[$j] >= 48) AND ($pattern[$j] <= 57)) {
22001 $zero = $pos + $j - $digits;
22004 $level = ($pattern[$j] - 48);
22006 if (!isset($hyphenword[$zero]) OR ($hyphenword[$zero] < $level)) {
22007 $hyphenword[$zero] = $level;
22016 $maxpos = $numchars - $rightmin;
22017 for ($i = $leftmin; $i <= $maxpos; ++$i) {
22019 if (isset($hyphenword[$i]) AND (($hyphenword[$i] % 2) != 0)) {
22021 array_splice($word, $i + $inserted, 0, 173);
22048 if (!is_array($patterns)) {
22054 foreach ($unichars as $char) {
22062 $txtarr = array_merge($txtarr, $this->
hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
22066 if (chr($char) ==
'<') {
22069 } elseif ($intag AND (chr($char) ==
'>')) {
22073 $expected =
array(115, 116, 121, 108, 101);
22074 $current = array_slice($txtarr, -6, 5);
22075 $compare = array_diff($expected, $current);
22076 if (empty($compare)) {
22078 $expected =
array(47);
22079 $current = array_slice($txtarr, -7, 1);
22080 $compare = array_diff($expected, $current);
22081 if (empty($compare)) {
22094 $txtarr = array_merge($txtarr, $this->
hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
22107 $this->rasterize_vector_images = $mode;
22118 if ($this->pdfa_mode) {
22119 $this->font_subsetting =
false;
22121 $this->font_subsetting = $enable ? true :
false;
22146 return preg_replace(
'/^'.$this->re_space[
'p'].
'+/'.$this->re_space[
'm'], $replace, $str);
22159 return preg_replace(
'/'.$this->re_space[
'p'].
'+$/'.$this->re_space[
'm'], $replace, $str);
22185 return (($this->CurrentFont[
'type'] ==
'TrueTypeUnicode') OR ($this->CurrentFont[
'type'] ==
'cidfont0'));
22198 $fontfamily = preg_replace(
'/[^a-z0-9_\,]/',
'', strtolower($fontfamily));
22200 $fontslist = preg_split(
'/[,]/', $fontfamily);
22202 foreach ($fontslist as $font) {
22204 $font = preg_replace(
'/regular$/',
'', $font);
22205 $font = preg_replace(
'/italic$/',
'I', $font);
22206 $font = preg_replace(
'/oblique$/',
'I', $font);
22207 $font = preg_replace(
'/bold([I]?)$/',
'B\\1', $font);
22209 $pattern =
array();
22210 $replacement =
array();
22211 $pattern[] =
'/^serif|^cursive|^fantasy|^timesnewroman/';
22212 $replacement[] =
'times';
22213 $pattern[] =
'/^sansserif/';
22214 $replacement[] =
'helvetica';
22215 $pattern[] =
'/^monospace/';
22216 $replacement[] =
'courier';
22217 $font = preg_replace($pattern, $replacement, $font);
22218 if (in_array(strtolower($font), $this->fontlist) OR in_array($font, $this->fontkeys)) {
22223 return $this->CurrentFont[
'fontkey'];
22241 if ($this->inxobj) {
22245 $this->inxobj =
true;
22248 $this->xobjid =
'XT'.$this->n;
22265 $this->num_columns = 1;
22266 $this->current_column = 0;
22268 if ((
$w ===
'') OR (
$w <= 0)) {
22271 if ((
$h ===
'') OR (
$h <= 0)) {
22286 $this->lMargin = 0;
22287 $this->rMargin = 0;
22288 $this->tMargin = 0;
22289 $this->bMargin = 0;
22306 if (!$this->inxobj) {
22310 $this->inxobj =
false;
22312 $this->
setGraphicVars($this->xobjects[$this->xobjid][
'gvars'],
true);
22335 if ($this->state != 2) {
22338 if (!isset($this->xobjects[$id])) {
22339 $this->
Error(
'The XObject Template \''.$id.
'\' doesn\
't exist!');
22341 if ($this->inxobj) {
22342 if ($id == $this->xobjid) {
22347 $this->xobjects[
$this->xobjid][
'xobjects'][$id] = $this->xobjects[$id];
22359 $ow = $this->xobjects[$id][
'w'];
22363 $oh = $this->xobjects[$id][
'h'];
22368 if ((
$w <= 0) AND (
$h <= 0)) {
22371 } elseif (
$w <= 0) {
22372 $w =
$h * $ow / $oh;
22373 } elseif (
$h <= 0) {
22374 $h =
$w * $oh / $ow;
22382 if ($palign ==
'L') {
22384 } elseif ($palign ==
'C') {
22385 $xt = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
22386 } elseif ($palign ==
'R') {
22387 $xt = $this->w - $this->rMargin -
$w;
22393 if ($palign ==
'L') {
22395 } elseif ($palign ==
'C') {
22396 $xt = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
22397 } elseif ($palign ==
'R') {
22398 $xt = $this->w - $this->rMargin -
$w;
22415 $tm[5] = ($this->h - $h -
$y) * $this->k;
22418 $this->
_out(
'/'.$id.
' Do');
22421 if (!empty($this->xobjects[$id][
'annotations'])) {
22422 foreach ($this->xobjects[$id][
'annotations'] as $annot) {
22426 $ay = ($this->h - $h - ($coordlt[5] /
$this->k));
22428 $aw = ($coordrb[4] /
$this->k) - $ax;
22429 $ah = ($this->h - $h - ($coordrb[5] /
$this->k)) - $ay;
22430 $this->
Annotation($ax, $ay, $aw, $ah, $annot[
'text'], $annot[
'opt'], $annot[
'spaces']);
22441 $this->y =
$y + round($h/2);
22451 $this->
SetY($rb_y);
22468 $this->font_stretching = $perc;
22490 $this->font_spacing = $spacing;
22529 $this->page_regions =
array();
22548 if (!isset($region[
'page']) OR empty($region[
'page'])) {
22551 if (isset($region[
'xt']) AND isset($region[
'xb']) AND ($region[
'xt'] > 0) AND ($region[
'xb'] > 0)
22552 AND isset($region[
'yt']) AND isset($region[
'yb']) AND ($region[
'yt'] >= 0) AND ($region[
'yt'] < $region[
'yb'])
22553 AND isset($region[
'side']) AND (($region[
'side'] ==
'L') OR ($region[
'side'] ==
'R'))) {
22554 $this->page_regions[] = $region;
22567 if (isset($this->page_regions[$key])) {
22568 unset($this->page_regions[$key]);
22592 if (!$this->check_page_regions OR empty($this->page_regions)) {
22605 if ($this->num_columns > 1) {
22613 $this->lMargin = max($this->clMargin, $this->original_lMargin);
22615 $this->rMargin = max($this->crMargin, $this->original_rMargin);
22619 foreach ($this->page_regions as $regid => $regdata) {
22620 if ($regdata[
'page'] == $this->page) {
22622 if ((
$y > ($regdata[
'yt'] -
$h)) AND (
$y <= $regdata[
'yb'])) {
22624 $minv = ($regdata[
'xb'] - $regdata[
'xt']) / ($regdata[
'yb'] - $regdata[
'yt']);
22625 $yt = max(
$y, $regdata[
'yt']);
22626 $yb = min(($yt +
$h), $regdata[
'yb']);
22627 $xt = (($yt - $regdata[
'yt']) * $minv) + $regdata[
'xt'];
22628 $xb = (($yb - $regdata[
'yt']) * $minv) + $regdata[
'xt'];
22629 if ($regdata[
'side'] ==
'L') {
22630 $new_margin = max($xt, $xb);
22631 if ($this->lMargin < $new_margin) {
22634 $this->lMargin = max(0, $new_margin);
22636 if (
$x < $new_margin) {
22639 if ($new_margin > ($this->w - $this->rMargin)) {
22641 $y = $regdata[
'yb'] -
$h;
22645 } elseif ($regdata[
'side'] ==
'R') {
22646 $new_margin = min($xt, $xb);
22647 if (($this->w - $this->rMargin) > $new_margin) {
22650 $this->rMargin = max(0, ($this->w - $new_margin));
22652 if (
$x > $new_margin) {
22655 if ($new_margin > $this->lMargin) {
22657 $y = $regdata[
'yb'] -
$h;
22688 if ($this->state != 2) {
22692 $this->svggradients =
array();
22693 $this->svggradientid = 0;
22694 $this->svgdefsmode =
false;
22695 $this->svgdefs =
array();
22696 $this->svgclipmode =
false;
22697 $this->svgclippaths =
array();
22698 $this->svgcliptm =
array();
22699 $this->svgclipid = 0;
22700 $this->svgtext =
'';
22701 $this->svgtextmode =
array();
22702 if ($this->rasterize_vector_images AND (
$w > 0) AND (
$h > 0)) {
22704 return $this->
Image(
$file,
$x,
$y,
$w,
$h,
'SVG', $link, $align,
true, 300, $palign,
false,
false,
$border,
false,
false,
false);
22706 if (
$file[0] ===
'@') {
22707 $this->svgdir =
'';
22708 $svgdata = substr(
$file, 1);
22710 $this->svgdir = dirname(
$file);
22713 if ($svgdata === FALSE) {
22729 $aspect_ratio_align =
'xMidYMid';
22730 $aspect_ratio_ms =
'meet';
22733 preg_match(
'/<svg([^>]*)>/si', $svgdata, $regs);
22734 if (isset($regs[1]) AND !empty($regs[1])) {
22736 if (preg_match(
'/[\s]+x[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22740 if (preg_match(
'/[\s]+y[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22744 if (preg_match(
'/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22748 if (preg_match(
'/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22752 $view_box =
array();
22753 if (preg_match(
'/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.\-]+)[\s]+([0-9\.\-]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $regs[1], $tmp)) {
22754 if (count($tmp) == 5) {
22756 foreach ($tmp as $key => $val) {
22759 $ox = $view_box[0];
22760 $oy = $view_box[1];
22764 if (preg_match(
'/[\s]+preserveAspectRatio[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
22765 $aspect_ratio = preg_split(
'/[\s]+/si', $tmp[1]);
22766 switch (count($aspect_ratio)) {
22768 $aspect_ratio_align = $aspect_ratio[1];
22769 $aspect_ratio_ms = $aspect_ratio[2];
22773 $aspect_ratio_align = $aspect_ratio[0];
22774 $aspect_ratio_ms = $aspect_ratio[1];
22778 $aspect_ratio_align = $aspect_ratio[0];
22779 $aspect_ratio_ms =
'meet';
22793 if ((
$w <= 0) AND (
$h <= 0)) {
22797 } elseif (
$w <= 0) {
22798 $w =
$h * $ow / $oh;
22799 } elseif (
$h <= 0) {
22800 $h =
$w * $oh / $ow;
22804 if ($this->rasterize_vector_images) {
22806 return $this->
Image(
$file,
$x,
$y,
$w,
$h,
'SVG', $link, $align,
true, 300, $palign,
false,
false,
$border,
false,
false,
false);
22809 $this->img_rb_y =
$y +
$h;
22812 if ($palign ==
'L') {
22814 } elseif ($palign ==
'C') {
22815 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
22816 } elseif ($palign ==
'R') {
22817 $ximg = $this->w - $this->rMargin -
$w;
22821 $this->img_rb_x = $ximg;
22823 if ($palign ==
'L') {
22825 } elseif ($palign ==
'C') {
22826 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
22827 } elseif ($palign ==
'R') {
22828 $ximg = $this->w - $this->rMargin -
$w;
22832 $this->img_rb_x = $ximg +
$w;
22837 $svgoffset_x = ($ximg - $ox) * $this->k;
22838 $svgoffset_y = -(
$y - $oy) * $this->k;
22839 if (isset($view_box[2]) AND ($view_box[2] > 0) AND ($view_box[3] > 0)) {
22840 $ow = $view_box[2];
22841 $oh = $view_box[3];
22850 $svgscale_x =
$w / $ow;
22851 $svgscale_y = $h / $oh;
22853 if ($aspect_ratio_align !=
'none') {
22855 $svgscale_old_x = $svgscale_x;
22856 $svgscale_old_y = $svgscale_y;
22858 if ($aspect_ratio_ms ==
'slice') {
22860 if ($svgscale_x > $svgscale_y) {
22861 $svgscale_y = $svgscale_x;
22862 } elseif ($svgscale_x < $svgscale_y) {
22863 $svgscale_x = $svgscale_y;
22867 if ($svgscale_x < $svgscale_y) {
22868 $svgscale_y = $svgscale_x;
22869 } elseif ($svgscale_x > $svgscale_y) {
22870 $svgscale_x = $svgscale_y;
22874 switch (substr($aspect_ratio_align, 1, 3)) {
22880 $svgoffset_x += ((
$w *
$this->k) - ($ow * $this->k * $svgscale_x));
22885 $svgoffset_x += (((
$w *
$this->k) - ($ow * $this->k * $svgscale_x)) / 2);
22890 switch (substr($aspect_ratio_align, 5)) {
22896 $svgoffset_y -= (($h *
$this->k) - ($oh * $this->k * $svgscale_y));
22901 $svgoffset_y -= ((($h *
$this->k) - ($oh * $this->k * $svgscale_y)) / 2);
22913 $this->
_out(
'q'.$this->epsmarker);
22917 $e = $ox * $this->k * (1 - $svgscale_x);
22918 $f = ($this->h - $oy) * $this->k * (1 - $svgscale_y);
22919 $this->
_out(sprintf(
'%F %F %F %F %F %F cm', $svgscale_x, 0, 0, $svgscale_y, ($e + $svgoffset_x), ($f + $svgoffset_y)));
22921 $this->parser = xml_parser_create(
'UTF-8');
22923 xml_set_object($this->parser, $this);
22925 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
22927 xml_set_element_handler($this->parser,
'startSVGElementHandler',
'endSVGElementHandler');
22929 xml_set_character_data_handler($this->parser,
'segSVGContentHandler');
22931 if (!xml_parse($this->parser, $svgdata)) {
22932 $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));
22933 $this->
Error($error_message);
22936 xml_parser_free($this->parser);
22938 $this->
_out($this->epsmarker.
'Q');
22941 $this->lasth = $gvars[
'lasth'];
22955 $this->
Link($ximg,
$y,
$w, $h, $link, 0);
22965 $this->y =
$y + round($h/2);
22975 $this->
SetY($this->img_rb_y);
22980 $this->x = $gvars[
'x'];
22981 $this->y = $gvars[
'y'];
22982 $this->page = $gvars[
'page'];
22983 $this->current_column = $gvars[
'current_column'];
22984 $this->tMargin = $gvars[
'tMargin'];
22985 $this->bMargin = $gvars[
'bMargin'];
22986 $this->w = $gvars[
'w'];
22987 $this->h = $gvars[
'h'];
22988 $this->wPt = $gvars[
'wPt'];
22989 $this->hPt = $gvars[
'hPt'];
22990 $this->fwPt = $gvars[
'fwPt'];
22991 $this->fhPt = $gvars[
'fhPt'];
23017 $e = (
$x * (1 - $a)) - (
$y * $c) + $e;
23018 $f = (
$y * (1 -
$d)) - (
$x * $b) + $f;
23019 return array($a, $b, $c,
$d, $e, $f);
23048 if ($this->state != 2) {
23053 if (!isset($svgstyle[
'opacity'])) {
23058 if (preg_match(
'/url\([\s]*\#([^\)]*)\)/si', $svgstyle[
'clip-path'], $regs)) {
23059 $clip_path = $this->svgclippaths[$regs[1]];
23060 foreach ($clip_path as $cp) {
23065 if ($svgstyle[
'opacity'] != 1) {
23066 $this->
setAlpha($svgstyle[
'opacity'],
'Normal', $svgstyle[
'opacity'],
false);
23075 if (preg_match(
'/rect\(([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)\)/si', $svgstyle[
'clip'], $regs)) {
23076 $top = (isset($regs[1])?$this->
getHTMLUnitToUnits($regs[1], 0, $this->svgunit,
false):0);
23077 $right = (isset($regs[2])?$this->
getHTMLUnitToUnits($regs[2], 0, $this->svgunit,
false):0);
23078 $bottom = (isset($regs[3])?$this->
getHTMLUnitToUnits($regs[3], 0, $this->svgunit,
false):0);
23079 $left = (isset($regs[4])?$this->
getHTMLUnitToUnits($regs[4], 0, $this->svgunit,
false):0);
23082 $cw =
$w - $left - $right;
23083 $ch =
$h - $top - $bottom;
23084 if ($svgstyle[
'clip-rule'] ==
'evenodd') {
23085 $clip_rule =
'CNZ';
23087 $clip_rule =
'CEO';
23093 if (preg_match(
'/url\([\s]*\#([^\)]*)\)/si', $svgstyle[
'fill'], $regs)) {
23095 $gradient = $this->svggradients[$regs[1]];
23096 if (isset($gradient[
'xref'])) {
23098 $newgradient = $this->svggradients[$gradient[
'xref']];
23099 $newgradient[
'coords'] = $gradient[
'coords'];
23100 $newgradient[
'mode'] = $gradient[
'mode'];
23101 $newgradient[
'type'] = $gradient[
'type'];
23102 $newgradient[
'gradientUnits'] = $gradient[
'gradientUnits'];
23103 if (isset($gradient[
'gradientTransform'])) {
23104 $newgradient[
'gradientTransform'] = $gradient[
'gradientTransform'];
23106 $gradient = $newgradient;
23111 if (!empty($clip_function) AND method_exists($this, $clip_function)) {
23112 $bbox = call_user_func_array(
array($this, $clip_function), $clip_params);
23113 if ((!isset($gradient[
'type']) OR ($gradient[
'type'] != 3)) AND is_array($bbox) AND (count($bbox) == 4)) {
23117 if ($gradient[
'mode'] ==
'measure') {
23118 if (!isset($gradient[
'coords'][4])) {
23119 $gradient[
'coords'][4] = 0.5;
23121 if (isset($gradient[
'gradientTransform']) AND !empty($gradient[
'gradientTransform'])) {
23122 $gtm = $gradient[
'gradientTransform'];
23124 $xa = ($gtm[0] * $gradient[
'coords'][0]) + ($gtm[2] * $gradient[
'coords'][1]) + $gtm[4];
23125 $ya = ($gtm[1] * $gradient[
'coords'][0]) + ($gtm[3] * $gradient[
'coords'][1]) + $gtm[5];
23126 $xb = ($gtm[0] * $gradient[
'coords'][2]) + ($gtm[2] * $gradient[
'coords'][3]) + $gtm[4];
23127 $yb = ($gtm[1] * $gradient[
'coords'][2]) + ($gtm[3] * $gradient[
'coords'][3]) + $gtm[5];
23128 $r = sqrt(pow(($gtm[0] * $gradient[
'coords'][4]), 2) + pow(($gtm[1] * $gradient[
'coords'][4]), 2));
23129 $gradient[
'coords'][0] = $xa;
23130 $gradient[
'coords'][1] = $ya;
23131 $gradient[
'coords'][2] = $xb;
23132 $gradient[
'coords'][3] = $yb;
23133 $gradient[
'coords'][4] =
$r;
23136 $gradient[
'coords'][0] = $this->
getHTMLUnitToUnits($gradient[
'coords'][0], 0, $this->svgunit,
false);
23137 $gradient[
'coords'][1] = $this->
getHTMLUnitToUnits($gradient[
'coords'][1], 0, $this->svgunit,
false);
23138 $gradient[
'coords'][2] = $this->
getHTMLUnitToUnits($gradient[
'coords'][2], 0, $this->svgunit,
false);
23139 $gradient[
'coords'][3] = $this->
getHTMLUnitToUnits($gradient[
'coords'][3], 0, $this->svgunit,
false);
23140 $gradient[
'coords'][4] = $this->
getHTMLUnitToUnits($gradient[
'coords'][4], 0, $this->svgunit,
false);
23141 if (
$w <= $minlen) {
23144 if (
$h <= $minlen) {
23148 if ($gradient[
'gradientUnits'] ==
'objectBoundingBox') {
23150 $gradient[
'coords'][0] +=
$x;
23151 $gradient[
'coords'][1] +=
$y;
23152 $gradient[
'coords'][2] +=
$x;
23153 $gradient[
'coords'][3] +=
$y;
23156 $gradient[
'coords'][0] = (($gradient[
'coords'][0] -
$x) /
$w);
23157 $gradient[
'coords'][1] = (($gradient[
'coords'][1] -
$y) /
$h);
23158 $gradient[
'coords'][2] = (($gradient[
'coords'][2] -
$x) /
$w);
23159 $gradient[
'coords'][3] = (($gradient[
'coords'][3] -
$y) /
$h);
23160 $gradient[
'coords'][4] /=
$w;
23161 } elseif ($gradient[
'mode'] ==
'percentage') {
23162 foreach($gradient[
'coords'] as $key => $val) {
23163 $gradient[
'coords'][$key] = (intval($val) / 100);
23165 $gradient[
'coords'][$key] = 0;
23166 } elseif ($val > 1) {
23167 $gradient[
'coords'][$key] = 1;
23171 if (($gradient[
'type'] == 2) AND ($gradient[
'coords'][0] == $gradient[
'coords'][2]) AND ($gradient[
'coords'][1] == $gradient[
'coords'][3])) {
23173 $gradient[
'coords'][0] = 1;
23174 $gradient[
'coords'][1] = 0;
23175 $gradient[
'coords'][2] = 0.999;
23176 $gradient[
'coords'][3] = 0;
23179 $tmp = $gradient[
'coords'][1];
23180 $gradient[
'coords'][1] = $gradient[
'coords'][3];
23181 $gradient[
'coords'][3] = $tmp;
23183 $cy = ($this->h -
$y);
23184 if ($gradient[
'type'] == 3) {
23186 $cy -= ($gradient[
'coords'][1] * (
$w +
$h));
23191 $this->
_out(sprintf(
'%F 0 0 %F %F %F cm', (
$w * $this->k), (
$h * $this->k), (
$x * $this->k), ($cy * $this->k)));
23192 if (count($gradient[
'stops']) > 1) {
23193 $this->
Gradient($gradient[
'type'], $gradient[
'coords'], $gradient[
'stops'],
array(),
false);
23195 } elseif ($svgstyle[
'fill'] !=
'none') {
23197 if ($svgstyle[
'fill-opacity'] != 1) {
23198 $this->
setAlpha($this->alpha[
'CA'],
'Normal', $svgstyle[
'fill-opacity'],
false);
23201 if ($svgstyle[
'fill-rule'] ==
'evenodd') {
23208 if ($svgstyle[
'stroke'] !=
'none') {
23209 if ($svgstyle[
'stroke-opacity'] != 1) {
23210 $this->
setAlpha($svgstyle[
'stroke-opacity'],
'Normal', $this->alpha[
'ca'],
false);
23211 } elseif (preg_match(
'/rgba\(\d+%?,\s*\d+%?,\s*\d+%?,\s*(\d+(?:\.\d+)?)\)/i', $svgstyle[
'stroke'], $rgba_matches)) {
23212 $this->
setAlpha($rgba_matches[1],
'Normal', $this->alpha[
'ca'],
false);
23214 $stroke_style =
array(
23216 'width' => $this->
getHTMLUnitToUnits($svgstyle[
'stroke-width'], 0, $this->svgunit,
false),
23217 'cap' => $svgstyle[
'stroke-linecap'],
23218 'join' => $svgstyle[
'stroke-linejoin']
23220 if (isset($svgstyle[
'stroke-dasharray']) AND !empty($svgstyle[
'stroke-dasharray']) AND ($svgstyle[
'stroke-dasharray'] !=
'none')) {
23221 $stroke_style[
'dash'] = $svgstyle[
'stroke-dasharray'];
23228 if (!empty($svgstyle[
'font'])) {
23229 if (preg_match(
'/font-family[\s]*:[\s]*([^\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23232 $font_family = $svgstyle[
'font-family'];
23234 if (preg_match(
'/font-size[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23235 $font_size = trim($regs[1]);
23237 $font_size = $svgstyle[
'font-size'];
23239 if (preg_match(
'/font-style[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23240 $font_style = trim($regs[1]);
23242 $font_style = $svgstyle[
'font-style'];
23244 if (preg_match(
'/font-weight[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23245 $font_weight = trim($regs[1]);
23247 $font_weight = $svgstyle[
'font-weight'];
23249 if (preg_match(
'/font-stretch[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23250 $font_stretch = trim($regs[1]);
23252 $font_stretch = $svgstyle[
'font-stretch'];
23254 if (preg_match(
'/letter-spacing[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
23261 $font_size = $svgstyle[
'font-size'];
23262 $font_style = $svgstyle[
'font-style'];
23263 $font_weight = $svgstyle[
'font-weight'];
23264 $font_stretch = $svgstyle[
'font-stretch'];
23267 $font_size = $this->
getHTMLFontUnits($font_size, $this->svgstyles[0][
'font-size'], $prevsvgstyle[
'font-size'], $this->svgunit);
23270 switch ($font_style) {
23285 switch ($font_weight) {
23288 $font_style .=
'B';
23292 if ((substr($font_family, -1) ==
'I') AND (substr($font_family, -2, 1) ==
'B')) {
23293 $font_family = substr($font_family, 0, -2).
'I';
23294 } elseif (substr($font_family, -1) ==
'B') {
23295 $font_family = substr($font_family, 0, -1);
23300 switch ($svgstyle[
'text-decoration']) {
23301 case 'underline': {
23302 $font_style .=
'U';
23306 $font_style .=
'O';
23309 case 'line-through': {
23310 $font_style .=
'D';
23318 $this->
SetFont($font_family, $font_style, $font_size);
23343 if ($this->state != 2) {
23352 $d = preg_replace(
'/([0-9ACHLMQSTVZ])([\-\+])/si',
'\\1 \\2',
$d);
23353 preg_match_all(
'/([ACHLMQSTVZ])[\s]*([^ACHLMQSTVZ\"]*)/si',
$d, $paths, PREG_SET_ORDER);
23360 $xmin = 2147483647;
23362 $ymin = 2147483647;
23368 foreach ($paths as $key => $val) {
23370 $cmd = trim($val[1]);
23382 if (isset($val[2])) {
23384 $rawparams = preg_split(
'/([\,\s]+)/si', trim($val[2]));
23386 foreach ($rawparams as $ck => $cp) {
23388 if (abs(
$params[$ck]) < $minlen) {
23397 switch (strtoupper(
$cmd)) {
23399 foreach (
$params as $ck => $cp) {
23400 if (($ck % 2) == 0) {
23401 $x = $cp + $xoffset;
23403 $y = $cp + $yoffset;
23404 if ($firstcmd OR (abs($x0 -
$x) >= $minlen) OR (abs($y0 -
$y) >= $minlen)) {
23414 $xmin = min($xmin,
$x);
23415 $ymin = min($ymin,
$y);
23416 $xmax = max($xmax,
$x);
23417 $ymax = max($ymax,
$y);
23427 foreach (
$params as $ck => $cp) {
23428 if (($ck % 2) == 0) {
23429 $x = $cp + $xoffset;
23431 $y = $cp + $yoffset;
23432 if ((abs($x0 -
$x) >= $minlen) OR (abs($y0 -
$y) >= $minlen)) {
23437 $xmin = min($xmin,
$x);
23438 $ymin = min($ymin,
$y);
23439 $xmax = max($xmax,
$x);
23440 $ymax = max($ymax,
$y);
23450 foreach (
$params as $ck => $cp) {
23451 $x = $cp + $xoffset;
23452 if ((abs($x0 -
$x) >= $minlen) OR (abs($y0 -
$y) >= $minlen)) {
23457 $xmin = min($xmin,
$x);
23458 $xmax = max($xmax,
$x);
23466 foreach (
$params as $ck => $cp) {
23467 $y = $cp + $yoffset;
23468 if ((abs($x0 -
$x) >= $minlen) OR (abs($y0 -
$y) >= $minlen)) {
23473 $ymin = min($ymin,
$y);
23474 $ymax = max($ymax,
$y);
23482 foreach (
$params as $ck => $cp) {
23484 if ((($ck + 1) % 6) == 0) {
23485 $x1 =
$params[($ck - 5)] + $xoffset;
23486 $y1 =
$params[($ck - 4)] + $yoffset;
23487 $x2 =
$params[($ck - 3)] + $xoffset;
23488 $y2 =
$params[($ck - 2)] + $yoffset;
23491 $this->
_outCurve($x1, $y1, $x2, $y2, $x, $y);
23492 $xmin = min($xmin, $x, $x1, $x2);
23493 $ymin = min($ymin, $y, $y1, $y2);
23494 $xmax = max($xmax, $x, $x1, $x2);
23495 $ymax = max($ymax, $y, $y1, $y2);
23505 foreach (
$params as $ck => $cp) {
23507 if ((($ck + 1) % 4) == 0) {
23508 if (($key > 0) AND ((strtoupper($paths[($key - 1)][1]) ==
'C') OR (strtoupper($paths[($key - 1)][1]) ==
'S'))) {
23509 $x1 = (2 *
$x) - $x2;
23510 $y1 = (2 *
$y) - $y2;
23515 $x2 =
$params[($ck - 3)] + $xoffset;
23516 $y2 =
$params[($ck - 2)] + $yoffset;
23519 $this->
_outCurve($x1, $y1, $x2, $y2, $x, $y);
23520 $xmin = min($xmin, $x, $x1, $x2);
23521 $ymin = min($ymin, $y, $y1, $y2);
23522 $xmax = max($xmax, $x, $x1, $x2);
23523 $ymax = max($ymax, $y, $y1, $y2);
23533 foreach (
$params as $ck => $cp) {
23535 if ((($ck + 1) % 4) == 0) {
23537 $x1 =
$params[($ck - 3)] + $xoffset;
23538 $y1 =
$params[($ck - 2)] + $yoffset;
23539 $xa = (
$x + (2 * $x1)) / 3;
23540 $ya = (
$y + (2 * $y1)) / 3;
23543 $xb = (
$x + (2 * $x1)) / 3;
23544 $yb = ($y + (2 * $y1)) / 3;
23546 $xmin = min($xmin,
$x, $xa, $xb);
23547 $ymin = min($ymin, $y, $ya, $yb);
23548 $xmax = max($xmax,
$x, $xa, $xb);
23549 $ymax = max($ymax, $y, $ya, $yb);
23559 foreach (
$params as $ck => $cp) {
23561 if (($ck % 2) != 0) {
23562 if (($key > 0) AND ((strtoupper($paths[($key - 1)][1]) ==
'Q') OR (strtoupper($paths[($key - 1)][1]) ==
'T'))) {
23563 $x1 = (2 *
$x) - $x1;
23564 $y1 = (2 *
$y) - $y1;
23570 $xa = (
$x + (2 * $x1)) / 3;
23571 $ya = (
$y + (2 * $y1)) / 3;
23574 $xb = (
$x + (2 * $x1)) / 3;
23575 $yb = ($y + (2 * $y1)) / 3;
23577 $xmin = min($xmin,
$x, $xa, $xb);
23578 $ymin = min($ymin, $y, $ya, $yb);
23579 $xmax = max($xmax,
$x, $xa, $xb);
23580 $ymax = max($ymax, $y, $ya, $yb);
23590 foreach (
$params as $ck => $cp) {
23592 if ((($ck + 1) % 7) == 0) {
23595 $rx = abs(
$params[($ck - 6)]);
23596 $ry = abs(
$params[($ck - 5)]);
23597 $ang = -$rawparams[($ck - 4)];
23599 $fa = $rawparams[($ck - 3)];
23600 $fs = $rawparams[($ck - 2)];
23603 if ((abs($x0 - $x) < $minlen) AND (abs($y0 - $y) < $minlen)) {
23605 $xmin = min($xmin, $x);
23606 $ymin = min($ymin, $y);
23607 $xmax = max($xmax, $x);
23608 $ymax = max($ymax, $y);
23610 $cos_ang = cos($angle);
23611 $sin_ang = sin($angle);
23612 $a = (($x0 -
$x) / 2);
23613 $b = (($y0 -
$y) / 2);
23614 $xa = ($a * $cos_ang) - ($b * $sin_ang);
23615 $ya = ($a * $sin_ang) + ($b * $cos_ang);
23620 $delta = ($xa2 / $rx2) + ($ya2 / $ry2);
23622 $rx *= sqrt($delta);
23623 $ry *= sqrt($delta);
23627 $numerator = (($rx2 * $ry2) - ($rx2 * $ya2) - ($ry2 * $xa2));
23628 if ($numerator < 0) {
23631 $root = sqrt($numerator / (($rx2 * $ya2) + ($ry2 * $xa2)));
23636 $cax = $root * (($rx * $ya) / $ry);
23637 $cay = -$root * (($ry * $xa) / $rx);
23639 $cx = ($cax * $cos_ang) - ($cay * $sin_ang) + (($x0 +
$x) / 2);
23640 $cy = ($cax * $sin_ang) + ($cay * $cos_ang) + (($y0 +
$y) / 2);
23644 if (($fs == 0) AND ($dang > 0)) {
23645 $dang -= (2 * M_PI);
23646 } elseif (($fs == 1) AND ($dang < 0)) {
23647 $dang += (2 * M_PI);
23649 $angf = $angs - $dang;
23650 if ((($fs == 0) AND ($angs > $angf)) OR (($fs == 1) AND ($angs < $angf))) {
23656 $angs = round(rad2deg($angs), 6);
23657 $angf = round(rad2deg($angf), 6);
23659 if (($angs < 0) AND ($angf < 0)) {
23664 if (($key == 0) AND (isset($paths[($key + 1)][1])) AND (trim($paths[($key + 1)][1]) ==
'z')) {
23667 list($axmin, $aymin, $axmax, $aymax) = $this->
_outellipticalarc($cx, $cy, $rx, $ry, $ang, $angs, $angf, $pie, 2,
false, ($fs == 0),
true);
23668 $xmin = min($xmin, $x, $axmin);
23669 $ymin = min($ymin, $y, $aymin);
23670 $xmax = max($xmax, $x, $axmax);
23671 $ymax = max($ymax, $y, $aymax);
23691 return array($xmin, $ymin, ($xmax - $xmin), ($ymax - $ymin));
23700 if(strpos($name,
':') !==
false) {
23701 $parts = explode(
':', $name);
23702 return $parts[(
sizeof($parts) - 1)];
23720 if ($this->svgclipmode) {
23721 $this->svgclippaths[
$this->svgclipid][] =
array(
'name' => $name,
'attribs' => $attribs,
'tm' => $this->svgcliptm[$this->svgclipid]);
23724 if ($this->svgdefsmode AND !in_array($name,
array(
'clipPath',
'linearGradient',
'radialGradient',
'stop'))) {
23725 if (isset($attribs[
'id'])) {
23726 $attribs[
'child_elements'] =
array();
23727 $this->svgdefs[$attribs[
'id']] =
array(
'name' => $name,
'attribs' => $attribs);
23730 if (end($this->svgdefs) !== FALSE) {
23731 $last_svgdefs_id = key($this->svgdefs);
23732 if (isset($this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'])) {
23733 $attribs[
'id'] =
'DF_'.(count($this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements']) + 1);
23734 $this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'][$attribs[
'id']] =
array(
'name' => $name,
'attribs' => $attribs);
23741 if (
$parser ==
'clip-path') {
23746 $prev_svgstyle = $this->svgstyles[max(0,(count($this->svgstyles) - 1))];
23747 $svgstyle = $this->svgstyles[0];
23748 if ($clipping AND !isset($attribs[
'fill']) AND (!isset($attribs[
'style']) OR (!preg_match(
'/[;\"\s]{1}fill[\s]*:[\s]*([^;\"]*)/si', $attribs[
'style'], $attrval)))) {
23750 $attribs[
'fill'] =
'none';
23754 $attribs[
'style'] =
';'.$attribs[
'style'];
23756 foreach ($prev_svgstyle as $key => $val) {
23759 $svgstyle[$key] = $val;
23763 if ($attribs[$key] ==
'inherit') {
23764 $svgstyle[$key] = $val;
23766 $svgstyle[$key] = $attribs[$key];
23770 $attrval =
array();
23771 if (preg_match(
'/[;\"\s]{1}'.$key.
'[\s]*:[\s]*([^;\"]*)/si', $attribs[
'style'], $attrval) AND isset($attrval[1])) {
23772 if ($attrval[1] ==
'inherit') {
23773 $svgstyle[$key] = $val;
23775 $svgstyle[$key] = $attrval[1];
23781 if (!empty($ctm)) {
23784 $tm =
array(1,0,0,1,0,0);
23786 if (isset($attribs[
'transform']) AND !empty($attribs[
'transform'])) {
23789 $svgstyle[
'transfmatrix'] = $tm;
23790 $invisible =
false;
23791 if (($svgstyle[
'visibility'] ==
'hidden') OR ($svgstyle[
'visibility'] ==
'collapse') OR ($svgstyle[
'display'] ==
'none')) {
23798 $this->svgdefsmode =
true;
23806 $this->svgclipmode =
true;
23807 if (!isset($attribs[
'id'])) {
23808 $attribs[
'id'] =
'CP_'.(count($this->svgcliptm) + 1);
23810 $this->svgclipid = $attribs[
'id'];
23817 if(++$this->svg_tag_depth <= 1) {
23821 array_push($this->svgstyles, $svgstyle);
23823 $svgX = (isset($attribs[
'x'])?$attribs[
'x']:0);
23824 $svgY = (isset($attribs[
'y'])?$attribs[
'y']:0);
23825 $svgW = (isset($attribs[
'width'])?$attribs[
'width']:0);
23826 $svgH = (isset($attribs[
'height'])?$attribs[
'height']:0);
23838 if (isset($attribs[
'viewBox'])) {
23840 preg_match_all(
"/[0-9]+/", $attribs[
'viewBox'], $tmp);
23842 if (
sizeof($tmp) == 4) {
23852 if (isset($attribs[
'preserveAspectRatio'])) {
23853 if($attribs[
'preserveAspectRatio'] ==
'none') {
23856 preg_match_all(
'/[a-zA-Z]+/', $attribs[
'preserveAspectRatio'], $tmp);
23858 if ((
sizeof($tmp) == 2) AND (strlen($tmp[0]) == 8) AND (in_array($tmp[1],
array(
'meet',
'slice',
'none')))) {
23859 $aspectX = substr($tmp[0], 0, 4);
23860 $aspectY = substr($tmp[0], 4, 4);
23865 $wr = ($svgW / $vw);
23866 $hr = ($svgH / $vh);
23868 if ((($fit ==
'meet') AND ($hr < $wr)) OR (($fit ==
'slice') AND ($hr > $wr))) {
23869 if ($aspectX ==
'xMax') {
23870 $ax = (($vw * ($wr / $hr)) - $vw);
23872 if ($aspectX ==
'xMid') {
23873 $ax = ((($vw * ($wr / $hr)) - $vw) / 2);
23876 } elseif ((($fit ==
'meet') AND ($hr > $wr)) OR (($fit ==
'slice') AND ($hr < $wr))) {
23877 if ($aspectY ==
'YMax') {
23878 $ay = (($vh * ($hr / $wr)) - $vh);
23880 if ($aspectY ==
'YMid') {
23881 $ay = ((($vh * ($hr / $wr)) - $vh) / 2);
23885 $newtm =
array($wr, 0, 0, $hr, (($wr * ($ax - $vx)) - $svgX), (($hr * ($ay - $vy)) - $svgY));
23895 array_push($this->svgstyles, $svgstyle);
23897 $x = (isset($attribs[
'x'])?$attribs[
'x']:0);
23898 $y = (isset($attribs[
'y'])?$attribs[
'y']:0);
23906 case 'linearGradient': {
23907 if ($this->pdfa_mode) {
23910 if (!isset($attribs[
'id'])) {
23911 $attribs[
'id'] =
'GR_'.(count($this->svggradients) + 1);
23913 $this->svggradientid = $attribs[
'id'];
23917 if (isset($attribs[
'gradientUnits'])) {
23923 if (((!isset($attribs[
'x1'])) AND (!isset($attribs[
'y1'])) AND (!isset($attribs[
'x2'])) AND (!isset($attribs[
'y2'])))
23924 OR ((isset($attribs[
'x1']) AND (substr($attribs[
'x1'], -1) ==
'%'))
23925 OR (isset($attribs[
'y1']) AND (substr($attribs[
'y1'], -1) ==
'%'))
23926 OR (isset($attribs[
'x2']) AND (substr($attribs[
'x2'], -1) ==
'%'))
23927 OR (isset($attribs[
'y2']) AND (substr($attribs[
'y2'], -1) ==
'%')))) {
23932 $x1 = (isset($attribs[
'x1'])?$attribs[
'x1']:
'0');
23933 $y1 = (isset($attribs[
'y1'])?$attribs[
'y1']:
'0');
23934 $x2 = (isset($attribs[
'x2'])?$attribs[
'x2']:
'100');
23935 $y2 = (isset($attribs[
'y2'])?$attribs[
'y2']:
'0');
23936 if (isset($attribs[
'gradientTransform'])) {
23940 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
23946 case 'radialGradient': {
23947 if ($this->pdfa_mode) {
23950 if (!isset($attribs[
'id'])) {
23951 $attribs[
'id'] =
'GR_'.(count($this->svggradients) + 1);
23953 $this->svggradientid = $attribs[
'id'];
23957 if (isset($attribs[
'gradientUnits'])) {
23963 if (((!isset($attribs[
'cx'])) AND (!isset($attribs[
'cy'])))
23964 OR ((isset($attribs[
'cx']) AND (substr($attribs[
'cx'], -1) ==
'%'))
23965 OR (isset($attribs[
'cy']) AND (substr($attribs[
'cy'], -1) ==
'%')))) {
23967 } elseif (isset($attribs[
'r']) AND is_numeric($attribs[
'r']) AND ($attribs[
'r']) <= 1) {
23972 $cx = (isset($attribs[
'cx']) ? $attribs[
'cx'] : 0.5);
23973 $cy = (isset($attribs[
'cy']) ? $attribs[
'cy'] : 0.5);
23974 $fx = (isset($attribs[
'fx']) ? $attribs[
'fx'] : $cx);
23975 $fy = (isset($attribs[
'fy']) ? $attribs[
'fy'] : $cy);
23976 $r = (isset($attribs[
'r']) ? $attribs[
'r'] : 0.5);
23977 if (isset($attribs[
'gradientTransform'])) {
23981 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
23989 if (substr($attribs[
'offset'], -1) ==
'%') {
23990 $offset = floatval(substr($attribs[
'offset'], -1)) / 100;
23992 $offset = floatval($attribs[
'offset']);
23998 $opacity = isset($svgstyle[
'stop-opacity'])?$svgstyle[
'stop-opacity']:1;
23999 $this->svggradients[
$this->svggradientid][
'stops'][] =
array(
'offset' => $offset,
'color' => $stop_color,
'opacity' => $opacity);
24007 if (isset($attribs[
'd'])) {
24008 $d = trim($attribs[
'd']);
24010 $x = (isset($attribs[
'x'])?$attribs[
'x']:0);
24011 $y = (isset($attribs[
'y'])?$attribs[
'y']:0);
24012 $w = (isset($attribs[
'width'])?$attribs[
'width']:1);
24013 $h = (isset($attribs[
'height'])?$attribs[
'height']:1);
24022 if (!empty($obstyle)) {
24036 $x = (isset($attribs[
'x'])?$this->
getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false):0);
24037 $y = (isset($attribs[
'y'])?$this->
getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false):0);
24038 $w = (isset($attribs[
'width'])?$this->
getHTMLUnitToUnits($attribs[
'width'], 0, $this->svgunit,
false):0);
24039 $h = (isset($attribs[
'height'])?$this->
getHTMLUnitToUnits($attribs[
'height'], 0, $this->svgunit,
false):0);
24040 $rx = (isset($attribs[
'rx'])?$this->
getHTMLUnitToUnits($attribs[
'rx'], 0, $this->svgunit,
false):0);
24041 $ry = (isset($attribs[
'ry'])?$this->
getHTMLUnitToUnits($attribs[
'ry'], 0, $this->svgunit,
false):$rx);
24048 $obstyle = $this->
setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y,
$w,
$h,
'RoundedRectXY',
array(
$x,
$y,
$w,
$h, $rx, $ry,
'1111',
'CNZ'));
24049 if (!empty($obstyle)) {
24060 $r = (isset($attribs[
'r']) ? $this->
getHTMLUnitToUnits($attribs[
'r'], 0, $this->svgunit,
false) : 0);
24061 $cx = (isset($attribs[
'cx']) ? $this->
getHTMLUnitToUnits($attribs[
'cx'], 0, $this->svgunit,
false) : (isset($attribs[
'x']) ? $this->
getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false) : 0));
24062 $cy = (isset($attribs[
'cy']) ? $this->
getHTMLUnitToUnits($attribs[
'cy'], 0, $this->svgunit,
false) : (isset($attribs[
'y']) ? $this->
getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false) : 0));
24073 $obstyle = $this->
setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y,
$w,
$h,
'Circle',
array($cx, $cy,
$r, 0, 360,
'CNZ'));
24074 if (!empty($obstyle)) {
24085 $rx = (isset($attribs[
'rx']) ? $this->
getHTMLUnitToUnits($attribs[
'rx'], 0, $this->svgunit,
false) : 0);
24086 $ry = (isset($attribs[
'ry']) ? $this->
getHTMLUnitToUnits($attribs[
'ry'], 0, $this->svgunit,
false) : 0);
24087 $cx = (isset($attribs[
'cx']) ? $this->
getHTMLUnitToUnits($attribs[
'cx'], 0, $this->svgunit,
false) : (isset($attribs[
'x']) ? $this->
getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false) : 0));
24088 $cy = (isset($attribs[
'cy']) ? $this->
getHTMLUnitToUnits($attribs[
'cy'], 0, $this->svgunit,
false) : (isset($attribs[
'y']) ? $this->
getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false) : 0));
24095 $this->
Ellipse($cx, $cy, $rx, $ry, 0, 0, 360,
'CNZ',
array(),
array(), 8);
24099 $obstyle = $this->
setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y,
$w,
$h,
'Ellipse',
array($cx, $cy, $rx, $ry, 0, 0, 360,
'CNZ'));
24100 if (!empty($obstyle)) {
24101 $this->
Ellipse($cx, $cy, $rx, $ry, 0, 0, 360, $obstyle,
array(),
array(), 8);
24111 $x1 = (isset($attribs[
'x1'])?$this->
getHTMLUnitToUnits($attribs[
'x1'], 0, $this->svgunit,
false):0);
24112 $y1 = (isset($attribs[
'y1'])?$this->
getHTMLUnitToUnits($attribs[
'y1'], 0, $this->svgunit,
false):0);
24113 $x2 = (isset($attribs[
'x2'])?$this->
getHTMLUnitToUnits($attribs[
'x2'], 0, $this->svgunit,
false):0);
24114 $y2 = (isset($attribs[
'y2'])?$this->
getHTMLUnitToUnits($attribs[
'y2'], 0, $this->svgunit,
false):0);
24117 $w = abs($x2 - $x1);
24118 $h = abs($y2 - $y1);
24122 $obstyle = $this->
setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y,
$w,
$h,
'Line',
array($x1, $y1, $x2, $y2));
24123 $this->
Line($x1, $y1, $x2, $y2);
24133 $points = (isset($attribs[
'points'])?$attribs[
'points']:
'0 0');
24134 $points = trim($points);
24136 $points = preg_split(
'/[\,\s]+/si', $points);
24137 if (count($points) < 4) {
24141 $xmin = 2147483647;
24143 $ymin = 2147483647;
24145 foreach ($points as $key => $val) {
24147 if (($key % 2) == 0) {
24149 $xmin = min($xmin, $p[$key]);
24150 $xmax = max($xmax, $p[$key]);
24153 $ymin = min($ymin, $p[$key]);
24154 $ymax = max($ymax, $p[$key]);
24159 $w = ($xmax - $xmin);
24160 $h = ($ymax - $ymin);
24161 if ($name ==
'polyline') {
24165 if (!empty($obstyle)) {
24177 if (!empty($obstyle)) {
24190 if (!isset($attribs[
'xlink:href']) OR empty($attribs[
'xlink:href'])) {
24193 $x = (isset($attribs[
'x'])?$this->
getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false):0);
24194 $y = (isset($attribs[
'y'])?$this->
getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false):0);
24195 $w = (isset($attribs[
'width'])?$this->
getHTMLUnitToUnits($attribs[
'width'], 0, $this->svgunit,
false):0);
24196 $h = (isset($attribs[
'height'])?$this->
getHTMLUnitToUnits($attribs[
'height'], 0, $this->svgunit,
false):0);
24197 $img = $attribs[
'xlink:href'];
24202 if (preg_match(
'/^data:image\/[^;]+;base64,/',
$img, $m) > 0) {
24204 $img =
'@'.base64_decode(substr(
$img, strlen($m[0])));
24211 if ((
$img[0] ==
'/') AND !empty(
$_SERVER[
'DOCUMENT_ROOT']) AND (
$_SERVER[
'DOCUMENT_ROOT'] !=
'/')) {
24213 if (($findroot ===
false) OR ($findroot > 1)) {
24214 if (substr(
$_SERVER[
'DOCUMENT_ROOT'], -1) ==
'/') {
24222 $testscrtype = @parse_url(
$img);
24223 if (!isset($testscrtype[
'query']) OR empty($testscrtype[
'query'])) {
24225 $img = str_replace(K_PATH_URL, K_PATH_MAIN,
$img);
24230 if (($imgtype ==
'eps') OR ($imgtype ==
'ai')) {
24232 } elseif ($imgtype ==
'svg') {
24266 if (isset($this->svgtextmode[
'text-anchor']) AND !empty($this->svgtext)) {
24270 $this->svgtextmode[
'invisible'] = $invisible;
24274 array_push($this->svgstyles, $svgstyle);
24275 if (isset($attribs[
'x'])) {
24277 } elseif ($name ==
'tspan') {
24282 if (isset($attribs[
'dx'])) {
24285 if (isset($attribs[
'y'])) {
24287 } elseif ($name ==
'tspan') {
24292 if (isset($attribs[
'dy'])) {
24295 $svgstyle[
'text-color'] = $svgstyle[
'fill'];
24296 $this->svgtext =
'';
24297 if (isset($svgstyle[
'text-anchor'])) {
24298 $this->svgtextmode[
'text-anchor'] = $svgstyle[
'text-anchor'];
24300 $this->svgtextmode[
'text-anchor'] =
'start';
24302 if (isset($svgstyle[
'direction'])) {
24303 if ($svgstyle[
'direction'] ==
'rtl') {
24304 $this->svgtextmode[
'rtl'] =
true;
24306 $this->svgtextmode[
'rtl'] =
false;
24309 $this->svgtextmode[
'rtl'] =
false;
24311 if (isset($svgstyle[
'stroke']) AND ($svgstyle[
'stroke'] !=
'none') AND isset($svgstyle[
'stroke-width']) AND ($svgstyle[
'stroke-width'] > 0)) {
24312 $this->svgtextmode[
'stroke'] = $this->
getHTMLUnitToUnits($svgstyle[
'stroke-width'], 0, $this->svgunit,
false);
24314 $this->svgtextmode[
'stroke'] =
false;
24325 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
24326 $svgdefid = substr($attribs[
'xlink:href'], 1);
24327 if (isset($this->svgdefs[$svgdefid])) {
24328 $use = $this->svgdefs[$svgdefid];
24329 if (isset($attribs[
'xlink:href'])) {
24330 unset($attribs[
'xlink:href']);
24332 if (isset($attribs[
'id'])) {
24333 unset($attribs[
'id']);
24335 if (isset($use[
'attribs'][
'x']) AND isset($attribs[
'x'])) {
24336 $attribs[
'x'] += $use[
'attribs'][
'x'];
24338 if (isset($use[
'attribs'][
'y']) AND isset($attribs[
'y'])) {
24339 $attribs[
'y'] += $use[
'attribs'][
'y'];
24341 if (empty($attribs[
'style'])) {
24342 $attribs[
'style'] =
'';
24344 if (!empty($use[
'attribs'][
'style'])) {
24346 $attribs[
'style'] = str_replace(
';;',
';',
';'.$use[
'attribs'][
'style'].$attribs[
'style']);
24348 $attribs = array_merge($use[
'attribs'], $attribs);
24360 if (!empty($attribs[
'child_elements'])) {
24361 $child_elements = $attribs[
'child_elements'];
24362 unset($attribs[
'child_elements']);
24363 foreach($child_elements as $child_element) {
24364 if (empty($child_element[
'attribs'][
'closing_tag'])) {
24367 if (isset($child_element[
'attribs'][
'content'])) {
24368 $this->svgtext = $child_element[
'attribs'][
'content'];
24386 if ($this->svgdefsmode AND !in_array($name,
array(
'defs',
'clipPath',
'linearGradient',
'radialGradient',
'stop'))) {;
24387 if (end($this->svgdefs) !== FALSE) {
24388 $last_svgdefs_id = key($this->svgdefs);
24389 if (isset($this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'])) {
24390 foreach($this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'] as $child_element) {
24391 if (isset($child_element[
'attribs'][
'id']) AND ($child_element[
'name'] == $name)) {
24392 $this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'][$child_element[
'attribs'][
'id'].
'_CLOSE'] =
array(
'name' => $name,
'attribs' =>
array(
'closing_tag' => TRUE,
'content' => $this->svgtext));
24396 if ($this->svgdefs[$last_svgdefs_id][
'name'] == $name) {
24397 $this->svgdefs[$last_svgdefs_id][
'attribs'][
'child_elements'][$last_svgdefs_id.
'_CLOSE'] =
array(
'name' => $name,
'attribs' =>
array(
'closing_tag' => TRUE,
'content' => $this->svgtext));
24406 $this->svgdefsmode =
false;
24411 $this->svgclipmode =
false;
24415 if (--$this->svg_tag_depth <= 0) {
24421 array_pop($this->svgstyles);
24427 if ($this->svgtextmode[
'invisible']) {
24436 if ($this->svgtextmode[
'text-anchor'] !=
'start') {
24438 if ($this->svgtextmode[
'text-anchor'] ==
'end') {
24439 if ($this->svgtextmode[
'rtl']) {
24440 $this->x += $textlen;
24442 $this->x -= $textlen;
24444 } elseif ($this->svgtextmode[
'text-anchor'] ==
'middle') {
24445 if ($this->svgtextmode[
'rtl']) {
24446 $this->x += ($textlen / 2);
24448 $this->x -= ($textlen / 2);
24455 if ($name ==
'text') {
24461 $this->
Cell($textlen, 0,
$text, 0, 0,
'',
false,
'', 0,
false,
'L',
'T');
24462 if ($name ==
'text') {
24470 $this->svgtext =
'';
24472 if (!$this->svgdefsmode) {
24473 array_pop($this->svgstyles);
24492 $this->svgtext .=
$data;
write1DBarcode($code, $type, $x='', $y='', $w='', $h='', $xres='', $style='', $align='')
Print a Linear Barcode.
$page_boxes
Define the page boundaries boxes to be set on document.
RoundedRectXY($x, $y, $w, $h, $rx, $ry, $round_corner='1111', $style='', $border_style=array(), $fill_color=array())
Draws a rounded rectangle.
getGroupPageNo()
Return the current page in the group.
resetLastH()
Reset the last cell height.
$column_start_page
Starting page for columns.
setPageFormat($format, $orientation='P')
Change the format of the current page.
$footerpos
Array used to store footer positions of each page.
__destruct()
Default destructor.
$PageBreakTrigger
Threshold used to trigger page breaks.
static convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R'=>128, 'G'=>128, 'B'=>128))
Returns an array (RGB or CMYK) from an html color name, or a six-digit (i.e.
$radiobutton_groups
List of radio buttons parent objects.
static getPathPaintOperator($style, $default='S')
Get the Path-Painting Operators.
$header_line_color
Color for header line (RGB array).
$TextColor
Commands for text color.
$encrypted
IBoolean flag indicating whether document is protected.
addTOCPage($orientation='', $format='', $keepmargins=false)
Adds a new TOC (Table Of Content) page to the document.
Close()
Terminates the PDF document.
setJPEGQuality($quality)
Set the default JPEG compression quality (1-100)
_putshaders()
Output gradient shaders.
$tagvspaces
Array used for custom vertical spaces for HTML tags.
setFooterMargin($fm=10)
Set footer margin.
setPDFVersion($version='1.7')
Set the PDF version (check PDF reference for valid values).
ImagePngAlpha($file, $x, $y, $wpx, $hpx, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $filehash='')
Extract info from a PNG image with alpha channel using the Imagick or GD library. ...
$pagelen
Array containing page lengths in bytes.
getNumberOfColumns()
Return the current number of columns.
$file_id
File ID (used on document trailer).
_putviewerpreferences()
Output viewer preferences.
$bgcolor
Current background color.
$svgdefsmode
Boolean value true when in SVG defs group.
$empty_signature_appearance
Array of empty digital signature appearances.
getFontSubsetting()
Return the default option for font subsetting.
getCellPaddings()
Get the internal Cell padding array.
static $pageboxes
Array page boxes names static.
setColor($type, $col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=false, $name='')
Defines the color used by the specified type ('draw', 'fill', 'text').
$listcount
HTML PARSER: array count list items on nested lists.
setLastH($h)
Set the last cell height.
_putresourcedict()
Output Resources Dictionary.
$tocpage
Boolean flag true when we are on TOC (Table Of Content) page.
static getFormattedDate($time)
Returns a formatted date-time.
static _getTrueTypeFontSubset($font, $subsetchars)
Returns a subset of the TrueType font data without the unused glyphs.
Link($x, $y, $w, $h, $link, $spaces=0)
Puts a link on a rectangular area of the page.
static getTagStyleFromCSSarray($css)
Compact CSS data array into single string.
GetNumChars($s)
Returns the numbero of characters in a string.
setHeaderFont($font)
Set header font.
SetFillColor($col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=false, $name='')
Defines the color used for all filling operations (filled rectangles and cell backgrounds).
getGraphicVars()
Returns current graphic variables as array.
Header()
This method is used to render the page header.
$buffer
Buffer holding in-memory PDF.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$page_regions
Array of no-write regions.
getFontsList()
Fill the list of available fonts ($this->fontlist).
$linestyleJoin
PDF string for join value of the last line.
$svgclipmode
Boolean value true when in SVG clipPath tag.
$form_obj_id
List of form annotations IDs.
$fonts
Array of used fonts.
setTextShadow($params=array('enabled'=>false, 'depth_w'=>0, 'depth_h'=>0, 'color'=>false, 'opacity'=>1, 'blend_mode'=> 'Normal'))
Set parameters for drop shadow effect for text.
addJavascriptObject($script, $onload=false)
Adds a javascript object and return object ID.
_outPoint($x, $y)
Begin a new subpath by moving the current point to coordinates (x, y), omitting any connecting line s...
$underline
Underlining flag.
setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1, $clip_function='', $clip_params=array())
Apply the requested SVG styles (*** TO BE COMPLETED ***)
SetFontSize($size, $out=true)
Defines the size of the current font.
getHeaderData()
Returns header data:
applyTSA($signature)
NOT YET IMPLEMENTED Request TSA for a timestamp.
MirrorP($x='', $y='')
Point reflection mirroring.
SetDisplayMode($zoom, $layout='SinglePage', $mode='UseNone')
Defines the way the document is to be displayed by the viewer.
$svg_tag_depth
Depth of the svg tag, to keep track if the svg tag is a subtag or the root tag.
$signature_data
Digital signature data.
startTransaction()
Stores a copy of the current TCPDF object used for undo operation.
setHeaderTemplateAutoreset($val=true)
Set a flag to automatically reset the xobject template used by Header() method at each page...
Button($name, $w, $h, $caption, $action, $prop=array(), $opt=array(), $x='', $y='', $js=false)
Creates a button field.
TranslateX($t_x)
Translate graphic object horizontally.
TextField($name, $w, $h, $prop=array(), $opt=array(), $x='', $y='', $js=false)
Creates a text field.
setFooter()
This method is used to render the page footer.
_outRestoreGraphicsState()
Outputs the "restore graphics state" operator 'Q'.
$overline
Overlining flag.
$footer_margin
Minimum distance between footer and bottom page margin.
getFontSpacing()
Get the amount to increase or decrease the space between characters in a text.
setPageBoxTypes($boxes)
Set page boxes to be included on page descriptions.
$tmprtl
Boolean flag used to force RTL or LTR string direction.
$AutoPageBreak
Automatic page breaking.
$FontAscent
Current font ascent (distance between font top and baseline).
$fhPt
Height of page format in points.
$n_dests
Object ID for Named Destinations.
SetBooklet($booklet=true, $inner=-1, $outer=-1)
Set the booklet mode for double-sided pages.
setHeader()
This method is used to render the page header.
getAllInternalPageNumberAliases()
Return an array containing all internal page aliases.
getImageRBY()
Return the right-bottom (or left-bottom for RTL) corner Y coordinate of last inserted image...
unhtmlentities($text_to_convert)
Reverse function for htmlentities.
static arrUTF8ToUTF16BE($unicode, $setbom=false)
Converts array of UTF-8 characters to UTF16-BE string.
$footerlen
Array used to store footer length of each page.
SetDrawColor($col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=false, $name='')
Defines the color used for all drawing operations (lines, rectangles and cell borders).
$fontlist
List of available fonts on filesystem.
getScaleFactor()
Returns the scale factor (number of points in user unit).
PieSectorXY($xc, $yc, $rx, $ry, $a, $b, $style='FD', $cw=false, $o=0, $nc=2)
Draw the sector of an ellipse.
getCSSPadding($csspadding, $width=0)
Get the internal Cell padding from CSS attribute.
setFontSubBuffer($font, $key, $data)
Set font buffer content.
Footer()
This method is used to render the page footer.
getFontBBox()
Returns the bounding box of the current font in user units.
getNumPages()
Get the total number of insered pages.
$offsets
Array of object offsets.
_putpages()
Output pages (and replace page number aliases).
static _escapeXML($str)
Escape some special characters (< > &) for XML output.
_putXMP()
Put XMP data object and return ID.
setFontSpacing($spacing=0)
Set the amount to increase or decrease the space between characters in a text.
$emptypagemrk
Array used to store page positions to track empty pages (keys are the page numbers).
Ellipse($x0, $y0, $rx, $ry='', $angle=0, $astart=0, $afinish=360, $style='', $line_style=array(), $fill_color=array(), $nc=2)
Draws an ellipse.
SetCreator($creator)
Defines the creator of the document.
_putbookmarks()
Create a bookmark PDF string.
SetTextColor($col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=false, $name='')
Defines the color used for text.
getFontAscent($font, $style='', $size=0)
Return the font ascent value.
getPageHeight($pagenum='')
Returns the page height in units.
$header_xobj_autoreset
If true reset the Header Xobject template at each page.
selectColumn($col='')
Set position at a given column.
$ZoomMode
Zoom display mode.
$lispacer
Spacer string for LI tags.
$numimages
Counts the number of pages.
$cell_height_ratio
Default cell height ratio.
sortBookmarks()
Sort bookmarks for page and key.
SetDefaultMonospacedFont($font)
Defines the default monospaced font.
getAutoPageBreak()
Return the auto-page-break mode (true or false).
setPageMark()
Set start-writing mark on current page stream used to put borders and fills.
$FontFamily
Current font family.
$signature_max_length
Digital signature max length.
getRemainingWidth()
Returns the remaining width between the current position and margins.
getDestination()
Return the Named Destination array.
setRTL($enable, $resetx=true)
Enable or disable Right-To-Left language mode.
$FontStyle
Current font style.
$img_rb_x
The right-bottom (or left-bottom for RTL) corner X coordinate of last inserted image.
$transfmatrix
Array of transformation matrix.
static swapPageBoxCoordinates($page, $pagedim)
Swap X and Y coordinates of page boxes (change page boxes orientation).
$header_xobjid
ID of the stored default header template (-1 = not set).
static intToRoman($number)
Returns the Roman representation of an integer number.
static _AES($key, $text)
Returns the input text exrypted using AES algorithm and the specified key.
colorRegistrationBar($x, $y, $w, $h, $transition=true, $vertical=false, $colors='A, R, G, B, C, M, Y, K')
Paints color transition registration bars.
Line($x1, $y1, $x2, $y2, $style=array())
Draws a line between two points.
$creator
Document creator.
MirrorH($x='')
Horizontal Mirroring.
getHTMLUnitToUnits($htmlval, $refsize=1, $defaultunit='px', $points=false)
Convert HTML string containing value and unit of measure to user's units or points.
$FontSize
Current font size in user unit.
_encrypt_data($n, $s)
Encrypt the input string.
SetXY($x, $y, $rtloff=false)
Defines the abscissa and ordinate of the current position.
getBreakMargin($pagenum='')
Returns the page break margin.
$js_objects
Javascript objects array.
_outRect($x, $y, $w, $h, $op)
Append a rectangle to the current path as a complete subpath, with lower-left corner (x...
$rtl
Boolean flag to indicate if the document language is Right-To-Left.
SetDrawSpotColor($name, $tint=100)
Defines the spot color used for all drawing operations (lines, rectangles and cell borders)...
if(PHP_SAPI !='cli') color
getRawCharWidth($char)
Returns the length of the char in user unit for the current font.
$hPt
Current height of page in points.
$encoding
Default encoding.
$efnames
Embedded Files Names.
setHtmlVSpace($tagvs)
Set the vertical spaces for HTML tags.
$tsa_data
Timestamping data.
closeHTMLTagHandler($dom, $key, $cell, $maxbottomliney=0)
Process closing tags.
_putjavascript()
Create a javascript PDF string.
writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='')
Allows to preserve some HTML formatting (limited support).
GetStringWidth($s, $fontname='', $fontstyle='', $fontsize=0, $getarray=false)
Returns the length of a string in user unit.
$DrawColor
Commands for drawing color.
getImageScale()
Returns the adjusting factor to convert pixels to user units.
$dpi
DPI (Dot Per Inch) Document Resolution (do not change).
setDestination($name, $y=-1, $page='', $x=-1)
Add a Named Destination.
const PDF_FONT_NAME_MAIN
Default main font name.
$newline
Boolean flag to indicate if a new line is created.
resetHeaderTemplate()
Reset the xobject template used by Header() method.
$FillColor
Commands for filling color.
setImageBuffer($image, $data)
Set image buffer content.
getPageBuffer($page)
Get page buffer content.
setBarcode($bc='')
Set document barcode.
$extgstates
Array of transparency objects and parameters.
static utf8Bidi($ta, $str='', $forcertl=false, $isunicode=true, &$currentfont)
Reverse the RLT substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
$FontDescent
Current font descent (distance between font bottom and baseline).
convertSVGtMatrix($tm)
Convert SVG transformation matrix to PDF.
RoundedRect($x, $y, $w, $h, $r, $round_corner='1111', $style='', $border_style=array(), $fill_color=array())
Draws a rounded rectangle.
$svgclipid
ID of last SVG clipPath.
startSVGElementHandler($parser, $name, $attribs, $ctm=array())
Sets the opening SVG element handler function for the XML parser.
ImageEps($file, $x='', $y='', $w=0, $h=0, $link='', $useBoundingBox=true, $align='', $palign='', $border=0, $fitonpage=false, $fixoutvals=false)
Embed vector-based Adobe Illustrator (AI) or AI-compatible EPS files.
$sign
Boolean flag to enable document digital signature.
openHTMLTagHandler($dom, $key, $cell)
Process opening tags.
$strokecolor
Current stroke color.
setSpacesRE($re='/[^\S\xa0]/')
Set regular expression to detect withespaces or word separators.
static getUserPermissionCode($permissions, $mode=0)
Return the permission code used on encryption (P value).
getFontStyle()
Returns the current font style.
SetAuthor($author)
Defines the author of the document.
StopTransform()
Stops a 2D tranformation restoring previous graphic state.
ScaleXY($s, $x='', $y='')
Vertical and horizontal proportional Scaling.
Ln($h='', $cell=false)
Performs a line break.
PolyLine($p, $style='', $line_style=array(), $fill_color=array())
Draws a polygonal line.
_outellipticalarc($xc, $yc, $rx, $ry, $xang=0, $angs=0, $angf=360, $pie=false, $nc=2, $startpoint=true, $ccw=true, $svg=false)
Append an elliptical arc to the current path.
$InFooter
Flag set when processing page footer.
Error($msg)
Throw an exception or print an error message and die if the K_TCPDF_PARSER_THROW_EXCEPTION_ERROR cons...
getBuffer()
Get buffer content.
setHtmlLinksStyle($color=array(0, 0, 255), $fontstyle='U')
Set the color and font style for HTML links.
static convertHexStringToString($bs)
Convert hexadecimal string to string.
getCSSMargin($cssmargin, $width=0)
Get the internal Cell margin from CSS attribute.
$inxobj
Boolean value true when we are inside an XObject.
getFontSizePt()
Returns the current font size in points unit.
getColumn()
Return the current column number.
static removeSHY($txt='', $unicode=true)
Removes SHY characters from text.
setExtGState($gs)
Add an extgstate.
getFontSize()
Returns the current font size.
getFontFamily()
Returns the current font family name.
_Ovalue()
Compute O value (used for encryption)
_outCurveV($x2, $y2, $x3, $y3)
Append a cubic Bezier curve to the current path.
Rotate($angle, $x='', $y='')
Rotate object.
$textstrokewidth
Text stroke width in doc units.
startPageGroup($page='')
Create a new page group.
$pdflayers
Array of PDF layers data.
getPageDimensions($pagenum='')
Returns an array of page dimensions:
static getEncPermissionsString($protection)
Convert encryption P value to a string of bytes, low-order byte first.
if(! $in) print Initializing normalization quick check tables n
GetX()
Returns the relative X value of current position.
$thead
Table header content to be repeated on each new page.
$listnum
HTML PARSER: current list nesting level.
isRTLTextDir()
Return the current temporary RTL status.
getFontDescent($font, $style='', $size=0)
Return the font descent value.
getImageBuffer($image)
Get image buffer content.
static unichr($c, $unicode=true)
Returns the unicode caracter specified by the value.
static _getfontpath()
Return fonts path.
setFooterFont($font)
Set footer font.
setTextRenderingMode($stroke=0, $fill=true, $clip=false)
Set Text rendering mode.
$ur
Array with additional document-wide usage rights for the document.
_outCurve($x1, $y1, $x2, $y2, $x3, $y3)
Append a cubic Bezier curve to the current path.
SetDocInfoUnicode($unicode=true)
Turn on/off Unicode mode for document information dictionary (meta tags).
static getHyphenPatternsFromTEX($file)
Returns an array of hyphenation patterns.
getAliasNbPages()
Returns the string alias used for the total number of pages.
setTimeStamp($tsa_host='', $tsa_username='', $tsa_password='', $tsa_cert='')
Enable document timestamping (requires the OpenSSL Library).
stringRightTrim($str, $replace='')
Right trim the input string.
$dests
A dictionary of names and corresponding destinations (Dests key on document Catalog).
static getRandomSeed($seed='')
Returns a string containing random data to be used as a seed for encryption methods.
static getBorderMode($brd, $position='start', $opencell=true)
Get the border mode accounting for multicell position (opens bottom side of multicell crossing pages)...
static getCSSdataArray($dom, $key, $css)
Returns the styles array that apply for the selected HTML tag.
setSRGBmode($mode=false)
Set flag to force sRGB_IEC61966-2.1 black scaled ICC color profile for the whole document.
$txtshadow
Text shadow data array.
SetFillColorArray($color, $ret=false)
Defines the color used for all filling operations (filled rectangles and cell backgrounds).
startLayer($name='', $print=true, $view=true, $lock=true)
Start a new pdf layer.
const K_PATH_IMAGES
Installation path (/var/www/tcpdf/).
static UTF8StringToArray($str, $isunicode=true, &$currentfont)
Converts UTF-8 strings to codepoints array.
$check_page_regions
Boolean value true when page region check is active.
_textstring($s, $n=0)
Format a text string for meta information.
static getTimestamp($date)
Returns timestamp in seconds from formatted date-time.
static sendOutputData($data, $length)
Output input data and compress it if possible.
addHTMLVertSpace($hbz=0, $hb=0, $cell=false, $firsttag=false, $lasttag=false)
Add vertical spaces if needed.
setTableHeader()
This method is used to render the table header on new page (if any).
getPageRegions()
Return an array of no-write page regions.
addExtGState($parms)
Add transparency parameters to the current extgstate.
$form_action
Current form action (used during XHTML rendering).
_putinfo()
Adds some Metadata information (Document Information Dictionary) (see Chapter 14.3.3 Document Information Dictionary of PDF32000_2008.pdf Reference)
static pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL)
Split string by a regular expression.
PHP class to creates array representations for 2D barcodes to be used with TCPDF (http://www.tcpdf.org).
$doc_creation_timestamp
Document creation date-time.
$img_rb_y
The right-bottom corner Y coordinate of last inserted image.
$CurOrientation
Current page orientation (P = Portrait, L = Landscape).
$isunicode
Boolean flag set to true when the input text is unicode (require unicode fonts).
$linestyleDash
PDF string for dash value of the last line.
Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style='', $line_style=array(), $fill_color=array())
Draws a Bezier curve.
static setGDImageTransparency($new_image, $image)
Set the transparency for the given GD image.
static formatTOCPageNumber($num)
Format the page numbers on the Table Of Content.
$footer_line_color
Color for footer line (RGB array).
ScaleY($s_y, $x='', $y='')
Vertical Scaling.
_dooverlinew($x, $y, $w)
Overline for rectangular text area.
setDocCreationTimestamp($time)
Set the document creation timestamp.
Static methods used by the TCPDF class.
$num_columns
Number of colums.
$default_graphic_vars
Array of default graphic settings.
getDocCreationTimestamp()
Returns document creation timestamp in seconds.
setLIsymbol($symbol='!')
Set the default bullet to be used as LI bullet symbol.
$pdfa_mode
If true set the document to PDF/A mode.
setHeaderMargin($hm=10)
Set header margin.
$default_form_prop
Deafult Javascript field properties.
PHP class for generating PDF documents without requiring external extensions.
_putcatalog()
Output Catalog.
const K_PATH_CACHE
Cache directory for temporary files (full path).
$CoreFonts
Array of standard font names.
setViewerPreferences($preferences)
Set the viewer preferences dictionary controlling the way the document is to be presented on the scre...
$tempfontsize
Temporary font size in points.
$pageobjects
Array of object IDs for each page.
static isValidURL($url)
Check if the URL exist.
$imagekeys
Store the image keys.
getNumLines($txt, $w=0, $reseth=false, $autopadding=true, $cellpadding='', $border=0)
This method return the estimated number of lines for print a simple text string using Multicell() met...
SetLink($link, $y=0, $page=-1)
Defines the page and position a link points to.
GetArrStringWidth($sa, $fontname='', $fontstyle='', $fontsize=0, $getarray=false)
Returns the string length of an array of chars in user unit or an array of characters widths...
for($col=0; $col< 50; $col++) $d
$default_monospaced_font
Default monospace font.
$objcopy
Cloned copy of the current class object.
$annotation_fonts
List of fonts used on form fields (fontname => fontkey).
getAbsFontMeasure($s)
Convert a relative font measure into absolute value.
$svgunit
Deafult unit of measure for SVG.
const K_THAI_TOPCHARS
Set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language...
$print_header
Boolean flag to print/hide page header.
SetFont($family, $style='', $size=null, $fontfile='', $subset='default', $out=true)
Sets the font used to print character strings.
_putresources()
Output Resources.
$embeddedfiles
Array of files to embedd.
lastPage($resetmargins=false)
Reset pointer to the last document page.
Arrow($x0, $y0, $x1, $y1, $head_style=0, $arm_size=5, $arm_angle=15)
Draws a grahic arrow.
$re_space
Array of $re_spaces parts.
static $uni_type
Array of Unicode types.
_outLine($x, $y)
Append a straight line segment from the current point to the point (x, y).
$viewer_preferences
PDF viewer preferences.
static empty_string($str)
Determine whether a string is empty.
SetTextColorArray($color, $ret=false)
Defines the color used for text.
_fixAES256Password($password)
Convert password for AES-256 encryption mode.
drawHTMLTagBorder($tag, $xmax)
Draw an HTML block border and fill.
setFooterData($tc=array(0, 0, 0), $lc=array(0, 0, 0))
Set footer data.
writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true)
Prints a cell (rectangular area) with optional borders, background color and html text string...
$subject
Document subject.
setCellHeightRatio($h)
Set the height of the cell (line height) respect the font height.
getPageGroupAlias()
Return the alias for the total number of pages in the current page group.
setImageScale($scale)
Set the adjusting factor to convert pixels to user units.
static UTF8ArrToLatin1Arr($unicode)
Converts UTF-8 characters array to array of Latin1 characters array
_Uvalue()
Compute U value (used for encryption)
$lisymbol
Symbol used for HTML unordered list items.
$font_stretching
Percentage of character stretching.
SetAbsXY($x, $y)
Set the absolute X and Y coordinates of the current pointer.
Write($h, $txt, $link='', $fill=false, $align='', $ln=false, $stretch=0, $firstline=false, $firstblock=false, $maxh=0, $wadj=0, $margin='')
This method prints text from the current position.
$default_table_columns
Default number of columns for html table.
$k
Scale factor (number of points in user unit).
setOpenCell($isopen)
Set the top/bottom cell sides to be open or closed when the cell cross the page.
getAliasNumPage()
Returns the string alias used for the page number.
$bordermrk
Array used to store positions inside the pages buffer (keys are the page numbers).
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)
Prints a text cell at the specified position.
$lasth
Height of last cell printed.
PieSector($xc, $yc, $r, $a, $b, $style='FD', $cw=true, $o=90)
Draw the sector of a circle.
_addfield($type, $name, $x, $y, $w, $h, $prop)
Adds a javascript form field.
static set_mqr($mqr)
Sets the current active configuration setting of magic_quotes_runtime (if the set_magic_quotes_runtim...
_objectkey($n)
Compute encryption key depending on object number where the encrypted data is stored.
startPage($orientation='', $format='', $tocpage=false)
Starts a new page to the document.
_getrawstream($s, $n=0)
get raw output stream.
$listindentlevel
HTML PARSER: current list indententation level.
Done rendering charts as images
_out($s)
Output a string to the document.
$force_srgb
If true force sRGB color profile for all document.
$header_text_color
Color for header text (RGB array).
inPageBody()
Check if we are on the page body (excluding page header and footer).
$original_lMargin
Original left margin value.
static $alias_tot_pages
String alias for total number of pages.
$textrendermode
Text rendering mode: 0 = Fill text; 1 = Stroke text; 2 = Fill, then stroke text; 3 = Neither fill nor...
Annotation($x, $y, $w, $h, $text, $opt=array('Subtype'=> 'Text'), $spaces=0)
Puts a markup annotation on a rectangular area of the page.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $preferences
getCSSFontStretching($stretch, $parent=100)
Returns the percentage of font stretching from CSS value.
getAlpha()
Get the alpha mode array (CA, ca, BM, AIS).
$barcode
Barcode to print on page footer (only if set).
$svgdefs
Array of SVG defs.
$PageAnnots
Array of Annotations in pages.
MirrorL($angle=0, $x='', $y='')
Reflection against a straight line through point (x, y) with the gradient angle (angle).
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())
Draws a star polygon.
$w
Current width of page in user unit.
$PageMode
A name object specifying how the document should be displayed when opened.
$currpagegroup
Current page group number.
$feps
Epsilon value used for float calculations.
swapMargins($reverse=true)
Swap the left and right margins.
$font_spacing
Increases or decreases the space between characters in a text by the specified amount (tracking)...
$sig_obj_id
Digital signature object ID.
_dolinethrough($x, $y, $txt)
Line through text.
endLayer()
End the current PDF layer.
getHashForTCPDFtagParams($data)
Return an hash code used to ensure that the serialized data has been generated by this TCPDF instance...
setPrintFooter($val=true)
Set a flag to print page footer.
MirrorV($y='')
Verical Mirroring.
Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
Prints a cell (rectangular area) with optional borders, background color and character string...
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
$header_logo
Header image logo.
static getTCPDFProducer()
Return the current TCPDF producer.
getBarcode()
Get current barcode.
$pdfunit
Default unit of measure for document.
static formatPageNumber($num)
Format the page numbers.
SetY($y, $resetx=true, $rtloff=false)
Moves the current abscissa back to the left margin and sets the ordinate.
$numfonts
Counts the number of fonts.
$endlinex
End position of the latest inserted line.
setBuffer($data)
Set buffer content (always append data).
SetKeywords($keywords)
Associates keywords with the document, generally in the form 'keyword1 keyword2 ...'.
removeTagNamespace($name)
Return the tag name without the namespace.
static replacePageNumAliases($page, $replace, $diff=0)
Replace page number aliases with number.
_outSaveGraphicsState()
Outputs the "save graphics state" operator 'q'.
static getFontRefSize($size, $refsize=12)
Get a reference font size.
static extractCSSproperties($cssdata)
Extracts the CSS properties from a CSS string.
setSignatureAppearance($x=0, $y=0, $w=0, $h=0, $page=-1, $name='')
Set the digital signature appearance (a cliccable rectangle area to get signature properties) ...
$print_footer
Boolean flag to print/hide page footer.
static _AESnopad($key, $text)
Returns the input text exrypted using AES algorithm and the specified key.
AddPage($orientation='', $format='', $keepmargins=false, $tocpage=false)
Adds a new page to the document.
$header_logo_width
Width of header image logo in user units.
setPageRegions($regions=array())
Set no-write regions on page.
getPage()
Get current document page number.
setBookmark($txt, $level=0, $y=-1, $page='', $style='', $color=array(0, 0, 0), $x=-1, $link='')
Adds a bookmark - alias for Bookmark().
getCellHeight($fontsize, $padding=TRUE)
Return the cell height.
static $alias_group_num_page
String alias for group page number.
$font_subsetting
Boolean flag: if true enables font subsetting by default.
$current_column
Current column number.
_dounderlinew($x, $y, $w)
Underline for rectangular text area.
$header_string
String to pring on page header after title.
$listindent
HTML PARSER: indent amount for lists.
setExtraXMP($xmp)
Set additional XMP data to be added on the default XMP data just before the end of "x:xmpmeta" tag...
static $byterange_string
ByteRange placemark used during digital signature process.
stringTrim($str, $replace='')
Trim the input string.
getAllSpotColors()
Returns the array of spot colors.
static utf8StrRev($str, $setbom=false, $forcertl=false, $isunicode=true, &$currentfont)
Reverse the RLT substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
getCSSBorderWidth($width)
Returns the border width from CSS property.
_endpage()
Mark end of page.
SetCompression($compress=true)
Activates or deactivates page compression.
$state
Current document state.
fitBlock($w, $h, $x, $y, $fitonpage=false)
Set the block dimensions accounting for page breaks and page/column fitting.
setUserRights( $enable=true, $document='/FullSave', $annots='/Create/Delete/Modify/Copy/Import/Export', $form='/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate', $signature='/Modify', $ef='/Create/Delete/Modify/Import', $formex='')
Set User's Rights for PDF Reader WARNING: This is experimental and currently do not work...
_putxobjects()
Output Form XObjects Templates.
_datestring($n=0, $timestamp=0)
Returns a formatted date for meta information.
static getPageSizeFromFormat($format)
Get page dimensions from format name.
$outlines
Outlines for bookmark.
getCharBBox($char)
Returns the glyph bounding box of the specified character in the current font in user units...
stringLeftTrim($str, $replace='')
Left trim the input string.
$cell_padding
Array of cell internal paddings ('T' => top, 'R' => right, 'B' => bottom, 'L' => left).
_dooverline($x, $y, $txt)
Overline text.
$LineWidth
Line width in user unit.
static $alias_num_page
String alias for page number.
hyphenateWord($word, $patterns, $dictionary=array(), $leftmin=1, $rightmin=2, $charmin=1, $charmax=8)
Returns an array of chars containing soft hyphens.
static getPageMode($mode='UseNone')
Get the canonical page layout mode.
$crMargin
Cell right margin (used by regions).
_dolinethroughw($x, $y, $w)
Line through for rectangular text area.
unserializeTCPDFtagParameters($data)
Unserialize parameters to be used with TCPDF tag in HTML code.
$header_font
Default font used on page header.
Circle($x0, $y0, $r, $angstr=0, $angend=360, $style='', $line_style=array(), $fill_color=array(), $nc=2)
Draws a circle.
getCSSBorderDashStyle($style)
Returns the border dash style from CSS property.
static UTF8ToUTF16BE($str, $setbom=false, $isunicode=true, &$currentfont)
Converts UTF-8 strings to UTF16-BE.
commitTransaction()
Delete the copy of the current TCPDF object used for undo operation.
setListIndentWidth($width)
Set custom width for list indentation.
serializeTCPDFtagParameters($data)
Serialize an array of parameters to be used with TCPDF tag in HTML code.
setDefaultTableColumns($cols=4)
Set the default number of columns in a row for HTML tables.
$textindent
Text indentation value (used for text-indent CSS attribute).
Play around with inserting and removing rows and columns
$footer_font
Default font used on page footer.
static $uni_RE_PATTERN_ARABIC
Pattern to test Arabic strings using regular expressions.
static $alias_group_tot_pages
String alias for total number of pages in a single group.
$form_enctype
Current form encryption type (used during XHTML rendering).
$OutlineRoot
Outline root for bookmark.
$numpages
Counts the number of pages.
getCellMargins()
Get the internal Cell margin array.
$xobjects
Array of XObjects.
setEqualColumns($numcols=0, $width=0, $y='')
Set multiple columns of the same size.
ScaleX($s_x, $x='', $y='')
Horizontal Scaling.
_putcidfont0($font)
Output CID-0 fonts.
setRasterizeVectorImages($mode)
Enable/disable rasterization of vector images using ImageMagick library.
AddSpotColor($name, $c, $m, $y, $k)
Defines a new spot color.
GetCharWidth($char, $notlast=true)
Returns the length of the char in user unit for the current font considering current stretching and s...
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)
Paints a coons patch mesh.
$internal_encoding
PHP internal encoding.
static setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k, $pagedim=array())
Set page boundaries.
$signature_appearance
Data for digital signature appearance.
getHtmlDomArray($html)
Returns the HTML DOM array.
copyPage($page=0)
Clone the specified page to a new page.
static getPageLayoutMode($layout='SinglePage')
Get the canonical page layout mode.
setSignature($signing_cert='', $private_key='', $private_key_password='', $extracerts='', $cert_type=2, $info=array(), $approval='')
Enable document signature (requires the OpenSSL Library).
$xobjid
Current XObject ID.
$linethrough
line through state
SetLeftMargin($margin)
Defines the left margin.
_UEvalue()
Compute UE value (used for encryption)
setCellMargins($left='', $top='', $right='', $bottom='')
Set the internal Cell margins.
static getTransformationMatrixProduct($ta, $tb)
Get the product of two SVG tranformation matrices.
Output($name='doc.pdf', $dest='I')
Send the document to a given destination: string, local file or browser.
setPageUnit($unit)
Set the units of measure for the document.
registrationMark($x, $y, $r, $double=false, $cola=array(100, 100, 100, 100, 'All'), $colb=array(0, 0, 0, 0, 'None'))
Paints a registration mark.
$linestyleWidth
PDF string for width value of the last line.
getPDFData()
Returns the PDF data.
rollbackTransaction($self=false)
This method allows to undo the latest transaction by returning the latest saved TCPDF object with sta...
static _escape($s)
Add "\" before "\", "(" and ")".
setFontSubsetting($enable=true)
Enable or disable default option for font subsetting.
$overprint
Overprint mode array.
AcceptPageBreak()
Whenever a page break condition is met, the method is called, and the break is issued or not dependin...
$x
Current horizontal position in user unit for cell positioning.
checkPageBreak($h=0, $y='', $addpage=true)
Add page if needed.
$premode
Boolean flag to indicate if we are inside a PRE tag.
const K_TCPDF_THROW_EXCEPTION_ERROR
If true and PHP version is greater than 5, then the Error() method throw new exception instead of ter...
const K_TCPDF_CALLS_IN_HTML
If true allows to call TCPDF methods using HTML syntax IMPORTANT: For security reason, disable this feature if you are printing user HTML content.
$clMargin
Cell left margin (used by regions).
getTextShadow()
Return the text shadow parameters array.
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())
Puts an image in the page.
static getSpotColor($name, &$spotc)
Return the Spot color array.
_beginpage($orientation='', $format='')
Initialize a new page.
_getxobjectdict()
Return XObjects Dictionary.
getCSSBorderMargin($cssbspace, $width=0)
Get the border-spacing from CSS attribute.
$CurrentFont
Current font info.
static UTF8ArrSubString($strarr, $start='', $end='', $unicode=true)
Extract a slice of the $strarr array and return it as string.
_putAPXObject($w=0, $h=0, $stream='')
Put appearance streams XObject used to define annotation's appearance states.
_destroy($destroyall=false, $preserve_objcopy=false)
Unset all class variables except the following critical variables.
AddLink()
Creates a new internal link and returns its identifier.
Add a drawing to the header
setCellPaddings($left='', $top='', $right='', $bottom='')
Set the internal Cell paddings.
getFooterMargin()
Returns footer margin in user units.
static getFontFullPath($file, $fontdir=false)
Return font full path.
$pagegroups
Array that contains the number of pages in each page group.
_putsignature()
Add certification signature (DocMDP or UR3) You can set only one signature type.
$javascript
Javascript code.
getMargins()
Returns an array containing current margins:
$cntmrk
Array used to store content positions inside the pages buffer (keys are the page numbers).
$form_mode
Current method to submit forms.
getFontStretching()
Get the percentage of character stretching.
setGraphicVars($gvars, $extended=false)
Set graphic variables.
$svggradients
Array of SVG gradients.
setPage($pnum, $resetmargins=false)
Move pointer at the specified document page and update page dimensions.
Rect($x, $y, $w, $h, $style='', $border_style=array(), $fill_color=array())
Draws a rectangle.
$starting_page_number
Starting page number.
$font_obj_ids
Store the font object IDs.
getSignatureAppearanceArray($x=0, $y=0, $w=0, $h=0, $page=-1, $name='')
Get the array that defines the signature appearance (page and rectangle coordinates).
getCellBorder($x, $y, $w, $h, $brd)
Returns the code to draw the cell border.
$h
Current height of page in user unit.
static $enc_padding
Encryption padding string.
$start_transaction_y
Store Y position when startTransaction() is called.
$jpeg_quality
Set the default JPEG compression quality (1-100).
setStartingPageNumber($num=1)
Set the starting page number.
SetAutoPageBreak($auto, $margin=0)
Enables or disables the automatic page breaking mode.
getPageNumGroupAlias()
Return the alias for the page number on the current page group.
getDocModificationTimestamp()
Returns document modification timestamp in seconds.
$last_enc_key
Last RC4 key encrypted (cached for optimisation).
static UniArrSubString($uniarr, $start='', $end='')
Extract a slice of the $uniarr array and return it as string.
Create styles array
The data for the language used.
$y
Current vertical position in user unit for cell positioning.
replaceChar($oldchar, $newchar)
Replace a char if is defined on the current font.
Polycurve($x0, $y0, $segments, $style='', $line_style=array(), $fill_color=array())
Draws a poly-Bezier curve.
$opencell
Boolean flag to indicate if the border of the cell sides that cross the page should be removed...
$FontFiles
Array of font files.
$customlistindent
HTML PARSER: custom indent amount for lists.
PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www...
setSpotColor($type, $name, $tint=100)
Set the spot color for the specified type ('draw', 'fill', 'text').
setFontStretching($perc=100)
Set the percentage of character stretching.
$tsa_timestamp
Boolean flag to enable document timestamping with TSA.
$radio_groups
List of radio group objects IDs.
movePage($frompage, $topage)
Move a page to a previous position.
_dounderline($x, $y, $txt)
Underline text.
static fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces)
Cleanup HTML code (requires HTML Tidy library).
setColorArray($type, $color, $ret=false)
Set the color array for the specified type ('draw', 'fill', 'text').
static _md5_16($str)
Encrypts a string using MD5 and returns it's value as a binary string.
$booklet
Booklet mode for double-sided pages.
_enddoc()
Output end of document (EOF).
$compress
Compression flag.
registrationMarkCMYK($x, $y, $r)
Paints a CMYK registration mark.
$linestyleCap
PDF string for CAP value of the last line.
ListBox($name, $w, $h, $values, $prop=array(), $opt=array(), $x='', $y='', $js=false)
Creates a List-box field.
$ColorFlag
Indicates whether fill and text colors are different.
foreach($mandatory_scripts as $file) $timestamp
checkPageRegions($h, $x, $y)
Check page for no-write regions and adapt current coordinates and page margins if necessary...
$inthead
True when we are printing the thead section on a new page.
$original_rMargin
Original right margin value.
resetColumns()
Remove columns and reset page margins.
setOverprint($stroking=true, $nonstroking='', $mode=0)
Set overprint mode for stroking (OP) and non-stroking (op) painting operations.
static $svginheritprop
Array of hinheritable SVG properties.
$maxselcol
Maximum page and column selected.
SetDrawColorArray($color, $ret=false)
Defines the color used for all drawing operations (lines, rectangles and cell borders).
PageNo()
Returns the current page number.
$htmlLinkFontStyle
Default font style to add to html links.
static $alias_right_shift
String alias for right shift compensation used to correctly align page numbers on the right...
$pageopen
Store the fage status (true when opened, false when closed).
Translate($t_x, $t_y)
Translate graphic object horizontally and vertically.
$openMarkedContent
Boolean flag to indicate if marked-content sequence is open.
$wPt
Current width of page in points.
_generateencryptionkey()
Compute encryption key.
replaceMissingChars($text, $font='', $style='', $subs=array())
Replace missing font characters on selected font with specified substitutions.
_putimages()
Output images.
$header_margin
Minimum distance between header and top page margin.
getLastH()
Get the last cell height.
GetY()
Returns the ordinate of the current position.
$htmlLinkColorArray
Default color for html links.
SetTopMargin($margin)
Defines the top margin.
_putencryption()
Put encryption on PDF document.
$imgscale
Adjusting factor to convert pixels to user units.
$InHeader
Flag set when processing page header.
Polygon($p, $style='', $line_style=array(), $fill_color=array(), $closed=true)
Draws a polygon.
getCSSBorderStyle($cssborder)
Returns the border style array from CSS border properties.
PageNoFormatted()
Returns the current page number formatted as a string.
$re_spaces
Regular expression used to find blank characters (required for word-wrapping).
getGroupPageNoFormatted()
Returns the current group page number formatted as a string.
$page_obj_id
ID of page objects.
$htmlvspace
Count the latest inserted vertical spaces on HTML.
printTemplate($id, $x='', $y='', $w=0, $h=0, $align='', $palign='', $fitonpage=false)
Print an XObject Template.
SetProtection($permissions=array('print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'), $user_pass='', $owner_pass=null, $mode=0, $pubkeys=null)
Set document protection Remark: the protection against modification is for people who have the full A...
__construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false)
This is the class constructor.
_putheader()
Output PDF File Header (7.5.2).
$footer_text_color
Color for footer text (RGB array).
static _toJPEG($image, $quality, $tempfile)
Convert the loaded image to a JPEG and then return a structure for the PDF creator.
isUnicodeFont()
Return true if the current font is unicode type.
addTOC($page='', $numbersfont='', $filler='.', $toc_name='TOC', $style='', $color=array(0, 0, 0))
Output a Table of Content Index (TOC).
LinearGradient($x, $y, $w, $h, $col1=array(), $col2=array(), $coords=array(0, 0, 1, 0))
Paints a linear colour gradient.
cropMark($x, $y, $w, $h, $type='T, R, B, L', $color=array(100, 100, 100, 100, 'All'))
Paints crop marks.
StartTransform()
Starts a 2D tranformation saving current graphic state.
$svgclippaths
Array of SVG clipPath commands.
SkewY($angle_y, $x='', $y='')
Skew vertically.
$svgstyles
Array of SVG properties.
$newpagegroup
Array of page numbers were a new page group was started (the page numbers are the keys of the array)...
segSVGContentHandler($parser, $data)
Sets the character data handler function for the XML parser.
$fontkeys
Store the font keys.
getGDgamma($img, $c)
Get the GD-corrected PNG gamma value from alpha color.
_putextgstates()
Put extgstates for object transparency.
static revstrpos($haystack, $needle, $offset=0)
Find position of last occurrence of a substring in a string.
$gdgammacache
Cache array for computed GD gamma values.
SetLineStyle($style, $ret=false)
Set line style.
SetRightMargin($margin)
Defines the right margin.
$columns
Array of column measures (width, space, starting Y position).
setTempRTL($mode)
Force temporary RTL language direction.
static UTF8ToLatin1($str, $isunicode=true, &$currentfont)
Converts UTF-8 strings to Latin1 when using the standard 14 core fonts.
replaceBuffer($data)
Replace the buffer content.
$tcpdflink
If true print TCPDF meta link.
getHeaderMargin()
Returns header margin in user units.
Open()
This method begins the generation of the PDF document.
getInternalPageNumberAliases($a='')
Return an array containing variations for the basic page number alias.
endTOCPage()
Terminate the current TOC (Table Of Content) page.
Clip($x, $y, $w, $h)
Set a rectangular clipping area.
getStringHeight($w, $txt, $reseth=false, $autopadding=true, $cellpadding='', $border=0)
This method return the estimated height needed for printing a simple text string using the Multicell(...
$last_enc_key_c
Last RC4 computed key.
const K_BLANK_IMAGE
Installation path (/var/www/tcpdf/).
static objclone($object)
Creates a copy of a class object.
$bufferlen
Length of the buffer in bytes.
SetMargins($left, $top, $right=-1, $keepmargins=false)
Defines the left, top and right margins.
endSVGElementHandler($parser, $name)
Sets the closing SVG element handler function for the XML parser.
SetSubject($subject)
Defines the subject of the document.
endTemplate()
End the current XObject Template started with startTemplate() and restore the previous graphic state...
getAliasRightShift()
Returns the string alias used right align page numbers.
setVisibility($v)
Set the visibility of the successive elements.
static $uni_identity_h
ToUnicode map for Identity-H stream static.
static getImageFileType($imgfile, $iminfo=array())
Return the image type given the file name or array returned by getimagesize() function.
putHtmlListBullet($listdepth, $listtype='', $size=10)
Output an HTML list bullet or ordered item symbol.
RadioButton($name, $w, $prop=array(), $opt=array(), $onvalue='On', $checked=false, $x='', $y='', $js=false)
Creates a RadioButton field.
replaceRightShiftPageNumAliases($page, $aliases, $diff)
Replace right shift page number aliases with spaces to correct right alignment.
SetAbsX($x)
Set the absolute X coordinate of the current pointer.
RadialGradient($x, $y, $w, $h, $col1=array(), $col2=array(), $coords=array(0.5, 0.5, 0.5, 0.5, 1))
Paints a radial colour gradient.
$cache_file_length
Array used to store the lengths of cache files.
TranslateY($t_y)
Translate graphic object vertically.
pixelsToUnits($px)
Converts pixels to User's Units.
isCharDefined($char, $font='', $style='')
Return true in the character is present in the specified font.
getHTMLFontUnits($val, $refsize=12, $parent_size=12, $defaultunit='pt')
Convert HTML string containing font size value to points.
$encryptdata
Array containing encryption settings.
$spot_colors
Array of Spot colors.
_dochecks()
Check for locale-related bug.
setPageOrientation($orientation, $autopagebreak='', $bottommargin='')
Set page orientation.
$listordered
HTML PARSER: array of boolean values, true in case of ordered list (OL), false otherwise.
$LayoutMode
Layout display mode.
$links
Array of internal links.
IncludeJS($script)
Adds a javascript.
setHeaderData($ln='', $lw=0, $ht='', $hs='', $tc=array(0, 0, 0), $lc=array(0, 0, 0))
Set header data.
getCellHeightRatio()
return the height of cell repect font height.
static _JScolor($color)
Convert color to javascript color.
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())
Draws a regular polygon.
write2DBarcode($code, $type, $x='', $y='', $w='', $h='', $style='', $align='', $distort=false)
Print 2D Barcode.
AddFont($family, $style='', $fontfile='', $subset='default')
Imports a TrueType, Type1, core, or CID0 font and makes it available.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
$bMargin
Page break margin.
setColumnsArray($columns)
Set columns array.
SetCellPadding($pad)
Set the same internal Cell padding for top, right, bottom, left-.
setFormDefaultProp($prop=array())
Set default properties for form fields.
static getObjFilename($type='tmp', $file_id='')
Returns a temporary filename for caching object on filesystem.
static _parsejpeg($file)
Extract info from a JPEG file without using the GD library.
ImageSVG($file, $x='', $y='', $w=0, $h=0, $link='', $align='', $palign='', $border=0, $fitonpage=false)
Embedd a Scalable Vector Graphics (SVG) image.
static _toPNG($image, $tempfile)
Convert the loaded image to a PNG and then return a structure for the PDF creator.
$keywords
Document keywords.
getHeaderFont()
Get header font.
_datastring($s, $n=0)
Format a data string for meta information.
Scale($s_x, $s_y, $x='', $y='')
Vertical and horizontal non-proportional Scaling.
Bookmark($txt, $level=0, $y=-1, $page='', $style='', $color=array(0, 0, 0), $x=-1, $link='')
Adds a bookmark.
fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='')
Cleanup HTML code (requires HTML Tidy library).
SetFillSpotColor($name, $tint=100)
Defines the spot color used for all filling operations (filled rectangles and cell backgrounds)...
static _RC4($key, $text, &$last_enc_key, &$last_enc_key_c)
Returns the input text encrypted using RC4 algorithm and the specified key.
$custom_xmp
Custom XMP data.
SetLineWidth($width)
Defines the line width.
hyphenateText($text, $patterns, $dictionary=array(), $leftmin=1, $rightmin=2, $charmin=1, $charmax=8)
Returns text with soft hyphens.
_getobj($objid='')
Return the starting object string for the selected object ID.
CheckBox($name, $w, $checked=false, $prop=array(), $opt=array(), $onvalue='Yes', $x='', $y='', $js=false)
Creates a CheckBox field.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
getOriginalMargins()
Returns an array containing original margins:
_getannotsrefs($n)
Get references to page annotations.
$transfmatrix_key
Current key for transformation matrix.
static encodeNameObject($name)
Encode a name object.
$transfmrk
Array used to store positions of graphics transformation blocks inside the page buffer.
$svgcliptm
Array of SVG clipPath tranformation matrix.
_outCurveY($x1, $y1, $x3, $y3)
Append a cubic Bezier curve to the current path.
getRTL()
Return the RTL status.
$doc_modification_timestamp
Document modification date-time.
_putEmbeddedFiles()
Embedd the attached files.
static $uni_RE_PATTERN_RTL
Pattern to test RTL (Righ-To-Left) strings using regular expressions.
$intmrk
Array used to store positions inside the pages buffer (keys are the page numbers).
addPageRegion($region)
Add a single no-write region on selected page.
static UTF8ArrayToUniArray($ta, $isunicode=true)
Convert an array of UTF8 values to array of unicode characters.
$diffs
Array of encoding differences.
$HREF
HTML PARSER: array to store current link and rendering styles.
$epsmarker
String used to mark the beginning and end of EPS image blocks.
getFooterFont()
Get Footer font.
SkewX($angle_x, $x='', $y='')
Skew horizontally.
$docinfounicode
If true set the document information dictionary in Unicode.
$page
Current page number.
setAlpha($stroking=1, $bm='Normal', $nonstroking='', $ais=false)
Set alpha for stroking (CA) and non-stroking (ca) operations.
$start_transaction_page
Store page number when startTransaction() is called.
removePageRegion($key)
Remove a single no-write region.
GetLineWidth()
Returns the current the line width.
$pages
Array containing pages.
Transform($tm)
Apply graphic transformations.
setDocModificationTimestamp($time)
Set the document modification timestamp.
$cell_margin
Array of cell margins ('T' => top, 'R' => right, 'B' => bottom, 'L' => left).
SVGPath($d, $style='')
Draws an SVG path.
$colxshift
Array of: X difference between table cell x start and starting page margin, cellspacing, cellpadding.
$images
Array of used images.
$gradients
Array for storing gradient information.
addEmptySignatureAppearance($x=0, $y=0, $w=0, $h=0, $page=-1, $name='')
Add an empty digital signature appearance (a cliccable rectangle area to get signature properties) ...
getBorderStartPosition()
Return the starting coordinates to draw an html border.
static fopenLocal($filename, $mode)
Wrapper to use fopen only with local files.
$svgtextmode
SVG text properties.
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)
This method allows printing text with line breaks.
getPageWidth($pagenum='')
Returns the page width in units.
const K_SMALL_RATIO
Reduction factor for small font.
Skew($angle_x, $angle_y, $x='', $y='')
Skew.
SetX($x, $rtloff=false)
Defines the abscissa of the current position.
adjustCellPadding($brd=0)
Adjust the internal Cell padding array to take account of the line width.
addHtmlLink($url, $name, $fill=false, $firstline=false, $color='', $style=-1, $firstblock=false)
Output anchor link.
_putspotcolors()
Output Spot Colors Resources.
static getSVGTransformMatrix($attribute)
Get the tranformation matrix from SVG transform attribute.
getFormDefaultProp()
Return the default properties for form fields.
setPageBuffer($page, $data, $append=false)
Set page buffer content.
startTemplate($w=0, $h=0, $group=false)
Start a new XObject Template.
_OEvalue()
Compute OE value (used for encryption)
static getVectorsAngle($x1, $y1, $x2, $y2)
Returns the angle in radiants between two vectors.
$rasterize_vector_images
Boolean flag: if true convert vector images (SVG, EPS) to raster image using GD or ImageMagick librar...
getCellCode($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
Returns the PDF string code to print a cell (rectangular area) with optional borders, background color and character string.
$header_title
Title to be printed on default page header.
Gradient($type, $coords, $stops, $background=array(), $antialias=false)
Output gradient.
SetTextSpotColor($name, $tint=100)
Defines the spot color used for text.
const K_CELL_HEIGHT_RATIO
Height of cell respect font height.
addHTMLTOC($page='', $toc_name='TOC', $templates=array(), $correct_align=true, $style='', $color=array(0, 0, 0))
Output a Table Of Content Index (TOC) using HTML templates.
getSpaceString()
Returns the string used to find spaces.
_putdests()
Insert Named Destinations.
_newobj()
Begin a new object and return the object number.
static fileGetContents($file)
Reads entire file into a string.
GetAbsX()
Returns the absolute X value of current position.
static get_mqr()
Gets the current active configuration setting of magic_quotes_runtime (if the get_magic_quotes_runtim...
endPage($tocpage=false)
Terminate the current page.
setPrintHeader($val=true)
Set a flag to print page header.
SVGTransform($tm)
Apply SVG graphic transformation matrix.
$fgcolor
Current foreground color.
getFontBuffer($font)
Get font buffer content.
$theadMargins
Margins used for table header.
deletePage($page)
Remove the specified page.
$FontSizePt
Current font size in points.
$svgdir
Directory used for the last SVG image.
setImageSubBuffer($image, $key, $data)
Set image buffer content for a specified sub-key.
getFontFamilyName($fontfamily)
Return normalized font name.
SetAbsY($y)
Set the absolute Y coordinate of the current pointer.
getCSSFontSpacing($spacing, $parent=0)
Returns the letter-spacing value from CSS value.
setContentMark($page=0)
Set start-writing mark on selected page.
_puttruetypeunicode($font)
Adds unicode fonts.
static getAnnotOptFromJSProp($prop, &$spot_colors, $rtl=false)
Convert JavaScript form fields properties array to Annotation Properties array.
_putannotsobjs()
Output annotations objects for all pages.
setFontBuffer($font, $data)
Set font buffer content.
$svggradientid
ID of last SVG gradient.
SetTitle($title)
Defines the title of the document.
setLanguageArray($language)
Set language array.
getOverprint()
Get the overprint mode array (OP, op, OPM).
$fwPt
Width of page format in points.
getImageRBX()
Return the right-bottom (or left-bottom for RTL) corner X coordinate of last inserted image...