144 require_once(dirname(__FILE__).
'/config/tcpdf_config.php');
149 define(
'PDF_PRODUCER',
'TCPDF 5.9.009 (http://www.tcpdf.org)');
297 protected $cell_margin = array(
'T' => 0,
'R' => 0,
'B' => 0,
'L' => 0);
786 protected $enc_padding =
"\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A";
1349 protected $default_form_prop = array(
'lineWidth'=>1,
'borderStyle'=>
'solid',
'fillColor'=>array(255, 255, 255),
'strokeColor'=>array(128, 128, 128));
1664 protected $svginheritprop = array(
'clip-rule',
'color',
'color-interpolation',
'color-interpolation-filters',
'color-profile',
'color-rendering',
'cursor',
'direction',
'fill',
'fill-opacity',
'fill-rule',
'font',
'font-family',
'font-size',
'font-size-adjust',
'font-stretch',
'font-style',
'font-variant',
'font-weight',
'glyph-orientation-horizontal',
'glyph-orientation-vertical',
'image-rendering',
'kerning',
'letter-spacing',
'marker',
'marker-end',
'marker-mid',
'marker-start',
'pointer-events',
'shape-rendering',
'stroke',
'stroke-dasharray',
'stroke-dashoffset',
'stroke-linecap',
'stroke-linejoin',
'stroke-miterlimit',
'stroke-opacity',
'stroke-width',
'text-anchor',
'text-rendering',
'visibility',
'word-spacing',
'writing-mode');
1672 'alignment-baseline' =>
'auto',
1673 'baseline-shift' =>
'baseline',
1675 'clip-path' =>
'none',
1676 'clip-rule' =>
'nonzero',
1678 'color-interpolation' =>
'sRGB',
1679 'color-interpolation-filters' =>
'linearRGB',
1680 'color-profile' =>
'auto',
1681 'color-rendering' =>
'auto',
1683 'direction' =>
'ltr',
1684 'display' =>
'inline',
1685 'dominant-baseline' =>
'auto',
1686 'enable-background' =>
'accumulate',
1688 'fill-opacity' => 1,
1689 'fill-rule' =>
'nonzero',
1691 'flood-color' =>
'black',
1692 'flood-opacity' => 1,
1694 'font-family' =>
'helvetica',
1695 'font-size' =>
'medium',
1696 'font-size-adjust' =>
'none',
1697 'font-stretch' =>
'normal',
1698 'font-style' =>
'normal',
1699 'font-variant' =>
'normal',
1700 'font-weight' =>
'normal',
1701 'glyph-orientation-horizontal' =>
'0deg',
1702 'glyph-orientation-vertical' =>
'auto',
1703 'image-rendering' =>
'auto',
1704 'kerning' =>
'auto',
1705 'letter-spacing' =>
'normal',
1706 'lighting-color' =>
'white',
1708 'marker-end' =>
'none',
1709 'marker-mid' =>
'none',
1710 'marker-start' =>
'none',
1713 'overflow' =>
'auto',
1714 'pointer-events' =>
'visiblePainted',
1715 'shape-rendering' =>
'auto',
1716 'stop-color' =>
'black',
1717 'stop-opacity' => 1,
1719 'stroke-dasharray' =>
'none',
1720 'stroke-dashoffset' => 0,
1721 'stroke-linecap' =>
'butt',
1722 'stroke-linejoin' =>
'miter',
1723 'stroke-miterlimit' => 4,
1724 'stroke-opacity' => 1,
1725 'stroke-width' => 1,
1726 'text-anchor' =>
'start',
1727 'text-decoration' =>
'none',
1728 'text-rendering' =>
'auto',
1729 'unicode-bidi' =>
'normal',
1730 'visibility' =>
'visible',
1731 'word-spacing' =>
'normal',
1732 'writing-mode' =>
'lr-tb',
1733 'text-color' =>
'black',
1734 'transfmatrix' => array(1, 0, 0, 1, 0, 0)
1755 if (function_exists(
'mb_internal_encoding') AND mb_internal_encoding()) {
1756 $this->internal_encoding = mb_internal_encoding();
1757 mb_internal_encoding(
'ASCII');
1759 require(dirname(__FILE__).
'/htmlcolors.php');
1761 require_once(dirname(__FILE__).
'/unicode_data.php');
1763 $this->font_obj_ids = array();
1764 $this->page_obj_id = array();
1765 $this->form_obj_id = array();
1767 $this->diskcache =
$diskcache ?
true :
false;
1770 $this->tmprtl =
false;
1776 $this->transfmrk[0] = array();
1777 $this->pagedim = array();
1780 $this->pages = array();
1782 $this->fonts = array();
1783 $this->FontFiles = array();
1784 $this->diffs = array();
1785 $this->images = array();
1786 $this->links = array();
1787 $this->gradients = array();
1788 $this->InFooter =
false;
1790 $this->FontFamily =
'helvetica';
1791 $this->FontStyle =
'';
1792 $this->FontSizePt = 12;
1793 $this->underline =
false;
1794 $this->overline =
false;
1795 $this->linethrough =
false;
1796 $this->DrawColor =
'0 G';
1797 $this->FillColor =
'0 g';
1798 $this->TextColor =
'0 g';
1799 $this->ColorFlag =
false;
1801 $this->encrypted =
false;
1802 $this->last_enc_key =
'';
1804 $this->CoreFonts = array(
1805 'courier'=>
'Courier',
1806 'courierB'=>
'Courier-Bold',
1807 'courierI'=>
'Courier-Oblique',
1808 'courierBI'=>
'Courier-BoldOblique',
1809 'helvetica'=>
'Helvetica',
1810 'helveticaB'=>
'Helvetica-Bold',
1811 'helveticaI'=>
'Helvetica-Oblique',
1812 'helveticaBI'=>
'Helvetica-BoldOblique',
1813 'times'=>
'Times-Roman',
1814 'timesB'=>
'Times-Bold',
1815 'timesI'=>
'Times-Italic',
1816 'timesBI'=>
'Times-BoldItalic',
1818 'zapfdingbats'=>
'ZapfDingbats'
1828 $cpadding = $margin / 10;
1833 $this->LineWidth = 0.57 /
$this->k;
1834 $this->linestyleWidth = sprintf(
'%.2F w', ($this->LineWidth * $this->k));
1835 $this->linestyleCap =
'0 J';
1836 $this->linestyleJoin =
'0 j';
1837 $this->linestyleDash =
'[] 0 d';
1845 $this->PDFVersion =
'1.7';
1847 $this->HREF = array();
1849 $this->fgcolor = array(
'R' => 0,
'G' => 0,
'B' => 0);
1850 $this->strokecolor = array(
'R' => 0,
'G' => 0,
'B' => 0);
1851 $this->bgcolor = array(
'R' => 255,
'G' => 255,
'B' => 255);
1852 $this->extgstates = array();
1854 $this->sign =
false;
1855 $this->ur[
'enabled'] =
false;
1856 $this->ur[
'document'] =
'/FullSave';
1857 $this->ur[
'annots'] =
'/Create/Delete/Modify/Copy/Import/Export';
1858 $this->ur[
'form'] =
'/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate';
1859 $this->ur[
'signature'] =
'/Modify';
1860 $this->ur[
'ef'] =
'/Create/Delete/Modify/Import';
1861 $this->ur[
'formex'] =
'';
1862 $this->signature_appearance = array(
'page' => 1,
'rect' =>
'0 0 0 0');
1864 $this->jpeg_quality = 75;
1868 $this->
SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
1870 if ($this->isunicode AND (@preg_match(
'/\pL/u',
'a') == 1)) {
1881 $this->default_form_prop = array(
'lineWidth'=>1,
'borderStyle'=>
'solid',
'fillColor'=>array(255, 255, 255),
'strokeColor'=>array(128, 128, 128));
1883 $this->file_id = md5($this->
getRandomSeed(
'TCPDF'.$orientation.$unit.$format.$encoding));
1895 if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
1896 mb_internal_encoding($this->internal_encoding);
1909 $unit = strtolower($unit);
1920 $this->k = $this->dpi / 25.4;
1925 $this->k = $this->dpi / 2.54;
1935 $this->
Error(
'Incorrect unit: '.$unit);
1939 $this->pdfunit = $unit;
1940 if (isset($this->CurOrientation)) {
2261 switch (strtoupper($format)) {
2263 case 'A0' : {$pf = array( 2383.937, 3370.394);
break;}
2264 case 'A1' : {$pf = array( 1683.780, 2383.937);
break;}
2265 case 'A2' : {$pf = array( 1190.551, 1683.780);
break;}
2266 case 'A3' : {$pf = array( 841.890, 1190.551);
break;}
2267 case 'A4' : {$pf = array( 595.276, 841.890);
break;}
2268 case 'A5' : {$pf = array( 419.528, 595.276);
break;}
2269 case 'A6' : {$pf = array( 297.638, 419.528);
break;}
2270 case 'A7' : {$pf = array( 209.764, 297.638);
break;}
2271 case 'A8' : {$pf = array( 147.402, 209.764);
break;}
2272 case 'A9' : {$pf = array( 104.882, 147.402);
break;}
2273 case 'A10': {$pf = array( 73.701, 104.882);
break;}
2274 case 'A11': {$pf = array( 51.024, 73.701);
break;}
2275 case 'A12': {$pf = array( 36.850, 51.024);
break;}
2277 case 'B0' : {$pf = array( 2834.646, 4008.189);
break;}
2278 case 'B1' : {$pf = array( 2004.094, 2834.646);
break;}
2279 case 'B2' : {$pf = array( 1417.323, 2004.094);
break;}
2280 case 'B3' : {$pf = array( 1000.630, 1417.323);
break;}
2281 case 'B4' : {$pf = array( 708.661, 1000.630);
break;}
2282 case 'B5' : {$pf = array( 498.898, 708.661);
break;}
2283 case 'B6' : {$pf = array( 354.331, 498.898);
break;}
2284 case 'B7' : {$pf = array( 249.449, 354.331);
break;}
2285 case 'B8' : {$pf = array( 175.748, 249.449);
break;}
2286 case 'B9' : {$pf = array( 124.724, 175.748);
break;}
2287 case 'B10': {$pf = array( 87.874, 124.724);
break;}
2288 case 'B11': {$pf = array( 62.362, 87.874);
break;}
2289 case 'B12': {$pf = array( 42.520, 62.362);
break;}
2291 case 'C0' : {$pf = array( 2599.370, 3676.535);
break;}
2292 case 'C1' : {$pf = array( 1836.850, 2599.370);
break;}
2293 case 'C2' : {$pf = array( 1298.268, 1836.850);
break;}
2294 case 'C3' : {$pf = array( 918.425, 1298.268);
break;}
2295 case 'C4' : {$pf = array( 649.134, 918.425);
break;}
2296 case 'C5' : {$pf = array( 459.213, 649.134);
break;}
2297 case 'C6' : {$pf = array( 323.150, 459.213);
break;}
2298 case 'C7' : {$pf = array( 229.606, 323.150);
break;}
2299 case 'C8' : {$pf = array( 161.575, 229.606);
break;}
2300 case 'C9' : {$pf = array( 113.386, 161.575);
break;}
2301 case 'C10': {$pf = array( 79.370, 113.386);
break;}
2302 case 'C11': {$pf = array( 56.693, 79.370);
break;}
2303 case 'C12': {$pf = array( 39.685, 56.693);
break;}
2304 case 'C76': {$pf = array( 229.606, 459.213);
break;}
2305 case 'DL' : {$pf = array( 311.811, 623.622);
break;}
2307 case 'E0' : {$pf = array( 2491.654, 3517.795);
break;}
2308 case 'E1' : {$pf = array( 1757.480, 2491.654);
break;}
2309 case 'E2' : {$pf = array( 1247.244, 1757.480);
break;}
2310 case 'E3' : {$pf = array( 878.740, 1247.244);
break;}
2311 case 'E4' : {$pf = array( 623.622, 878.740);
break;}
2312 case 'E5' : {$pf = array( 439.370, 623.622);
break;}
2313 case 'E6' : {$pf = array( 311.811, 439.370);
break;}
2314 case 'E7' : {$pf = array( 221.102, 311.811);
break;}
2315 case 'E8' : {$pf = array( 155.906, 221.102);
break;}
2316 case 'E9' : {$pf = array( 110.551, 155.906);
break;}
2317 case 'E10': {$pf = array( 76.535, 110.551);
break;}
2318 case 'E11': {$pf = array( 53.858, 76.535);
break;}
2319 case 'E12': {$pf = array( 36.850, 53.858);
break;}
2321 case 'G0' : {$pf = array( 2715.591, 3838.110);
break;}
2322 case 'G1' : {$pf = array( 1919.055, 2715.591);
break;}
2323 case 'G2' : {$pf = array( 1357.795, 1919.055);
break;}
2324 case 'G3' : {$pf = array( 958.110, 1357.795);
break;}
2325 case 'G4' : {$pf = array( 677.480, 958.110);
break;}
2326 case 'G5' : {$pf = array( 479.055, 677.480);
break;}
2327 case 'G6' : {$pf = array( 337.323, 479.055);
break;}
2328 case 'G7' : {$pf = array( 238.110, 337.323);
break;}
2329 case 'G8' : {$pf = array( 167.244, 238.110);
break;}
2330 case 'G9' : {$pf = array( 119.055, 167.244);
break;}
2331 case 'G10': {$pf = array( 82.205, 119.055);
break;}
2332 case 'G11': {$pf = array( 59.528, 82.205);
break;}
2333 case 'G12': {$pf = array( 39.685, 59.528);
break;}
2335 case 'RA0': {$pf = array( 2437.795, 3458.268);
break;}
2336 case 'RA1': {$pf = array( 1729.134, 2437.795);
break;}
2337 case 'RA2': {$pf = array( 1218.898, 1729.134);
break;}
2338 case 'RA3': {$pf = array( 864.567, 1218.898);
break;}
2339 case 'RA4': {$pf = array( 609.449, 864.567);
break;}
2340 case 'SRA0': {$pf = array( 2551.181, 3628.346);
break;}
2341 case 'SRA1': {$pf = array( 1814.173, 2551.181);
break;}
2342 case 'SRA2': {$pf = array( 1275.591, 1814.173);
break;}
2343 case 'SRA3': {$pf = array( 907.087, 1275.591);
break;}
2344 case 'SRA4': {$pf = array( 637.795, 907.087);
break;}
2346 case '4A0': {$pf = array( 4767.874, 6740.787);
break;}
2347 case '2A0': {$pf = array( 3370.394, 4767.874);
break;}
2349 case 'A2_EXTRA' : {$pf = array( 1261.417, 1754.646);
break;}
2350 case 'A3+' : {$pf = array( 932.598, 1369.134);
break;}
2351 case 'A3_EXTRA' : {$pf = array( 912.756, 1261.417);
break;}
2352 case 'A3_SUPER' : {$pf = array( 864.567, 1440.000);
break;}
2353 case 'SUPER_A3' : {$pf = array( 864.567, 1380.472);
break;}
2354 case 'A4_EXTRA' : {$pf = array( 666.142, 912.756);
break;}
2355 case 'A4_SUPER' : {$pf = array( 649.134, 912.756);
break;}
2356 case 'SUPER_A4' : {$pf = array( 643.465, 1009.134);
break;}
2357 case 'A4_LONG' : {$pf = array( 595.276, 986.457);
break;}
2358 case 'F4' : {$pf = array( 595.276, 935.433);
break;}
2359 case 'SO_B5_EXTRA': {$pf = array( 572.598, 782.362);
break;}
2360 case 'A5_EXTRA' : {$pf = array( 490.394, 666.142);
break;}
2362 case 'ANSI_E': {$pf = array( 2448.000, 3168.000);
break;}
2363 case 'ANSI_D': {$pf = array( 1584.000, 2448.000);
break;}
2364 case 'ANSI_C': {$pf = array( 1224.000, 1584.000);
break;}
2365 case 'ANSI_B': {$pf = array( 792.000, 1224.000);
break;}
2366 case 'ANSI_A': {$pf = array( 612.000, 792.000);
break;}
2369 case 'LEDGER' : {$pf = array( 1224.000, 792.000);
break;}
2373 case 'TABLOID': {$pf = array( 792.000, 1224.000);
break;}
2376 case 'LETTER' : {$pf = array( 612.000, 792.000);
break;}
2378 case 'LEGAL' : {$pf = array( 612.000, 1008.000);
break;}
2379 case 'GOVERNMENTLETTER':
2380 case 'GLETTER': {$pf = array( 576.000, 756.000);
break;}
2382 case 'JLEGAL' : {$pf = array( 576.000, 360.000);
break;}
2384 case 'QUADDEMY': {$pf = array( 2520.000, 3240.000);
break;}
2385 case 'SUPER_B': {$pf = array( 936.000, 1368.000);
break;}
2386 case 'QUARTO': {$pf = array( 648.000, 792.000);
break;}
2387 case 'GOVERNMENTLEGAL':
2388 case 'FOLIO': {$pf = array( 612.000, 936.000);
break;}
2390 case 'EXECUTIVE': {$pf = array( 522.000, 756.000);
break;}
2393 case 'MEMO': {$pf = array( 396.000, 612.000);
break;}
2394 case 'FOOLSCAP': {$pf = array( 595.440, 936.000);
break;}
2395 case 'COMPACT': {$pf = array( 306.000, 486.000);
break;}
2396 case 'ORGANIZERJ': {$pf = array( 198.000, 360.000);
break;}
2398 case 'P1': {$pf = array( 1587.402, 2437.795);
break;}
2399 case 'P2': {$pf = array( 1218.898, 1587.402);
break;}
2400 case 'P3': {$pf = array( 793.701, 1218.898);
break;}
2401 case 'P4': {$pf = array( 609.449, 793.701);
break;}
2402 case 'P5': {$pf = array( 396.850, 609.449);
break;}
2403 case 'P6': {$pf = array( 303.307, 396.850);
break;}
2405 case 'ARCH_E' : {$pf = array( 2592.000, 3456.000);
break;}
2406 case 'ARCH_E1': {$pf = array( 2160.000, 3024.000);
break;}
2407 case 'ARCH_D' : {$pf = array( 1728.000, 2592.000);
break;}
2409 case 'ARCH_C' : {$pf = array( 1296.000, 1728.000);
break;}
2410 case 'ARCH_B' : {$pf = array( 864.000, 1296.000);
break;}
2411 case 'ARCH_A' : {$pf = array( 648.000, 864.000);
break;}
2414 case 'ANNENV_A2' : {$pf = array( 314.640, 414.000);
break;}
2415 case 'ANNENV_A6' : {$pf = array( 342.000, 468.000);
break;}
2416 case 'ANNENV_A7' : {$pf = array( 378.000, 522.000);
break;}
2417 case 'ANNENV_A8' : {$pf = array( 396.000, 584.640);
break;}
2418 case 'ANNENV_A10' : {$pf = array( 450.000, 692.640);
break;}
2419 case 'ANNENV_SLIM': {$pf = array( 278.640, 638.640);
break;}
2421 case 'COMMENV_N6_1/4': {$pf = array( 252.000, 432.000);
break;}
2422 case 'COMMENV_N6_3/4': {$pf = array( 260.640, 468.000);
break;}
2423 case 'COMMENV_N8' : {$pf = array( 278.640, 540.000);
break;}
2424 case 'COMMENV_N9' : {$pf = array( 278.640, 638.640);
break;}
2425 case 'COMMENV_N10' : {$pf = array( 296.640, 684.000);
break;}
2426 case 'COMMENV_N11' : {$pf = array( 324.000, 746.640);
break;}
2427 case 'COMMENV_N12' : {$pf = array( 342.000, 792.000);
break;}
2428 case 'COMMENV_N14' : {$pf = array( 360.000, 828.000);
break;}
2430 case 'CATENV_N1' : {$pf = array( 432.000, 648.000);
break;}
2431 case 'CATENV_N1_3/4' : {$pf = array( 468.000, 684.000);
break;}
2432 case 'CATENV_N2' : {$pf = array( 468.000, 720.000);
break;}
2433 case 'CATENV_N3' : {$pf = array( 504.000, 720.000);
break;}
2434 case 'CATENV_N6' : {$pf = array( 540.000, 756.000);
break;}
2435 case 'CATENV_N7' : {$pf = array( 576.000, 792.000);
break;}
2436 case 'CATENV_N8' : {$pf = array( 594.000, 810.000);
break;}
2437 case 'CATENV_N9_1/2' : {$pf = array( 612.000, 756.000);
break;}
2438 case 'CATENV_N9_3/4' : {$pf = array( 630.000, 810.000);
break;}
2439 case 'CATENV_N10_1/2': {$pf = array( 648.000, 864.000);
break;}
2440 case 'CATENV_N12_1/2': {$pf = array( 684.000, 900.000);
break;}
2441 case 'CATENV_N13_1/2': {$pf = array( 720.000, 936.000);
break;}
2442 case 'CATENV_N14_1/4': {$pf = array( 810.000, 882.000);
break;}
2443 case 'CATENV_N14_1/2': {$pf = array( 828.000, 1044.000);
break;}
2445 case 'JIS_B0' : {$pf = array( 2919.685, 4127.244);
break;}
2446 case 'JIS_B1' : {$pf = array( 2063.622, 2919.685);
break;}
2447 case 'JIS_B2' : {$pf = array( 1459.843, 2063.622);
break;}
2448 case 'JIS_B3' : {$pf = array( 1031.811, 1459.843);
break;}
2449 case 'JIS_B4' : {$pf = array( 728.504, 1031.811);
break;}
2450 case 'JIS_B5' : {$pf = array( 515.906, 728.504);
break;}
2451 case 'JIS_B6' : {$pf = array( 362.835, 515.906);
break;}
2452 case 'JIS_B7' : {$pf = array( 257.953, 362.835);
break;}
2453 case 'JIS_B8' : {$pf = array( 181.417, 257.953);
break;}
2454 case 'JIS_B9' : {$pf = array( 127.559, 181.417);
break;}
2455 case 'JIS_B10': {$pf = array( 90.709, 127.559);
break;}
2456 case 'JIS_B11': {$pf = array( 62.362, 90.709);
break;}
2457 case 'JIS_B12': {$pf = array( 45.354, 62.362);
break;}
2459 case 'PA0' : {$pf = array( 2381.102, 3174.803,);
break;}
2460 case 'PA1' : {$pf = array( 1587.402, 2381.102);
break;}
2461 case 'PA2' : {$pf = array( 1190.551, 1587.402);
break;}
2462 case 'PA3' : {$pf = array( 793.701, 1190.551);
break;}
2463 case 'PA4' : {$pf = array( 595.276, 793.701);
break;}
2464 case 'PA5' : {$pf = array( 396.850, 595.276);
break;}
2465 case 'PA6' : {$pf = array( 297.638, 396.850);
break;}
2466 case 'PA7' : {$pf = array( 198.425, 297.638);
break;}
2467 case 'PA8' : {$pf = array( 147.402, 198.425);
break;}
2468 case 'PA9' : {$pf = array( 99.213, 147.402);
break;}
2469 case 'PA10': {$pf = array( 73.701, 99.213);
break;}
2471 case 'PASSPORT_PHOTO': {$pf = array( 99.213, 127.559);
break;}
2472 case 'E' : {$pf = array( 233.858, 340.157);
break;}
2474 case '3R' : {$pf = array( 252.283, 360.000);
break;}
2476 case '4R' : {$pf = array( 289.134, 430.866);
break;}
2477 case '4D' : {$pf = array( 340.157, 430.866);
break;}
2479 case '5R' : {$pf = array( 360.000, 504.567);
break;}
2481 case '6R' : {$pf = array( 430.866, 575.433);
break;}
2483 case '8R' : {$pf = array( 575.433, 720.000);
break;}
2485 case 'S8R' : {$pf = array( 575.433, 864.567);
break;}
2487 case '10R' : {$pf = array( 720.000, 864.567);
break;}
2489 case 'S10R': {$pf = array( 720.000, 1080.000);
break;}
2490 case '11R' : {$pf = array( 790.866, 1009.134);
break;}
2491 case 'S11R': {$pf = array( 790.866, 1224.567);
break;}
2492 case '12R' : {$pf = array( 864.567, 1080.000);
break;}
2493 case 'S12R': {$pf = array( 864.567, 1292.598);
break;}
2495 case 'NEWSPAPER_BROADSHEET': {$pf = array( 2125.984, 1700.787);
break;}
2496 case 'NEWSPAPER_BERLINER' : {$pf = array( 1332.283, 892.913);
break;}
2497 case 'NEWSPAPER_TABLOID':
2498 case 'NEWSPAPER_COMPACT' : {$pf = array( 1218.898, 793.701);
break;}
2501 case 'BUSINESS_CARD':
2502 case 'BUSINESS_CARD_ISO7810': {$pf = array( 153.014, 242.646);
break;}
2503 case 'BUSINESS_CARD_ISO216' : {$pf = array( 147.402, 209.764);
break;}
2504 case 'BUSINESS_CARD_IT':
2505 case 'BUSINESS_CARD_UK':
2506 case 'BUSINESS_CARD_FR':
2507 case 'BUSINESS_CARD_DE':
2508 case 'BUSINESS_CARD_ES' : {$pf = array( 155.906, 240.945);
break;}
2509 case 'BUSINESS_CARD_CA':
2510 case 'BUSINESS_CARD_US' : {$pf = array( 144.567, 252.283);
break;}
2511 case 'BUSINESS_CARD_JP' : {$pf = array( 155.906, 257.953);
break;}
2512 case 'BUSINESS_CARD_HK' : {$pf = array( 153.071, 255.118);
break;}
2513 case 'BUSINESS_CARD_AU':
2514 case 'BUSINESS_CARD_DK':
2515 case 'BUSINESS_CARD_SE' : {$pf = array( 155.906, 255.118);
break;}
2516 case 'BUSINESS_CARD_RU':
2517 case 'BUSINESS_CARD_CZ':
2518 case 'BUSINESS_CARD_FI':
2519 case 'BUSINESS_CARD_HU':
2520 case 'BUSINESS_CARD_IL' : {$pf = array( 141.732, 255.118);
break;}
2522 case '4SHEET' : {$pf = array( 2880.000, 4320.000);
break;}
2523 case '6SHEET' : {$pf = array( 3401.575, 5102.362);
break;}
2524 case '12SHEET': {$pf = array( 8640.000, 4320.000);
break;}
2525 case '16SHEET': {$pf = array( 5760.000, 8640.000);
break;}
2526 case '32SHEET': {$pf = array(11520.000, 8640.000);
break;}
2527 case '48SHEET': {$pf = array(17280.000, 8640.000);
break;}
2528 case '64SHEET': {$pf = array(23040.000, 8640.000);
break;}
2529 case '96SHEET': {$pf = array(34560.000, 8640.000);
break;}
2532 case 'EN_EMPEROR' : {$pf = array( 3456.000, 5184.000);
break;}
2533 case 'EN_ANTIQUARIAN' : {$pf = array( 2232.000, 3816.000);
break;}
2534 case 'EN_GRAND_EAGLE' : {$pf = array( 2070.000, 3024.000);
break;}
2535 case 'EN_DOUBLE_ELEPHANT' : {$pf = array( 1926.000, 2880.000);
break;}
2536 case 'EN_ATLAS' : {$pf = array( 1872.000, 2448.000);
break;}
2537 case 'EN_COLOMBIER' : {$pf = array( 1692.000, 2484.000);
break;}
2538 case 'EN_ELEPHANT' : {$pf = array( 1656.000, 2016.000);
break;}
2539 case 'EN_DOUBLE_DEMY' : {$pf = array( 1620.000, 2556.000);
break;}
2540 case 'EN_IMPERIAL' : {$pf = array( 1584.000, 2160.000);
break;}
2541 case 'EN_PRINCESS' : {$pf = array( 1548.000, 2016.000);
break;}
2542 case 'EN_CARTRIDGE' : {$pf = array( 1512.000, 1872.000);
break;}
2543 case 'EN_DOUBLE_LARGE_POST': {$pf = array( 1512.000, 2376.000);
break;}
2544 case 'EN_ROYAL' : {$pf = array( 1440.000, 1800.000);
break;}
2546 case 'EN_HALF_POST' : {$pf = array( 1404.000, 1692.000);
break;}
2547 case 'EN_SUPER_ROYAL' : {$pf = array( 1368.000, 1944.000);
break;}
2548 case 'EN_DOUBLE_POST' : {$pf = array( 1368.000, 2196.000);
break;}
2549 case 'EN_MEDIUM' : {$pf = array( 1260.000, 1656.000);
break;}
2550 case 'EN_DEMY' : {$pf = array( 1260.000, 1620.000);
break;}
2551 case 'EN_LARGE_POST' : {$pf = array( 1188.000, 1512.000);
break;}
2552 case 'EN_COPY_DRAUGHT' : {$pf = array( 1152.000, 1440.000);
break;}
2553 case 'EN_POST' : {$pf = array( 1116.000, 1386.000);
break;}
2554 case 'EN_CROWN' : {$pf = array( 1080.000, 1440.000);
break;}
2555 case 'EN_PINCHED_POST' : {$pf = array( 1062.000, 1332.000);
break;}
2556 case 'EN_BRIEF' : {$pf = array( 972.000, 1152.000);
break;}
2557 case 'EN_FOOLSCAP' : {$pf = array( 972.000, 1224.000);
break;}
2558 case 'EN_SMALL_FOOLSCAP' : {$pf = array( 954.000, 1188.000);
break;}
2559 case 'EN_POTT' : {$pf = array( 900.000, 1080.000);
break;}
2561 case 'BE_GRAND_AIGLE' : {$pf = array( 1984.252, 2948.031);
break;}
2562 case 'BE_COLOMBIER' : {$pf = array( 1757.480, 2409.449);
break;}
2563 case 'BE_DOUBLE_CARRE': {$pf = array( 1757.480, 2607.874);
break;}
2564 case 'BE_ELEPHANT' : {$pf = array( 1746.142, 2182.677);
break;}
2565 case 'BE_PETIT_AIGLE' : {$pf = array( 1700.787, 2381.102);
break;}
2566 case 'BE_GRAND_JESUS' : {$pf = array( 1559.055, 2069.291);
break;}
2567 case 'BE_JESUS' : {$pf = array( 1530.709, 2069.291);
break;}
2568 case 'BE_RAISIN' : {$pf = array( 1417.323, 1842.520);
break;}
2569 case 'BE_GRAND_MEDIAN': {$pf = array( 1303.937, 1714.961);
break;}
2570 case 'BE_DOUBLE_POSTE': {$pf = array( 1233.071, 1601.575);
break;}
2571 case 'BE_COQUILLE' : {$pf = array( 1218.898, 1587.402);
break;}
2572 case 'BE_PETIT_MEDIAN': {$pf = array( 1176.378, 1502.362);
break;}
2573 case 'BE_RUCHE' : {$pf = array( 1020.472, 1303.937);
break;}
2574 case 'BE_PROPATRIA' : {$pf = array( 977.953, 1218.898);
break;}
2575 case 'BE_LYS' : {$pf = array( 898.583, 1125.354);
break;}
2576 case 'BE_POT' : {$pf = array( 870.236, 1088.504);
break;}
2577 case 'BE_ROSETTE' : {$pf = array( 765.354, 983.622);
break;}
2579 case 'FR_UNIVERS' : {$pf = array( 2834.646, 3685.039);
break;}
2580 case 'FR_DOUBLE_COLOMBIER' : {$pf = array( 2551.181, 3571.654);
break;}
2581 case 'FR_GRANDE_MONDE' : {$pf = array( 2551.181, 3571.654);
break;}
2582 case 'FR_DOUBLE_SOLEIL' : {$pf = array( 2267.717, 3401.575);
break;}
2583 case 'FR_DOUBLE_JESUS' : {$pf = array( 2154.331, 3174.803);
break;}
2584 case 'FR_GRAND_AIGLE' : {$pf = array( 2125.984, 3004.724);
break;}
2585 case 'FR_PETIT_AIGLE' : {$pf = array( 1984.252, 2664.567);
break;}
2586 case 'FR_DOUBLE_RAISIN' : {$pf = array( 1842.520, 2834.646);
break;}
2587 case 'FR_JOURNAL' : {$pf = array( 1842.520, 2664.567);
break;}
2588 case 'FR_COLOMBIER_AFFICHE': {$pf = array( 1785.827, 2551.181);
break;}
2589 case 'FR_DOUBLE_CAVALIER' : {$pf = array( 1757.480, 2607.874);
break;}
2590 case 'FR_CLOCHE' : {$pf = array( 1700.787, 2267.717);
break;}
2591 case 'FR_SOLEIL' : {$pf = array( 1700.787, 2267.717);
break;}
2592 case 'FR_DOUBLE_CARRE' : {$pf = array( 1587.402, 2551.181);
break;}
2593 case 'FR_DOUBLE_COQUILLE' : {$pf = array( 1587.402, 2494.488);
break;}
2594 case 'FR_JESUS' : {$pf = array( 1587.402, 2154.331);
break;}
2595 case 'FR_RAISIN' : {$pf = array( 1417.323, 1842.520);
break;}
2596 case 'FR_CAVALIER' : {$pf = array( 1303.937, 1757.480);
break;}
2597 case 'FR_DOUBLE_COURONNE' : {$pf = array( 1303.937, 2040.945);
break;}
2598 case 'FR_CARRE' : {$pf = array( 1275.591, 1587.402);
break;}
2599 case 'FR_COQUILLE' : {$pf = array( 1247.244, 1587.402);
break;}
2600 case 'FR_DOUBLE_TELLIERE' : {$pf = array( 1247.244, 1927.559);
break;}
2601 case 'FR_DOUBLE_CLOCHE' : {$pf = array( 1133.858, 1700.787);
break;}
2602 case 'FR_DOUBLE_POT' : {$pf = array( 1133.858, 1757.480);
break;}
2603 case 'FR_ECU' : {$pf = array( 1133.858, 1474.016);
break;}
2604 case 'FR_COURONNE' : {$pf = array( 1020.472, 1303.937);
break;}
2605 case 'FR_TELLIERE' : {$pf = array( 963.780, 1247.244);
break;}
2606 case 'FR_POT' : {$pf = array( 878.740, 1133.858);
break;}
2608 default: {$pf = array( 595.276, 841.890);
break;}
2669 if (!empty($format) AND isset($this->pagedim[$this->page])) {
2671 unset($this->pagedim[$this->page]);
2673 if (is_string($format)) {
2676 $this->fwPt = $pf[0];
2677 $this->fhPt = $pf[1];
2680 if (isset($format[
'MediaBox'])) {
2681 $this->
setPageBoxes($this->page,
'MediaBox', $format[
'MediaBox'][
'llx'], $format[
'MediaBox'][
'lly'], $format[
'MediaBox'][
'urx'], $format[
'MediaBox'][
'ury'],
false);
2682 $this->fwPt = (($format[
'MediaBox'][
'urx'] - $format[
'MediaBox'][
'llx']) * $this->k);
2683 $this->fhPt = (($format[
'MediaBox'][
'ury'] - $format[
'MediaBox'][
'lly']) * $this->k);
2685 if (isset($format[0]) AND is_numeric($format[0]) AND isset($format[1]) AND is_numeric($format[1])) {
2686 $pf = array(($format[0] * $this->k), ($format[1] * $this->k));
2688 if (!isset($format[
'format'])) {
2690 $format[
'format'] =
'A4';
2694 $this->fwPt = $pf[0];
2695 $this->fhPt = $pf[1];
2696 $this->
setPageBoxes($this->page,
'MediaBox', 0, 0, $this->fwPt, $this->fhPt,
true);
2699 if (isset($format[
'CropBox'])) {
2700 $this->
setPageBoxes($this->page,
'CropBox', $format[
'CropBox'][
'llx'], $format[
'CropBox'][
'lly'], $format[
'CropBox'][
'urx'], $format[
'CropBox'][
'ury'],
false);
2703 if (isset($format[
'BleedBox'])) {
2704 $this->
setPageBoxes($this->page,
'BleedBox', $format[
'BleedBox'][
'llx'], $format[
'BleedBox'][
'lly'], $format[
'BleedBox'][
'urx'], $format[
'BleedBox'][
'ury'],
false);
2707 if (isset($format[
'TrimBox'])) {
2708 $this->
setPageBoxes($this->page,
'TrimBox', $format[
'TrimBox'][
'llx'], $format[
'TrimBox'][
'lly'], $format[
'TrimBox'][
'urx'], $format[
'TrimBox'][
'ury'],
false);
2711 if (isset($format[
'ArtBox'])) {
2712 $this->
setPageBoxes($this->page,
'ArtBox', $format[
'ArtBox'][
'llx'], $format[
'ArtBox'][
'lly'], $format[
'ArtBox'][
'urx'], $format[
'ArtBox'][
'ury'],
false);
2715 if (isset($format[
'BoxColorInfo'])) {
2716 $this->pagedim[
$this->page][
'BoxColorInfo'] = $format[
'BoxColorInfo'];
2718 if (isset($format[
'Rotate']) AND (($format[
'Rotate'] % 90) == 0)) {
2720 $this->pagedim[
$this->page][
'Rotate'] = intval($format[
'Rotate']);
2722 if (isset($format[
'PZ'])) {
2724 $this->pagedim[
$this->page][
'PZ'] = floatval($format[
'PZ']);
2726 if (isset($format[
'trans'])) {
2728 if (isset($format[
'trans'][
'Dur'])) {
2730 $this->pagedim[
$this->page][
'trans'][
'Dur'] = floatval($format[
'trans'][
'Dur']);
2732 $stansition_styles = array(
'Split',
'Blinds',
'Box',
'Wipe',
'Dissolve',
'Glitter',
'R',
'Fly',
'Push',
'Cover',
'Uncover',
'Fade');
2733 if (isset($format[
'trans'][
'S']) AND in_array($format[
'trans'][
'S'], $stansition_styles)) {
2735 $this->pagedim[
$this->page][
'trans'][
'S'] = $format[
'trans'][
'S'];
2736 $valid_effect = array(
'Split',
'Blinds');
2737 $valid_vals = array(
'H',
'V');
2738 if (isset($format[
'trans'][
'Dm']) AND in_array($format[
'trans'][
'S'], $valid_effect) AND in_array($format[
'trans'][
'Dm'], $valid_vals)) {
2739 $this->pagedim[
$this->page][
'trans'][
'Dm'] = $format[
'trans'][
'Dm'];
2741 $valid_effect = array(
'Split',
'Box',
'Fly');
2742 $valid_vals = array(
'I',
'O');
2743 if (isset($format[
'trans'][
'M']) AND in_array($format[
'trans'][
'S'], $valid_effect) AND in_array($format[
'trans'][
'M'], $valid_vals)) {
2744 $this->pagedim[
$this->page][
'trans'][
'M'] = $format[
'trans'][
'M'];
2746 $valid_effect = array(
'Wipe',
'Glitter',
'Fly',
'Cover',
'Uncover',
'Push');
2747 if (isset($format[
'trans'][
'Di']) AND in_array($format[
'trans'][
'S'], $valid_effect)) {
2748 if (((($format[
'trans'][
'Di'] == 90) OR ($format[
'trans'][
'Di'] == 180)) AND ($format[
'trans'][
'S'] ==
'Wipe'))
2749 OR (($format[
'trans'][
'Di'] == 315) AND ($format[
'trans'][
'S'] ==
'Glitter'))
2750 OR (($format[
'trans'][
'Di'] == 0) OR ($format[
'trans'][
'Di'] == 270))) {
2751 $this->pagedim[
$this->page][
'trans'][
'Di'] = intval($format[
'trans'][
'Di']);
2754 if (isset($format[
'trans'][
'SS']) AND ($format[
'trans'][
'S'] ==
'Fly')) {
2755 $this->pagedim[
$this->page][
'trans'][
'SS'] = floatval($format[
'trans'][
'SS']);
2757 if (isset($format[
'trans'][
'B']) AND ($format[
'trans'][
'B'] ===
true) AND ($format[
'trans'][
'S'] ==
'Fly')) {
2758 $this->pagedim[
$this->page][
'trans'][
'B'] =
'true';
2763 if (isset($format[
'trans'][
'D'])) {
2765 $this->pagedim[
$this->page][
'trans'][
'D'] = floatval($format[
'trans'][
'D']);
2787 if (!isset($this->pagedim[
$page])) {
2789 $this->pagedim[
$page] = array();
2791 $pageboxes = array(
'MediaBox',
'CropBox',
'BleedBox',
'TrimBox',
'ArtBox');
2792 if (!in_array(
$type, $pageboxes)) {
2813 $pageboxes = array(
'MediaBox',
'CropBox',
'BleedBox',
'TrimBox',
'ArtBox');
2814 foreach ($pageboxes as
$type) {
2816 if (isset($this->pagedim[
$page][$type])) {
2836 if (!isset($this->pagedim[$this->page][
'MediaBox'])) {
2838 $this->
setPageBoxes($this->page,
'MediaBox', 0, 0, $this->fwPt, $this->fhPt,
true);
2840 if (!isset($this->pagedim[$this->page][
'CropBox'])) {
2842 $this->
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);
2844 if (!isset($this->pagedim[$this->page][
'BleedBox'])) {
2846 $this->
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);
2848 if (!isset($this->pagedim[$this->page][
'TrimBox'])) {
2850 $this->
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);
2852 if (!isset($this->pagedim[$this->page][
'ArtBox'])) {
2854 $this->
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);
2856 if (!isset($this->pagedim[$this->page][
'Rotate'])) {
2860 if (!isset($this->pagedim[$this->page][
'PZ'])) {
2864 if ($this->fwPt > $this->fhPt) {
2866 $default_orientation =
'L';
2869 $default_orientation =
'P';
2871 $valid_orientations = array(
'P',
'L');
2872 if (empty($orientation)) {
2873 $orientation = $default_orientation;
2875 $orientation = strtoupper($orientation{0});
2877 if (in_array($orientation, $valid_orientations) AND ($orientation != $default_orientation)) {
2878 $this->CurOrientation = $orientation;
2882 $this->CurOrientation = $default_orientation;
2886 if ((abs($this->pagedim[$this->page][
'MediaBox'][
'urx'] - $this->hPt) < $this->feps) AND (abs($this->pagedim[$this->page][
'MediaBox'][
'ury'] - $this->wPt) < $this->feps)){
2893 if (isset($this->AutoPageBreak)) {
2896 $autopagebreak =
true;
2900 if (isset($this->bMargin)) {
2904 $bottommargin = 2 * 28.35 /
$this->k;
2914 $this->pagedim[
$this->page][
'bm'] = $bottommargin;
2917 $this->pagedim[
$this->page][
'pb'] = $autopagebreak;
2941 $this->re_spaces = $re;
2942 $re_parts = explode(
'/', $re);
2944 $this->re_space = array();
2945 if (isset($re_parts[1]) AND !empty($re_parts[1])) {
2946 $this->re_space[
'p'] = $re_parts[1];
2948 $this->re_space[
'p'] =
'[\s]';
2951 if (isset($re_parts[2]) AND !empty($re_parts[2])) {
2952 $this->re_space[
'm'] = $re_parts[2];
2954 $this->re_space[
'm'] =
'';
2965 public function setRTL($enable, $resetx=
true) {
2966 $enable = $enable ?
true :
false;
2967 $resetx = ($resetx AND ($enable != $this->rtl));
2968 $this->rtl = $enable;
2969 $this->tmprtl =
false;
2993 switch (strtoupper($mode)) {
3014 $this->tmprtl = $newmode;
3024 return ($this->rtl OR ($this->tmprtl ==
'R'));
3065 $this->imgscale = $scale;
3089 if (empty($pagenum)) {
3092 return $this->pagedim[$pagenum];
3105 if (empty($pagenum)) {
3108 return $this->pagedim[$pagenum][
'w'];
3121 if (empty($pagenum)) {
3124 return $this->pagedim[$pagenum][
'h'];
3137 if (empty($pagenum)) {
3140 return $this->pagedim[$pagenum][
'bm'];
3164 public function SetMargins($left, $top, $right=-1, $keepmargins=
false) {
3166 $this->lMargin = $left;
3167 $this->tMargin = $top;
3171 $this->rMargin = $right;
3188 $this->lMargin = $margin;
3189 if (($this->page > 0) AND ($this->x < $margin)) {
3203 $this->tMargin = $margin;
3204 if (($this->page > 0) AND ($this->y < $margin)) {
3217 $this->rMargin = $margin;
3218 if (($this->page > 0) AND ($this->x > ($this->w - $margin))) {
3219 $this->x = $this->w - $margin;
3232 $this->cell_padding[
'L'] = $pad;
3233 $this->cell_padding[
'T'] = $pad;
3234 $this->cell_padding[
'R'] = $pad;
3235 $this->cell_padding[
'B'] = $pad;
3250 if (($left !==
'') AND ($left >= 0)) {
3251 $this->cell_padding[
'L'] = $left;
3253 if (($top !==
'') AND ($top >= 0)) {
3254 $this->cell_padding[
'T'] = $top;
3256 if (($right !==
'') AND ($right >= 0)) {
3257 $this->cell_padding[
'R'] = $right;
3259 if (($bottom !==
'') AND ($bottom >= 0)) {
3260 $this->cell_padding[
'B'] = $bottom;
3286 if (($left !==
'') AND ($left >= 0)) {
3287 $this->cell_margin[
'L'] = $left;
3289 if (($top !==
'') AND ($top >= 0)) {
3290 $this->cell_margin[
'T'] = $top;
3292 if (($right !==
'') AND ($right >= 0)) {
3293 $this->cell_margin[
'R'] = $right;
3295 if (($bottom !==
'') AND ($bottom >= 0)) {
3296 $this->cell_margin[
'B'] = $bottom;
3322 if (is_string($brd)) {
3324 $slen = strlen($brd);
3326 for ($i = 0; $i < $slen; ++$i) {
3327 $newbrd[$brd{$i}] =
true;
3330 } elseif (($brd === 1) OR ($brd ===
true) OR (is_numeric($brd) AND (intval($brd) > 0))) {
3331 $brd = array(
'LRTB' =>
true);
3333 if (!is_array($brd)) {
3339 if (isset($brd[
'mode'])) {
3340 $mode = $brd[
'mode'];
3341 unset($brd[
'mode']);
3346 foreach ($brd as $border => $style) {
3348 if (is_array($style) AND isset($style[
'width'])) {
3350 $line_width = $style[
'width'];
3364 $adj = ($line_width / 2);
3369 if ((strpos($border,
'T') !==
false) AND ($this->cell_padding[
'T'] < $adj)) {
3370 $this->cell_padding[
'T'] = $adj;
3372 if ((strpos($border,
'R') !==
false) AND ($this->cell_padding[
'R'] < $adj)) {
3373 $this->cell_padding[
'R'] = $adj;
3375 if ((strpos($border,
'B') !==
false) AND ($this->cell_padding[
'B'] < $adj)) {
3376 $this->cell_padding[
'B'] = $adj;
3378 if ((strpos($border,
'L') !==
false) AND ($this->cell_padding[
'L'] < $adj)) {
3379 $this->cell_padding[
'L'] = $adj;
3382 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']));
3395 $this->AutoPageBreak = $auto;
3396 $this->bMargin = $margin;
3397 $this->PageBreakTrigger = $this->h - $margin;
3410 if (($zoom ==
'fullpage') OR ($zoom ==
'fullwidth') OR ($zoom ==
'real') OR ($zoom ==
'default') OR (!is_string($zoom))) {
3411 $this->ZoomMode = $zoom;
3413 $this->
Error(
'Incorrect zoom display mode: '.$zoom);
3418 case 'SinglePage': {
3419 $this->LayoutMode =
'SinglePage';
3424 $this->LayoutMode =
'OneColumn';
3428 case 'TwoColumnLeft': {
3429 $this->LayoutMode =
'TwoColumnLeft';
3432 case 'TwoColumnRight': {
3433 $this->LayoutMode =
'TwoColumnRight';
3436 case 'TwoPageLeft': {
3437 $this->LayoutMode =
'TwoPageLeft';
3440 case 'TwoPageRight': {
3441 $this->LayoutMode =
'TwoPageRight';
3445 $this->LayoutMode =
'SinglePage';
3450 $this->PageMode =
'UseNone';
3453 case 'UseOutlines': {
3454 $this->PageMode =
'UseOutlines';
3458 $this->PageMode =
'UseThumbs';
3461 case 'FullScreen': {
3462 $this->PageMode =
'FullScreen';
3466 $this->PageMode =
'UseOC';
3470 $this->PageMode =
'UseAttachments';
3474 $this->PageMode =
'UseNone';
3488 if (function_exists(
'gzcompress')) {
3489 $this->compress =
$compress ?
true :
false;
3491 $this->compress =
false;
3566 die(
'<strong>TCPDF ERROR: </strong>'.$msg);
3591 if ($this->state == 3) {
3594 if ($this->page == 0) {
3599 $this->lastpage(
true);
3602 $this->y = $this->h - (1 /
$this->k);
3606 $this->
SetFont(
'helvetica',
'', 1);
3608 $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";
3609 $lnk =
"\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67";
3610 $this->
Cell(0, 0, $msg, 0, 0,
'L', 0, $lnk, 0,
false,
'D',
'B');
3631 public function setPage($pnum, $resetmargins=
false) {
3632 if (($pnum == $this->page) AND ($this->state == 2)) {
3635 if (($pnum > 0) AND ($pnum <= $this->numpages)) {
3640 $this->page = $pnum;
3645 $this->tMargin = $this->pagedim[
$this->page][
'tm'];
3646 $this->bMargin = $this->pagedim[
$this->page][
'bm'];
3647 $this->original_lMargin = $this->pagedim[
$this->page][
'olm'];
3648 $this->original_rMargin = $this->pagedim[
$this->page][
'orm'];
3649 $this->AutoPageBreak = $this->pagedim[
$this->page][
'pb'];
3650 $this->CurOrientation = $this->pagedim[
$this->page][
'or'];
3654 if ($resetmargins) {
3655 $this->lMargin = $this->pagedim[
$this->page][
'olm'];
3656 $this->rMargin = $this->pagedim[
$this->page][
'orm'];
3657 $this->
SetY($this->tMargin);
3660 if ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$oldpage][
'olm']) {
3662 $this->lMargin += $deltam;
3663 $this->rMargin -= $deltam;
3667 $this->
Error(
'Wrong page number on setPage() function: '.$pnum);
3712 public function addTOCPage($orientation=
'', $format=
'', $keepmargins=
false) {
3713 $this->
AddPage($orientation, $format, $keepmargins,
true);
3737 public function AddPage($orientation=
'', $format=
'', $keepmargins=
false,
$tocpage=
false) {
3738 if ($this->inxobj) {
3742 if (!isset($this->original_lMargin) OR $keepmargins) {
3745 if (!isset($this->original_rMargin) OR $keepmargins) {
3763 if (($this->page == 0) OR ($this->numpages > $this->page) OR (!$this->pageopen[$this->page])) {
3766 $this->InFooter =
true;
3773 $this->InFooter =
false;
3775 $this->tocpage =
false;
3790 $this->tocpage =
true;
3792 if ($this->numpages > $this->page) {
3794 $this->
setPage($this->page + 1);
3795 $this->
SetY($this->tMargin);
3799 if ($this->state == 0) {
3851 if (isset($this->footerlen[
$page])) {
3852 $this->cntmrk[
$page] = $this->pagelen[
$page] - $this->footerlen[
$page];
3854 $this->cntmrk[
$page] = $this->pagelen[
$page];
3867 $this->header_logo = $ln;
3868 $this->header_logo_width = $lw;
3869 $this->header_title = $ht;
3870 $this->header_string = $hs;
3896 $this->header_margin = $hm;
3916 $this->footer_margin = $fm;
3934 $this->print_header = $val;
3943 $this->print_footer = $val;
3973 if (($headerdata[
'logo']) AND ($headerdata[
'logo'] !=
K_BLANK_IMAGE)) {
3977 $imgy = $this->
GetY();
3982 $header_x = $ormargins[
'right'] + ($headerdata[
'logo_width'] * 1.1);
3984 $header_x = $ormargins[
'left'] + ($headerdata[
'logo_width'] * 1.1);
3988 $this->
SetFont($headerfont[0],
'B', $headerfont[2] + 1);
3989 $this->
SetX($header_x);
3990 $this->
Cell(0, $cell_height, $headerdata[
'title'], 0, 1,
'', 0,
'', 0);
3992 $this->
SetFont($headerfont[0], $headerfont[1], $headerfont[2]);
3993 $this->
SetX($header_x);
3994 $this->
MultiCell(0, $cell_height, $headerdata[
'string'], 0,
'', 0, 1,
'',
'',
true, 0,
false);
3996 $this->
SetLineStyle(array(
'width' => 0.85 / $this->
getScaleFactor(),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => array(0, 0, 0)));
3999 $this->
SetX($ormargins[
'right']);
4001 $this->
SetX($ormargins[
'left']);
4003 $this->
Cell(0, 0,
'',
'T', 0,
'C');
4012 $cur_y = $this->
GetY();
4017 $this->
SetLineStyle(array(
'width' => $line_width,
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => array(0, 0, 0)));
4021 $this->
Ln($line_width);
4022 $barcode_width = round(($this->
getPageWidth() - $ormargins[
'left'] - $ormargins[
'right']) / 3);
4024 'position' => $this->rtl?
'R':
'L',
4025 'align' => $this->rtl?
'R':
'L',
4028 'cellfitalign' =>
'',
4031 'fgcolor' => array(0,0,0),
4037 if (empty($this->pagegroups)) {
4042 $this->
SetY($cur_y);
4045 $this->
SetX($ormargins[
'right']);
4046 $this->
Cell(0, 0, $pagenumtxt,
'T', 0,
'L');
4048 $this->
SetX($ormargins[
'left']);
4049 $this->
Cell(0, 0, $pagenumtxt,
'T', 0,
'R');
4059 if ($this->print_header) {
4070 $this->
SetXY($this->original_rMargin, $this->header_margin);
4072 $this->
SetXY($this->original_lMargin, $this->header_margin);
4074 $this->
SetFont($this->header_font[0], $this->header_font[1], $this->header_font[2]);
4078 $this->
SetXY($this->original_rMargin, $this->tMargin);
4080 $this->
SetXY($this->original_lMargin, $this->tMargin);
4084 $this->thead = $temp_thead;
4085 $this->theadMargins = $temp_theadMargins;
4086 $this->newline =
false;
4102 if ($this->print_footer) {
4104 $this->current_column = 0;
4105 $this->num_columns = 1;
4116 $this->
SetXY($this->original_rMargin, $footer_y);
4118 $this->
SetXY($this->original_lMargin, $footer_y);
4120 $this->
SetFont($this->footer_font[0], $this->footer_font[1], $this->footer_font[2]);
4124 $this->
SetXY($this->original_rMargin, $this->tMargin);
4126 $this->
SetXY($this->original_lMargin, $this->tMargin);
4130 $this->thead = $temp_thead;
4131 $this->theadMargins = $temp_theadMargins;
4135 $this->current_column = $gvars[
'current_column'];
4136 $this->num_columns = $gvars[
'num_columns'];
4147 if ($this->num_columns > 1) {
4151 if (isset($this->theadMargins[
'top'])) {
4153 $this->tMargin = $this->theadMargins[
'top'];
4157 if (!$this->
empty_string($this->thead) AND (!$this->inthead)) {
4162 $this->lMargin = $this->theadMargins[
'lmargin'] + ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$this->theadMargins[
'page']][
'olm']);
4163 $this->rMargin = $this->theadMargins[
'rmargin'] + ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$this->theadMargins[
'page']][
'orm']);
4164 $this->cell_padding = $this->theadMargins[
'cell_padding'];
4171 $this->
writeHTML($this->thead,
false,
false,
false,
false,
'');
4173 if (!isset($this->theadMargins[
'top'])) {
4179 $this->lMargin = $prev_lMargin;
4180 $this->rMargin = $prev_rMargin;
4181 $this->cell_padding = $prev_cell_padding;
4209 if (!isset($this->spot_colors[
$name])) {
4210 $i = 1 + count($this->spot_colors);
4211 $this->spot_colors[
$name] = array(
'i' => $i,
'c' => $c,
'm' => $m,
'y' =>
$y,
'k' =>
$k);
4227 if (is_array($color)) {
4228 $color = array_values($color);
4229 $r = isset($color[0]) ? $color[0] : -1;
4230 $g = isset($color[1]) ? $color[1] : -1;
4231 $b = isset($color[2]) ? $color[2] : -1;
4232 $k = isset($color[3]) ? $color[3] : -1;
4254 if (!is_numeric($col1)) {
4257 if (!is_numeric($col2)) {
4260 if (!is_numeric($col3)) {
4263 if (!is_numeric($col4)) {
4267 if (($col2 == -1) AND ($col3 == -1) AND ($col4 == -1)) {
4269 $this->DrawColor = sprintf(
'%.3F G', $col1/255);
4270 $this->strokecolor = array(
'G' => $col1);
4271 } elseif ($col4 == -1) {
4273 $this->DrawColor = sprintf(
'%.3F %.3F %.3F RG', $col1/255, $col2/255, $col3/255);
4274 $this->strokecolor = array(
'R' => $col1,
'G' => $col2,
'B' => $col3);
4277 $this->DrawColor = sprintf(
'%.3F %.3F %.3F %.3F K', $col1/100, $col2/100, $col3/100, $col4/100);
4278 $this->strokecolor = array(
'C' => $col1,
'M' => $col2,
'Y' => $col3,
'K' => $col4);
4280 if ($this->page > 0) {
4282 $this->
_out($this->DrawColor);
4298 if (!isset($this->spot_colors[
$name])) {
4299 $this->
Error(
'Undefined spot color: '.$name);
4301 $this->DrawColor = sprintf(
'/CS%d CS %.3F SCN', $this->spot_colors[$name][
'i'], $tint/100);
4302 if ($this->page > 0) {
4303 $this->
_out($this->DrawColor);
4317 if (is_array($color)) {
4318 $color = array_values($color);
4319 $r = isset($color[0]) ? $color[0] : -1;
4320 $g = isset($color[1]) ? $color[1] : -1;
4321 $b = isset($color[2]) ? $color[2] : -1;
4322 $k = isset($color[3]) ? $color[3] : -1;
4341 if (!is_numeric($col1)) {
4344 if (!is_numeric($col2)) {
4347 if (!is_numeric($col3)) {
4350 if (!is_numeric($col4)) {
4354 if (($col2 == -1) AND ($col3 == -1) AND ($col4 == -1)) {
4356 $this->FillColor = sprintf(
'%.3F g', $col1/255);
4357 $this->bgcolor = array(
'G' => $col1);
4358 } elseif ($col4 == -1) {
4360 $this->FillColor = sprintf(
'%.3F %.3F %.3F rg', $col1/255, $col2/255, $col3/255);
4361 $this->bgcolor = array(
'R' => $col1,
'G' => $col2,
'B' => $col3);
4364 $this->FillColor = sprintf(
'%.3F %.3F %.3F %.3F k', $col1/100, $col2/100, $col3/100, $col4/100);
4365 $this->bgcolor = array(
'C' => $col1,
'M' => $col2,
'Y' => $col3,
'K' => $col4);
4368 if ($this->page > 0) {
4369 $this->
_out($this->FillColor);
4382 if (!isset($this->spot_colors[
$name])) {
4383 $this->
Error(
'Undefined spot color: '.$name);
4385 $this->FillColor = sprintf(
'/CS%d cs %.3F scn', $this->spot_colors[$name][
'i'], $tint/100);
4387 if ($this->page > 0) {
4388 $this->
_out($this->FillColor);
4401 if (is_array($color)) {
4402 $color = array_values($color);
4403 $r = isset($color[0]) ? $color[0] : -1;
4404 $g = isset($color[1]) ? $color[1] : -1;
4405 $b = isset($color[2]) ? $color[2] : -1;
4406 $k = isset($color[3]) ? $color[3] : -1;
4425 if (!is_numeric($col1)) {
4428 if (!is_numeric($col2)) {
4431 if (!is_numeric($col3)) {
4434 if (!is_numeric($col4)) {
4438 if (($col2 == -1) AND ($col3 == -1) AND ($col4 == -1)) {
4440 $this->TextColor = sprintf(
'%.3F g', $col1/255);
4441 $this->fgcolor = array(
'G' => $col1);
4442 } elseif ($col4 == -1) {
4444 $this->TextColor = sprintf(
'%.3F %.3F %.3F rg', $col1/255, $col2/255, $col3/255);
4445 $this->fgcolor = array(
'R' => $col1,
'G' => $col2,
'B' => $col3);
4448 $this->TextColor = sprintf(
'%.3F %.3F %.3F %.3F k', $col1/100, $col2/100, $col3/100, $col4/100);
4449 $this->fgcolor = array(
'C' => $col1,
'M' => $col2,
'Y' => $col3,
'K' => $col4);
4463 if (!isset($this->spot_colors[
$name])) {
4464 $this->
Error(
'Undefined spot color: '.$name);
4466 $this->TextColor = sprintf(
'/CS%d cs %.3F scn', $this->spot_colors[$name][
'i'], $tint/100);
4468 if ($this->page > 0) {
4469 $this->
_out($this->TextColor);
4485 public function GetStringWidth($s, $fontname=
'', $fontstyle=
'', $fontsize=0, $getarray=
false) {
4507 $this->
SetFont($fontname, $fontstyle, $fontsize);
4513 foreach ($sa as $ck => $char) {
4521 $this->
SetFont($prev_FontFamily, $prev_FontStyle, $prev_FontSizePt);
4541 if (($this->font_spacing != 0) AND $notlast) {
4545 if ($this->font_stretching != 100) {
4547 $chw *= ($this->font_stretching / 100);
4565 $cw = &$this->CurrentFont[
'cw'];
4566 if (isset(
$cw[$char])) {
4568 } elseif (isset($this->CurrentFont[
'dw'])) {
4570 $w = $this->CurrentFont[
'dw'];
4571 } elseif (isset(
$cw[32])) {
4577 return (
$w * $this->FontSize / 1000);
4601 while ((
$file = readdir($fontsdir)) !==
false) {
4602 if (substr(
$file, -4) ==
'.php') {
4603 array_push($this->fontlist, strtolower(basename(
$file,
'.php')));
4606 closedir($fontsdir);
4622 public function AddFont($family, $style=
'', $fontfile=
'', $subset=
'default') {
4623 if ($subset ===
'default') {
4630 $this->
Error(
'Empty font family');
4634 if (substr($family, -1) ==
'I') {
4636 $family = substr($family, 0, -1);
4638 if (substr($family, -1) ==
'B') {
4640 $family = substr($family, 0, -1);
4643 $family = strtolower($family);
4644 if ((!$this->isunicode) AND ($family ==
'arial')) {
4645 $family =
'helvetica';
4647 if (($family ==
'symbol') OR ($family ==
'zapfdingbats')) {
4650 $tempstyle = strtoupper($style);
4653 if (strpos($tempstyle,
'U') !==
false) {
4654 $this->underline =
true;
4656 $this->underline =
false;
4659 if (strpos($tempstyle,
'D') !==
false) {
4660 $this->linethrough =
true;
4662 $this->linethrough =
false;
4665 if (strpos($tempstyle,
'O') !==
false) {
4666 $this->overline =
true;
4668 $this->overline =
false;
4671 if (strpos($tempstyle,
'B') !==
false) {
4675 if (strpos($tempstyle,
'I') !==
false) {
4679 $fontkey = $family.$style;
4680 $font_style = $style.($this->underline ?
'U' :
'').($this->linethrough ?
'D' :
'').($this->overline ?
'O' :
'');
4681 $fontdata = array(
'fontkey' => $fontkey,
'family' => $family,
'style' => $font_style);
4684 if ($fb !==
false) {
4685 if ($this->inxobj) {
4687 $this->xobjects[
$this->xobjid][
'fonts'][$fontkey] = $fb[
'i'];
4700 $fontdir = dirname($fontfile);
4701 if ($this->
empty_string($fontdir) OR ($fontdir ==
'.')) {
4708 if ($this->
empty_string($fontfile) OR (!file_exists($fontfile))) {
4710 $fontfile1 = str_replace(
' ',
'', $family).strtolower($style).
'.php';
4711 $fontfile2 = str_replace(
' ',
'', $family).
'.php';
4713 if (($fontdir !==
false) AND file_exists($fontdir.$fontfile1)) {
4714 $fontfile = $fontdir.$fontfile1;
4715 } elseif (file_exists($this->
_getfontpath().$fontfile1)) {
4717 } elseif (file_exists($fontfile1)) {
4718 $fontfile = $fontfile1;
4719 } elseif (($fontdir !==
false) AND file_exists($fontdir.$fontfile2)) {
4720 $fontfile = $fontdir.$fontfile2;
4721 } elseif (file_exists($this->
_getfontpath().$fontfile2)) {
4724 $fontfile = $fontfile2;
4728 if (file_exists($fontfile)) {
4731 $this->
Error(
'Could not include font definition file: '.$family.
'');
4734 if ((!isset(
$type)) OR (!isset(
$cw))) {
4735 $this->
Error(
'The font definition file has a bad format: '.$fontfile.
'');
4745 $cidinfo = array(
'Registry'=>
'Adobe',
'Ordering'=>
'Identity',
'Supplement'=>0);
4765 if (isset(
$desc[
'MissingWidth']) AND (
$desc[
'MissingWidth'] > 0)) {
4767 } elseif (isset(
$cw[32])) {
4774 if (
$type ==
'cidfont0') {
4776 $styles = array(
'' =>
'',
'B' =>
',Bold',
'I' =>
',Italic',
'BI' =>
',BoldItalic');
4777 $sname =
$name.$styles[$bistyle];
4779 if (strpos($bistyle,
'B') !==
false) {
4780 if (isset(
$desc[
'StemV'])) {
4781 $desc[
'StemV'] *= 2;
4783 $desc[
'StemV'] = 120;
4787 if (strpos($bistyle,
'I') !==
false) {
4788 if (isset(
$desc[
'ItalicAngle'])) {
4789 $desc[
'ItalicAngle'] -= 11;
4791 $desc[
'ItalicAngle'] = -11;
4794 } elseif (
$type ==
'core') {
4795 $name = $this->CoreFonts[$fontkey];
4797 } elseif ((
$type ==
'TrueType') OR (
$type ==
'Type1')) {
4799 } elseif (
$type ==
'TrueTypeUnicode') {
4800 $enc =
'Identity-H';
4805 $subsetchars = array_fill(0, 256,
true);
4806 $this->
setFontBuffer($fontkey, array(
'fontkey' => $fontkey,
'i' => $this->numfonts,
'type' =>
$type,
'name' =>
$name,
'desc' =>
$desc,
'up' =>
$up,
'ut' =>
$ut,
'cw' =>
$cw,
'dw' =>
$dw,
'enc' =>
$enc,
'cidinfo' =>
$cidinfo,
'file' =>
$file,
'ctg' =>
$ctg,
'subset' => $subset,
'subsetchars' => $subsetchars));
4807 if ($this->inxobj) {
4814 $nb = count($this->diffs);
4815 for ($i=1; $i <= $nb; ++$i) {
4816 if ($this->diffs[$i] ==
$diff) {
4828 if (!isset($this->FontFiles[
$file])) {
4829 if ((strcasecmp(
$type,
'TrueType') == 0) OR (strcasecmp(
$type,
'TrueTypeUnicode') == 0)) {
4830 $this->FontFiles[
$file] = array(
'length1' =>
$originalsize,
'fontdir' => $fontdir,
'subset' => $subset,
'fontkeys' => array($fontkey));
4831 } elseif (
$type !=
'core') {
4832 $this->FontFiles[
$file] = array(
'length1' => $size1,
'length2' => $size2,
'fontdir' => $fontdir,
'subset' => $subset,
'fontkeys' => array($fontkey));
4836 $this->FontFiles[
$file][
'subset'] = ($this->FontFiles[
$file][
'subset'] AND $subset);
4837 if (!in_array($fontkey, $this->FontFiles[$file][
'fontkeys'])) {
4838 $this->FontFiles[
$file][
'fontkeys'][] = $fontkey;
4861 public function SetFont($family, $style=
'', $size=0, $fontfile=
'', $subset=
'default') {
4867 $fontdata = $this->
AddFont($family, $style, $fontfile, $subset);
4868 $this->FontFamily = $fontdata[
'family'];
4869 $this->FontStyle = $fontdata[
'style'];
4870 $this->CurrentFont = $this->
getFontBuffer($fontdata[
'fontkey']);
4884 $this->FontSizePt = $size;
4886 $this->FontSize = $size /
$this->k;
4888 if (isset($this->CurrentFont[
'desc'][
'FontBBox'])) {
4889 $bbox = explode(
' ', substr($this->CurrentFont[
'desc'][
'FontBBox'], 1, -1));
4890 $font_height = ((intval($bbox[3]) - intval($bbox[1])) * $size / 1000);
4892 $font_height = $size * 1.219;
4894 if (isset($this->CurrentFont[
'desc'][
'Ascent']) AND ($this->CurrentFont[
'desc'][
'Ascent'] > 0)) {
4895 $font_ascent = ($this->CurrentFont[
'desc'][
'Ascent'] * $size / 1000);
4897 if (isset($this->CurrentFont[
'desc'][
'Descent']) AND ($this->CurrentFont[
'desc'][
'Descent'] <= 0)) {
4898 $font_descent = (- $this->CurrentFont[
'desc'][
'Descent'] * $size / 1000);
4900 if (!isset($font_ascent) AND !isset($font_descent)) {
4902 $font_ascent = 0.76 * $font_height;
4903 $font_descent = $font_height - $font_ascent;
4904 } elseif (!isset($font_descent)) {
4905 $font_descent = $font_height - $font_ascent;
4906 } elseif (!isset($font_ascent)) {
4907 $font_ascent = $font_height - $font_descent;
4909 $this->FontAscent = $font_ascent /
$this->k;
4910 $this->FontDescent = $font_descent /
$this->k;
4911 if (
$out AND ($this->page > 0) AND (isset($this->CurrentFont[
'i']))) {
4912 $this->
_out(sprintf(
'BT /F%d %.2F Tf ET', $this->CurrentFont[
'i'], $this->FontSizePt));
4927 $fontdata = $this->
AddFont($font, $style);
4929 if (isset($fontinfo[
'desc'][
'Descent']) AND ($fontinfo[
'desc'][
'Descent'] <= 0)) {
4930 $descent = (- $fontinfo[
'desc'][
'Descent'] * $size / 1000);
4932 $descent = 1.219 * 0.24 * $size;
4934 return ($descent / $this->k);
4948 $fontdata = $this->
AddFont($font, $style);
4950 if (isset($fontinfo[
'desc'][
'Ascent']) AND ($fontinfo[
'desc'][
'Ascent'] > 0)) {
4951 $ascent = ($fontinfo[
'desc'][
'Ascent'] * $size / 1000);
4953 $ascent = 1.219 * 0.76 * $size;
4955 return ($ascent / $this->k);
4965 $this->default_monospaced_font = $font;
4977 $n = count($this->links) + 1;
4978 $this->links[
$n] = array(0, 0);
4998 $this->links[$link] = array(
$page,
$y);
5032 if ($this->inxobj) {
5034 $this->xobjects[
$this->xobjid][
'annotations'][] = array(
'x' =>
$x,
'y' =>
$y,
'w' =>
$w,
'h' =>
$h,
'text' => $text,
'opt' => $opt,
'spaces' => $spaces);
5046 if (isset($this->transfmatrix) AND !empty($this->transfmatrix)) {
5047 for ($i=$this->transfmatrix_key; $i > 0; --$i) {
5048 $maxid = count($this->transfmatrix[$i]) - 1;
5049 for ($j=$maxid; $j >= 0; --$j) {
5050 $ctm = $this->transfmatrix[$i][$j];
5051 if (isset($ctm[
'a'])) {
5053 $y = ($this->h -
$y) * $this->k;
5059 $x1 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
5060 $y1 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
5064 $x2 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
5065 $y2 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
5069 $x3 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
5070 $y3 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
5074 $x4 = ($ctm[
'a'] * $xt) + ($ctm[
'c'] * $yt) + $ctm[
'e'];
5075 $y4 = ($ctm[
'b'] * $xt) + ($ctm[
'd'] * $yt) + $ctm[
'f'];
5077 $x = min($x1, $x2, $x3, $x4);
5078 $y = max($y1, $y2, $y3, $y4);
5079 $w = (max($x1, $x2, $x3, $x4) -
$x) / $this->k;
5080 $h = (
$y - min($y1, $y2, $y3, $y4)) / $this->k;
5087 if ($this->page <= 0) {
5092 if (!isset($this->PageAnnots[
$page])) {
5093 $this->PageAnnots[
$page] = array();
5096 $this->PageAnnots[
$page][] = array(
'n' => $this->
n,
'x' =>
$x,
'y' =>
$y,
'w' =>
$w,
'h' =>
$h,
'txt' => $text,
'opt' => $opt,
'numspaces' => $spaces);
5097 if ((($opt[
'Subtype'] ==
'FileAttachment') OR ($opt[
'Subtype'] ==
'Sound')) AND (!$this->
empty_string($opt[
'FS'])) AND file_exists($opt[
'FS']) AND (!isset($this->embeddedfiles[basename($opt[
'FS'])]))) {
5099 $this->embeddedfiles[basename($opt[
'FS'])] = array(
'n' => $this->
n,
'file' => $opt[
'FS']);
5102 if (isset($opt[
'mk'][
'i']) AND file_exists($opt[
'mk'][
'i'])) {
5103 $this->
Image($opt[
'mk'][
'i'],
'',
'', 10, 10,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
5105 if (isset($opt[
'mk'][
'ri']) AND file_exists($opt[
'mk'][
'ri'])) {
5106 $this->
Image($opt[
'mk'][
'ri'],
'',
'', 0, 0,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
5108 if (isset($opt[
'mk'][
'ix']) AND file_exists($opt[
'mk'][
'ix'])) {
5109 $this->
Image($opt[
'mk'][
'ix'],
'',
'', 0, 0,
'',
'',
'',
false, 300,
'',
false,
false, 0,
false,
true);
5120 reset($this->embeddedfiles);
5121 foreach ($this->embeddedfiles as
$filename => $filedata) {
5122 $data = file_get_contents($filedata[
'file']);
5124 if ($this->compress) {
5126 $filter =
' /Filter /FlateDecode';
5130 $out .=
'<< /Type /EmbeddedFile'.$filter.
' /Length '.strlen($stream).
' >>';
5131 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
5132 $out .=
"\n".
'endobj';
5161 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) {
5166 $this->
Cell(0, 0, $txt, $border, $ln, $align, $fill, $link, $stretch, $ignore_min_height, $calign, $valign);
5182 if ($this->num_columns > 1) {
5184 if($this->current_column < ($this->num_columns - 1)) {
5213 if (((
$y +
$h) > $this->PageBreakTrigger) AND (!$this->InFooter) AND ($this->
AcceptPageBreak())) {
5217 $this->
AddPage($this->CurOrientation);
5219 $oldpage = $this->page - 1;
5221 if ($this->pagedim[$this->page][
'orm'] != $this->pagedim[$oldpage][
'orm']) {
5222 $this->x =
$x - ($this->pagedim[
$this->page][
'orm'] - $this->pagedim[$oldpage][
'orm']);
5227 if ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$oldpage][
'olm']) {
5228 $this->x =
$x + ($this->pagedim[
$this->page][
'olm'] - $this->pagedim[$oldpage][
'olm']);
5234 $this->newline =
true;
5237 if ($current_page != $this->page) {
5239 $this->newline =
true;
5262 $txt = preg_replace(
'/([\\xc2]{1}[\\xad]{1})/',
'', $txt);
5263 if (!$this->isunicode) {
5264 $txt = preg_replace(
'/([\\xad]{1})/',
'', $txt);
5288 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') {
5292 if (!$ignore_min_height) {
5293 $min_cell_height = ($this->FontSize *
$this->cell_height_ratio) + $this->cell_padding[
'T'] + $this->cell_padding[
'B'];
5294 if (
$h < $min_cell_height) {
5295 $h = $min_cell_height;
5298 $this->
checkPageBreak(
$h + $this->cell_margin[
'T'] + $this->cell_margin[
'B']);
5299 $this->
_out($this->
getCellCode(
$w,
$h, $txt, $border, $ln, $align, $fill, $link, $stretch,
true, $calign, $valign));
5300 $this->cell_padding = $prev_cell_padding;
5301 $this->cell_margin = $prev_cell_margin;
5324 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') {
5330 if (!$ignore_min_height) {
5331 $min_cell_height = ($this->FontSize *
$this->cell_height_ratio) + $this->cell_padding[
'T'] + $this->cell_padding[
'B'];
5332 if (
$h < $min_cell_height) {
5333 $h = $min_cell_height;
5340 $x = $this->x - $this->cell_margin[
'R'];
5342 $x = $this->x + $this->cell_margin[
'L'];
5344 $y = $this->y + $this->cell_margin[
'T'];
5354 $y -= $this->cell_padding[
'T'];
5405 $y -= (
$h - $this->cell_padding[
'B']);
5439 $yt =
$y + $this->cell_padding[
'T'];
5460 $w = $this->w - $this->rMargin -
$x;
5465 if (is_string($border) AND (strlen($border) == 4)) {
5469 if ($fill OR ($border == 1)) {
5471 $op = ($border == 1) ?
'B' :
'f';
5480 $s .= sprintf(
'%.2F %.2F %.2F %.2F re %s ', $xk, (($this->h -
$y) *
$k), (
$w * $k), (-
$h * $k), $op);
5486 if ($this->isunicode) {
5487 if (($this->CurrentFont[
'type'] ==
'core') OR ($this->CurrentFont[
'type'] ==
'TrueType') OR ($this->CurrentFont[
'type'] ==
'Type1')) {
5496 $topchar = array(3611, 3613, 3615, 3650, 3651, 3652);
5497 $topsym = array(3633, 3636, 3637, 3638, 3639, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662);
5500 $uniblock = array();
5501 $uniblock[$unik] = array();
5504 for ($i = 1; $i < $numchars; ++$i) {
5506 if (in_array(
$unicode[$i], $topsym) AND (in_array(
$unicode[($i - 1)], $topsym) OR in_array(
$unicode[($i - 1)], $topchar))) {
5509 $uniblock[$unik] = array();
5512 $uniblock[$unik] = array();
5523 $txt2 = $this->
_escape($txt2);
5533 $ratio = ((
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / $width);
5536 if (($ratio < 1) OR (($ratio > 1) AND (($stretch % 2) == 0))) {
5540 $this->font_spacing += (
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'] - $width) / (max(($this->
GetNumChars($txt) - 1), 1) * ($this->font_stretching / 100));
5543 $this->font_stretching *= $ratio;
5546 $width =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
5551 if ($this->font_stretching != 100) {
5553 $rs .= sprintf(
'BT %.2F Tz ET ', $this->font_stretching);
5555 if ($this->font_spacing != 0) {
5557 $rs .= sprintf(
'BT %.2F Tc ET ', ($this->font_spacing * $this->k));
5559 if ($this->ColorFlag) {
5560 $s .=
'q '.$this->TextColor.
' ';
5563 $s .= sprintf(
'BT %d Tr %.2F w ET ', $this->textrendermode, $this->textstrokewidth);
5565 $ns = substr_count($txt, chr(32));
5568 if (($align ==
'J') AND ($ns > 0)) {
5573 $spacewidth = -1000 * (
$w - $width - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1) /
$this->FontSize;
5574 if ($this->font_stretching != 100) {
5576 $spacewidth /= ($this->font_stretching / 100);
5579 $txt2 = str_replace(chr(0).chr(32),
') '.sprintf(
'%.3F', $spacewidth).
' (', $txt2);
5580 $unicode_justification =
true;
5585 $spacewidth = ((
$w - $width - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1)) * $this->k;
5586 if ($this->font_stretching != 100) {
5588 $spacewidth /= ($this->font_stretching / 100);
5591 $rs .= sprintf(
'BT %.3F Tw ET ', $spacewidth);
5593 $width =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
5596 $txt2 = str_replace(
"\r",
' ', $txt2);
5599 $dx = (
$w - $width) / 2;
5604 $dx = $this->cell_padding[
'R'];
5606 $dx =
$w - $width - $this->cell_padding[
'R'];
5612 $dx =
$w - $width - $this->cell_padding[
'L'];
5614 $dx = $this->cell_padding[
'L'];
5621 $dx = $this->cell_padding[
'R'];
5623 $dx = $this->cell_padding[
'L'];
5629 $xdx =
$x - $dx - $width;
5635 $s .= sprintf(
'BT %.2F %.2F Td [(%s)] TJ ET', $xdk, (($this->h - $basefonty) * $k), $txt2);
5636 if (isset($uniblock)) {
5640 $spw = ((
$w - $txwidth - $this->cell_padding[
'L'] - $this->cell_padding[
'R']) / ($ns?$ns:1));
5641 foreach ($uniblock as $uk => $uniarr) {
5642 if (($uk % 2) == 0) {
5644 if ($spacewidth != 0) {
5646 $xshift += (count(array_keys($uniarr, 32)) * $spw);
5652 $topchr = $this->
_escape($topchr);
5653 $s .= sprintf(
' BT %.2F %.2F Td [(%s)] TJ ET', ($xdk + ($xshift * $k)), $ty, $topchr);
5657 if ($this->underline) {
5658 $s .=
' '.$this->_dounderlinew($xdx, $basefonty, $width);
5660 if ($this->linethrough) {
5661 $s .=
' '.$this->_dolinethroughw($xdx, $basefonty, $width);
5663 if ($this->overline) {
5664 $s .=
' '.$this->_dooverlinew($xdx, $basefonty, $width);
5666 if ($this->ColorFlag) {
5670 $this->
Link($xdx, $yt, $width, ($this->FontAscent + $this->FontDescent), $link, $ns);
5677 if ($this->font_spacing != 0) {
5679 $rs .=
' BT 0 Tc ET';
5681 if ($this->font_stretching != 100) {
5683 $rs .=
' BT 100 Tz ET';
5688 $rs .=
' BT 0 Tw ET';
5691 $this->font_stretching = $prev_font_stretching;
5692 $this->font_spacing = $prev_font_spacing;
5696 $this->y =
$y +
$h + $this->cell_margin[
'B'];
5707 $this->x =
$x -
$w - $this->cell_margin[
'L'];
5709 $this->x =
$x +
$w + $this->cell_margin[
'R'];
5712 $gstyles =
''.$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' '.$this->FillColor.
"\n";
5714 $this->cell_padding = $prev_cell_padding;
5715 $this->cell_margin = $prev_cell_margin;
5738 $brd = array(
'LRTB' =>
true);
5747 $xeR = (
$x +
$w) * $k;
5749 $yeL = (($this->h - (
$y +
$h)) *
$k);
5750 $yeT = (($this->h -
$y) *
$k);
5755 if (is_string($brd)) {
5757 $slen = strlen($brd);
5759 for ($i = 0; $i < $slen; ++$i) {
5760 $newbrd[$brd{$i}] = array(
'cap' =>
'square',
'join' =>
'miter');
5764 if (isset($brd[
'mode'])) {
5765 $mode = $brd[
'mode'];
5766 unset($brd[
'mode']);
5770 foreach ($brd as $border => $style) {
5771 if (is_array($style) AND !empty($style)) {
5773 $prev_style = $this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' ';
5778 $off = (($this->LineWidth / 2) *
$k);
5792 $off = ($this->LineWidth / 2) *
$k;
5819 if (strlen($border) == 4) {
5820 $s .= sprintf(
'%.2F %.2F %.2F %.2F re S ', $xT, $yT, (
$w *
$k), (-
$h * $k));
5821 } elseif (strlen($border) == 3) {
5822 if (strpos($border,
'B') ===
false) {
5823 $s .= sprintf(
'%.2F %.2F m ', $xL, $yL);
5824 $s .= sprintf(
'%.2F %.2F l ', $xT, $yT);
5825 $s .= sprintf(
'%.2F %.2F l ', $xR, $yR);
5826 $s .= sprintf(
'%.2F %.2F l ', $xB, $yB);
5828 } elseif (strpos($border,
'L') ===
false) {
5829 $s .= sprintf(
'%.2F %.2F m ', $xT, $yT);
5830 $s .= sprintf(
'%.2F %.2F l ', $xR, $yR);
5831 $s .= sprintf(
'%.2F %.2F l ', $xB, $yB);
5832 $s .= sprintf(
'%.2F %.2F l ', $xL, $yL);
5834 } elseif (strpos($border,
'T') ===
false) {
5835 $s .= sprintf(
'%.2F %.2F m ', $xR, $yR);
5836 $s .= sprintf(
'%.2F %.2F l ', $xB, $yB);
5837 $s .= sprintf(
'%.2F %.2F l ', $xL, $yL);
5838 $s .= sprintf(
'%.2F %.2F l ', $xT, $yT);
5840 } elseif (strpos($border,
'R') ===
false) {
5841 $s .= sprintf(
'%.2F %.2F m ', $xB, $yB);
5842 $s .= sprintf(
'%.2F %.2F l ', $xL, $yL);
5843 $s .= sprintf(
'%.2F %.2F l ', $xT, $yT);
5844 $s .= sprintf(
'%.2F %.2F l ', $xR, $yR);
5847 } elseif (strlen($border) == 2) {
5848 if ((strpos($border,
'L') !==
false) AND (strpos($border,
'T') !==
false)) {
5849 $s .= sprintf(
'%.2F %.2F m ', $xL, $yL);
5850 $s .= sprintf(
'%.2F %.2F l ', $xT, $yT);
5851 $s .= sprintf(
'%.2F %.2F l ', $xR, $yR);
5853 } elseif ((strpos($border,
'T') !==
false) AND (strpos($border,
'R') !==
false)) {
5854 $s .= sprintf(
'%.2F %.2F m ', $xT, $yT);
5855 $s .= sprintf(
'%.2F %.2F l ', $xR, $yR);
5856 $s .= sprintf(
'%.2F %.2F l ', $xB, $yB);
5858 } elseif ((strpos($border,
'R') !==
false) AND (strpos($border,
'B') !==
false)) {
5859 $s .= sprintf(
'%.2F %.2F m ', $xR, $yR);
5860 $s .= sprintf(
'%.2F %.2F l ', $xB, $yB);
5861 $s .= sprintf(
'%.2F %.2F l ', $xL, $yL);
5863 } elseif ((strpos($border,
'B') !==
false) AND (strpos($border,
'L') !==
false)) {
5864 $s .= sprintf(
'%.2F %.2F m ', $xB, $yB);
5865 $s .= sprintf(
'%.2F %.2F l ', $xL, $yL);
5866 $s .= sprintf(
'%.2F %.2F l ', $xT, $yT);
5868 } elseif ((strpos($border,
'L') !==
false) AND (strpos($border,
'R') !==
false)) {
5869 $s .= sprintf(
'%.2F %.2F m ', $xL, $yL);
5870 $s .= sprintf(
'%.2F %.2F l ', $xT, $yT);
5872 $s .= sprintf(
'%.2F %.2F m ', $xR, $yR);
5873 $s .= sprintf(
'%.2F %.2F l ', $xB, $yB);
5875 } elseif ((strpos($border,
'T') !==
false) AND (strpos($border,
'B') !==
false)) {
5876 $s .= sprintf(
'%.2F %.2F m ', $xT, $yT);
5877 $s .= sprintf(
'%.2F %.2F l ', $xR, $yR);
5879 $s .= sprintf(
'%.2F %.2F m ', $xB, $yB);
5880 $s .= sprintf(
'%.2F %.2F l ', $xL, $yL);
5884 if (strpos($border,
'L') !==
false) {
5885 $s .= sprintf(
'%.2F %.2F m ', $xL, $yL);
5886 $s .= sprintf(
'%.2F %.2F l ', $xT, $yT);
5888 } elseif (strpos($border,
'T') !==
false) {
5889 $s .= sprintf(
'%.2F %.2F m ', $xT, $yT);
5890 $s .= sprintf(
'%.2F %.2F l ', $xR, $yR);
5892 } elseif (strpos($border,
'R') !==
false) {
5893 $s .= sprintf(
'%.2F %.2F m ', $xR, $yR);
5894 $s .= sprintf(
'%.2F %.2F l ', $xB, $yB);
5896 } elseif (strpos($border,
'B') !==
false) {
5897 $s .= sprintf(
'%.2F %.2F m ', $xB, $yB);
5898 $s .= sprintf(
'%.2F %.2F l ', $xL, $yL);
5902 if (is_array($style) AND !empty($style)) {
5904 $s .=
"\n".$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
"\n";
5935 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) {
5942 $this->cell_padding[
'T'] = 0;
5943 $this->cell_padding[
'B'] = 0;
5955 if ((!$this->InFooter) AND ((
$y +
$h + $mc_margin[
'T'] + $mc_margin[
'B']) > $this->PageBreakTrigger)) {
5957 $newh = $this->PageBreakTrigger -
$y;
5958 $resth =
$h - $newh;
5973 $oy =
$y + $mc_margin[
'T'];
5975 $ox = $this->w -
$x - $mc_margin[
'R'];
5977 $ox =
$x + $mc_margin[
'L'];
5984 $w = $this->x - $this->lMargin - $mc_margin[
'L'];
5986 $w = $this->w - $this->x - $this->rMargin - $mc_margin[
'R'];
5993 $this->rMargin = $this->w -
$this->x;
5994 $this->lMargin = $this->x -
$w;
5997 $this->rMargin = $this->w - $this->x -
$w;
6001 $this->y += $mc_padding[
'T'];
6004 $this->
writeHTML($txt,
true, 0, $reseth,
true, $align);
6010 $text_height = $this->
getStringHeight(
$w, $txt, $reseth, $autopadding, $mc_padding, $border);
6016 $prev_text_height = $text_height;
6018 while ($maxit > 0) {
6019 $fmid = (($fmax + $fmin) / 2);
6022 $text_height = $this->
getStringHeight(
$w, $txt, $reseth, $autopadding, $mc_padding, $border);
6023 if (($text_height == $maxh) OR (($text_height < $maxh) AND ($fmin >= ($fmax - 0.01)))) {
6025 } elseif ($text_height < $maxh) {
6034 if ($text_height < $maxh) {
6035 if ($valign ==
'M') {
6037 $this->y += (($maxh - $text_height) / 2);
6038 } elseif ($valign ==
'B') {
6040 $this->y += ($maxh - $text_height);
6044 $nl = $this->
Write($this->lasth, $txt,
'', 0, $align,
true, $stretch,
false,
true, $maxh, 0, $mc_margin);
6052 $this->y += $mc_padding[
'B'];
6059 $skip = ($endpage - $startpage);
6061 while ($tmpresth > 0) {
6066 if ($this->num_columns > 1) {
6078 if ($this->num_columns == 0) {
6079 $this->num_columns = 1;
6082 $border_start = $this->
getBorderMode($border, $position=
'start');
6083 $border_end = $this->
getBorderMode($border, $position=
'end');
6084 $border_middle = $this->
getBorderMode($border, $position=
'middle');
6089 if ($this->num_columns < 2) {
6095 if (
$page > $startpage) {
6096 if (($this->rtl) AND ($this->pagedim[
$page][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
6097 $this->x -= ($this->pagedim[
$page][
'orm'] - $this->pagedim[$startpage][
'orm']);
6098 } elseif ((!$this->rtl) AND ($this->pagedim[
$page][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
6099 $this->x += ($this->pagedim[
$page][
'olm'] - $this->pagedim[$startpage][
'olm']);
6102 if ($startpage == $endpage) {
6104 for ($column = $startcolumn; $column <= $endcolumn; ++$column) {
6107 $this->x -= $mc_margin[
'R'];
6109 $this->x += $mc_margin[
'L'];
6111 if ($startcolumn == $endcolumn) {
6113 $h = max(
$h, ($currentY - $oy));
6115 } elseif ($column == $startcolumn) {
6116 $cborder = $border_start;
6119 } elseif ($column == $endcolumn) {
6120 $cborder = $border_end;
6126 $cborder = $border_middle;
6130 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6132 } elseif (
$page == $startpage) {
6136 $this->x -= $mc_margin[
'R'];
6138 $this->x += $mc_margin[
'L'];
6140 if ($column == $startcolumn) {
6141 $cborder = $border_start;
6145 $cborder = $border_middle;
6149 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6151 } elseif (
$page == $endpage) {
6152 for ($column = 0; $column <= $endcolumn; ++$column) {
6155 $this->x -= $mc_margin[
'R'];
6157 $this->x += $mc_margin[
'L'];
6159 if ($column == $endcolumn) {
6161 $cborder = $border_end;
6168 $cborder = $border_middle;
6172 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6178 $this->x -= $mc_margin[
'R'];
6180 $this->x += $mc_margin[
'L'];
6182 $cborder = $border_middle;
6185 $ccode .= $this->
getCellCode(
$w,
$h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
6188 if ($cborder OR $fill) {
6190 if ($this->inxobj) {
6192 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
6193 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
6194 $pagemark = &$this->xobjects[
$this->xobjid][
'transfmrk'][$pagemarkkey];
6199 $pstart = substr($pagebuff, 0, $pagemark);
6200 $pend = substr($pagebuff, $pagemark);
6201 $this->xobjects[
$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
6202 $pagemark += strlen($ccode);
6204 if (end($this->transfmrk[$this->page]) !==
false) {
6205 $pagemarkkey = key($this->transfmrk[$this->page]);
6206 $pagemark = &$this->transfmrk[
$this->page][$pagemarkkey];
6207 } elseif ($this->InFooter) {
6213 $pstart = substr($pagebuff, 0, $pagemark);
6214 $pend = substr($pagebuff, $pagemark);
6216 $pagemark += strlen($ccode);
6221 $currentY = $this->
GetY();
6227 $this->
SetY($currentY + $mc_margin[
'B']);
6229 $this->
SetX(
$x +
$w + $mc_margin[
'L'] + $mc_margin[
'R']);
6235 $this->
SetX(
$x +
$w + $mc_margin[
'L'] + $mc_margin[
'R']);
6238 $this->cell_padding = $prev_cell_padding;
6239 $this->cell_margin = $prev_cell_margin;
6252 if ((!$this->opencell) OR empty($brd)) {
6258 if (is_string($brd)) {
6260 $slen = strlen($brd);
6262 for ($i = 0; $i < $slen; ++$i) {
6263 $newbrd[$brd{$i}] = array(
'cap' =>
'square',
'join' =>
'miter');
6267 foreach ($brd as $border => $style) {
6268 switch ($position) {
6270 if (strpos($border,
'B') !==
false) {
6272 $newkey = str_replace(
'B',
'', $border);
6273 if (strlen($newkey) > 0) {
6274 $brd[$newkey] = $style;
6276 unset($brd[$border]);
6281 if (strpos($border,
'B') !==
false) {
6283 $newkey = str_replace(
'B',
'', $border);
6284 if (strlen($newkey) > 0) {
6285 $brd[$newkey] = $style;
6287 unset($brd[$border]);
6290 if (strpos($border,
'T') !==
false) {
6292 $newkey = str_replace(
'T',
'', $border);
6293 if (strlen($newkey) > 0) {
6294 $brd[$newkey] = $style;
6296 unset($brd[$border]);
6301 if (strpos($border,
'T') !==
false) {
6303 $newkey = str_replace(
'T',
'', $border);
6304 if (strlen($newkey) > 0) {
6305 $brd[$newkey] = $style;
6307 unset($brd[$border]);
6329 public function getNumLines($txt,
$w=0, $reseth=
false, $autopadding=
true, $cellpadding=
'', $border=0) {
6337 if (is_array($cellpadding)) {
6338 $this->cell_padding = $cellpadding;
6348 $wmax =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
6357 $length = count($chars);
6358 $lastSeparator = -1;
6359 for ($i = 0; $i < $length; ++$i) {
6360 $charWidth = $charsWidth[$i];
6361 if (preg_match($this->re_spaces, $this->
unichr($chars[$i]))) {
6362 $lastSeparator = $i;
6364 if ((($sum + $charWidth) > $wmax) OR ($chars[$i] == 10)) {
6366 if ($lastSeparator != -1) {
6367 $i = $lastSeparator;
6368 $lastSeparator = -1;
6377 if ($chars[($length - 1)] == 10) {
6380 $this->cell_padding = $prev_cell_padding;
6381 $this->lasth = $prev_lasth;
6432 public function getStringHeight(
$w, $txt, $reseth=
false, $autopadding=
true, $cellpadding=
'', $border=0) {
6436 if (is_array($cellpadding)) {
6437 $this->cell_padding = $cellpadding;
6440 $lines = $this->
getNumLines($txt,
$w, $reseth, $autopadding, $cellpadding, $border);
6444 $height += ($this->cell_padding[
'T'] + $this->cell_padding[
'B']);
6446 $this->cell_padding = $prev_cell_padding;
6447 $this->lasth = $prev_lasth;
6469 public function Write(
$h, $txt, $link=
'', $fill=
false, $align=
'', $ln=
false, $stretch=0, $firstline=
false, $firstblock=
false, $maxh=0, $wadj=0, $margin=
'') {
6472 if (strlen($txt) == 0) {
6476 if ($margin ===
'') {
6481 $s = str_replace(
"\r",
'', $txt);
6483 if (preg_match($this->unicode->uni_RE_PATTERN_ARABIC, $s)) {
6489 if ($arabic OR ($this->tmprtl ==
'R') OR preg_match($this->unicode->uni_RE_PATTERN_RTL, $s)) {
6501 $nb = count($chars);
6503 $shy_replacement = 45;
6504 $shy_replacement_char = $this->
unichr($shy_replacement);
6506 $shy_replacement_width = $this->
GetCharWidth($shy_replacement);
6508 $maxy = $this->y + $maxh -
$h - $this->cell_padding[
'T'] - $this->cell_padding[
'B'];
6518 $wmax -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
6520 if ((!$firstline) AND (($chrwidth > $wmax) OR ($this->
GetCharWidth($chars[0]) > $wmax))) {
6525 $row_height = max(
$h, $this->FontSize * $this->cell_height_ratio);
6537 if (($maxh > 0) AND ($this->y >= $maxy) ) {
6544 if ($align ==
'J') {
6556 $tmparr = array_slice($chars, $j, ($i - $j));
6558 $tmparr = $this->
utf8Bidi($tmparr, $tmpstr, $this->tmprtl);
6563 $this->endlinex = $startx - $linew;
6565 $this->endlinex = $startx + $linew;
6577 if (!empty($tmpstr) OR ($this->y < ($this->PageBreakTrigger - $row_height))) {
6578 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $talign, $fill, $link, $stretch);
6582 $this->cell_padding = $tmpcellpadding;
6591 if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND (!$this->InFooter)) {
6594 $this->x -= $margin[
'R'];
6596 $this->x += $margin[
'L'];
6598 $this->lMargin += $margin[
'L'];
6599 $this->rMargin += $margin[
'R'];
6602 $wmax =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
6609 if (($c != 160) AND (($c == 173) OR preg_match($this->re_spaces, $this->
unichr($c)))) {
6616 $tmp_shy_replacement_width = 0;
6617 $tmp_shy_replacement_char =
'';
6619 $tmp_shy_replacement_width = $shy_replacement_width;
6620 $tmp_shy_replacement_char = $shy_replacement_char;
6634 if ((
$l > $wmax) OR (($c == 173) AND ((
$l + $tmp_shy_replacement_width) > $wmax)) ) {
6638 if (($this->rtl AND ($this->x <= ($this->w - $this->rMargin - $chrwidth)))
6639 OR ((!$this->rtl) AND ($this->x >= ($this->lMargin + $chrwidth)))) {
6651 $tmparr = array_slice($chars, $j, ($i - $j));
6653 $tmparr = $this->
utf8Bidi($tmparr, $tmpstr, $this->tmprtl);
6658 $this->endlinex = $startx - $linew;
6660 $this->endlinex = $startx + $linew;
6671 $this->
Cell(
$w,
$h, $tmpstr, 0, 1, $align, $fill, $link, $stretch);
6674 $this->cell_padding = $tmpcellpadding;
6682 if ($this->rtl AND (!$firstblock) AND ($sep < $i)) {
6689 $shy_width = $tmp_shy_replacement_width;
6691 $shy_char_left = $tmp_shy_replacement_char;
6692 $shy_char_right =
'';
6694 $shy_char_left =
'';
6695 $shy_char_right = $tmp_shy_replacement_char;
6699 $shy_char_left =
'';
6700 $shy_char_right =
'';
6705 $tmparr = array_slice($chars, $j, (($sep + $endspace) - $j));
6707 $tmparr = $this->
utf8Bidi($tmparr, $tmpstr, $this->tmprtl);
6712 $this->endlinex = $startx - $linew - $shy_width;
6714 $this->endlinex = $startx + $linew + $shy_width;
6726 $this->
Cell(
$w,
$h, $shy_char_left.$tmpstr.$shy_char_right, 0, 1, $align, $fill, $link, $stretch);
6730 $this->cell_padding = $tmpcellpadding;
6739 if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND (!$this->InFooter)) {
6742 $this->x -= $margin[
'R'];
6744 $this->x += $margin[
'L'];
6746 $this->lMargin += $margin[
'L'];
6747 $this->rMargin += $margin[
'R'];
6750 $wmax =
$w - $this->cell_padding[
'L'] - $this->cell_padding[
'R'];
6795 $tmparr = array_slice($chars, $j, ($nb - $j));
6797 $tmparr = $this->
utf8Bidi($tmparr, $tmpstr, $this->tmprtl);
6802 $this->endlinex = $startx - $linew;
6804 $this->endlinex = $startx + $linew;
6815 $this->
Cell(
$w,
$h, $tmpstr, 0, $ln, $align, $fill, $link, $stretch);
6818 $this->cell_padding = $tmpcellpadding;
6837 return ($this->x - $this->lMargin);
6839 return ($this->w - $this->rMargin - $this->x);
6852 if (strlen($start) == 0) {
6855 if (strlen($end) == 0) {
6856 $end = count($strarr);
6859 for ($i=$start; $i < $end; ++$i) {
6860 $string .= $this->
unichr($strarr[$i]);
6875 if (strlen($start) == 0) {
6878 if (strlen($end) == 0) {
6879 $end = count($uniarr);
6882 for ($i=$start; $i < $end; ++$i) {
6883 $string .= $uniarr[$i];
6896 return array_map(array($this,
'unichr'), $ta);
6908 if (!$this->isunicode) {
6910 } elseif ($c <= 0x7F) {
6913 } elseif ($c <= 0x7FF) {
6915 return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
6916 } elseif ($c <= 0xFFFF) {
6918 return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
6919 } elseif ($c <= 0x10FFFF) {
6921 return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
6936 if (isset($iminfo[
'mime']) AND !empty($iminfo[
'mime'])) {
6937 $mime = explode(
'/', $iminfo[
'mime']);
6938 if ((count($mime) > 1) AND ($mime[0] ==
'image') AND (!empty($mime[1]))) {
6939 $type = strtolower(trim($mime[1]));
6943 $fileinfo = pathinfo($imgfile);
6944 if (isset($fileinfo[
'extension']) AND (!$this->
empty_string($fileinfo[
'extension']))) {
6945 $type = strtolower(trim($fileinfo[
'extension']));
6948 if (
$type ==
'jpg') {
6966 if ($fitonpage OR $this->AutoPageBreak) {
6967 $ratio_wh = (
$w /
$h);
6968 if (
$h > ($this->PageBreakTrigger - $this->tMargin)) {
6970 $w = (
$h * $ratio_wh);
6977 $h = (
$w / $ratio_wh);
6989 $x += ($this->x - $prev_x);
6994 $ratio_wh = (
$w /
$h);
6996 $h = $this->PageBreakTrigger -
$y;
6997 $w = (
$h * $ratio_wh);
6999 if ((!$this->rtl) AND ((
$x +
$w) > ($this->w - $this->rMargin))) {
7000 $w = $this->w - $this->rMargin -
$x;
7001 $h = (
$w / $ratio_wh);
7002 } elseif (($this->rtl) AND ((
$x -
$w) < ($this->lMargin))) {
7004 $h = (
$w / $ratio_wh);
7041 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) {
7050 $cached_file =
false;
7052 $imsize = @getimagesize(
$file);
7053 if ($imsize === FALSE) {
7056 $imsize = @getimagesize(
$file);
7057 if ($imsize === FALSE) {
7058 if (function_exists(
'curl_init')) {
7061 curl_setopt($cs, CURLOPT_URL,
$file);
7062 curl_setopt($cs, CURLOPT_BINARYTRANSFER,
true);
7063 curl_setopt($cs, CURLOPT_FAILONERROR,
true);
7064 curl_setopt($cs, CURLOPT_RETURNTRANSFER,
true);
7065 curl_setopt($cs, CURLOPT_CONNECTTIMEOUT, 5);
7066 curl_setopt($cs, CURLOPT_TIMEOUT, 30);
7067 $imgdata = curl_exec($cs);
7069 if($imgdata !== FALSE) {
7072 $fp = fopen(
$file,
'w');
7073 fwrite($fp, $imgdata);
7076 $cached_file =
true;
7077 $imsize = @getimagesize(
$file);
7078 if ($imsize === FALSE) {
7080 $cached_file =
false;
7083 } elseif ((
$w > 0) AND (
$h > 0)) {
7087 $imsize = array($pw, $ph);
7091 if ($imsize === FALSE) {
7092 $this->
Error(
'[Image] Unable to get image: '.
$file);
7095 list($pixw, $pixh) = $imsize;
7097 if ((
$w <= 0) AND (
$h <= 0)) {
7101 } elseif (
$w <= 0) {
7102 $w =
$h * $pixw / $pixh;
7103 } elseif (
$h <= 0) {
7104 $h =
$w * $pixh / $pixw;
7105 } elseif ($fitbox AND (
$w > 0) AND (
$h > 0)) {
7107 if (((
$w * $pixh) / (
$h * $pixw)) < 1) {
7108 $h =
$w * $pixh / $pixw;
7110 $w =
$h * $pixw / $pixh;
7116 $neww = round(
$w * $this->k *
$dpi / $this->dpi);
7117 $newh = round(
$h * $this->k *
$dpi / $this->dpi);
7119 $newsize = ($neww * $newh);
7120 $pixsize = ($pixw * $pixh);
7121 if (intval($resize) == 2) {
7123 } elseif ($newsize >= $pixsize) {
7128 if (in_array(
$file, $this->imagekeys)) {
7133 $oldsize = ($info[
'w'] * $info[
'h']);
7134 if ((($oldsize < $newsize) AND ($resize)) OR (($oldsize < $pixsize) AND (!$resize))) {
7143 } elseif (
$type ==
'jpg') {
7149 $mtd =
'_parse'.$type;
7151 $gdfunction =
'imagecreatefrom'.$type;
7153 if ((method_exists($this, $mtd)) AND (!($resize AND function_exists($gdfunction)))) {
7155 $info = $this->$mtd(
$file);
7156 if ($info ==
'pngalpha') {
7157 return $this->
ImagePngAlpha(
$file,
$x,
$y, $pixw, $pixh,
$w,
$h,
'PNG', $link, $align, $resize,
$dpi, $palign);
7161 if (function_exists($gdfunction)) {
7165 $imgr = imagecreatetruecolor($neww, $newh);
7169 imagecopyresampled($imgr,
$img, 0, 0, 0, 0, $neww, $newh, $pixw, $pixh);
7171 $info = $this->
_toPNG($imgr);
7173 $info = $this->
_toJPEG($imgr);
7182 } elseif (extension_loaded(
'imagick')) {
7184 $img =
new Imagick();
7185 if (
$type ==
'SVG') {
7187 $svgimg = file_get_contents(
$file);
7190 if (preg_match(
'/<svg([^>]*)>/si', $svgimg, $regs)) {
7193 if (preg_match(
'/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
7195 $owu = sprintf(
'%.3F', ($ow *
$dpi / 72)).$this->pdfunit;
7196 $svgtag = preg_replace(
'/[\s]+width[\s]*=[\s]*"[^"]*"/si',
' width="'.$owu.
'"', $svgtag, 1);
7201 if (preg_match(
'/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
7203 $ohu = sprintf(
'%.3F', ($oh *
$dpi / 72)).$this->pdfunit;
7204 $svgtag = preg_replace(
'/[\s]+height[\s]*=[\s]*"[^"]*"/si',
' height="'.$ohu.
'"', $svgtag, 1);
7209 if (!preg_match(
'/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $svgtag, $tmp)) {
7210 $vbw = ($ow * $this->imgscale *
$this->k);
7211 $vbh = ($oh * $this->imgscale *
$this->k);
7212 $vbox = sprintf(
' viewBox="0 0 %.3F %.3F" ', $vbw, $vbh);
7213 $svgtag = $vbox.$svgtag;
7215 $svgimg = preg_replace(
'/<svg([^>]*)>/si',
'<svg'.$svgtag.
'>', $svgimg, 1);
7217 $img->readImageBlob($svgimg);
7222 $img->resizeImage($neww, $newh, 10, 1,
false);
7224 $img->setCompressionQuality($this->jpeg_quality);
7225 $img->setImageFormat(
'jpeg');
7227 $img->writeImage($tempname);
7235 if ($info ===
false) {
7242 $info[
'cs'] =
'DeviceGray';
7245 if (!in_array(
$file, $this->imagekeys)) {
7248 if ($imgmask !==
false) {
7249 $info[
'masked'] = $imgmask;
7259 $this->img_rb_y =
$y +
$h;
7262 if ($palign ==
'L') {
7264 } elseif ($palign ==
'C') {
7265 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
7266 } elseif ($palign ==
'R') {
7267 $ximg = $this->w - $this->rMargin -
$w;
7271 $this->img_rb_x = $ximg;
7273 if ($palign ==
'L') {
7275 } elseif ($palign ==
'C') {
7276 $ximg = ($this->w + $this->lMargin - $this->rMargin -
$w) / 2;
7277 } elseif ($palign ==
'R') {
7278 $ximg = $this->w - $this->rMargin -
$w;
7282 $this->img_rb_x = $ximg +
$w;
7284 if ($ismask OR $hidden) {
7289 $this->
_out(sprintf(
'q %.2F 0 0 %.2F %.2F %.2F cm /I%u Do Q', (
$w * $this->k), ($h * $this->k), $xkimg, (($this->h - (
$y + $h)) * $this->k), $info[
'i']));
7290 if (!empty($border)) {
7298 $this->
Cell(
$w, $h,
'', $border, 0,
'', 0,
'', 0,
true);
7303 $this->
Link($ximg,
$y,
$w, $h, $link, 0);
7313 $this->y =
$y + round($h/2);
7323 $this->
SetY($this->img_rb_y);
7331 if ($this->inxobj) {
7344 if(!defined(
'PHP_VERSION_ID')) {
7345 $version = PHP_VERSION;
7346 define(
'PHP_VERSION_ID', (($version{0} * 10000) + ($version{2} * 100) + $version{4}));
7348 if (PHP_VERSION_ID < 50300) {
7349 @set_magic_quotes_runtime($mqr);
7359 if(!defined(
'PHP_VERSION_ID')) {
7360 $version = PHP_VERSION;
7361 define(
'PHP_VERSION_ID', (($version{0} * 10000) + ($version{2} * 100) + $version{4}));
7363 if (PHP_VERSION_ID < 50300) {
7364 return @get_magic_quotes_runtime();
7379 imagejpeg($image, $tempname, $this->jpeg_quality);
7380 imagedestroy($image);
7398 imagepng($image, $tempname);
7399 imagedestroy($image);
7416 $tid = imagecolortransparent($image);
7418 $tcol = array(
'red' => 255,
'green' => 255,
'blue' => 255);
7421 $tcol = imagecolorsforindex($image, $tid);
7423 $tid = imagecolorallocate($new_image, $tcol[
'red'], $tcol[
'green'], $tcol[
'blue']);
7424 imagefill($new_image, 0, 0, $tid);
7425 imagecolortransparent($new_image, $tid);
7436 $a = getimagesize(
$file);
7438 $this->
Error(
'Missing or incorrect image file: '.
$file);
7443 if ((!isset($a[
'channels'])) OR ($a[
'channels'] == 3)) {
7444 $colspace =
'DeviceRGB';
7445 } elseif ($a[
'channels'] == 4) {
7446 $colspace =
'DeviceCMYK';
7448 $colspace =
'DeviceGray';
7450 $bpc = isset($a[
'bits']) ? $a[
'bits'] : 8;
7452 return array(
'w' => $a[0],
'h' => $a[1],
'cs' => $colspace,
'bpc' => $bpc,
'f' =>
'DCTDecode',
'data' =>
$data);
7464 $this->
Error(
'Can\'t open image file: '.
$file);
7467 if (fread(
$f, 8) != chr(137).
'PNG'.chr(13).chr(10).chr(26).chr(10)) {
7472 if (fread(
$f, 4) !=
'IHDR') {
7477 $bpc = ord(fread(
$f, 1));
7483 $ct = ord(fread(
$f, 1));
7485 $colspace =
'DeviceGray';
7486 } elseif ($ct == 2) {
7487 $colspace =
'DeviceRGB';
7488 } elseif ($ct == 3) {
7489 $colspace =
'Indexed';
7495 if (ord(fread(
$f, 1)) != 0) {
7500 if (ord(fread(
$f, 1)) != 0) {
7505 if (ord(fread(
$f, 1)) != 0) {
7511 $parms =
'/DecodeParms << /Predictor 15 /Colors '.($ct == 2 ? 3 : 1).
' /BitsPerComponent '.$bpc.
' /Columns '.
$w.
' >>';
7517 $n = $this->_freadint(
$f);
7519 if (
$type ==
'PLTE') {
7523 } elseif (
$type ==
'tRNS') {
7527 $trns = array(ord(substr(
$t, 1, 1)));
7528 } elseif ($ct == 2) {
7529 $trns = array(ord(substr(
$t, 1, 1)), ord(substr(
$t, 3, 1)), ord(substr(
$t, 5, 1)));
7531 $pos = strpos(
$t, chr(0));
7532 if (
$pos !==
false) {
7533 $trns = array(
$pos);
7537 } elseif (
$type ==
'IDAT') {
7541 } elseif (
$type ==
'IEND') {
7547 if (($colspace ==
'Indexed') AND (empty($pal))) {
7553 return array(
'w' =>
$w,
'h' =>
$h,
'cs' => $colspace,
'bpc' => $bpc,
'f' =>
'FlateDecode',
'parms' => $parms,
'pal' => $pal,
'trns' => $trns,
'data' =>
$data);
7568 if (
$data ===
false) {
7598 protected function ImagePngAlpha(
$file,
$x,
$y, $wpx, $hpx, $w, $h,
$type, $link, $align, $resize, $dpi, $palign) {
7603 if (extension_loaded(
'imagick')) {
7605 $img =
new Imagick();
7608 $imga =
$img->clone();
7610 $img->separateImageChannel(imagick::CHANNEL_ALPHA | imagick::CHANNEL_OPACITY | imagick::CHANNEL_MATTE);
7611 $img->negateImage(
true);
7612 $img->setImageFormat(
'png');
7613 $img->writeImage($tempfile_alpha);
7615 $imga->separateImageChannel(imagick::CHANNEL_ALL & ~(imagick::CHANNEL_ALPHA | imagick::CHANNEL_OPACITY | imagick::CHANNEL_MATTE));
7616 $imga->setImageFormat(
'png');
7617 $imga->writeImage($tempfile_plain);
7621 $imgalpha = imagecreate($wpx, $hpx);
7623 for ($c = 0; $c < 256; ++$c) {
7624 ImageColorAllocate($imgalpha, $c, $c, $c);
7627 for ($xpx = 0; $xpx < $wpx; ++$xpx) {
7628 for ($ypx = 0; $ypx < $hpx; ++$ypx) {
7629 $color = imagecolorat(
$img, $xpx, $ypx);
7630 $alpha = ($color >> 24);
7631 $alpha = (((127 - $alpha) / 127) * 255);
7632 $alpha = $this->getGDgamma($alpha);
7633 imagesetpixel($imgalpha, $xpx, $ypx, $alpha);
7636 imagepng($imgalpha, $tempfile_alpha);
7637 imagedestroy($imgalpha);
7639 $imgplain = imagecreatetruecolor($wpx, $hpx);
7640 imagecopy($imgplain,
$img, 0, 0, 0, 0, $wpx, $hpx);
7641 imagepng($imgplain, $tempfile_plain);
7642 imagedestroy($imgplain);
7645 $imgmask = $this->Image($tempfile_alpha,
$x,
$y, $w, $h,
'PNG',
'',
'', $resize, $dpi,
'',
true,
false);
7647 $this->Image($tempfile_plain,
$x,
$y, $w, $h,
$type, $link, $align, $resize, $dpi, $palign,
false, $imgmask);
7649 unlink($tempfile_alpha);
7650 unlink($tempfile_plain);
7660 return (pow(($v / 255), 2.2) * 255);
7672 public function Ln($h=
'', $cell=
false) {
7673 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'])) {
7679 $cellpadding = $this->cell_padding[
'R'];
7681 $cellpadding = $this->cell_padding[
'L'];
7687 $this->x = $this->w - $this->rMargin - $cellpadding;
7689 $this->x = $this->lMargin + $cellpadding;
7691 if (is_string($h)) {
7692 $this->y += $this->lasth;
7696 $this->newline =
true;
7710 return ($this->w - $this->x);
7748 if (!$rtloff AND $this->rtl) {
7750 $this->x = $this->w -
$x;
7758 $this->x = $this->w +
$x;
7764 if ($this->x > $this->w) {
7765 $this->x = $this->w;
7779 public function SetY(
$y, $resetx=
true, $rtloff=
false) {
7782 if (!$rtloff AND $this->rtl) {
7783 $this->x = $this->w - $this->rMargin;
7785 $this->x = $this->lMargin;
7791 $this->y = $this->h +
$y;
7796 if ($this->y > $this->h) {
7797 $this->y = $this->h;
7812 $this->SetY(
$y,
false, $rtloff);
7813 $this->SetX(
$x, $rtloff);
7829 if ($this->state < 3) {
7833 if (is_bool($dest)) {
7834 $dest = $dest ?
'D' :
'F';
7836 $dest = strtoupper($dest);
7837 if ($dest{0} !=
'F') {
7839 $name = preg_replace(
'/[^a-zA-Z0-9_\.-]/',
'',
$name);
7844 $pdfdoc = $this->getBuffer();
7846 $pdfdoc = substr($pdfdoc, 0, -1);
7848 if (isset($this->diskcache) AND $this->diskcache) {
7850 unlink($this->buffer);
7852 unset($this->buffer);
7854 $byterange_string_len = strlen($this->byterange_string);
7856 $byte_range = array();
7858 $byte_range[1] = strpos($pdfdoc, $this->byterange_string) + $byterange_string_len + 10;
7859 $byte_range[2] = $byte_range[1] + $this->signature_max_length + 2;
7860 $byte_range[3] = strlen($pdfdoc) - $byte_range[2];
7861 $pdfdoc = substr($pdfdoc, 0, $byte_range[1]).substr($pdfdoc, $byte_range[2]);
7863 $byterange = sprintf(
'/ByteRange[0 %u %u %u]', $byte_range[1], $byte_range[2], $byte_range[3]);
7864 $byterange .= str_repeat(
' ', ($byterange_string_len - strlen($byterange)));
7865 $pdfdoc = str_replace($this->byterange_string, $byterange, $pdfdoc);
7868 $f = fopen($tempdoc,
'wb');
7870 $this->Error(
'Unable to create temporary file: '.$tempdoc);
7872 $pdfdoc_length = strlen($pdfdoc);
7873 fwrite(
$f, $pdfdoc, $pdfdoc_length);
7877 if (empty($this->signature_data[
'extracerts'])) {
7878 openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data[
'signcert'], array($this->signature_data[
'privkey'], $this->signature_data[
'password']), array(), PKCS7_BINARY | PKCS7_DETACHED);
7880 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']);
7884 $signature = file_get_contents($tempsign);
7887 $signature = substr($signature, $pdfdoc_length);
7888 $signature = substr($signature, (strpos($signature,
"%%EOF\n\n------") + 13));
7889 $tmparr = explode(
"\n\n", $signature);
7890 $signature = $tmparr[1];
7893 $signature = base64_decode(trim($signature));
7895 $signature = current(unpack(
'H*', $signature));
7896 $signature = str_pad($signature, $this->signature_max_length,
'0');
7898 $pdfdoc = substr($pdfdoc, 0, $byte_range[1]).
'<'.$signature.
'>'.substr($pdfdoc, $byte_range[1]);
7899 $this->diskcache =
false;
7900 $this->buffer = &$pdfdoc;
7901 $this->bufferlen = strlen($pdfdoc);
7906 if (ob_get_contents()) {
7907 $this->Error(
'Some data has already been output, can\'t send PDF file');
7909 if (php_sapi_name() !=
'cli') {
7911 header(
'Content-Type: application/pdf');
7912 if (headers_sent()) {
7913 $this->Error(
'Some data has already been output to browser, can\'t send PDF file');
7915 header(
'Cache-Control: public, must-revalidate, max-age=0');
7916 header(
'Pragma: public');
7917 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7918 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7919 header(
'Content-Length: '.$this->bufferlen);
7920 header(
'Content-Disposition: inline; filename="'.basename(
$name).
'";');
7922 echo $this->getBuffer();
7927 if (ob_get_contents()) {
7928 $this->Error(
'Some data has already been output, can\'t send PDF file');
7930 header(
'Content-Description: File Transfer');
7931 if (headers_sent()) {
7932 $this->Error(
'Some data has already been output to browser, can\'t send PDF file');
7934 header(
'Cache-Control: public, must-revalidate, max-age=0');
7935 header(
'Pragma: public');
7936 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7937 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7939 header(
'Content-Type: application/force-download');
7940 header(
'Content-Type: application/octet-stream',
false);
7941 header(
'Content-Type: application/download',
false);
7942 header(
'Content-Type: application/pdf',
false);
7944 header(
'Content-Disposition: attachment; filename="'.basename(
$name).
'";');
7945 header(
'Content-Transfer-Encoding: binary');
7946 header(
'Content-Length: '.$this->bufferlen);
7947 echo $this->getBuffer();
7954 if ($this->diskcache) {
7955 copy($this->buffer,
$name);
7959 $this->Error(
'Unable to create output file: '.
$name);
7961 fwrite(
$f, $this->getBuffer(), $this->bufferlen);
7964 if ($dest ==
'FI') {
7966 header(
'Content-Type: application/pdf');
7967 header(
'Cache-Control: public, must-revalidate, max-age=0');
7968 header(
'Pragma: public');
7969 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7970 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7971 header(
'Content-Length: '.filesize(
$name));
7972 header(
'Content-Disposition: inline; filename="'.basename(
$name).
'";');
7974 echo file_get_contents(
$name);
7975 } elseif ($dest ==
'FD') {
7977 if (ob_get_contents()) {
7978 $this->Error(
'Some data has already been output, can\'t send PDF file');
7980 header(
'Content-Description: File Transfer');
7981 if (headers_sent()) {
7982 $this->Error(
'Some data has already been output to browser, can\'t send PDF file');
7984 header(
'Cache-Control: public, must-revalidate, max-age=0');
7985 header(
'Pragma: public');
7986 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
7987 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
7989 header(
'Content-Type: application/force-download');
7990 header(
'Content-Type: application/octet-stream',
false);
7991 header(
'Content-Type: application/download',
false);
7992 header(
'Content-Type: application/pdf',
false);
7994 header(
'Content-Disposition: attachment; filename="'.basename(
$name).
'";');
7995 header(
'Content-Transfer-Encoding: binary');
7996 header(
'Content-Length: '.filesize(
$name));
7998 echo file_get_contents(
$name);
8004 return $this->getBuffer();
8007 $this->Error(
'Incorrect output destination: '.$dest);
8020 public function _destroy($destroyall=
false, $preserve_objcopy=
false) {
8021 if ($destroyall AND isset($this->diskcache) AND $this->diskcache AND (!$preserve_objcopy) AND (!$this->empty_string($this->buffer))) {
8023 unlink($this->buffer);
8025 foreach (array_keys(get_object_vars($this)) as $val) {
8026 if ($destroyall OR (
8027 ($val !=
'internal_encoding')
8028 AND ($val !=
'state')
8029 AND ($val !=
'bufferlen')
8030 AND ($val !=
'buffer')
8031 AND ($val !=
'diskcache')
8032 AND ($val !=
'sign')
8033 AND ($val !=
'signature_data')
8034 AND ($val !=
'signature_max_length')
8035 AND ($val !=
'byterange_string')
8037 if ((!$preserve_objcopy OR ($val !=
'objcopy')) AND isset($this->$val)) {
8051 $this->Error(
'Don\'t alter the locale before including class file');
8054 if (sprintf(
'%.1F', 1.0) !=
'1.0') {
8055 setlocale(LC_NUMERIC,
'C');
8065 if (!defined(
'K_PATH_FONTS') AND is_dir(dirname(__FILE__).
'/fonts')) {
8066 define(
'K_PATH_FONTS', dirname(__FILE__).
'/fonts/');
8076 $nb = $this->numpages;
8077 if (!empty($this->AliasNbPages)) {
8078 $nbs = $this->formatPageNumber($nb);
8079 $nbu = $this->UTF8ToUTF16BE($nbs,
false);
8080 $alias_a = $this->_escape($this->AliasNbPages);
8081 $alias_au = $this->_escape(
'{'.$this->AliasNbPages.
'}');
8082 if ($this->isunicode) {
8083 $alias_b = $this->_escape($this->UTF8ToLatin1($this->AliasNbPages));
8084 $alias_bu = $this->_escape($this->UTF8ToLatin1(
'{'.$this->AliasNbPages.
'}'));
8085 $alias_c = $this->_escape($this->utf8StrRev($this->AliasNbPages,
false, $this->tmprtl));
8086 $alias_cu = $this->_escape($this->utf8StrRev(
'{'.$this->AliasNbPages.
'}',
false, $this->tmprtl));
8089 if (!empty($this->AliasNumPage)) {
8090 $alias_pa = $this->_escape($this->AliasNumPage);
8091 $alias_pau = $this->_escape(
'{'.$this->AliasNumPage.
'}');
8092 if ($this->isunicode) {
8093 $alias_pb = $this->_escape($this->UTF8ToLatin1($this->AliasNumPage));
8094 $alias_pbu = $this->_escape($this->UTF8ToLatin1(
'{'.$this->AliasNumPage.
'}'));
8095 $alias_pc = $this->_escape($this->utf8StrRev($this->AliasNumPage,
false, $this->tmprtl));
8096 $alias_pcu = $this->_escape($this->utf8StrRev(
'{'.$this->AliasNumPage.
'}',
false, $this->tmprtl));
8100 $filter = ($this->compress) ?
'/Filter /FlateDecode ' :
'';
8101 for ($n=1; $n <= $nb; ++$n) {
8102 $temppage = $this->getPageBuffer($n);
8103 if (!empty($this->pagegroups)) {
8104 if(isset($this->newpagegroup[$n])) {
8108 foreach ($this->pagegroups as $k => $v) {
8110 $vs = $this->formatPageNumber($v);
8111 $vu = $this->UTF8ToUTF16BE($vs,
false);
8112 $alias_ga = $this->_escape($k);
8113 $alias_gau = $this->_escape(
'{'.$k.
'}');
8114 if ($this->isunicode) {
8115 $alias_gb = $this->_escape($this->UTF8ToLatin1($k));
8116 $alias_gbu = $this->_escape($this->UTF8ToLatin1(
'{'.$k.
'}'));
8117 $alias_gc = $this->_escape($this->utf8StrRev($k,
false, $this->tmprtl));
8118 $alias_gcu = $this->_escape($this->utf8StrRev(
'{'.$k.
'}',
false, $this->tmprtl));
8120 $temppage = str_replace($alias_gau, $vu, $temppage);
8121 if ($this->isunicode) {
8122 $temppage = str_replace($alias_gbu, $vu, $temppage);
8123 $temppage = str_replace($alias_gcu, $vu, $temppage);
8124 $temppage = str_replace($alias_gb, $vs, $temppage);
8125 $temppage = str_replace($alias_gc, $vs, $temppage);
8127 $temppage = str_replace($alias_ga, $vs, $temppage);
8129 $pvs = $this->formatPageNumber($pagegroupnum);
8130 $pvu = $this->UTF8ToUTF16BE($pvs,
false);
8131 $pk = str_replace(
'{nb',
'{pnb', $k);
8132 $alias_pga = $this->_escape($pk);
8133 $alias_pgau = $this->_escape(
'{'.$pk.
'}');
8134 if ($this->isunicode) {
8135 $alias_pgb = $this->_escape($this->UTF8ToLatin1($pk));
8136 $alias_pgbu = $this->_escape($this->UTF8ToLatin1(
'{'.$pk.
'}'));
8137 $alias_pgc = $this->_escape($this->utf8StrRev($pk,
false, $this->tmprtl));
8138 $alias_pgcu = $this->_escape($this->utf8StrRev(
'{'.$pk.
'}',
false, $this->tmprtl));
8140 $temppage = str_replace($alias_pgau, $pvu, $temppage);
8141 if ($this->isunicode) {
8142 $temppage = str_replace($alias_pgbu, $pvu, $temppage);
8143 $temppage = str_replace($alias_pgcu, $pvu, $temppage);
8144 $temppage = str_replace($alias_pgb, $pvs, $temppage);
8145 $temppage = str_replace($alias_pgc, $pvs, $temppage);
8147 $temppage = str_replace($alias_pga, $pvs, $temppage);
8150 if (!empty($this->AliasNbPages)) {
8152 $temppage = str_replace($alias_au, $nbu, $temppage);
8153 if ($this->isunicode) {
8154 $temppage = str_replace($alias_bu, $nbu, $temppage);
8155 $temppage = str_replace($alias_cu, $nbu, $temppage);
8156 $temppage = str_replace($alias_b, $nbs, $temppage);
8157 $temppage = str_replace($alias_c, $nbs, $temppage);
8159 $temppage = str_replace($alias_a, $nbs, $temppage);
8161 if (!empty($this->AliasNumPage)) {
8163 $pnbs = $this->formatPageNumber($n);
8164 $pnbu = $this->UTF8ToUTF16BE($pnbs,
false);
8165 $temppage = str_replace($alias_pau, $pnbu, $temppage);
8166 if ($this->isunicode) {
8167 $temppage = str_replace($alias_pbu, $pnbu, $temppage);
8168 $temppage = str_replace($alias_pcu, $pnbu, $temppage);
8169 $temppage = str_replace($alias_pb, $pnbs, $temppage);
8170 $temppage = str_replace($alias_pc, $pnbs, $temppage);
8172 $temppage = str_replace($alias_pa, $pnbs, $temppage);
8174 $temppage = str_replace($this->epsmarker,
'', $temppage);
8176 $this->page_obj_id[$n] = $this->_newobj();
8178 $out .=
' /Type /Page';
8179 $out .=
' /Parent 1 0 R';
8180 $out .=
' /LastModified '.$this->_datestring();
8181 $out .=
' /Resources 2 0 R';
8182 $boxes = array(
'MediaBox',
'CropBox',
'BleedBox',
'TrimBox',
'ArtBox');
8183 foreach ($boxes as $box) {
8185 $out .= sprintf(
' [%.2F %.2F %.2F %.2F]', $this->pagedim[$n][$box][
'llx'], $this->pagedim[$n][$box][
'lly'], $this->pagedim[$n][$box][
'urx'], $this->pagedim[$n][$box][
'ury']);
8187 if (isset($this->pagedim[$n][
'BoxColorInfo']) AND !empty($this->pagedim[$n][
'BoxColorInfo'])) {
8188 $out .=
' /BoxColorInfo <<';
8189 foreach ($boxes as $box) {
8190 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box])) {
8191 $out .=
' /'.$box.
' <<';
8192 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'C'])) {
8193 $color = $this->pagedim[$n][
'BoxColorInfo'][$box][
'C'];
8195 $out .= sprintf(
' %.3F %.3F %.3F', $color[0]/255, $color[1]/255, $color[2]/255);
8198 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'W'])) {
8199 $out .=
' /W '.($this->pagedim[$n][
'BoxColorInfo'][$box][
'W'] * $this->k);
8201 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'S'])) {
8202 $out .=
' /S /'.$this->pagedim[$n][
'BoxColorInfo'][$box][
'S'];
8204 if (isset($this->pagedim[$n][
'BoxColorInfo'][$box][
'D'])) {
8205 $dashes = $this->pagedim[$n][
'BoxColorInfo'][$box][
'D'];
8207 foreach ($dashes as $dash) {
8208 $out .= sprintf(
' %.3F', ($dash * $this->k));
8217 $out .=
' /Contents '.($this->n + 1).
' 0 R';
8218 $out .=
' /Rotate '.$this->pagedim[$n][
'Rotate'];
8219 $out .=
' /Group << /Type /Group /S /Transparency /CS /DeviceRGB >>';
8220 if (isset($this->pagedim[$n][
'trans']) AND !empty($this->pagedim[$n][
'trans'])) {
8222 if (isset($this->pagedim[$n][
'trans'][
'Dur'])) {
8223 $out .=
' /Dur '.$this->pagedim[$n][
'trans'][
'Dur'];
8225 $out .=
' /Trans <<';
8226 $out .=
' /Type /Trans';
8227 if (isset($this->pagedim[$n][
'trans'][
'S'])) {
8228 $out .=
' /S /'.$this->pagedim[$n][
'trans'][
'S'];
8230 if (isset($this->pagedim[$n][
'trans'][
'D'])) {
8231 $out .=
' /D '.$this->pagedim[$n][
'trans'][
'D'];
8233 if (isset($this->pagedim[$n][
'trans'][
'Dm'])) {
8234 $out .=
' /Dm /'.$this->pagedim[$n][
'trans'][
'Dm'];
8236 if (isset($this->pagedim[$n][
'trans'][
'M'])) {
8237 $out .=
' /M /'.$this->pagedim[$n][
'trans'][
'M'];
8239 if (isset($this->pagedim[$n][
'trans'][
'Di'])) {
8240 $out .=
' /Di '.$this->pagedim[$n][
'trans'][
'Di'];
8242 if (isset($this->pagedim[$n][
'trans'][
'SS'])) {
8243 $out .=
' /SS '.$this->pagedim[$n][
'trans'][
'SS'];
8245 if (isset($this->pagedim[$n][
'trans'][
'B'])) {
8246 $out .=
' /B '.$this->pagedim[$n][
'trans'][
'B'];
8250 $out .= $this->_getannotsrefs($n);
8251 $out .=
' /PZ '.$this->pagedim[$n][
'PZ'];
8253 $out .=
"\n".
'endobj';
8256 $p = ($this->compress) ? gzcompress($temppage) : $temppage;
8258 $p = $this->_getrawstream($p);
8259 $this->_out(
'<<'.$filter.
'/Length '.strlen($p).
'>> stream'.
"\n".$p.
"\n".
'endstream'.
"\n".
'endobj');
8260 if ($this->diskcache) {
8262 unlink($this->pages[$n]);
8266 $out = $this->_getobj(1).
"\n";
8267 $out .=
'<< /Type /Pages /Kids [';
8268 foreach($this->page_obj_id as $page_obj) {
8269 $out .=
' '.$page_obj.
' 0 R';
8271 $out .=
' ] /Count '.$nb.
' >>';
8272 $out .=
"\n".
'endobj';
8285 $this->_out($this->_getannotsrefs($n));
8297 if (!(isset($this->PageAnnots[$n]) OR ($this->sign AND isset($this->signature_data[
'cert_type'])))) {
8300 $out =
' /Annots [';
8301 if (isset($this->PageAnnots[$n])) {
8302 foreach ($this->PageAnnots[$n] as $key => $val) {
8303 if (!in_array($val[
'n'], $this->radio_groups)) {
8304 $out .=
' '.$val[
'n'].
' 0 R';
8308 if (isset($this->radiobutton_groups[$n])) {
8309 foreach ($this->radiobutton_groups[$n] as $key =>
$data) {
8310 if (isset(
$data[
'n'])) {
8311 $out .=
' '.$data[
'n'].
' 0 R';
8316 if ($this->sign AND ($n == $this->signature_appearance[
'page']) AND isset($this->signature_data[
'cert_type'])) {
8318 $out .=
' '.$this->sig_obj_id.
' 0 R';
8334 for ($n=1; $n <= $this->numpages; ++$n) {
8335 if (isset($this->PageAnnots[$n])) {
8337 foreach ($this->PageAnnots[$n] as $key => $pl) {
8338 $annot_obj_id = $this->PageAnnots[$n][$key][
'n'];
8340 if (isset($this->radiobutton_groups[$n][$pl[
'txt']]) AND is_array($this->radiobutton_groups[$n][$pl[
'txt']])) {
8341 $radio_button_obj_id = $this->radiobutton_groups[$n][$pl[
'txt']][
'n'];
8343 $annots .=
' /Type /Annot';
8344 $annots .=
' /Subtype /Widget';
8345 $annots .=
' /Rect [0 0 0 0]';
8346 $annots .=
' /T '.$this->_datastring($pl[
'txt'], $radio_button_obj_id);
8347 $annots .=
' /FT /Btn';
8348 $annots .=
' /Ff 49152';
8349 $annots .=
' /Kids [';
8350 foreach ($this->radiobutton_groups[$n][$pl[
'txt']] as $key =>
$data) {
8352 $annots .=
' '.$data[
'kid'].
' 0 R';
8353 if (
$data[
'def'] !==
'Off') {
8354 $defval =
$data[
'def'];
8359 if (isset($defval)) {
8360 $annots .=
' /V /'.$defval;
8363 $this->_out($this->_getobj($radio_button_obj_id).
"\n".$annots.
"\n".
'endobj');
8364 $this->form_obj_id[] = $radio_button_obj_id;
8366 $this->radiobutton_groups[$n][$pl[
'txt']] = $radio_button_obj_id;
8369 $pl[
'opt'] = array_change_key_case($pl[
'opt'], CASE_LOWER);
8370 $a = $pl[
'x'] * $this->k;
8371 $b = $this->pagedim[$n][
'h'] - (($pl[
'y'] + $pl[
'h']) * $this->k);
8372 $c = $pl[
'w'] * $this->k;
8373 $d = $pl[
'h'] * $this->k;
8374 $rect = sprintf(
'%.2F %.2F %.2F %.2F', $a, $b, $a+$c, $b+
$d);
8376 $annots =
'<</Type /Annot';
8377 $annots .=
' /Subtype /'.$pl[
'opt'][
'subtype'];
8378 $annots .=
' /Rect ['.$rect.
']';
8379 $ft = array(
'Btn',
'Tx',
'Ch',
'Sig');
8380 if (isset($pl[
'opt'][
'ft']) AND in_array($pl[
'opt'][
'ft'], $ft)) {
8381 $annots .=
' /FT /'.$pl[
'opt'][
'ft'];
8384 $annots .=
' /Contents '.$this->_textstring($pl[
'txt'], $annot_obj_id);
8385 $annots .=
' /P '.$this->page_obj_id[$n].
' 0 R';
8386 $annots .=
' /NM '.$this->_datastring(sprintf(
'%04u-%04u', $n, $key), $annot_obj_id);
8387 $annots .=
' /M '.$this->_datestring($annot_obj_id);
8388 if (isset($pl[
'opt'][
'f'])) {
8390 if (is_array($pl[
'opt'][
'f'])) {
8391 foreach ($pl[
'opt'][
'f'] as
$f) {
8392 switch (strtolower($f)) {
8425 case 'togglenoview': {
8429 case 'lockedcontents': {
8439 $val = intval($pl[
'opt'][
'f']);
8441 $annots .=
' /F '.intval($val);
8443 if (isset($pl[
'opt'][
'as']) AND is_string($pl[
'opt'][
'as'])) {
8444 $annots .=
' /AS /'.$pl[
'opt'][
'as'];
8446 if (isset($pl[
'opt'][
'ap'])) {
8448 $annots .=
' /AP <<';
8449 if (is_array($pl[
'opt'][
'ap'])) {
8450 foreach ($pl[
'opt'][
'ap'] as $apmode => $apdef) {
8452 $annots .=
' /'.strtoupper($apmode);
8453 if (is_array($apdef)) {
8455 foreach ($apdef as $apstate => $stream) {
8457 $apsobjid = $this->_putAPXObject($c,
$d, $stream);
8458 $annots .=
' /'.$apstate.
' '.$apsobjid.
' 0 R';
8463 $apsobjid = $this->_putAPXObject($c,
$d, $apdef);
8464 $annots .=
' '.$apsobjid.
' 0 R';
8468 $annots .= $pl[
'opt'][
'ap'];
8472 if (isset($pl[
'opt'][
'bs']) AND (is_array($pl[
'opt'][
'bs']))) {
8473 $annots .=
' /BS <<';
8474 $annots .=
' /Type /Border';
8475 if (isset($pl[
'opt'][
'bs'][
'w'])) {
8476 $annots .=
' /W '.intval($pl[
'opt'][
'bs'][
'w']);
8478 $bstyles = array(
'S',
'D',
'B',
'I',
'U');
8479 if (isset($pl[
'opt'][
'bs'][
's']) AND in_array($pl[
'opt'][
'bs'][
's'], $bstyles)) {
8480 $annots .=
' /S /'.$pl[
'opt'][
'bs'][
's'];
8482 if (isset($pl[
'opt'][
'bs'][
'd']) AND (is_array($pl[
'opt'][
'bs'][
'd']))) {
8484 foreach ($pl[
'opt'][
'bs'][
'd'] as $cord) {
8485 $annots .=
' '.intval($cord);
8491 $annots .=
' /Border [';
8492 if (isset($pl[
'opt'][
'border']) AND (count($pl[
'opt'][
'border']) >= 3)) {
8493 $annots .= intval($pl[
'opt'][
'border'][0]).
' ';
8494 $annots .= intval($pl[
'opt'][
'border'][1]).
' ';
8495 $annots .= intval($pl[
'opt'][
'border'][2]);
8496 if (isset($pl[
'opt'][
'border'][3]) AND is_array($pl[
'opt'][
'border'][3])) {
8498 foreach ($pl[
'opt'][
'border'][3] as $dash) {
8499 $annots .= intval($dash).
' ';
8508 if (isset($pl[
'opt'][
'be']) AND (is_array($pl[
'opt'][
'be']))) {
8509 $annots .=
' /BE <<';
8510 $bstyles = array(
'S',
'C');
8511 if (isset($pl[
'opt'][
'be'][
's']) AND in_array($pl[
'opt'][
'be'][
's'], $markups)) {
8512 $annots .=
' /S /'.$pl[
'opt'][
'bs'][
's'];
8514 $annots .=
' /S /S';
8516 if (isset($pl[
'opt'][
'be'][
'i']) AND ($pl[
'opt'][
'be'][
'i'] >= 0) AND ($pl[
'opt'][
'be'][
'i'] <= 2)) {
8517 $annots .=
' /I '.sprintf(
' %.4F', $pl[
'opt'][
'be'][
'i']);
8521 if (isset($pl[
'opt'][
'c']) AND (is_array($pl[
'opt'][
'c'])) AND !empty($pl[
'opt'][
'c'])) {
8523 foreach ($pl[
'opt'][
'c'] as $col) {
8524 $col = intval($col);
8525 $color = $col <= 0 ? 0 : ($col >= 255 ? 1 : $col / 255);
8526 $annots .= sprintf(
' %.4F', $color);
8532 $markups = array(
'text',
'freetext',
'line',
'square',
'circle',
'polygon',
'polyline',
'highlight',
'underline',
'squiggly',
'strikeout',
'stamp',
'caret',
'ink',
'fileattachment',
'sound');
8533 if (in_array(strtolower($pl[
'opt'][
'subtype']), $markups)) {
8535 if (isset($pl[
'opt'][
't']) AND is_string($pl[
'opt'][
't'])) {
8536 $annots .=
' /T '.$this->_textstring($pl[
'opt'][
't'], $annot_obj_id);
8539 if (isset($pl[
'opt'][
'ca'])) {
8540 $annots .=
' /CA '.sprintf(
'%.4F', floatval($pl[
'opt'][
'ca']));
8542 if (isset($pl[
'opt'][
'rc'])) {
8543 $annots .=
' /RC '.$this->_textstring($pl[
'opt'][
'rc'], $annot_obj_id);
8545 $annots .=
' /CreationDate '.$this->_datestring($annot_obj_id);
8547 if (isset($pl[
'opt'][
'subj'])) {
8548 $annots .=
' /Subj '.$this->_textstring($pl[
'opt'][
'subj'], $annot_obj_id);
8554 $lineendings = array(
'Square',
'Circle',
'Diamond',
'OpenArrow',
'ClosedArrow',
'None',
'Butt',
'ROpenArrow',
'RClosedArrow',
'Slash');
8556 switch (strtolower($pl[
'opt'][
'subtype'])) {
8558 if (isset($pl[
'opt'][
'open'])) {
8559 $annots .=
' /Open '. (strtolower($pl[
'opt'][
'open']) ==
'true' ?
'true' :
'false');
8561 $iconsapp = array(
'Comment',
'Help',
'Insert',
'Key',
'NewParagraph',
'Note',
'Paragraph');
8562 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8563 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8565 $annots .=
' /Name /Note';
8567 $statemodels = array(
'Marked',
'Review');
8568 if (isset($pl[
'opt'][
'statemodel']) AND in_array($pl[
'opt'][
'statemodel'], $statemodels)) {
8569 $annots .=
' /StateModel /'.$pl[
'opt'][
'statemodel'];
8571 $pl[
'opt'][
'statemodel'] =
'Marked';
8572 $annots .=
' /StateModel /'.$pl[
'opt'][
'statemodel'];
8574 if ($pl[
'opt'][
'statemodel'] ==
'Marked') {
8575 $states = array(
'Accepted',
'Unmarked');
8577 $states = array(
'Accepted',
'Rejected',
'Cancelled',
'Completed',
'None');
8579 if (isset($pl[
'opt'][
'state']) AND in_array($pl[
'opt'][
'state'], $states)) {
8580 $annots .=
' /State /'.$pl[
'opt'][
'state'];
8582 if ($pl[
'opt'][
'statemodel'] ==
'Marked') {
8583 $annots .=
' /State /Unmarked';
8585 $annots .=
' /State /None';
8591 if(is_string($pl[
'txt'])) {
8593 $annots .=
' /A <</S /URI /URI '.$this->_datastring($this->unhtmlentities($pl[
'txt']), $annot_obj_id).
'>>';
8596 $l = $this->links[$pl[
'txt']];
8597 $annots .= sprintf(
' /Dest [%u 0 R /XYZ 0 %.2F null]', $this->page_obj_id[(
$l[0])], ($this->pagedim[
$l[0]][
'h'] - (
$l[1] * $this->k)));
8599 $hmodes = array(
'N',
'I',
'O',
'P');
8600 if (isset($pl[
'opt'][
'h']) AND in_array($pl[
'opt'][
'h'], $hmodes)) {
8601 $annots .=
' /H /'.$pl[
'opt'][
'h'];
8603 $annots .=
' /H /I';
8610 if (isset($pl[
'opt'][
'da']) AND !empty($pl[
'opt'][
'da'])) {
8611 $annots .=
' /DA ('.$pl[
'opt'][
'da'].
')';
8613 if (isset($pl[
'opt'][
'q']) AND ($pl[
'opt'][
'q'] >= 0) AND ($pl[
'opt'][
'q'] <= 2)) {
8614 $annots .=
' /Q '.intval($pl[
'opt'][
'q']);
8616 if (isset($pl[
'opt'][
'rc'])) {
8617 $annots .=
' /RC '.$this->_textstring($pl[
'opt'][
'rc'], $annot_obj_id);
8619 if (isset($pl[
'opt'][
'ds'])) {
8620 $annots .=
' /DS '.$this->_textstring($pl[
'opt'][
'ds'], $annot_obj_id);
8622 if (isset($pl[
'opt'][
'cl']) AND is_array($pl[
'opt'][
'cl'])) {
8623 $annots .=
' /CL [';
8624 foreach ($pl[
'opt'][
'cl'] as $cl) {
8625 $annots .= sprintf(
'%.4F ', $cl * $this->k);
8629 $tfit = array(
'FreeText',
'FreeTextCallout',
'FreeTextTypeWriter');
8630 if (isset($pl[
'opt'][
'it']) AND in_array($pl[
'opt'][
'it'], $tfit)) {
8631 $annots .=
' /IT /'.$pl[
'opt'][
'it'];
8633 if (isset($pl[
'opt'][
'rd']) AND is_array($pl[
'opt'][
'rd'])) {
8634 $l = $pl[
'opt'][
'rd'][0] * $this->k;
8635 $r = $pl[
'opt'][
'rd'][1] * $this->k;
8636 $t = $pl[
'opt'][
'rd'][2] * $this->k;
8637 $b = $pl[
'opt'][
'rd'][3] * $this->k;
8638 $annots .=
' /RD ['.sprintf(
'%.2F %.2F %.2F %.2F',
$l, $r,
$t, $b).
']';
8640 if (isset($pl[
'opt'][
'le']) AND in_array($pl[
'opt'][
'le'], $lineendings)) {
8641 $annots .=
' /LE /'.$pl[
'opt'][
'le'];
8684 case 'fileattachment': {
8685 if (!isset($pl[
'opt'][
'fs'])) {
8689 if (isset($this->embeddedfiles[
$filename][
'n'])) {
8690 $annots .=
' /FS <</Type /Filespec /F '.$this->_datastring($filename, $annot_obj_id).
' /EF <</F '.$this->embeddedfiles[
$filename][
'n'].
' 0 R>> >>';
8691 $iconsapp = array(
'Graph',
'Paperclip',
'PushPin',
'Tag');
8692 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8693 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8695 $annots .=
' /Name /PushPin';
8701 if (!isset($pl[
'opt'][
'fs'])) {
8705 if (isset($this->embeddedfiles[
$filename][
'n'])) {
8708 $annots .=
' /Sound <</Type /Filespec /F '.$this->_datastring($filename, $annot_obj_id).
' /EF <</F '.$this->embeddedfiles[
$filename][
'n'].
' 0 R>> >>';
8709 $iconsapp = array(
'Speaker',
'Mic');
8710 if (isset($pl[
'opt'][
'name']) AND in_array($pl[
'opt'][
'name'], $iconsapp)) {
8711 $annots .=
' /Name /'.$pl[
'opt'][
'name'];
8713 $annots .=
' /Name /Speaker';
8722 $hmode = array(
'N',
'I',
'O',
'P',
'T');
8723 if (isset($pl[
'opt'][
'h']) AND in_array($pl[
'opt'][
'h'], $hmode)) {
8724 $annots .=
' /H /'.$pl[
'opt'][
'h'];
8726 if (isset($pl[
'opt'][
'mk']) AND (is_array($pl[
'opt'][
'mk'])) AND !empty($pl[
'opt'][
'mk'])) {
8727 $annots .=
' /MK <<';
8728 if (isset($pl[
'opt'][
'mk'][
'r'])) {
8729 $annots .=
' /R '.$pl[
'opt'][
'mk'][
'r'];
8731 if (isset($pl[
'opt'][
'mk'][
'bc']) AND (is_array($pl[
'opt'][
'mk'][
'bc']))) {
8732 $annots .=
' /BC [';
8733 foreach($pl[
'opt'][
'mk'][
'bc'] AS $col) {
8734 $col = intval($col);
8735 $color = $col <= 0 ? 0 : ($col >= 255 ? 1 : $col / 255);
8736 $annots .= sprintf(
' %.2F', $color);
8740 if (isset($pl[
'opt'][
'mk'][
'bg']) AND (is_array($pl[
'opt'][
'mk'][
'bg']))) {
8741 $annots .=
' /BG [';
8742 foreach($pl[
'opt'][
'mk'][
'bg'] AS $col) {
8743 $col = intval($col);
8744 $color = $col <= 0 ? 0 : ($col >= 255 ? 1 : $col / 255);
8745 $annots .= sprintf(
' %.2F', $color);
8749 if (isset($pl[
'opt'][
'mk'][
'ca'])) {
8750 $annots .=
' /CA '.$pl[
'opt'][
'mk'][
'ca'];
8752 if (isset($pl[
'opt'][
'mk'][
'rc'])) {
8753 $annots .=
' /RC '.$pl[
'opt'][
'mk'][
'rc'];
8755 if (isset($pl[
'opt'][
'mk'][
'ac'])) {
8756 $annots .=
' /AC '.$pl[
'opt'][
'mk'][
'ac'];
8758 if (isset($pl[
'opt'][
'mk'][
'i'])) {
8759 $info = $this->getImageBuffer($pl[
'opt'][
'mk'][
'i']);
8760 if ($info !==
false) {
8761 $annots .=
' /I '.$info[
'n'].
' 0 R';
8764 if (isset($pl[
'opt'][
'mk'][
'ri'])) {
8765 $info = $this->getImageBuffer($pl[
'opt'][
'mk'][
'ri']);
8766 if ($info !==
false) {
8767 $annots .=
' /RI '.$info[
'n'].
' 0 R';
8770 if (isset($pl[
'opt'][
'mk'][
'ix'])) {
8771 $info = $this->getImageBuffer($pl[
'opt'][
'mk'][
'ix']);
8772 if ($info !==
false) {
8773 $annots .=
' /IX '.$info[
'n'].
' 0 R';
8776 if (isset($pl[
'opt'][
'mk'][
'if']) AND (is_array($pl[
'opt'][
'mk'][
'if'])) AND !empty($pl[
'opt'][
'mk'][
'if'])) {
8777 $annots .=
' /IF <<';
8778 $if_sw = array(
'A',
'B',
'S',
'N');
8779 if (isset($pl[
'opt'][
'mk'][
'if'][
'sw']) AND in_array($pl[
'opt'][
'mk'][
'if'][
'sw'], $if_sw)) {
8780 $annots .=
' /SW /'.$pl[
'opt'][
'mk'][
'if'][
'sw'];
8782 $if_s = array(
'A',
'P');
8783 if (isset($pl[
'opt'][
'mk'][
'if'][
's']) AND in_array($pl[
'opt'][
'mk'][
'if'][
's'], $if_s)) {
8784 $annots .=
' /S /'.$pl[
'opt'][
'mk'][
'if'][
's'];
8786 if (isset($pl[
'opt'][
'mk'][
'if'][
'a']) AND (is_array($pl[
'opt'][
'mk'][
'if'][
'a'])) AND !empty($pl[
'opt'][
'mk'][
'if'][
'a'])) {
8787 $annots .= sprintf(
' /A [%.2F %.2F]', $pl[
'opt'][
'mk'][
'if'][
'a'][0], $pl[
'opt'][
'mk'][
'if'][
'a'][1]);
8789 if (isset($pl[
'opt'][
'mk'][
'if'][
'fb']) AND ($pl[
'opt'][
'mk'][
'if'][
'fb'])) {
8790 $annots .=
' /FB true';
8794 if (isset($pl[
'opt'][
'mk'][
'tp']) AND ($pl[
'opt'][
'mk'][
'tp'] >= 0) AND ($pl[
'opt'][
'mk'][
'tp'] <= 6)) {
8795 $annots .=
' /TP '.intval($pl[
'opt'][
'mk'][
'tp']);
8797 $annots .=
' /TP 0';
8802 if (isset($this->radiobutton_groups[$n][$pl[
'txt']])) {
8804 $annots .=
' /Parent '.$this->radiobutton_groups[$n][$pl[
'txt']].
' 0 R';
8806 if (isset($pl[
'opt'][
't']) AND is_string($pl[
'opt'][
't'])) {
8807 $annots .=
' /T '.$this->_datastring($pl[
'opt'][
't'], $annot_obj_id);
8809 if (isset($pl[
'opt'][
'tu']) AND is_string($pl[
'opt'][
'tu'])) {
8810 $annots .=
' /TU '.$this->_datastring($pl[
'opt'][
'tu'], $annot_obj_id);
8812 if (isset($pl[
'opt'][
'tm']) AND is_string($pl[
'opt'][
'tm'])) {
8813 $annots .=
' /TM '.$this->_datastring($pl[
'opt'][
'tm'], $annot_obj_id);
8815 if (isset($pl[
'opt'][
'ff'])) {
8816 if (is_array($pl[
'opt'][
'ff'])) {
8819 foreach($pl[
'opt'][
'ff'] as $val) {
8820 $flag += 1 << ($val - 1);
8823 $flag = intval($pl[
'opt'][
'ff']);
8825 $annots .=
' /Ff '.$flag;
8827 if (isset($pl[
'opt'][
'maxlen'])) {
8828 $annots .=
' /MaxLen '.intval($pl[
'opt'][
'maxlen']);
8830 if (isset($pl[
'opt'][
'v'])) {
8832 if (is_array($pl[
'opt'][
'v'])) {
8833 foreach ($pl[
'opt'][
'v'] AS $optval) {
8834 if (is_float($optval)) {
8835 $optval = sprintf(
'%.2F', $optval);
8837 $annots .=
' '.$optval;
8840 $annots .=
' '.$this->_textstring($pl[
'opt'][
'v'], $annot_obj_id);
8843 if (isset($pl[
'opt'][
'dv'])) {
8845 if (is_array($pl[
'opt'][
'dv'])) {
8846 foreach ($pl[
'opt'][
'dv'] AS $optval) {
8847 if (is_float($optval)) {
8848 $optval = sprintf(
'%.2F', $optval);
8850 $annots .=
' '.$optval;
8853 $annots .=
' '.$this->_textstring($pl[
'opt'][
'dv'], $annot_obj_id);
8856 if (isset($pl[
'opt'][
'rv'])) {
8858 if (is_array($pl[
'opt'][
'rv'])) {
8859 foreach ($pl[
'opt'][
'rv'] AS $optval) {
8860 if (is_float($optval)) {
8861 $optval = sprintf(
'%.2F', $optval);
8863 $annots .=
' '.$optval;
8866 $annots .=
' '.$this->_textstring($pl[
'opt'][
'rv'], $annot_obj_id);
8869 if (isset($pl[
'opt'][
'a']) AND !empty($pl[
'opt'][
'a'])) {
8870 $annots .=
' /A << '.$pl[
'opt'][
'a'].
' >>';
8872 if (isset($pl[
'opt'][
'aa']) AND !empty($pl[
'opt'][
'aa'])) {
8873 $annots .=
' /AA << '.$pl[
'opt'][
'aa'].
' >>';
8875 if (isset($pl[
'opt'][
'da']) AND !empty($pl[
'opt'][
'da'])) {
8876 $annots .=
' /DA ('.$pl[
'opt'][
'da'].
')';
8878 if (isset($pl[
'opt'][
'q']) AND ($pl[
'opt'][
'q'] >= 0) AND ($pl[
'opt'][
'q'] <= 2)) {
8879 $annots .=
' /Q '.intval($pl[
'opt'][
'q']);
8881 if (isset($pl[
'opt'][
'opt']) AND (is_array($pl[
'opt'][
'opt'])) AND !empty($pl[
'opt'][
'opt'])) {
8882 $annots .=
' /Opt [';
8883 foreach($pl[
'opt'][
'opt'] AS $copt) {
8884 if (is_array($copt)) {
8885 $annots .=
' ['.$this->_textstring($copt[0], $annot_obj_id).
' '.$this->_textstring($copt[1], $annot_obj_id).
']';
8887 $annots .=
' '.$this->_textstring($copt, $annot_obj_id);
8892 if (isset($pl[
'opt'][
'ti'])) {
8893 $annots .=
' /TI '.intval($pl[
'opt'][
'ti']);
8895 if (isset($pl[
'opt'][
'i']) AND (is_array($pl[
'opt'][
'i'])) AND !empty($pl[
'opt'][
'i'])) {
8897 foreach($pl[
'opt'][
'i'] AS $copt) {
8898 $annots .= intval($copt).
' ';
8907 case 'printermark': {
8925 $this->_out($this->_getobj($annot_obj_id).
"\n".$annots.
"\n".
'endobj');
8926 if ($formfield AND !isset($this->radiobutton_groups[$n][$pl[
'txt']])) {
8928 $this->form_obj_id[] = $annot_obj_id;
8945 $stream = trim($stream);
8946 $out = $this->_getobj().
"\n";
8947 $this->xobjects[
'AX'.$this->n] = array(
'n' => $this->
n);
8949 $out .=
' /Type /XObject';
8950 $out .=
' /Subtype /Form';
8951 $out .=
' /FormType 1';
8952 if ($this->compress) {
8953 $stream = gzcompress($stream);
8954 $out .=
' /Filter /FlateDecode';
8956 $rect = sprintf(
'%.2F %.2F', $w, $h);
8957 $out .=
' /BBox [0 0 '.$rect.
']';
8958 $out .=
' /Matrix [1 0 0 1 0 0]';
8959 $out .=
' /Resources <<';
8960 $out .=
' /ProcSet [/PDF /Text]';
8961 $out .=
' /Font <<';
8962 foreach ($this->annotation_fonts as $fontkey => $fontid) {
8963 $out .=
' /F'.$fontid.
' '.$this->font_obj_ids[$fontkey].
' 0 R';
8967 $stream = $this->_getrawstream($stream);
8968 $out .=
' /Length '.strlen($stream);
8970 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
8971 $out .=
"\n".
'endobj';
8986 $v = unpack(
'Ni', substr($str, $offset, 4));
9001 $v = unpack(
'ni', substr($str, $offset, 2));
9016 $v = unpack(
'si', substr($str, $offset, 2));
9031 $v = unpack(
'Ci', substr($str, $offset, 1));
9046 ksort($subsetchars);
9048 if ($this->_getULONG($font, $offset) != 0x10000) {
9053 $numTables = $this->_getUSHORT($font, $offset);
9059 for ($i = 0; $i < $numTables; ++$i) {
9061 $tag = substr($font, $offset, 4);
9063 $table[$tag] = array();
9064 $table[$tag][
'checkSum'] = $this->_getULONG($font, $offset);
9065 $table[$tag][
'offset'] = $this->_getULONG($font, $offset);
9066 $table[$tag][
'length'] = $this->_getULONG($font, $offset);
9069 $offset = $table[
'head'][
'offset'] + 12;
9070 if ($this->_getULONG($font, $offset) != 0x5F0F3CF5) {
9075 $offset = $table[
'head'][
'offset'] + 50;
9076 $short_offset = ($this->_getSHORT($font, $offset) == 0);
9078 $indexToLoc = array();
9079 $offset = $table[
'loca'][
'offset'];
9080 if ($short_offset) {
9082 $n = $table[
'loca'][
'length'] / 2;
9083 for ($i = 0; $i < $n; ++$i) {
9084 $indexToLoc[$i] = $this->_getUSHORT($font, $offset) * 2;
9088 $n = $table[
'loca'][
'length'] / 4;
9089 for ($i = 0; $i < $n; ++$i) {
9090 $indexToLoc[$i] = $this->_getULONG($font, $offset);
9094 $subsetglyphs = array();
9095 $subsetglyphs[0] =
true;
9096 $offset = $table[
'cmap'][
'offset'] + 2;
9097 $numEncodingTables = $this->_getUSHORT($font, $offset);
9098 $encodingTables = array();
9099 for ($i = 0; $i < $numEncodingTables; ++$i) {
9100 $encodingTables[$i][
'platformID'] = $this->_getUSHORT($font, $offset);
9101 $encodingTables[$i][
'encodingID'] = $this->_getUSHORT($font, $offset);
9102 $encodingTables[$i][
'offset'] = $this->_getULONG($font, $offset);
9104 foreach ($encodingTables as $enctable) {
9105 if (($enctable[
'platformID'] == 3) AND ($enctable[
'encodingID'] == 0)) {
9108 $modesymbol =
false;
9110 $offset = $table[
'cmap'][
'offset'] + $enctable[
'offset'];
9111 $format = $this->_getUSHORT($font, $offset);
9115 for ($k = 0; $k < 256; ++$k) {
9116 if (isset($subsetchars[$k])) {
9117 $g = $this->_getBYTE($font, $offset);
9118 $subsetglyphs[$g] = $k;
9131 $length = $this->_getUSHORT($font, $offset);
9133 $segCount = ($this->_getUSHORT($font, $offset) / 2);
9135 $endCount = array();
9136 for ($k = 0; $k < $segCount; ++$k) {
9137 $endCount[$k] = $this->_getUSHORT($font, $offset);
9140 $startCount = array();
9141 for ($k = 0; $k < $segCount; ++$k) {
9142 $startCount[$k] = $this->_getUSHORT($font, $offset);
9145 for ($k = 0; $k < $segCount; ++$k) {
9146 $idDelta[$k] = $this->_getUSHORT($font, $offset);
9148 $idRangeOffset = array();
9149 for ($k = 0; $k < $segCount; ++$k) {
9150 $idRangeOffset[$k] = $this->_getUSHORT($font, $offset);
9152 $gidlen = ($length / 2) - 8 - (4 * $segCount);
9153 $glyphIdArray = array();
9154 for ($k = 0; $k < $gidlen; ++$k) {
9155 $glyphIdArray[$k] = $this->_getUSHORT($font, $offset);
9157 for ($k = 0; $k < $segCount; ++$k) {
9158 for ($c = $startCount[$k]; $c <= $endCount[$k]; ++$c) {
9159 if (isset($subsetchars[$c])) {
9160 if ($idRangeOffset[$k] == 0) {
9163 $gid = (($idRangeOffset[$k] / 2) + ($c - $startCount[$k]) - ($segCount - $k));
9164 $g = $glyphIdArray[$gid];
9166 $g += ($idDelta[$k] - 65536);
9170 $subsetglyphs[$g] = $c;
9178 $firstCode = $this->_getUSHORT($font, $offset);
9179 $entryCount = $this->_getUSHORT($font, $offset);
9180 for ($k = 0; $k < $entryCount; ++$k) {
9181 $c = ($k + $firstCode);
9182 if (isset($subsetchars[$c])) {
9183 $g = $this->_getUSHORT($font, $offset);
9184 $subsetglyphs[$g] = $c;
9198 $startCharCode = $this->_getULONG($font, $offset);
9199 $numChars = $this->_getULONG($font, $offset);
9200 for ($k = 0; $k < $numChars; ++$k) {
9201 $c = ($k + $startCharCode);
9202 if (isset($subsetchars[$c])) {
9203 $g = $this->_getUSHORT($font, $offset);
9204 $subsetglyphs[$g] = $c;
9213 $nGroups = $this->_getULONG($font, $offset);
9214 for ($k = 0; $k < $nGroups; ++$k) {
9215 $startCharCode = $this->_getULONG($font, $offset);
9216 $endCharCode = $this->_getULONG($font, $offset);
9217 $startGlyphCode = $this->_getULONG($font, $offset);
9218 for ($c = $startCharCode; $c <= $endCharCode; ++$c) {
9219 if (isset($subsetchars[$c])) {
9220 $subsetglyphs[$startGlyphCode] = $c;
9230 ksort($subsetglyphs);
9232 foreach ($subsetglyphs as $key => $val) {
9233 if (isset($indexToLoc[$key])) {
9234 $offset = $table[
'glyf'][
'offset'] + $indexToLoc[$key];
9235 $numberOfContours = $this->_getSHORT($font, $offset);
9236 if ($numberOfContours < 0) {
9239 $flags = $this->_getUSHORT($font, $offset);
9240 $glyphIndex = $this->_getUSHORT($font, $offset);
9241 if (!isset($subsetglyphs[$glyphIndex]) AND isset($indexToLoc[$glyphIndex])) {
9243 $subsetglyphs[$glyphIndex] =
true;
9253 } elseif ($flags & 64) {
9255 } elseif ($flags & 128) {
9258 }
while ($flags & 32);
9261 unset($subsetglyphs[$key]);
9268 $newIndexToLoc = array_fill(0, count($indexToLoc), 0);
9270 foreach ($subsetglyphs as $glyphID => $char) {
9271 if (isset($indexToLoc[$glyphID]) AND isset($indexToLoc[($glyphID + 1)])) {
9272 $start = $indexToLoc[$glyphID];
9273 $length = ($indexToLoc[($glyphID + 1)] - $start);
9274 $glyf .= substr($font, ($table[
'glyf'][
'offset'] + $start), $length);
9275 $newIndexToLoc[$glyphID] = $goffset;
9276 $goffset += $length;
9281 if ($short_offset) {
9282 foreach ($newIndexToLoc as $glyphID => $offset) {
9283 $loca .= pack(
'n', ($offset / 2));
9286 foreach ($newIndexToLoc as $glyphID => $offset) {
9287 $loca .= pack(
'N', $offset);
9293 $table_names = array (
'head',
'hhea',
'hmtx',
'maxp',
'cvt ',
'fpgm',
'prep');
9296 foreach ($table as $tag => $val) {
9297 if (in_array($tag, $table_names)) {
9298 $table[$tag][
'data'] = substr($font, $table[$tag][
'offset'], $table[$tag][
'length']);
9299 if ($tag ==
'head') {
9301 $table[$tag][
'data'] = substr($table[$tag][
'data'], 0, 8).
"\x0\x0\x0\x0".substr($table[$tag][
'data'], 12);
9303 $pad = 4 - ($table[$tag][
'length'] % 4);
9306 $table[$tag][
'length'] += $pad;
9307 $table[$tag][
'data'] .= str_repeat(
"\x0", $pad);
9309 $table[$tag][
'offset'] = $offset;
9310 $offset += $table[$tag][
'length'];
9314 unset($table[$tag]);
9318 $table[
'loca'][
'data'] = $loca;
9319 $table[
'loca'][
'length'] = strlen($loca);
9320 $pad = 4 - ($table[
'loca'][
'length'] % 4);
9323 $table[
'loca'][
'length'] += $pad;
9324 $table[
'loca'][
'data'] .= str_repeat(
"\x0", $pad);
9326 $table[
'loca'][
'offset'] = $offset;
9327 $table[
'loca'][
'checkSum'] = $this->_getTTFtableChecksum($table[
'loca'][
'data'], $table[
'loca'][
'length']);
9328 $offset += $table[
'loca'][
'length'];
9330 $table[
'glyf'][
'data'] = $glyf;
9331 $table[
'glyf'][
'length'] = strlen($glyf);
9332 $pad = 4 - ($table[
'glyf'][
'length'] % 4);
9335 $table[
'glyf'][
'length'] += $pad;
9336 $table[
'glyf'][
'data'] .= str_repeat(
"\x0", $pad);
9338 $table[
'glyf'][
'offset'] = $offset;
9339 $table[
'glyf'][
'checkSum'] = $this->_getTTFtableChecksum($table[
'glyf'][
'data'], $table[
'glyf'][
'length']);
9342 $font .= pack(
'N', 0x10000);
9343 $numTables = count($table);
9344 $font .= pack(
'n', $numTables);
9345 $entrySelector = floor(log($numTables, 2));
9346 $searchRange = pow(2, $entrySelector) * 16;
9347 $rangeShift = ($numTables * 16) - $searchRange;
9348 $font .= pack(
'n', $searchRange);
9349 $font .= pack(
'n', $entrySelector);
9350 $font .= pack(
'n', $rangeShift);
9351 $offset = ($numTables * 16);
9352 foreach ($table as $tag =>
$data) {
9354 $font .= pack(
'N',
$data[
'checkSum']);
9355 $font .= pack(
'N', (
$data[
'offset'] + $offset));
9356 $font .= pack(
'N',
$data[
'length']);
9358 foreach ($table as
$data) {
9359 $font .= $data[
'data'];
9362 $checkSumAdjustment = 0xB1B0AFBA - $this->_getTTFtableChecksum($font, strlen($font));
9363 $font = substr($font, 0, $table[
'head'][
'offset'] + 8).pack(
'N', $checkSumAdjustment).substr($font, $table[
'head'][
'offset'] + 12);
9378 $tlen = ($length / 4);
9380 for ($i = 0; $i < $tlen; ++$i) {
9381 $v = unpack(
'Ni', substr($table, $offset, 4));
9385 $sum = unpack(
'Ni', pack(
'N', $sum));
9406 foreach ($font[
'cw'] as $cid => $width) {
9408 if ($font[
'subset'] AND ($cid > 255) AND (!isset($font[
'subsetchars'][$cid]))) {
9412 if ($width != $font[
'dw']) {
9413 if ($cid == ($prevcid + 1)) {
9415 if ($width == $prevwidth) {
9416 if ($width == $range[$rangeid][0]) {
9417 $range[$rangeid][] = $width;
9419 array_pop($range[$rangeid]);
9421 $rangeid = $prevcid;
9422 $range[$rangeid] = array();
9423 $range[$rangeid][] = $prevwidth;
9424 $range[$rangeid][] = $width;
9427 $range[$rangeid][
'interval'] =
true;
9432 $range[$rangeid] = array();
9433 $range[$rangeid][] = $width;
9435 $range[$rangeid][] = $width;
9442 $range[$rangeid] = array();
9443 $range[$rangeid][] = $width;
9447 $prevwidth = $width;
9454 foreach ($range as $k => $ws) {
9456 if (($k == $nextk) AND (!$prevint) AND ((!isset($ws[
'interval'])) OR ($cws < 4))) {
9457 if (isset($range[$k][
'interval'])) {
9458 unset($range[$k][
'interval']);
9460 $range[$prevk] = array_merge($range[$prevk], $range[$k]);
9466 if (isset($ws[
'interval'])) {
9472 unset($range[$k][
'interval']);
9480 foreach ($range as $k => $ws) {
9481 if (count(array_count_values($ws)) == 1) {
9483 $w .=
' '.$k.
' '.($k + count($ws) - 1).
' '.$ws[0];
9486 $w .=
' '.$k.
' [ '.implode(
' ', $ws).
' ]';
9489 return '/W ['.$w.
' ]';
9499 foreach ($this->diffs as
$diff) {
9502 $this->_out(
'<< /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.
'] >>'.
"\n".
'endobj');
9504 $mqr = $this->get_mqr();
9505 $this->set_mqr(
false);
9506 foreach ($this->FontFiles as
$file => $info) {
9508 $fontdir = $info[
'fontdir'];
9512 if (($fontdir !==
false) AND file_exists($fontdir.$file)) {
9513 $fontfile = $fontdir.$file;
9514 } elseif (file_exists($this->_getfontpath().
$file)) {
9515 $fontfile = $this->_getfontpath().$file;
9516 } elseif (file_exists(
$file)) {
9519 if (!$this->empty_string($fontfile)) {
9520 $font = file_get_contents($fontfile);
9521 $compressed = (substr(
$file, -2) ==
'.z');
9522 if ((!$compressed) AND (isset($info[
'length2']))) {
9523 $header = (ord($font{0}) == 128);
9526 $font = substr($font, 6);
9528 if ($header AND (ord($font{$info[
'length1']}) == 128)) {
9530 $font = substr($font, 0, $info[
'length1']).substr($font, ($info[
'length1'] + 6));
9532 } elseif ($info[
'subset'] AND ((!$compressed) OR ($compressed AND function_exists(
'gzcompress')))) {
9535 $font = gzuncompress($font);
9538 $subsetchars = array();
9539 foreach ($info[
'fontkeys'] as $fontkey) {
9540 $fontinfo = $this->getFontBuffer($fontkey);
9541 $subsetchars += $fontinfo[
'subsetchars'];
9543 $font = $this->_getTrueTypeFontSubset($font, $subsetchars);
9546 $font = gzcompress($font);
9550 $this->FontFiles[
$file][
'n'] = $this->n;
9551 $stream = $this->_getrawstream($font);
9552 $out =
'<< /Length '.strlen($stream);
9554 $out .=
' /Filter /FlateDecode';
9556 $out .=
' /Length1 '.$info[
'length1'];
9557 if (isset($info[
'length2'])) {
9558 $out .=
' /Length2 '.$info[
'length2'].
' /Length3 0';
9561 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
9562 $out .=
"\n".
'endobj';
9566 $this->set_mqr($mqr);
9567 foreach ($this->fontkeys as $k) {
9569 $font = $this->getFontBuffer($k);
9570 $type = $font[
'type'];
9571 $name = $font[
'name'];
9572 if (
$type ==
'core') {
9574 $out = $this->_getobj($this->font_obj_ids[$k]).
"\n";
9575 $out .=
'<</Type /Font';
9576 $out .=
' /Subtype /Type1';
9577 $out .=
' /BaseFont /'.$name;
9578 $out .=
' /Name /F'.$font[
'i'];
9579 if ((strtolower(
$name) !=
'symbol') AND (strtolower(
$name) !=
'zapfdingbats')) {
9580 $out .=
' /Encoding /WinAnsiEncoding';
9582 if ($k ==
'helvetica') {
9584 $this->annotation_fonts[$k] = $font[
'i'];
9587 $out .=
"\n".
'endobj';
9589 } elseif ((
$type ==
'Type1') OR (
$type ==
'TrueType')) {
9591 $out = $this->_getobj($this->font_obj_ids[$k]).
"\n";
9592 $out .=
'<</Type /Font';
9593 $out .=
' /Subtype /'.$type;
9594 $out .=
' /BaseFont /'.$name;
9595 $out .=
' /Name /F'.$font[
'i'];
9596 $out .=
' /FirstChar 32 /LastChar 255';
9597 $out .=
' /Widths '.($this->n + 1).
' 0 R';
9598 $out .=
' /FontDescriptor '.($this->n + 2).
' 0 R';
9600 if (isset($font[
'diff'])) {
9601 $out .=
' /Encoding '.($nf + $font[
'diff']).
' 0 R';
9603 $out .=
' /Encoding /WinAnsiEncoding';
9607 $out .=
"\n".
'endobj';
9613 for ($i = 32; $i < 256; ++$i) {
9617 $s .=
"\n".
'endobj';
9621 $s =
'<</Type /FontDescriptor /FontName /'.$name;
9622 foreach ($font[
'desc'] as $fdk => $fdv) {
9623 if(is_float($fdv)) {
9624 $fdv = sprintf(
'%.3F', $fdv);
9626 $s .=
' /'.$fdk.
' '.$fdv.
'';
9628 if (!$this->empty_string($font[
'file'])) {
9629 $s .=
' /FontFile'.($type ==
'Type1' ?
'' :
'2').
' '.$this->FontFiles[$font[
'file']][
'n'].
' 0 R';
9632 $s .=
"\n".
'endobj';
9636 $mtd =
'_put'.strtolower(
$type);
9637 if (!method_exists($this, $mtd)) {
9638 $this->Error(
'Unsupported font type: '.
$type);
9655 if ($font[
'subset']) {
9657 $subtag = sprintf(
'%06u', $font[
'i']);
9658 $subtag = strtr($subtag,
'0123456789',
'ABCDEFGHIJ');
9659 $fontname .= $subtag.
'+';
9661 $fontname .= $font[
'name'];
9664 $out = $this->_getobj($this->font_obj_ids[$font[
'fontkey']]).
"\n";
9665 $out .=
'<< /Type /Font';
9666 $out .=
' /Subtype /Type0';
9667 $out .=
' /BaseFont /'.$fontname;
9668 $out .=
' /Name /F'.$font[
'i'];
9669 $out .=
' /Encoding /'.$font[
'enc'];
9670 $out .=
' /ToUnicode '.($this->n + 1).
' 0 R';
9671 $out .=
' /DescendantFonts ['.($this->n + 2).
' 0 R]';
9673 $out .=
"\n".
'endobj';
9676 $stream =
"/CIDInit /ProcSet findresource begin\n";
9677 $stream .=
"12 dict begin\n";
9678 $stream .=
"begincmap\n";
9679 $stream .=
"/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n";
9680 $stream .=
"/CMapName /Adobe-Identity-UCS def\n";
9681 $stream .=
"/CMapType 2 def\n";
9682 $stream .=
"/WMode 0 def\n";
9683 $stream .=
"1 begincodespacerange\n";
9684 $stream .=
"<0000> <FFFF>\n";
9685 $stream .=
"endcodespacerange\n";
9686 $stream .=
"100 beginbfrange\n";
9687 $stream .=
"<0000> <00ff> <0000>\n";
9688 $stream .=
"<0100> <01ff> <0100>\n";
9689 $stream .=
"<0200> <02ff> <0200>\n";
9690 $stream .=
"<0300> <03ff> <0300>\n";
9691 $stream .=
"<0400> <04ff> <0400>\n";
9692 $stream .=
"<0500> <05ff> <0500>\n";
9693 $stream .=
"<0600> <06ff> <0600>\n";
9694 $stream .=
"<0700> <07ff> <0700>\n";
9695 $stream .=
"<0800> <08ff> <0800>\n";
9696 $stream .=
"<0900> <09ff> <0900>\n";
9697 $stream .=
"<0a00> <0aff> <0a00>\n";
9698 $stream .=
"<0b00> <0bff> <0b00>\n";
9699 $stream .=
"<0c00> <0cff> <0c00>\n";
9700 $stream .=
"<0d00> <0dff> <0d00>\n";
9701 $stream .=
"<0e00> <0eff> <0e00>\n";
9702 $stream .=
"<0f00> <0fff> <0f00>\n";
9703 $stream .=
"<1000> <10ff> <1000>\n";
9704 $stream .=
"<1100> <11ff> <1100>\n";
9705 $stream .=
"<1200> <12ff> <1200>\n";
9706 $stream .=
"<1300> <13ff> <1300>\n";
9707 $stream .=
"<1400> <14ff> <1400>\n";
9708 $stream .=
"<1500> <15ff> <1500>\n";
9709 $stream .=
"<1600> <16ff> <1600>\n";
9710 $stream .=
"<1700> <17ff> <1700>\n";
9711 $stream .=
"<1800> <18ff> <1800>\n";
9712 $stream .=
"<1900> <19ff> <1900>\n";
9713 $stream .=
"<1a00> <1aff> <1a00>\n";
9714 $stream .=
"<1b00> <1bff> <1b00>\n";
9715 $stream .=
"<1c00> <1cff> <1c00>\n";
9716 $stream .=
"<1d00> <1dff> <1d00>\n";
9717 $stream .=
"<1e00> <1eff> <1e00>\n";
9718 $stream .=
"<1f00> <1fff> <1f00>\n";
9719 $stream .=
"<2000> <20ff> <2000>\n";
9720 $stream .=
"<2100> <21ff> <2100>\n";
9721 $stream .=
"<2200> <22ff> <2200>\n";
9722 $stream .=
"<2300> <23ff> <2300>\n";
9723 $stream .=
"<2400> <24ff> <2400>\n";
9724 $stream .=
"<2500> <25ff> <2500>\n";
9725 $stream .=
"<2600> <26ff> <2600>\n";
9726 $stream .=
"<2700> <27ff> <2700>\n";
9727 $stream .=
"<2800> <28ff> <2800>\n";
9728 $stream .=
"<2900> <29ff> <2900>\n";
9729 $stream .=
"<2a00> <2aff> <2a00>\n";
9730 $stream .=
"<2b00> <2bff> <2b00>\n";
9731 $stream .=
"<2c00> <2cff> <2c00>\n";
9732 $stream .=
"<2d00> <2dff> <2d00>\n";
9733 $stream .=
"<2e00> <2eff> <2e00>\n";
9734 $stream .=
"<2f00> <2fff> <2f00>\n";
9735 $stream .=
"<3000> <30ff> <3000>\n";
9736 $stream .=
"<3100> <31ff> <3100>\n";
9737 $stream .=
"<3200> <32ff> <3200>\n";
9738 $stream .=
"<3300> <33ff> <3300>\n";
9739 $stream .=
"<3400> <34ff> <3400>\n";
9740 $stream .=
"<3500> <35ff> <3500>\n";
9741 $stream .=
"<3600> <36ff> <3600>\n";
9742 $stream .=
"<3700> <37ff> <3700>\n";
9743 $stream .=
"<3800> <38ff> <3800>\n";
9744 $stream .=
"<3900> <39ff> <3900>\n";
9745 $stream .=
"<3a00> <3aff> <3a00>\n";
9746 $stream .=
"<3b00> <3bff> <3b00>\n";
9747 $stream .=
"<3c00> <3cff> <3c00>\n";
9748 $stream .=
"<3d00> <3dff> <3d00>\n";
9749 $stream .=
"<3e00> <3eff> <3e00>\n";
9750 $stream .=
"<3f00> <3fff> <3f00>\n";
9751 $stream .=
"<4000> <40ff> <4000>\n";
9752 $stream .=
"<4100> <41ff> <4100>\n";
9753 $stream .=
"<4200> <42ff> <4200>\n";
9754 $stream .=
"<4300> <43ff> <4300>\n";
9755 $stream .=
"<4400> <44ff> <4400>\n";
9756 $stream .=
"<4500> <45ff> <4500>\n";
9757 $stream .=
"<4600> <46ff> <4600>\n";
9758 $stream .=
"<4700> <47ff> <4700>\n";
9759 $stream .=
"<4800> <48ff> <4800>\n";
9760 $stream .=
"<4900> <49ff> <4900>\n";
9761 $stream .=
"<4a00> <4aff> <4a00>\n";
9762 $stream .=
"<4b00> <4bff> <4b00>\n";
9763 $stream .=
"<4c00> <4cff> <4c00>\n";
9764 $stream .=
"<4d00> <4dff> <4d00>\n";
9765 $stream .=
"<4e00> <4eff> <4e00>\n";
9766 $stream .=
"<4f00> <4fff> <4f00>\n";
9767 $stream .=
"<5000> <50ff> <5000>\n";
9768 $stream .=
"<5100> <51ff> <5100>\n";
9769 $stream .=
"<5200> <52ff> <5200>\n";
9770 $stream .=
"<5300> <53ff> <5300>\n";
9771 $stream .=
"<5400> <54ff> <5400>\n";
9772 $stream .=
"<5500> <55ff> <5500>\n";
9773 $stream .=
"<5600> <56ff> <5600>\n";
9774 $stream .=
"<5700> <57ff> <5700>\n";
9775 $stream .=
"<5800> <58ff> <5800>\n";
9776 $stream .=
"<5900> <59ff> <5900>\n";
9777 $stream .=
"<5a00> <5aff> <5a00>\n";
9778 $stream .=
"<5b00> <5bff> <5b00>\n";
9779 $stream .=
"<5c00> <5cff> <5c00>\n";
9780 $stream .=
"<5d00> <5dff> <5d00>\n";
9781 $stream .=
"<5e00> <5eff> <5e00>\n";
9782 $stream .=
"<5f00> <5fff> <5f00>\n";
9783 $stream .=
"<6000> <60ff> <6000>\n";
9784 $stream .=
"<6100> <61ff> <6100>\n";
9785 $stream .=
"<6200> <62ff> <6200>\n";
9786 $stream .=
"<6300> <63ff> <6300>\n";
9787 $stream .=
"endbfrange\n";
9788 $stream .=
"100 beginbfrange\n";
9789 $stream .=
"<6400> <64ff> <6400>\n";
9790 $stream .=
"<6500> <65ff> <6500>\n";
9791 $stream .=
"<6600> <66ff> <6600>\n";
9792 $stream .=
"<6700> <67ff> <6700>\n";
9793 $stream .=
"<6800> <68ff> <6800>\n";
9794 $stream .=
"<6900> <69ff> <6900>\n";
9795 $stream .=
"<6a00> <6aff> <6a00>\n";
9796 $stream .=
"<6b00> <6bff> <6b00>\n";
9797 $stream .=
"<6c00> <6cff> <6c00>\n";
9798 $stream .=
"<6d00> <6dff> <6d00>\n";
9799 $stream .=
"<6e00> <6eff> <6e00>\n";
9800 $stream .=
"<6f00> <6fff> <6f00>\n";
9801 $stream .=
"<7000> <70ff> <7000>\n";
9802 $stream .=
"<7100> <71ff> <7100>\n";
9803 $stream .=
"<7200> <72ff> <7200>\n";
9804 $stream .=
"<7300> <73ff> <7300>\n";
9805 $stream .=
"<7400> <74ff> <7400>\n";
9806 $stream .=
"<7500> <75ff> <7500>\n";
9807 $stream .=
"<7600> <76ff> <7600>\n";
9808 $stream .=
"<7700> <77ff> <7700>\n";
9809 $stream .=
"<7800> <78ff> <7800>\n";
9810 $stream .=
"<7900> <79ff> <7900>\n";
9811 $stream .=
"<7a00> <7aff> <7a00>\n";
9812 $stream .=
"<7b00> <7bff> <7b00>\n";
9813 $stream .=
"<7c00> <7cff> <7c00>\n";
9814 $stream .=
"<7d00> <7dff> <7d00>\n";
9815 $stream .=
"<7e00> <7eff> <7e00>\n";
9816 $stream .=
"<7f00> <7fff> <7f00>\n";
9817 $stream .=
"<8000> <80ff> <8000>\n";
9818 $stream .=
"<8100> <81ff> <8100>\n";
9819 $stream .=
"<8200> <82ff> <8200>\n";
9820 $stream .=
"<8300> <83ff> <8300>\n";
9821 $stream .=
"<8400> <84ff> <8400>\n";
9822 $stream .=
"<8500> <85ff> <8500>\n";
9823 $stream .=
"<8600> <86ff> <8600>\n";
9824 $stream .=
"<8700> <87ff> <8700>\n";
9825 $stream .=
"<8800> <88ff> <8800>\n";
9826 $stream .=
"<8900> <89ff> <8900>\n";
9827 $stream .=
"<8a00> <8aff> <8a00>\n";
9828 $stream .=
"<8b00> <8bff> <8b00>\n";
9829 $stream .=
"<8c00> <8cff> <8c00>\n";
9830 $stream .=
"<8d00> <8dff> <8d00>\n";
9831 $stream .=
"<8e00> <8eff> <8e00>\n";
9832 $stream .=
"<8f00> <8fff> <8f00>\n";
9833 $stream .=
"<9000> <90ff> <9000>\n";
9834 $stream .=
"<9100> <91ff> <9100>\n";
9835 $stream .=
"<9200> <92ff> <9200>\n";
9836 $stream .=
"<9300> <93ff> <9300>\n";
9837 $stream .=
"<9400> <94ff> <9400>\n";
9838 $stream .=
"<9500> <95ff> <9500>\n";
9839 $stream .=
"<9600> <96ff> <9600>\n";
9840 $stream .=
"<9700> <97ff> <9700>\n";
9841 $stream .=
"<9800> <98ff> <9800>\n";
9842 $stream .=
"<9900> <99ff> <9900>\n";
9843 $stream .=
"<9a00> <9aff> <9a00>\n";
9844 $stream .=
"<9b00> <9bff> <9b00>\n";
9845 $stream .=
"<9c00> <9cff> <9c00>\n";
9846 $stream .=
"<9d00> <9dff> <9d00>\n";
9847 $stream .=
"<9e00> <9eff> <9e00>\n";
9848 $stream .=
"<9f00> <9fff> <9f00>\n";
9849 $stream .=
"<a000> <a0ff> <a000>\n";
9850 $stream .=
"<a100> <a1ff> <a100>\n";
9851 $stream .=
"<a200> <a2ff> <a200>\n";
9852 $stream .=
"<a300> <a3ff> <a300>\n";
9853 $stream .=
"<a400> <a4ff> <a400>\n";
9854 $stream .=
"<a500> <a5ff> <a500>\n";
9855 $stream .=
"<a600> <a6ff> <a600>\n";
9856 $stream .=
"<a700> <a7ff> <a700>\n";
9857 $stream .=
"<a800> <a8ff> <a800>\n";
9858 $stream .=
"<a900> <a9ff> <a900>\n";
9859 $stream .=
"<aa00> <aaff> <aa00>\n";
9860 $stream .=
"<ab00> <abff> <ab00>\n";
9861 $stream .=
"<ac00> <acff> <ac00>\n";
9862 $stream .=
"<ad00> <adff> <ad00>\n";
9863 $stream .=
"<ae00> <aeff> <ae00>\n";
9864 $stream .=
"<af00> <afff> <af00>\n";
9865 $stream .=
"<b000> <b0ff> <b000>\n";
9866 $stream .=
"<b100> <b1ff> <b100>\n";
9867 $stream .=
"<b200> <b2ff> <b200>\n";
9868 $stream .=
"<b300> <b3ff> <b300>\n";
9869 $stream .=
"<b400> <b4ff> <b400>\n";
9870 $stream .=
"<b500> <b5ff> <b500>\n";
9871 $stream .=
"<b600> <b6ff> <b600>\n";
9872 $stream .=
"<b700> <b7ff> <b700>\n";
9873 $stream .=
"<b800> <b8ff> <b800>\n";
9874 $stream .=
"<b900> <b9ff> <b900>\n";
9875 $stream .=
"<ba00> <baff> <ba00>\n";
9876 $stream .=
"<bb00> <bbff> <bb00>\n";
9877 $stream .=
"<bc00> <bcff> <bc00>\n";
9878 $stream .=
"<bd00> <bdff> <bd00>\n";
9879 $stream .=
"<be00> <beff> <be00>\n";
9880 $stream .=
"<bf00> <bfff> <bf00>\n";
9881 $stream .=
"<c000> <c0ff> <c000>\n";
9882 $stream .=
"<c100> <c1ff> <c100>\n";
9883 $stream .=
"<c200> <c2ff> <c200>\n";
9884 $stream .=
"<c300> <c3ff> <c300>\n";
9885 $stream .=
"<c400> <c4ff> <c400>\n";
9886 $stream .=
"<c500> <c5ff> <c500>\n";
9887 $stream .=
"<c600> <c6ff> <c600>\n";
9888 $stream .=
"<c700> <c7ff> <c700>\n";
9889 $stream .=
"endbfrange\n";
9890 $stream .=
"56 beginbfrange\n";
9891 $stream .=
"<c800> <c8ff> <c800>\n";
9892 $stream .=
"<c900> <c9ff> <c900>\n";
9893 $stream .=
"<ca00> <caff> <ca00>\n";
9894 $stream .=
"<cb00> <cbff> <cb00>\n";
9895 $stream .=
"<cc00> <ccff> <cc00>\n";
9896 $stream .=
"<cd00> <cdff> <cd00>\n";
9897 $stream .=
"<ce00> <ceff> <ce00>\n";
9898 $stream .=
"<cf00> <cfff> <cf00>\n";
9899 $stream .=
"<d000> <d0ff> <d000>\n";
9900 $stream .=
"<d100> <d1ff> <d100>\n";
9901 $stream .=
"<d200> <d2ff> <d200>\n";
9902 $stream .=
"<d300> <d3ff> <d300>\n";
9903 $stream .=
"<d400> <d4ff> <d400>\n";
9904 $stream .=
"<d500> <d5ff> <d500>\n";
9905 $stream .=
"<d600> <d6ff> <d600>\n";
9906 $stream .=
"<d700> <d7ff> <d700>\n";
9907 $stream .=
"<d800> <d8ff> <d800>\n";
9908 $stream .=
"<d900> <d9ff> <d900>\n";
9909 $stream .=
"<da00> <daff> <da00>\n";
9910 $stream .=
"<db00> <dbff> <db00>\n";
9911 $stream .=
"<dc00> <dcff> <dc00>\n";
9912 $stream .=
"<dd00> <ddff> <dd00>\n";
9913 $stream .=
"<de00> <deff> <de00>\n";
9914 $stream .=
"<df00> <dfff> <df00>\n";
9915 $stream .=
"<e000> <e0ff> <e000>\n";
9916 $stream .=
"<e100> <e1ff> <e100>\n";
9917 $stream .=
"<e200> <e2ff> <e200>\n";
9918 $stream .=
"<e300> <e3ff> <e300>\n";
9919 $stream .=
"<e400> <e4ff> <e400>\n";
9920 $stream .=
"<e500> <e5ff> <e500>\n";
9921 $stream .=
"<e600> <e6ff> <e600>\n";
9922 $stream .=
"<e700> <e7ff> <e700>\n";
9923 $stream .=
"<e800> <e8ff> <e800>\n";
9924 $stream .=
"<e900> <e9ff> <e900>\n";
9925 $stream .=
"<ea00> <eaff> <ea00>\n";
9926 $stream .=
"<eb00> <ebff> <eb00>\n";
9927 $stream .=
"<ec00> <ecff> <ec00>\n";
9928 $stream .=
"<ed00> <edff> <ed00>\n";
9929 $stream .=
"<ee00> <eeff> <ee00>\n";
9930 $stream .=
"<ef00> <efff> <ef00>\n";
9931 $stream .=
"<f000> <f0ff> <f000>\n";
9932 $stream .=
"<f100> <f1ff> <f100>\n";
9933 $stream .=
"<f200> <f2ff> <f200>\n";
9934 $stream .=
"<f300> <f3ff> <f300>\n";
9935 $stream .=
"<f400> <f4ff> <f400>\n";
9936 $stream .=
"<f500> <f5ff> <f500>\n";
9937 $stream .=
"<f600> <f6ff> <f600>\n";
9938 $stream .=
"<f700> <f7ff> <f700>\n";
9939 $stream .=
"<f800> <f8ff> <f800>\n";
9940 $stream .=
"<f900> <f9ff> <f900>\n";
9941 $stream .=
"<fa00> <faff> <fa00>\n";
9942 $stream .=
"<fb00> <fbff> <fb00>\n";
9943 $stream .=
"<fc00> <fcff> <fc00>\n";
9944 $stream .=
"<fd00> <fdff> <fd00>\n";
9945 $stream .=
"<fe00> <feff> <fe00>\n";
9946 $stream .=
"<ff00> <ffff> <ff00>\n";
9947 $stream .=
"endbfrange\n";
9948 $stream .=
"endcmap\n";
9949 $stream .=
"CMapName currentdict /CMap defineresource pop\n";
9954 $stream = ($this->compress) ? gzcompress($stream) : $stream;
9955 $filter = ($this->compress) ?
'/Filter /FlateDecode ' :
'';
9956 $stream = $this->_getrawstream($stream);
9957 $this->_out(
'<<'.$filter.
'/Length '.strlen($stream).
'>> stream'.
"\n".$stream.
"\n".
'endstream'.
"\n".
'endobj');
9960 $oid = $this->_newobj();
9961 $out =
'<< /Type /Font';
9962 $out .=
' /Subtype /CIDFontType2';
9963 $out .=
' /BaseFont /'.$fontname;
9965 $cidinfo =
'/Registry '.$this->_datastring($font[
'cidinfo'][
'Registry'], $oid);
9966 $cidinfo .=
' /Ordering '.$this->_datastring($font[
'cidinfo'][
'Ordering'], $oid);
9967 $cidinfo .=
' /Supplement '.$font[
'cidinfo'][
'Supplement'];
9968 $out .=
' /CIDSystemInfo << '.$cidinfo.
' >>';
9969 $out .=
' /FontDescriptor '.($this->n + 1).
' 0 R';
9970 $out .=
' /DW '.$font[
'dw'];
9971 $out .=
"\n".$this->_putfontwidths($font, 0);
9972 if (isset($font[
'ctg']) AND (!$this->empty_string($font[
'ctg']))) {
9973 $out .=
"\n".
'/CIDToGIDMap '.($this->
n + 2).
' 0 R';
9976 $out .=
"\n".
'endobj';
9981 $out =
'<< /Type /FontDescriptor';
9982 $out .=
' /FontName /'.$fontname;
9983 foreach ($font[
'desc'] as $key => $value) {
9984 if(is_float($value)) {
9985 $value = sprintf(
'%.3F', $value);
9987 $out .=
' /'.$key.
' '.$value;
9990 if (!$this->empty_string($font[
'file'])) {
9992 $out .=
' /FontFile2 '.$this->FontFiles[$font[
'file']][
'n'].
' 0 R';
9993 $fontdir = $this->FontFiles[$font[
'file']][
'fontdir'];
9996 $out .=
"\n".
'endobj';
9998 if (isset($font[
'ctg']) AND (!$this->empty_string($font[
'ctg']))) {
10003 $ctgfile = strtolower($font[
'ctg']);
10007 if (($fontdir !==
false) AND file_exists($fontdir.$ctgfile)) {
10008 $fontfile = $fontdir.$ctgfile;
10009 } elseif (file_exists($this->_getfontpath().$ctgfile)) {
10010 $fontfile = $this->_getfontpath().$ctgfile;
10011 } elseif (file_exists($ctgfile)) {
10012 $fontfile = $ctgfile;
10014 if ($this->empty_string($fontfile)) {
10015 $this->Error(
'Font file not found: '.$ctgfile);
10017 $stream = $this->_getrawstream(file_get_contents($fontfile));
10018 $out =
'<< /Length '.strlen($stream).
'';
10019 if (substr($fontfile, -2) ==
'.z') {
10023 $out .=
' /Filter /FlateDecode';
10026 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
10027 $out .=
"\n".
'endobj';
10042 if (!isset($font[
'cw'][1])) {
10045 if (isset($font[
'cidinfo'][
'uni2cid'])) {
10047 $uni2cid = $font[
'cidinfo'][
'uni2cid'];
10049 foreach ($font[
'cw'] as $uni => $width) {
10050 if (isset($uni2cid[$uni])) {
10051 $cw[($uni2cid[$uni] + $cidoffset)] = $width;
10052 } elseif ($uni < 256) {
10053 $cw[$uni] = $width;
10056 $font = array_merge($font, array(
'cw' =>
$cw));
10058 $name = $font[
'name'];
10059 $enc = $font[
'enc'];
10065 $out = $this->_getobj($this->font_obj_ids[$font[
'fontkey']]).
"\n";
10066 $out .=
'<</Type /Font';
10067 $out .=
' /Subtype /Type0';
10068 $out .=
' /BaseFont /'.$longname;
10069 $out .=
' /Name /F'.$font[
'i'];
10071 $out .=
' /Encoding /'.$enc;
10073 $out .=
' /DescendantFonts ['.($this->n + 1).
' 0 R]';
10075 $out .=
"\n".
'endobj';
10077 $oid = $this->_newobj();
10078 $out =
'<</Type /Font';
10079 $out .=
' /Subtype /CIDFontType0';
10080 $out .=
' /BaseFont /'.$name;
10081 $cidinfo =
'/Registry '.$this->_datastring($font[
'cidinfo'][
'Registry'], $oid);
10082 $cidinfo .=
' /Ordering '.$this->_datastring($font[
'cidinfo'][
'Ordering'], $oid);
10083 $cidinfo .=
' /Supplement '.$font[
'cidinfo'][
'Supplement'];
10084 $out .=
' /CIDSystemInfo <<'.$cidinfo.
'>>';
10085 $out .=
' /FontDescriptor '.($this->n + 1).
' 0 R';
10086 $out .=
' /DW '.$font[
'dw'];
10087 $out .=
"\n".$this->_putfontwidths($font, $cidoffset);
10089 $out .=
"\n".
'endobj';
10092 $s =
'<</Type /FontDescriptor /FontName /'.$name;
10093 foreach ($font[
'desc'] as $k => $v) {
10094 if ($k !=
'Style') {
10096 $v = sprintf(
'%.3F', $v);
10098 $s .=
' /'.$k.
' '.$v.
'';
10102 $s .=
"\n".
'endobj';
10111 $filter = ($this->compress) ?
'/Filter /FlateDecode ' :
'';
10112 foreach ($this->imagekeys as
$file) {
10113 $info = $this->getImageBuffer($file);
10114 $oid = $this->_newobj();
10115 $this->xobjects[
'I'.$info[
'i']] = array(
'n' => $oid);
10116 $this->setImageSubBuffer($file,
'n', $this->
n);
10117 $out =
'<</Type /XObject';
10118 $out .=
' /Subtype /Image';
10119 $out .=
' /Width '.$info[
'w'];
10120 $out .=
' /Height '.$info[
'h'];
10121 if (array_key_exists(
'masked', $info)) {
10122 $out .=
' /SMask '.($this->n - 1).
' 0 R';
10124 if ($info[
'cs'] ==
'Indexed') {
10125 $out .=
' /ColorSpace [/Indexed /DeviceRGB '.((strlen($info[
'pal']) / 3) - 1).
' '.($this->
n + 1).
' 0 R]';
10127 $out .=
' /ColorSpace /'.$info[
'cs'];
10128 if ($info[
'cs'] ==
'DeviceCMYK') {
10129 $out .=
' /Decode [1 0 1 0 1 0 1 0]';
10132 $out .=
' /BitsPerComponent '.$info[
'bpc'];
10133 if (isset($info[
'f'])) {
10134 $out .=
' /Filter /'.$info[
'f'];
10136 if (isset($info[
'parms'])) {
10137 $out .=
' '.$info[
'parms'];
10139 if (isset($info[
'trns']) AND is_array($info[
'trns'])) {
10141 $count_info = count($info[
'trns']);
10142 for ($i=0; $i < $count_info; ++$i) {
10143 $trns .= $info[
'trns'][$i].
' '.$info[
'trns'][$i].
' ';
10145 $out .=
' /Mask ['.$trns.
']';
10147 $stream = $this->_getrawstream($info[
'data']);
10148 $out .=
' /Length '.strlen($stream).
' >>';
10149 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
10150 $out .=
"\n".
'endobj';
10153 if ($info[
'cs'] ==
'Indexed') {
10155 $pal = ($this->compress) ? gzcompress($info[
'pal']) : $info[
'pal'];
10156 $pal = $this->_getrawstream($pal);
10157 $this->_out(
'<<'.$filter.
'/Length '.strlen($pal).
'>> stream'.
"\n".$pal.
"\n".
'endstream'.
"\n".
'endobj');
10170 foreach ($this->xobjects as $key =>
$data) {
10171 if (isset(
$data[
'outdata'])) {
10172 $stream = trim(
$data[
'outdata']);
10173 $out = $this->_getobj(
$data[
'n']).
"\n";
10175 $out .=
' /Type /XObject';
10176 $out .=
' /Subtype /Form';
10177 $out .=
' /FormType 1';
10178 if ($this->compress) {
10179 $stream = gzcompress($stream);
10180 $out .=
' /Filter /FlateDecode';
10182 $out .= sprintf(
' /BBox [%.2F %.2F %.2F %.2F]', (
$data[
'x'] * $this->k), (-
$data[
'y'] * $this->k), ((
$data[
'w'] +
$data[
'x']) * $this->k), ((
$data[
'h'] -
$data[
'y']) * $this->k));
10183 $out .=
' /Matrix [1 0 0 1 0 0]';
10184 $out .=
' /Resources <<';
10185 $out .=
' /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]';
10187 if (!empty(
$data[
'fonts'])) {
10188 $out .=
' /Font <<';
10189 foreach (
$data[
'fonts'] as $fontkey => $fontid) {
10190 $out .=
' /F'.$fontid.
' '.$this->font_obj_ids[$fontkey].
' 0 R';
10195 if (!empty(
$data[
'images']) OR !empty(
$data[
'xobjects'])) {
10196 $out .=
' /XObject <<';
10197 foreach (
$data[
'images'] as $imgid) {
10198 $out .=
' /I'.$imgid.
' '.$this->xobjects[
'I'.$imgid][
'n'].
' 0 R';
10200 foreach (
$data[
'xobjects'] as $sub_id => $sub_objid) {
10201 $out .=
' /'.$sub_id.
' '.$sub_objid[
'n'].
' 0 R';
10206 $stream = $this->_getrawstream($stream);
10207 $out .=
' /Length '.strlen($stream);
10209 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
10210 $out .=
"\n".
'endobj';
10222 foreach ($this->spot_colors as
$name => $color) {
10224 $this->spot_colors[
$name][
'n'] = $this->n;
10225 $out =
'[/Separation /'.str_replace(
' ',
'#20',
$name);
10226 $out .=
' /DeviceCMYK <<';
10227 $out .=
' /Range [0 1 0 1 0 1 0 1] /C0 [0 0 0 0]';
10228 $out .=
' '.sprintf(
'/C1 [%.4F %.4F %.4F %.4F] ', $color[
'c']/100, $color[
'm']/100, $color[
'y']/100, $color[
'k']/100);
10229 $out .=
' /FunctionType 2 /Domain [0 1] /N 1>>]';
10230 $out .=
"\n".
'endobj';
10243 foreach ($this->xobjects as $id => $objid) {
10244 $out .=
' /'.$id.
' '.$objid[
'n'].
' 0 R';
10254 $out = $this->_getobj(2).
"\n";
10255 $out .=
'<< /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]';
10256 $out .=
' /Font <<';
10257 foreach ($this->fontkeys as $fontkey) {
10258 $font = $this->getFontBuffer($fontkey);
10259 $out .=
' /F'.$font[
'i'].
' '.$font[
'n'].
' 0 R';
10262 $out .=
' /XObject <<';
10263 $out .= $this->_getxobjectdict();
10266 $out .=
' /Properties <</OC1 '.$this->n_ocg_print.
' 0 R /OC2 '.$this->n_ocg_view.
' 0 R>>';
10268 $out .=
' /ExtGState <<';
10269 foreach ($this->extgstates as $k => $extgstate) {
10270 if (isset($extgstate[
'name'])) {
10271 $out .=
' /'.$extgstate[
'name'];
10275 $out .=
' '.$extgstate[
'n'].
' 0 R';
10279 if (isset($this->gradients) AND (count($this->gradients) > 0)) {
10280 $out .=
' /Pattern <<';
10281 foreach ($this->gradients as $id => $grad) {
10282 $out .=
' /p'.$id.
' '.$grad[
'pattern'].
' 0 R';
10287 if (isset($this->gradients) AND (count($this->gradients) > 0)) {
10288 $out .=
' /Shading <<';
10289 foreach ($this->gradients as $id => $grad) {
10290 $out .=
' /Sh'.$id.
' '.$grad[
'id'].
' 0 R';
10295 if (isset($this->spot_colors) AND (count($this->spot_colors) > 0)) {
10296 $out .=
' /ColorSpace <<';
10297 foreach ($this->spot_colors as $color) {
10298 $out .=
' /CS'.$color[
'i'].
' '.$color[
'n'].
' 0 R';
10303 $out .=
"\n".
'endobj';
10312 $this->_putextgstates();
10314 $this->_putfonts();
10315 $this->_putimages();
10316 $this->_putxobjects();
10317 $this->_putspotcolors();
10318 $this->_putshaders();
10319 $this->_putresourcedict();
10320 $this->_putbookmarks();
10321 $this->_putEmbeddedFiles();
10322 $this->_putannotsobjs();
10323 $this->_putjavascript();
10324 $this->_putencryption();
10334 $oid = $this->_newobj();
10336 if (!$this->empty_string($this->title)) {
10338 $out .=
' /Title '.$this->_textstring($this->title, $oid);
10340 if (!$this->empty_string($this->author)) {
10342 $out .=
' /Author '.$this->_textstring($this->author, $oid);
10344 if (!$this->empty_string($this->subject)) {
10346 $out .=
' /Subject '.$this->_textstring($this->subject, $oid);
10348 if (!$this->empty_string($this->keywords)) {
10350 $out .=
' /Keywords '.$this->_textstring($this->keywords.
' TCP'.
'DF', $oid);
10352 if (!$this->empty_string($this->creator)) {
10354 $out .=
' /Creator '.$this->_textstring($this->creator, $oid);
10356 if (defined(
'PDF_PRODUCER')) {
10358 $out .=
' /Producer '.$this->_textstring(
PDF_PRODUCER.
' (TCP'.
'DF)', $oid);
10361 $out .=
' /Producer '.$this->_textstring(
'TCP'.
'DF', $oid);
10364 $out .=
' /CreationDate '.$this->_datestring();
10366 $out .=
' /ModDate '.$this->_datestring();
10368 $out .=
' /Trapped /False';
10370 $out .=
"\n".
'endobj';
10381 $oid = $this->_newobj();
10382 $out =
'<< /Type /Catalog';
10383 $out .=
' /Pages 1 0 R';
10384 if ($this->ZoomMode ==
'fullpage') {
10385 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /Fit]';
10386 } elseif ($this->ZoomMode ==
'fullwidth') {
10387 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /FitH null]';
10388 } elseif ($this->ZoomMode ==
'real') {
10389 $out .=
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /XYZ null null 1]';
10390 } elseif (!is_string($this->ZoomMode)) {
10391 $out .= sprintf(
' /OpenAction ['.$this->page_obj_id[1].
' 0 R /XYZ null null %.2F]',($this->ZoomMode / 100));
10393 if (isset($this->LayoutMode) AND (!$this->empty_string($this->LayoutMode))) {
10394 $out .=
' /PageLayout /'.$this->LayoutMode;
10396 if (isset($this->PageMode) AND (!$this->empty_string($this->PageMode))) {
10397 $out .=
' /PageMode /'.$this->PageMode;
10399 if (isset($this->l[
'a_meta_language'])) {
10400 $out .=
' /Lang '.$this->_textstring($this->l[
'a_meta_language'], $oid);
10402 $out .=
' /Names <<';
10403 if ((!empty($this->javascript)) OR (!empty($this->js_objects))) {
10404 $out .=
' /JavaScript '.($this->n_js).
' 0 R';
10407 if (count($this->outlines) > 0) {
10408 $out .=
' /Outlines '.$this->OutlineRoot.
' 0 R';
10409 $out .=
' /PageMode /UseOutlines';
10411 $out .=
' '.$this->_putviewerpreferences();
10412 $p = $this->n_ocg_print.
' 0 R';
10413 $v = $this->n_ocg_view.
' 0 R';
10414 $as =
'<< /Event /Print /OCGs ['.$p.
' '.$v.
'] /Category [/Print] >> << /Event /View /OCGs ['.$p.
' '.$v.
'] /Category [/View] >>';
10415 $out .=
' /OCProperties << /OCGs ['.$p.
' '.$v.
'] /D << /ON ['.$p.
'] /OFF ['.$v.
'] /AS ['.$as.
'] >> >>';
10417 if (!empty($this->form_obj_id) OR ($this->sign AND isset($this->signature_data[
'cert_type']))) {
10418 $out .=
' /AcroForm <<';
10420 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
10421 $objrefs .= $this->sig_obj_id.
' 0 R';
10423 if (!empty($this->form_obj_id)) {
10424 foreach($this->form_obj_id as $objid) {
10425 $objrefs .=
' '.$objid.
' 0 R';
10428 $out .=
' /Fields ['.$objrefs.
']';
10429 if (!empty($this->form_obj_id) AND !$this->sign) {
10431 $out .=
' /NeedAppearances true';
10433 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
10434 if ($this->signature_data[
'cert_type'] > 0) {
10435 $out .=
' /SigFlags 3';
10437 $out .=
' /SigFlags 1';
10441 if (isset($this->annotation_fonts) AND !empty($this->annotation_fonts)) {
10443 $out .=
' /Font <<';
10444 foreach ($this->annotation_fonts as $fontkey => $fontid) {
10445 $out .=
' /F'.$fontid.
' '.$this->font_obj_ids[$fontkey].
' 0 R';
10449 $font = $this->getFontBuffer(
'helvetica');
10450 $out .=
' /DA (/F'.$font[
'i'].
' 0 Tf 0 g)';
10451 $out .=
' /Q '.(($this->rtl)?
'2':
'0');
10455 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
10456 if ($this->signature_data[
'cert_type'] > 0) {
10457 $out .=
' /Perms << /DocMDP '.($this->sig_obj_id + 1).
' 0 R >>';
10459 $out .=
' /Perms << /UR3 '.($this->sig_obj_id + 1).
' 0 R >>';
10464 $out .=
"\n".
'endobj';
10477 $out =
'/ViewerPreferences <<';
10479 $out .=
' /Direction /R2L';
10481 $out .=
' /Direction /L2R';
10483 if (isset($this->viewer_preferences[
'HideToolbar']) AND ($this->viewer_preferences[
'HideToolbar'])) {
10484 $out .=
' /HideToolbar true';
10486 if (isset($this->viewer_preferences[
'HideMenubar']) AND ($this->viewer_preferences[
'HideMenubar'])) {
10487 $out .=
' /HideMenubar true';
10489 if (isset($this->viewer_preferences[
'HideWindowUI']) AND ($this->viewer_preferences[
'HideWindowUI'])) {
10490 $out .=
' /HideWindowUI true';
10492 if (isset($this->viewer_preferences[
'FitWindow']) AND ($this->viewer_preferences[
'FitWindow'])) {
10493 $out .=
' /FitWindow true';
10495 if (isset($this->viewer_preferences[
'CenterWindow']) AND ($this->viewer_preferences[
'CenterWindow'])) {
10496 $out .=
' /CenterWindow true';
10498 if (isset($this->viewer_preferences[
'DisplayDocTitle']) AND ($this->viewer_preferences[
'DisplayDocTitle'])) {
10499 $out .=
' /DisplayDocTitle true';
10501 if (isset($this->viewer_preferences[
'NonFullScreenPageMode'])) {
10502 $out .=
' /NonFullScreenPageMode /'.$this->viewer_preferences[
'NonFullScreenPageMode'];
10504 if (isset($this->viewer_preferences[
'ViewArea'])) {
10505 $out .=
' /ViewArea /'.$this->viewer_preferences[
'ViewArea'];
10507 if (isset($this->viewer_preferences[
'ViewClip'])) {
10508 $out .=
' /ViewClip /'.$this->viewer_preferences[
'ViewClip'];
10510 if (isset($this->viewer_preferences[
'PrintArea'])) {
10511 $out .=
' /PrintArea /'.$this->viewer_preferences[
'PrintArea'];
10513 if (isset($this->viewer_preferences[
'PrintClip'])) {
10514 $out .=
' /PrintClip /'.$this->viewer_preferences[
'PrintClip'];
10516 if (isset($this->viewer_preferences[
'PrintScaling'])) {
10517 $out .=
' /PrintScaling /'.$this->viewer_preferences[
'PrintScaling'];
10519 if (isset($this->viewer_preferences[
'Duplex']) AND (!$this->empty_string($this->viewer_preferences[
'Duplex']))) {
10520 $out .=
' /Duplex /'.$this->viewer_preferences[
'Duplex'];
10522 if (isset($this->viewer_preferences[
'PickTrayByPDFSize'])) {
10523 if ($this->viewer_preferences[
'PickTrayByPDFSize']) {
10524 $out .=
' /PickTrayByPDFSize true';
10526 $out .=
' /PickTrayByPDFSize false';
10529 if (isset($this->viewer_preferences[
'PrintPageRange'])) {
10530 $PrintPageRangeNum =
'';
10531 foreach ($this->viewer_preferences[
'PrintPageRange'] as $k => $v) {
10532 $PrintPageRangeNum .=
' '.($v - 1).
'';
10534 $out .=
' /PrintPageRange ['.substr($PrintPageRangeNum,1).
']';
10536 if (isset($this->viewer_preferences[
'NumCopies'])) {
10537 $out .=
' /NumCopies '.intval($this->viewer_preferences[
'NumCopies']);
10548 $this->_out(
'%PDF-'.$this->PDFVersion);
10557 $this->_putheader();
10558 $this->_putpages();
10559 $this->_putresources();
10561 if ($this->sign AND isset($this->signature_data[
'cert_type'])) {
10563 $out = $this->_getobj($this->sig_obj_id).
"\n";
10564 $out .=
'<< /Type /Annot';
10565 $out .=
' /Subtype /Widget';
10566 $out .=
' /Rect ['.$this->signature_appearance[
'rect'].
']';
10567 $out .=
' /P '.$this->page_obj_id[($this->signature_appearance[
'page'])].
' 0 R';
10569 $out .=
' /FT /Sig';
10570 $out .=
' /T '.$this->_textstring(
'Signature', $this->sig_obj_id);
10572 $out .=
' /V '.($this->sig_obj_id + 1).
' 0 R';
10574 $out .=
"\n".
'endobj';
10577 $this->_putsignature();
10580 $objid_info = $this->_putinfo();
10582 $objid_catalog = $this->_putcatalog();
10584 $o = $this->bufferlen;
10586 $this->_out(
'xref');
10587 $this->_out(
'0 '.($this->
n + 1));
10588 $this->_out(
'0000000000 65535 f ');
10589 for ($i=1; $i <= $this->n; ++$i) {
10590 $this->_out(sprintf(
'%010d 00000 n ', $this->offsets[$i]));
10593 $out =
'trailer <<';
10594 $out .=
' /Size '.($this->n + 1);
10595 $out .=
' /Root '.$objid_catalog.
' 0 R';
10596 $out .=
' /Info '.$objid_info.
' 0 R';
10597 if ($this->encrypted) {
10598 $out .=
' /Encrypt '.$this->encryptdata[
'objid'].
' 0 R';
10600 $out .=
' /ID [ <'.$this->file_id.
'> <'.$this->file_id.
'> ]';
10603 $this->_out(
'startxref');
10605 $this->_out(
'%%EOF');
10607 if ($this->diskcache) {
10609 foreach ($this->imagekeys as $key) {
10611 unlink($this->images[$key]);
10613 foreach ($this->fontkeys as $key) {
10615 unlink($this->fonts[$key]);
10629 $this->setPageBuffer($this->page,
'');
10631 $this->transfmrk[$this->page] = array();
10633 if ($this->empty_string($orientation)) {
10634 if (isset($this->CurOrientation)) {
10635 $orientation = $this->CurOrientation;
10636 } elseif ($this->fwPt > $this->fhPt) {
10638 $orientation =
'L';
10641 $orientation =
'P';
10644 if ($this->empty_string($format)) {
10645 $this->pagedim[$this->page] = $this->pagedim[($this->page - 1)];
10646 $this->setPageOrientation($orientation);
10648 $this->setPageFormat($format, $orientation);
10651 $this->x = $this->w - $this->rMargin;
10653 $this->x = $this->lMargin;
10655 $this->y = $this->tMargin;
10656 if (isset($this->newpagegroup[$this->page])) {
10658 $n =
sizeof($this->pagegroups) + 1;
10659 $alias =
'{nb'.$n.
'}';
10660 $this->pagegroups[$alias] = 1;
10661 $this->currpagegroup = $alias;
10662 } elseif ($this->currpagegroup) {
10663 ++$this->pagegroups[$this->currpagegroup];
10672 $this->setVisibility(
'all');
10682 $this->_out($this->_getobj());
10694 if ($objid ===
'') {
10698 $this->offsets[$objid] = $this->bufferlen;
10699 return $objid.
' 0 obj';
10710 $w = $this->GetStringWidth($txt);
10711 return $this->_dounderlinew(
$x,
$y, $w);
10723 $linew = - $this->CurrentFont[
'ut'] / 1000 * $this->FontSizePt;
10724 return sprintf(
'%.2F %.2F %.2F %.2F re f',
$x * $this->k, ((($this->h -
$y) * $this->k) + $linew), $w * $this->k, $linew);
10735 $w = $this->GetStringWidth($txt);
10736 return $this->_dolinethroughw(
$x,
$y, $w);
10748 $linew = - $this->CurrentFont[
'ut'] / 1000 * $this->FontSizePt;
10749 return sprintf(
'%.2F %.2F %.2F %.2F re f',
$x * $this->k, ((($this->h -
$y) * $this->k) + $linew + ($this->FontSizePt / 3)), $w * $this->k, $linew);
10761 $w = $this->GetStringWidth($txt);
10762 return $this->_dooverlinew(
$x,
$y, $w);
10774 $linew = - $this->CurrentFont[
'ut'] / 1000 * $this->FontSizePt;
10775 return sprintf(
'%.2F %.2F %.2F %.2F re f',
$x * $this->k, (($this->h -
$y + $this->FontAscent) * $this->k) - $linew, $w * $this->k, $linew);
10786 $a = unpack(
'Ni', fread(
$f, 4));
10798 return strtr($s, array(
')' =>
'\\)',
'(' =>
'\\(',
'\\' =>
'\\\\', chr(13) =>
'\r'));
10812 $s = $this->_encrypt_data($n, $s);
10813 return '('. $this->_escape($s).
')';
10824 $current_time = substr_replace(date(
'YmdHisO'),
'\'', (0 - 2), 0).
'\'';
10825 return $this->_datastring(
'D:'.$current_time, $n);
10836 if ($this->isunicode) {
10838 $s = $this->UTF8ToUTF16BE($s,
true);
10840 return $this->_datastring($s, $n);
10852 if ($this->isunicode) {
10853 if (($this->CurrentFont[
'type'] ==
'core') OR ($this->CurrentFont[
'type'] ==
'TrueType') OR ($this->CurrentFont[
'type'] ==
'Type1')) {
10854 $s = $this->UTF8ToLatin1($s);
10857 $s = $this->utf8StrRev($s,
false, $this->tmprtl);
10860 return $this->_escape($s);
10876 return $this->_encrypt_data($n, $s);
10887 return 'stream'.
"\n".$this->_getrawstream($s, $n).
"\n".
'endstream';
10898 $this->_out($this->_getstream($s, $n));
10907 if ($this->state == 2) {
10908 if ($this->inxobj) {
10910 $this->xobjects[$this->xobjid][
'outdata'] .= $s.
"\n";
10911 } elseif ((!$this->InFooter) AND isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) {
10913 $pagebuff = $this->getPageBuffer($this->page);
10914 $page = substr($pagebuff, 0, -$this->footerlen[$this->page]);
10915 $footer = substr($pagebuff, -$this->footerlen[$this->page]);
10916 $this->setPageBuffer($this->page, $page.$s.
"\n".$footer);
10918 $this->footerpos[$this->page] += strlen($s.
"\n");
10920 $this->setPageBuffer($this->page, $s.
"\n",
true);
10923 $this->setBuffer($s.
"\n");
10963 $strkey = md5($str);
10964 if (isset($this->cache_UTF8StringToArray[$strkey])) {
10966 $chrarray = $this->cache_UTF8StringToArray[$strkey][
's'];
10967 if (!isset($this->cache_UTF8StringToArray[$strkey][
'f'][$this->CurrentFont[
'fontkey']])) {
10968 if ($this->isunicode) {
10969 foreach ($chrarray as $chr) {
10971 $this->CurrentFont[
'subsetchars'][$chr] =
true;
10974 $this->setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
10976 $this->cache_UTF8StringToArray[$strkey][
'f'][$this->CurrentFont[
'fontkey']] =
true;
10981 if ($this->cache_size_UTF8StringToArray >= $this->cache_maxsize_UTF8StringToArray) {
10983 array_shift($this->cache_UTF8StringToArray);
10986 $this->cache_UTF8StringToArray[$strkey] = array(
's' => array(),
'f' => array());
10987 ++$this->cache_size_UTF8StringToArray;
10988 if (!$this->isunicode) {
10991 $strlen = strlen($str);
10992 for ($i=0; $i < $strlen; ++$i) {
10993 $strarr[] = ord($str{$i});
10996 $this->cache_UTF8StringToArray[$strkey][
's'] = $strarr;
10997 $this->cache_UTF8StringToArray[$strkey][
'f'][$this->CurrentFont[
'fontkey']] =
true;
11001 $unicode = array();
11005 $length = strlen($str);
11006 for ($i = 0; $i < $length; ++$i) {
11007 $char = ord($str{$i});
11008 if (count($bytes) == 0) {
11009 if ($char <= 0x7F) {
11012 } elseif (($char >> 0x05) == 0x06) {
11013 $bytes[] = ($char - 0xC0) << 0x06;
11015 } elseif (($char >> 0x04) == 0x0E) {
11016 $bytes[] = ($char - 0xE0) << 0x0C;
11018 } elseif (($char >> 0x03) == 0x1E) {
11019 $bytes[] = ($char - 0xF0) << 0x12;
11027 } elseif (($char >> 0x06) == 0x02) {
11028 $bytes[] = $char - 0x80;
11029 if (count($bytes) == $numbytes) {
11032 for ($j = 1; $j < $numbytes; ++$j) {
11033 $char += ($bytes[$j] << (($numbytes - $j - 1) * 0x06));
11035 if ((($char >= 0xD800) AND ($char <= 0xDFFF)) OR ($char >= 0x10FFFF)) {
11054 if ($unichar >= 0) {
11056 $unicode[] = $unichar;
11058 $this->CurrentFont[
'subsetchars'][$unichar] =
true;
11063 $this->setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
11065 $this->cache_UTF8StringToArray[$strkey][
's'] = $unicode;
11066 $this->cache_UTF8StringToArray[$strkey][
'f'][$this->CurrentFont[
'fontkey']] =
true;
11081 if (!$this->isunicode) {
11084 $unicode = $this->UTF8StringToArray($str);
11085 return $this->arrUTF8ToUTF16BE($unicode, $setbom);
11097 if (!$this->isunicode) {
11101 $unicode = $this->UTF8StringToArray($str);
11102 foreach ($unicode as $char) {
11104 $outstr .= chr($char);
11105 } elseif (array_key_exists($char, $this->unicode->uni_utf8tolatin)) {
11107 $outstr .= chr($this->unicode->uni_utf8tolatin[$char]);
11108 } elseif ($char == 0xFFFD) {
11126 if ((!$this->isunicode) OR $this->isUnicodeFont()) {
11130 foreach ($unicode as $char) {
11133 } elseif (array_key_exists($char, $this->unicode->uni_utf8tolatin)) {
11135 $outarr[] = $this->unicode->uni_utf8tolatin[$char];
11136 } elseif ($char == 0xFFFD) {
11186 $outstr .=
"\xFE\xFF";
11188 foreach ($unicode as $char) {
11189 if ($char == 0x200b) {
11191 } elseif ($char == 0xFFFD) {
11192 $outstr .=
"\xFF\xFD";
11193 } elseif ($char < 0x10000) {
11194 $outstr .= chr($char >> 0x08);
11195 $outstr .= chr($char & 0xFF);
11198 $w1 = 0xD800 | ($char >> 0x10);
11199 $w2 = 0xDC00 | ($char & 0x3FF);
11200 $outstr .= chr($w1 >> 0x08);
11201 $outstr .= chr($w1 & 0xFF);
11202 $outstr .= chr($w2 >> 0x08);
11203 $outstr .= chr($w2 & 0xFF);
11217 $this->header_font = $font;
11227 return $this->header_font;
11237 $this->footer_font = $font;
11247 return $this->footer_font;
11257 $this->l = $language;
11258 if (isset($this->l[
'a_meta_dir'])) {
11259 $this->rtl = $this->l[
'a_meta_dir']==
'rtl' ?
true :
false;
11261 $this->rtl =
false;
11270 if ($this->state < 3) {
11273 return $this->buffer;
11288 public function addHtmlLink($url,
$name, $fill=
false, $firstline=
false, $color=
'', $style=-1, $firstblock=
false) {
11289 if (!$this->empty_string($url) AND ($url{0} ==
'#')) {
11291 $lnkdata = explode(
',', $url);
11292 if (isset($lnkdata[0])) {
11293 $page = intval(substr($lnkdata[0], 1));
11294 if (empty($page) OR ($page <= 0)) {
11295 $page = $this->page;
11297 if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
11298 $lnky = floatval($lnkdata[1]);
11302 $url = $this->AddLink();
11303 $this->SetLink($url, $lnky, $page);
11307 $prevcolor = $this->fgcolor;
11308 $prevstyle = $this->FontStyle;
11309 if (empty($color)) {
11310 $this->SetTextColorArray($this->htmlLinkColorArray);
11312 $this->SetTextColorArray($color);
11314 if ($style == -1) {
11315 $this->SetFont(
'', $this->FontStyle.$this->htmlLinkFontStyle);
11317 $this->SetFont(
'', $this->FontStyle.$style);
11319 $ret = $this->Write($this->lasth,
$name, $url, $fill,
'',
false, 0, $firstline, $firstblock, 0);
11321 $this->SetFont(
'', $prevstyle);
11322 $this->SetTextColorArray($prevcolor);
11333 $returncolor =
false;
11334 $color = preg_replace(
'/[\s]*/',
'', $color);
11335 $color = strtolower($color);
11336 if (($dotpos = strpos($color,
'.')) !==
false) {
11338 $color = substr($color, ($dotpos + 1));
11340 if (strlen($color) == 0) {
11344 if (substr($color, 0, 3) ==
'rgb') {
11345 $codes = substr($color, 4);
11346 $codes = str_replace(
')',
'', $codes);
11347 $returncolor = explode(
',', $codes);
11348 return $returncolor;
11351 if (substr($color, 0, 4) ==
'cmyk') {
11352 $codes = substr($color, 5);
11353 $codes = str_replace(
')',
'', $codes);
11354 $returncolor = explode(
',', $codes);
11355 return $returncolor;
11358 if (substr($color, 0, 1) !=
'#') {
11360 if (isset($this->webcolor[$color])) {
11361 $color_code = $this->webcolor[$color];
11366 $color_code = substr($color, 1);
11369 switch (strlen($color_code)) {
11372 $r = substr($color_code, 0, 1);
11373 $g = substr($color_code, 1, 1);
11374 $b = substr($color_code, 2, 1);
11375 $returncolor[
'R'] = hexdec($r.$r);
11376 $returncolor[
'G'] = hexdec($g.$g);
11377 $returncolor[
'B'] = hexdec($b.$b);
11382 $returncolor[
'R'] = hexdec(substr($color_code, 0, 2));
11383 $returncolor[
'G'] = hexdec(substr($color_code, 2, 2));
11384 $returncolor[
'B'] = hexdec(substr($color_code, 4, 2));
11388 return $returncolor;
11399 return ($px / ($this->imgscale * $this->k));
11410 return html_entity_decode($text_to_convert, ENT_QUOTES, $this->encoding);
11424 $seed .= microtime();
11425 if (function_exists(
'openssl_random_pseudo_bytes')) {
11426 $seed .= openssl_random_pseudo_bytes(512);
11428 $seed .= uniqid(
'',
true);
11430 $seed .= getmypid();
11432 $seed .= $this->bufferlen;
11433 if (isset($_SERVER[
'REMOTE_ADDR'])) {
11434 $seed .= $_SERVER[
'REMOTE_ADDR'];
11436 if (isset($_SERVER[
'HTTP_USER_AGENT'])) {
11437 $seed .= $_SERVER[
'HTTP_USER_AGENT'];
11439 if (isset($_SERVER[
'HTTP_ACCEPT'])) {
11440 $seed .= $_SERVER[
'HTTP_ACCEPT'];
11442 if (isset($_SERVER[
'HTTP_ACCEPT_ENCODING'])) {
11443 $seed .= $_SERVER[
'HTTP_ACCEPT_ENCODING'];
11445 if (isset($_SERVER[
'HTTP_ACCEPT_LANGUAGE'])) {
11446 $seed .= $_SERVER[
'HTTP_ACCEPT_LANGUAGE'];
11448 if (isset($_SERVER[
'HTTP_ACCEPT_CHARSET'])) {
11449 $seed .= $_SERVER[
'HTTP_ACCEPT_CHARSET'];
11452 $seed .= uniqid(
'',
true);
11453 $seed .= microtime();
11467 $objkey = $this->encryptdata[
'key'].pack(
'VXxx', $n);
11468 if ($this->encryptdata[
'mode'] == 2) {
11470 $objkey .=
"\x73\x41\x6C\x54";
11472 $objkey = substr($this->_md5_16($objkey), 0, (($this->encryptdata[
'Length'] / 8) + 5));
11473 $objkey = substr($objkey, 0, 16);
11487 if (!$this->encrypted) {
11490 switch ($this->encryptdata[
'mode']) {
11493 $s = $this->_RC4($this->_objectkey($n), $s);
11497 $s = $this->_AES($this->_objectkey($n), $s);
11501 $s = $this->_AES($this->encryptdata[
'key'], $s);
11515 if (!$this->encrypted) {
11518 $this->encryptdata[
'objid'] = $this->_newobj();
11520 if (!isset($this->encryptdata[
'Filter']) OR empty($this->encryptdata[
'Filter'])) {
11521 $this->encryptdata[
'Filter'] =
'Standard';
11523 $out .=
' /Filter /'.$this->encryptdata[
'Filter'];
11524 if (isset($this->encryptdata[
'SubFilter']) AND !empty($this->encryptdata[
'SubFilter'])) {
11525 $out .=
' /SubFilter /'.$this->encryptdata[
'SubFilter'];
11527 if (!isset($this->encryptdata[
'V']) OR empty($this->encryptdata[
'V'])) {
11528 $this->encryptdata[
'V'] = 1;
11531 $out .=
' /V '.$this->encryptdata[
'V'];
11532 if (isset($this->encryptdata[
'Length']) AND !empty($this->encryptdata[
'Length'])) {
11534 $out .=
' /Length '.$this->encryptdata[
'Length'];
11536 $out .=
' /Length 40';
11538 if ($this->encryptdata[
'V'] >= 4) {
11539 if (!isset($this->encryptdata[
'StmF']) OR empty($this->encryptdata[
'StmF'])) {
11540 $this->encryptdata[
'StmF'] =
'Identity';
11542 if (!isset($this->encryptdata[
'StrF']) OR empty($this->encryptdata[
'StrF'])) {
11544 $this->encryptdata[
'StrF'] =
'Identity';
11547 if (isset($this->encryptdata[
'CF']) AND !empty($this->encryptdata[
'CF'])) {
11549 $out .=
' /'.$this->encryptdata[
'StmF'].
' <<';
11550 $out .=
' /Type /CryptFilter';
11551 if (isset($this->encryptdata[
'CF'][
'CFM']) AND !empty($this->encryptdata[
'CF'][
'CFM'])) {
11553 $out .=
' /CFM /'.$this->encryptdata[
'CF'][
'CFM'];
11554 if ($this->encryptdata[
'pubkey']) {
11555 $out .=
' /Recipients [';
11556 foreach ($this->encryptdata[
'Recipients'] as $rec) {
11557 $out .=
' <'.$rec.
'>';
11560 if (isset($this->encryptdata[
'CF'][
'EncryptMetadata']) AND (!$this->encryptdata[
'CF'][
'EncryptMetadata'])) {
11561 $out .=
' /EncryptMetadata false';
11563 $out .=
' /EncryptMetadata true';
11567 $out .=
' /CFM /None';
11569 if (isset($this->encryptdata[
'CF'][
'AuthEvent']) AND !empty($this->encryptdata[
'CF'][
'AuthEvent'])) {
11571 $out .=
' /AuthEvent /'.$this->encryptdata[
'CF'][
'AuthEvent'];
11573 $out .=
' /AuthEvent /DocOpen';
11575 if (isset($this->encryptdata[
'CF'][
'Length']) AND !empty($this->encryptdata[
'CF'][
'Length'])) {
11577 $out .=
' /Length '.$this->encryptdata[
'CF'][
'Length'];
11582 $out .=
' /StmF /'.$this->encryptdata[
'StmF'];
11584 $out .=
' /StrF /'.$this->encryptdata[
'StrF'];
11585 if (isset($this->encryptdata[
'EFF']) AND !empty($this->encryptdata[
'EFF'])) {
11587 $out .=
' /EFF /'.$this->encryptdata[
''];
11591 if ($this->encryptdata[
'pubkey']) {
11592 if (($this->encryptdata[
'V'] < 4) AND isset($this->encryptdata[
'Recipients']) AND !empty($this->encryptdata[
'Recipients'])) {
11593 $out .=
' /Recipients [';
11594 foreach ($this->encryptdata[
'Recipients'] as $rec) {
11595 $out .=
' <'.$rec.
'>';
11601 if ($this->encryptdata[
'V'] == 5) {
11603 $out .=
' /OE ('.$this->_escape($this->encryptdata[
'OE']).
')';
11604 $out .=
' /UE ('.$this->_escape($this->encryptdata[
'UE']).
')';
11605 $out .=
' /Perms ('.$this->_escape($this->encryptdata[
'perms']).
')';
11606 } elseif ($this->encryptdata[
'V'] == 4) {
11608 } elseif ($this->encryptdata[
'V'] < 2) {
11613 $out .=
' /O ('.$this->_escape($this->encryptdata[
'O']).
')';
11614 $out .=
' /U ('.$this->_escape($this->encryptdata[
'U']).
')';
11615 $out .=
' /P '.$this->encryptdata[
'P'];
11616 if (isset($this->encryptdata[
'EncryptMetadata']) AND (!$this->encryptdata[
'EncryptMetadata'])) {
11617 $out .=
' /EncryptMetadata false';
11619 $out .=
' /EncryptMetadata true';
11623 $out .=
"\n".
'endobj';
11638 if (function_exists(
'mcrypt_decrypt') AND (
$out = @mcrypt_decrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM,
''))) {
11642 if ($this->last_enc_key != $key) {
11643 $k = str_repeat($key, ((256 / strlen($key)) + 1));
11644 $rc4 = range(0, 255);
11646 for ($i = 0; $i < 256; ++$i) {
11648 $j = ($j +
$t + ord($k{$i})) % 256;
11649 $rc4[$i] = $rc4[$j];
11652 $this->last_enc_key = $key;
11653 $this->last_enc_key_c = $rc4;
11655 $rc4 = $this->last_enc_key_c;
11657 $len = strlen($text);
11661 for ($i = 0; $i < $len; ++$i) {
11662 $a = ($a + 1) % 256;
11664 $b = ($b +
$t) % 256;
11665 $rc4[$a] = $rc4[$b];
11667 $k = $rc4[($rc4[$a] + $rc4[$b]) % 256];
11668 $out .= chr(ord($text{$i}) ^ $k);
11685 $padding = 16 - (strlen($text) % 16);
11686 $text .= str_repeat(chr($padding), $padding);
11687 $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
11688 $text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
11702 return pack(
'H*', md5($str));
11713 if ($this->encryptdata[
'mode'] == 0) {
11714 return $this->_RC4($this->encryptdata[
'key'], $this->enc_padding);
11715 } elseif ($this->encryptdata[
'mode'] < 3) {
11716 $tmp = $this->_md5_16($this->enc_padding.$this->encryptdata[
'fileid']);
11717 $enc = $this->_RC4($this->encryptdata[
'key'], $tmp);
11718 $len = strlen($tmp);
11719 for ($i = 1; $i <= 19; ++$i) {
11721 for ($j = 0; $j < $len; ++$j) {
11722 $ek .= chr(ord($this->encryptdata[
'key']{$j}) ^ $i);
11726 $enc .= str_repeat(
"\x00", 16);
11727 return substr(
$enc, 0, 32);
11728 } elseif ($this->encryptdata[
'mode'] == 3) {
11729 $seed = $this->_md5_16($this->getRandomSeed());
11731 $this->encryptdata[
'UVS'] = substr($seed, 0, 8);
11733 $this->encryptdata[
'UKS'] = substr($seed, 8, 16);
11734 return hash(
'sha256', $this->encryptdata[
'user_password'].$this->encryptdata[
'UVS'],
true).$this->encryptdata[
'UVS'].$this->encryptdata[
'UKS'];
11746 $hashkey = hash(
'sha256', $this->encryptdata[
'user_password'].$this->encryptdata[
'UKS'],
true);
11747 $iv = str_repeat(
"\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
11748 return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $hashkey, $this->encryptdata[
'key'], MCRYPT_MODE_CBC, $iv);
11759 if ($this->encryptdata[
'mode'] < 3) {
11760 $tmp = $this->_md5_16($this->encryptdata[
'owner_password']);
11761 if ($this->encryptdata[
'mode'] > 0) {
11762 for ($i = 0; $i < 50; ++$i) {
11763 $tmp = $this->_md5_16($tmp);
11766 $owner_key = substr($tmp, 0, ($this->encryptdata[
'Length'] / 8));
11767 $enc = $this->_RC4($owner_key, $this->encryptdata[
'user_password']);
11768 if ($this->encryptdata[
'mode'] > 0) {
11769 $len = strlen($owner_key);
11770 for ($i = 1; $i <= 19; ++$i) {
11772 for ($j = 0; $j < $len; ++$j) {
11773 $ek .= chr(ord($owner_key{$j}) ^ $i);
11779 } elseif ($this->encryptdata[
'mode'] == 3) {
11780 $seed = $this->_md5_16($this->getRandomSeed());
11782 $this->encryptdata[
'OVS'] = substr($seed, 0, 8);
11784 $this->encryptdata[
'OKS'] = substr($seed, 8, 16);
11785 return hash(
'sha256', $this->encryptdata[
'owner_password'].$this->encryptdata[
'OVS'].$this->encryptdata[
'U'],
true).$this->encryptdata[
'OVS'].$this->encryptdata[
'OKS'];
11797 $hashkey = hash(
'sha256', $this->encryptdata[
'owner_password'].$this->encryptdata[
'OKS'].$this->encryptdata[
'U'],
true);
11798 $iv = str_repeat(
"\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
11799 return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $hashkey, $this->encryptdata[
'key'], MCRYPT_MODE_CBC, $iv);
11811 $psw_array = $this->utf8Bidi($this->UTF8StringToArray($password), $password, $this->rtl);
11812 foreach ($psw_array as $c) {
11813 $psw .= $this->unichr($c);
11815 return substr($psw, 0, 127);
11825 $keybytelen = ($this->encryptdata[
'Length'] / 8);
11826 if (!$this->encryptdata[
'pubkey']) {
11827 if ($this->encryptdata[
'mode'] == 3) {
11829 $this->encryptdata[
'key'] = substr(hash(
'sha256', $this->getRandomSeed(),
true), 0, $keybytelen);
11831 $this->encryptdata[
'user_password'] = $this->_fixAES256Password($this->encryptdata[
'user_password']);
11832 $this->encryptdata[
'owner_password'] = $this->_fixAES256Password($this->encryptdata[
'owner_password']);
11834 $this->encryptdata[
'U'] = $this->_Uvalue();
11836 $this->encryptdata[
'UE'] = $this->_UEvalue();
11838 $this->encryptdata[
'O'] = $this->_Ovalue();
11840 $this->encryptdata[
'OE'] = $this->_OEvalue();
11842 $this->encryptdata[
'P'] = $this->encryptdata[
'protection'];
11844 $perms = $this->getEncPermissionsString($this->encryptdata[
'protection']);
11845 $perms .= chr(255).chr(255).chr(255).chr(255);
11846 if (isset($this->encryptdata[
'CF'][
'EncryptMetadata']) AND (!$this->encryptdata[
'CF'][
'EncryptMetadata'])) {
11853 $iv = str_repeat(
"\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB));
11854 $this->encryptdata[
'perms'] = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->encryptdata[
'key'], $perms, MCRYPT_MODE_ECB, $iv);
11857 $this->encryptdata[
'user_password'] = substr($this->encryptdata[
'user_password'].$this->enc_padding, 0, 32);
11858 $this->encryptdata[
'owner_password'] = substr($this->encryptdata[
'owner_password'].$this->enc_padding, 0, 32);
11860 $this->encryptdata[
'O'] = $this->_Ovalue();
11862 $permissions = $this->getEncPermissionsString($this->encryptdata[
'protection']);
11864 $tmp = $this->_md5_16($this->encryptdata[
'user_password'].$this->encryptdata[
'O'].$permissions.$this->encryptdata[
'fileid']);
11865 if ($this->encryptdata[
'mode'] > 0) {
11866 for ($i = 0; $i < 50; ++$i) {
11867 $tmp = $this->_md5_16(substr($tmp, 0, $keybytelen));
11870 $this->encryptdata[
'key'] = substr($tmp, 0, $keybytelen);
11872 $this->encryptdata[
'U'] = $this->_Uvalue();
11874 $this->encryptdata[
'P'] = $this->encryptdata[
'protection'];
11878 $seed = sha1($this->getRandomSeed(),
true);
11879 $recipient_bytes =
'';
11880 foreach ($this->encryptdata[
'pubkeys'] as $pubkey) {
11882 if (isset($pubkey[
'p'])) {
11883 $pkprotection = $this->getUserPermissionCode($pubkey[
'p'], $this->encryptdata[
'mode']);
11885 $pkprotection = $this->encryptdata[
'protection'];
11888 $pkpermissions = $this->getEncPermissionsString($pkprotection);
11890 $envelope = $seed.$pkpermissions;
11893 $f = fopen($tempkeyfile,
'wb');
11895 $this->Error(
'Unable to create temporary key file: '.$tempkeyfile);
11897 $envelope_lenght = strlen($envelope);
11898 fwrite(
$f, $envelope, $envelope_lenght);
11901 if (!openssl_pkcs7_encrypt($tempkeyfile, $tempencfile, $pubkey[
'c'], array(), PKCS7_DETACHED | PKCS7_BINARY)) {
11902 $this->Error(
'Unable to encrypt the file: '.$tempkeyfile);
11904 unlink($tempkeyfile);
11906 $signature = file_get_contents($tempencfile,
false, null, $envelope_lenght);
11907 unlink($tempencfile);
11909 $signature = substr($signature, strpos($signature,
'Content-Disposition'));
11910 $tmparr = explode(
"\n\n", $signature);
11911 $signature = trim($tmparr[1]);
11914 $signature = base64_decode($signature);
11916 $hexsignature = current(unpack(
'H*', $signature));
11918 $this->encryptdata[
'Recipients'][] = $hexsignature;
11920 $recipient_bytes .= $signature;
11923 if ($this->encryptdata[
'mode'] == 3) {
11924 $this->encryptdata[
'key'] = substr(hash(
'sha256', $seed.$recipient_bytes,
true), 0, $keybytelen);
11926 $this->encryptdata[
'key'] = substr(sha1($seed.$recipient_bytes,
true), 0, $keybytelen);
11945 'annot-forms' => 32,
11946 'fill-forms' => 256,
11948 'assemble' => 1024,
11949 'print-high' => 2048
11951 $protection = 2147422012;
11952 foreach ($permissions as $permission) {
11953 if (!isset($options[$permission])) {
11954 $this->Error(
'Incorrect permission: '.$permission);
11956 if (($mode > 0) OR ($options[$permission] <= 32)) {
11958 if ($options[$permission] == 2) {
11960 $protection += $options[$permission];
11962 $protection -= $options[$permission];
11966 return $protection;
11983 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) {
11984 $this->encryptdata[
'protection'] = $this->getUserPermissionCode($permissions, $mode);
11985 if (($pubkeys !== null) AND (is_array($pubkeys))) {
11987 $this->encryptdata[
'pubkeys'] = $pubkeys;
11992 if (!function_exists(
'openssl_pkcs7_encrypt')) {
11993 $this->Error(
'Public-Key Security requires openssl library.');
11996 $this->encryptdata[
'pubkey'] =
true;
11997 $this->encryptdata[
'Filter'] =
'Adobe.PubSec';
11998 $this->encryptdata[
'StmF'] =
'DefaultCryptFilter';
11999 $this->encryptdata[
'StrF'] =
'DefaultCryptFilter';
12002 $this->encryptdata[
'pubkey'] =
false;
12003 $this->encryptdata[
'Filter'] =
'Standard';
12004 $this->encryptdata[
'StmF'] =
'StdCF';
12005 $this->encryptdata[
'StrF'] =
'StdCF';
12008 if (!extension_loaded(
'mcrypt')) {
12009 $this->Error(
'AES encryption requires mcrypt library (http://www.php.net/manual/en/mcrypt.requirements.php).');
12011 if (mcrypt_get_cipher_name(MCRYPT_RIJNDAEL_128) ===
false) {
12012 $this->Error(
'AES encryption requires MCRYPT_RIJNDAEL_128 cypher.');
12014 if (($mode == 3) AND !function_exists(
'hash')) {
12016 $this->Error(
'AES 256 encryption requires HASH Message Digest Framework (http://www.php.net/manual/en/book.hash.php).');
12019 if ($owner_pass === null) {
12020 $owner_pass = md5($this->getRandomSeed());
12022 $this->encryptdata[
'user_password'] = $user_pass;
12023 $this->encryptdata[
'owner_password'] = $owner_pass;
12024 $this->encryptdata[
'mode'] = $mode;
12027 $this->encryptdata[
'V'] = 1;
12028 $this->encryptdata[
'Length'] = 40;
12029 $this->encryptdata[
'CF'][
'CFM'] =
'V2';
12033 $this->encryptdata[
'V'] = 2;
12034 $this->encryptdata[
'Length'] = 128;
12035 $this->encryptdata[
'CF'][
'CFM'] =
'V2';
12036 if ($this->encryptdata[
'pubkey']) {
12037 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s4';
12038 $this->encryptdata[
'Recipients'] = array();
12043 $this->encryptdata[
'V'] = 4;
12044 $this->encryptdata[
'Length'] = 128;
12045 $this->encryptdata[
'CF'][
'CFM'] =
'AESV2';
12046 $this->encryptdata[
'CF'][
'Length'] = 128;
12047 if ($this->encryptdata[
'pubkey']) {
12048 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s5';
12049 $this->encryptdata[
'Recipients'] = array();
12054 $this->encryptdata[
'V'] = 5;
12055 $this->encryptdata[
'Length'] = 256;
12056 $this->encryptdata[
'CF'][
'CFM'] =
'AESV3';
12057 $this->encryptdata[
'CF'][
'Length'] = 256;
12058 if ($this->encryptdata[
'pubkey']) {
12059 $this->encryptdata[
'SubFilter'] =
'adbe.pkcs7.s5';
12060 $this->encryptdata[
'Recipients'] = array();
12065 $this->encrypted =
true;
12066 $this->encryptdata[
'fileid'] = $this->convertHexStringToString($this->file_id);
12067 $this->_generateencryptionkey();
12080 $bslenght = strlen($bs);
12081 if (($bslenght % 2) != 0) {
12086 for ($i = 0; $i < $bslenght; $i += 2) {
12087 $string .= chr(hexdec($bs{$i}.$bs{($i + 1)}));
12102 $chars = preg_split(
'//', $s, -1, PREG_SPLIT_NO_EMPTY);
12103 foreach ($chars as $c) {
12104 $bs .= sprintf(
'%02s', dechex(ord($c)));
12118 $binprot = sprintf(
'%032b', $protection);
12119 $str = chr(bindec(substr($binprot, 24, 8)));
12120 $str .= chr(bindec(substr($binprot, 16, 8)));
12121 $str .= chr(bindec(substr($binprot, 8, 8)));
12122 $str .= chr(bindec(substr($binprot, 0, 8)));
12140 if ($this->inxobj) {
12142 $this->xobjects[$this->xobjid][
'transfmrk'][] = strlen($this->xobjects[$this->xobjid][
'outdata']);
12144 $this->transfmrk[$this->page][] = $this->pagelen[$this->page];
12146 ++$this->transfmatrix_key;
12147 $this->transfmatrix[$this->transfmatrix_key] = array();
12160 if (isset($this->transfmatrix[$this->transfmatrix_key])) {
12161 array_pop($this->transfmatrix[$this->transfmatrix_key]);
12162 --$this->transfmatrix_key;
12164 if ($this->inxobj) {
12166 array_pop($this->xobjects[$this->xobjid][
'transfmrk']);
12168 array_pop($this->transfmrk[$this->page]);
12181 $this->Scale($s_x, 100,
$x,
$y);
12194 $this->Scale(100, $s_y,
$x,
$y);
12207 $this->Scale($s, $s,
$x,
$y);
12227 if (($s_x == 0) OR ($s_y == 0)) {
12228 $this->Error(
'Please do not use values equal to zero for scaling');
12230 $y = ($this->h -
$y) * $this->k;
12240 $tm[4] =
$x * (1 - $s_x);
12241 $tm[5] =
$y * (1 - $s_y);
12243 $this->Transform($tm);
12254 $this->Scale(-100, 100,
$x);
12265 $this->Scale(100, -100,
'',
$y);
12277 $this->Scale(-100, -100,
$x,
$y);
12290 $this->Scale(-100, 100,
$x,
$y);
12291 $this->Rotate(-2*($angle-90),
$x,
$y);
12302 $this->Translate($t_x, 0);
12313 $this->Translate(0, $t_y);
12331 $tm[4] = $t_x * $this->k;
12332 $tm[5] = -$t_y * $this->k;
12334 $this->Transform($tm);
12353 $y = ($this->h -
$y) * $this->k;
12357 $tm[0] = cos(deg2rad($angle));
12358 $tm[1] = sin(deg2rad($angle));
12361 $tm[4] =
$x + ($tm[1] *
$y) - ($tm[0] *
$x);
12362 $tm[5] =
$y - ($tm[0] *
$y) - ($tm[1] * $x);
12364 $this->Transform($tm);
12377 $this->Skew($angle_x, 0,
$x,
$y);
12390 $this->Skew(0, $angle_y,
$x,
$y);
12410 if (($angle_x <= -90) OR ($angle_x >= 90) OR ($angle_y <= -90) OR ($angle_y >= 90)) {
12411 $this->Error(
'Please use values between -90 and +90 degrees for Skewing.');
12414 $y = ($this->h -
$y) * $this->k;
12418 $tm[1] = tan(deg2rad($angle_y));
12419 $tm[2] = tan(deg2rad($angle_x));
12421 $tm[4] = -$tm[2] *
$y;
12422 $tm[5] = -$tm[1] *
$x;
12424 $this->Transform($tm);
12435 $this->_out(sprintf(
'%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
12437 $this->transfmatrix[$this->transfmatrix_key][] = array(
'a' => $tm[0],
'b' => $tm[1],
'c' => $tm[2],
'd' => $tm[3],
'e' => $tm[4],
'f' => $tm[5]);
12439 if ($this->inxobj) {
12441 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
12442 $key = key($this->xobjects[$this->xobjid][
'transfmrk']);
12443 $this->xobjects[$this->xobjid][
'transfmrk'][$key] = strlen($this->xobjects[$this->xobjid][
'outdata']);
12445 } elseif (end($this->transfmrk[$this->page]) !==
false) {
12446 $key = key($this->transfmrk[$this->page]);
12447 $this->transfmrk[$this->page][$key] = $this->pagelen[$this->page];
12465 $this->LineWidth = $width;
12466 $this->linestyleWidth = sprintf(
'%.2F w', ($width * $this->k));
12467 if ($this->page > 0) {
12468 $this->_out($this->linestyleWidth);
12480 return $this->LineWidth;
12508 if (!is_array($style)) {
12512 if (isset($width)) {
12513 $this->LineWidth = $width;
12514 $this->linestyleWidth = sprintf(
'%.2F w', ($width * $this->k));
12515 $s .= $this->linestyleWidth.
' ';
12518 $ca = array(
'butt' => 0,
'round'=> 1,
'square' => 2);
12519 if (isset($ca[$cap])) {
12520 $this->linestyleCap = $ca[$cap].
' J';
12521 $s .= $this->linestyleCap.
' ';
12524 if (isset($join)) {
12525 $ja = array(
'miter' => 0,
'round' => 1,
'bevel' => 2);
12526 if (isset($ja[$join])) {
12527 $this->linestyleJoin = $ja[$join].
' j';
12528 $s .= $this->linestyleJoin.
' ';
12531 if (isset($dash)) {
12534 if (preg_match(
'/^.+,/', $dash) > 0) {
12535 $tab = explode(
',', $dash);
12537 $tab = array($dash);
12540 foreach (
$tab as $i => $v) {
12542 $dash_string .=
' ';
12544 $dash_string .= sprintf(
'%.2F', $v);
12547 if (!isset($phase) OR !$dash) {
12550 $this->linestyleDash = sprintf(
'[%s] %.2F d', $dash_string, $phase);
12551 $s .= $this->linestyleDash.
' ';
12553 if (isset($color)) {
12554 $s .= $this->SetDrawColorArray($color,
true).
' ';
12570 $this->_out(sprintf(
'%.2F %.2F m',
$x * $this->k, ($this->h -
$y) * $this->k));
12582 $this->_out(sprintf(
'%.2F %.2F l',
$x * $this->k, ($this->h -
$y) * $this->k));
12596 $this->_out(sprintf(
'%.2F %.2F %.2F %.2F re %s',
$x * $this->k, ($this->h -
$y) * $this->k, $w * $this->k, -$h * $this->k, $op));
12612 $this->_out(sprintf(
'%.2F %.2F %.2F %.2F %.2F %.2F 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));
12626 $this->_out(sprintf(
'%.2F %.2F %.2F %.2F v', $x2 * $this->k, ($this->h - $y2) * $this->k, $x3 * $this->k, ($this->h - $y3) * $this->k));
12642 $this->_out(sprintf(
'%.2F %.2F %.2F %.2F y', $x1 * $this->k, ($this->h - $y1) * $this->k, $x3 * $this->k, ($this->h - $y3) * $this->k));
12656 public function Line($x1, $y1, $x2, $y2, $style=array()) {
12657 if (is_array($style)) {
12658 $this->SetLineStyle($style);
12660 $this->_outPoint($x1, $y1);
12661 $this->_outLine($x2, $y2);
12684 public function Rect(
$x,
$y, $w, $h, $style=
'', $border_style=array(), $fill_color=array()) {
12685 if (!(
false === strpos($style,
'F')) AND !empty($fill_color)) {
12686 $this->SetFillColorArray($fill_color);
12688 $op = $this->getPathPaintOperator($style);
12689 if ((!$border_style) OR (isset($border_style[
'all']))) {
12690 if (isset($border_style[
'all']) AND $border_style[
'all']) {
12691 $this->SetLineStyle($border_style[
'all']);
12692 $border_style = array();
12695 $this->_outRect(
$x,
$y, $w, $h, $op);
12696 if ($border_style) {
12697 $border_style2 = array();
12698 foreach ($border_style as $line => $value) {
12699 $length = strlen($line);
12700 for ($i = 0; $i < $length; ++$i) {
12701 $border_style2[$line[$i]] = $value;
12704 $border_style = $border_style2;
12705 if (isset($border_style[
'L']) AND $border_style[
'L']) {
12706 $this->Line(
$x,
$y,
$x,
$y + $h, $border_style[
'L']);
12708 if (isset($border_style[
'T']) AND $border_style[
'T']) {
12709 $this->Line(
$x,
$y,
$x + $w,
$y, $border_style[
'T']);
12711 if (isset($border_style[
'R']) AND $border_style[
'R']) {
12712 $this->Line(
$x + $w,
$y,
$x + $w,
$y + $h, $border_style[
'R']);
12714 if (isset($border_style[
'B']) AND $border_style[
'B']) {
12715 $this->Line(
$x,
$y + $h,
$x + $w,
$y + $h, $border_style[
'B']);
12739 public function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style=
'', $line_style=array(), $fill_color=array()) {
12740 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
12741 $this->SetFillColorArray($fill_color);
12743 $op = $this->getPathPaintOperator($style);
12745 $this->SetLineStyle($line_style);
12747 $this->_outPoint($x0, $y0);
12748 $this->_outCurve($x1, $y1, $x2, $y2, $x3, $y3);
12766 public function Polycurve($x0, $y0, $segments, $style=
'', $line_style=array(), $fill_color=array()) {
12767 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
12768 $this->SetFillColorArray($fill_color);
12770 $op = $this->getPathPaintOperator($style);
12772 $line_style = array();
12775 $this->SetLineStyle($line_style);
12777 $this->_outPoint($x0, $y0);
12778 foreach ($segments as $segment) {
12779 list($x1, $y1, $x2, $y2, $x3, $y3) = $segment;
12780 $this->_outCurve($x1, $y1, $x2, $y2, $x3, $y3);
12803 public function Ellipse($x0, $y0, $rx, $ry=
'', $angle=0, $astart=0, $afinish=360, $style=
'', $line_style=array(), $fill_color=array(), $nc=2) {
12804 if ($this->empty_string($ry) OR ($ry == 0)) {
12807 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
12808 $this->SetFillColorArray($fill_color);
12810 $op = $this->getPathPaintOperator($style);
12812 $line_style = array();
12815 $this->SetLineStyle($line_style);
12817 $this->_outellipticalarc($x0, $y0, $rx, $ry, $angle, $astart, $afinish,
false, $nc);
12837 protected function _outellipticalarc($xc, $yc, $rx, $ry, $xang=0, $angs=0, $angf=360, $pie=
false, $nc=2) {
12844 $this->_outPoint($xc, $yc);
12846 $xang = deg2rad((
float) $xang);
12847 $angs = deg2rad((
float) $angs);
12848 $angf = deg2rad((
float) $angf);
12849 $as = atan2((sin($angs) / $ry), (cos($angs) / $rx));
12850 $af = atan2((sin($angf) / $ry), (cos($angf) / $rx));
12861 $total_angle = ($af - $as);
12866 $nc *= (2 * abs($total_angle) / M_PI);
12867 $nc = round($nc) + 1;
12869 $arcang = $total_angle / $nc;
12872 $y0 = ($this->h - $yc);
12875 $alpha = sin($arcang) * ((sqrt(4 + (3 * pow(tan(($arcang) / 2), 2))) - 1) / 3);
12876 $cos_xang = cos($xang);
12877 $sin_xang = sin($xang);
12878 $cos_ang = cos($ang);
12879 $sin_ang = sin($ang);
12881 $px1 = $x0 + ($rx * $cos_xang * $cos_ang) - ($ry * $sin_xang * $sin_ang);
12882 $py1 = $y0 + ($rx * $sin_xang * $cos_ang) + ($ry * $cos_xang * $sin_ang);
12884 $qx1 = ($alpha * ((-$rx * $cos_xang * $sin_ang) - ($ry * $sin_xang * $cos_ang)));
12885 $qy1 = ($alpha * ((-$rx * $sin_xang * $sin_ang) + ($ry * $cos_xang * $cos_ang)));
12887 $this->_outLine($px1, $this->h - $py1);
12889 $this->_outPoint($px1, $this->h - $py1);
12892 for ($i = 1; $i <= $nc; ++$i) {
12894 $ang = $as + ($i * $arcang);
12895 $cos_xang = cos($xang);
12896 $sin_xang = sin($xang);
12897 $cos_ang = cos($ang);
12898 $sin_ang = sin($ang);
12900 $px2 = $x0 + ($rx * $cos_xang * $cos_ang) - ($ry * $sin_xang * $sin_ang);
12901 $py2 = $y0 + ($rx * $sin_xang * $cos_ang) + ($ry * $cos_xang * $sin_ang);
12903 $qx2 = ($alpha * ((-$rx * $cos_xang * $sin_ang) - ($ry * $sin_xang * $cos_ang)));
12904 $qy2 = ($alpha * ((-$rx * $sin_xang * $sin_ang) + ($ry * $cos_xang * $cos_ang)));
12906 $this->_outCurve(($px1 + $qx1), ($this->h - ($py1 + $qy1)), ($px2 - $qx2), ($this->h - ($py2 - $qy2)), $px2, ($this->h - $py2));
12914 $this->_outLine($xc, $yc);
12933 public function Circle($x0, $y0, $r, $angstr=0, $angend=360, $style=
'', $line_style=array(), $fill_color=array(), $nc=2) {
12934 $this->Ellipse($x0, $y0, $r, $r, 0, $angstr, $angend, $style, $line_style, $fill_color, $nc);
12952 public function PolyLine($p, $style=
'', $line_style=array(), $fill_color=array()) {
12953 $this->Polygon($p, $style, $line_style, $fill_color,
false);
12971 public function Polygon($p, $style=
'', $line_style=array(), $fill_color=array(), $closed=
true) {
12976 for ($i = 0; $i < 4; ++$i) {
12977 $p[$nc + $i] = $p[$i];
12980 if (isset($line_style[0])) {
12981 $line_style[$np] = $line_style[0];
12985 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
12986 $this->SetFillColorArray($fill_color);
12988 $op = $this->getPathPaintOperator($style);
12990 $line_style = array();
12994 if (isset($line_style[
'all'])) {
12995 $this->SetLineStyle($line_style[
'all']);
13001 $this->_outPoint($p[0], $p[1]);
13002 for ($i = 2; $i < $nc; $i = $i + 2) {
13003 $this->_outLine($p[$i], $p[$i + 1]);
13008 $this->_outPoint($p[0], $p[1]);
13009 for ($i = 2; $i < $nc; $i = $i + 2) {
13010 $line_num = ($i / 2) - 1;
13011 if (isset($line_style[$line_num])) {
13012 if ($line_style[$line_num] != 0) {
13013 if (is_array($line_style[$line_num])) {
13015 $this->SetLineStyle($line_style[$line_num]);
13016 $this->_outPoint($p[$i - 2], $p[$i - 1]);
13017 $this->_outLine($p[$i], $p[$i + 1]);
13019 $this->_outPoint($p[$i], $p[$i + 1]);
13021 $this->_outLine($p[$i], $p[$i + 1]);
13025 $this->_outLine($p[$i], $p[$i + 1]);
13032 $this->_outPoint($p[0], $p[1]);
13033 for ($i = 2; $i < $nc; $i = $i + 2) {
13034 $this->_outLine($p[$i], $p[$i + 1]);
13069 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()) {
13073 if ($draw_circle) {
13074 $this->Circle($x0, $y0, $r, 0, 360, $circle_style, $circle_outLine_style, $circle_fill_color);
13077 for ($i = 0; $i < $ns; ++$i) {
13078 $a = $angle + ($i * 360 / $ns);
13079 $a_rad = deg2rad((
float) $a);
13080 $p[] = $x0 + ($r * sin($a_rad));
13081 $p[] = $y0 + ($r * cos($a_rad));
13083 $this->Polygon($p, $style, $line_style, $fill_color);
13117 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()) {
13121 if ($draw_circle) {
13122 $this->Circle($x0, $y0, $r, 0, 360, $circle_style, $circle_outLine_style, $circle_fill_color);
13125 $visited = array();
13126 for ($i = 0; $i < $nv; ++$i) {
13127 $a = $angle + ($i * 360 / $nv);
13128 $a_rad = deg2rad((
float) $a);
13129 $p2[] = $x0 + ($r * sin($a_rad));
13130 $p2[] = $y0 + ($r * cos($a_rad));
13131 $visited[] =
false;
13136 $p[] = $p2[$i * 2];
13137 $p[] = $p2[($i * 2) + 1];
13138 $visited[$i] =
true;
13141 }
while (!$visited[$i]);
13142 $this->Polygon($p, $style, $line_style, $fill_color);
13159 public function RoundedRect(
$x,
$y, $w, $h, $r, $round_corner=
'1111', $style=
'', $border_style=array(), $fill_color=array()) {
13160 $this->RoundedRectXY(
$x,
$y, $w, $h, $r, $r, $round_corner, $style, $border_style, $fill_color);
13178 public function RoundedRectXY(
$x,
$y, $w, $h, $rx, $ry, $round_corner=
'1111', $style=
'', $border_style=array(), $fill_color=array()) {
13179 if (($round_corner ==
'0000') OR (($rx == $ry) AND ($rx == 0))) {
13181 $this->Rect(
$x,
$y, $w, $h, $style, $border_style, $fill_color);
13185 if (!(
false === strpos($style,
'F')) AND isset($fill_color)) {
13186 $this->SetFillColorArray($fill_color);
13188 $op = $this->getPathPaintOperator($style);
13190 $border_style = array();
13192 if ($border_style) {
13193 $this->SetLineStyle($border_style);
13195 $MyArc = 4 / 3 * (sqrt(2) - 1);
13196 $this->_outPoint(
$x + $rx,
$y);
13197 $xc =
$x + $w - $rx;
13199 $this->_outLine($xc,
$y);
13200 if ($round_corner[0]) {
13201 $this->_outCurve($xc + ($rx * $MyArc), $yc - $ry, $xc + $rx, $yc - ($ry * $MyArc), $xc + $rx, $yc);
13203 $this->_outLine(
$x + $w,
$y);
13205 $xc =
$x + $w - $rx;
13206 $yc =
$y + $h - $ry;
13207 $this->_outLine(
$x + $w, $yc);
13208 if ($round_corner[1]) {
13209 $this->_outCurve($xc + $rx, $yc + ($ry * $MyArc), $xc + ($rx * $MyArc), $yc + $ry, $xc, $yc + $ry);
13211 $this->_outLine(
$x + $w,
$y + $h);
13214 $yc =
$y + $h - $ry;
13215 $this->_outLine($xc,
$y + $h);
13216 if ($round_corner[2]) {
13217 $this->_outCurve($xc - ($rx * $MyArc), $yc + $ry, $xc - $rx, $yc + ($ry * $MyArc), $xc - $rx, $yc);
13219 $this->_outLine(
$x,
$y + $h);
13223 $this->_outLine(
$x, $yc);
13224 if ($round_corner[3]) {
13225 $this->_outCurve($xc - $rx, $yc - ($ry * $MyArc), $xc - ($rx * $MyArc), $yc - $ry, $xc, $yc - $ry);
13227 $this->_outLine(
$x,
$y);
13228 $this->_outLine(
$x + $rx,
$y);
13245 public function Arrow($x0, $y0, $x1, $y1, $head_style=0, $arm_size=5, $arm_angle=15) {
13248 $dir_angle = atan2(($y0 - $y1), ($x0 - $x1));
13249 if ($dir_angle < 0) {
13250 $dir_angle += (2 * M_PI);
13252 $arm_angle = deg2rad($arm_angle);
13255 if ($head_style > 0) {
13257 $sx1 = $x1 + (($arm_size - $this->LineWidth) * cos($dir_angle));
13258 $sy1 = $y1 + (($arm_size - $this->LineWidth) * sin($dir_angle));
13261 $this->Line($x0, $y0, $sx1, $sy1);
13263 $x2L = $x1 + ($arm_size * cos($dir_angle + $arm_angle));
13264 $y2L = $y1 + ($arm_size * sin($dir_angle + $arm_angle));
13266 $x2R = $x1 + ($arm_size * cos($dir_angle - $arm_angle));
13267 $y2R = $y1 + ($arm_size * sin($dir_angle - $arm_angle));
13270 switch ($head_style) {
13274 $style = array(1, 1, 0);
13293 $this->Polygon(array($x2L, $y2L, $x1, $y1, $x2R, $y2R), $mode, $style, array());
13310 protected function utf8StrRev($str, $setbom=
false, $forcertl=
false) {
13311 return $this->utf8StrArrRev($this->UTF8StringToArray($str), $str, $setbom, $forcertl);
13326 return $this->arrUTF8ToUTF16BE($this->utf8Bidi($arr, $str, $forcertl), $setbom);
13339 protected function utf8Bidi($ta, $str=
'', $forcertl=
false) {
13344 if ($this->empty_string($str)) {
13346 $str = $this->UTF8ArrSubString($ta);
13349 if (preg_match($this->unicode->uni_RE_PATTERN_ARABIC, $str)) {
13355 if (!($forcertl OR $arabic OR preg_match($this->unicode->uni_RE_PATTERN_RTL, $str))) {
13360 $numchars = count($ta);
13362 if ($forcertl ==
'R') {
13364 } elseif ($forcertl ==
'L') {
13369 for ($i=0; $i < $numchars; ++$i) {
13370 $type = $this->unicode->uni_type[$ta[$i]];
13371 if (
$type ==
'L') {
13374 } elseif ((
$type ==
'AL') OR (
$type ==
'R')) {
13385 $remember = array();
13387 $sor = $pel % 2 ?
'R' :
'L';
13391 $chardata = Array();
13395 for ($i=0; $i < $numchars; ++$i) {
13396 if ($ta[$i] == $this->unicode->uni_RLE) {
13400 $next_level = $cel + ($cel % 2) + 1;
13401 if ($next_level < 62) {
13402 $remember[] = array(
'num' => $this->unicode->uni_RLE,
'cel' => $cel,
'dos' => $dos);
13403 $cel = $next_level;
13406 $eor = $cel % 2 ?
'R' :
'L';
13408 } elseif ($ta[$i] == $this->unicode->uni_LRE) {
13412 $next_level = $cel + 2 - ($cel % 2);
13413 if ( $next_level < 62 ) {
13414 $remember[] = array(
'num' => $this->unicode->uni_LRE,
'cel' => $cel,
'dos' => $dos);
13415 $cel = $next_level;
13418 $eor = $cel % 2 ?
'R' :
'L';
13420 } elseif ($ta[$i] == $this->unicode->uni_RLO) {
13424 $next_level = $cel + ($cel % 2) + 1;
13425 if ($next_level < 62) {
13426 $remember[] = array(
'num' => $this->unicode->uni_RLO,
'cel' => $cel,
'dos' => $dos);
13427 $cel = $next_level;
13430 $eor = $cel % 2 ?
'R' :
'L';
13432 } elseif ($ta[$i] == $this->unicode->uni_LRO) {
13436 $next_level = $cel + 2 - ($cel % 2);
13437 if ( $next_level < 62 ) {
13438 $remember[] = array(
'num' => $this->unicode->uni_LRO,
'cel' => $cel,
'dos' => $dos);
13439 $cel = $next_level;
13442 $eor = $cel % 2 ?
'R' :
'L';
13444 } elseif ($ta[$i] == $this->unicode->uni_PDF) {
13446 if (count($remember)) {
13447 $last = count($remember ) - 1;
13448 if (($remember[$last][
'num'] == $this->unicode->uni_RLE) OR
13449 ($remember[$last][
'num'] == $this->unicode->uni_LRE) OR
13450 ($remember[$last][
'num'] == $this->unicode->uni_RLO) OR
13451 ($remember[$last][
'num'] == $this->unicode->uni_LRO)) {
13452 $match = array_pop($remember);
13453 $cel = $match[
'cel'];
13454 $dos = $match[
'dos'];
13456 $eor = ($cel > $match[
'cel'] ? $cel : $match[
'cel']) % 2 ?
'R' :
'L';
13459 } elseif (($ta[$i] != $this->unicode->uni_RLE) AND
13460 ($ta[$i] != $this->unicode->uni_LRE) AND
13461 ($ta[$i] != $this->unicode->uni_RLO) AND
13462 ($ta[$i] != $this->unicode->uni_LRO) AND
13463 ($ta[$i] != $this->unicode->uni_PDF)) {
13470 if (isset($this->unicode->uni_type[$ta[$i]])) {
13471 $chardir = $this->unicode->uni_type[$ta[$i]];
13477 $chardata[] = array(
'char' => $ta[$i],
'level' => $cel,
'type' => $chardir,
'sor' => $sor,
'eor' => $eor);
13488 $numchars = count($chardata);
13493 for ($i=0; $i < $numchars; ++$i) {
13494 if ($chardata[$i][
'type'] ==
'NSM') {
13496 $chardata[$i][
'type'] = $chardata[$i][
'sor'];
13497 } elseif ($i > 0) {
13498 $chardata[$i][
'type'] = $chardata[($i-1)][
'type'];
13501 if ($chardata[$i][
'level'] != $prevlevel) {
13506 $prevlevel = $chardata[$i][
'level'];
13512 for ($i=0; $i < $numchars; ++$i) {
13513 if ($chardata[$i][
'char'] ==
'EN') {
13514 for ($j=$levcount; $j >= 0; $j--) {
13515 if ($chardata[$j][
'type'] ==
'AL') {
13516 $chardata[$i][
'type'] =
'AN';
13517 } elseif (($chardata[$j][
'type'] ==
'L') OR ($chardata[$j][
'type'] ==
'R')) {
13522 if ($chardata[$i][
'level'] != $prevlevel) {
13527 $prevlevel = $chardata[$i][
'level'];
13531 for ($i=0; $i < $numchars; ++$i) {
13532 if ($chardata[$i][
'type'] ==
'AL') {
13533 $chardata[$i][
'type'] =
'R';
13540 for ($i=0; $i < $numchars; ++$i) {
13541 if (($levcount > 0) AND (($i+1) < $numchars) AND ($chardata[($i+1)][
'level'] == $prevlevel)) {
13542 if (($chardata[$i][
'type'] ==
'ES') AND ($chardata[($i-1)][
'type'] ==
'EN') AND ($chardata[($i+1)][
'type'] ==
'EN')) {
13543 $chardata[$i][
'type'] =
'EN';
13544 } elseif (($chardata[$i][
'type'] ==
'CS') AND ($chardata[($i-1)][
'type'] ==
'EN') AND ($chardata[($i+1)][
'type'] ==
'EN')) {
13545 $chardata[$i][
'type'] =
'EN';
13546 } elseif (($chardata[$i][
'type'] ==
'CS') AND ($chardata[($i-1)][
'type'] ==
'AN') AND ($chardata[($i+1)][
'type'] ==
'AN')) {
13547 $chardata[$i][
'type'] =
'AN';
13550 if ($chardata[$i][
'level'] != $prevlevel) {
13555 $prevlevel = $chardata[$i][
'level'];
13561 for ($i=0; $i < $numchars; ++$i) {
13562 if ($chardata[$i][
'type'] ==
'ET') {
13563 if (($levcount > 0) AND ($chardata[($i-1)][
'type'] ==
'EN')) {
13564 $chardata[$i][
'type'] =
'EN';
13567 while (($j < $numchars) AND ($chardata[$j][
'level'] == $prevlevel)) {
13568 if ($chardata[$j][
'type'] ==
'EN') {
13569 $chardata[$i][
'type'] =
'EN';
13571 } elseif ($chardata[$j][
'type'] !=
'ET') {
13578 if ($chardata[$i][
'level'] != $prevlevel) {
13583 $prevlevel = $chardata[$i][
'level'];
13589 for ($i=0; $i < $numchars; ++$i) {
13590 if (($chardata[$i][
'type'] ==
'ET') OR ($chardata[$i][
'type'] ==
'ES') OR ($chardata[$i][
'type'] ==
'CS')) {
13591 $chardata[$i][
'type'] =
'ON';
13593 if ($chardata[$i][
'level'] != $prevlevel) {
13598 $prevlevel = $chardata[$i][
'level'];
13604 for ($i=0; $i < $numchars; ++$i) {
13605 if ($chardata[$i][
'char'] ==
'EN') {
13606 for ($j=$levcount; $j >= 0; $j--) {
13607 if ($chardata[$j][
'type'] ==
'L') {
13608 $chardata[$i][
'type'] =
'L';
13609 } elseif ($chardata[$j][
'type'] ==
'R') {
13614 if ($chardata[$i][
'level'] != $prevlevel) {
13619 $prevlevel = $chardata[$i][
'level'];
13625 for ($i=0; $i < $numchars; ++$i) {
13626 if (($levcount > 0) AND (($i+1) < $numchars) AND ($chardata[($i+1)][
'level'] == $prevlevel)) {
13627 if (($chardata[$i][
'type'] ==
'N') AND ($chardata[($i-1)][
'type'] ==
'L') AND ($chardata[($i+1)][
'type'] ==
'L')) {
13628 $chardata[$i][
'type'] =
'L';
13629 } elseif (($chardata[$i][
'type'] ==
'N') AND
13630 (($chardata[($i-1)][
'type'] ==
'R') OR ($chardata[($i-1)][
'type'] ==
'EN') OR ($chardata[($i-1)][
'type'] ==
'AN')) AND
13631 (($chardata[($i+1)][
'type'] ==
'R') OR ($chardata[($i+1)][
'type'] ==
'EN') OR ($chardata[($i+1)][
'type'] ==
'AN'))) {
13632 $chardata[$i][
'type'] =
'R';
13633 } elseif ($chardata[$i][
'type'] ==
'N') {
13635 $chardata[$i][
'type'] = $chardata[$i][
'sor'];
13637 } elseif (($levcount == 0) AND (($i+1) < $numchars) AND ($chardata[($i+1)][
'level'] == $prevlevel)) {
13639 if (($chardata[$i][
'type'] ==
'N') AND ($chardata[$i][
'sor'] ==
'L') AND ($chardata[($i+1)][
'type'] ==
'L')) {
13640 $chardata[$i][
'type'] =
'L';
13641 } elseif (($chardata[$i][
'type'] ==
'N') AND
13642 (($chardata[$i][
'sor'] ==
'R') OR ($chardata[$i][
'sor'] ==
'EN') OR ($chardata[$i][
'sor'] ==
'AN')) AND
13643 (($chardata[($i+1)][
'type'] ==
'R') OR ($chardata[($i+1)][
'type'] ==
'EN') OR ($chardata[($i+1)][
'type'] ==
'AN'))) {
13644 $chardata[$i][
'type'] =
'R';
13645 } elseif ($chardata[$i][
'type'] ==
'N') {
13647 $chardata[$i][
'type'] = $chardata[$i][
'sor'];
13649 } elseif (($levcount > 0) AND ((($i+1) == $numchars) OR (($i+1) < $numchars) AND ($chardata[($i+1)][
'level'] != $prevlevel))) {
13651 if (($chardata[$i][
'type'] ==
'N') AND ($chardata[($i-1)][
'type'] ==
'L') AND ($chardata[$i][
'eor'] ==
'L')) {
13652 $chardata[$i][
'type'] =
'L';
13653 } elseif (($chardata[$i][
'type'] ==
'N') AND
13654 (($chardata[($i-1)][
'type'] ==
'R') OR ($chardata[($i-1)][
'type'] ==
'EN') OR ($chardata[($i-1)][
'type'] ==
'AN')) AND
13655 (($chardata[$i][
'eor'] ==
'R') OR ($chardata[$i][
'eor'] ==
'EN') OR ($chardata[$i][
'eor'] ==
'AN'))) {
13656 $chardata[$i][
'type'] =
'R';
13657 } elseif ($chardata[$i][
'type'] ==
'N') {
13659 $chardata[$i][
'type'] = $chardata[$i][
'sor'];
13661 } elseif ($chardata[$i][
'type'] ==
'N') {
13663 $chardata[$i][
'type'] = $chardata[$i][
'sor'];
13665 if ($chardata[$i][
'level'] != $prevlevel) {
13670 $prevlevel = $chardata[$i][
'level'];
13675 for ($i=0; $i < $numchars; ++$i) {
13676 $odd = $chardata[$i][
'level'] % 2;
13678 if (($chardata[$i][
'type'] ==
'L') OR ($chardata[$i][
'type'] ==
'AN') OR ($chardata[$i][
'type'] ==
'EN')) {
13679 $chardata[$i][
'level'] += 1;
13682 if ($chardata[$i][
'type'] ==
'R') {
13683 $chardata[$i][
'level'] += 1;
13684 } elseif (($chardata[$i][
'type'] ==
'AN') OR ($chardata[$i][
'type'] ==
'EN')) {
13685 $chardata[$i][
'level'] += 2;
13688 $maxlevel = max($chardata[$i][
'level'],$maxlevel);
13696 for ($i=0; $i < $numchars; ++$i) {
13697 if (($chardata[$i][
'type'] ==
'B') OR ($chardata[$i][
'type'] ==
'S')) {
13698 $chardata[$i][
'level'] = $pel;
13699 } elseif ($chardata[$i][
'type'] ==
'WS') {
13701 while ($j < $numchars) {
13702 if ((($chardata[$j][
'type'] ==
'B') OR ($chardata[$j][
'type'] ==
'S')) OR
13703 (($j == ($numchars-1)) AND ($chardata[$j][
'type'] ==
'WS'))) {
13704 $chardata[$i][
'level'] = $pel;
13706 } elseif ($chardata[$j][
'type'] !=
'WS') {
13717 $endedletter = array(1569,1570,1571,1572,1573,1575,1577,1583,1584,1585,1586,1608,1688);
13718 $alfletter = array(1570,1571,1573,1575);
13719 $chardata2 = $chardata;
13720 $laaletter =
false;
13723 for ($i=0; $i < $numchars; ++$i) {
13724 if (($this->unicode->uni_type[$chardata[$i][
'char']] ==
'AL') OR ($chardata[$i][
'char'] == 32) OR ($chardata[$i][
'char'] == 8204)) {
13725 $charAL[
$x] = $chardata[$i];
13726 $charAL[
$x][
'i'] = $i;
13727 $chardata[$i][
'x'] =
$x;
13732 for ($i=0; $i < $numchars; ++$i) {
13733 $thischar = $chardata[$i];
13735 $prevchar = $chardata[($i-1)];
13739 if (($i+1) < $numchars) {
13740 $nextchar = $chardata[($i+1)];
13744 if ($this->unicode->uni_type[$thischar[
'char']] ==
'AL') {
13745 $x = $thischar[
'x'];
13747 $prevchar = $charAL[(
$x-1)];
13751 if ((
$x+1) < $numAL) {
13752 $nextchar = $charAL[(
$x+1)];
13757 if (($prevchar !==
false) AND ($prevchar[
'char'] == 1604) AND (in_array($thischar[
'char'], $alfletter))) {
13758 $arabicarr = $this->unicode->uni_laa_array;
13761 $prevchar = $charAL[(
$x-2)];
13766 $arabicarr = $this->unicode->uni_arabicsubst;
13767 $laaletter =
false;
13769 if (($prevchar !==
false) AND ($nextchar !==
false) AND
13770 (($this->unicode->uni_type[$prevchar[
'char']] ==
'AL') OR ($this->unicode->uni_type[$prevchar[
'char']] ==
'NSM')) AND
13771 (($this->unicode->uni_type[$nextchar[
'char']] ==
'AL') OR ($this->unicode->uni_type[$nextchar[
'char']] ==
'NSM')) AND
13772 ($prevchar[
'type'] == $thischar[
'type']) AND
13773 ($nextchar[
'type'] == $thischar[
'type']) AND
13774 ($nextchar[
'char'] != 1567)) {
13775 if (in_array($prevchar[
'char'], $endedletter)) {
13776 if (isset($arabicarr[$thischar[
'char']][2])) {
13778 $chardata2[$i][
'char'] = $arabicarr[$thischar[
'char']][2];
13781 if (isset($arabicarr[$thischar[
'char']][3])) {
13783 $chardata2[$i][
'char'] = $arabicarr[$thischar[
'char']][3];
13786 } elseif (($nextchar !==
false) AND
13787 (($this->unicode->uni_type[$nextchar[
'char']] ==
'AL') OR ($this->unicode->uni_type[$nextchar[
'char']] ==
'NSM')) AND
13788 ($nextchar[
'type'] == $thischar[
'type']) AND
13789 ($nextchar[
'char'] != 1567)) {
13790 if (isset($arabicarr[$chardata[$i][
'char']][2])) {
13792 $chardata2[$i][
'char'] = $arabicarr[$thischar[
'char']][2];
13794 } elseif ((($prevchar !==
false) AND
13795 (($this->unicode->uni_type[$prevchar[
'char']] ==
'AL') OR ($this->unicode->uni_type[$prevchar[
'char']] ==
'NSM')) AND
13796 ($prevchar[
'type'] == $thischar[
'type'])) OR
13797 (($nextchar !==
false) AND ($nextchar[
'char'] == 1567))) {
13799 if (($i > 1) AND ($thischar[
'char'] == 1607) AND
13800 ($chardata[$i-1][
'char'] == 1604) AND
13801 ($chardata[$i-2][
'char'] == 1604)) {
13804 $chardata2[$i-2][
'char'] =
false;
13805 $chardata2[$i-1][
'char'] =
false;
13806 $chardata2[$i][
'char'] = 65010;
13808 if (($prevchar !==
false) AND in_array($prevchar[
'char'], $endedletter)) {
13809 if (isset($arabicarr[$thischar[
'char']][0])) {
13811 $chardata2[$i][
'char'] = $arabicarr[$thischar[
'char']][0];
13814 if (isset($arabicarr[$thischar[
'char']][1])) {
13816 $chardata2[$i][
'char'] = $arabicarr[$thischar[
'char']][1];
13820 } elseif (isset($arabicarr[$thischar[
'char']][0])) {
13822 $chardata2[$i][
'char'] = $arabicarr[$thischar[
'char']][0];
13827 $chardata2[($charAL[(
$x-1)][
'i'])][
'char'] =
false;
13835 $cw = &$this->CurrentFont[
'cw'];
13836 for ($i = 0; $i < ($numchars-1); ++$i) {
13837 if (($chardata2[$i][
'char'] == 1617) AND (isset($this->unicode->uni_diacritics[($chardata2[$i+1][
'char'])]))) {
13839 if (isset(
$cw[($this->unicode->uni_diacritics[($chardata2[$i+1][
'char'])])])) {
13840 $chardata2[$i][
'char'] =
false;
13841 $chardata2[$i+1][
'char'] = $this->unicode->uni_diacritics[($chardata2[$i+1][
'char'])];
13846 foreach ($chardata2 as $key => $value) {
13847 if ($value[
'char'] ===
false) {
13848 unset($chardata2[$key]);
13851 $chardata = array_values($chardata2);
13852 $numchars = count($chardata);
13860 for ($j=$maxlevel; $j > 0; $j--) {
13861 $ordarray = Array();
13864 for ($i=0; $i < $numchars; ++$i) {
13865 if ($chardata[$i][
'level'] >= $j) {
13867 if (isset($this->unicode->uni_mirror[$chardata[$i][
'char']])) {
13869 $chardata[$i][
'char'] = $this->unicode->uni_mirror[$chardata[$i][
'char']];
13871 $revarr[] = $chardata[$i];
13874 $revarr = array_reverse($revarr);
13875 $ordarray = array_merge($ordarray, $revarr);
13879 $ordarray[] = $chardata[$i];
13883 $revarr = array_reverse($revarr);
13884 $ordarray = array_merge($ordarray, $revarr);
13886 $chardata = $ordarray;
13889 $ordarray = array();
13890 for ($i=0; $i < $numchars; ++$i) {
13891 $ordarray[] = $chardata[$i][
'char'];
13893 $this->CurrentFont[
'subsetchars'][$chardata[$i][
'char']] =
true;
13896 $this->setFontSubBuffer($this->CurrentFont[
'fontkey'],
'subsetchars', $this->CurrentFont[
'subsetchars']);
13916 if (isset($this->outlines[0])) {
13917 $lastoutline = end($this->outlines);
13918 $maxlevel = $lastoutline[
'l'] + 1;
13922 if ($level > $maxlevel) {
13923 $level = $maxlevel;
13926 $y = $this->GetY();
13928 if (empty($page)) {
13929 $page = $this->PageNo();
13930 if (empty($page)) {
13934 $this->outlines[] = array(
't' => $txt,
'l' => $level,
'y' =>
$y,
'p' => $page);
13944 $nb = count($this->outlines);
13949 $outline_p = array();
13950 $outline_y = array();
13951 foreach ($this->outlines as $key =>
$row) {
13952 $outline_p[$key] =
$row[
'p'];
13953 $outline_k[$key] = $key;
13956 array_multisort($outline_p, SORT_NUMERIC, SORT_ASC, $outline_k, SORT_NUMERIC, SORT_ASC, $this->outlines);
13959 foreach ($this->outlines as $i => $o) {
13961 $parent = $lru[($o[
'l'] - 1)];
13963 $this->outlines[$i][
'parent'] = $parent;
13964 $this->outlines[$parent][
'last'] = $i;
13965 if ($o[
'l'] > $level) {
13967 $this->outlines[$parent][
'first'] = $i;
13970 $this->outlines[$i][
'parent'] = $nb;
13972 if (($o[
'l'] <= $level) AND ($i > 0)) {
13974 $prev = $lru[$o[
'l']];
13975 $this->outlines[$prev][
'next'] = $i;
13976 $this->outlines[$i][
'prev'] = $prev;
13978 $lru[$o[
'l']] = $i;
13983 $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';
13984 foreach ($this->outlines as $i => $o) {
13985 if (isset($this->page_obj_id[($o[
'p'])])) {
13986 $oid = $this->_newobj();
13988 $title = preg_replace($nltags,
"\n", $o[
't']);
13993 $out =
'<</Title '.$this->_textstring(
$title, $oid);
13994 $out .=
' /Parent '.($n + $o[
'parent']).
' 0 R';
13995 if (isset($o[
'prev'])) {
13996 $out .=
' /Prev '.($n + $o[
'prev']).
' 0 R';
13998 if (isset($o[
'next'])) {
13999 $out .=
' /Next '.($n + $o[
'next']).
' 0 R';
14001 if (isset($o[
'first'])) {
14002 $out .=
' /First '.($n + $o[
'first']).
' 0 R';
14004 if (isset($o[
'last'])) {
14005 $out .=
' /Last '.($n + $o[
'last']).
' 0 R';
14007 $out .=
' '.sprintf(
'/Dest [%u 0 R /XYZ 0 %.2F null]', $this->page_obj_id[($o[
'p'])], ($this->pagedim[$o[
'p']][
'h'] - ($o[
'y'] * $this->k)));
14008 $out .=
' /Count 0 >>';
14009 $out .=
"\n".
'endobj';
14014 $this->OutlineRoot = $this->_newobj();
14015 $this->_out(
'<< /Type /Outlines /First '.$n.
' 0 R /Last '.($n + $lru[0]).
' 0 R >>'.
"\n".
'endobj');
14028 $this->javascript .= $script;
14042 $this->js_objects[$this->n] = array(
'n' => $this->
n,
'js' => $script,
'onload' => $onload);
14053 if (empty($this->javascript) AND empty($this->js_objects)) {
14056 if (strpos($this->javascript,
'this.addField') > 0) {
14057 if (!$this->ur[
'enabled']) {
14062 $jsa = sprintf(
"ftcpdfdocsaved=this.addField('%s','%s',%d,[%.2F,%.2F,%.2F,%.2F]);",
'tcpdfdocsaved',
'text', 0, 0, 1, 0, 1);
14063 $jsb =
"getField('tcpdfdocsaved').value='saved';";
14064 $this->javascript = $jsa.
"\n".$this->javascript.
"\n".$jsb;
14066 $this->n_js = $this->_newobj();
14067 $out =
' << /Names [';
14068 if (!empty($this->javascript)) {
14069 $out .=
' (EmbeddedJS) '.($this->n + 1).
' 0 R';
14071 if (!empty($this->js_objects)) {
14072 foreach ($this->js_objects as $key => $val) {
14073 if ($val[
'onload']) {
14074 $out .=
' (JS'.$key.
') '.$key.
' 0 R';
14079 $out .=
"\n".
'endobj';
14082 if (!empty($this->javascript)) {
14083 $obj_id = $this->_newobj();
14084 $out =
'<< /S /JavaScript';
14085 $out .=
' /JS '.$this->_textstring($this->javascript, $obj_id);
14087 $out .=
"\n".
'endobj';
14091 if (!empty($this->js_objects)) {
14092 foreach ($this->js_objects as $key => $val) {
14093 $out = $this->_getobj($key).
"\n".
' << /S /JavaScript /JS '.$this->_textstring($val[
'js'], $key).
' >>'.
"\n".
'endobj';
14107 static $aColors = array(
'transparent',
'black',
'white',
'red',
'green',
'blue',
'cyan',
'magenta',
'yellow',
'dkGray',
'gray',
'ltGray');
14108 if (substr($color,0,1) ==
'#') {
14109 return sprintf(
"['RGB',%.3F,%.3F,%.3F]", hexdec(substr($color,1,2))/255, hexdec(substr($color,3,2))/255, hexdec(substr($color,5,2))/255);
14111 if (!in_array($color,$aColors)) {
14112 $this->Error(
'Invalid color: '.$color);
14114 return 'color.'.$color;
14135 $this->javascript .=
"if(getField('tcpdfdocsaved').value != 'saved') {";
14137 $this->javascript .= sprintf(
"f".
$name.
"=this.addField('%s','%s',%u,[%.2F,%.2F,%.2F,%.2F]);",
$name,
$type, $this->PageNo()-1,
$x*$k, ($this->h-
$y)*$k+1, (
$x+$w)*$k, ($this->h-
$y-$h)*$k+1).
"\n";
14138 $this->javascript .=
'f'.$name.
'.textSize='.$this->FontSizePt.
";\n";
14139 while (list($key, $val) = each($prop)) {
14140 if (strcmp(substr($key, -5),
'Color') == 0) {
14141 $val = $this->_JScolor($val);
14143 $val =
"'".$val.
"'";
14145 $this->javascript .=
'f'.$name.
'.'.$key.
'='.$val.
";\n";
14152 $this->javascript .=
'}';
14166 if (isset($prop[
'aopt']) AND is_array($prop[
'aopt'])) {
14168 return $prop[
'aopt'];
14172 if (isset($prop[
'alignment'])) {
14173 switch ($prop[
'alignment']) {
14187 $opt[
'q'] = ($this->rtl)?2:0;
14193 if (isset($prop[
'lineWidth'])) {
14194 $linewidth = intval($prop[
'lineWidth']);
14199 if (isset($prop[
'borderStyle'])) {
14200 switch ($prop[
'borderStyle']) {
14203 $opt[
'border'] = array(0, 0, $linewidth, array(3, 2));
14204 $opt[
'bs'] = array(
'w'=>$linewidth,
's'=>
'D',
'd'=>array(3, 2));
14209 $opt[
'border'] = array(0, 0, $linewidth);
14210 $opt[
'bs'] = array(
'w'=>$linewidth,
's'=>
'B');
14215 $opt[
'border'] = array(0, 0, $linewidth);
14216 $opt[
'bs'] = array(
'w'=>$linewidth,
's'=>
'I');
14220 case 'underline': {
14221 $opt[
'border'] = array(0, 0, $linewidth);
14222 $opt[
'bs'] = array(
'w'=>$linewidth,
's'=>
'U');
14228 $opt[
'border'] = array(0, 0, $linewidth);
14229 $opt[
'bs'] = array(
'w'=>$linewidth,
's'=>
'S');
14234 if (isset($prop[
'border']) AND is_array($prop[
'border'])) {
14235 $opt[
'border'] = $prop[
'border'];
14237 if (!isset($opt[
'mk'])) {
14238 $opt[
'mk'] = array();
14240 if (!isset($opt[
'mk'][
'if'])) {
14241 $opt[
'mk'][
'if'] = array();
14243 $opt[
'mk'][
'if'][
'a'] = array(0.5, 0.5);
14245 if (isset($prop[
'buttonAlignX'])) {
14246 $opt[
'mk'][
'if'][
'a'][0] = $prop[
'buttonAlignX'];
14249 if (isset($prop[
'buttonAlignY'])) {
14250 $opt[
'mk'][
'if'][
'a'][1] = $prop[
'buttonAlignY'];
14253 if (isset($prop[
'buttonFitBounds']) AND ($prop[
'buttonFitBounds'] ==
'true')) {
14254 $opt[
'mk'][
'if'][
'fb'] =
true;
14257 if (isset($prop[
'buttonScaleHow'])) {
14258 switch ($prop[
'buttonScaleHow']) {
14259 case 'scaleHow.proportional': {
14260 $opt[
'mk'][
'if'][
's'] =
'P';
14263 case 'scaleHow.anamorphic': {
14264 $opt[
'mk'][
'if'][
's'] =
'A';
14270 if (isset($prop[
'buttonScaleWhen'])) {
14271 switch ($prop[
'buttonScaleWhen']) {
14272 case 'scaleWhen.always': {
14273 $opt[
'mk'][
'if'][
'sw'] =
'A';
14276 case 'scaleWhen.never': {
14277 $opt[
'mk'][
'if'][
'sw'] =
'N';
14280 case 'scaleWhen.tooBig': {
14281 $opt[
'mk'][
'if'][
'sw'] =
'B';
14284 case 'scaleWhen.tooSmall': {
14285 $opt[
'mk'][
'if'][
'sw'] =
'S';
14291 if (isset($prop[
'buttonPosition'])) {
14292 switch ($prop[
'buttonPosition']) {
14294 case 'position.textOnly': {
14295 $opt[
'mk'][
'tp'] = 0;
14299 case 'position.iconOnly': {
14300 $opt[
'mk'][
'tp'] = 1;
14304 case 'position.iconTextV': {
14305 $opt[
'mk'][
'tp'] = 2;
14309 case 'position.textIconV': {
14310 $opt[
'mk'][
'tp'] = 3;
14314 case 'position.iconTextH': {
14315 $opt[
'mk'][
'tp'] = 4;
14319 case 'position.textIconH': {
14320 $opt[
'mk'][
'tp'] = 5;
14324 case 'position.overlay': {
14325 $opt[
'mk'][
'tp'] = 6;
14331 if (isset($prop[
'fillColor'])) {
14332 if (is_array($prop[
'fillColor'])) {
14333 $opt[
'mk'][
'bg'] = $prop[
'fillColor'];
14335 $opt[
'mk'][
'bg'] = $this->convertHTMLColorToDec($prop[
'fillColor']);
14339 if (isset($prop[
'strokeColor'])) {
14340 if (is_array($prop[
'strokeColor'])) {
14341 $opt[
'mk'][
'bc'] = $prop[
'strokeColor'];
14343 $opt[
'mk'][
'bc'] = $this->convertHTMLColorToDec($prop[
'strokeColor']);
14347 if (isset($prop[
'rotation'])) {
14348 $opt[
'mk'][
'r'] = $prop[
'rotation'];
14351 if (isset($prop[
'charLimit'])) {
14352 $opt[
'maxlen'] = intval($prop[
'charLimit']);
14358 if (isset($prop[
'readonly']) AND ($prop[
'readonly'] ==
'true')) {
14362 if (isset($prop[
'required']) AND ($prop[
'required'] ==
'true')) {
14366 if (isset($prop[
'multiline']) AND ($prop[
'multiline'] ==
'true')) {
14370 if (isset($prop[
'password']) AND ($prop[
'password'] ==
'true')) {
14374 if (isset($prop[
'NoToggleToOff']) AND ($prop[
'NoToggleToOff'] ==
'true')) {
14378 if (isset($prop[
'Radio']) AND ($prop[
'Radio'] ==
'true')) {
14382 if (isset($prop[
'Pushbutton']) AND ($prop[
'Pushbutton'] ==
'true')) {
14386 if (isset($prop[
'Combo']) AND ($prop[
'Combo'] ==
'true')) {
14390 if (isset($prop[
'editable']) AND ($prop[
'editable'] ==
'true')) {
14394 if (isset($prop[
'Sort']) AND ($prop[
'Sort'] ==
'true')) {
14398 if (isset($prop[
'fileSelect']) AND ($prop[
'fileSelect'] ==
'true')) {
14402 if (isset($prop[
'multipleSelection']) AND ($prop[
'multipleSelection'] ==
'true')) {
14406 if (isset($prop[
'doNotSpellCheck']) AND ($prop[
'doNotSpellCheck'] ==
'true')) {
14410 if (isset($prop[
'doNotScroll']) AND ($prop[
'doNotScroll'] ==
'true')) {
14414 if (isset($prop[
'comb']) AND ($prop[
'comb'] ==
'true')) {
14418 if (isset($prop[
'radiosInUnison']) AND ($prop[
'radiosInUnison'] ==
'true')) {
14422 if (isset($prop[
'richText']) AND ($prop[
'richText'] ==
'true')) {
14426 if (isset($prop[
'commitOnSelChange']) AND ($prop[
'commitOnSelChange'] ==
'true')) {
14431 if (isset($prop[
'defaultValue'])) {
14432 $opt[
'dv'] = $prop[
'defaultValue'];
14436 if (isset($prop[
'readonly']) AND ($prop[
'readonly'] ==
'true')) {
14440 if (isset($prop[
'display'])) {
14441 if ($prop[
'display'] ==
'display.visible') {
14443 } elseif ($prop[
'display'] ==
'display.hidden') {
14445 } elseif ($prop[
'display'] ==
'display.noPrint') {
14447 } elseif ($prop[
'display'] ==
'display.noView') {
14453 if (isset($prop[
'currentValueIndices']) AND is_array($prop[
'currentValueIndices'])) {
14454 $opt[
'i'] = $prop[
'currentValueIndices'];
14457 if (isset($prop[
'value'])) {
14458 if (is_array($prop[
'value'])) {
14459 $opt[
'opt'] = array();
14460 foreach ($prop[
'value'] AS $key => $optval) {
14462 if (isset($prop[
'exportValues'][$key])) {
14463 $opt[
'opt'][$key] = array($prop[
'exportValues'][$key], $prop[
'value'][$key]);
14465 $opt[
'opt'][$key] = $prop[
'value'][$key];
14469 $opt[
'v'] = $prop[
'value'];
14473 if (isset($prop[
'richValue'])) {
14474 $opt[
'rv'] = $prop[
'richValue'];
14477 if (isset($prop[
'submitName'])) {
14478 $opt[
'tm'] = $prop[
'submitName'];
14481 if (isset($prop[
'name'])) {
14482 $opt[
't'] = $prop[
'name'];
14485 if (isset($prop[
'userName'])) {
14486 $opt[
'tu'] = $prop[
'userName'];
14489 if (isset($prop[
'highlight'])) {
14490 switch ($prop[
'highlight']) {
14492 case 'highlight.n': {
14497 case 'highlight.i': {
14502 case 'highlight.p': {
14507 case 'highlight.o': {
14530 $this->default_form_prop = $prop;
14541 return $this->default_form_prop;
14566 $this->checkPageRegions($h,
$x,
$y);
14568 $this->_addfield(
'text',
$name,
$x,
$y, $w, $h, $prop);
14572 $prop = array_merge($this->getFormDefaultProp(), $prop);
14574 $popt = $this->getAnnotOptFromJSProp($prop);
14576 $this->annotation_fonts[$this->CurrentFont[
'fontkey']] = $this->CurrentFont[
'i'];
14577 $fontstyle = sprintf(
'/F%d %.2F Tf %s', $this->CurrentFont[
'i'], $this->FontSizePt, $this->TextColor);
14578 $popt[
'da'] = $fontstyle;
14579 $popt[
'ap'] = array();
14580 $popt[
'ap'][
'n'] =
'q BT '.$fontstyle.
' ET Q';
14582 $opt = array_merge($popt, $opt);
14586 $opt[
'Subtype'] =
'Widget';
14624 $this->Annotation(
$x,
$y, $w, $h,
$name, $opt, 0);
14647 public function RadioButton(
$name, $w, $prop=array(), $opt=array(), $onvalue=
'On', $checked=
false,
$x=
'',
$y=
'', $js=
false) {
14655 $this->checkPageRegions($w,
$x,
$y);
14657 $this->_addfield(
'radiobutton',
$name,
$x,
$y, $w, $w, $prop);
14660 if ($this->empty_string($onvalue)) {
14664 $defval = $onvalue;
14669 if (!isset($this->radiobutton_groups[$this->page])) {
14670 $this->radiobutton_groups[$this->page] = array();
14672 if (!isset($this->radiobutton_groups[$this->page][
$name])) {
14673 $this->radiobutton_groups[$this->page][
$name] = array();
14675 $this->radiobutton_groups[$this->page][
$name][
'n'] = $this->n;
14676 $this->radio_groups[] = $this->n;
14677 $kid = ($this->
n + 2);
14679 $kid = ($this->
n + 1);
14682 $this->radiobutton_groups[$this->page][
$name][] = array(
'kid' => $kid,
'def' => $defval);
14684 $prop = array_merge($this->getFormDefaultProp(), $prop);
14685 $prop[
'NoToggleToOff'] =
'true';
14686 $prop[
'Radio'] =
'true';
14687 $prop[
'borderStyle'] =
'inset';
14689 $popt = $this->getAnnotOptFromJSProp($prop);
14691 $font =
'zapfdingbats';
14692 $this->AddFont($font);
14693 $tmpfont = $this->getFontBuffer($font);
14694 $this->annotation_fonts[$tmpfont[
'fontkey']] = $tmpfont[
'i'];
14695 $fontstyle = sprintf(
'/F%d %.2F Tf %s', $tmpfont[
'i'], $this->FontSizePt, $this->TextColor);
14696 $popt[
'da'] = $fontstyle;
14697 $popt[
'ap'] = array();
14698 $popt[
'ap'][
'n'] = array();
14699 $popt[
'ap'][
'n'][$onvalue] =
'q BT '.$fontstyle.
' 0 0 Td (8) Tj ET Q';
14700 $popt[
'ap'][
'n'][
'Off'] =
'q BT '.$fontstyle.
' 0 0 Td (8) Tj ET Q';
14701 if (!isset($popt[
'mk'])) {
14702 $popt[
'mk'] = array();
14704 $popt[
'mk'][
'ca'] =
'(l)';
14706 $opt = array_merge($popt, $opt);
14708 $opt[
'Subtype'] =
'Widget';
14709 $opt[
'ft'] =
'Btn';
14711 $opt[
'v'] = array(
'/'.$onvalue);
14712 $opt[
'as'] = $onvalue;
14714 $opt[
'as'] =
'Off';
14716 $this->Annotation(
$x,
$y, $w, $w, $name, $opt, 0);
14739 public function ListBox(
$name, $w, $h, $values, $prop=array(), $opt=array(),
$x=
'',
$y=
'', $js=
false) {
14747 $this->checkPageRegions($h,
$x,
$y);
14749 $this->_addfield(
'listbox',
$name,
$x,
$y, $w, $h, $prop);
14751 foreach ($values as $value) {
14752 $s .=
"'".addslashes($value).
"',";
14754 $this->javascript .=
'f'.$name.
'.setItems(['.substr($s, 0, -1).
"]);\n";
14758 $prop = array_merge($this->getFormDefaultProp(), $prop);
14760 $popt = $this->getAnnotOptFromJSProp($prop);
14762 $this->annotation_fonts[$this->CurrentFont[
'fontkey']] = $this->CurrentFont[
'i'];
14763 $fontstyle = sprintf(
'/F%d %.2F Tf %s', $this->CurrentFont[
'i'], $this->FontSizePt, $this->TextColor);
14764 $popt[
'da'] = $fontstyle;
14765 $popt[
'ap'] = array();
14766 $popt[
'ap'][
'n'] =
'q BT '.$fontstyle.
' ET Q';
14768 $opt = array_merge($popt, $opt);
14770 $opt[
'Subtype'] =
'Widget';
14773 $opt[
'opt'] = $values;
14774 $this->Annotation(
$x,
$y, $w, $h,
$name, $opt, 0);
14797 public function ComboBox(
$name, $w, $h, $values, $prop=array(), $opt=array(),
$x=
'',
$y=
'', $js=
false) {
14805 $this->checkPageRegions($h,
$x,
$y);
14807 $this->_addfield(
'combobox',
$name,
$x,
$y, $w, $h, $prop);
14809 foreach ($values as $value) {
14810 $s .=
"'".addslashes($value).
"',";
14812 $this->javascript .=
'f'.$name.
'.setItems(['.substr($s, 0, -1).
"]);\n";
14816 $prop = array_merge($this->getFormDefaultProp(), $prop);
14817 $prop[
'Combo'] =
true;
14819 $popt = $this->getAnnotOptFromJSProp($prop);
14821 $this->annotation_fonts[$this->CurrentFont[
'fontkey']] = $this->CurrentFont[
'i'];
14822 $fontstyle = sprintf(
'/F%d %.2F Tf %s', $this->CurrentFont[
'i'], $this->FontSizePt, $this->TextColor);
14823 $popt[
'da'] = $fontstyle;
14824 $popt[
'ap'] = array();
14825 $popt[
'ap'][
'n'] =
'q BT '.$fontstyle.
' ET Q';
14827 $opt = array_merge($popt, $opt);
14829 $opt[
'Subtype'] =
'Widget';
14832 $opt[
'opt'] = $values;
14833 $this->Annotation(
$x,
$y, $w, $h,
$name, $opt, 0);
14856 public function CheckBox(
$name, $w, $checked=
false, $prop=array(), $opt=array(), $onvalue=
'Yes',
$x=
'',
$y=
'', $js=
false) {
14864 $this->checkPageRegions($w,
$x,
$y);
14866 $this->_addfield(
'checkbox',
$name,
$x,
$y, $w, $w, $prop);
14869 if (!isset($prop[
'value'])) {
14870 $prop[
'value'] = array(
'Yes');
14873 $prop = array_merge($this->getFormDefaultProp(), $prop);
14874 $prop[
'borderStyle'] =
'inset';
14876 $popt = $this->getAnnotOptFromJSProp($prop);
14878 $font =
'zapfdingbats';
14879 $this->AddFont($font);
14880 $tmpfont = $this->getFontBuffer($font);
14881 $this->annotation_fonts[$tmpfont[
'fontkey']] = $tmpfont[
'i'];
14882 $fontstyle = sprintf(
'/F%d %.2F Tf %s', $tmpfont[
'i'], $this->FontSizePt, $this->TextColor);
14883 $popt[
'da'] = $fontstyle;
14884 $popt[
'ap'] = array();
14885 $popt[
'ap'][
'n'] = array();
14886 $popt[
'ap'][
'n'][
'Yes'] =
'q BT '.$fontstyle.
' 0 0 Td (8) Tj ET Q';
14887 $popt[
'ap'][
'n'][
'Off'] =
'q BT '.$fontstyle.
' 0 0 Td (8) Tj ET Q';
14889 $opt = array_merge($popt, $opt);
14891 $opt[
'Subtype'] =
'Widget';
14892 $opt[
'ft'] =
'Btn';
14894 $opt[
'opt'] = array($onvalue);
14896 $opt[
'v'] = array(
'/0');
14897 $opt[
'as'] =
'Yes';
14899 $opt[
'v'] = array(
'/Off');
14900 $opt[
'as'] =
'Off';
14902 $this->Annotation(
$x,
$y, $w, $w,
$name, $opt, 0);
14926 public function Button(
$name, $w, $h, $caption, $action, $prop=array(), $opt=array(),
$x=
'',
$y=
'', $js=
false) {
14934 $this->checkPageRegions($h,
$x,
$y);
14936 $this->_addfield(
'button',
$name, $this->x, $this->y, $w, $h, $prop);
14937 $this->javascript .=
'f'.$name.
".buttonSetCaption('".addslashes($caption).
"');\n";
14938 $this->javascript .=
'f'.$name.
".setAction('MouseUp','".addslashes($action).
"');\n";
14939 $this->javascript .=
'f'.$name.
".highlight='push';\n";
14940 $this->javascript .=
'f'.$name.
".print=false;\n";
14944 $prop = array_merge($this->getFormDefaultProp(), $prop);
14945 $prop[
'Pushbutton'] =
'true';
14946 $prop[
'highlight'] =
'push';
14947 $prop[
'display'] =
'display.noPrint';
14949 $popt = $this->getAnnotOptFromJSProp($prop);
14950 $this->annotation_fonts[$this->CurrentFont[
'fontkey']] = $this->CurrentFont[
'i'];
14951 $fontstyle = sprintf(
'/F%d %.2F Tf %s', $this->CurrentFont[
'i'], $this->FontSizePt, $this->TextColor);
14952 $popt[
'da'] = $fontstyle;
14953 $popt[
'ap'] = array();
14954 $popt[
'ap'][
'n'] =
'q BT '.$fontstyle.
' ET Q';
14956 if (!isset($popt[
'mk'])) {
14957 $popt[
'mk'] = array();
14959 $ann_obj_id = ($this->
n + 1);
14960 if (!empty($action) AND !is_array($action)) {
14961 $ann_obj_id = ($this->
n + 2);
14963 $popt[
'mk'][
'ca'] = $this->_textstring($caption, $ann_obj_id);
14964 $popt[
'mk'][
'rc'] = $this->_textstring($caption, $ann_obj_id);
14965 $popt[
'mk'][
'ac'] = $this->_textstring($caption, $ann_obj_id);
14967 $opt = array_merge($popt, $opt);
14969 $opt[
'Subtype'] =
'Widget';
14970 $opt[
'ft'] =
'Btn';
14971 $opt[
't'] = $caption;
14973 if (!empty($action)) {
14974 if (is_array($action)) {
14976 $opt[
'aa'] =
'/D <<';
14977 $bmode = array(
'SubmitForm',
'ResetForm',
'ImportData');
14978 foreach ($action AS $key => $val) {
14979 if (($key ==
'S') AND in_array($val, $bmode)) {
14980 $opt[
'aa'] .=
' /S /'.$val;
14981 } elseif (($key ==
'F') AND (!empty($val))) {
14982 $opt[
'aa'] .=
' /F '.$this->_datastring($val, $ann_obj_id);
14983 } elseif (($key ==
'Fields') AND is_array($val) AND !empty($val)) {
14984 $opt[
'aa'] .=
' /Fields [';
14985 foreach ($val AS $field) {
14986 $opt[
'aa'] .=
' '.$this->_textstring($field, $ann_obj_id);
14989 } elseif (($key ==
'Flags')) {
14991 if (is_array($val)) {
14992 foreach ($val AS $flag) {
14994 case 'Include/Exclude': {
14998 case 'IncludeNoValueFields': {
15002 case 'ExportFormat': {
15006 case 'GetMethod': {
15010 case 'SubmitCoordinates': {
15018 case 'IncludeAppendSaves': {
15022 case 'IncludeAnnotations': {
15026 case 'SubmitPDF': {
15030 case 'CanonicalFormat': {
15034 case 'ExclNonUserAnnots': {
15042 case 'EmbedForm': {
15049 $ff = intval($val);
15051 $opt[
'aa'] .=
' /Flags '.$ff;
15054 $opt[
'aa'] .=
' >>';
15057 $js_obj_id = $this->addJavascriptObject($action);
15058 $opt[
'aa'] =
'/D '.$js_obj_id.
' 0 R';
15061 $this->Annotation(
$x,
$y, $w, $h,
$name, $opt, 0);
15079 if ((!$this->sign) OR (!isset($this->signature_data[
'cert_type']))) {
15082 $out = $this->_getobj($this->sig_obj_id + 1).
"\n";
15083 $out .=
'<< /Type /Sig';
15084 $out .=
' /Filter /Adobe.PPKLite';
15085 $out .=
' /SubFilter /adbe.pkcs7.detached';
15086 $out .=
' '.$this->byterange_string;
15087 $out .=
' /Contents<'.str_repeat(
'0', $this->signature_max_length).
'>';
15088 $out .=
' /Reference [';
15089 $out .=
' << /Type /SigRef';
15090 if ($this->signature_data[
'cert_type'] > 0) {
15091 $out .=
' /TransformMethod /DocMDP';
15092 $out .=
' /TransformParams <<';
15093 $out .=
' /Type /TransformParams';
15094 $out .=
' /V /1.2';
15095 $out .=
' /P '.$this->signature_data[
'cert_type'];
15097 $out .=
' /TransformMethod /UR3';
15098 $out .=
' /TransformParams <<';
15099 $out .=
' /Type /TransformParams';
15100 $out .=
' /V /2.2';
15101 if (!$this->empty_string($this->ur[
'document'])) {
15102 $out .=
' /Document['.$this->ur[
'document'].
']';
15104 if (!$this->empty_string($this->ur[
'form'])) {
15105 $out .=
' /Form['.$this->ur[
'form'].
']';
15107 if (!$this->empty_string($this->ur[
'signature'])) {
15108 $out .=
' /Signature['.$this->ur[
'signature'].
']';
15110 if (!$this->empty_string($this->ur[
'annots'])) {
15111 $out .=
' /Annots['.$this->ur[
'annots'].
']';
15113 if (!$this->empty_string($this->ur[
'ef'])) {
15114 $out .=
' /EF['.$this->ur[
'ef'].
']';
15116 if (!$this->empty_string($this->ur[
'formex'])) {
15117 $out .=
' /FormEX['.$this->ur[
'formex'].
']';
15128 if (isset($this->signature_data[
'info'][
'Name']) AND !$this->empty_string($this->signature_data[
'info'][
'Name'])) {
15129 $out .=
' /Name '.$this->_textstring($this->signature_data[
'info'][
'Name']);
15131 if (isset($this->signature_data[
'info'][
'Location']) AND !$this->empty_string($this->signature_data[
'info'][
'Location'])) {
15132 $out .=
' /Location '.$this->_textstring($this->signature_data[
'info'][
'Location']);
15134 if (isset($this->signature_data[
'info'][
'Reason']) AND !$this->empty_string($this->signature_data[
'info'][
'Reason'])) {
15135 $out .=
' /Reason '.$this->_textstring($this->signature_data[
'info'][
'Reason']);
15137 if (isset($this->signature_data[
'info'][
'ContactInfo']) AND !$this->empty_string($this->signature_data[
'info'][
'ContactInfo'])) {
15138 $out .=
' /ContactInfo '.$this->_textstring($this->signature_data[
'info'][
'ContactInfo']);
15140 $out .=
' /M '.$this->_datestring();
15142 $out .=
"\n".
'endobj';
15163 public function setUserRights(
15165 $document=
'/FullSave',
15166 $annots=
'/Create/Delete/Modify/Copy/Import/Export',
15167 $form=
'/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate',
15168 $signature=
'/Modify',
15169 $ef=
'/Create/Delete/Modify/Import',
15171 $this->ur[
'enabled'] = $enable;
15172 $this->ur[
'document'] = $document;
15173 $this->ur[
'annots'] = $annots;
15174 $this->ur[
'form'] = $form;
15175 $this->ur[
'signature'] = $signature;
15176 $this->ur[
'ef'] = $ef;
15177 $this->ur[
'formex'] = $formex;
15178 if (!$this->sign) {
15179 $this->setSignature(
'',
'',
'',
'', 0, array());
15199 public function setSignature($signing_cert=
'', $private_key=
'', $private_key_password=
'', $extracerts=
'', $cert_type=2, $info=array()) {
15204 $this->sign =
true;
15206 $this->sig_obj_id = $this->n;
15208 $this->signature_data = array();
15209 if (strlen($signing_cert) == 0) {
15210 $signing_cert =
'file://'.dirname(__FILE__).
'/tcpdf.crt';
15211 $private_key_password =
'tcpdfdemo';
15213 if (strlen($private_key) == 0) {
15214 $private_key = $signing_cert;
15216 $this->signature_data[
'signcert'] = $signing_cert;
15217 $this->signature_data[
'privkey'] = $private_key;
15218 $this->signature_data[
'password'] = $private_key_password;
15219 $this->signature_data[
'extracerts'] = $extracerts;
15220 $this->signature_data[
'cert_type'] = $cert_type;
15221 $this->signature_data[
'info'] = $info;
15236 if (($page < 1) OR ($page > $this->numpages)) {
15237 $this->signature_appearance[
'page'] = $this->page;
15239 $this->signature_appearance[
'page'] = intval($page);
15241 $a =
$x * $this->k;
15242 $b = $this->pagedim[($this->signature_appearance[
'page'])][
'h'] - ((
$y + $h) * $this->k);
15243 $c = $w * $this->k;
15244 $d = $h * $this->k;
15245 $this->signature_appearance[
'rect'] = sprintf(
'%.2F %.2F %.2F %.2F', $a, $b, $a+$c, $b+
$d);
15256 if (empty($page)) {
15257 $page = $this->page + 1;
15259 $this->newpagegroup[$page] =
true;
15271 $this->AliasNbPages = $alias;
15283 if ($this->isUnicodeFont()) {
15284 return '{'.$this->AliasNbPages.
'}';
15286 return $this->AliasNbPages;
15299 $this->AliasNumPage = $alias;
15311 if ($this->isUnicodeFont()) {
15312 return '{'.$this->AliasNumPage.
'}';
15314 return $this->AliasNumPage;
15324 return $this->pagegroups[$this->currpagegroup];
15334 return $this->formatPageNumber($this->getGroupPageNo());
15346 if ($this->isUnicodeFont()) {
15347 return '{'.$this->currpagegroup.
'}';
15349 return $this->currpagegroup;
15361 if ($this->isUnicodeFont()) {
15362 return '{'.str_replace(
'{nb',
'{pnb', $this->currpagegroup).
'}';
15364 return str_replace(
'{nb',
'{pnb', $this->currpagegroup);
15375 return number_format((
float)$num, 0,
'',
'.');
15387 return number_format((
float)$num, 0,
'',
'.');
15397 return $this->formatPageNumber($this->PageNo());
15406 $this->n_ocg_print = $this->_newobj();
15407 $this->_out(
'<< /Type /OCG /Name '.$this->_textstring(
'print', $this->n_ocg_print).
' /Usage << /Print <</PrintState /ON>> /View <</ViewState /OFF>> >> >>'.
"\n".
'endobj');
15408 $this->n_ocg_view = $this->_newobj();
15409 $this->_out(
'<< /Type /OCG /Name '.$this->_textstring(
'view', $this->n_ocg_view).
' /Usage << /Print <</PrintState /OFF>> /View <</ViewState /ON>> >> >>'.
"\n".
'endobj');
15421 if ($this->openMarkedContent) {
15423 $this->_out(
'EMC');
15424 $this->openMarkedContent =
false;
15428 $this->_out(
'/OC /OC1 BDC');
15429 $this->openMarkedContent =
true;
15433 $this->_out(
'/OC /OC2 BDC');
15434 $this->openMarkedContent =
true;
15442 $this->Error(
'Incorrect visibility: '.$v);
15446 $this->visibility = $v;
15457 $n = count($this->extgstates) + 1;
15459 for ($i = 1; $i < $n; ++$i) {
15460 if ($this->extgstates[$i][
'parms'] == $parms) {
15465 $this->extgstates[$n][
'parms'] = $parms;
15476 $this->_out(sprintf(
'/GS%d gs', $gs));
15486 $ne = count($this->extgstates);
15487 for ($i = 1; $i <= $ne; ++$i) {
15488 $this->extgstates[$i][
'n'] = $this->_newobj();
15489 $out =
'<< /Type /ExtGState';
15490 foreach ($this->extgstates[$i][
'parms'] as $k => $v) {
15491 if (is_float($v)) {
15492 $v = sprintf(
'%.2F', $v);
15494 $out .=
' /'.$k.
' '.$v;
15497 $out .=
"\n".
'endobj';
15510 $gs = $this->addExtGState(array(
'ca' => $alpha,
'CA' => $alpha,
'BM' =>
'/'.$bm,
'AIS' =>
'false'));
15511 $this->setExtGState($gs);
15521 if (($quality < 1) OR ($quality > 100)) {
15524 $this->jpeg_quality = intval($quality);
15534 $this->default_table_columns = intval($cols);
15544 $this->cell_height_ratio = $h;
15553 return $this->cell_height_ratio;
15563 $this->PDFVersion = $version;
15576 $this->viewer_preferences = $preferences;
15592 public function colorRegistrationBar(
$x,
$y, $w, $h, $transition=
true, $vertical=
false, $colors=
'A,R,G,B,C,M,Y,K') {
15593 $bars = explode(
',', $colors);
15594 $numbars = count($bars);
15597 $coords = array(0, 0, 0, 1);
15598 $wb = $w / $numbars;
15603 $coords = array(1, 0, 0, 0);
15605 $hb = $h / $numbars;
15611 foreach ($bars as $col) {
15615 $col_a = array(255);
15621 $col_b = array(255);
15625 $col_a = array(255,255,255);
15626 $col_b = array(255,0,0);
15630 $col_a = array(255,255,255);
15631 $col_b = array(0,255,0);
15635 $col_a = array(255,255,255);
15636 $col_b = array(0,0,255);
15640 $col_a = array(0,0,0,0);
15641 $col_b = array(100,0,0,0);
15645 $col_a = array(0,0,0,0);
15646 $col_b = array(0,100,0,0);
15650 $col_a = array(0,0,0,0);
15651 $col_b = array(0,0,100,0);
15655 $col_a = array(0,0,0,0);
15656 $col_b = array(0,0,0,100);
15660 $col_a = array(255);
15667 $this->LinearGradient($xb, $yb, $wb, $hb, $col_a, $col_b, $coords);
15670 $this->SetFillColorArray($col_b);
15671 $this->Rect($xb, $yb, $wb, $hb,
'F', array());
15690 public function cropMark(
$x,
$y, $w, $h,
$type=
'A,B,C,D', $color=array(0,0,0)) {
15691 $this->SetLineStyle(array(
'width' => (0.5 / $this->k),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $color));
15692 $crops = explode(
',',
$type);
15693 $numcrops = count($crops);
15696 foreach ($crops as $crop) {
15743 $this->Line($x1, $y1, $x2, $y2);
15744 $this->Line($x3, $y3, $x4, $y4);
15761 $line_style = array(
'width' => (0.5 / $this->k),
'cap' =>
'butt',
'join' =>
'miter',
'dash' => 0,
'color' => $cola);
15762 $this->SetFillColorArray($cola);
15763 $this->PieSector(
$x,
$y, $r, 90, 180,
'F');
15764 $this->PieSector(
$x,
$y, $r, 270, 360,
'F');
15765 $this->Circle(
$x,
$y, $r, 0, 360,
'C', $line_style, array(), 8);
15768 $this->SetFillColorArray($colb);
15769 $this->PieSector(
$x,
$y, $r2, 90, 180,
'F');
15770 $this->PieSector(
$x,
$y, $r2, 270, 360,
'F');
15771 $this->SetFillColorArray($cola);
15772 $this->PieSector(
$x,
$y, $r2, 0, 90,
'F');
15773 $this->PieSector(
$x,
$y, $r2, 180, 270,
'F');
15774 $this->Circle(
$x,
$y, $r2, 0, 360,
'C', $line_style, array(), 8);
15792 $this->Clip(
$x,
$y, $w, $h);
15793 $this->Gradient(2, $coords, array(array(
'color' => $col1,
'offset' => 0,
'exponent' => 1), array(
'color' => $col2,
'offset' => 1,
'exponent' => 1)), array(),
false);
15809 public function RadialGradient(
$x,
$y, $w, $h, $col1=array(), $col2=array(), $coords=array(0.5,0.5,0.5,0.5,1)) {
15810 $this->Clip(
$x,
$y, $w, $h);
15811 $this->Gradient(3, $coords, array(array(
'color' => $col1,
'offset' => 0,
'exponent' => 1), array(
'color' => $col2,
'offset' => 1,
'exponent' => 1)), array(),
false);
15832 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) {
15833 $this->Clip(
$x,
$y, $w, $h);
15834 $n = count($this->gradients) + 1;
15835 $this->gradients[$n] = array();
15836 $this->gradients[$n][
'type'] = 6;
15837 $this->gradients[$n][
'coords'] = array();
15838 $this->gradients[$n][
'antialias'] = $antialias;
15839 $this->gradients[$n][
'colors'] = array();
15840 $this->gradients[$n][
'transparency'] =
false;
15842 if (!isset($coords[0][
'f'])) {
15844 if (!isset($col1[1])) {
15845 $col1[1] = $col1[2] = $col1[0];
15847 if (!isset($col2[1])) {
15848 $col2[1] = $col2[2] = $col2[0];
15850 if (!isset($col3[1])) {
15851 $col3[1] = $col3[2] = $col3[0];
15853 if (!isset($col4[1])) {
15854 $col4[1] = $col4[2] = $col4[0];
15856 $patch_array[0][
'f'] = 0;
15857 $patch_array[0][
'points'] = $coords;
15858 $patch_array[0][
'colors'][0][
'r'] = $col1[0];
15859 $patch_array[0][
'colors'][0][
'g'] = $col1[1];
15860 $patch_array[0][
'colors'][0][
'b'] = $col1[2];
15861 $patch_array[0][
'colors'][1][
'r'] = $col2[0];
15862 $patch_array[0][
'colors'][1][
'g'] = $col2[1];
15863 $patch_array[0][
'colors'][1][
'b'] = $col2[2];
15864 $patch_array[0][
'colors'][2][
'r'] = $col3[0];
15865 $patch_array[0][
'colors'][2][
'g'] = $col3[1];
15866 $patch_array[0][
'colors'][2][
'b'] = $col3[2];
15867 $patch_array[0][
'colors'][3][
'r'] = $col4[0];
15868 $patch_array[0][
'colors'][3][
'g'] = $col4[1];
15869 $patch_array[0][
'colors'][3][
'b'] = $col4[2];
15872 $patch_array = $coords;
15876 $this->gradients[$n][
'stream'] =
'';
15877 $count_patch = count($patch_array);
15878 for ($i=0; $i < $count_patch; ++$i) {
15879 $this->gradients[$n][
'stream'] .= chr($patch_array[$i][
'f']);
15880 $count_points = count($patch_array[$i][
'points']);
15881 for ($j=0; $j < $count_points; ++$j) {
15883 $patch_array[$i][
'points'][$j] = (($patch_array[$i][
'points'][$j] - $coords_min) / ($coords_max - $coords_min)) * $bpcd;
15884 if ($patch_array[$i][
'points'][$j] < 0) {
15885 $patch_array[$i][
'points'][$j] = 0;
15887 if ($patch_array[$i][
'points'][$j] > $bpcd) {
15888 $patch_array[$i][
'points'][$j] = $bpcd;
15890 $this->gradients[$n][
'stream'] .= chr(floor($patch_array[$i][
'points'][$j] / 256));
15891 $this->gradients[$n][
'stream'] .= chr(floor($patch_array[$i][
'points'][$j] % 256));
15893 $count_cols = count($patch_array[$i][
'colors']);
15894 for ($j=0; $j < $count_cols; ++$j) {
15896 $this->gradients[$n][
'stream'] .= chr($patch_array[$i][
'colors'][$j][
'r']);
15897 $this->gradients[$n][
'stream'] .= chr($patch_array[$i][
'colors'][$j][
'g']);
15898 $this->gradients[$n][
'stream'] .= chr($patch_array[$i][
'colors'][$j][
'b']);
15902 $this->_out(
'/Sh'.$n.
' sh');
15919 $x = $this->w -
$x - $w;
15924 $s .= sprintf(
' %.2F %.2F %.2F %.2F re W n',
$x*$this->k, ($this->h-
$y)*$this->k, $w*$this->k, -$h*$this->k);
15926 $s .= sprintf(
' %.3F 0 0 %.3F %.3F %.3F cm', $w*$this->k, $h*$this->k,
$x*$this->k, ($this->h-(
$y+$h))*$this->k);
15941 public function Gradient(
$type, $coords, $stops, $background=array(), $antialias=
false) {
15942 $n = count($this->gradients) + 1;
15943 $this->gradients[$n] = array();
15944 $this->gradients[$n][
'type'] =
$type;
15945 $this->gradients[$n][
'coords'] = $coords;
15946 $this->gradients[$n][
'antialias'] = $antialias;
15947 $this->gradients[$n][
'colors'] = array();
15948 $this->gradients[$n][
'transparency'] =
false;
15950 $numcolspace = count($stops[0][
'color']);
15951 $bcolor = array_values($background);
15952 switch($numcolspace) {
15954 $this->gradients[$n][
'colspace'] =
'DeviceCMYK';
15955 if (!empty($background)) {
15956 $this->gradients[$n][
'background'] = sprintf(
'%.3F %.3F %.3F %.3F', $bcolor[0]/100, $bcolor[1]/100, $bcolor[2]/100, $bcolor[3]/100);
15961 $this->gradients[$n][
'colspace'] =
'DeviceRGB';
15962 if (!empty($background)) {
15963 $this->gradients[$n][
'background'] = sprintf(
'%.3F %.3F %.3F', $bcolor[0]/255, $bcolor[1]/255, $bcolor[2]/255);
15968 $this->gradients[$n][
'colspace'] =
'DeviceGray';
15969 if (!empty($background)) {
15970 $this->gradients[$n][
'background'] = sprintf(
'%.3F', $bcolor[0]/255);
15975 $num_stops = count($stops);
15976 $last_stop_id = $num_stops - 1;
15977 foreach ($stops as $key => $stop) {
15978 $this->gradients[$n][
'colors'][$key] = array();
15980 if (isset($stop[
'offset'])) {
15981 $this->gradients[$n][
'colors'][$key][
'offset'] = $stop[
'offset'];
15984 $this->gradients[$n][
'colors'][$key][
'offset'] = 0;
15985 } elseif ($key == $last_stop_id) {
15986 $this->gradients[$n][
'colors'][$key][
'offset'] = 1;
15988 $offsetstep = (1 - $this->gradients[$n][
'colors'][($key - 1)][
'offset']) / ($num_stops - $key);
15989 $this->gradients[$n][
'colors'][$key][
'offset'] = $this->gradients[$n][
'colors'][($key - 1)][
'offset'] + $offsetstep;
15992 if (isset($stop[
'opacity'])) {
15993 $this->gradients[$n][
'colors'][$key][
'opacity'] = $stop[
'opacity'];
15994 if ($stop[
'opacity'] < 1) {
15995 $this->gradients[$n][
'transparency'] =
true;
15998 $this->gradients[$n][
'colors'][$key][
'opacity'] = 1;
16001 if (isset($stop[
'exponent'])) {
16002 $this->gradients[$n][
'colors'][$key][
'exponent'] = $stop[
'exponent'];
16004 $this->gradients[$n][
'colors'][$key][
'exponent'] = 1;
16007 $color = array_values($stop[
'color']);
16008 switch($numcolspace) {
16010 $this->gradients[$n][
'colors'][$key][
'color'] = sprintf(
'%.3F %.3F %.3F %.3F', $color[0]/100, $color[1]/100, $color[2]/100, $color[3]/100);
16014 $this->gradients[$n][
'colors'][$key][
'color'] = sprintf(
'%.3F %.3F %.3F', $color[0]/255, $color[1]/255, $color[2]/255);
16018 $this->gradients[$n][
'colors'][$key][
'color'] = sprintf(
'%.3F', $color[0]/255);
16023 if ($this->gradients[$n][
'transparency']) {
16025 $this->_out(
'/TGS'.$n.
' gs');
16028 $this->_out(
'/Sh'.$n.
' sh');
16040 $idt = count($this->gradients);
16041 foreach ($this->gradients as $id => $grad) {
16042 if (($grad[
'type'] == 2) OR ($grad[
'type'] == 3)) {
16043 $fc = $this->_newobj();
16045 $out .=
' /FunctionType 3';
16046 $out .=
' /Domain [0 1]';
16051 $num_cols = count($grad[
'colors']);
16052 $lastcols = $num_cols - 1;
16053 for ($i = 1; $i < $num_cols; ++$i) {
16054 $functions .= ($fc + $i).
' 0 R ';
16055 if ($i < $lastcols) {
16056 $bounds .= sprintf(
'%.3F ', $grad[
'colors'][$i][
'offset']);
16060 $out .=
' /Functions ['.trim($functions).
']';
16061 $out .=
' /Bounds ['.trim($bounds).
']';
16062 $out .=
' /Encode ['.trim($encode).
']';
16064 $out .=
"\n".
'endobj';
16066 for ($i = 1; $i < $num_cols; ++$i) {
16069 $out .=
' /FunctionType 2';
16070 $out .=
' /Domain [0 1]';
16071 $out .=
' /C0 ['.$grad[
'colors'][($i - 1)][
'color'].
']';
16072 $out .=
' /C1 ['.$grad[
'colors'][$i][
'color'].
']';
16073 $out .=
' /N '.$grad[
'colors'][$i][
'exponent'];
16075 $out .=
"\n".
'endobj';
16079 if ($grad[
'transparency']) {
16080 $ft = $this->_newobj();
16082 $out .=
' /FunctionType 3';
16083 $out .=
' /Domain [0 1]';
16086 $num_cols = count($grad[
'colors']);
16087 for ($i = 1; $i < $num_cols; ++$i) {
16088 $functions .= ($ft + $i).
' 0 R ';
16090 $out .=
' /Functions ['.trim($functions).
']';
16091 $out .=
' /Bounds ['.trim($bounds).
']';
16092 $out .=
' /Encode ['.trim($encode).
']';
16094 $out .=
"\n".
'endobj';
16096 for ($i = 1; $i < $num_cols; ++$i) {
16099 $out .=
' /FunctionType 2';
16100 $out .=
' /Domain [0 1]';
16101 $out .=
' /C0 ['.$grad[
'colors'][($i - 1)][
'opacity'].
']';
16102 $out .=
' /C1 ['.$grad[
'colors'][$i][
'opacity'].
']';
16103 $out .=
' /N '.$grad[
'colors'][$i][
'exponent'];
16105 $out .=
"\n".
'endobj';
16112 $out =
'<< /ShadingType '.$grad[
'type'];
16113 if (isset($grad[
'colspace'])) {
16114 $out .=
' /ColorSpace /'.$grad[
'colspace'];
16116 $out .=
' /ColorSpace /DeviceRGB';
16118 if (isset($grad[
'background']) AND !empty($grad[
'background'])) {
16119 $out .=
' /Background ['.$grad[
'background'].
']';
16121 if (isset($grad[
'antialias']) AND ($grad[
'antialias'] ===
true)) {
16122 $out .=
' /AntiAlias true';
16124 if ($grad[
'type'] == 2) {
16125 $out .=
' '.sprintf(
'/Coords [%.3F %.3F %.3F %.3F]', $grad[
'coords'][0], $grad[
'coords'][1], $grad[
'coords'][2], $grad[
'coords'][3]);
16126 $out .=
' /Domain [0 1]';
16127 $out .=
' /Function '.$fc.
' 0 R';
16128 $out .=
' /Extend [true true]';
16130 } elseif ($grad[
'type'] == 3) {
16133 $out .=
' '.sprintf(
'/Coords [%.3F %.3F 0 %.3F %.3F %.3F]', $grad[
'coords'][0], $grad[
'coords'][1], $grad[
'coords'][2], $grad[
'coords'][3], $grad[
'coords'][4]);
16134 $out .=
' /Domain [0 1]';
16135 $out .=
' /Function '.$fc.
' 0 R';
16136 $out .=
' /Extend [true true]';
16138 } elseif ($grad[
'type'] == 6) {
16139 $out .=
' /BitsPerCoordinate 16';
16140 $out .=
' /BitsPerComponent 8';
16141 $out .=
' /Decode[0 1 0 1 0 1 0 1 0 1]';
16142 $out .=
' /BitsPerFlag 8';
16143 $stream = $this->_getrawstream($grad[
'stream']);
16144 $out .=
' /Length '.strlen($stream);
16146 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
16148 $out .=
"\n".
'endobj';
16150 if ($grad[
'transparency']) {
16151 $shading_transparency = preg_replace(
'/\/ColorSpace \/[^\s]+/si',
'/ColorSpace /DeviceGray',
$out);
16152 $shading_transparency = preg_replace(
'/\/Function [0-9]+ /si',
'/Function '.$ft.
' ', $shading_transparency);
16154 $this->gradients[$id][
'id'] = $this->n;
16157 $out =
'<< /Type /Pattern /PatternType 2';
16158 $out .=
' /Shading '.$this->gradients[$id][
'id'].
' 0 R';
16160 $out .=
"\n".
'endobj';
16162 $this->gradients[$id][
'pattern'] = $this->n;
16164 if ($grad[
'transparency']) {
16166 $idgs = $id + $idt;
16168 $this->_out($shading_transparency);
16169 $this->gradients[$idgs][
'id'] = $this->n;
16171 $out =
'<< /Type /Pattern /PatternType 2';
16172 $out .=
' /Shading '.$this->gradients[$idgs][
'id'].
' 0 R';
16174 $out .=
"\n".
'endobj';
16176 $this->gradients[$idgs][
'pattern'] = $this->n;
16178 $oid = $this->_newobj();
16179 $this->xobjects[
'LX'.$oid] = array(
'n' => $oid);
16181 $stream =
'q /a0 gs /Pattern cs /p'.$idgs.
' scn 0 0 '.$this->wPt.
' '.$this->hPt.
' re f Q';
16182 if ($this->compress) {
16183 $filter =
' /Filter /FlateDecode';
16184 $stream = gzcompress($stream);
16186 $stream = $this->_getrawstream($stream);
16187 $out =
'<< /Type /XObject /Subtype /Form /FormType 1'.$filter;
16188 $out .=
' /Length '.strlen($stream);
16189 $rect = sprintf(
'%.2F %.2F', $this->wPt, $this->hPt);
16190 $out .=
' /BBox [0 0 '.$rect.
']';
16191 $out .=
' /Group << /Type /Group /S /Transparency /CS /DeviceGray >>';
16192 $out .=
' /Resources <<';
16193 $out .=
' /ExtGState << /a0 << /ca 1 /CA 1 >> >>';
16194 $out .=
' /Pattern << /p'.$idgs.
' '.$this->gradients[$idgs][
'pattern'].
' 0 R >>';
16197 $out .=
' stream'.
"\n".$stream.
"\n".
'endstream';
16198 $out .=
"\n".
'endobj';
16202 $out =
'<< /Type /Mask /S /Luminosity /G '.($this->n - 1).
' 0 R >>'.
"\n".
'endobj';
16206 $out =
'<< /Type /ExtGState /SMask '.($this->n - 1).
' 0 R /AIS false >>'.
"\n".
'endobj';
16208 $this->extgstates[] = array(
'n' => $this->
n,
'name' =>
'TGS'.$id);
16228 public function PieSector($xc, $yc, $r, $a, $b, $style=
'FD',
$cw=
true, $o=90) {
16229 $this->PieSectorXY($xc, $yc, $r, $r, $a, $b, $style,
$cw, $o);
16249 public function PieSectorXY($xc, $yc, $rx, $ry, $a, $b, $style=
'FD',
$cw=
false, $o=0, $nc=2) {
16251 $xc = $this->w - $xc;
16253 $op = $this->getPathPaintOperator($style);
16255 $line_style = array();
16259 $b = 360 - $a + $o;
16260 $a = 360 -
$d + $o;
16265 $this->_outellipticalarc($xc, $yc, $rx, $ry, 0, $a, $b,
true, $nc);
16289 public function ImageEps(
$file,
$x=
'',
$y=
'', $w=0, $h=0, $link=
'', $useBoundingBox=
true, $align=
'', $palign=
'', $border=0, $fitonpage=
false) {
16290 if ($this->rasterize_vector_images AND ($w > 0) AND ($h > 0)) {
16292 return $this->Image(
$file,
$x,
$y, $w, $h,
'EPS', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false, $fitonpage);
16301 $this->checkPageRegions($h,
$x,
$y);
16304 if (
$data ===
false) {
16305 $this->Error(
'EPS file not found: '.
$file);
16309 preg_match(
"/%%Creator:([^\r\n]+)/",
$data, $regs); # find Creator
16310 if (count($regs) > 1) {
16311 $version_str = trim($regs[1]); # e.g.
"Adobe Illustrator(R) 8.0"
16312 if (strpos($version_str,
'Adobe Illustrator') !==
false) {
16313 $versexp = explode(
' ', $version_str);
16314 $version = (float)array_pop($versexp);
16315 if ($version >= 9) {
16316 $this->Error(
'This version of Adobe Illustrator file is not supported: '.
$file);
16321 $start = strpos(
$data,
'%!PS-Adobe');
16326 preg_match(
"/%%BoundingBox:([^\r\n]+)/",
$data, $regs);
16327 if (count($regs) > 1) {
16328 list($x1, $y1, $x2, $y2) = explode(
' ', trim($regs[1]));
16330 $this->Error(
'No BoundingBox found in EPS file: '.
$file);
16332 $start = strpos(
$data,
'%%EndSetup');
16333 if ($start ===
false) {
16334 $start = strpos(
$data,
'%%EndProlog');
16336 if ($start ===
false) {
16337 $start = strpos(
$data,
'%%BoundingBox');
16340 $end = strpos(
$data,
'%%PageTrailer');
16341 if ($end===
false) {
16342 $end = strpos(
$data,
'showpage');
16348 if (($w <= 0) AND ($h <= 0)) {
16349 $w = ($x2 - $x1) / $k;
16350 $h = ($y2 - $y1) / $k;
16351 } elseif ($w <= 0) {
16352 $w = ($x2-$x1) / $k * ($h / (($y2 - $y1) / $k));
16353 } elseif ($h <= 0) {
16354 $h = ($y2 - $y1) / $k * ($w / (($x2 - $x1) / $k));
16357 $this->fitBlock($w, $h,
$x,
$y, $fitonpage);
16358 if ($this->rasterize_vector_images) {
16360 return $this->Image(
$file,
$x,
$y, $w, $h,
'EPS', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false, $fitonpage);
16363 $scale_x = $w / (($x2 - $x1) / $k);
16364 $scale_y = $h / (($y2 - $y1) / $k);
16366 $this->img_rb_y =
$y + $h;
16369 if ($palign ==
'L') {
16370 $ximg = $this->lMargin;
16371 } elseif ($palign ==
'C') {
16372 $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
16373 } elseif ($palign ==
'R') {
16374 $ximg = $this->w - $this->rMargin - $w;
16378 $this->img_rb_x = $ximg;
16380 if ($palign ==
'L') {
16381 $ximg = $this->lMargin;
16382 } elseif ($palign ==
'C') {
16383 $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
16384 } elseif ($palign ==
'R') {
16385 $ximg = $this->w - $this->rMargin - $w;
16389 $this->img_rb_x = $ximg + $w;
16391 if ($useBoundingBox) {
16392 $dx = $ximg * $k - $x1;
16393 $dy =
$y * $k - $y1;
16399 $this->_out(
'q'.$this->epsmarker);
16401 $this->_out(sprintf(
'%.3F %.3F %.3F %.3F %.3F %.3F cm', 1, 0, 0, 1, $dx, $dy + ($this->hPt - (2 *
$y * $k) - ($y2 - $y1))));
16403 if (isset($scale_x)) {
16404 $this->_out(sprintf(
'%.3F %.3F %.3F %.3F %.3F %.3F cm', $scale_x, 0, 0, $scale_y, $x1 * (1 - $scale_x), $y2 * (1 - $scale_y)));
16407 preg_match(
'/[\r\n]+/s',
$data, $regs);
16408 $lines = explode($regs[0],
$data);
16410 $cnt = count($lines);
16411 for ($i=0; $i < $cnt; ++$i) {
16412 $line = $lines[$i];
16413 if (($line ==
'') OR ($line{0} ==
'%')) {
16416 $len = strlen($line);
16417 $chunks = explode(
' ', $line);
16418 $cmd = array_pop($chunks);
16420 if ((
$cmd ==
'Xa') OR (
$cmd ==
'XA')) {
16421 $b = array_pop($chunks);
16422 $g = array_pop($chunks);
16423 $r = array_pop($chunks);
16424 $this->_out(
''.$r.
' '.$g.
' '.$b.
' '.(
$cmd==
'Xa'?
'rg':
'RG'));
16445 $this->_out($line);
16449 list($c,$m,
$y,$k) = $chunks;
16450 $this->_out(
''.$c.
' '.$m.
' '.
$y.
' '.$k.
' k');
16454 list($c,$m,
$y,$k) = $chunks;
16455 $this->_out(
''.$c.
' '.$m.
' '.
$y.
' '.$k.
' K');
16463 $line{$len-1} = strtolower(
$cmd);
16464 $this->_out($line);
16469 $this->_out(
$cmd .
'*');
16476 $max = min($i+5, $cnt);
16477 for ($j=$i+1; $j < $max; ++$j) {
16478 $isU = ($isU OR (($lines[$j] ==
'U') OR ($lines[$j] ==
'*U')));
16499 $this->_out($this->epsmarker.
'Q');
16500 if (!empty($border)) {
16508 $this->Cell($w, $h,
'', $border, 0,
'', 0,
'', 0,
true);
16513 $this->Link($ximg,
$y, $w, $h, $link, 0);
16519 $this->x = $this->img_rb_x;
16523 $this->y =
$y + round($h/2);
16524 $this->x = $this->img_rb_x;
16528 $this->y = $this->img_rb_y;
16529 $this->x = $this->img_rb_x;
16533 $this->SetY($this->img_rb_y);
16540 $this->endlinex = $this->img_rb_x;
16549 $this->barcode = $bc;
16559 return $this->barcode;
16593 if ($this->empty_string(trim($code))) {
16596 require_once(dirname(__FILE__).
'/barcodes.php');
16598 $gvars = $this->getGraphicVars();
16601 $arrcode = $barcodeobj->getBarcodeArray();
16602 if ($arrcode ===
false) {
16603 $this->Error(
'Error in 1D barcode string');
16606 if (!isset($style[
'position'])) {
16607 $style[
'position'] =
'';
16608 } elseif ($style[
'position'] ==
'S') {
16610 $style[
'position'] =
'';
16611 $style[
'stretch'] =
true;
16613 if (!isset($style[
'fitwidth'])) {
16614 if (!isset($style[
'stretch'])) {
16615 $style[
'fitwidth'] =
true;
16617 $style[
'fitwidth'] =
false;
16620 if ($style[
'fitwidth']) {
16622 $style[
'stretch'] =
false;
16624 if (!isset($style[
'stretch'])) {
16625 if (($w ===
'') OR ($w <= 0)) {
16626 $style[
'stretch'] =
false;
16628 $style[
'stretch'] =
true;
16631 if (!isset($style[
'fgcolor'])) {
16632 $style[
'fgcolor'] = array(0,0,0);
16634 if (!isset($style[
'bgcolor'])) {
16635 $style[
'bgcolor'] =
false;
16637 if (!isset($style[
'border'])) {
16638 $style[
'border'] =
false;
16641 if (!isset($style[
'text'])) {
16642 $style[
'text'] =
false;
16644 if ($style[
'text'] AND isset($style[
'font'])) {
16645 if (isset($style[
'fontsize'])) {
16646 $fontsize = $style[
'fontsize'];
16648 $this->SetFont($style[
'font'],
'', $fontsize);
16650 if (!isset($style[
'stretchtext'])) {
16651 $style[
'stretchtext'] = 4;
16660 $this->checkPageRegions($h,
$x,
$y);
16661 if (($w ===
'') OR ($w <= 0)) {
16663 $w =
$x - $this->lMargin;
16665 $w = $this->w - $this->rMargin -
$x;
16669 if (!isset($style[
'padding'])) {
16671 } elseif ($style[
'padding'] ===
'auto') {
16672 $padding = 10 * ($w / ($arrcode[
'maxw'] + 20));
16674 $padding = floatval($style[
'padding']);
16677 if (!isset($style[
'hpadding'])) {
16678 $hpadding = $padding;
16679 } elseif ($style[
'hpadding'] ===
'auto') {
16680 $hpadding = 10 * ($w / ($arrcode[
'maxw'] + 20));
16682 $hpadding = floatval($style[
'hpadding']);
16685 if (!isset($style[
'vpadding'])) {
16686 $vpadding = $padding;
16687 } elseif ($style[
'vpadding'] ===
'auto') {
16688 $vpadding = ($hpadding / 2);
16690 $vpadding = floatval($style[
'vpadding']);
16693 $max_xres = ($w - (2 * $hpadding)) / $arrcode[
'maxw'];
16694 if ($style[
'stretch']) {
16697 if ($this->empty_string($xres)) {
16698 $xres = (0.141 * $this->k);
16700 if ($xres > $max_xres) {
16704 if ((isset($style[
'padding']) AND ($style[
'padding'] ===
'auto'))
16705 OR (isset($style[
'hpadding']) AND ($style[
'hpadding'] ===
'auto'))) {
16706 $hpadding = 10 * $xres;
16707 if (isset($style[
'vpadding']) AND ($style[
'vpadding'] ===
'auto')) {
16708 $vpadding = ($hpadding / 2);
16712 if ($style[
'fitwidth']) {
16714 $w = (($arrcode[
'maxw'] * $xres) + (2 * $hpadding));
16715 if (isset($style[
'cellfitalign'])) {
16716 switch ($style[
'cellfitalign']) {
16719 $x -= ($wold - $w);
16725 $x += ($wold - $w);
16731 $x -= (($wold - $w) / 2);
16733 $x += (($wold - $w) / 2);
16743 $text_height = ($this->cell_height_ratio * $fontsize / $this->k);
16745 if (($h ===
'') OR ($h <= 0)) {
16747 $h = (($arrcode[
'maxw'] * $xres) / 3) + (2 * $vpadding) + $text_height;
16749 $barh = $h - $text_height - (2 * $vpadding);
16752 if ($text_height > $h) {
16753 $fontsize = (($h * $this->k) / (4 * $this->cell_height_ratio));
16754 $text_height = ($this->cell_height_ratio * $fontsize / $this->k);
16755 $this->SetFont($style[
'font'],
'', $fontsize);
16757 if ($vpadding > 0) {
16758 $vpadding = (($h - $text_height) / 4);
16760 $barh = $h - $text_height - (2 * $vpadding);
16763 $this->fitBlock($w, $h,
$x,
$y,
false);
16765 $this->img_rb_y =
$y + $h;
16768 if ($style[
'position'] ==
'L') {
16769 $xpos = $this->lMargin;
16770 } elseif ($style[
'position'] ==
'C') {
16771 $xpos = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
16772 } elseif ($style[
'position'] ==
'R') {
16773 $xpos = $this->w - $this->rMargin - $w;
16777 $this->img_rb_x = $xpos;
16779 if ($style[
'position'] ==
'L') {
16780 $xpos = $this->lMargin;
16781 } elseif ($style[
'position'] ==
'C') {
16782 $xpos = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
16783 } elseif ($style[
'position'] ==
'R') {
16784 $xpos = $this->w - $this->rMargin - $w;
16788 $this->img_rb_x = $xpos + $w;
16790 $xpos_rect = $xpos;
16791 if (!isset($style[
'align'])) {
16792 $style[
'align'] =
'C';
16794 switch ($style[
'align']) {
16796 $xpos = $xpos_rect + $hpadding;
16800 $xpos = $xpos_rect + ($w - ($arrcode[
'maxw'] * $xres)) - $hpadding;
16805 $xpos = $xpos_rect + (($w - ($arrcode[
'maxw'] * $xres)) / 2);
16809 $xpos_text = $xpos;
16811 $tempRTL = $this->rtl;
16812 $this->rtl =
false;
16814 if ($style[
'bgcolor']) {
16815 $this->Rect($xpos_rect,
$y, $w, $h, $style[
'border'] ?
'DF' :
'F',
'', $style[
'bgcolor']);
16816 } elseif ($style[
'border']) {
16817 $this->Rect($xpos_rect,
$y, $w, $h,
'D');
16820 $this->SetDrawColorArray($style[
'fgcolor']);
16821 $this->SetTextColorArray($style[
'fgcolor']);
16823 foreach ($arrcode[
'bcode'] as $k => $v) {
16824 $bw = ($v[
'w'] * $xres);
16827 $ypos =
$y + $vpadding + ($v[
'p'] * $barh / $arrcode[
'maxh']);
16828 $this->Rect($xpos, $ypos, $bw, ($v[
'h'] * $barh / $arrcode[
'maxh']),
'F', array(), $style[
'fgcolor']);
16833 if ($style[
'text']) {
16834 if (isset($style[
'label']) AND !$this->empty_string($style[
'label'])) {
16835 $label = $style[
'label'];
16839 $txtwidth = ($arrcode[
'maxw'] * $xres);
16840 if ($this->GetStringWidth($label) > $txtwidth) {
16841 $style[
'stretchtext'] = 2;
16844 $this->x = $xpos_text;
16845 $this->y =
$y + $vpadding + $barh;
16846 $cellpadding = $this->cell_padding;
16847 $this->SetCellPadding(0);
16848 $this->Cell($txtwidth,
'', $label, 0, 0,
'C', 0,
'', $style[
'stretchtext'],
false,
'T',
'T');
16849 $this->cell_padding = $cellpadding;
16852 $this->rtl = $tempRTL;
16854 $this->setGraphicVars($gvars);
16859 $this->x = $this->img_rb_x;
16863 $this->y =
$y + round($h / 2);
16864 $this->x = $this->img_rb_x;
16868 $this->y = $this->img_rb_y;
16869 $this->x = $this->img_rb_x;
16873 $this->SetY($this->img_rb_y);
16880 $this->endlinex = $this->img_rb_x;
16904 'stretch' =>
false,
16905 'fitwidth' =>
false,
16906 'cellfitalign' =>
'',
16909 'fgcolor' => array(0,0,0),
16910 'bgcolor' =>
false,
16917 $newstyle[
'border'] =
true;
16920 $newstyle[
'bgcolor'] =
false;
16923 $newstyle[
'position'] =
'C';
16924 } elseif ($style & 8) {
16925 $newstyle[
'position'] =
'L';
16926 } elseif ($style & 16) {
16927 $newstyle[
'position'] =
'R';
16929 if ($style & 128) {
16930 $newstyle[
'text'] =
true;
16932 if ($style & 256) {
16933 $newstyle[
'stretchtext'] = 4;
16935 $this->write1DBarcode($code,
$type,
$x,
$y, $w, $h, $xres, $newstyle,
'');
16964 if ($this->empty_string(trim($code))) {
16967 require_once(dirname(__FILE__).
'/2dbarcodes.php');
16969 $gvars = $this->getGraphicVars();
16972 $arrcode = $barcodeobj->getBarcodeArray();
16973 if (($arrcode ===
false) OR empty($arrcode)) {
16974 $this->Error(
'Error in 2D barcode string');
16977 if (!isset($style[
'position'])) {
16978 $style[
'position'] =
'';
16980 if (!isset($style[
'fgcolor'])) {
16981 $style[
'fgcolor'] = array(0,0,0);
16983 if (!isset($style[
'bgcolor'])) {
16984 $style[
'bgcolor'] =
false;
16986 if (!isset($style[
'border'])) {
16987 $style[
'border'] =
false;
16990 if (!isset($style[
'padding'])) {
16991 $style[
'padding'] = 0;
16992 } elseif ($style[
'padding'] ===
'auto') {
16993 $style[
'padding'] = 4;
16995 if (!isset($style[
'hpadding'])) {
16996 $style[
'hpadding'] = $style[
'padding'];
16997 } elseif ($style[
'hpadding'] ===
'auto') {
16998 $style[
'hpadding'] = 4;
17000 if (!isset($style[
'vpadding'])) {
17001 $style[
'vpadding'] = $style[
'padding'];
17002 } elseif ($style[
'vpadding'] ===
'auto') {
17003 $style[
'vpadding'] = 4;
17006 if (!isset($style[
'module_width'])) {
17007 $style[
'module_width'] = 1;
17009 if (!isset($style[
'module_height'])) {
17010 $style[
'module_height'] = 1;
17019 $this->checkPageRegions($h,
$x,
$y);
17021 $rows = $arrcode[
'num_rows'];
17022 $cols = $arrcode[
'num_cols'];
17024 $mw = $style[
'module_width'];
17025 $mh = $style[
'module_height'];
17028 $maxw =
$x - $this->lMargin;
17030 $maxw = $this->w - $this->rMargin -
$x;
17032 $maxh = ($this->h - $this->tMargin - $this->bMargin);
17033 $ratioHW = ($rows * $mh) / ($cols * $mw);
17034 $ratioWH = ($cols * $mw) / ($rows * $mh);
17036 if (($maxw * $ratioHW) > $maxh) {
17037 $maxw = $maxh * $ratioWH;
17039 if (($maxh * $ratioWH) > $maxw) {
17040 $maxh = $maxw * $ratioHW;
17050 $hpad = (2 * $style[
'hpadding']);
17051 $vpad = (2 * $style[
'vpadding']);
17053 if ((($w ===
'') OR ($w <= 0)) AND (($h ===
'') OR ($h <= 0))) {
17054 $w = ($cols + $hpad) * ($mw / $this->k);
17055 $h = ($rows + $vpad) * ($mh / $this->k);
17056 } elseif (($w ===
'') OR ($w <= 0)) {
17057 $w = $h * $ratioWH;
17058 } elseif (($h ===
'') OR ($h <= 0)) {
17059 $h = $w * $ratioHW;
17062 $bw = ($w * $cols) / ($cols + $hpad);
17063 $bh = ($h * $rows) / ($rows + $vpad);
17068 if ((
$cw / $ch) > ($mw / $mh)) {
17070 $cw = $ch * $mw / $mh;
17072 $style[
'hpadding'] = ($w - $bw) / (2 *
$cw);
17075 $ch =
$cw * $mh / $mw;
17077 $style[
'vpadding'] = ($h - $bh) / (2 * $ch);
17081 $this->fitBlock($w, $h,
$x,
$y,
false);
17083 $this->img_rb_y =
$y + $h;
17086 if ($style[
'position'] ==
'L') {
17087 $xpos = $this->lMargin;
17088 } elseif ($style[
'position'] ==
'C') {
17089 $xpos = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
17090 } elseif ($style[
'position'] ==
'R') {
17091 $xpos = $this->w - $this->rMargin - $w;
17095 $this->img_rb_x = $xpos;
17097 if ($style[
'position'] ==
'L') {
17098 $xpos = $this->lMargin;
17099 } elseif ($style[
'position'] ==
'C') {
17100 $xpos = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
17101 } elseif ($style[
'position'] ==
'R') {
17102 $xpos = $this->w - $this->rMargin - $w;
17106 $this->img_rb_x = $xpos + $w;
17108 $xstart = $xpos + ($style[
'hpadding'] *
$cw);
17109 $ystart =
$y + ($style[
'vpadding'] * $ch);
17111 $tempRTL = $this->rtl;
17112 $this->rtl =
false;
17114 if ($style[
'bgcolor']) {
17115 $this->Rect($xpos,
$y, $w, $h, $style[
'border'] ?
'DF' :
'F',
'', $style[
'bgcolor']);
17116 } elseif ($style[
'border']) {
17117 $this->Rect($xpos,
$y, $w, $h,
'D');
17120 $this->SetDrawColorArray($style[
'fgcolor']);
17123 for ($r = 0; $r < $rows; ++$r) {
17126 for ($c = 0; $c < $cols; ++$c) {
17127 if ($arrcode[
'bcode'][$r][$c] == 1) {
17129 $this->Rect($xr, $ystart,
$cw, $ch,
'F', array(), $style[
'fgcolor']);
17136 $this->rtl = $tempRTL;
17138 $this->setGraphicVars($gvars);
17143 $this->x = $this->img_rb_x;
17147 $this->y =
$y + round($h/2);
17148 $this->x = $this->img_rb_x;
17152 $this->y = $this->img_rb_y;
17153 $this->x = $this->img_rb_x;
17157 $this->SetY($this->img_rb_y);
17164 $this->endlinex = $this->img_rb_x;
17188 'left' => $this->lMargin,
17189 'right' => $this->rMargin,
17190 'top' => $this->tMargin,
17191 'bottom' => $this->bMargin,
17192 'header' => $this->header_margin,
17193 'footer' => $this->footer_margin,
17194 'cell' => $this->cell_padding,
17195 'padding_left' => $this->cell_padding[
'L'],
17196 'padding_top' => $this->cell_padding[
'T'],
17197 'padding_right' => $this->cell_padding[
'R'],
17198 'padding_bottom' => $this->cell_padding[
'B']
17215 'left' => $this->original_lMargin,
17216 'right' => $this->original_rMargin
17228 return $this->FontSize;
17238 return $this->FontSizePt;
17248 return $this->FontFamily;
17258 return $this->FontStyle;
17270 if (empty($cssdata)) {
17274 $cssdata = preg_replace(
'/\/\*[^\*]*\*\//',
'', $cssdata);
17276 $cssdata = preg_replace(
'/[\s]+/',
' ', $cssdata);
17278 $cssdata = preg_replace(
'/[\s]*([;:\{\}]{1})[\s]*/',
'\\1', $cssdata);
17280 $cssdata = preg_replace(
'/([^\}\{]+)\{\}/',
'', $cssdata);
17282 $cssdata = preg_replace(
'/@media[\s]+([^\{]*)\{/i',
'@media \\1§', $cssdata);
17283 $cssdata = preg_replace(
'/\}\}/si',
'}§', $cssdata);
17285 $cssdata = trim($cssdata);
17287 $cssblocks = array();
17288 $matches = array();
17289 if (preg_match_all(
'/@media[\s]+([^\§]*)§([^§]*)§/i', $cssdata, $matches) > 0) {
17290 foreach ($matches[1] as $key =>
$type) {
17291 $cssblocks[
$type] = $matches[2][$key];
17294 $cssdata = preg_replace(
'/@media[\s]+([^\§]*)§([^§]*)§/i',
'', $cssdata);
17297 if (isset($cssblocks[
'all']) AND !empty($cssblocks[
'all'])) {
17298 $cssdata .= $cssblocks[
'all'];
17300 if (isset($cssblocks[
'print']) AND !empty($cssblocks[
'print'])) {
17301 $cssdata .= $cssblocks[
'print'];
17304 $cssblocks = array();
17305 $matches = array();
17307 if (substr($cssdata, -1) ==
'}') {
17309 $cssdata = substr($cssdata, 0, -1);
17311 $matches = explode(
'}', $cssdata);
17312 foreach ($matches as $key => $block) {
17314 $cssblocks[$key] = explode(
'{', $block);
17315 if (!isset($cssblocks[$key][1])) {
17317 unset($cssblocks[$key]);
17321 foreach ($cssblocks as $key => $block) {
17322 if (strpos($block[0],
',') > 0) {
17323 $selectors = explode(
',', $block[0]);
17324 foreach ($selectors as $sel) {
17325 $cssblocks[] = array(0 => trim($sel), 1 => $block[1]);
17327 unset($cssblocks[$key]);
17331 $cssdata = array();
17332 foreach ($cssblocks as $block) {
17333 $selector = $block[0];
17335 $matches = array();
17337 $b = intval(preg_match_all(
'/[\#]/', $selector, $matches));
17338 $c = intval(preg_match_all(
'/[\[\.]/', $selector, $matches));
17339 $c += intval(preg_match_all(
'/[\:]link|visited|hover|active|focus|target|lang|enabled|disabled|checked|indeterminate|root|nth|first|last|only|empty|contains|not/i', $selector, $matches));
17340 $d = intval(preg_match_all(
'/[>\+\~\s]{1}[a-zA-Z0-9\*]+/',
' '.$selector, $matches));
17341 $d += intval(preg_match_all(
'/[\:][\:]/', $selector, $matches));
17342 $specificity = $a.$b.$c.$d;
17344 $cssdata[$specificity.
' '.$selector] = $block[1];
17347 ksort($cssdata, SORT_STRING);
17363 $tag = $dom[$key][
'value'];
17365 if (isset($dom[$key][
'attribute'][
'class']) AND !empty($dom[$key][
'attribute'][
'class'])) {
17366 $class = explode(
' ', strtolower($dom[$key][
'attribute'][
'class']));
17369 if (isset($dom[$key][
'attribute'][
'id']) AND !empty($dom[$key][
'attribute'][
'id'])) {
17370 $id = strtolower($dom[$key][
'attribute'][
'id']);
17372 $selector = preg_replace(
'/([>\+\~\s]{1})([\.]{1})([^>\+\~\s]*)/si',
'\\1*.\\3', $selector);
17373 $matches = array();
17374 if (preg_match_all(
'/([>\+\~\s]{1})([a-zA-Z0-9\*]+)([^>\+\~\s]*)/si', $selector, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) > 0) {
17375 $parentop = array_pop($matches[1]);
17376 $operator = $parentop[0];
17377 $offset = $parentop[1];
17378 $lasttag = array_pop($matches[2]);
17379 $lasttag = strtolower(trim($lasttag[0]));
17380 if (($lasttag ==
'*') OR ($lasttag == $tag)) {
17382 $attrib = array_pop($matches[3]);
17388 if (in_array(substr(
$attrib, 1), $class)) {
17394 if (substr(
$attrib, 1) == $id) {
17400 $attrmatch = array();
17401 if (preg_match(
'/\[([a-zA-Z0-9]*)[\s]*([\~\^\$\*\|\=]*)[\s]*["]?([^"\]]*)["]?\]/i',
$attrib, $attrmatch) > 0) {
17402 $att = strtolower($attrmatch[1]);
17403 $val = $attrmatch[3];
17404 if (isset($dom[$key][
'attribute'][$att])) {
17405 switch ($attrmatch[2]) {
17407 if ($dom[$key][
'attribute'][$att] == $val) {
17413 if (in_array($val, explode(
' ', $dom[$key][
'attribute'][$att]))) {
17419 if ($val == substr($dom[$key][
'attribute'][$att], 0, strlen($val))) {
17425 if ($val == substr($dom[$key][
'attribute'][$att], -strlen($val))) {
17431 if (strpos($dom[$key][
'attribute'][$att], $val) !==
false) {
17437 if ($dom[$key][
'attribute'][$att] == $val) {
17439 } elseif (preg_match(
'/'.$val.
'[\-]{1}/i', $dom[$key][
'attribute'][$att]) > 0) {
17466 if (
$valid AND ($offset > 0)) {
17469 $selector = substr($selector, 0, $offset);
17470 switch ($operator) {
17472 while ($dom[$key][
'parent'] > 0) {
17473 if ($this->isValidCSSSelectorForTag($dom, $dom[$key][
'parent'], $selector)) {
17477 $key = $dom[$key][
'parent'];
17483 $valid = $this->isValidCSSSelectorForTag($dom, $dom[$key][
'parent'], $selector);
17487 for ($i = ($key - 1); $i > $dom[$key][
'parent']; --$i) {
17488 if ($dom[$i][
'tag'] AND $dom[$i][
'opening']) {
17489 $valid = $this->isValidCSSSelectorForTag($dom, $i, $selector);
17496 for ($i = ($key - 1); $i > $dom[$key][
'parent']; --$i) {
17497 if ($dom[$i][
'tag'] AND $dom[$i][
'opening']) {
17498 if ($this->isValidCSSSelectorForTag($dom, $i, $selector)) {
17524 foreach($css as $selector => $style) {
17526 $selector = substr($selector, strpos($selector,
' '));
17528 if ($this->isValidCSSSelectorForTag($dom, $key, $selector)) {
17530 $tagstyle .=
';'.$style;
17533 if (isset($dom[$key][
'attribute'][
'style'])) {
17535 $tagstyle .=
';'.$dom[$key][
'attribute'][
'style'];
17538 $tagstyle = preg_replace(
'/[;]+/',
';', $tagstyle);
17550 if ($width ==
'thin') {
17551 $width = (2 / $this->k);
17552 } elseif ($width ==
'medium') {
17553 $width = (4 / $this->k);
17554 } elseif ($width ==
'thick') {
17555 $width = (6 / $this->k);
17557 $width = $this->getHTMLUnitToUnits($width, 1,
'px',
false);
17570 switch (strtolower($style)) {
17606 $bprop = preg_split(
'/[\s]+/', trim($cssborder));
17608 switch (count($bprop)) {
17610 $width = $bprop[0];
17611 $style = $bprop[1];
17612 $color = $bprop[2];
17617 $style = $bprop[0];
17618 $color = $bprop[1];
17623 $style = $bprop[0];
17634 if ($style ==
'none') {
17637 $border[
'cap'] =
'square';
17638 $border[
'join'] =
'miter';
17639 $border[
'dash'] = $this->getCSSBorderDashStyle($style);
17640 if ($border[
'dash'] < 0) {
17643 $border[
'width'] = $this->getCSSBorderWidth($width);
17644 $border[
'color'] = $this->convertHTMLColorToDec($color);
17656 $padding = preg_split(
'/[\s]+/', trim($csspadding));
17657 $cell_padding = array();
17658 switch (count($padding)) {
17660 $cell_padding[
'T'] = $padding[0];
17661 $cell_padding[
'R'] = $padding[1];
17662 $cell_padding[
'B'] = $padding[2];
17663 $cell_padding[
'L'] = $padding[3];
17667 $cell_padding[
'T'] = $padding[0];
17668 $cell_padding[
'R'] = $padding[1];
17669 $cell_padding[
'B'] = $padding[2];
17670 $cell_padding[
'L'] = $padding[1];
17674 $cell_padding[
'T'] = $padding[0];
17675 $cell_padding[
'R'] = $padding[1];
17676 $cell_padding[
'B'] = $padding[0];
17677 $cell_padding[
'L'] = $padding[1];
17681 $cell_padding[
'T'] = $padding[0];
17682 $cell_padding[
'R'] = $padding[0];
17683 $cell_padding[
'B'] = $padding[0];
17684 $cell_padding[
'L'] = $padding[0];
17688 return $this->cell_padding;
17692 $width = $this->w - $this->lMargin - $this->rMargin;
17694 $cell_padding[
'T'] = $this->getHTMLUnitToUnits($cell_padding[
'T'], $width,
'px',
false);
17695 $cell_padding[
'R'] = $this->getHTMLUnitToUnits($cell_padding[
'R'], $width,
'px',
false);
17696 $cell_padding[
'B'] = $this->getHTMLUnitToUnits($cell_padding[
'B'], $width,
'px',
false);
17697 $cell_padding[
'L'] = $this->getHTMLUnitToUnits($cell_padding[
'L'], $width,
'px',
false);
17698 return $cell_padding;
17709 $margin = preg_split(
'/[\s]+/', trim($cssmargin));
17710 $cell_margin = array();
17711 switch (count($margin)) {
17713 $cell_margin[
'T'] = $margin[0];
17714 $cell_margin[
'R'] = $margin[1];
17715 $cell_margin[
'B'] = $margin[2];
17716 $cell_margin[
'L'] = $margin[3];
17720 $cell_margin[
'T'] = $margin[0];
17721 $cell_margin[
'R'] = $margin[1];
17722 $cell_margin[
'B'] = $margin[2];
17723 $cell_margin[
'L'] = $margin[1];
17727 $cell_margin[
'T'] = $margin[0];
17728 $cell_margin[
'R'] = $margin[1];
17729 $cell_margin[
'B'] = $margin[0];
17730 $cell_margin[
'L'] = $margin[1];
17734 $cell_margin[
'T'] = $margin[0];
17735 $cell_margin[
'R'] = $margin[0];
17736 $cell_margin[
'B'] = $margin[0];
17737 $cell_margin[
'L'] = $margin[0];
17741 return $this->cell_margin;
17745 $width = $this->w - $this->lMargin - $this->rMargin;
17747 $cell_margin[
'T'] = $this->getHTMLUnitToUnits(str_replace(
'auto',
'0', $cell_margin[
'T']), $width,
'px',
false);
17748 $cell_margin[
'R'] = $this->getHTMLUnitToUnits(str_replace(
'auto',
'0', $cell_margin[
'R']), $width,
'px',
false);
17749 $cell_margin[
'B'] = $this->getHTMLUnitToUnits(str_replace(
'auto',
'0', $cell_margin[
'B']), $width,
'px',
false);
17750 $cell_margin[
'L'] = $this->getHTMLUnitToUnits(str_replace(
'auto',
'0', $cell_margin[
'L']), $width,
'px',
false);
17751 return $cell_margin;
17764 $spacing = trim($spacing);
17765 switch ($spacing) {
17771 if ($parent ==
'normal') {
17779 $val = $this->getHTMLUnitToUnits($spacing, 0,
'px',
false);
17795 $stretch = trim($stretch);
17796 switch ($stretch) {
17797 case 'ultra-condensed': {
17801 case 'extra-condensed': {
17805 case 'condensed': {
17809 case 'semi-condensed': {
17817 case 'semi-expanded': {
17825 case 'extra-expanded': {
17829 case 'ultra-expanded': {
17834 $val = $parent + 10;
17838 $val = $parent - 10;
17842 if ($parent ==
'normal') {
17850 $val = $this->getHTMLUnitToUnits($stretch, 100,
'%',
false);
17867 $matches = array();
17868 if (preg_match_all(
'/<cssarray>([^<]*)<\/cssarray>/isU', $html, $matches) > 0) {
17869 if (isset($matches[1][0])) {
17870 $css = array_merge($css, unserialize($this->unhtmlentities($matches[1][0])));
17872 $html = preg_replace(
'/<cssarray>(.*?)<\/cssarray>/isU',
'', $html);
17875 $matches = array();
17876 if (preg_match_all(
'/<link([^>]*)>/isU', $html, $matches) > 0) {
17877 foreach ($matches[1] as $key => $link) {
17879 if (preg_match(
'/type[\s]*=[\s]*"text\/css"/', $link,
$type)) {
17881 preg_match(
'/media[\s]*=[\s]*"([^"]*)"/', $link,
$type);
17886 if (preg_match(
'/href[\s]*=[\s]*"([^"]*)"/', $link,
$type) > 0) {
17888 $cssdata = file_get_contents(trim(
$type[1]));
17889 $css = array_merge($css, $this->extractCSSproperties($cssdata));
17896 $matches = array();
17897 if (preg_match_all(
'/<style([^>]*)>([^<]*)<\/style>/isU', $html, $matches) > 0) {
17898 foreach ($matches[1] as $key => $media) {
17900 preg_match(
'/media[\s]*=[\s]*"([^"]*)"/', $media,
$type);
17904 $cssdata = $matches[2][$key];
17905 $css = array_merge($css, $this->extractCSSproperties($cssdata));
17910 $csstagarray =
'<cssarray>'.htmlentities(serialize($css)).
'</cssarray>';
17912 $html = preg_replace(
'/<head([^>]*)>(.*?)<\/head>/siU',
'', $html);
17913 $html = preg_replace(
'/<style([^>]*)>([^<]*)<\/style>/isU',
'', $html);
17915 $blocktags = array(
'blockquote',
'br',
'dd',
'dl',
'div',
'dt',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'hr',
'li',
'ol',
'p',
'pre',
'ul',
'tcpdf',
'table',
'tr',
'td');
17917 $selfclosingtags = array(
'area',
'base',
'basefont',
'br',
'hr',
'input',
'img',
'link',
'meta');
17919 $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>');
17921 $html = preg_replace(
'/<pre/',
'<xre', $html);
17922 $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);
17923 $html = preg_replace(
'@(\r\n|\r)@',
"\n", $html);
17924 $repTable = array(
"\t" =>
' ',
"\0" =>
' ',
"\x0B" =>
' ',
"\\" =>
"\\\\");
17925 $html = strtr($html, $repTable);
17927 while (($offset < strlen($html)) AND (
$pos = strpos($html,
'</pre>', $offset)) !==
false) {
17928 $html_a = substr($html, 0, $offset);
17929 $html_b = substr($html, $offset, (
$pos - $offset + 6));
17930 while (preg_match(
"'<xre([^>]*)>(.*?)\n(.*?)</pre>'si", $html_b)) {
17932 $html_b = preg_replace(
"'<xre([^>]*)>(.*?)\n(.*?)</pre>'si",
"<xre\\1>\\2<br />\\3</pre>", $html_b);
17934 while (preg_match(
"'<xre([^>]*)>(.*?)".$this->re_space[
'p'].
"(.*?)</pre>'".$this->re_space[
'm'], $html_b)) {
17936 $html_b = preg_replace(
"'<xre([^>]*)>(.*?)".$this->re_space[
'p'].
"(.*?)</pre>'".$this->re_space[
'm'],
"<xre\\1>\\2 \\3</pre>", $html_b);
17938 $html = $html_a.$html_b.substr($html,
$pos + 6);
17939 $offset = strlen($html_a.$html_b);
17942 while (($offset < strlen($html)) AND (
$pos = strpos($html,
'</textarea>', $offset)) !==
false) {
17943 $html_a = substr($html, 0, $offset);
17944 $html_b = substr($html, $offset, (
$pos - $offset + 11));
17945 while (preg_match(
"'<textarea([^>]*)>(.*?)\n(.*?)</textarea>'si", $html_b)) {
17947 $html_b = preg_replace(
"'<textarea([^>]*)>(.*?)\n(.*?)</textarea>'si",
"<textarea\\1>\\2<TBR>\\3</textarea>", $html_b);
17948 $html_b = preg_replace(
"'<textarea([^>]*)>(.*?)[\"](.*?)</textarea>'si",
"<textarea\\1>\\2''\\3</textarea>", $html_b);
17950 $html = $html_a.$html_b.substr($html,
$pos + 11);
17951 $offset = strlen($html_a.$html_b);
17953 $html = preg_replace(
'/([\s]*)<option/si',
'<option', $html);
17954 $html = preg_replace(
'/<\/option>([\s]*)/si',
'</option>', $html);
17956 while (($offset < strlen($html)) AND (
$pos = strpos($html,
'</option>', $offset)) !==
false) {
17957 $html_a = substr($html, 0, $offset);
17958 $html_b = substr($html, $offset, (
$pos - $offset + 9));
17959 while (preg_match(
"'<option([^>]*)>(.*?)</option>'si", $html_b)) {
17960 $html_b = preg_replace(
"'<option([\s]+)value=\"([^\"]*)\"([^>]*)>(.*?)</option>'si",
"\\2#!TaB!#\\4#!NwL!#", $html_b);
17961 $html_b = preg_replace(
"'<option([^>]*)>(.*?)</option>'si",
"\\2#!NwL!#", $html_b);
17963 $html = $html_a.$html_b.substr($html,
$pos + 9);
17964 $offset = strlen($html_a.$html_b);
17966 if (preg_match(
"'</select'si", $html)) {
17967 $html = preg_replace(
"'<select([^>]*)>'si",
"<select\\1 opt=\"", $html);
17968 $html = preg_replace(
"'#!NwL!#</select>'si",
"\" />", $html);
17970 $html = str_replace(
"\n",
' ', $html);
17972 $html = str_replace(
'<TBR>',
"\n", $html);
17974 $html = preg_replace(
'/[\s]+<\/(table|tr|ul|ol|dl)>/',
'</\\1>', $html);
17975 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<\/(td|th|li|dt|dd)>/'.$this->re_space[
'm'],
'</\\1>', $html);
17976 $html = preg_replace(
'/[\s]+<(tr|td|th|li|dt|dd)/',
'<\\1', $html);
17977 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<(ul|ol|dl|br)/'.$this->re_space[
'm'],
'<\\1', $html);
17978 $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);
17979 $html = preg_replace(
'/<\/(td|th)>/',
'<marker style="font-size:0"/></\\1>', $html);
17980 $html = preg_replace(
'/<\/table>([\s]*)<marker style="font-size:0"\/>/',
'</table>', $html);
17981 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+<img/'.$this->re_space[
'm'], chr(32).
'<img', $html);
17982 $html = preg_replace(
'/<img([^>]*)>/xi',
'<img\\1><span><marker style="font-size:0"/></span>', $html);
17983 $html = preg_replace(
'/<xre/',
'<pre', $html);
17984 $html = preg_replace(
'/<textarea([^>]*)>([^<]*)<\/textarea>/xi',
'<textarea\\1 value="\\2" />', $html);
17985 $html = preg_replace(
'/<li([^>]*)><\/li>/',
'<li\\1> </li>', $html);
17986 $html = preg_replace(
'/<li([^>]*)>'.$this->re_space[
'p'].
'*<img/'.$this->re_space[
'm'],
'<li\\1><font size="1"> </font><img', $html);
17987 $html = preg_replace(
'/<([^>\/]*)>[\s]/',
'<\\1> ', $html);
17988 $html = preg_replace(
'/[\s]<\/([^>]*)>/',
' </\\1>', $html);
17989 $html = preg_replace(
'/'.$this->re_space[
'p'].
'+/'.$this->re_space[
'm'], chr(32), $html);
17991 $html = $this->stringTrim($html);
17993 $tagpattern =
'/(<[^>]+>)/';
17995 $a = preg_split($tagpattern, $html, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
17997 $maxel = count($a);
18002 $dom[$key] = array();
18005 $dom[$key][
'tag'] =
false;
18006 $dom[$key][
'block'] =
false;
18007 $dom[$key][
'value'] =
'';
18008 $dom[$key][
'parent'] = 0;
18009 $dom[$key][
'fontname'] = $this->FontFamily;
18010 $dom[$key][
'fontstyle'] = $this->FontStyle;
18011 $dom[$key][
'fontsize'] = $this->FontSizePt;
18012 $dom[$key][
'font-stretch'] = 100;
18013 $dom[$key][
'letter-spacing'] = 0;
18014 $dom[$key][
'stroke'] = $this->textstrokewidth;
18015 $dom[$key][
'fill'] = (($this->textrendermode % 2) == 0);
18016 $dom[$key][
'clip'] = ($this->textrendermode > 3);
18017 $dom[$key][
'line-height'] = $this->cell_height_ratio;
18018 $dom[$key][
'bgcolor'] =
false;
18019 $dom[$key][
'fgcolor'] = $this->fgcolor;
18020 $dom[$key][
'strokecolor'] = $this->strokecolor;
18021 $dom[$key][
'align'] =
'';
18022 $dom[$key][
'listtype'] =
'';
18023 $dom[$key][
'text-indent'] = 0;
18024 $dom[$key][
'border'] = array();
18025 $dom[$key][
'dir'] = $this->rtl?
'rtl':
'ltr';
18029 array_push($level, 0);
18030 while ($elkey < $maxel) {
18031 $dom[$key] = array();
18032 $element = $a[$elkey];
18033 $dom[$key][
'elkey'] = $elkey;
18034 if (preg_match($tagpattern, $element)) {
18036 $element = substr($element, 1, -1);
18038 preg_match(
'/[\/]?([a-zA-Z0-9]*)/', $element, $tag);
18039 $tagname = strtolower($tag[1]);
18041 if ($tagname ==
'thead') {
18042 if ($element{0} ==
'/') {
18050 $dom[$key][
'tag'] =
true;
18051 $dom[$key][
'value'] = $tagname;
18052 if (in_array($dom[$key][
'value'], $blocktags)) {
18053 $dom[$key][
'block'] =
true;
18055 $dom[$key][
'block'] =
false;
18057 if ($element{0} ==
'/') {
18059 $dom[$key][
'opening'] =
false;
18060 $dom[$key][
'parent'] = end($level);
18062 $dom[$key][
'fontname'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontname'];
18063 $dom[$key][
'fontstyle'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontstyle'];
18064 $dom[$key][
'fontsize'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fontsize'];
18065 $dom[$key][
'font-stretch'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'font-stretch'];
18066 $dom[$key][
'letter-spacing'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'letter-spacing'];
18067 $dom[$key][
'stroke'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'stroke'];
18068 $dom[$key][
'fill'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fill'];
18069 $dom[$key][
'clip'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'clip'];
18070 $dom[$key][
'line-height'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'line-height'];
18071 $dom[$key][
'bgcolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'bgcolor'];
18072 $dom[$key][
'fgcolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'fgcolor'];
18073 $dom[$key][
'strokecolor'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'strokecolor'];
18074 $dom[$key][
'align'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'align'];
18075 $dom[$key][
'dir'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'dir'];
18076 if (isset($dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'listtype'])) {
18077 $dom[$key][
'listtype'] = $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'listtype'];
18080 if (($dom[$key][
'value'] ==
'tr') AND (!isset($dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'cols']))) {
18081 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'cols'] = $dom[($dom[$key][
'parent'])][
'cols'];
18083 if (($dom[$key][
'value'] ==
'td') OR ($dom[$key][
'value'] ==
'th')) {
18084 $dom[($dom[$key][
'parent'])][
'content'] = $csstagarray;
18085 for ($i = ($dom[$key][
'parent'] + 1); $i < $key; ++$i) {
18086 $dom[($dom[$key][
'parent'])][
'content'] .= $a[$dom[$i][
'elkey']];
18089 $parent_table = $dom[$dom[$dom[($dom[$key][
'parent'])][
'parent']][
'parent']];
18090 $parent_padding = 0;
18091 $parent_spacing = 0;
18092 if (isset($parent_table[
'attribute'][
'cellpadding'])) {
18093 $parent_padding = $this->getHTMLUnitToUnits($parent_table[
'attribute'][
'cellpadding'], 1,
'px');
18095 if (isset($parent_table[
'attribute'][
'cellspacing'])) {
18096 $parent_spacing = $this->getHTMLUnitToUnits($parent_table[
'attribute'][
'cellspacing'], 1,
'px');
18099 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'<table',
'<table nested="true" pcellpadding="'.$parent_padding.
'" pcellspacing="'.$parent_spacing.
'"', $dom[($dom[$key][
'parent'])][
'content']);
18101 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'<thead>',
'', $dom[($dom[$key][
'parent'])][
'content']);
18102 $dom[($dom[$key][
'parent'])][
'content'] = str_replace(
'</thead>',
'', $dom[($dom[$key][
'parent'])][
'content']);
18105 if (($dom[$key][
'value'] ==
'tr') AND ($dom[($dom[$key][
'parent'])][
'thead'] ===
true)) {
18106 if ($this->empty_string($dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'thead'])) {
18107 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'thead'] = $a[$dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'elkey']];
18109 for ($i = $dom[$key][
'parent']; $i <= $key; ++$i) {
18110 $dom[($dom[($dom[$key][
'parent'])][
'parent'])][
'thead'] .= $a[$dom[$i][
'elkey']];
18112 if (!isset($dom[($dom[$key][
'parent'])][
'attribute'])) {
18113 $dom[($dom[$key][
'parent'])][
'attribute'] = array();
18116 $dom[($dom[$key][
'parent'])][
'attribute'][
'nobr'] =
'true';
18118 if (($dom[$key][
'value'] ==
'table') AND (!$this->empty_string($dom[($dom[$key][
'parent'])][
'thead']))) {
18120 $dom[($dom[$key][
'parent'])][
'thead'] = str_replace(
' nobr="true"',
'', $dom[($dom[$key][
'parent'])][
'thead']);
18121 $dom[($dom[$key][
'parent'])][
'thead'] .=
'</tablehead>';
18125 $dom[$key][
'opening'] =
true;
18126 $dom[$key][
'parent'] = end($level);
18127 if ((substr($element, -1, 1) ==
'/') OR (in_array($dom[$key][
'value'], $selfclosingtags))) {
18129 $dom[$key][
'self'] =
true;
18132 array_push($level, $key);
18133 $dom[$key][
'self'] =
false;
18138 $parentkey = $dom[$key][
'parent'];
18139 $dom[$key][
'fontname'] = $dom[$parentkey][
'fontname'];
18140 $dom[$key][
'fontstyle'] = $dom[$parentkey][
'fontstyle'];
18141 $dom[$key][
'fontsize'] = $dom[$parentkey][
'fontsize'];
18142 $dom[$key][
'font-stretch'] = $dom[$parentkey][
'font-stretch'];
18143 $dom[$key][
'letter-spacing'] = $dom[$parentkey][
'letter-spacing'];
18144 $dom[$key][
'stroke'] = $dom[$parentkey][
'stroke'];
18145 $dom[$key][
'fill'] = $dom[$parentkey][
'fill'];
18146 $dom[$key][
'clip'] = $dom[$parentkey][
'clip'];
18147 $dom[$key][
'line-height'] = $dom[$parentkey][
'line-height'];
18148 $dom[$key][
'bgcolor'] = $dom[$parentkey][
'bgcolor'];
18149 $dom[$key][
'fgcolor'] = $dom[$parentkey][
'fgcolor'];
18150 $dom[$key][
'strokecolor'] = $dom[$parentkey][
'strokecolor'];
18151 $dom[$key][
'align'] = $dom[$parentkey][
'align'];
18152 $dom[$key][
'listtype'] = $dom[$parentkey][
'listtype'];
18153 $dom[$key][
'text-indent'] = $dom[$parentkey][
'text-indent'];
18154 $dom[$key][
'border'] = array();
18155 $dom[$key][
'dir'] = $dom[$parentkey][
'dir'];
18158 preg_match_all(
'/([^=\s]*)[\s]*=[\s]*"([^"]*)"/', $element, $attr_array, PREG_PATTERN_ORDER);
18159 $dom[$key][
'attribute'] = array();
18160 while (list($id,
$name) = each($attr_array[1])) {
18161 $dom[$key][
'attribute'][strtolower(
$name)] = $attr_array[2][$id];
18163 if (!empty($css)) {
18165 $dom[$key][
'attribute'][
'style'] = $this->getTagStyleFromCSS($dom, $key, $css);
18168 if (isset($dom[$key][
'attribute'][
'style']) AND !empty($dom[$key][
'attribute'][
'style'])) {
18170 preg_match_all(
'/([^;:\s]*):([^;]*)/', $dom[$key][
'attribute'][
'style'], $style_array, PREG_PATTERN_ORDER);
18171 $dom[$key][
'style'] = array();
18172 while (list($id,
$name) = each($style_array[1])) {
18174 $dom[$key][
'style'][strtolower(
$name)] = trim($style_array[2][$id]);
18178 if (isset($dom[$key][
'style'][
'direction'])) {
18179 $dom[$key][
'dir'] = $dom[$key][
'style'][
'direction'];
18182 if (isset($dom[$key][
'style'][
'font-family'])) {
18183 $dom[$key][
'fontname'] = $this->getFontFamilyName($dom[$key][
'style'][
'font-family']);
18186 if (isset($dom[$key][
'style'][
'list-style-type'])) {
18187 $dom[$key][
'listtype'] = trim(strtolower($dom[$key][
'style'][
'list-style-type']));
18188 if ($dom[$key][
'listtype'] ==
'inherit') {
18189 $dom[$key][
'listtype'] = $dom[$parentkey][
'listtype'];
18193 if (isset($dom[$key][
'style'][
'text-indent'])) {
18194 $dom[$key][
'text-indent'] = $this->getHTMLUnitToUnits($dom[$key][
'style'][
'text-indent']);
18195 if ($dom[$key][
'text-indent'] ==
'inherit') {
18196 $dom[$key][
'text-indent'] = $dom[$parentkey][
'text-indent'];
18200 if (isset($dom[$key][
'style'][
'font-size'])) {
18201 $fsize = trim($dom[$key][
'style'][
'font-size']);
18205 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'] - 4;
18209 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'] - 3;
18213 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'] - 2;
18217 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'];
18221 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'] + 2;
18225 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'] + 4;
18229 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'] + 6;
18234 $dom[$key][
'fontsize'] = $dom[$parentkey][
'fontsize'] - 3;
18238 $dom[$key][
'fontsize'] = $dom[$parentkey][
'fontsize'] + 3;
18242 $dom[$key][
'fontsize'] = $this->getHTMLUnitToUnits($fsize, $dom[$parentkey][
'fontsize'],
'pt',
true);
18247 if (isset($dom[$key][
'style'][
'font-stretch'])) {
18248 $dom[$key][
'font-stretch'] = $this->getCSSFontStretching($dom[$key][
'style'][
'font-stretch'], $dom[$parentkey][
'font-stretch']);
18251 if (isset($dom[$key][
'style'][
'letter-spacing'])) {
18252 $dom[$key][
'letter-spacing'] = $this->getCSSFontSpacing($dom[$key][
'style'][
'letter-spacing'], $dom[$parentkey][
'letter-spacing']);
18255 if (isset($dom[$key][
'style'][
'line-height'])) {
18256 $lineheight = trim($dom[$key][
'style'][
'line-height']);
18257 switch ($lineheight) {
18260 $dom[$key][
'line-height'] = $dom[0][
'line-height'];
18264 if (is_numeric($lineheight)) {
18265 $lineheight = $lineheight * 100;
18267 $dom[$key][
'line-height'] = $this->getHTMLUnitToUnits($lineheight, 1,
'%',
true);
18272 if (isset($dom[$key][
'style'][
'font-weight']) AND (strtolower($dom[$key][
'style'][
'font-weight']{0}) ==
'b')) {
18273 $dom[$key][
'fontstyle'] .=
'B';
18275 if (isset($dom[$key][
'style'][
'font-style']) AND (strtolower($dom[$key][
'style'][
'font-style']{0}) ==
'i')) {
18276 $dom[$key][
'fontstyle'] .=
'I';
18279 if (isset($dom[$key][
'style'][
'color']) AND (!$this->empty_string($dom[$key][
'style'][
'color']))) {
18280 $dom[$key][
'fgcolor'] = $this->convertHTMLColorToDec($dom[$key][
'style'][
'color']);
18281 } elseif ($dom[$key][
'value'] ==
'a') {
18282 $dom[$key][
'fgcolor'] = $this->htmlLinkColorArray;
18285 if (isset($dom[$key][
'style'][
'background-color']) AND (!$this->empty_string($dom[$key][
'style'][
'background-color']))) {
18286 $dom[$key][
'bgcolor'] = $this->convertHTMLColorToDec($dom[$key][
'style'][
'background-color']);
18289 if (isset($dom[$key][
'style'][
'text-decoration'])) {
18290 $decors = explode(
' ', strtolower($dom[$key][
'style'][
'text-decoration']));
18291 foreach ($decors as $dec) {
18293 if (!$this->empty_string($dec)) {
18294 if ($dec{0} ==
'u') {
18296 $dom[$key][
'fontstyle'] .=
'U';
18297 } elseif ($dec{0} ==
'l') {
18299 $dom[$key][
'fontstyle'] .=
'D';
18300 } elseif ($dec{0} ==
'o') {
18302 $dom[$key][
'fontstyle'] .=
'O';
18306 } elseif ($dom[$key][
'value'] ==
'a') {
18307 $dom[$key][
'fontstyle'] = $this->htmlLinkFontStyle;
18310 if (isset($dom[$key][
'style'][
'width'])) {
18311 $dom[$key][
'width'] = $dom[$key][
'style'][
'width'];
18314 if (isset($dom[$key][
'style'][
'height'])) {
18315 $dom[$key][
'height'] = $dom[$key][
'style'][
'height'];
18318 if (isset($dom[$key][
'style'][
'text-align'])) {
18319 $dom[$key][
'align'] = strtoupper($dom[$key][
'style'][
'text-align']{0});
18322 if (isset($dom[$key][
'style'][
'border'])) {
18323 $borderstyle = $this->getCSSBorderStyle($dom[$key][
'style'][
'border']);
18324 if (!empty($borderstyle)) {
18325 $dom[$key][
'border'][
'LTRB'] = $borderstyle;
18328 if (isset($dom[$key][
'style'][
'border-color'])) {
18329 $brd_colors = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-color']));
18330 if (isset($brd_colors[3])) {
18331 $dom[$key][
'border'][
'L'][
'color'] = $this->convertHTMLColorToDec($brd_colors[3]);
18333 if (isset($brd_colors[1])) {
18334 $dom[$key][
'border'][
'R'][
'color'] = $this->convertHTMLColorToDec($brd_colors[1]);
18336 if (isset($brd_colors[0])) {
18337 $dom[$key][
'border'][
'T'][
'color'] = $this->convertHTMLColorToDec($brd_colors[0]);
18339 if (isset($brd_colors[2])) {
18340 $dom[$key][
'border'][
'B'][
'color'] = $this->convertHTMLColorToDec($brd_colors[2]);
18343 if (isset($dom[$key][
'style'][
'border-width'])) {
18344 $brd_widths = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-width']));
18345 if (isset($brd_widths[3])) {
18346 $dom[$key][
'border'][
'L'][
'width'] = $this->getCSSBorderWidth($brd_widths[3]);
18348 if (isset($brd_widths[1])) {
18349 $dom[$key][
'border'][
'R'][
'width'] = $this->getCSSBorderWidth($brd_widths[1]);
18351 if (isset($brd_widths[0])) {
18352 $dom[$key][
'border'][
'T'][
'width'] = $this->getCSSBorderWidth($brd_widths[0]);
18354 if (isset($brd_widths[2])) {
18355 $dom[$key][
'border'][
'B'][
'width'] = $this->getCSSBorderWidth($brd_widths[2]);
18358 if (isset($dom[$key][
'style'][
'border-style'])) {
18359 $brd_styles = preg_split(
'/[\s]+/', trim($dom[$key][
'style'][
'border-style']));
18360 if (isset($brd_styles[3])) {
18361 $dom[$key][
'border'][
'L'][
'cap'] =
'square';
18362 $dom[$key][
'border'][
'L'][
'join'] =
'miter';
18363 $dom[$key][
'border'][
'L'][
'dash'] = $this->getCSSBorderDashStyle($brd_styles[3]);
18364 if ($dom[$key][
'border'][
'L'][
'dash'] < 0) {
18365 $dom[$key][
'border'][
'L'] = array();
18368 if (isset($brd_styles[1])) {
18369 $dom[$key][
'border'][
'R'][
'cap'] =
'square';
18370 $dom[$key][
'border'][
'R'][
'join'] =
'miter';
18371 $dom[$key][
'border'][
'R'][
'dash'] = $this->getCSSBorderDashStyle($brd_styles[1]);
18372 if ($dom[$key][
'border'][
'R'][
'dash'] < 0) {
18373 $dom[$key][
'border'][
'R'] = array();
18376 if (isset($brd_styles[0])) {
18377 $dom[$key][
'border'][
'T'][
'cap'] =
'square';
18378 $dom[$key][
'border'][
'T'][
'join'] =
'miter';
18379 $dom[$key][
'border'][
'T'][
'dash'] = $this->getCSSBorderDashStyle($brd_styles[0]);
18380 if ($dom[$key][
'border'][
'T'][
'dash'] < 0) {
18381 $dom[$key][
'border'][
'T'] = array();
18384 if (isset($brd_styles[2])) {
18385 $dom[$key][
'border'][
'B'][
'cap'] =
'square';
18386 $dom[$key][
'border'][
'B'][
'join'] =
'miter';
18387 $dom[$key][
'border'][
'B'][
'dash'] = $this->getCSSBorderDashStyle($brd_styles[2]);
18388 if ($dom[$key][
'border'][
'B'][
'dash'] < 0) {
18389 $dom[$key][
'border'][
'B'] = array();
18393 $cellside = array(
'L' =>
'left',
'R' =>
'right',
'T' =>
'top',
'B' =>
'bottom');
18394 foreach ($cellside as $bsk => $bsv) {
18395 if (isset($dom[$key][
'style'][
'border-'.$bsv])) {
18396 $borderstyle = $this->getCSSBorderStyle($dom[$key][
'style'][
'border-'.$bsv]);
18397 if (!empty($borderstyle)) {
18398 $dom[$key][
'border'][$bsk] = $borderstyle;
18401 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-color'])) {
18402 $dom[$key][
'border'][$bsk][
'color'] = $this->convertHTMLColorToDec($dom[$key][
'style'][
'border-'.$bsv.
'-color']);
18404 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-width'])) {
18405 $dom[$key][
'border'][$bsk][
'width'] = $this->getCSSBorderWidth($dom[$key][
'style'][
'border-'.$bsv.
'-width']);
18407 if (isset($dom[$key][
'style'][
'border-'.$bsv.
'-style'])) {
18408 $dom[$key][
'border'][$bsk][
'dash'] = $this->getCSSBorderDashStyle($dom[$key][
'style'][
'border-'.$bsv.
'-style']);
18409 if ($dom[$key][
'border'][$bsk][
'dash'] < 0) {
18410 $dom[$key][
'border'][$bsk] = array();
18415 if (isset($dom[$key][
'style'][
'padding'])) {
18416 $dom[$key][
'padding'] = $this->getCSSPadding($dom[$key][
'style'][
'padding']);
18418 $dom[$key][
'padding'] = $this->cell_padding;
18420 foreach ($cellside as $psk => $psv) {
18421 if (isset($dom[$key][
'style'][
'padding-'.$psv])) {
18422 $dom[$key][
'padding'][$psk] = $this->getHTMLUnitToUnits($dom[$key][
'style'][
'padding-'.$psv], 0,
'px',
false);
18426 if (isset($dom[$key][
'style'][
'margin'])) {
18427 $dom[$key][
'margin'] = $this->getCSSMargin($dom[$key][
'style'][
'margin']);
18429 $dom[$key][
'margin'] = $this->cell_margin;
18431 foreach ($cellside as $psk => $psv) {
18432 if (isset($dom[$key][
'style'][
'margin-'.$psv])) {
18433 $dom[$key][
'margin'][$psk] = $this->getHTMLUnitToUnits(str_replace(
'auto',
'0', $dom[$key][
'style'][
'margin-'.$psv]), 0,
'px',
false);
18437 if (isset($dom[$key][
'style'][
'page-break-inside']) AND ($dom[$key][
'style'][
'page-break-inside'] ==
'avoid')) {
18438 $dom[$key][
'attribute'][
'nobr'] =
'true';
18441 if (isset($dom[$key][
'style'][
'page-break-before'])) {
18442 if ($dom[$key][
'style'][
'page-break-before'] ==
'always') {
18443 $dom[$key][
'attribute'][
'pagebreak'] =
'true';
18444 } elseif ($dom[$key][
'style'][
'page-break-before'] ==
'left') {
18445 $dom[$key][
'attribute'][
'pagebreak'] =
'left';
18446 } elseif ($dom[$key][
'style'][
'page-break-before'] ==
'right') {
18447 $dom[$key][
'attribute'][
'pagebreak'] =
'right';
18451 if (isset($dom[$key][
'style'][
'page-break-after'])) {
18452 if ($dom[$key][
'style'][
'page-break-after'] ==
'always') {
18453 $dom[$key][
'attribute'][
'pagebreakafter'] =
'true';
18454 } elseif ($dom[$key][
'style'][
'page-break-after'] ==
'left') {
18455 $dom[$key][
'attribute'][
'pagebreakafter'] =
'left';
18456 } elseif ($dom[$key][
'style'][
'page-break-after'] ==
'right') {
18457 $dom[$key][
'attribute'][
'pagebreakafter'] =
'right';
18461 if (isset($dom[$key][
'attribute'][
'border']) AND ($dom[$key][
'attribute'][
'border'] != 0)) {
18462 $borderstyle = $this->getCSSBorderStyle($dom[$key][
'attribute'][
'border'].
' solid black');
18463 if (!empty($borderstyle)) {
18464 $dom[$key][
'border'][
'LTRB'] = $borderstyle;
18468 if ($dom[$key][
'value'] ==
'font') {
18470 if (isset($dom[$key][
'attribute'][
'face'])) {
18471 $dom[$key][
'fontname'] = $this->getFontFamilyName($dom[$key][
'attribute'][
'face']);
18474 if (isset($dom[$key][
'attribute'][
'size'])) {
18476 if ($dom[$key][
'attribute'][
'size']{0} ==
'+') {
18477 $dom[$key][
'fontsize'] = $dom[($dom[$key][
'parent'])][
'fontsize'] + intval(substr($dom[$key][
'attribute'][
'size'], 1));
18478 } elseif ($dom[$key][
'attribute'][
'size']{0} ==
'-') {
18479 $dom[$key][
'fontsize'] = $dom[($dom[$key][
'parent'])][
'fontsize'] - intval(substr($dom[$key][
'attribute'][
'size'], 1));
18481 $dom[$key][
'fontsize'] = intval($dom[$key][
'attribute'][
'size']);
18484 $dom[$key][
'fontsize'] = intval($dom[$key][
'attribute'][
'size']);
18489 if ((($dom[$key][
'value'] ==
'ul') OR ($dom[$key][
'value'] ==
'ol') OR ($dom[$key][
'value'] ==
'dl'))
18490 AND (!isset($dom[$key][
'align']) OR $this->empty_string($dom[$key][
'align']) OR ($dom[$key][
'align'] !=
'J'))) {
18492 $dom[$key][
'align'] =
'R';
18494 $dom[$key][
'align'] =
'L';
18497 if (($dom[$key][
'value'] ==
'small') OR ($dom[$key][
'value'] ==
'sup') OR ($dom[$key][
'value'] ==
'sub')) {
18498 if (!isset($dom[$key][
'attribute'][
'size']) AND !isset($dom[$key][
'style'][
'font-size'])) {
18499 $dom[$key][
'fontsize'] = $dom[$key][
'fontsize'] *
K_SMALL_RATIO;
18502 if (($dom[$key][
'value'] ==
'strong') OR ($dom[$key][
'value'] ==
'b')) {
18503 $dom[$key][
'fontstyle'] .=
'B';
18505 if (($dom[$key][
'value'] ==
'em') OR ($dom[$key][
'value'] ==
'i')) {
18506 $dom[$key][
'fontstyle'] .=
'I';
18508 if ($dom[$key][
'value'] ==
'u') {
18509 $dom[$key][
'fontstyle'] .=
'U';
18511 if (($dom[$key][
'value'] ==
'del') OR ($dom[$key][
'value'] ==
's') OR ($dom[$key][
'value'] ==
'strike')) {
18512 $dom[$key][
'fontstyle'] .=
'D';
18514 if (!isset($dom[$key][
'style'][
'text-decoration']) AND ($dom[$key][
'value'] ==
'a')) {
18515 $dom[$key][
'fontstyle'] = $this->htmlLinkFontStyle;
18517 if (($dom[$key][
'value'] ==
'pre') OR ($dom[$key][
'value'] ==
'tt')) {
18518 $dom[$key][
'fontname'] = $this->default_monospaced_font;
18520 if (($dom[$key][
'value']{0} ==
'h') AND (intval($dom[$key][
'value']{1}) > 0) AND (intval($dom[$key][
'value']{1}) < 7)) {
18522 if (!isset($dom[$key][
'attribute'][
'size']) AND !isset($dom[$key][
'style'][
'font-size'])) {
18523 $headsize = (4 - intval($dom[$key][
'value']{1})) * 2;
18524 $dom[$key][
'fontsize'] = $dom[0][
'fontsize'] + $headsize;
18526 if (!isset($dom[$key][
'style'][
'font-weight'])) {
18527 $dom[$key][
'fontstyle'] .=
'B';
18530 if (($dom[$key][
'value'] ==
'table')) {
18531 $dom[$key][
'rows'] = 0;
18532 $dom[$key][
'trids'] = array();
18533 $dom[$key][
'thead'] =
'';
18535 if (($dom[$key][
'value'] ==
'tr')) {
18536 $dom[$key][
'cols'] = 0;
18538 $dom[$key][
'thead'] =
true;
18541 $dom[$key][
'thead'] =
false;
18543 ++$dom[($dom[$key][
'parent'])][
'rows'];
18545 array_push($dom[($dom[$key][
'parent'])][
'trids'], $key);
18548 if (($dom[$key][
'value'] ==
'th') OR ($dom[$key][
'value'] ==
'td')) {
18549 if (isset($dom[$key][
'attribute'][
'colspan'])) {
18550 $colspan = intval($dom[$key][
'attribute'][
'colspan']);
18554 $dom[$key][
'attribute'][
'colspan'] = $colspan;
18555 $dom[($dom[$key][
'parent'])][
'cols'] += $colspan;
18558 if (isset($dom[$key][
'attribute'][
'dir'])) {
18559 $dom[$key][
'dir'] = $dom[$key][
'attribute'][
'dir'];
18562 if (isset($dom[$key][
'attribute'][
'color']) AND (!$this->empty_string($dom[$key][
'attribute'][
'color']))) {
18563 $dom[$key][
'fgcolor'] = $this->convertHTMLColorToDec($dom[$key][
'attribute'][
'color']);
18564 } elseif (!isset($dom[$key][
'style'][
'color']) AND ($dom[$key][
'value'] ==
'a')) {
18565 $dom[$key][
'fgcolor'] = $this->htmlLinkColorArray;
18568 if (isset($dom[$key][
'attribute'][
'bgcolor']) AND (!$this->empty_string($dom[$key][
'attribute'][
'bgcolor']))) {
18569 $dom[$key][
'bgcolor'] = $this->convertHTMLColorToDec($dom[$key][
'attribute'][
'bgcolor']);
18572 if (isset($dom[$key][
'attribute'][
'strokecolor']) AND (!$this->empty_string($dom[$key][
'attribute'][
'strokecolor']))) {
18573 $dom[$key][
'strokecolor'] = $this->convertHTMLColorToDec($dom[$key][
'attribute'][
'strokecolor']);
18576 if (isset($dom[$key][
'attribute'][
'width'])) {
18577 $dom[$key][
'width'] = $dom[$key][
'attribute'][
'width'];
18580 if (isset($dom[$key][
'attribute'][
'height'])) {
18581 $dom[$key][
'height'] = $dom[$key][
'attribute'][
'height'];
18584 if (isset($dom[$key][
'attribute'][
'align']) AND (!$this->empty_string($dom[$key][
'attribute'][
'align'])) AND ($dom[$key][
'value'] !==
'img')) {
18585 $dom[$key][
'align'] = strtoupper($dom[$key][
'attribute'][
'align']{0});
18588 if (isset($dom[$key][
'attribute'][
'stroke'])) {
18590 $dom[$key][
'stroke'] = $this->getHTMLUnitToUnits($dom[$key][
'attribute'][
'stroke'], $dom[$key][
'fontsize'],
'pt',
true);
18592 if (isset($dom[$key][
'attribute'][
'fill'])) {
18594 if ($dom[$key][
'attribute'][
'fill'] ==
'true') {
18595 $dom[$key][
'fill'] =
true;
18597 $dom[$key][
'fill'] =
false;
18600 if (isset($dom[$key][
'attribute'][
'clip'])) {
18602 if ($dom[$key][
'attribute'][
'clip'] ==
'true') {
18603 $dom[$key][
'clip'] =
true;
18605 $dom[$key][
'clip'] =
false;
18611 $dom[$key][
'tag'] =
false;
18612 $dom[$key][
'block'] =
false;
18613 $element = str_replace(
'$nbsp;', $this->unichr(160), $element);
18614 $dom[$key][
'value'] = stripslashes($this->unhtmlentities($element));
18615 $dom[$key][
'parent'] = end($level);
18631 $spacestr = chr(32);
18632 if ($this->isUnicodeFont()) {
18633 $spacestr = chr(0).chr(32);
18658 public function writeHTMLCell($w, $h,
$x,
$y, $html=
'', $border=0, $ln=0, $fill=
false, $reseth=
true, $align=
'', $autopadding=
true) {
18659 return $this->MultiCell($w, $h, $html, $border, $align, $fill, $ln,
$x,
$y, $reseth, 0,
true, $autopadding, 0);
18674 public function writeHTML($html, $ln=
true, $fill=
false, $reseth=
false, $cell=
false, $align=
'') {
18675 $gvars = $this->getGraphicVars();
18677 $prev_cell_margin = $this->cell_margin;
18678 $prev_cell_padding = $this->cell_padding;
18679 $prevPage = $this->page;
18680 $prevlMargin = $this->lMargin;
18681 $prevrMargin = $this->rMargin;
18682 $curfontname = $this->FontFamily;
18683 $curfontstyle = $this->FontStyle;
18684 $curfontsize = $this->FontSizePt;
18685 $curfontascent = $this->getFontAscent($curfontname, $curfontstyle, $curfontsize);
18686 $curfontdescent = $this->getFontDescent($curfontname, $curfontstyle, $curfontsize);
18687 $curfontstretcing = $this->font_stretching;
18688 $curfontkerning = $this->font_spacing;
18689 $this->newline =
true;
18691 $startlinepage = $this->page;
18693 $maxbottomliney = 0;
18699 $this_method_vars = array();
18701 $fontaligned =
false;
18702 $reverse_dir =
false;
18703 $this->premode =
false;
18704 if ($this->inxobj) {
18706 $pask = count($this->xobjects[$this->xobjid][
'annotations']);
18707 } elseif (isset($this->PageAnnots[$this->page])) {
18708 $pask = count($this->PageAnnots[$this->page]);
18712 if ($this->inxobj) {
18714 $startlinepos = strlen($this->xobjects[$this->xobjid][
'outdata']);
18715 } elseif (!$this->InFooter) {
18716 if (isset($this->footerlen[$this->page])) {
18717 $this->footerpos[$this->page] = $this->pagelen[$this->page] - $this->footerlen[$this->page];
18719 $this->footerpos[$this->page] = $this->pagelen[$this->page];
18721 $startlinepos = $this->footerpos[$this->page];
18724 $startlinepos = $this->pagelen[$this->page];
18729 $w = $this->x - $this->lMargin;
18731 $w = $this->w - $this->rMargin -
$this->x;
18733 $w -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
18736 $this->x -= $this->cell_padding[
'R'];
18737 $this->lMargin += $this->cell_padding[
'R'];
18739 $this->x += $this->cell_padding[
'L'];
18740 $this->rMargin += $this->cell_padding[
'L'];
18743 if ($this->customlistindent >= 0) {
18744 $this->listindent = $this->customlistindent;
18746 $this->listindent = $this->GetStringWidth(
'0000');
18748 $this->listindentlevel = 0;
18750 $prev_cell_height_ratio = $this->cell_height_ratio;
18751 $prev_listnum = $this->listnum;
18752 $prev_listordered = $this->listordered;
18753 $prev_listcount = $this->listcount;
18754 $prev_lispacer = $this->lispacer;
18755 $this->listnum = 0;
18756 $this->listordered = array();
18757 $this->listcount = array();
18758 $this->lispacer =
'';
18759 if (($this->empty_string($this->lasth)) OR ($reseth)) {
18761 $this->resetLastH();
18763 $dom = $this->getHtmlDomArray($html);
18764 $maxel = count($dom);
18766 while ($key < $maxel) {
18767 if ($dom[$key][
'tag'] AND isset($dom[$key][
'attribute'][
'pagebreak'])) {
18769 if (($dom[$key][
'attribute'][
'pagebreak'] ==
'true') OR ($dom[$key][
'attribute'][
'pagebreak'] ==
'left') OR ($dom[$key][
'attribute'][
'pagebreak'] ==
'right')) {
18771 $this->checkPageBreak($this->PageBreakTrigger + 1);
18773 if ((($dom[$key][
'attribute'][
'pagebreak'] ==
'left') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
18774 OR (($dom[$key][
'attribute'][
'pagebreak'] ==
'right') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
18776 $this->checkPageBreak($this->PageBreakTrigger + 1);
18779 if ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND isset($dom[$key][
'attribute'][
'nobr']) AND ($dom[$key][
'attribute'][
'nobr'] ==
'true')) {
18780 if (isset($dom[($dom[$key][
'parent'])][
'attribute'][
'nobr']) AND ($dom[($dom[$key][
'parent'])][
'attribute'][
'nobr'] ==
'true')) {
18781 $dom[$key][
'attribute'][
'nobr'] =
false;
18784 $this->startTransaction();
18786 $this_method_vars[
'html'] = $html;
18787 $this_method_vars[
'ln'] = $ln;
18788 $this_method_vars[
'fill'] = $fill;
18789 $this_method_vars[
'reseth'] = $reseth;
18790 $this_method_vars[
'cell'] = $cell;
18791 $this_method_vars[
'align'] = $align;
18792 $this_method_vars[
'gvars'] = $gvars;
18793 $this_method_vars[
'prevPage'] = $prevPage;
18794 $this_method_vars[
'prev_cell_margin'] = $prev_cell_margin;
18795 $this_method_vars[
'prev_cell_padding'] = $prev_cell_padding;
18796 $this_method_vars[
'prevlMargin'] = $prevlMargin;
18797 $this_method_vars[
'prevrMargin'] = $prevrMargin;
18798 $this_method_vars[
'curfontname'] = $curfontname;
18799 $this_method_vars[
'curfontstyle'] = $curfontstyle;
18800 $this_method_vars[
'curfontsize'] = $curfontsize;
18801 $this_method_vars[
'curfontascent'] = $curfontascent;
18802 $this_method_vars[
'curfontdescent'] = $curfontdescent;
18803 $this_method_vars[
'curfontstretcing'] = $curfontstretcing;
18804 $this_method_vars[
'curfontkerning'] = $curfontkerning;
18805 $this_method_vars[
'minstartliney'] = $minstartliney;
18806 $this_method_vars[
'maxbottomliney'] = $maxbottomliney;
18807 $this_method_vars[
'yshift'] = $yshift;
18808 $this_method_vars[
'startlinepage'] = $startlinepage;
18809 $this_method_vars[
'startlinepos'] = $startlinepos;
18810 $this_method_vars[
'startlinex'] = $startlinex;
18811 $this_method_vars[
'startliney'] = $startliney;
18812 $this_method_vars[
'newline'] = $newline;
18813 $this_method_vars[
'loop'] = $loop;
18814 $this_method_vars[
'curpos'] = $curpos;
18815 $this_method_vars[
'pask'] = $pask;
18816 $this_method_vars[
'lalign'] = $lalign;
18817 $this_method_vars[
'plalign'] = $plalign;
18818 $this_method_vars[
'w'] = $w;
18819 $this_method_vars[
'prev_cell_height_ratio'] = $prev_cell_height_ratio;
18820 $this_method_vars[
'prev_listnum'] = $prev_listnum;
18821 $this_method_vars[
'prev_listordered'] = $prev_listordered;
18822 $this_method_vars[
'prev_listcount'] = $prev_listcount;
18823 $this_method_vars[
'prev_lispacer'] = $prev_lispacer;
18824 $this_method_vars[
'fontaligned'] = $fontaligned;
18825 $this_method_vars[
'key'] = $key;
18826 $this_method_vars[
'dom'] = $dom;
18830 if (($dom[$key][
'value'] ==
'tr') AND isset($dom[$key][
'thead']) AND $dom[$key][
'thead']) {
18831 if (isset($dom[$key][
'parent']) AND isset($dom[$dom[$key][
'parent']][
'thead']) AND !$this->empty_string($dom[$dom[$key][
'parent']][
'thead'])) {
18832 $this->inthead =
true;
18834 $this->writeHTML($this->thead,
false,
false,
false,
false,
'');
18836 if (($this->y < $this->start_transaction_y) OR ($this->checkPageBreak($this->lasth,
'',
false))) {
18839 $this->rollbackTransaction(
true);
18841 foreach ($this_method_vars as $vkey => $vval) {
18845 $tmp_thead = $this->thead;
18849 if ((!$this->checkPageBreak($this->PageBreakTrigger + 1)) AND ($this->y < $pre_y)) {
18853 $this->start_transaction_page = $this->page;
18854 $this->start_transaction_y =
$this->y;
18856 $this->thead = $tmp_thead;
18858 if (isset($dom[$dom[$key][
'parent']][
'attribute'][
'cellspacing'])) {
18859 $tmp_cellspacing = $this->getHTMLUnitToUnits($dom[$dom[$key][
'parent']][
'attribute'][
'cellspacing'], 1,
'px');
18861 $tmp_cellspacing = 0;
18863 $dom[$dom[$key][
'parent']][
'borderposition'][
'page'] = $this->page;
18864 $dom[$dom[$key][
'parent']][
'borderposition'][
'column'] = $this->current_column;
18865 $dom[$dom[$key][
'parent']][
'borderposition'][
'y'] = $this->y + $tmp_cellspacing;
18866 $xoffset = ($this->x - $dom[$dom[$key][
'parent']][
'borderposition'][
'x']);
18867 $dom[$dom[$key][
'parent']][
'borderposition'][
'x'] += $xoffset;
18868 $dom[$dom[$key][
'parent']][
'borderposition'][
'xmax'] += $xoffset;
18870 $this->writeHTML($this->thead,
false,
false,
false,
false,
'');
18874 while ( ($key < $maxel) AND (!(
18875 ($dom[$key][
'tag'] AND $dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'tr') AND (!isset($dom[$key][
'thead']) OR !$dom[$key][
'thead']))
18876 OR ($dom[$key][
'tag'] AND (!$dom[$key][
'opening']) AND ($dom[$key][
'value'] ==
'table'))) )) {
18880 if ($dom[$key][
'tag'] OR ($key == 0)) {
18881 if ((($dom[$key][
'value'] ==
'table') OR ($dom[$key][
'value'] ==
'tr')) AND (isset($dom[$key][
'align']))) {
18882 $dom[$key][
'align'] = ($this->rtl) ?
'R' :
'L';
18885 if ((!$this->newline) AND ($dom[$key][
'value'] ==
'img') AND (isset($dom[$key][
'height'])) AND ($dom[$key][
'height'] > 0)) {
18887 $imgh = $this->getHTMLUnitToUnits($dom[$key][
'height'], $this->lasth,
'px');
18889 $autolinebreak =
false;
18890 if (isset($dom[$key][
'width']) AND ($dom[$key][
'width'] > 0)) {
18891 $imgw = $this->getHTMLUnitToUnits($dom[$key][
'width'], 1,
'px',
false);
18892 if (($this->rtl AND (($this->x - $imgw) < ($this->lMargin + $this->cell_padding[
'L'])))
18893 OR (!$this->rtl AND (($this->x + $imgw) > ($this->w - $this->rMargin - $this->cell_padding[
'R'])))) {
18895 $autolinebreak =
true;
18896 $this->Ln(
'', $cell);
18901 if (!$autolinebreak) {
18902 if (!$this->InFooter) {
18905 if ((!$this->checkPageBreak($imgh)) AND ($this->y < $pre_y)) {
18910 if ($this->page > $startlinepage) {
18912 if (isset($this->footerlen[$startlinepage])) {
18913 $curpos = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
18916 $pagebuff = $this->getPageBuffer($startlinepage);
18917 $linebeg = substr($pagebuff, $startlinepos, ($curpos - $startlinepos));
18918 $tstart = substr($pagebuff, 0, $startlinepos);
18919 $tend = substr($this->getPageBuffer($startlinepage), $curpos);
18921 $this->setPageBuffer($startlinepage, $tstart.
''.$tend);
18922 $pagebuff = $this->getPageBuffer($this->page);
18923 $tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
18924 $tend = substr($pagebuff, $this->cntmrk[$this->page]);
18926 $yshift = $minstartliney -
$this->y;
18927 if ($fontaligned) {
18928 $yshift += ($curfontsize / $this->k);
18930 $try = sprintf(
'1 0 0 1 0 %.3F cm', ($yshift * $this->k));
18931 $this->setPageBuffer($this->page, $tstart.
"\nq\n".$try.
"\n".$linebeg.
"\nQ\n".$tend);
18933 if (isset($this->PageAnnots[$this->page])) {
18934 $next_pask = count($this->PageAnnots[$this->page]);
18938 if (isset($this->PageAnnots[$startlinepage])) {
18939 foreach ($this->PageAnnots[$startlinepage] as $pak => $pac) {
18940 if ($pak >= $pask) {
18941 $this->PageAnnots[$this->page][] = $pac;
18942 unset($this->PageAnnots[$startlinepage][$pak]);
18943 $npak = count($this->PageAnnots[$this->page]) - 1;
18944 $this->PageAnnots[$this->page][$npak][
'y'] -= $yshift;
18948 $pask = $next_pask;
18949 $startlinepos = $this->cntmrk[$this->page];
18950 $startlinepage = $this->page;
18952 $this->newline =
false;
18954 $this->y += ((($curfontsize * $this->cell_height_ratio / $this->k) + $curfontascent - $curfontdescent) / 2) - $imgh;
18955 $minstartliney = min($this->y, $minstartliney);
18956 $maxbottomliney = ($startliney + ($this->FontSize * $this->cell_height_ratio));
18958 } elseif (isset($dom[$key][
'fontname']) OR isset($dom[$key][
'fontstyle']) OR isset($dom[$key][
'fontsize']) OR isset($dom[$key][
'line-height'])) {
18960 $pfontname = $curfontname;
18961 $pfontstyle = $curfontstyle;
18962 $pfontsize = $curfontsize;
18963 $fontname = isset($dom[$key][
'fontname']) ? $dom[$key][
'fontname'] : $curfontname;
18964 $fontstyle = isset($dom[$key][
'fontstyle']) ? $dom[$key][
'fontstyle'] : $curfontstyle;
18965 $fontsize = isset($dom[$key][
'fontsize']) ? $dom[$key][
'fontsize'] : $curfontsize;
18966 $fontascent = $this->getFontAscent($fontname, $fontstyle, $fontsize);
18967 $fontdescent = $this->getFontDescent($fontname, $fontstyle, $fontsize);
18968 if (($fontname != $curfontname) OR ($fontstyle != $curfontstyle) OR ($fontsize != $curfontsize) OR ($this->cell_height_ratio != $dom[$key][
'line-height'])) {
18969 if ((!$this->newline) AND ($key < ($maxel - 1))
18970 AND ((is_numeric($fontsize) AND ($fontsize >= 0) AND is_numeric($curfontsize) AND ($curfontsize >= 0) AND ($fontsize != $curfontsize))
18971 OR ($this->cell_height_ratio != $dom[$key][
'line-height']))) {
18972 if ($this->page > $startlinepage) {
18974 if (isset($this->footerlen[$startlinepage])) {
18975 $curpos = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
18978 $pagebuff = $this->getPageBuffer($startlinepage);
18979 $linebeg = substr($pagebuff, $startlinepos, ($curpos - $startlinepos));
18980 $tstart = substr($pagebuff, 0, $startlinepos);
18981 $tend = substr($this->getPageBuffer($startlinepage), $curpos);
18983 $this->setPageBuffer($startlinepage, $tstart.
''.$tend);
18984 $pagebuff = $this->getPageBuffer($this->page);
18985 $tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
18986 $tend = substr($pagebuff, $this->cntmrk[$this->page]);
18988 $yshift = $minstartliney -
$this->y;
18989 $try = sprintf(
'1 0 0 1 0 %.3F cm', ($yshift * $this->k));
18990 $this->setPageBuffer($this->page, $tstart.
"\nq\n".$try.
"\n".$linebeg.
"\nQ\n".$tend);
18992 if (isset($this->PageAnnots[$this->page])) {
18993 $next_pask = count($this->PageAnnots[$this->page]);
18997 if (isset($this->PageAnnots[$startlinepage])) {
18998 foreach ($this->PageAnnots[$startlinepage] as $pak => $pac) {
18999 if ($pak >= $pask) {
19000 $this->PageAnnots[$this->page][] = $pac;
19001 unset($this->PageAnnots[$startlinepage][$pak]);
19002 $npak = count($this->PageAnnots[$this->page]) - 1;
19003 $this->PageAnnots[$this->page][$npak][
'y'] -= $yshift;
19007 $pask = $next_pask;
19008 $startlinepos = $this->cntmrk[$this->page];
19009 $startlinepage = $this->page;
19012 if (!isset($dom[$key][
'line-height'])) {
19013 $dom[$key][
'line-height'] = $this->cell_height_ratio;
19015 if (!$dom[$key][
'block']) {
19016 $this->y += (((($curfontsize * $this->cell_height_ratio ) - ($fontsize * $dom[$key][
'line-height'])) / $this->k) + $curfontascent - $fontascent - $curfontdescent + $fontdescent) / 2;
19017 if (($dom[$key][
'value'] !=
'sup') AND ($dom[$key][
'value'] !=
'sub')) {
19018 $minstartliney = min($this->y, $minstartliney);
19019 $maxbottomliney = max(($this->y + (($fontsize * $this->cell_height_ratio) / $this->k)), $maxbottomliney);
19022 $this->cell_height_ratio = $dom[$key][
'line-height'];
19023 $fontaligned =
true;
19025 $this->SetFont($fontname, $fontstyle, $fontsize);
19027 $this->resetLastH();
19028 $curfontname = $fontname;
19029 $curfontstyle = $fontstyle;
19030 $curfontsize = $fontsize;
19031 $curfontascent = $fontascent;
19032 $curfontdescent = $fontdescent;
19036 $textstroke = isset($dom[$key][
'stroke']) ? $dom[$key][
'stroke'] : $this->textstrokewidth;
19037 $textfill = isset($dom[$key][
'fill']) ? $dom[$key][
'fill'] : (($this->textrendermode % 2) == 0);
19038 $textclip = isset($dom[$key][
'clip']) ? $dom[$key][
'clip'] : ($this->textrendermode > 3);
19039 $this->setTextRenderingMode($textstroke, $textfill, $textclip);
19040 if (isset($dom[$key][
'font-stretch']) AND ($dom[$key][
'font-stretch'] !==
false)) {
19041 $this->setFontStretching($dom[$key][
'font-stretch']);
19043 if (isset($dom[$key][
'letter-spacing']) AND ($dom[$key][
'letter-spacing'] !==
false)) {
19044 $this->setFontSpacing($dom[$key][
'letter-spacing']);
19046 if (($plalign ==
'J') AND $dom[$key][
'block']) {
19050 $curpos = $this->pagelen[$startlinepage];
19051 if (isset($dom[$key][
'bgcolor']) AND ($dom[$key][
'bgcolor'] !==
false)) {
19052 $this->SetFillColorArray($dom[$key][
'bgcolor']);
19055 $wfill = $fill |
false;
19057 if (isset($dom[$key][
'fgcolor']) AND ($dom[$key][
'fgcolor'] !==
false)) {
19058 $this->SetTextColorArray($dom[$key][
'fgcolor']);
19060 if (isset($dom[$key][
'strokecolor']) AND ($dom[$key][
'strokecolor'] !==
false)) {
19061 $this->SetDrawColorArray($dom[$key][
'strokecolor']);
19063 if (isset($dom[$key][
'align'])) {
19064 $lalign = $dom[$key][
'align'];
19066 if ($this->empty_string($lalign)) {
19071 if ($this->newline AND (strlen($dom[$key][
'value']) > 0) AND ($dom[$key][
'value'] !=
'td') AND ($dom[$key][
'value'] !=
'th')) {
19073 $fontaligned =
false;
19075 if (isset($startlinex)) {
19076 $yshift = $minstartliney - $startliney;
19077 if (($yshift > 0) OR ($this->page > $startlinepage)) {
19082 $linew = abs($this->endlinex - $startlinex);
19083 if ($this->inxobj) {
19085 $pstart = substr($this->xobjects[$this->xobjid][
'outdata'], 0, $startlinepos);
19086 if (isset($opentagpos)) {
19087 $midpos = $opentagpos;
19092 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos, ($midpos - $startlinepos));
19093 $pend = substr($this->xobjects[$this->xobjid][
'outdata'], $midpos);
19095 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos);
19099 $pstart = substr($this->getPageBuffer($startlinepage), 0, $startlinepos);
19100 if (isset($opentagpos) AND isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
19101 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
19102 $midpos = min($opentagpos, $this->footerpos[$startlinepage]);
19103 } elseif (isset($opentagpos)) {
19104 $midpos = $opentagpos;
19105 } elseif (isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
19106 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
19107 $midpos = $this->footerpos[$startlinepage];
19112 $pmid = substr($this->getPageBuffer($startlinepage), $startlinepos, ($midpos - $startlinepos));
19113 $pend = substr($this->getPageBuffer($startlinepage), $midpos);
19115 $pmid = substr($this->getPageBuffer($startlinepage), $startlinepos);
19119 if ((isset($plalign) AND ((($plalign ==
'C') OR ($plalign ==
'J') OR (($plalign ==
'R') AND (!$this->rtl)) OR (($plalign ==
'L') AND ($this->rtl)))))) {
19122 if (($plalign ==
'J') AND $this->isRTLTextDir() AND ($this->num_columns > 1)) {
19123 $tw += $this->cell_padding[
'R'];
19125 if ($this->lMargin != $prevlMargin) {
19126 $tw += ($prevlMargin - $this->lMargin);
19128 if ($this->rMargin != $prevrMargin) {
19129 $tw += ($prevrMargin - $this->rMargin);
19131 $one_space_width = $this->GetStringWidth(chr(32));
19133 if ($this->isRTLTextDir()) {
19135 $pos1 = $this->revstrpos($pmid,
'[(');
19137 $pos1 = intval($pos1);
19138 if ($this->isUnicodeFont()) {
19139 $pos2 = intval($this->revstrpos($pmid,
'[('.chr(0).chr(32)));
19142 $pos2 = intval($this->revstrpos($pmid,
'[('.chr(32)));
19145 if ($pos1 == $pos2) {
19146 $pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
19147 if (substr($pmid, $pos1, 4) ==
'[()]') {
19148 $linew -= $one_space_width;
19149 } elseif ($pos1 == strpos($pmid,
'[(')) {
19156 $pos1 = $this->revstrpos($pmid,
')]');
19158 $pos1 = intval($pos1);
19159 if ($this->isUnicodeFont()) {
19160 $pos2 = intval($this->revstrpos($pmid, chr(0).chr(32).
')]')) + 2;
19163 $pos2 = intval($this->revstrpos($pmid, chr(32).
')]')) + 1;
19166 if ($pos1 == $pos2) {
19167 $pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
19168 $linew -= $one_space_width;
19172 $mdiff = ($tw - $linew);
19173 if ($plalign ==
'C') {
19175 $t_x = -($mdiff / 2);
19177 $t_x = ($mdiff / 2);
19179 } elseif ($plalign ==
'R') {
19182 } elseif ($plalign ==
'L') {
19185 } elseif (($plalign ==
'J') AND ($plalign == $lalign)) {
19187 if ($this->isRTLTextDir()) {
19194 $pmidtemp = preg_replace(
'/[\\\][\(]/x',
'\\#!#OP#!#', $pmidtemp);
19195 $pmidtemp = preg_replace(
'/[\\\][\)]/x',
'\\#!#CP#!#', $pmidtemp);
19197 if (preg_match_all(
'/\[\(([^\)]*)\)\]/x', $pmidtemp, $lnstring, PREG_PATTERN_ORDER)) {
19198 $spacestr = $this->getSpaceString();
19199 $maxkk = count($lnstring[1]) - 1;
19200 for ($kk=0; $kk <= $maxkk; ++$kk) {
19202 $lnstring[1][$kk] = str_replace(
'#!#OP#!#',
'(', $lnstring[1][$kk]);
19203 $lnstring[1][$kk] = str_replace(
'#!#CP#!#',
')', $lnstring[1][$kk]);
19205 $lnstring[2][$kk] = substr_count($lnstring[1][$kk], $spacestr);
19207 $ns += $lnstring[2][$kk];
19208 $lnstring[3][$kk] = $ns;
19214 $spacewidth = ($mdiff / ($ns - $no)) * $this->k;
19215 $spacewidthu = -1000 * ($mdiff + (($ns + $no) * $one_space_width)) / $ns / $this->FontSize;
19216 if ($this->font_spacing != 0) {
19218 $osw = -1000 * $this->font_spacing / $this->FontSize;
19219 $spacewidthu += $osw;
19226 $prev_epsposbeg = 0;
19228 if ($this->isRTLTextDir()) {
19229 $textpos = $this->wPt;
19232 while (preg_match(
'/([0-9\.\+\-]*)[\s](Td|cm|m|l|c|re)[\s]/x', $pmid, $strpiece, PREG_OFFSET_CAPTURE, $offset) == 1) {
19234 $stroffset = strpos($pmid,
'[(', $offset);
19235 if (($stroffset !==
false) AND ($stroffset <= $strpiece[2][1])) {
19237 $offset = strpos($pmid,
')]', $stroffset);
19238 while (($offset !==
false) AND ($pmid{($offset - 1)} ==
'\\')) {
19239 $offset = strpos($pmid,
')]', ($offset + 1));
19241 if ($offset ===
false) {
19242 $this->Error(
'HTML Justification: malformed PDF code.');
19246 if ($this->isRTLTextDir()) {
19247 $spacew = ($spacewidth * ($nsmax - $ns));
19249 $spacew = ($spacewidth * $ns);
19251 $offset = $strpiece[2][1] + strlen($strpiece[2][0]);
19252 $epsposbeg = strpos($pmid,
'q'.$this->epsmarker, $offset);
19253 $epsposend = strpos($pmid, $this->epsmarker.
'Q', $offset) + strlen($this->epsmarker.
'Q');
19254 if ((($epsposbeg > 0) AND ($epsposend > 0) AND ($offset > $epsposbeg) AND ($offset < $epsposend))
19255 OR (($epsposbeg ===
false) AND ($epsposend > 0) AND ($offset < $epsposend))) {
19257 $trx = sprintf(
'1 0 0 1 %.3F 0 cm', $spacew);
19258 $epsposbeg = strpos($pmid,
'q'.$this->epsmarker, ($prev_epsposbeg - 6));
19259 $pmid_b = substr($pmid, 0, $epsposbeg);
19260 $pmid_m = substr($pmid, $epsposbeg, ($epsposend - $epsposbeg));
19261 $pmid_e = substr($pmid, $epsposend);
19262 $pmid = $pmid_b.
"\nq\n".$trx.
"\n".$pmid_m.
"\nQ\n".$pmid_e;
19263 $offset = $epsposend;
19267 $prev_epsposbeg = $epsposbeg;
19270 switch ($strpiece[2][0]) {
19276 preg_match(
'/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s]('.$strpiece[2][0].
')([\s]*)/x', $pmid, $xmatches);
19277 $currentxpos = $xmatches[1];
19278 $textpos = $currentxpos;
19279 if (($strcount <= $maxkk) AND ($strpiece[2][0] ==
'Td')) {
19280 $ns = $lnstring[3][$strcount];
19281 if ($this->isRTLTextDir()) {
19282 $spacew = ($spacewidth * ($nsmax - $ns));
19287 $pmid = preg_replace_callback(
'/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s]('.$strpiece[2][0].
')([\s]*)/x',
19288 create_function(
'$matches',
'global $spacew;
19289 $newx = sprintf("%.2F",(floatval($matches[1]) + $spacew));
19290 return "".$newx." ".$matches[2]." x*#!#*x".$matches[3].$matches[4];'), $pmid, 1);
19295 if (!$this->empty_string($this->lispacer)) {
19296 $this->lispacer =
'';
19299 preg_match(
'/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].
')[\s](re)([\s]*)/x', $pmid, $xmatches);
19300 $currentxpos = $xmatches[1];
19301 global $x_diff, $w_diff;
19304 if ($this->isRTLTextDir()) {
19305 if ($currentxpos < $textpos) {
19306 $x_diff = ($spacewidth * ($nsmax - $lnstring[3][$strcount]));
19307 $w_diff = ($spacewidth * $lnstring[2][$strcount]);
19309 if ($strcount > 0) {
19310 $x_diff = ($spacewidth * ($nsmax - $lnstring[3][($strcount - 1)]));
19311 $w_diff = ($spacewidth * $lnstring[2][($strcount - 1)]);
19315 if ($currentxpos > $textpos) {
19316 if ($strcount > 0) {
19317 $x_diff = ($spacewidth * $lnstring[3][($strcount - 1)]);
19319 $w_diff = ($spacewidth * $lnstring[2][$strcount]);
19321 if ($strcount > 1) {
19322 $x_diff = ($spacewidth * $lnstring[3][($strcount - 2)]);
19324 if ($strcount > 0) {
19325 $w_diff = ($spacewidth * $lnstring[2][($strcount - 1)]);
19329 $pmid = preg_replace_callback(
'/('.$xmatches[1].
')[\s]('.$xmatches[2].
')[\s]('.$xmatches[3].
')[\s]('.$strpiece[1][0].
')[\s](re)([\s]*)/x',
19330 create_function(
'$matches',
'global $x_diff, $w_diff;
19331 $newx = sprintf("%.2F",(floatval($matches[1]) + $x_diff));
19332 $neww = sprintf("%.2F",(floatval($matches[3]) + $w_diff));
19333 return "".$newx." ".$matches[2]." ".$neww." ".$matches[4]." x*#!#*x".$matches[5].$matches[6];'), $pmid, 1);
19338 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);
19339 $currentxpos = $xmatches[1];
19341 $pmid = preg_replace_callback(
'/('.$xmatches[1].
')[\s]('.$xmatches[2].
')[\s]('.$xmatches[3].
')[\s]('.$xmatches[4].
')[\s]('.$xmatches[5].
')[\s]('.$strpiece[1][0].
')[\s](c)([\s]*)/x',
19342 create_function(
'$matches',
'global $spacew;
19343 $newx1 = sprintf("%.3F",(floatval($matches[1]) + $spacew));
19344 $newx2 = sprintf("%.3F",(floatval($matches[3]) + $spacew));
19345 $newx3 = sprintf("%.3F",(floatval($matches[5]) + $spacew));
19346 return "".$newx1." ".$matches[2]." ".$newx2." ".$matches[4]." ".$newx3." ".$matches[6]." x*#!#*x".$matches[7].$matches[8];'), $pmid, 1);
19351 $cxpos = ($currentxpos / $this->k);
19352 $lmpos = ($this->lMargin + $this->cell_padding[
'L'] + $this->feps);
19353 if ($this->inxobj) {
19355 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
19356 if (($pac[
'y'] >= $minstartliney) AND (($pac[
'x'] * $this->k) >= ($currentxpos - $this->feps)) AND (($pac[
'x'] * $this->k) <= ($currentxpos + $this->feps))) {
19357 if ($cxpos > $lmpos) {
19358 $this->xobjects[$this->xobjid][
'annotations'][$pak][
'x'] += ($spacew / $this->k);
19359 $this->xobjects[$this->xobjid][
'annotations'][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
19361 $this->xobjects[$this->xobjid][
'annotations'][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
19366 } elseif (isset($this->PageAnnots[$this->page])) {
19367 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
19368 if (($pac[
'y'] >= $minstartliney) AND (($pac[
'x'] * $this->k) >= ($currentxpos - $this->feps)) AND (($pac[
'x'] * $this->k) <= ($currentxpos + $this->feps))) {
19369 if ($cxpos > $lmpos) {
19370 $this->PageAnnots[$this->page][$pak][
'x'] += ($spacew / $this->k);
19371 $this->PageAnnots[$this->page][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
19373 $this->PageAnnots[$this->page][$pak][
'w'] += (($spacewidth * $pac[
'numspaces']) / $this->k);
19381 $pmid = str_replace(
'x*#!#*x',
'', $pmid);
19382 if ($this->isUnicodeFont()) {
19384 $spacew = $spacewidthu;
19385 if ($this->font_stretching != 100) {
19387 $spacew /= ($this->font_stretching / 100);
19391 $pmidtemp = preg_replace(
'/[\\\][\(]/x',
'\\#!#OP#!#', $pmidtemp);
19392 $pmidtemp = preg_replace(
'/[\\\][\)]/x',
'\\#!#CP#!#', $pmidtemp);
19393 $pmid = preg_replace_callback(
"/\[\(([^\)]*)\)\]/x",
19394 create_function(
'$matches',
'global $spacew;
19395 $matches[1] = str_replace("#!#OP#!#", "(", $matches[1]);
19396 $matches[1] = str_replace("#!#CP#!#", ")", $matches[1]);
19397 return "[(".str_replace(chr(0).chr(32), ") ".sprintf("%.3F", $spacew)." (", $matches[1]).")]";'), $pmidtemp);
19398 if ($this->inxobj) {
19400 $this->xobjects[$this->xobjid][
'outdata'] = $pstart.
"\n".$pmid.
"\n".$pend;
19402 $this->setPageBuffer($startlinepage, $pstart.
"\n".$pmid.
"\n".$pend);
19404 $endlinepos = strlen($pstart.
"\n".$pmid.
"\n");
19407 if ($this->font_stretching != 100) {
19409 $spacewidth /= ($this->font_stretching / 100);
19411 $rs = sprintf(
'%.3F Tw', $spacewidth);
19412 $pmid = preg_replace(
"/\[\(/x", $rs.
' [(', $pmid);
19413 if ($this->inxobj) {
19415 $this->xobjects[$this->xobjid][
'outdata'] = $pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n".$pend;
19417 $this->setPageBuffer($startlinepage, $pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n".$pend);
19419 $endlinepos = strlen($pstart.
"\n".$pmid.
"\nBT 0 Tw ET\n");
19424 if (($t_x != 0) OR ($yshift < 0)) {
19426 $trx = sprintf(
'1 0 0 1 %.3F %.3F cm', ($t_x * $this->k), ($yshift * $this->k));
19427 $pstart .=
"\nq\n".$trx.
"\n".$pmid.
"\nQ\n";
19428 $endlinepos = strlen($pstart);
19429 if ($this->inxobj) {
19431 $this->xobjects[$this->xobjid][
'outdata'] = $pstart.$pend;
19432 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
19433 if ($pak >= $pask) {
19434 $this->xobjects[$this->xobjid][
'annotations'][$pak][
'x'] += $t_x;
19435 $this->xobjects[$this->xobjid][
'annotations'][$pak][
'y'] -= $yshift;
19439 $this->setPageBuffer($startlinepage, $pstart.$pend);
19441 if (isset($this->PageAnnots[$this->page])) {
19442 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
19443 if ($pak >= $pask) {
19444 $this->PageAnnots[$this->page][$pak][
'x'] += $t_x;
19445 $this->PageAnnots[$this->page][$pak][
'y'] -= $yshift;
19450 $this->y -= $yshift;
19453 $pbrk = $this->checkPageBreak($this->lasth);
19454 $this->newline =
false;
19457 if ($dom[$dom[$key][
'parent']][
'value'] ==
'sup') {
19458 $startliney -= ((0.3 * $this->FontSizePt) / $this->k);
19459 } elseif ($dom[$dom[$key][
'parent']][
'value'] ==
'sub') {
19460 $startliney -= (($this->FontSizePt / 0.7) / $this->k);
19462 $minstartliney = $startliney;
19463 $maxbottomliney = ($this->y + (($fontsize * $this->cell_height_ratio) / $this->k));
19465 $startlinepage = $this->page;
19466 if (isset($endlinepos) AND (!$pbrk)) {
19467 $startlinepos = $endlinepos;
19469 if ($this->inxobj) {
19471 $startlinepos = strlen($this->xobjects[$this->xobjid][
'outdata']);
19472 } elseif (!$this->InFooter) {
19473 if (isset($this->footerlen[$this->page])) {
19474 $this->footerpos[$this->page] = $this->pagelen[$this->page] - $this->footerlen[$this->page];
19476 $this->footerpos[$this->page] = $this->pagelen[$this->page];
19478 $startlinepos = $this->footerpos[$this->page];
19480 $startlinepos = $this->pagelen[$this->page];
19483 unset($endlinepos);
19484 $plalign = $lalign;
19485 if (isset($this->PageAnnots[$this->page])) {
19486 $pask = count($this->PageAnnots[$this->page]);
19490 if (!($dom[$key][
'tag'] AND !$dom[$key][
'opening'] AND ($dom[$key][
'value'] ==
'table') AND ($this->emptypagemrk[$this->page] == $this->pagelen[$this->page]))) {
19491 $this->SetFont($fontname, $fontstyle, $fontsize);
19493 $this->SetFillColorArray($this->bgcolor);
19497 if (isset($opentagpos)) {
19498 unset($opentagpos);
19500 if ($dom[$key][
'tag']) {
19501 if ($dom[$key][
'opening']) {
19503 if (isset($dom[$key][
'text-indent']) AND $dom[$key][
'block']) {
19504 $this->textindent = $dom[$key][
'text-indent'];
19505 $this->newline =
true;
19508 if ($dom[$key][
'value'] ==
'table') {
19511 $wtmp = $this->x - $this->lMargin;
19513 $wtmp = $this->w - $this->rMargin -
$this->x;
19515 if (isset($dom[$key][
'attribute'][
'cellspacing'])) {
19516 $cellspacing = $this->getHTMLUnitToUnits($dom[$key][
'attribute'][
'cellspacing'], 1,
'px');
19521 if (isset($dom[$key][
'width'])) {
19522 $table_width = $this->getHTMLUnitToUnits($dom[$key][
'width'], $wtmp,
'px');
19524 $table_width = $wtmp;
19526 $table_width -= (2 * $cellspacing);
19527 if (!$this->inthead) {
19528 $this->y += $cellspacing;
19531 $cellspacingx = -$cellspacing;
19533 $cellspacingx = $cellspacing;
19536 $table_columns_width = ($table_width - ($cellspacing * ($dom[$key][
'cols'] - 1)));
19538 $table_min_column_width = ($table_columns_width / $dom[$key][
'cols']);
19540 $table_colwidths = array_fill(0, $dom[$key][
'cols'], $table_min_column_width);
19543 if ($dom[$key][
'value'] ==
'tr') {
19548 if (($dom[$key][
'value'] ==
'td') OR ($dom[$key][
'value'] ==
'th')) {
19549 $trid = $dom[$key][
'parent'];
19550 $table_el = $dom[$trid][
'parent'];
19551 if (!isset($dom[$table_el][
'cols'])) {
19552 $dom[$table_el][
'cols'] = $dom[$trid][
'cols'];
19556 if (isset($dom[$key][
'border']) AND !empty($dom[$key][
'border'])) {
19557 $tdborder = $dom[$key][
'border'];
19559 $colspan = $dom[$key][
'attribute'][
'colspan'];
19560 $old_cell_padding = $this->cell_padding;
19561 if (isset($dom[($dom[$trid][
'parent'])][
'attribute'][
'cellpadding'])) {
19562 $current_cell_padding = $this->getHTMLUnitToUnits($dom[($dom[$trid][
'parent'])][
'attribute'][
'cellpadding'], 1,
'px');
19564 $current_cell_padding = 0;
19566 $this->SetCellPadding($current_cell_padding);
19567 if (isset($dom[$key][
'height'])) {
19569 $cellh = $this->getHTMLUnitToUnits($dom[$key][
'height'], 0,
'px');
19573 if (isset($dom[$key][
'content'])) {
19574 $cell_content = $dom[$key][
'content'];
19576 $cell_content =
' ';
19578 $tagtype = $dom[$key][
'value'];
19580 while (($key < $maxel) AND (!(($dom[$key][
'tag']) AND (!$dom[$key][
'opening']) AND ($dom[$key][
'value'] == $tagtype) AND ($dom[$key][
'parent'] == $parentid)))) {
19584 if (!isset($dom[$trid][
'startpage'])) {
19585 $dom[$trid][
'startpage'] = $this->page;
19587 $this->setPage($dom[$trid][
'startpage']);
19589 if (!isset($dom[$trid][
'startcolumn'])) {
19590 $dom[$trid][
'startcolumn'] = $this->current_column;
19591 } elseif ($this->current_column != $dom[$trid][
'startcolumn']) {
19593 $this->selectColumn($dom[$trid][
'startcolumn']);
19596 if (!isset($dom[$trid][
'starty'])) {
19599 $this->y = $dom[$trid][
'starty'];
19601 if (!isset($dom[$trid][
'startx'])) {
19603 $this->x += $cellspacingx;
19605 $this->x += ($cellspacingx / 2);
19607 if (isset($dom[$parentid][
'attribute'][
'rowspan'])) {
19608 $rowspan = intval($dom[$parentid][
'attribute'][
'rowspan']);
19613 if (isset($dom[$table_el][
'rowspans'])) {
19615 $rskmax = count($dom[$table_el][
'rowspans']);
19616 while ($rsk < $rskmax) {
19617 $trwsp = $dom[$table_el][
'rowspans'][$rsk];
19618 $rsstartx = $trwsp[
'startx'];
19619 $rsendx = $trwsp[
'endx'];
19621 if ($trwsp[
'startpage'] < $this->page) {
19622 if (($this->rtl) AND ($this->pagedim[$this->page][
'orm'] != $this->pagedim[$trwsp[
'startpage']][
'orm'])) {
19623 $dl = ($this->pagedim[$this->page][
'orm'] - $this->pagedim[$trwsp[
'startpage']][
'orm']);
19626 } elseif ((!$this->rtl) AND ($this->pagedim[$this->page][
'olm'] != $this->pagedim[$trwsp[
'startpage']][
'olm'])) {
19627 $dl = ($this->pagedim[$this->page][
'olm'] - $this->pagedim[$trwsp[
'startpage']][
'olm']);
19632 if (($trwsp[
'rowspan'] > 0)
19633 AND ($rsstartx > ($this->x - $cellspacing - $current_cell_padding - $this->feps))
19634 AND ($rsstartx < ($this->x + $cellspacing + $current_cell_padding + $this->feps))
19635 AND (($trwsp[
'starty'] < ($this->y - $this->feps)) OR ($trwsp[
'startpage'] < $this->page) OR ($trwsp[
'startcolumn'] < $this->current_column))) {
19637 $this->x = $rsendx + $cellspacingx;
19639 $colid += $trwsp[
'colspan'];
19640 if (($trwsp[
'rowspan'] == 1)
19641 AND (isset($dom[$trid][
'endy']))
19642 AND (isset($dom[$trid][
'endpage']))
19643 AND (isset($dom[$trid][
'endcolumn']))
19644 AND ($trwsp[
'endpage'] == $dom[$trid][
'endpage'])
19645 AND ($trwsp[
'endcolumn'] == $dom[$trid][
'endcolumn'])) {
19647 $dom[$table_el][
'rowspans'][$rsk][
'endy'] = max($dom[$trid][
'endy'], $trwsp[
'endy']);
19648 $dom[$trid][
'endy'] = $dom[$table_el][
'rowspans'][$rsk][
'endy'];
19656 if (isset($dom[$parentid][
'width'])) {
19658 $cellw = $this->getHTMLUnitToUnits($dom[$parentid][
'width'], $table_columns_width,
'px');
19659 $tmpcw = ($cellw / $colspan);
19660 for ($i = 0; $i < $colspan; ++$i) {
19661 $table_colwidths[($colid + $i)] = $tmpcw;
19666 for ($i = 0; $i < $colspan; ++$i) {
19667 $cellw += $table_colwidths[($colid + $i)];
19670 $cellw += (($colspan - 1) * $cellspacing);
19672 $colid += $colspan;
19674 if ($rowspan > 1) {
19675 $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));
19677 $cellid = array_push($dom[$trid][
'cellpos'], array(
'startx' => $this->x));
19678 if ($rowspan > 1) {
19679 $dom[$trid][
'cellpos'][($cellid - 1)][
'rowspanid'] = ($trsid - 1);
19682 if (isset($dom[$parentid][
'bgcolor']) AND ($dom[$parentid][
'bgcolor'] !==
false)) {
19683 $dom[$trid][
'cellpos'][($cellid - 1)][
'bgcolor'] = $dom[$parentid][
'bgcolor'];
19686 if (isset($tdborder) AND !empty($tdborder)) {
19687 $dom[$trid][
'cellpos'][($cellid - 1)][
'border'] = $tdborder;
19689 $prevLastH = $this->lasth;
19692 $this->colxshift[
'x'] = $this->w - $this->x - $this->rMargin;
19694 $this->colxshift[
'x'] = $this->x - $this->lMargin;
19696 $this->colxshift[
's'] = $cellspacing;
19697 $this->colxshift[
'p'] = $current_cell_padding;
19699 $this->MultiCell($cellw, $cellh, $cell_content,
false, $lalign,
false, 2,
'',
'',
true, 0,
true);
19701 $this->colxshift = array(
'x' => 0,
's' => 0,
'p' => 0);
19702 $this->lasth = $prevLastH;
19703 $this->cell_padding = $old_cell_padding;
19704 $dom[$trid][
'cellpos'][($cellid - 1)][
'endx'] = $this->x;
19706 if ($rowspan <= 1) {
19707 if (isset($dom[$trid][
'endy'])) {
19708 if (($this->page == $dom[$trid][
'endpage']) AND ($this->current_column == $dom[$trid][
'endcolumn'])) {
19709 $dom[$trid][
'endy'] = max($this->y, $dom[$trid][
'endy']);
19710 } elseif (($this->page > $dom[$trid][
'endpage']) OR ($this->current_column > $dom[$trid][
'endcolumn'])) {
19716 if (isset($dom[$trid][
'endpage'])) {
19717 $dom[$trid][
'endpage'] = max($this->page, $dom[$trid][
'endpage']);
19719 $dom[$trid][
'endpage'] = $this->page;
19721 if (isset($dom[$trid][
'endcolumn'])) {
19722 $dom[$trid][
'endcolumn'] = max($this->current_column, $dom[$trid][
'endcolumn']);
19724 $dom[$trid][
'endcolumn'] = $this->current_column;
19728 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endx'] = $this->x;
19729 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endy'] = $this->y;
19730 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endpage'] = $this->page;
19731 $dom[$table_el][
'rowspans'][($trsid - 1)][
'endcolumn'] = $this->current_column;
19733 if (isset($dom[$table_el][
'rowspans'])) {
19735 foreach ($dom[$table_el][
'rowspans'] as $k => $trwsp) {
19736 if ($trwsp[
'rowspan'] > 0) {
19737 if (isset($dom[$trid][
'endpage'])) {
19738 if (($trwsp[
'endpage'] == $dom[$trid][
'endpage']) AND ($trwsp[
'endcolumn'] == $dom[$trid][
'endcolumn'])) {
19739 $dom[$table_el][
'rowspans'][$k][
'endy'] = max($dom[$trid][
'endy'], $trwsp[
'endy']);
19740 } elseif (($trwsp[
'endpage'] < $dom[$trid][
'endpage']) OR ($trwsp[
'endcolumn'] < $dom[$trid][
'endcolumn'])) {
19741 $dom[$table_el][
'rowspans'][$k][
'endy'] = $dom[$trid][
'endy'];
19742 $dom[$table_el][
'rowspans'][$k][
'endpage'] = $dom[$trid][
'endpage'];
19743 $dom[$table_el][
'rowspans'][$k][
'endcolumn'] = $dom[$trid][
'endcolumn'];
19745 $dom[$trid][
'endy'] = $this->pagedim[$dom[$trid][
'endpage']][
'hk'] - $this->pagedim[$dom[$trid][
'endpage']][
'bm'];
19751 $this->x += ($cellspacingx / 2);
19754 if (!isset($opentagpos)) {
19755 if ($this->inxobj) {
19757 $opentagpos = strlen($this->xobjects[$this->xobjid][
'outdata']);
19758 } elseif (!$this->InFooter) {
19759 if (isset($this->footerlen[$this->page])) {
19760 $this->footerpos[$this->page] = $this->pagelen[$this->page] - $this->footerlen[$this->page];
19762 $this->footerpos[$this->page] = $this->pagelen[$this->page];
19764 $opentagpos = $this->footerpos[$this->page];
19767 $this->openHTMLTagHandler($dom, $key, $cell);
19770 $prev_numpages = $this->numpages;
19771 $old_bordermrk = $this->bordermrk[$this->page];
19772 $this->closeHTMLTagHandler($dom, $key, $cell, $maxbottomliney);
19773 if ($this->bordermrk[$this->page] > $old_bordermrk) {
19774 $startlinepos += ($this->bordermrk[$this->page] - $old_bordermrk);
19776 if ($prev_numpages > $this->numpages) {
19777 $startlinepage = $this->page;
19780 } elseif (strlen($dom[$key][
'value']) > 0) {
19782 if (!$this->empty_string($this->lispacer) AND ($this->lispacer !=
'^')) {
19783 $this->SetFont($pfontname, $pfontstyle, $pfontsize);
19784 $this->resetLastH();
19786 $maxbottomliney = ($startliney + ($this->FontSize * $this->cell_height_ratio));
19787 $this->putHtmlListBullet($this->listnum, $this->lispacer, $pfontsize);
19788 $this->SetFont($curfontname, $curfontstyle, $curfontsize);
19789 $this->resetLastH();
19790 if (is_numeric($pfontsize) AND ($pfontsize > 0) AND is_numeric($curfontsize) AND ($curfontsize > 0) AND ($pfontsize != $curfontsize)) {
19791 $pfontascent = $this->getFontAscent($pfontname, $pfontstyle, $pfontsize);
19792 $pfontdescent = $this->getFontDescent($pfontname, $pfontstyle, $pfontsize);
19793 $this->y += ((($pfontsize - $curfontsize) * $this->cell_height_ratio / $this->k) + $pfontascent - $curfontascent - $pfontdescent + $curfontdescent) / 2;
19794 $minstartliney = min($this->y, $minstartliney);
19795 $maxbottomliney = max(($this->y + (($pfontsize * $this->cell_height_ratio) / $this->k)), $maxbottomliney);
19799 $this->htmlvspace = 0;
19800 if ((!$this->premode) AND $this->isRTLTextDir()) {
19804 if (preg_match(
'/^('.$this->re_space[
'p'].
'+)/'.$this->re_space[
'm'], $dom[$key][
'value'], $matches)) {
19805 $lsp = $matches[1];
19807 if (preg_match(
'/('.$this->re_space[
'p'].
'+)$/'.$this->re_space[
'm'], $dom[$key][
'value'], $matches)) {
19808 $rsp = $matches[1];
19810 $dom[$key][
'value'] = $rsp.$this->stringTrim($dom[$key][
'value']).$lsp;
19813 if (!$this->premode) {
19814 $prelen = strlen($dom[$key][
'value']);
19815 if ($this->isRTLTextDir()) {
19817 $dom[$key][
'value'] = $this->stringRightTrim($dom[$key][
'value']);
19820 $dom[$key][
'value'] = $this->stringLeftTrim($dom[$key][
'value']);
19822 $postlen = strlen($dom[$key][
'value']);
19823 if (($postlen == 0) AND ($prelen > 0)) {
19824 $dom[$key][
'trimmed_space'] =
true;
19828 $firstblock =
true;
19830 $firstblock =
false;
19832 $dom[$key][
'value'] = preg_replace(
'/^'.$this->re_space[
'p'].
'+$/'.$this->re_space[
'm'], chr(32), $dom[$key][
'value']);
19836 $this->x -= $this->textindent;
19838 $this->x += $this->textindent;
19840 if (!isset($dom[$key][
'trimmed_space']) OR !$dom[$key][
'trimmed_space']) {
19841 if (!empty($this->HREF) AND (isset($this->HREF[
'url']))) {
19844 if (isset($dom[($dom[$key][
'parent'])][
'fgcolor']) AND ($dom[($dom[$key][
'parent'])][
'fgcolor'] !==
false)) {
19845 $hrefcolor = $dom[($dom[$key][
'parent'])][
'fgcolor'];
19848 if (isset($dom[($dom[$key][
'parent'])][
'fontstyle']) AND ($dom[($dom[$key][
'parent'])][
'fontstyle'] !==
false)) {
19849 $hrefstyle = $dom[($dom[$key][
'parent'])][
'fontstyle'];
19851 $strrest = $this->addHtmlLink($this->HREF[
'url'], $dom[$key][
'value'], $wfill,
true, $hrefcolor, $hrefstyle,
true);
19856 $nkey = ($key + 1);
19857 $write_block =
true;
19858 $tmp_fontname = $this->FontFamily;
19859 $tmp_fontstyle = $this->FontStyle;
19860 $tmp_fontsize = $this->FontSizePt;
19861 while ($write_block AND isset($dom[$nkey])) {
19862 if ($dom[$nkey][
'tag']) {
19863 if ($dom[$nkey][
'block']) {
19865 $write_block =
false;
19867 $tmp_fontname = isset($dom[$nkey][
'fontname']) ? $dom[$nkey][
'fontname'] : $this->FontFamily;
19868 $tmp_fontstyle = isset($dom[$nkey][
'fontstyle']) ? $dom[$nkey][
'fontstyle'] : $this->FontStyle;
19869 $tmp_fontsize = isset($dom[$nkey][
'fontsize']) ? $dom[$nkey][
'fontsize'] : $this->FontSizePt;
19871 $nextstr = preg_split(
'/'.$this->re_space[
'p'].
'+/'.$this->re_space[
'm'], $dom[$nkey][
'value']);
19872 if (isset($nextstr[0])) {
19873 $wadj += $this->GetStringWidth($nextstr[0], $tmp_fontname, $tmp_fontstyle, $tmp_fontsize);
19876 if (isset($nextstr[1])) {
19877 $write_block =
false;
19883 if (($wadj > 0) AND (($this->rtl AND ($this->tmprtl ==
'L')) OR (!$this->rtl AND ($this->tmprtl ==
'R')))) {
19885 $reverse_dir =
true;
19886 $this->rtl = !$this->rtl;
19887 $revshift = ($this->GetStringWidth($dom[$key][
'value']) + $wadj) + 0.000001;
19889 $this->x += $revshift;
19891 $this->x -= $revshift;
19896 $strrest = $this->Write($this->lasth, $dom[$key][
'value'],
'', $wfill,
'',
false, 0,
true, $firstblock, 0, $wadj);
19898 if ($reverse_dir AND ($wadj == 0)) {
19900 $this->rtl = !$this->rtl;
19901 $reverse_dir =
false;
19905 $this->textindent = 0;
19906 if (strlen($strrest) > 0) {
19908 $this->newline =
true;
19909 if ($strrest == $dom[$key][
'value']) {
19915 $dom[$key][
'value'] = $strrest;
19918 $this->x -= $this->cell_padding[
'R'];
19920 $this->x += $this->cell_padding[
'L'];
19931 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')) {
19933 if ((!$undo) AND ($this->y < $this->start_transaction_y)) {
19936 $this->rollbackTransaction(
true);
19938 foreach ($this_method_vars as $vkey => $vval) {
19943 if ((!$this->checkPageBreak($this->PageBreakTrigger + 1)) AND ($this->y < $pre_y)) {
19953 if (isset($startlinex)) {
19954 $yshift = $minstartliney - $startliney;
19955 if (($yshift > 0) OR ($this->page > $startlinepage)) {
19960 $linew = abs($this->endlinex - $startlinex);
19961 if ($this->inxobj) {
19963 $pstart = substr($this->xobjects[$this->xobjid][
'outdata'], 0, $startlinepos);
19964 if (isset($opentagpos)) {
19965 $midpos = $opentagpos;
19970 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos, ($midpos - $startlinepos));
19971 $pend = substr($this->xobjects[$this->xobjid][
'outdata'], $midpos);
19973 $pmid = substr($this->xobjects[$this->xobjid][
'outdata'], $startlinepos);
19977 $pstart = substr($this->getPageBuffer($startlinepage), 0, $startlinepos);
19978 if (isset($opentagpos) AND isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
19979 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
19980 $midpos = min($opentagpos, $this->footerpos[$startlinepage]);
19981 } elseif (isset($opentagpos)) {
19982 $midpos = $opentagpos;
19983 } elseif (isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
19984 $this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
19985 $midpos = $this->footerpos[$startlinepage];
19990 $pmid = substr($this->getPageBuffer($startlinepage), $startlinepos, ($midpos - $startlinepos));
19991 $pend = substr($this->getPageBuffer($startlinepage), $midpos);
19993 $pmid = substr($this->getPageBuffer($startlinepage), $startlinepos);
19997 if ((isset($plalign) AND ((($plalign ==
'C') OR (($plalign ==
'R') AND (!$this->rtl)) OR (($plalign ==
'L') AND ($this->rtl)))))) {
20000 if ($this->lMargin != $prevlMargin) {
20001 $tw += ($prevlMargin - $this->lMargin);
20003 if ($this->rMargin != $prevrMargin) {
20004 $tw += ($prevrMargin - $this->rMargin);
20006 $one_space_width = $this->GetStringWidth(chr(32));
20008 if ($this->isRTLTextDir()) {
20010 $pos1 = $this->revstrpos($pmid,
'[(');
20012 $pos1 = intval($pos1);
20013 if ($this->isUnicodeFont()) {
20014 $pos2 = intval($this->revstrpos($pmid,
'[('.chr(0).chr(32)));
20017 $pos2 = intval($this->revstrpos($pmid,
'[('.chr(32)));
20020 if ($pos1 == $pos2) {
20021 $pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
20022 if (substr($pmid, $pos1, 4) ==
'[()]') {
20023 $linew -= $one_space_width;
20024 } elseif ($pos1 == strpos($pmid,
'[(')) {
20031 $pos1 = $this->revstrpos($pmid,
')]');
20033 $pos1 = intval($pos1);
20034 if ($this->isUnicodeFont()) {
20035 $pos2 = intval($this->revstrpos($pmid, chr(0).chr(32).
')]')) + 2;
20038 $pos2 = intval($this->revstrpos($pmid, chr(32).
')]')) + 1;
20041 if ($pos1 == $pos2) {
20042 $pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
20043 $linew -= $one_space_width;
20047 $mdiff = ($tw - $linew);
20048 if ($plalign ==
'C') {
20050 $t_x = -($mdiff / 2);
20052 $t_x = ($mdiff / 2);
20054 } elseif ($plalign ==
'R') {
20057 } elseif ($plalign ==
'L') {
20062 if (($t_x != 0) OR ($yshift < 0)) {
20064 $trx = sprintf(
'1 0 0 1 %.3F %.3F cm', ($t_x * $this->k), ($yshift * $this->k));
20065 $pstart .=
"\nq\n".$trx.
"\n".$pmid.
"\nQ\n";
20066 $endlinepos = strlen($pstart);
20067 if ($this->inxobj) {
20069 $this->xobjects[$this->xobjid][
'outdata'] = $pstart.$pend;
20070 foreach ($this->xobjects[$this->xobjid][
'annotations'] as $pak => $pac) {
20071 if ($pak >= $pask) {
20072 $this->xobjects[$this->xobjid][
'annotations'][$pak][
'x'] += $t_x;
20073 $this->xobjects[$this->xobjid][
'annotations'][$pak][
'y'] -= $yshift;
20077 $this->setPageBuffer($startlinepage, $pstart.$pend);
20079 if (isset($this->PageAnnots[$this->page])) {
20080 foreach ($this->PageAnnots[$this->page] as $pak => $pac) {
20081 if ($pak >= $pask) {
20082 $this->PageAnnots[$this->page][$pak][
'x'] += $t_x;
20083 $this->PageAnnots[$this->page][$pak][
'y'] -= $yshift;
20088 $this->y -= $yshift;
20092 $this->setGraphicVars($gvars);
20093 if ($this->num_columns > 1) {
20094 $this->selectColumn();
20095 } elseif ($this->page > $prevPage) {
20096 $this->lMargin = $this->pagedim[$this->page][
'olm'];
20097 $this->rMargin = $this->pagedim[$this->page][
'orm'];
20100 $this->cell_height_ratio = $prev_cell_height_ratio;
20101 $this->listnum = $prev_listnum;
20102 $this->listordered = $prev_listordered;
20103 $this->listcount = $prev_listcount;
20104 $this->lispacer = $prev_lispacer;
20105 if ($ln AND (!($cell AND ($dom[$key-1][
'value'] ==
'table')))) {
20106 $this->Ln($this->lasth);
20107 if ($this->y < $maxbottomliney) {
20108 $this->y = $maxbottomliney;
20123 $parent = $dom[($dom[$key][
'parent'])];
20124 $firsttag = ($key == 1);
20126 if (isset($tag[
'dir'])) {
20127 $this->setTempRTL($tag[
'dir']);
20129 $this->tmprtl =
false;
20131 if ($tag[
'block']) {
20135 if (isset($this->tagvspaces[$tag[
'value']][0][
'h']) AND ($this->tagvspaces[$tag[
'value']][0][
'h'] >= 0)) {
20136 $cur_h = $this->tagvspaces[$tag[
'value']][0][
'h'];
20137 } elseif (isset($tag[
'fontsize'])) {
20138 $cur_h = ($tag[
'fontsize'] / $this->k) * $this->cell_height_ratio;
20140 $cur_h = $this->FontSize * $this->cell_height_ratio;
20142 if (isset($this->tagvspaces[$tag[
'value']][0][
'n'])) {
20143 $n = $this->tagvspaces[$tag[
'value']][0][
'n'];
20144 } elseif (preg_match(
'/[h][0-9]/', $tag[
'value']) > 0) {
20149 $hb = ($n * $cur_h);
20150 if (($this->htmlvspace <= 0) AND ($n > 0)) {
20151 if (isset($parent[
'fontsize'])) {
20152 $hbz = (($parent[
'fontsize'] / $this->k) * $this->cell_height_ratio);
20154 $hbz = $this->FontSize * $this->cell_height_ratio;
20159 switch($tag[
'value']) {
20163 $dom[$key][
'rowspans'] = array();
20164 if (!isset($dom[$key][
'attribute'][
'nested']) OR ($dom[$key][
'attribute'][
'nested'] !=
'true')) {
20166 if (!$this->empty_string($dom[$key][
'thead'])) {
20168 $this->thead = $dom[$key][
'thead'];
20169 if (!isset($this->theadMargins) OR (empty($this->theadMargins))) {
20170 $this->theadMargins = array();
20171 $this->theadMargins[
'cell_padding'] = $this->cell_padding;
20172 $this->theadMargins[
'lmargin'] = $this->lMargin;
20173 $this->theadMargins[
'rmargin'] = $this->rMargin;
20174 $this->theadMargins[
'page'] = $this->page;
20179 $dom[$key][
'old_cell_padding'] = $this->cell_padding;
20180 if (isset($tag[
'attribute'][
'cellpadding'])) {
20181 $pad = $this->getHTMLUnitToUnits($tag[
'attribute'][
'cellpadding'], 1,
'px');
20182 $this->SetCellPadding($pad);
20184 if (isset($tag[
'attribute'][
'cellspacing'])) {
20185 $cs = $this->getHTMLUnitToUnits($tag[
'attribute'][
'cellspacing'], 1,
'px');
20188 if ($this->checkPageBreak(((2 * $cp) + (2 * $cs) + $this->lasth),
'',
false) OR ($this->y < $prev_y)) {
20189 $this->inthead =
true;
20191 $this->checkPageBreak($this->PageBreakTrigger + 1);
20197 $dom[$key][
'cellpos'] = array();
20201 if ((isset($tag[
'height'])) AND ($tag[
'height'] !=
'')) {
20202 $hrHeight = $this->getHTMLUnitToUnits($tag[
'height'], 1,
'px');
20204 $hrHeight = $this->GetLineWidth();
20206 $this->addHTMLVertSpace($hbz, ($hrHeight / 2), $cell, $firsttag);
20207 $x = $this->GetX();
20208 $y = $this->GetY();
20209 $wtmp = $this->w - $this->lMargin - $this->rMargin;
20211 $wtmp -= ($this->cell_padding[
'L'] + $this->cell_padding[
'R']);
20213 if ((isset($tag[
'width'])) AND ($tag[
'width'] !=
'')) {
20214 $hrWidth = $this->getHTMLUnitToUnits($tag[
'width'], $wtmp,
'px');
20218 $prevlinewidth = $this->GetLineWidth();
20219 $this->SetLineWidth($hrHeight);
20220 $this->Line(
$x,
$y,
$x + $hrWidth,
$y);
20221 $this->SetLineWidth($prevlinewidth);
20222 $this->addHTMLVertSpace(($hrHeight / 2), 0, $cell, !isset($dom[($key + 1)]));
20226 if (array_key_exists(
'href', $tag[
'attribute'])) {
20227 $this->HREF[
'url'] = $tag[
'attribute'][
'href'];
20232 if (isset($tag[
'attribute'][
'src'])) {
20234 if (($tag[
'attribute'][
'src'][0] ==
'/') AND ($_SERVER[
'DOCUMENT_ROOT'] !=
'/')) {
20235 $findroot = strpos($tag[
'attribute'][
'src'], $_SERVER[
'DOCUMENT_ROOT']);
20236 if (($findroot ===
false) OR ($findroot > 1)) {
20237 $tag[
'attribute'][
'src'] = $_SERVER[
'DOCUMENT_ROOT'].$tag[
'attribute'][
'src'];
20240 $tag[
'attribute'][
'src'] = urldecode($tag[
'attribute'][
'src']);
20241 $type = $this->getImageFileType($tag[
'attribute'][
'src']);
20242 $testscrtype = @parse_url($tag[
'attribute'][
'src']);
20243 if (!isset($testscrtype[
'query']) OR empty($testscrtype[
'query'])) {
20247 if (!isset($tag[
'width'])) {
20250 if (!isset($tag[
'height'])) {
20251 $tag[
'height'] = 0;
20256 $tag[
'attribute'][
'align'] =
'bottom';
20258 switch($tag[
'attribute'][
'align']) {
20279 if (isset($dom[($key - 1)])) {
20280 if (($dom[($key - 1)][
'value'] ==
' ') OR (isset($dom[($key - 1)][
'trimmed_space']))) {
20281 $xpos -= $this->GetStringWidth(chr(32));
20282 } elseif ($this->rtl AND $dom[($key - 1)][
'value'] ==
' ') {
20283 $xpos += (2 * $this->GetStringWidth(chr(32)));
20287 if (isset($this->HREF[
'url']) AND !$this->empty_string($this->HREF[
'url'])) {
20288 $imglink = $this->HREF[
'url'];
20289 if ($imglink{0} ==
'#') {
20291 $lnkdata = explode(
',', $imglink);
20292 if (isset($lnkdata[0])) {
20293 $page = intval(substr($lnkdata[0], 1));
20294 if (empty($page) OR ($page <= 0)) {
20295 $page = $this->page;
20297 if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
20298 $lnky = floatval($lnkdata[1]);
20302 $imglink = $this->AddLink();
20303 $this->SetLink($imglink, $lnky, $page);
20308 if (isset($tag[
'border']) AND !empty($tag[
'border'])) {
20310 $border = $tag[
'border'];
20313 if (isset($tag[
'width'])) {
20314 $iw = $this->getHTMLUnitToUnits($tag[
'width'], 1,
'px',
false);
20317 if (isset($tag[
'height'])) {
20318 $ih = $this->getHTMLUnitToUnits($tag[
'height'], 1,
'px',
false);
20321 $this->ImageEps($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih, $imglink,
true, $align,
'', $border,
true);
20322 } elseif (
$type ==
'svg') {
20323 $this->ImageSVG($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih, $imglink, $align,
'', $border,
true);
20325 $this->Image($tag[
'attribute'][
'src'], $xpos, $this->y, $iw, $ih,
'', $imglink, $align,
false, 300,
'',
false,
false, $border,
false,
false,
true);
20333 $this->y = (($this->img_rb_y + $prevy - ($tag[
'fontsize'] / $this->k)) / 2) ;
20337 $this->y = $this->img_rb_y - ($tag[
'fontsize'] / $this->k);
20346 if ($this->listnum == 1) {
20347 $this->addHTMLVertSpace($hbz, $hb, $cell, $firsttag);
20349 $this->addHTMLVertSpace(0, 0, $cell, $firsttag);
20354 $this->addHTMLVertSpace($hbz, 0, $cell, $firsttag);
20359 $this->rMargin += $this->listindent;
20361 $this->lMargin += $this->listindent;
20363 ++$this->listindentlevel;
20364 $this->addHTMLVertSpace($hbz, 0, $cell, $firsttag);
20370 if ($tag[
'value'] ==
'ol') {
20371 $this->listordered[$this->listnum] =
true;
20373 $this->listordered[$this->listnum] =
false;
20375 if (isset($tag[
'attribute'][
'start'])) {
20376 $this->listcount[$this->listnum] = intval($tag[
'attribute'][
'start']) - 1;
20378 $this->listcount[$this->listnum] = 0;
20381 $this->rMargin += $this->listindent;
20382 $this->x -= $this->listindent;
20384 $this->lMargin += $this->listindent;
20385 $this->x += $this->listindent;
20387 ++$this->listindentlevel;
20388 if ($this->listnum == 1) {
20389 $this->addHTMLVertSpace($hbz, $hb, $cell, $firsttag);
20391 $this->addHTMLVertSpace(0, 0, $cell, $firsttag);
20396 $this->addHTMLVertSpace($hbz, 0, $cell, $firsttag);
20397 if ($this->listordered[$this->listnum]) {
20399 if (isset($parent[
'attribute'][
'type']) AND !$this->empty_string($parent[
'attribute'][
'type'])) {
20400 $this->lispacer = $parent[
'attribute'][
'type'];
20401 } elseif (isset($parent[
'listtype']) AND !$this->empty_string($parent[
'listtype'])) {
20402 $this->lispacer = $parent[
'listtype'];
20403 } elseif (isset($this->lisymbol) AND !$this->empty_string($this->lisymbol)) {
20404 $this->lispacer = $this->lisymbol;
20406 $this->lispacer =
'#';
20408 ++$this->listcount[$this->listnum];
20409 if (isset($tag[
'attribute'][
'value'])) {
20410 $this->listcount[$this->listnum] = intval($tag[
'attribute'][
'value']);
20414 if (isset($parent[
'attribute'][
'type']) AND !$this->empty_string($parent[
'attribute'][
'type'])) {
20415 $this->lispacer = $parent[
'attribute'][
'type'];
20416 } elseif (isset($parent[
'listtype']) AND !$this->empty_string($parent[
'listtype'])) {
20417 $this->lispacer = $parent[
'listtype'];
20418 } elseif (isset($this->lisymbol) AND !$this->empty_string($this->lisymbol)) {
20419 $this->lispacer = $this->lisymbol;
20421 $this->lispacer =
'!';
20426 case 'blockquote': {
20428 $this->rMargin += $this->listindent;
20430 $this->lMargin += $this->listindent;
20432 ++$this->listindentlevel;
20433 $this->addHTMLVertSpace($hbz, $hb, $cell, $firsttag);
20437 $this->addHTMLVertSpace($hbz, 0, $cell, $firsttag);
20441 $this->addHTMLVertSpace($hbz, 0, $cell, $firsttag);
20445 $this->addHTMLVertSpace($hbz, $hb, $cell, $firsttag);
20449 $this->addHTMLVertSpace($hbz, $hb, $cell, $firsttag);
20450 $this->premode =
true;
20454 $this->SetXY($this->GetX(), $this->GetY() - ((0.7 * $this->FontSizePt) / $this->k));
20458 $this->SetXY($this->GetX(), $this->GetY() + ((0.3 * $this->FontSizePt) / $this->k));
20467 $this->addHTMLVertSpace($hbz, $hb, $cell, $firsttag);
20472 if (isset($tag[
'attribute'][
'action'])) {
20473 $this->form_action = $tag[
'attribute'][
'action'];
20475 $this->form_action =
K_PATH_URL.$_SERVER[
'SCRIPT_NAME'];
20477 if (isset($tag[
'attribute'][
'enctype'])) {
20478 $this->form_enctype = $tag[
'attribute'][
'enctype'];
20480 $this->form_enctype =
'application/x-www-form-urlencoded';
20482 if (isset($tag[
'attribute'][
'method'])) {
20483 $this->form_mode = $tag[
'attribute'][
'method'];
20485 $this->form_mode =
'post';
20490 if (isset($tag[
'attribute'][
'name']) AND !$this->empty_string($tag[
'attribute'][
'name'])) {
20491 $name = $tag[
'attribute'][
'name'];
20497 if (isset($tag[
'attribute'][
'readonly']) AND !$this->empty_string($tag[
'attribute'][
'readonly'])) {
20498 $prop[
'readonly'] =
true;
20500 if (isset($tag[
'attribute'][
'value']) AND !$this->empty_string($tag[
'attribute'][
'value'])) {
20501 $value = $tag[
'attribute'][
'value'];
20503 if (isset($tag[
'attribute'][
'maxlength']) AND !$this->empty_string($tag[
'attribute'][
'maxlength'])) {
20504 $opt[
'maxlen'] = intval($tag[
'attribute'][
'value']);
20506 $h = $this->FontSize * $this->cell_height_ratio;
20507 if (isset($tag[
'attribute'][
'size']) AND !$this->empty_string($tag[
'attribute'][
'size'])) {
20508 $w = intval($tag[
'attribute'][
'size']) * $this->GetStringWidth(chr(32)) * 2;
20512 if (isset($tag[
'attribute'][
'checked']) AND (($tag[
'attribute'][
'checked'] ==
'checked') OR ($tag[
'attribute'][
'checked'] ==
'true'))) {
20517 switch ($tag[
'attribute'][
'type']) {
20519 if (isset($value)) {
20520 $opt[
'v'] = $value;
20522 $this->TextField(
$name, $w, $h, $prop, $opt,
'',
'',
false);
20526 if (isset($value)) {
20527 $opt[
'v'] = $value;
20529 $prop[
'password'] =
'true';
20530 $this->TextField(
$name, $w, $h, $prop, $opt,
'',
'',
false);
20534 $this->CheckBox(
$name, $w, $checked, $prop, $opt, $value,
'',
'',
false);
20538 $this->RadioButton(
$name, $w, $prop, $opt, $value, $checked,
'',
'',
false);
20542 $w = $this->GetStringWidth($value) * 1.5;
20544 $prop = array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>array(196, 196, 196),
'strokeColor'=>array(255, 255, 255));
20546 $action[
'S'] =
'SubmitForm';
20547 $action[
'F'] = $this->form_action;
20548 if ($this->form_enctype !=
'FDF') {
20549 $action[
'Flags'] = array(
'ExportFormat');
20551 if ($this->form_mode ==
'get') {
20552 $action[
'Flags'] = array(
'GetMethod');
20554 $this->Button(
$name, $w, $h, $value, $action, $prop, $opt,
'',
'',
false);
20558 $w = $this->GetStringWidth($value) * 1.5;
20560 $prop = array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>array(196, 196, 196),
'strokeColor'=>array(255, 255, 255));
20561 $this->Button(
$name, $w, $h, $value, array(
'S'=>
'ResetForm'), $prop, $opt,
'',
'',
false);
20565 $prop[
'fileSelect'] =
'true';
20566 $this->TextField(
$name, $w, $h, $prop, $opt,
'',
'',
false);
20567 if (!isset($value)) {
20570 $w = $this->GetStringWidth($value) * 2;
20572 $prop = array(
'lineWidth'=>1,
'borderStyle'=>
'beveled',
'fillColor'=>array(196, 196, 196),
'strokeColor'=>array(255, 255, 255));
20573 $jsaction =
'var f=this.getField(\''.$name.
'\'); f.browseForFileToSubmit();
';
20574 $this->Button('FB_
'.$name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false);
20578 if (isset($value)) {
20579 $opt['v
'] = $value;
20581 $opt['f
'] = array('invisible
', 'hidden
');
20582 $this->TextField($name, 0, 0, $prop, $opt, '', '', false);
20586 // THIS TYPE MUST BE FIXED
20587 if (isset($tag['attribute
']['src
']) AND !$this->empty_string($tag['attribute
']['src
'])) {
20588 $img = $tag['attribute
']['src
'];
20593 //$opt['mk
'] = array('i
'=>$img, 'tp
'=>1, 'if'=>array('sw
'=>'A
', 's
'=>'A
', 'fb
'=>false));
20594 if (isset($tag['attribute
']['onclick
']) AND !empty($tag['attribute
']['onclick
'])) {
20595 $jsaction = $tag['attribute
']['onclick
'];
20599 $this->Button($name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false);
20603 $w = $this->GetStringWidth($value) * 1.5;
20605 $prop = array('lineWidth
'=>1, 'borderStyle
'=>'beveled
', 'fillColor
'=>array(196, 196, 196), 'strokeColor
'=>array(255, 255, 255));
20606 if (isset($tag['attribute
']['onclick
']) AND !empty($tag['attribute
']['onclick
'])) {
20607 $jsaction = $tag['attribute
']['onclick
'];
20611 $this->Button($name, $w, $h, $value, $jsaction, $prop, $opt, '', '', false);
20620 if (isset($tag['attribute
']['readonly
']) AND !$this->empty_string($tag['attribute
']['readonly
'])) {
20621 $prop['readonly
'] = true;
20623 if (isset($tag['attribute
']['name
']) AND !$this->empty_string($tag['attribute
']['name
'])) {
20624 $name = $tag['attribute
']['name
'];
20628 if (isset($tag['attribute
']['value
']) AND !$this->empty_string($tag['attribute
']['value
'])) {
20629 $opt['v
'] = $tag['attribute
']['value
'];
20631 if (isset($tag['attribute
']['cols
']) AND !$this->empty_string($tag['attribute
']['cols
'])) {
20632 $w = intval($tag['attribute
']['cols
']) * $this->GetStringWidth(chr(32)) * 2;
20636 if (isset($tag['attribute
']['rows
']) AND !$this->empty_string($tag['attribute
']['rows
'])) {
20637 $h = intval($tag['attribute
']['rows
']) * $this->FontSize * $this->cell_height_ratio;
20641 $prop['multiline
'] = 'true';
20642 $this->TextField($name, $w, $h, $prop, $opt, '', '', false);
20646 $h = $this->FontSize * $this->cell_height_ratio;
20647 if (isset($tag['attribute
']['size
']) AND !$this->empty_string($tag['attribute
']['size
'])) {
20648 $h *= ($tag['attribute
']['size
'] + 1);
20652 if (isset($tag['attribute
']['name
']) AND !$this->empty_string($tag['attribute
']['name
'])) {
20653 $name = $tag['attribute
']['name
'];
20658 if (isset($tag['attribute
']['opt
']) AND !$this->empty_string($tag['attribute
']['opt
'])) {
20659 $options = explode('#!NwL!#
', $tag['attribute
']['opt
']);
20661 foreach ($options as $val) {
20662 if (strpos($val, '#!TaB!#
') !== false) {
20663 $opts = explode('#!TaB!#
', $val);
20665 $w = max($w, $this->GetStringWidth($opts[1]));
20668 $w = max($w, $this->GetStringWidth($val));
20675 if (isset($tag['attribute
']['multiple
']) AND ($tag['attribute
']['multiple
']='multiple
')) {
20676 $prop['multipleSelection
'] = 'true';
20677 $this->ListBox($name, $w, $h, $values, $prop, $opt, '', '', false);
20679 $this->ComboBox($name, $w, $h, $values, $prop, $opt, '', '', false);
20685 // Special tag used to call TCPDF methods
20686 if (isset($tag['attribute
']['method
'])) {
20687 $tcpdf_method = $tag['attribute
']['method
'];
20688 if (method_exists($this, $tcpdf_method)) {
20689 if (isset($tag['attribute
']['params
']) AND (!empty($tag['attribute
']['params
']))) {
20690 $params = unserialize(urldecode($tag['attribute
']['params
']));
20691 call_user_func_array(array($this, $tcpdf_method), $params);
20693 $this->$tcpdf_method();
20695 $this->newline = true;
20705 // define tags that support borders and background colors
20706 $bordertags = array('blockquote
','br
','dd
','dl
','div
','dt
','h1
','h2
','h3
','h4
','h5
','h6
','hr
','li
','ol
','p
','pre
','ul
','tcpdf
','table
');
20707 if (in_array($tag['value
'], $bordertags)) {
20709 $dom[$key]['borderposition
'] = $this->getBorderStartPosition();
20711 if ($dom[$key]['self'] AND isset($dom[$key]['attribute
']['pagebreakafter
'])) {
20712 $pba = $dom[$key]['attribute
']['pagebreakafter
'];
20713 // check for pagebreak
20714 if (($pba == 'true') OR ($pba == 'left
') OR ($pba == 'right
')) {
20715 // add a page (or trig AcceptPageBreak() for multicolumn mode)
20716 $this->checkPageBreak($this->PageBreakTrigger + 1);
20718 if ((($pba == 'left
') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
20719 OR (($pba == 'right
') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
20720 // add a page (or trig AcceptPageBreak() for multicolumn mode)
20721 $this->checkPageBreak($this->PageBreakTrigger + 1);
20734 protected function closeHTMLTagHandler(&$dom, $key, $cell, $maxbottomliney=0) {
20736 $parent = $dom[($dom[$key]['parent
'])];
20737 $lasttag = ((!isset($dom[($key + 1)])) OR ((!isset($dom[($key + 2)])) AND ($dom[($key + 1)]['value
'] == 'marker
')));
20738 $in_table_head = false;
20739 // maximum x position (used to draw borders)
20745 if ($tag['block
']) {
20746 $hbz = 0; // distance from y to line bottom
20747 $hb = 0; // vertical space between block tags
20748 // calculate vertical space for block tags
20749 if (isset($this->tagvspaces[$tag['value
']][1]['h
']) AND ($this->tagvspaces[$tag['value
']][1]['h
'] >= 0)) {
20750 $pre_h = $this->tagvspaces[$tag['value
']][1]['h
'];
20751 } elseif (isset($parent['fontsize
'])) {
20752 $pre_h = (($parent['fontsize
'] / $this->k) * $this->cell_height_ratio);
20754 $pre_h = $this->FontSize * $this->cell_height_ratio;
20756 if (isset($this->tagvspaces[$tag['value
']][1]['n'])) {
20757 $n = $this->tagvspaces[$tag['value
']][1]['n'];
20758 } elseif (preg_match('/[h][0-9]/
', $tag['value
']) > 0) {
20763 $hb = ($n * $pre_h);
20764 if ($this->y < $maxbottomliney) {
20765 $hbz = ($maxbottomliney - $this->y);
20769 switch($tag['value
']) {
20771 $table_el = $dom[($dom[$key]['parent
'])]['parent
'];
20772 if (!isset($parent['endy
'])) {
20773 $dom[($dom[$key]['parent
'])]['endy
'] = $this->y;
20774 $parent['endy
'] = $this->y;
20776 if (!isset($parent['endpage
'])) {
20777 $dom[($dom[$key]['parent
'])]['endpage
'] = $this->page;
20778 $parent['endpage
'] = $this->page;
20780 if (!isset($parent['endcolumn
'])) {
20781 $dom[($dom[$key]['parent
'])]['endcolumn
'] = $this->current_column;
20782 $parent['endcolumn
'] = $this->current_column;
20784 // update row-spanned cells
20785 if (isset($dom[$table_el]['rowspans
'])) {
20786 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) {
20787 $dom[$table_el]['rowspans
'][$k]['rowspan
'] -= 1;
20788 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) {
20789 if (($dom[$table_el]['rowspans
'][$k]['endpage
'] == $parent['endpage
']) AND ($dom[$table_el]['rowspans
'][$k]['endcolumn
'] == $parent['endcolumn
'])) {
20790 $dom[($dom[$key]['parent
'])]['endy
'] = max($dom[$table_el]['rowspans
'][$k]['endy
'], $parent['endy
']);
20791 } elseif (($dom[$table_el]['rowspans
'][$k]['endpage
'] > $parent['endpage
']) OR ($dom[$table_el]['rowspans
'][$k]['endcolumn
'] > $parent['endcolumn
'])) {
20792 $dom[($dom[$key]['parent
'])]['endy
'] = $dom[$table_el]['rowspans
'][$k]['endy
'];
20793 $dom[($dom[$key]['parent
'])]['endpage
'] = $dom[$table_el]['rowspans
'][$k]['endpage
'];
20794 $dom[($dom[$key]['parent
'])]['endcolumn
'] = $dom[$table_el]['rowspans
'][$k]['endcolumn
'];
20798 // report new endy and endpage to the rowspanned cells
20799 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) {
20800 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) {
20801 $dom[$table_el]['rowspans
'][$k]['endpage
'] = max($dom[$table_el]['rowspans
'][$k]['endpage
'], $dom[($dom[$key]['parent
'])]['endpage
']);
20802 $dom[($dom[$key]['parent
'])]['endpage
'] = $dom[$table_el]['rowspans
'][$k]['endpage
'];
20803 $dom[$table_el]['rowspans
'][$k]['endcolumn
'] = max($dom[$table_el]['rowspans
'][$k]['endcolumn
'], $dom[($dom[$key]['parent
'])]['endcolumn
']);
20804 $dom[($dom[$key]['parent
'])]['endcolumn
'] = $dom[$table_el]['rowspans
'][$k]['endcolumn
'];
20805 $dom[$table_el]['rowspans
'][$k]['endy
'] = max($dom[$table_el]['rowspans
'][$k]['endy
'], $dom[($dom[$key]['parent
'])]['endy
']);
20806 $dom[($dom[$key]['parent
'])]['endy
'] = $dom[$table_el]['rowspans
'][$k]['endy
'];
20809 // update remaining rowspanned cells
20810 foreach ($dom[$table_el]['rowspans
'] as $k => $trwsp) {
20811 if ($dom[$table_el]['rowspans
'][$k]['rowspan
'] == 0) {
20812 $dom[$table_el]['rowspans
'][$k]['endpage
'] = $dom[($dom[$key]['parent
'])]['endpage
'];
20813 $dom[$table_el]['rowspans
'][$k]['endcolumn
'] = $dom[($dom[$key]['parent
'])]['endcolumn
'];
20814 $dom[$table_el]['rowspans
'][$k]['endy
'] = $dom[($dom[$key]['parent
'])]['endy
'];
20818 $this->setPage($dom[($dom[$key]['parent
'])]['endpage
']);
20819 if ($this->num_columns > 1) {
20820 $this->selectColumn($dom[($dom[$key]['parent
'])]['endcolumn
']);
20822 $this->y = $dom[($dom[$key]['parent
'])]['endy
'];
20823 if (isset($dom[$table_el]['attribute
']['cellspacing
'])) {
20824 $cellspacing = $this->getHTMLUnitToUnits($dom[$table_el]['attribute
']['cellspacing
'], 1, 'px
');
20825 $this->y += $cellspacing;
20827 $this->Ln(0, $cell);
20828 if ($this->current_column == $parent['startcolumn
']) {
20829 $this->x = $parent['startx
'];
20831 // account for booklet mode
20832 if ($this->page > $parent['startpage
']) {
20833 if (($this->rtl) AND ($this->pagedim[$this->page]['orm
'] != $this->pagedim[$parent['startpage
']]['orm
'])) {
20834 $this->x -= ($this->pagedim[$this->page]['orm
'] - $this->pagedim[$parent['startpage
']]['orm
']);
20835 } elseif ((!$this->rtl) AND ($this->pagedim[$this->page]['olm
'] != $this->pagedim[$parent['startpage
']]['olm
'])) {
20836 $this->x += ($this->pagedim[$this->page]['olm
'] - $this->pagedim[$parent['startpage
']]['olm
']);
20842 // closing tag used for the thead part
20843 $in_table_head = true;
20844 $this->inthead = false;
20846 $table_el = $parent;
20847 // set default border
20848 if (isset($table_el['attribute
']['border
']) AND ($table_el['attribute
']['border
'] > 0)) {
20849 // set default border
20850 $border = array('LTRB
' => array('width
' => $this->getCSSBorderWidth($table_el['attribute
']['border
']), 'cap
'=>'square
', 'join
'=>'miter
', 'dash
'=> 0, 'color
'=>array(0,0,0)));
20854 $default_border = $border;
20855 if (isset($table_el['attribute
']['cellspacing
'])) {
20856 $cellspacing = $this->getHTMLUnitToUnits($table_el['attribute
']['cellspacing
'], 1, 'px
');
20860 // fix bottom line alignment of last line before page break
20861 foreach ($dom[($dom[$key]['parent
'])]['trids
'] as $j => $trkey) {
20862 // update row-spanned cells
20863 if (isset($dom[($dom[$key]['parent
'])]['rowspans
'])) {
20864 foreach ($dom[($dom[$key]['parent
'])]['rowspans
'] as $k => $trwsp) {
20865 if ($trwsp['trid
'] == $trkey) {
20866 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['mrowspan
'] -= 1;
20868 if (isset($prevtrkey) AND ($trwsp['trid
'] == $prevtrkey) AND ($trwsp['mrowspan
'] >= 0)) {
20869 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['trid
'] = $trkey;
20873 if (isset($prevtrkey) AND ($dom[$trkey]['startpage
'] > $dom[$prevtrkey]['endpage
'])) {
20874 $pgendy = $this->pagedim[$dom[$prevtrkey]['endpage
']]['hk
'] - $this->pagedim[$dom[$prevtrkey]['endpage
']]['bm
'];
20875 $dom[$prevtrkey]['endy
'] = $pgendy;
20876 // update row-spanned cells
20877 if (isset($dom[($dom[$key]['parent
'])]['rowspans
'])) {
20878 foreach ($dom[($dom[$key]['parent
'])]['rowspans
'] as $k => $trwsp) {
20879 if (($trwsp['trid
'] == $trkey) AND ($trwsp['mrowspan
'] > 1) AND ($trwsp['endpage
'] == $dom[$prevtrkey]['endpage
'])) {
20880 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['endy
'] = $pgendy;
20881 $dom[($dom[$key]['parent
'])]['rowspans
'][$k]['mrowspan
'] = -1;
20886 $prevtrkey = $trkey;
20887 $table_el = $dom[($dom[$key]['parent
'])];
20891 foreach ($table_el['trids
'] as $j => $trkey) {
20892 $parent = $dom[$trkey];
20893 if (!isset($xmax)) {
20894 $xmax = $parent['cellpos
'][(count($parent['cellpos
']) - 1)]['endx
'];
20896 // for each cell on the row
20897 foreach ($parent['cellpos
'] as $k => $cellpos) {
20898 if (isset($cellpos['rowspanid
']) AND ($cellpos['rowspanid
'] >= 0)) {
20899 $cellpos['startx
'] = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startx
'];
20900 $cellpos['endx
'] = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endx
'];
20901 $endy = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endy
'];
20902 $startpage = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startpage
'];
20903 $endpage = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endpage
'];
20904 $startcolumn = $table_el['rowspans
'][($cellpos['rowspanid
'])]['startcolumn
'];
20905 $endcolumn = $table_el['rowspans
'][($cellpos['rowspanid
'])]['endcolumn
'];
20907 $endy = $parent['endy
'];
20908 $startpage = $parent['startpage
'];
20909 $endpage = $parent['endpage
'];
20910 $startcolumn = $parent['startcolumn
'];
20911 $endcolumn = $parent['endcolumn
'];
20913 if ($this->num_columns == 0) {
20914 $this->num_columns = 1;
20916 if (isset($cellpos['border
'])) {
20917 $border = $cellpos['border
'];
20919 if (isset($cellpos['bgcolor
']) AND ($cellpos['bgcolor
']) !== false) {
20920 $this->SetFillColorArray($cellpos['bgcolor
']);
20925 $x = $cellpos['startx
'];
20926 $y = $parent['starty
'];
20928 $w = abs($cellpos['endx
'] - $cellpos['startx
']);
20929 // get border modes
20930 $border_start = $this->getBorderMode($border, $position='start
');
20931 $border_end = $this->getBorderMode($border, $position='end
');
20932 $border_middle = $this->getBorderMode($border, $position='middle
');
20933 // design borders around HTML cells.
20934 for ($page = $startpage; $page <= $endpage; ++$page) { // for each page
20936 $this->setPage($page);
20937 if ($this->num_columns < 2) {
20938 // single-column mode
20940 $this->y = $this->tMargin;
20942 // account for margin changes
20943 if ($page > $startpage) {
20944 if (($this->rtl) AND ($this->pagedim[$page]['orm
'] != $this->pagedim[$startpage]['orm
'])) {
20945 $this->x -= ($this->pagedim[$page]['orm
'] - $this->pagedim[$startpage]['orm
']);
20946 } elseif ((!$this->rtl) AND ($this->pagedim[$page]['olm
'] != $this->pagedim[$startpage]['olm
'])) {
20947 $this->x += ($this->pagedim[$page]['olm
'] - $this->pagedim[$startpage]['olm
']);
20950 if ($startpage == $endpage) { // single page
20953 for ($column = $startcolumn; $column <= $endcolumn; ++$column) { // for each column
20954 $this->selectColumn($column);
20955 if ($startcolumn == $endcolumn) { // single column
20956 $cborder = $border;
20957 $h = $endy - $parent['starty
'];
20960 } elseif ($column == $startcolumn) { // first column
20961 $cborder = $border_start;
20962 $this->y = $starty;
20964 $h = $this->h - $this->y - $this->bMargin;
20966 $deltacol = $this->x + $this->rMargin - $this->w;
20968 $deltacol = $this->x - $this->lMargin;
20970 } elseif ($column == $endcolumn) { // end column
20971 $cborder = $border_end;
20972 if (isset($this->columns[$column]['th
']['\
''.$page.
'\''])) {
20973 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
20975 $this->x += $deltacol;
20978 $cborder = $border_middle;
20979 if (isset($this->columns[$column][
'th'][
'\''.$page.
'\''])) {
20980 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
20982 $this->x += $deltacol;
20983 $h = $this->h - $this->y - $this->bMargin;
20985 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
20987 } elseif ($page == $startpage) {
20990 for ($column = $startcolumn; $column < $this->num_columns; ++$column) {
20991 $this->selectColumn($column);
20992 if ($column == $startcolumn) {
20993 $cborder = $border_start;
20994 $this->y = $starty;
20996 $h = $this->h - $this->y - $this->bMargin;
20998 $deltacol = $this->x + $this->rMargin - $this->w;
21000 $deltacol = $this->x - $this->lMargin;
21003 $cborder = $border_middle;
21004 if (isset($this->columns[$column][
'th'][
'\''.$page.
'\''])) {
21005 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
21007 $this->x += $deltacol;
21008 $h = $this->h - $this->y - $this->bMargin;
21010 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
21012 } elseif ($page == $endpage) {
21015 for ($column = 0; $column <= $endcolumn; ++$column) {
21016 $this->selectColumn($column);
21017 if ($column == $endcolumn) {
21018 $cborder = $border_end;
21019 if (isset($this->columns[$column][
'th'][
'\''.$page.
'\''])) {
21020 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
21022 $this->x += $deltacol;
21025 $cborder = $border_middle;
21026 if (isset($this->columns[$column][
'th'][
'\''.$page.
'\''])) {
21027 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
21029 $this->x += $deltacol;
21030 $h = $this->h - $this->y - $this->bMargin;
21032 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
21037 for ($column = 0; $column < $this->num_columns; ++$column) {
21038 $this->selectColumn($column);
21039 $cborder = $border_middle;
21040 if (isset($this->columns[$column][
'th'][
'\''.$page.
'\''])) {
21041 $this->y = $this->columns[$column][
'th'][
'\''.$page.
'\''];
21043 $this->x += $deltacol;
21044 $h = $this->h - $this->y - $this->bMargin;
21045 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
21048 if ($cborder OR $fill) {
21050 if ($this->inxobj) {
21052 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
21053 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
21054 $pagemark = &$this->xobjects[$this->xobjid][
'transfmrk'][$pagemarkkey];
21056 $pagemark = &$this->xobjects[$this->xobjid][
'intmrk'];
21058 $pagebuff = $this->xobjects[$this->xobjid][
'outdata'];
21059 $pstart = substr($pagebuff, 0, $pagemark);
21060 $pend = substr($pagebuff, $pagemark);
21061 $this->xobjects[$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
21062 $pagemark += strlen($ccode);
21065 if (end($this->transfmrk[$this->page]) !==
false) {
21066 $pagemarkkey = key($this->transfmrk[$this->page]);
21067 $pagemark = &$this->transfmrk[$this->page][$pagemarkkey];
21068 } elseif ($this->InFooter) {
21069 $pagemark = &$this->footerpos[$this->page];
21071 $pagemark = &$this->intmrk[$this->page];
21073 $pagebuff = $this->getPageBuffer($this->page);
21074 $pstart = substr($pagebuff, 0, $pagemark);
21075 $pend = substr($pagebuff, $pagemark);
21076 $this->setPageBuffer($this->page, $pstart.$ccode.$pend);
21077 $pagemark += strlen($ccode);
21082 $border = $default_border;
21084 if (isset($table_el[
'attribute'][
'cellspacing'])) {
21085 $cellspacing = $this->getHTMLUnitToUnits($table_el[
'attribute'][
'cellspacing'], 1,
'px');
21086 $this->y += $cellspacing;
21088 $this->Ln(0, $cell);
21089 $this->x = $parent[
'startx'];
21090 if ($endpage > $startpage) {
21091 if (($this->rtl) AND ($this->pagedim[$endpage][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
21092 $this->x += ($this->pagedim[$endpage][
'orm'] - $this->pagedim[$startpage][
'orm']);
21093 } elseif ((!$this->rtl) AND ($this->pagedim[$endpage][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
21094 $this->x += ($this->pagedim[$endpage][
'olm'] - $this->pagedim[$startpage][
'olm']);
21098 if (!$in_table_head) {
21099 $this->cell_padding = $table_el[
'old_cell_padding'];
21101 $this->resetLastH();
21102 if (($this->page == ($this->numpages - 1)) AND ($this->pageopen[$this->numpages]) AND ($this->emptypagemrk[$this->numpages] == $this->pagelen[$this->numpages])) {
21104 $this->deletePage($this->numpages);
21106 if (isset($this->theadMargins[
'top'])) {
21108 $this->tMargin = $this->theadMargins[
'top'];
21109 $this->pagedim[$this->page][
'tm'] = $this->tMargin;
21111 if (!isset($table_el[
'attribute'][
'nested']) OR ($table_el[
'attribute'][
'nested'] !=
'true')) {
21114 $this->theadMargins = array();
21117 $parent = $table_el;
21125 $this->SetXY($this->GetX(), $this->GetY() + ((0.7 * $parent[
'fontsize']) / $this->k));
21129 $this->SetXY($this->GetX(), $this->GetY() - ((0.3 * $parent[
'fontsize'])/$this->k));
21133 $this->addHTMLVertSpace($hbz, 0, $cell,
false, $lasttag);
21136 case 'blockquote': {
21138 $this->rMargin -= $this->listindent;
21140 $this->lMargin -= $this->listindent;
21142 --$this->listindentlevel;
21143 $this->addHTMLVertSpace($hbz, $hb, $cell,
false, $lasttag);
21147 $this->addHTMLVertSpace($hbz, $hb, $cell,
false, $lasttag);
21151 $this->addHTMLVertSpace($hbz, $hb, $cell,
false, $lasttag);
21152 $this->premode =
false;
21157 if ($this->listnum <= 0) {
21158 $this->listnum = 0;
21159 $this->addHTMLVertSpace($hbz, $hb, $cell,
false, $lasttag);
21161 $this->addHTMLVertSpace(0, 0, $cell,
false, $lasttag);
21163 $this->resetLastH();
21167 $this->lispacer =
'';
21168 $this->addHTMLVertSpace(0, 0, $cell,
false, $lasttag);
21172 $this->lispacer =
'';
21174 $this->rMargin -= $this->listindent;
21176 $this->lMargin -= $this->listindent;
21178 --$this->listindentlevel;
21179 $this->addHTMLVertSpace(0, 0, $cell,
false, $lasttag);
21185 $this->lispacer =
'';
21187 $this->rMargin -= $this->listindent;
21189 $this->lMargin -= $this->listindent;
21191 --$this->listindentlevel;
21192 if ($this->listnum <= 0) {
21193 $this->listnum = 0;
21194 $this->addHTMLVertSpace($hbz, $hb, $cell,
false, $lasttag);
21196 $this->addHTMLVertSpace(0, 0, $cell,
false, $lasttag);
21198 $this->resetLastH();
21202 $this->lispacer =
'';
21203 $this->addHTMLVertSpace(0, 0, $cell,
false, $lasttag);
21212 $this->addHTMLVertSpace($hbz, $hb, $cell,
false, $lasttag);
21217 $this->form_action =
'';
21218 $this->form_enctype =
'application/x-www-form-urlencoded';
21226 $this->drawHTMLTagBorder($parent, $xmax);
21227 if (isset($dom[($dom[$key][
'parent'])][
'attribute'][
'pagebreakafter'])) {
21228 $pba = $dom[($dom[$key][
'parent'])][
'attribute'][
'pagebreakafter'];
21230 if (($pba ==
'true') OR ($pba ==
'left') OR ($pba == 'right')) {
21232 $this->checkPageBreak($this->PageBreakTrigger + 1);
21234 if ((($pba ==
'left') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
21235 OR (($pba ==
'right') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
21237 $this->checkPageBreak($this->PageBreakTrigger + 1);
21240 $this->tmprtl =
false;
21254 $this->Ln(0, $cell);
21255 $this->htmlvspace = 0;
21259 $this->Ln($hbz, $cell);
21260 $this->htmlvspace = 0;
21263 if ($hb < $this->htmlvspace) {
21266 $hd = $hb - $this->htmlvspace;
21267 $this->htmlvspace = $hb;
21269 $this->Ln(($hbz + $hd), $cell);
21280 $xmax = $this->lMargin;
21282 $xmax = $this->w - $this->rMargin;
21284 return array(
'page' => $this->page,
'column' => $this->current_column,
'x' => $this->x,
'y' => $this->y,
'xmax' => $xmax);
21295 if (!isset($tag[
'borderposition'])) {
21301 $prev_lasth = $this->lasth;
21305 if (isset($tag[
'border']) AND !empty($tag[
'border'])) {
21307 $border = $tag[
'border'];
21308 if (!$this->empty_string($this->thead) AND (!$this->inthead)) {
21310 $border = $this->getBorderMode($border, $position=
'middle');
21313 if (isset($tag[
'bgcolor']) AND ($tag[
'bgcolor'] !==
false)) {
21315 $old_bgcolor = $this->bgcolor;
21316 $this->SetFillColorArray($tag[
'bgcolor']);
21319 if (!$border AND !$fill) {
21323 if (isset($tag[
'attribute'][
'cellspacing'])) {
21324 $cellspacing = $this->getHTMLUnitToUnits($tag[
'attribute'][
'cellspacing'], 1,
'px');
21328 if (($tag[
'value'] !=
'table') AND (is_array($border)) AND (!empty($border))) {
21330 $border[
'mode'] =
'ext';
21333 if ($xmax >= $tag[
'borderposition'][
'x']) {
21334 $xmax = $tag[
'borderposition'][
'xmax'];
21336 $w = ($tag[
'borderposition'][
'x'] - $xmax);
21338 if ($xmax <= $tag[
'borderposition'][
'x']) {
21339 $xmax = $tag[
'borderposition'][
'xmax'];
21341 $w = ($xmax - $tag[
'borderposition'][
'x']);
21346 $w += $cellspacing;
21347 $startpage = $tag[
'borderposition'][
'page'];
21348 $startcolumn = $tag[
'borderposition'][
'column'];
21349 $x = $tag[
'borderposition'][
'x'];
21350 $y = $tag[
'borderposition'][
'y'];
21351 $endpage = $this->page;
21352 $starty = $tag[
'borderposition'][
'y'] - $cellspacing;
21356 $endcolumn = $this->current_column;
21357 if ($this->num_columns == 0) {
21358 $this->num_columns = 1;
21361 $border_start = $this->getBorderMode($border, $position=
'start');
21362 $border_end = $this->getBorderMode($border, $position=
'end');
21363 $border_middle = $this->getBorderMode($border, $position=
'middle');
21365 for ($page = $startpage; $page <= $endpage; ++$page) {
21367 $this->setPage($page);
21368 if ($this->num_columns < 2) {
21371 $this->y = $this->tMargin;
21374 if ($page > $startpage) {
21375 if (($this->rtl) AND ($this->pagedim[$page][
'orm'] != $this->pagedim[$startpage][
'orm'])) {
21376 $this->x -= ($this->pagedim[$page][
'orm'] - $this->pagedim[$startpage][
'orm']);
21377 } elseif ((!$this->rtl) AND ($this->pagedim[$page][
'olm'] != $this->pagedim[$startpage][
'olm'])) {
21378 $this->x += ($this->pagedim[$page][
'olm'] - $this->pagedim[$startpage][
'olm']);
21381 if ($startpage == $endpage) {
21383 for ($column = $startcolumn; $column <= $endcolumn; ++$column) {
21384 $this->selectColumn($column);
21385 if ($startcolumn == $endcolumn) {
21386 $cborder = $border;
21387 $h = ($currentY -
$y) + $cellspacing;
21388 $this->y = $starty;
21389 } elseif ($column == $startcolumn) {
21390 $cborder = $border_start;
21391 $this->y = $starty;
21392 $h = $this->h - $this->y - $this->bMargin;
21393 } elseif ($column == $endcolumn) {
21394 $cborder = $border_end;
21397 $cborder = $border_middle;
21398 $h = $this->h - $this->y - $this->bMargin;
21400 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
21402 } elseif ($page == $startpage) {
21403 for ($column = $startcolumn; $column < $this->num_columns; ++$column) {
21404 $this->selectColumn($column);
21405 if ($column == $startcolumn) {
21406 $cborder = $border_start;
21407 $this->y = $starty;
21408 $h = $this->h - $this->y - $this->bMargin;
21410 $cborder = $border_middle;
21411 $h = $this->h - $this->y - $this->bMargin;
21413 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
21415 } elseif ($page == $endpage) {
21416 for ($column = 0; $column <= $endcolumn; ++$column) {
21417 $this->selectColumn($column);
21418 if ($column == $endcolumn) {
21420 $cborder = $border_end;
21424 $cborder = $border_middle;
21425 $h = $this->h - $this->y - $this->bMargin;
21427 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
21430 for ($column = 0; $column < $this->num_columns; ++$column) {
21431 $this->selectColumn($column);
21432 $cborder = $border_middle;
21433 $h = $this->h - $this->y - $this->bMargin;
21434 $ccode .= $this->getCellCode($w, $h,
'', $cborder, 1,
'', $fill,
'', 0,
true).
"\n";
21437 if ($cborder OR $fill) {
21439 if ($this->inxobj) {
21441 if (end($this->xobjects[$this->xobjid][
'transfmrk']) !==
false) {
21442 $pagemarkkey = key($this->xobjects[$this->xobjid][
'transfmrk']);
21443 $pagemark = &$this->xobjects[$this->xobjid][
'transfmrk'][$pagemarkkey];
21445 $pagemark = &$this->xobjects[$this->xobjid][
'intmrk'];
21447 $pagebuff = $this->xobjects[$this->xobjid][
'outdata'];
21448 $pstart = substr($pagebuff, 0, $pagemark);
21449 $pend = substr($pagebuff, $pagemark);
21450 $this->xobjects[$this->xobjid][
'outdata'] = $pstart.$ccode.$pend;
21451 $pagemark += strlen($ccode);
21453 if (end($this->transfmrk[$this->page]) !==
false) {
21454 $pagemarkkey = key($this->transfmrk[$this->page]);
21455 $pagemark = &$this->transfmrk[$this->page][$pagemarkkey];
21456 } elseif ($this->InFooter) {
21457 $pagemark = &$this->footerpos[$this->page];
21459 $pagemark = &$this->intmrk[$this->page];
21461 $pagebuff = $this->getPageBuffer($this->page);
21462 $pstart = substr($pagebuff, 0, $this->bordermrk[$this->page]);
21463 $pend = substr($pagebuff, $this->bordermrk[$this->page]);
21464 $this->setPageBuffer($this->page, $pstart.$ccode.$pend);
21465 $offsetlen = strlen($ccode);
21466 $this->bordermrk[$this->page] += $offsetlen;
21467 $this->cntmrk[$this->page] += $offsetlen;
21468 $pagemark += $offsetlen;
21472 if (isset($old_bgcolor)) {
21474 $this->SetFillColorArray($old_bgcolor);
21477 $this->x = $prev_x;
21478 $this->y = $prev_y;
21479 $this->lasth = $prev_lasth;
21489 $symbol = strtolower($symbol);
21498 case 'decimal-leading-zero':
21500 case 'lower-roman':
21502 case 'upper-roman':
21504 case 'lower-alpha':
21505 case 'lower-latin':
21507 case 'upper-alpha':
21508 case 'upper-latin':
21509 case 'lower-greek': {
21510 $this->lisymbol = $symbol;
21514 $this->lisymbol =
'';
21528 $this->booklet = $booklet;
21530 $this->lMargin = $inner;
21533 $this->rMargin = $outer;
21546 $mtemp = $this->original_lMargin;
21547 $this->original_lMargin = $this->original_rMargin;
21548 $this->original_rMargin = $mtemp;
21549 $deltam = $this->original_lMargin - $this->original_rMargin;
21550 $this->lMargin += $deltam;
21551 $this->rMargin -= $deltam;
21568 $this->tagvspaces = $tagvs;
21578 return $this->customlistindent = floatval($width);
21588 $this->opencell = $isopen;
21599 $this->htmlLinkColorArray = $color;
21600 $this->htmlLinkFontStyle = $fontstyle;
21614 $supportedunits = array(
'%',
'em',
'ex',
'px',
'in',
'cm',
'mm',
'pc',
'pt');
21622 if (in_array($defaultunit, $supportedunits)) {
21623 $unit = $defaultunit;
21625 if (is_numeric($htmlval)) {
21626 $value = floatval($htmlval);
21627 } elseif (preg_match(
'/([0-9\.\-\+]+)/', $htmlval, $mnum)) {
21628 $value = floatval($mnum[1]);
21629 if (preg_match(
'/([a-z%]+)/', $htmlval, $munit)) {
21630 if (in_array($munit[1], $supportedunits)) {
21638 $retval = (($value * $refsize) / 100);
21643 $retval = ($value * $refsize);
21648 $retval = $value * ($refsize / 2);
21653 $retval = ($value * $this->dpi) / $k;
21658 $retval = ($value / 2.54 * $this->dpi) / $k;
21663 $retval = ($value / 25.4 * $this->dpi) / $k;
21668 $retval = ($value * 12) / $k;
21673 $retval = $value / $k;
21678 $retval = $this->pixelsToUnits($value);
21694 while ($number >= 1000) {
21698 while ($number >= 900) {
21702 while ($number >= 500) {
21706 while ($number >= 400) {
21710 while ($number >= 100) {
21714 while ($number >= 90) {
21718 while ($number >= 50) {
21722 while ($number >= 40) {
21726 while ($number >= 10) {
21730 while ($number >= 9) {
21734 while ($number >= 5) {
21738 while ($number >= 4) {
21742 while ($number >= 1) {
21760 $color = $this->fgcolor;
21764 $lspace = $this->GetStringWidth(
' ');
21765 if ($listtype ==
'^') {
21767 $this->lispacer =
'';
21769 } elseif ($listtype ==
'!') {
21771 $deftypes = array(
'disc',
'circle',
'square');
21772 $listtype = $deftypes[($listdepth - 1) % 3];
21773 } elseif ($listtype ==
'#') {
21775 $listtype =
'decimal';
21777 switch ($listtype) {
21788 $lspace += (2 * $r);
21790 $this->x += $lspace;
21792 $this->x -= $lspace;
21794 $this->Circle(($this->x + $r), ($this->y + ($this->lasth / 2)), $r, 0, 360, $fill, array(
'color'=>$color), $color, 8);
21801 $this->x += $lspace;
21803 $this->x -= $lspace;
21805 $this->Rect($this->x, ($this->y + (($this->lasth -
$l)/ 2)),
$l,
$l,
'F', array(), $color);
21813 $textitem = $this->listcount[$this->listnum];
21816 case 'decimal-leading-zero': {
21817 $textitem = sprintf(
'%02d', $this->listcount[$this->listnum]);
21821 case 'lower-roman': {
21822 $textitem = strtolower($this->intToRoman($this->listcount[$this->listnum]));
21826 case 'upper-roman': {
21827 $textitem = $this->intToRoman($this->listcount[$this->listnum]);
21831 case 'lower-alpha':
21832 case 'lower-latin': {
21833 $textitem = chr(97 + $this->listcount[$this->listnum] - 1);
21837 case 'upper-alpha':
21838 case 'upper-latin': {
21839 $textitem = chr(65 + $this->listcount[$this->listnum] - 1);
21842 case 'lower-greek': {
21843 $textitem = $this->unichr(945 + $this->listcount[$this->listnum] - 1);
21874 $textitem = $this->listcount[$this->listnum];
21877 if (!$this->empty_string($textitem)) {
21880 $textitem =
'.'.$textitem;
21882 $textitem = $textitem.
'.';
21884 $lspace += $this->GetStringWidth($textitem);
21886 $this->x += $lspace;
21888 $this->x -= $lspace;
21890 $this->Write($this->lasth, $textitem,
'',
false,
'',
false, 0,
false);
21893 $this->lispacer =
'^';
21904 'FontFamily' => $this->FontFamily,
21905 'FontStyle' => $this->FontStyle,
21906 'FontSizePt' => $this->FontSizePt,
21907 'rMargin' => $this->rMargin,
21908 'lMargin' => $this->lMargin,
21909 'cell_padding' => $this->cell_padding,
21910 'cell_margin' => $this->cell_margin,
21911 'LineWidth' => $this->LineWidth,
21912 'linestyleWidth' => $this->linestyleWidth,
21913 'linestyleCap' => $this->linestyleCap,
21914 'linestyleJoin' => $this->linestyleJoin,
21915 'linestyleDash' => $this->linestyleDash,
21916 'textrendermode' => $this->textrendermode,
21917 'textstrokewidth' => $this->textstrokewidth,
21918 'DrawColor' => $this->DrawColor,
21919 'FillColor' => $this->FillColor,
21920 'TextColor' => $this->TextColor,
21921 'ColorFlag' => $this->ColorFlag,
21922 'bgcolor' => $this->bgcolor,
21923 'fgcolor' => $this->fgcolor,
21924 'htmlvspace' => $this->htmlvspace,
21925 'listindent' => $this->listindent,
21926 'listindentlevel' => $this->listindentlevel,
21927 'listnum' => $this->listnum,
21928 'listordered' => $this->listordered,
21929 'listcount' => $this->listcount,
21930 'lispacer' => $this->lispacer,
21931 'cell_height_ratio' => $this->cell_height_ratio,
21932 'font_stretching' => $this->font_stretching,
21933 'font_spacing' => $this->font_spacing,
21935 'lasth' => $this->lasth,
21936 'tMargin' => $this->tMargin,
21937 'bMargin' => $this->bMargin,
21938 'AutoPageBreak' => $this->AutoPageBreak,
21939 'PageBreakTrigger' => $this->PageBreakTrigger,
21944 'wPt' => $this->wPt,
21945 'hPt' => $this->hPt,
21946 'fwPt' => $this->fwPt,
21947 'fhPt' => $this->fhPt,
21948 'page' => $this->page,
21949 'current_column' => $this->current_column,
21950 'num_columns' => $this->num_columns
21963 $this->FontFamily = $gvars[
'FontFamily'];
21964 $this->FontStyle = $gvars[
'FontStyle'];
21965 $this->FontSizePt = $gvars[
'FontSizePt'];
21966 $this->rMargin = $gvars[
'rMargin'];
21967 $this->lMargin = $gvars[
'lMargin'];
21968 $this->cell_padding = $gvars[
'cell_padding'];
21969 $this->cell_margin = $gvars[
'cell_margin'];
21970 $this->LineWidth = $gvars[
'LineWidth'];
21971 $this->linestyleWidth = $gvars[
'linestyleWidth'];
21972 $this->linestyleCap = $gvars[
'linestyleCap'];
21973 $this->linestyleJoin = $gvars[
'linestyleJoin'];
21974 $this->linestyleDash = $gvars[
'linestyleDash'];
21975 $this->textrendermode = $gvars[
'textrendermode'];
21976 $this->textstrokewidth = $gvars[
'textstrokewidth'];
21977 $this->DrawColor = $gvars[
'DrawColor'];
21978 $this->FillColor = $gvars[
'FillColor'];
21979 $this->TextColor = $gvars[
'TextColor'];
21980 $this->ColorFlag = $gvars[
'ColorFlag'];
21981 $this->bgcolor = $gvars[
'bgcolor'];
21982 $this->fgcolor = $gvars[
'fgcolor'];
21983 $this->htmlvspace = $gvars[
'htmlvspace'];
21984 $this->listindent = $gvars[
'listindent'];
21985 $this->listindentlevel = $gvars[
'listindentlevel'];
21986 $this->listnum = $gvars[
'listnum'];
21987 $this->listordered = $gvars[
'listordered'];
21988 $this->listcount = $gvars[
'listcount'];
21989 $this->lispacer = $gvars[
'lispacer'];
21990 $this->cell_height_ratio = $gvars[
'cell_height_ratio'];
21991 $this->font_stretching = $gvars[
'font_stretching'];
21992 $this->font_spacing = $gvars[
'font_spacing'];
21995 $this->lasth = $gvars[
'lasth'];
21996 $this->tMargin = $gvars[
'tMargin'];
21997 $this->bMargin = $gvars[
'bMargin'];
21998 $this->AutoPageBreak = $gvars[
'AutoPageBreak'];
21999 $this->PageBreakTrigger = $gvars[
'PageBreakTrigger'];
22000 $this->x = $gvars[
'x'];
22001 $this->y = $gvars[
'y'];
22002 $this->w = $gvars[
'w'];
22003 $this->h = $gvars[
'h'];
22004 $this->wPt = $gvars[
'wPt'];
22005 $this->hPt = $gvars[
'hPt'];
22006 $this->fwPt = $gvars[
'fwPt'];
22007 $this->fhPt = $gvars[
'fhPt'];
22008 $this->page = $gvars[
'page'];
22009 $this->current_column = $gvars[
'current_column'];
22010 $this->num_columns = $gvars[
'num_columns'];
22012 $this->_out(
''.$this->linestyleWidth.
' '.$this->linestyleCap.
' '.$this->linestyleJoin.
' '.$this->linestyleDash.
' '.$this->DrawColor.
' '.$this->FillColor.
'');
22013 if (!$this->empty_string($this->FontFamily)) {
22014 $this->SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
22045 $this->Error(
'Unable to write cache file: '.
$filename);
22051 if (!isset($this->cache_file_length[
'_'.
$filename])) {
22052 $this->cache_file_length[
'_'.$filename] = strlen(
$data);
22054 $this->cache_file_length[
'_'.$filename] += strlen(
$data);
22076 $this->bufferlen += strlen(
$data);
22077 if ($this->diskcache) {
22078 if (!isset($this->buffer) OR $this->empty_string($this->buffer)) {
22079 $this->buffer = $this->getObjFilename(
'buffer');
22081 $this->writeDiskCache($this->buffer,
$data,
true);
22083 $this->buffer .=
$data;
22094 $this->bufferlen = strlen(
$data);
22095 if ($this->diskcache) {
22096 if (!isset($this->buffer) OR $this->empty_string($this->buffer)) {
22097 $this->buffer = $this->getObjFilename(
'buffer');
22099 $this->writeDiskCache($this->buffer,
$data,
false);
22101 $this->buffer =
$data;
22112 if ($this->diskcache) {
22113 return $this->readDiskCache($this->buffer);
22115 return $this->buffer;
22128 if ($this->diskcache) {
22129 if (!isset($this->pages[$page])) {
22130 $this->pages[$page] = $this->getObjFilename(
'page'.$page);
22132 $this->writeDiskCache($this->pages[$page],
$data, $append);
22135 $this->pages[$page] .=
$data;
22137 $this->pages[$page] =
$data;
22140 if ($append AND isset($this->pagelen[$page])) {
22141 $this->pagelen[$page] += strlen(
$data);
22143 $this->pagelen[$page] = strlen(
$data);
22155 if ($this->diskcache) {
22156 return $this->readDiskCache($this->pages[$page]);
22157 } elseif (isset($this->pages[$page])) {
22158 return $this->pages[$page];
22171 if ($this->diskcache) {
22172 if (!isset($this->images[$image])) {
22173 $this->images[$image] = $this->getObjFilename(
'image'.$image);
22175 $this->writeDiskCache($this->images[$image], serialize(
$data));
22177 $this->images[$image] =
$data;
22179 if (!in_array($image, $this->imagekeys)) {
22180 $this->imagekeys[] = $image;
22181 ++$this->numimages;
22194 if (!isset($this->images[$image])) {
22195 $this->setImageBuffer($image, array());
22197 if ($this->diskcache) {
22198 $tmpimg = $this->getImageBuffer($image);
22199 $tmpimg[$key] =
$data;
22200 $this->writeDiskCache($this->images[$image], serialize($tmpimg));
22202 $this->images[$image][$key] =
$data;
22214 if ($this->diskcache AND isset($this->images[$image])) {
22215 return unserialize($this->readDiskCache($this->images[$image]));
22216 } elseif (isset($this->images[$image])) {
22217 return $this->images[$image];
22230 if ($this->diskcache) {
22231 if (!isset($this->fonts[$font])) {
22232 $this->fonts[$font] = $this->getObjFilename(
'font');
22234 $this->writeDiskCache($this->fonts[$font], serialize(
$data));
22236 $this->fonts[$font] =
$data;
22238 if (!in_array($font, $this->fontkeys)) {
22239 $this->fontkeys[] = $font;
22242 $this->font_obj_ids[$font] = $this->n;
22243 $this->setFontSubBuffer($font,
'n', $this->
n);
22256 if (!isset($this->fonts[$font])) {
22257 $this->setFontBuffer($font, array());
22259 if ($this->diskcache) {
22260 $tmpfont = $this->getFontBuffer($font);
22261 $tmpfont[$key] =
$data;
22262 $this->writeDiskCache($this->fonts[$font], serialize($tmpfont));
22264 $this->fonts[$font][$key] =
$data;
22276 if ($this->diskcache AND isset($this->fonts[$font])) {
22277 return unserialize($this->readDiskCache($this->fonts[$font]));
22278 } elseif (isset($this->fonts[$font])) {
22279 return $this->fonts[$font];
22293 if (($frompage > $this->numpages) OR ($frompage <= $topage)) {
22296 if ($frompage == $this->page) {
22301 $tmppage = $this->pages[$frompage];
22302 $tmppagedim = $this->pagedim[$frompage];
22303 $tmppagelen = $this->pagelen[$frompage];
22304 $tmpintmrk = $this->intmrk[$frompage];
22305 $tmpbordermrk = $this->bordermrk[$frompage];
22306 $tmpcntmrk = $this->cntmrk[$frompage];
22307 if (isset($this->footerpos[$frompage])) {
22308 $tmpfooterpos = $this->footerpos[$frompage];
22310 if (isset($this->footerlen[$frompage])) {
22311 $tmpfooterlen = $this->footerlen[$frompage];
22313 if (isset($this->transfmrk[$frompage])) {
22314 $tmptransfmrk = $this->transfmrk[$frompage];
22316 if (isset($this->PageAnnots[$frompage])) {
22317 $tmpannots = $this->PageAnnots[$frompage];
22319 if (isset($this->newpagegroup[$frompage])) {
22320 $tmpnewpagegroup = $this->newpagegroup[$frompage];
22322 for ($i = $frompage; $i > $topage; --$i) {
22325 $this->pages[$i] = $this->pages[$j];
22326 $this->pagedim[$i] = $this->pagedim[$j];
22327 $this->pagelen[$i] = $this->pagelen[$j];
22328 $this->intmrk[$i] = $this->intmrk[$j];
22329 $this->bordermrk[$i] = $this->bordermrk[$j];
22330 $this->cntmrk[$i] = $this->cntmrk[$j];
22331 if (isset($this->footerpos[$j])) {
22332 $this->footerpos[$i] = $this->footerpos[$j];
22333 } elseif (isset($this->footerpos[$i])) {
22334 unset($this->footerpos[$i]);
22336 if (isset($this->footerlen[$j])) {
22337 $this->footerlen[$i] = $this->footerlen[$j];
22338 } elseif (isset($this->footerlen[$i])) {
22339 unset($this->footerlen[$i]);
22341 if (isset($this->transfmrk[$j])) {
22342 $this->transfmrk[$i] = $this->transfmrk[$j];
22343 } elseif (isset($this->transfmrk[$i])) {
22344 unset($this->transfmrk[$i]);
22346 if (isset($this->PageAnnots[$j])) {
22347 $this->PageAnnots[$i] = $this->PageAnnots[$j];
22348 } elseif (isset($this->PageAnnots[$i])) {
22349 unset($this->PageAnnots[$i]);
22351 if (isset($this->newpagegroup[$j])) {
22352 $this->newpagegroup[$i] = $this->newpagegroup[$j];
22353 } elseif (isset($this->newpagegroup[$i])) {
22354 unset($this->newpagegroup[$i]);
22357 $this->pages[$topage] = $tmppage;
22358 $this->pagedim[$topage] = $tmppagedim;
22359 $this->pagelen[$topage] = $tmppagelen;
22360 $this->intmrk[$topage] = $tmpintmrk;
22361 $this->bordermrk[$topage] = $tmpbordermrk;
22362 $this->cntmrk[$topage] = $tmpcntmrk;
22363 if (isset($tmpfooterpos)) {
22364 $this->footerpos[$topage] = $tmpfooterpos;
22365 } elseif (isset($this->footerpos[$topage])) {
22366 unset($this->footerpos[$topage]);
22368 if (isset($tmpfooterlen)) {
22369 $this->footerlen[$topage] = $tmpfooterlen;
22370 } elseif (isset($this->footerlen[$topage])) {
22371 unset($this->footerlen[$topage]);
22373 if (isset($tmptransfmrk)) {
22374 $this->transfmrk[$topage] = $tmptransfmrk;
22375 } elseif (isset($this->transfmrk[$topage])) {
22376 unset($this->transfmrk[$topage]);
22378 if (isset($tmpannots)) {
22379 $this->PageAnnots[$topage] = $tmpannots;
22380 } elseif (isset($this->PageAnnots[$topage])) {
22381 unset($this->PageAnnots[$topage]);
22383 if (isset($tmpnewpagegroup)) {
22384 $this->newpagegroup[$topage] = $tmpnewpagegroup;
22385 } elseif (isset($this->newpagegroup[$topage])) {
22386 unset($this->newpagegroup[$topage]);
22389 $tmpoutlines = $this->outlines;
22390 foreach ($tmpoutlines as $key => $outline) {
22391 if (($outline[
'p'] >= $topage) AND ($outline[
'p'] < $frompage)) {
22392 $this->outlines[$key][
'p'] = $outline[
'p'] + 1;
22393 } elseif ($outline[
'p'] == $frompage) {
22394 $this->outlines[$key][
'p'] = $topage;
22398 $tmplinks = $this->links;
22399 foreach ($tmplinks as $key => $link) {
22400 if (($link[0] >= $topage) AND ($link[0] < $frompage)) {
22401 $this->links[$key][0] = $link[0] + 1;
22402 } elseif ($link[0] == $frompage) {
22403 $this->links[$key][0] = $topage;
22407 $tmpjavascript = $this->javascript;
22408 global $jfrompage, $jtopage;
22409 $jfrompage = $frompage;
22410 $jtopage = $topage;
22411 $this->javascript = preg_replace_callback(
'/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/',
22412 create_function(
'$matches',
'global $jfrompage, $jtopage;
22413 $pagenum = intval($matches[3]) + 1;
22414 if (($pagenum >= $jtopage) AND ($pagenum < $jfrompage)) {
22415 $newpage = ($pagenum + 1);
22416 } elseif ($pagenum == $jfrompage) {
22417 $newpage = $jtopage;
22419 $newpage = $pagenum;
22422 return "this.addField(\'".$matches[1]."\',\'".$matches[2]."\',".$newpage."";'), $tmpjavascript);
22424 $this->lastPage(
true);
22436 if (($page < 1) OR ($page > $this->numpages)) {
22440 unset($this->pages[$page]);
22441 unset($this->pagedim[$page]);
22442 unset($this->pagelen[$page]);
22443 unset($this->intmrk[$page]);
22444 unset($this->bordermrk[$page]);
22445 unset($this->cntmrk[$page]);
22446 if (isset($this->footerpos[$page])) {
22447 unset($this->footerpos[$page]);
22449 if (isset($this->footerlen[$page])) {
22450 unset($this->footerlen[$page]);
22452 if (isset($this->transfmrk[$page])) {
22453 unset($this->transfmrk[$page]);
22455 if (isset($this->PageAnnots[$page])) {
22456 unset($this->PageAnnots[$page]);
22458 if (isset($this->newpagegroup[$page])) {
22459 unset($this->newpagegroup[$page]);
22461 if (isset($this->pageopen[$page])) {
22462 unset($this->pageopen[$page]);
22465 for ($i = $page; $i < $this->numpages; ++$i) {
22468 $this->pages[$i] = $this->pages[$j];
22469 $this->pagedim[$i] = $this->pagedim[$j];
22470 $this->pagelen[$i] = $this->pagelen[$j];
22471 $this->intmrk[$i] = $this->intmrk[$j];
22472 $this->bordermrk[$i] = $this->bordermrk[$j];
22473 $this->cntmrk[$i] = $this->cntmrk[$j];
22474 if (isset($this->footerpos[$j])) {
22475 $this->footerpos[$i] = $this->footerpos[$j];
22476 } elseif (isset($this->footerpos[$i])) {
22477 unset($this->footerpos[$i]);
22479 if (isset($this->footerlen[$j])) {
22480 $this->footerlen[$i] = $this->footerlen[$j];
22481 } elseif (isset($this->footerlen[$i])) {
22482 unset($this->footerlen[$i]);
22484 if (isset($this->transfmrk[$j])) {
22485 $this->transfmrk[$i] = $this->transfmrk[$j];
22486 } elseif (isset($this->transfmrk[$i])) {
22487 unset($this->transfmrk[$i]);
22489 if (isset($this->PageAnnots[$j])) {
22490 $this->PageAnnots[$i] = $this->PageAnnots[$j];
22491 } elseif (isset($this->PageAnnots[$i])) {
22492 unset($this->PageAnnots[$i]);
22494 if (isset($this->newpagegroup[$j])) {
22495 $this->newpagegroup[$i] = $this->newpagegroup[$j];
22496 } elseif (isset($this->newpagegroup[$i])) {
22497 unset($this->newpagegroup[$i]);
22499 if (isset($this->pageopen[$j])) {
22500 $this->pageopen[$i] = $this->pageopen[$j];
22501 } elseif (isset($this->pageopen[$i])) {
22502 unset($this->pageopen[$i]);
22506 unset($this->pages[$this->numpages]);
22507 unset($this->pagedim[$this->numpages]);
22508 unset($this->pagelen[$this->numpages]);
22509 unset($this->intmrk[$this->numpages]);
22510 unset($this->bordermrk[$this->numpages]);
22511 unset($this->cntmrk[$this->numpages]);
22512 if (isset($this->footerpos[$this->numpages])) {
22513 unset($this->footerpos[$this->numpages]);
22515 if (isset($this->footerlen[$this->numpages])) {
22516 unset($this->footerlen[$this->numpages]);
22518 if (isset($this->transfmrk[$this->numpages])) {
22519 unset($this->transfmrk[$this->numpages]);
22521 if (isset($this->PageAnnots[$this->numpages])) {
22522 unset($this->PageAnnots[$this->numpages]);
22524 if (isset($this->newpagegroup[$this->numpages])) {
22525 unset($this->newpagegroup[$this->numpages]);
22527 if (isset($this->pageopen[$this->numpages])) {
22528 unset($this->pageopen[$this->numpages]);
22531 $this->page = $this->numpages;
22533 $tmpoutlines = $this->outlines;
22534 foreach ($tmpoutlines as $key => $outline) {
22535 if ($outline[
'p'] > $page) {
22536 $this->outlines[$key][
'p'] = $outline[
'p'] - 1;
22537 } elseif ($outline[
'p'] == $page) {
22538 unset($this->outlines[$key]);
22542 $tmplinks = $this->links;
22543 foreach ($tmplinks as $key => $link) {
22544 if ($link[0] > $page) {
22545 $this->links[$key][0] = $link[0] - 1;
22546 } elseif ($link[0] == $page) {
22547 unset($this->links[$key]);
22551 $tmpjavascript = $this->javascript;
22554 $this->javascript = preg_replace_callback(
'/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/',
22555 create_function(
'$matches',
'global $jpage;
22556 $pagenum = intval($matches[3]) + 1;
22557 if ($pagenum >= $jpage) {
22558 $newpage = ($pagenum - 1);
22559 } elseif ($pagenum == $jpage) {
22562 $newpage = $pagenum;
22565 return "this.addField(\'".$matches[1]."\',\'".$matches[2]."\',".$newpage."";'), $tmpjavascript);
22567 $this->lastPage(
true);
22581 $page = $this->page;
22583 if (($page < 1) OR ($page > $this->numpages)) {
22586 if ($page == $this->page) {
22592 $this->page = $this->numpages;
22593 $this->pages[$this->page] = $this->pages[$page];
22594 $this->pagedim[$this->page] = $this->pagedim[$page];
22595 $this->pagelen[$this->page] = $this->pagelen[$page];
22596 $this->intmrk[$this->page] = $this->intmrk[$page];
22597 $this->bordermrk[$this->page] = $this->bordermrk[$page];
22598 $this->cntmrk[$this->page] = $this->cntmrk[$page];
22599 $this->pageopen[$this->page] =
false;
22600 if (isset($this->footerpos[$page])) {
22601 $this->footerpos[$this->page] = $this->footerpos[$page];
22603 if (isset($this->footerlen[$page])) {
22604 $this->footerlen[$this->page] = $this->footerlen[$page];
22606 if (isset($this->transfmrk[$page])) {
22607 $this->transfmrk[$this->page] = $this->transfmrk[$page];
22609 if (isset($this->PageAnnots[$page])) {
22610 $this->PageAnnots[$this->page] = $this->PageAnnots[$page];
22612 if (isset($this->newpagegroup[$page])) {
22613 $this->newpagegroup[$this->page] = $this->newpagegroup[$page];
22616 $tmpoutlines = $this->outlines;
22617 foreach ($tmpoutlines as $key => $outline) {
22618 if ($outline[
'p'] == $page) {
22619 $this->outlines[] = array(
't' => $outline[
't'],
'l' => $outline[
'l'],
'y' => $outline[
'y'],
'p' => $this->page);
22623 $tmplinks = $this->links;
22624 foreach ($tmplinks as $key => $link) {
22625 if ($link[0] == $page) {
22626 $this->links[] = array($this->page, $link[1]);
22630 $this->lastPage(
true);
22648 public function addTOC($page=
'', $numbersfont=
'', $filler=
'.', $toc_name=
'TOC') {
22649 $fontsize = $this->FontSizePt;
22650 $fontfamily = $this->FontFamily;
22651 $fontstyle = $this->FontStyle;
22652 $w = $this->w - $this->lMargin - $this->rMargin;
22653 $spacer = $this->GetStringWidth(chr(32)) * 4;
22654 $page_first = $this->getPage();
22655 $lmargin = $this->lMargin;
22656 $rmargin = $this->rMargin;
22657 $x_start = $this->GetX();
22658 $current_page = $this->page;
22659 $current_column = $this->current_column;
22660 if ($this->empty_string($numbersfont)) {
22661 $numbersfont = $this->default_monospaced_font;
22663 if ($this->empty_string($filler)) {
22666 if ($this->empty_string($page)) {
22674 foreach ($this->outlines as $key => $outline) {
22682 if ($outline[
'l'] == 0) {
22683 $this->SetFont($fontfamily, $fontstyle.
'B', $fontsize);
22685 $this->SetFont($fontfamily, $fontstyle, $fontsize - $outline[
'l']);
22688 $this->checkPageBreak(($this->FontSize * $this->cell_height_ratio));
22690 if (($this->page == $current_page) AND ($this->current_column == $current_column)) {
22691 $this->lMargin = $lmargin;
22692 $this->rMargin = $rmargin;
22694 if ($this->current_column != $current_column) {
22696 $x_start = $this->w - $this->columns[$this->current_column][
'x'];
22698 $x_start = $this->columns[$this->current_column][
'x'];
22701 $lmargin = $this->lMargin;
22702 $rmargin = $this->rMargin;
22703 $current_page = $this->page;
22704 $current_column = $this->current_column;
22706 $this->SetX($x_start);
22707 $indent = ($spacer * $outline[
'l']);
22709 $this->rMargin += $indent;
22710 $this->x -= $indent;
22712 $this->lMargin += $indent;
22713 $this->x += $indent;
22715 $link = $this->AddLink();
22716 $this->SetLink($link, $outline[
'y'], $outline[
'p']);
22718 $this->Write(0, $outline[
't'], $link, 0, $aligntext,
false, 0,
false,
false, 0);
22719 $this->SetFont($numbersfont, $fontstyle, $fontsize);
22720 if ($this->empty_string($page)) {
22721 $pagenum = $outline[
'p'];
22724 $pagenum =
'{#'.($outline[
'p']).
'}';
22725 if ($this->isUnicodeFont()) {
22726 $pagenum =
'{'.$pagenum.
'}';
22729 $numwidth = $this->GetStringWidth($pagenum);
22731 $tw = $this->x - $this->lMargin;
22733 $tw = $this->w - $this->rMargin -
$this->x;
22735 $fw = $tw - $numwidth - $this->GetStringWidth(chr(32));
22736 $numfills = floor($fw / $this->GetStringWidth($filler));
22737 if ($numfills > 0) {
22738 $rowfill = str_repeat($filler, $numfills);
22743 $pagenum = $pagenum.$gap.$rowfill.
' ';
22745 $pagenum =
' '.$rowfill.$gap.$pagenum;
22748 $this->Cell($tw, 0, $pagenum, 0, 1, $alignnum, 0, $link, 0);
22750 $page_last = $this->getPage();
22751 $numpages = $page_last - $page_first + 1;
22752 if (!$this->empty_string($page)) {
22753 for ($p = $page_first; $p <= $page_last; ++$p) {
22755 $temppage = $this->getPageBuffer($p);
22756 for ($n = 1; $n <= $this->numpages; ++$n) {
22760 $alias_a = $this->_escape($k);
22761 $alias_au = $this->_escape($ku);
22762 if ($this->isunicode) {
22763 $alias_b = $this->_escape($this->UTF8ToLatin1($k));
22764 $alias_bu = $this->_escape($this->UTF8ToLatin1($ku));
22765 $alias_c = $this->_escape($this->utf8StrRev($k,
false, $this->tmprtl));
22766 $alias_cu = $this->_escape($this->utf8StrRev($ku,
false, $this->tmprtl));
22769 $np = $n + $numpages;
22773 $ns = $this->formatTOCPageNumber($np);
22775 $sdiff = strlen($k) - strlen($ns) - 1;
22776 $sdiffu = strlen($ku) - strlen($ns) - 1;
22777 $sfill = str_repeat($filler, $sdiff);
22778 $sfillu = str_repeat($filler, $sdiffu);
22780 $ns = $ns.
' '.$sfill;
22781 $nu = $nu.
' '.$sfillu;
22783 $ns = $sfill.
' '.$ns;
22784 $nu = $sfillu.
' '.$nu;
22786 $nu = $this->UTF8ToUTF16BE($nu,
false);
22787 $temppage = str_replace($alias_au, $nu, $temppage);
22788 if ($this->isunicode) {
22789 $temppage = str_replace($alias_bu, $nu, $temppage);
22790 $temppage = str_replace($alias_cu, $nu, $temppage);
22791 $temppage = str_replace($alias_b, $ns, $temppage);
22792 $temppage = str_replace($alias_c, $ns, $temppage);
22794 $temppage = str_replace($alias_a, $ns, $temppage);
22797 $this->setPageBuffer($p, $temppage);
22800 $this->Bookmark($toc_name, 0, 0, $page_first);
22801 for ($i = 0; $i < $numpages; ++$i) {
22802 $this->movePage($page_last, $page);
22820 public function addHTMLTOC($page=
'', $toc_name=
'TOC', $templates=array(), $correct_align=
true) {
22821 $prev_htmlLinkColorArray = $this->htmlLinkColorArray;
22822 $prev_htmlLinkFontStyle = $this->htmlLinkFontStyle;
22824 $this->htmlLinkColorArray = array();
22825 $this->htmlLinkFontStyle =
'';
22826 $page_first = $this->getPage();
22828 $current_font = $this->FontFamily;
22829 foreach ($templates as $level => $html) {
22830 $dom = $this->getHtmlDomArray($html);
22831 foreach ($dom as $key => $value) {
22832 if ($value[
'value'] ==
'#TOC_PAGE_NUMBER#') {
22833 $this->SetFont($dom[($key - 1)][
'fontname']);
22834 $templates[
'F'.$level] = $this->isUnicodeFont();
22838 $this->SetFont($current_font);
22839 foreach ($this->outlines as $key => $outline) {
22841 $row = $templates[$outline[
'l']];
22842 if ($this->empty_string($page)) {
22843 $pagenum = $outline[
'p'];
22846 $pagenum =
'{#'.($outline[
'p']).
'}';
22847 if ($templates[
'F'.$outline[
'l']]) {
22848 $pagenum =
'{'.$pagenum.
'}';
22852 $row = str_replace(
'#TOC_DESCRIPTION#', $outline[
't'],
$row);
22853 $row = str_replace(
'#TOC_PAGE_NUMBER#', $pagenum,
$row);
22855 $row =
'<a href="#'.$outline[
'p'].
','.$outline[
'y'].
'">'.
$row.
'</a>';
22857 $this->writeHTML(
$row,
false,
false,
true,
false,
'');
22860 $this->htmlLinkColorArray = $prev_htmlLinkColorArray;
22861 $this->htmlLinkFontStyle = $prev_htmlLinkFontStyle;
22863 $page_last = $this->getPage();
22864 $numpages = $page_last - $page_first + 1;
22865 if (!$this->empty_string($page)) {
22866 for ($p = $page_first; $p <= $page_last; ++$p) {
22868 $temppage = $this->getPageBuffer($p);
22869 for ($n = 1; $n <= $this->numpages; ++$n) {
22873 $alias_a = $this->_escape($k);
22874 $alias_au = $this->_escape(
'{'.$k.
'}');
22875 if ($this->isunicode) {
22876 $alias_b = $this->_escape($this->UTF8ToLatin1($k));
22877 $alias_bu = $this->_escape($this->UTF8ToLatin1($ku));
22878 $alias_c = $this->_escape($this->utf8StrRev($k,
false, $this->tmprtl));
22879 $alias_cu = $this->_escape($this->utf8StrRev($ku,
false, $this->tmprtl));
22882 $np = $n + $numpages;
22886 $ns = $this->formatTOCPageNumber($np);
22888 if ($correct_align) {
22889 $sdiff = strlen($k) - strlen($ns);
22890 $sdiffu = strlen($ku) - strlen($ns);
22891 $sfill = str_repeat(
' ', $sdiff);
22892 $sfillu = str_repeat(
' ', $sdiffu);
22901 $nu = $this->UTF8ToUTF16BE($nu,
false);
22902 $temppage = str_replace($alias_au, $nu, $temppage);
22903 if ($this->isunicode) {
22904 $temppage = str_replace($alias_bu, $nu, $temppage);
22905 $temppage = str_replace($alias_cu, $nu, $temppage);
22906 $temppage = str_replace($alias_b, $ns, $temppage);
22907 $temppage = str_replace($alias_c, $ns, $temppage);
22909 $temppage = str_replace($alias_a, $ns, $temppage);
22912 $this->setPageBuffer($p, $temppage);
22915 $this->Bookmark($toc_name, 0, 0, $page_first);
22916 for ($i = 0; $i < $numpages; ++$i) {
22917 $this->movePage($page_last, $page);
22928 if (isset($this->objcopy)) {
22930 $this->commitTransaction();
22933 $this->start_transaction_page = $this->page;
22934 $this->start_transaction_y =
$this->y;
22936 $this->objcopy = $this->objclone($this);
22945 if (isset($this->objcopy)) {
22946 $this->objcopy->_destroy(
true,
true);
22947 unset($this->objcopy);
22959 if (isset($this->objcopy)) {
22960 if (isset($this->objcopy->diskcache) AND $this->objcopy->diskcache) {
22962 foreach ($this->objcopy->cache_file_length as
$file => $length) {
22968 $this->_destroy(
true,
true);
22970 $objvars = get_object_vars($this->objcopy);
22971 foreach ($objvars as $key => $value) {
22972 $this->$key = $value;
22975 return $this->objcopy;
22988 return @clone($object);
22999 return (is_null($str) OR (is_string($str) AND (strlen($str) == 0)));
23012 $length = strlen($haystack);
23013 $offset = ($offset > 0)?($length - $offset):abs($offset);
23014 $pos = strpos(strrev($haystack), strrev($needle), $offset);
23015 return (
$pos ===
false)?
false:($length -
$pos - strlen($needle));
23029 $this->columns = array();
23030 if ($numcols < 2) {
23032 $this->columns = array();
23035 $maxwidth = ($this->w - $this->original_lMargin - $this->original_rMargin) / $numcols;
23036 if (($width == 0) OR ($width > $maxwidth)) {
23037 $width = $maxwidth;
23039 if ($this->empty_string(
$y)) {
23043 $space = (($this->w - $this->original_lMargin - $this->original_rMargin - ($numcols * $width)) / ($numcols - 1));
23045 for ($i = 0; $i < $numcols; ++$i) {
23046 $this->columns[$i] = array(
'w' => $width,
's' =>
$space,
'y' =>
$y);
23049 $this->num_columns = $numcols;
23050 $this->current_column = 0;
23051 $this->column_start_page = $this->page;
23062 $this->columns = $columns;
23063 $this->num_columns = count($columns);
23064 $this->current_column = 0;
23065 $this->column_start_page = $this->page;
23075 if (is_string($col)) {
23076 $col = $this->current_column;
23077 } elseif($col >= $this->num_columns) {
23081 $enable_thead =
false;
23082 if ($this->num_columns > 1) {
23083 if ($col != $this->current_column) {
23085 if ($this->column_start_page == $this->page) {
23086 $this->y = $this->columns[$col][
'y'];
23088 $this->y = $this->tMargin;
23091 if (($this->page > $this->maxselcol[
'page']) OR (($this->page == $this->maxselcol[
'page']) AND ($col > $this->maxselcol[
'column']))) {
23092 $enable_thead =
true;
23093 $this->maxselcol[
'page'] = $this->page;
23094 $this->maxselcol[
'column'] = $col;
23097 $xshift = $this->colxshift;
23099 $listindent = ($this->listindentlevel * $this->listindent);
23100 $colpos = ($col * ($this->columns[$col][
'w'] + $this->columns[$col][
's']));
23102 $x = $this->w - $this->original_rMargin - $colpos;
23103 $this->rMargin = ($this->w -
$x + $listindent);
23104 $this->lMargin = (
$x - $this->columns[$col][
'w']);
23105 $this->x =
$x - $listindent;
23107 $x = $this->original_lMargin + $colpos;
23108 $this->lMargin = (
$x + $listindent);
23109 $this->rMargin = ($this->w -
$x - $this->columns[$col][
'w']);
23110 $this->x =
$x + $listindent;
23112 $this->columns[$col][
'x'] =
$x;
23114 $this->current_column = $col;
23116 $this->newline =
true;
23118 if ((!$this->empty_string($this->thead)) AND (!$this->inthead)) {
23119 if ($enable_thead) {
23121 $this->writeHTML($this->thead,
false,
false,
false,
false,
'');
23122 $this->y += $xshift[
's'];
23124 if (!isset($this->columns[$col][
'th'])) {
23125 $this->columns[$col][
'th'] = array();
23127 $this->columns[$col][
'th'][
'\''.$this->page.
'\''] =
$this->y;
23129 } elseif (isset($this->columns[$col][
'th'][
'\''.$this->page.
'\''])) {
23130 $this->y = $this->columns[$col][
'th'][
'\''.$this->page.
'\''];
23135 $this->rMargin += $xshift[
'x'];
23136 $this->x -= ($xshift[
'x'] + $xshift[
'p']);
23138 $this->lMargin += $xshift[
'x'];
23139 $this->x += $xshift[
'x'] + $xshift[
'p'];
23150 return $this->current_column;
23160 return $this->num_columns;
23171 return urlencode(serialize($pararray));
23188 if ($fill ===
true) {
23190 if ($clip ===
true) {
23192 $textrendermode = 6;
23195 $textrendermode = 2;
23197 $textstrokewidth = $stroke;
23199 if ($clip ===
true) {
23201 $textrendermode = 4;
23204 $textrendermode = 0;
23209 if ($clip ===
true) {
23211 $textrendermode = 5;
23214 $textrendermode = 1;
23216 $textstrokewidth = $stroke;
23218 if ($clip ===
true) {
23220 $textrendermode = 7;
23223 $textrendermode = 3;
23227 $this->textrendermode = $textrendermode;
23228 $this->textstrokewidth = $stroke * $this->k;
23245 protected function hyphenateWord($word, $patterns, $dictionary=array(), $leftmin=1, $rightmin=2, $charmin=1, $charmax=8) {
23246 $hyphenword = array();
23247 $numchars = count($word);
23248 if ($numchars <= $charmin) {
23251 $word_string = $this->UTF8ArrSubString($word);
23253 $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})(\]?)$/';
23254 if (preg_match($pattern, $word_string) > 0) {
23258 $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})(\]?)$/';
23259 if (preg_match($pattern, $word_string) > 0) {
23263 if (isset($dictionary[$word_string])) {
23264 return $this->UTF8StringToArray($dictionary[$word_string]);
23267 $tmpword = array_merge(array(95), $word, array(95));
23268 $tmpnumchars = $numchars + 2;
23269 $maxpos = $tmpnumchars - $charmin;
23271 $imax = min(($tmpnumchars -
$pos), $charmax);
23272 for ($i = $charmin; $i <= $imax; ++$i) {
23273 $subword = strtolower($this->UTF8ArrSubString($tmpword,
$pos,
$pos + $i));
23274 if (isset($patterns[$subword])) {
23275 $pattern = $this->UTF8StringToArray($patterns[$subword]);
23276 $pattern_length = count($pattern);
23278 for ($j = 0; $j < $pattern_length; ++$j) {
23280 if (($pattern[$j] >= 48) AND ($pattern[$j] <= 57)) {
23284 $zero =
$pos + $j - $digits;
23286 if (!isset($hyphenword[$zero]) OR ($hyphenword[$zero] != $pattern[$j])) {
23287 $hyphenword[$zero] = $this->unichr($pattern[$j]);
23296 $maxpos = $numchars - $rightmin;
23297 for($i = $leftmin; $i <= $maxpos; ++$i) {
23298 if(isset($hyphenword[$i]) AND (($hyphenword[$i] % 2) != 0)) {
23300 array_splice($word, $i + $inserted, 0, 173);
23319 $patterns = array();
23321 $data = preg_replace(
'/\%[^\n]*/',
'',
$data);
23323 preg_match(
'/\\\\patterns\{([^\}]*)\}/i',
$data, $matches);
23324 $data = trim(substr($matches[0], 10, -1));
23326 $patterns_array = preg_split(
'/[\s]+/',
$data);
23328 $patterns = array();
23329 foreach($patterns_array as $val) {
23330 if (!$this->empty_string($val)) {
23332 $val = str_replace(
'\'',
'\\\'', $val);
23333 $key = preg_replace(
'/[0-9]+/',
'', $val);
23334 $patterns[$key] = $val;
23354 public function hyphenateText($text, $patterns, $dictionary=array(), $leftmin=1, $rightmin=2, $charmin=1, $charmax=8) {
23355 $text = $this->unhtmlentities($text);
23359 if (!is_array($patterns)) {
23360 $patterns = $this->getHyphenPatternsFromTEX($patterns);
23363 $unichars = $this->UTF8StringToArray($text);
23365 foreach ($unichars as $char) {
23366 if ((!$intag) AND $this->unicode->uni_type[$char] ==
'L') {
23371 if (!$this->empty_string($word)) {
23373 $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
23377 if (chr($char) ==
'<') {
23380 } elseif ($intag AND (chr($char) ==
'>')) {
23386 if (!$this->empty_string($word)) {
23388 $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
23391 return $this->UTF8ArrSubString($txtarr);
23401 $this->rasterize_vector_images = $mode;
23486 if (!empty($default)) {
23487 $op = $this->getPathPaintOperator($default,
'');
23504 $this->font_subsetting = $enable ?
true :
false;
23515 return $this->font_subsetting;
23528 return preg_replace(
'/^'.$this->re_space[
'p'].
'+/'.$this->re_space[
'm'], $replace, $str);
23541 return preg_replace(
'/'.$this->re_space[
'p'].
'+$/'.$this->re_space[
'm'], $replace, $str);
23554 $str = $this->stringLeftTrim($str, $replace);
23555 $str = $this->stringRightTrim($str, $replace);
23567 return (($this->CurrentFont[
'type'] ==
'TrueTypeUnicode') OR ($this->CurrentFont[
'type'] ==
'cidfont0'));
23580 $fontfamily = preg_replace(
'/[^a-z0-9\,]/',
'', strtolower($fontfamily));
23582 $fontslist = preg_split(
'/[,]/', $fontfamily);
23584 foreach ($fontslist as $font) {
23586 $font = preg_replace(
'/italic$/',
'I', $font);
23587 $font = preg_replace(
'/oblique$/',
'I', $font);
23588 $font = preg_replace(
'/bold([I]?)$/',
'B\\1', $font);
23590 $pattern = array();
23591 $replacement = array();
23592 $pattern[] =
'/^serif|^cursive|^fantasy|^timesnewroman/';
23593 $replacement[] =
'times';
23594 $pattern[] =
'/^sansserif/';
23595 $replacement[] =
'helvetica';
23596 $pattern[] =
'/^monospace/';
23597 $replacement[] =
'courier';
23598 $font = preg_replace($pattern, $replacement, $font);
23599 if (in_array(strtolower($font), $this->fontlist) OR in_array($font, $this->fontkeys)) {
23604 return $this->CurrentFont[
'fontkey'];
23621 if ($this->inxobj) {
23625 $this->inxobj =
true;
23628 $this->xobjid =
'XT'.$this->n;
23630 $this->xobjects[$this->xobjid] = array(
'n' => $this->
n);
23632 $this->xobjects[$this->xobjid][
'gvars'] = $this->getGraphicVars();
23634 $this->xobjects[$this->xobjid][
'intmrk'] = 0;
23635 $this->xobjects[$this->xobjid][
'transfmrk'] = array();
23636 $this->xobjects[$this->xobjid][
'outdata'] =
'';
23637 $this->xobjects[$this->xobjid][
'xobjects'] = array();
23638 $this->xobjects[$this->xobjid][
'images'] = array();
23639 $this->xobjects[$this->xobjid][
'fonts'] = array();
23640 $this->xobjects[$this->xobjid][
'annotations'] = array();
23642 $this->num_columns = 1;
23643 $this->current_column = 0;
23644 $this->SetAutoPageBreak(
false);
23645 if (($w ===
'') OR ($w <= 0)) {
23646 $w = $this->w - $this->lMargin - $this->rMargin;
23648 if (($h ===
'') OR ($h <= 0)) {
23649 $h = $this->h - $this->tMargin - $this->bMargin;
23651 $this->xobjects[$this->xobjid][
'x'] = 0;
23652 $this->xobjects[$this->xobjid][
'y'] = 0;
23653 $this->xobjects[$this->xobjid][
'w'] = $w;
23654 $this->xobjects[$this->xobjid][
'h'] = $h;
23657 $this->wPt = $this->w * $this->k;
23658 $this->hPt = $this->h * $this->k;
23659 $this->fwPt = $this->wPt;
23660 $this->fhPt = $this->hPt;
23663 $this->lMargin = 0;
23664 $this->rMargin = 0;
23665 $this->tMargin = 0;
23666 $this->bMargin = 0;
23667 return $this->xobjid;
23681 if (!$this->inxobj) {
23685 $this->inxobj =
false;
23687 $this->setGraphicVars($this->xobjects[$this->xobjid][
'gvars'],
true);
23688 return $this->xobjid;
23710 if (!isset($this->xobjects[$id])) {
23711 $this->Error(
'The XObject Template \''.$id.
'\' doesn\
't exist!');
23713 if ($this->inxobj) {
23714 if ($id == $this->xobjid) {
23716 $this->endTemplate();
23719 $this->xobjects[$this->xobjid][
'xobjects'][$id] = $this->xobjects[$id];
23730 $this->checkPageRegions($h,
$x,
$y);
23731 $ow = $this->xobjects[$id][
'w'];
23732 $oh = $this->xobjects[$id][
'h'];
23734 if (($w <= 0) AND ($h <= 0)) {
23737 } elseif ($w <= 0) {
23738 $w = $h * $ow / $oh;
23739 } elseif ($h <= 0) {
23740 $h = $w * $oh / $ow;
23743 $this->fitBlock($w, $h,
$x,
$y, $fitonpage);
23748 if ($palign ==
'L') {
23749 $xt = $this->lMargin;
23750 } elseif ($palign ==
'C') {
23751 $xt = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
23752 } elseif ($palign ==
'R') {
23753 $xt = $this->w - $this->rMargin - $w;
23759 if ($palign ==
'L') {
23760 $xt = $this->lMargin;
23761 } elseif ($palign ==
'C') {
23762 $xt = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
23763 } elseif ($palign ==
'R') {
23764 $xt = $this->w - $this->rMargin - $w;
23771 $this->StartTransform();
23773 $sx = ($w / $this->xobjects[$id][
'w']);
23774 $sy = ($h / $this->xobjects[$id][
'h']);
23780 $tm[4] = $xt * $this->k;
23781 $tm[5] = ($this->h - $h -
$y) * $this->k;
23782 $this->Transform($tm);
23784 $this->_out(
'/'.$id.
' Do');
23785 $this->StopTransform();
23787 if (!empty($this->xobjects[$id][
'annotations'])) {
23788 foreach ($this->xobjects[$id][
'annotations'] as $annot) {
23790 $coordlt = $this->getTransformationMatrixProduct($tm, array(1, 0, 0, 1, ($annot[
'x'] * $this->k), (-$annot[
'y'] * $this->k)));
23791 $ax = ($coordlt[4] / $this->k);
23792 $ay = ($this->h - $h - ($coordlt[5] / $this->k));
23793 $coordrb = $this->getTransformationMatrixProduct($tm, array(1, 0, 0, 1, (($annot[
'x'] + $annot[
'w']) * $this->k), ((-$annot[
'y'] - $annot[
'h']) * $this->k)));
23794 $aw = ($coordrb[4] / $this->k) - $ax;
23795 $ah = ($this->h - $h - ($coordrb[5] / $this->k)) - $ay;
23796 $this->Annotation($ax, $ay, $aw, $ah, $annot[
'text'], $annot[
'opt'], $annot[
'spaces']);
23807 $this->y =
$y + round($h/2);
23817 $this->SetY($rb_y);
23834 $this->font_stretching = $perc;
23845 return $this->font_stretching;
23856 $this->font_spacing = $spacing;
23867 return $this->font_spacing;
23879 return $this->page_regions;
23895 $this->page_regions = array();
23897 foreach ($regions as
$data) {
23898 $this->addPageRegion($data);
23914 if (!isset($region[
'page']) OR empty($region[
'page'])) {
23915 $region[
'page'] = $this->page;
23917 if (isset($region[
'xt']) AND isset($region[
'xb']) AND ($region[
'xt'] > 0) AND ($region[
'xb'] > 0)
23918 AND isset($region[
'yt']) AND isset($region[
'yb']) AND ($region[
'yt'] >= 0) AND ($region[
'yt'] < $region[
'yb'])
23919 AND isset($region[
'side']) AND (($region[
'side'] ==
'L') OR ($region[
'side'] ==
'R'))) {
23920 $this->page_regions[] = $region;
23933 if (isset($this->page_regions[$key])) {
23934 unset($this->page_regions[$key]);
23957 if (empty($this->page_regions)) {
23962 $h = ($this->FontSize * $this->cell_height_ratio) + $this->cell_padding[
'T'] + $this->cell_padding[
'B'];
23965 $this->lMargin = $this->original_lMargin;
23967 $this->rMargin = $this->original_rMargin;
23969 if ($this->AutoPageBreak AND !$this->InFooter AND ((
$y + $h) > $this->PageBreakTrigger)) {
23974 foreach ($this->page_regions as $regid => $regdata) {
23975 if ($regdata[
'page'] == $this->page) {
23977 if ((
$y > ($regdata[
'yt'] - $h)) AND (
$y <= $regdata[
'yb'])) {
23979 $minv = ($regdata[
'xb'] - $regdata[
'xt']) / ($regdata[
'yb'] - $regdata[
'yt']);
23980 $yt = max(
$y, $regdata[
'yt']);
23981 $yb = min(($yt + $h), $regdata[
'yb']);
23982 $xt = (($yt - $regdata[
'yt']) * $minv) + $regdata[
'xt'];
23983 $xb = (($yb - $regdata[
'yt']) * $minv) + $regdata[
'xt'];
23984 if ($regdata[
'side'] ==
'L') {
23985 $new_margin = max($xt, $xb);
23986 if ($this->lMargin < $new_margin) {
23989 $this->lMargin = $new_margin;
23991 if (
$x < $new_margin) {
23996 } elseif ($regdata[
'side'] ==
'R') {
23997 $new_margin = min($xt, $xb);
23998 if (($this->w - $this->rMargin) > $new_margin) {
24001 $this->rMargin = ($this->w - $new_margin);
24003 if (
$x > $new_margin) {
24035 public function ImageSVG(
$file,
$x=
'',
$y=
'', $w=0, $h=0, $link=
'', $align=
'', $palign=
'', $border=0, $fitonpage=
false) {
24036 if ($this->rasterize_vector_images AND ($w > 0) AND ($h > 0)) {
24038 return $this->Image(
$file,
$x,
$y, $w, $h,
'SVG', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false,
false);
24040 $this->svgdir = dirname(
$file);
24041 $svgdata = file_get_contents(
$file);
24042 if ($svgdata ===
false) {
24043 $this->Error(
'SVG file not found: '.
$file);
24052 $this->checkPageRegions(
$x,
$y);
24058 $aspect_ratio_align =
'xMidYMid';
24059 $aspect_ratio_ms =
'meet';
24062 preg_match(
'/<svg([^>]*)>/si', $svgdata, $regs);
24063 if (isset($regs[1]) AND !empty($regs[1])) {
24065 if (preg_match(
'/[\s]+x[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
24066 $ox = $this->getHTMLUnitToUnits($tmp[1], 0, $this->svgunit,
false);
24069 if (preg_match(
'/[\s]+y[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
24070 $oy = $this->getHTMLUnitToUnits($tmp[1], 0, $this->svgunit,
false);
24073 if (preg_match(
'/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
24074 $ow = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit,
false);
24077 if (preg_match(
'/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
24078 $oh = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit,
false);
24081 $view_box = array();
24082 if (preg_match(
'/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.\-]+)[\s]+([0-9\.\-]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $regs[1], $tmp)) {
24083 if (count($tmp) == 5) {
24085 foreach ($tmp as $key => $val) {
24086 $view_box[$key] = $this->getHTMLUnitToUnits($val, 0, $this->svgunit,
false);
24088 $ox = $view_box[0];
24089 $oy = $view_box[1];
24093 if (preg_match(
'/[\s]+preserveAspectRatio[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
24094 $aspect_ratio = preg_split(
'/[\s]+/si', $tmp[1]);
24095 switch (count($aspect_ratio)) {
24097 $aspect_ratio_align = $aspect_ratio[1];
24098 $aspect_ratio_ms = $aspect_ratio[2];
24102 $aspect_ratio_align = $aspect_ratio[0];
24103 $aspect_ratio_ms = $aspect_ratio[1];
24107 $aspect_ratio_align = $aspect_ratio[0];
24108 $aspect_ratio_ms =
'meet';
24116 if (($w <= 0) AND ($h <= 0)) {
24120 } elseif ($w <= 0) {
24121 $w = $h * $ow / $oh;
24122 } elseif ($h <= 0) {
24123 $h = $w * $oh / $ow;
24126 $this->fitBlock($w, $h,
$x,
$y, $fitonpage);
24127 if ($this->rasterize_vector_images) {
24129 return $this->Image(
$file,
$x,
$y, $w, $h,
'SVG', $link, $align,
true, 300, $palign,
false,
false, $border,
false,
false,
false);
24132 $this->img_rb_y =
$y + $h;
24135 if ($palign ==
'L') {
24136 $ximg = $this->lMargin;
24137 } elseif ($palign ==
'C') {
24138 $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
24139 } elseif ($palign ==
'R') {
24140 $ximg = $this->w - $this->rMargin - $w;
24144 $this->img_rb_x = $ximg;
24146 if ($palign ==
'L') {
24147 $ximg = $this->lMargin;
24148 } elseif ($palign ==
'C') {
24149 $ximg = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
24150 } elseif ($palign ==
'R') {
24151 $ximg = $this->w - $this->rMargin - $w;
24155 $this->img_rb_x = $ximg + $w;
24158 $gvars = $this->getGraphicVars();
24160 $svgoffset_x = ($ximg - $ox) * $this->k;
24161 $svgoffset_y = -(
$y - $oy) * $this->k;
24162 if (isset($view_box[2]) AND ($view_box[2] > 0) AND ($view_box[3] > 0)) {
24163 $ow = $view_box[2];
24164 $oh = $view_box[3];
24166 $svgscale_x = $w / $ow;
24167 $svgscale_y = $h / $oh;
24169 if ($aspect_ratio_align !=
'none') {
24171 $svgscale_old_x = $svgscale_x;
24172 $svgscale_old_y = $svgscale_y;
24174 if ($aspect_ratio_ms ==
'slice') {
24176 if ($svgscale_x > $svgscale_y) {
24177 $svgscale_y = $svgscale_x;
24178 } elseif ($svgscale_x < $svgscale_y) {
24179 $svgscale_x = $svgscale_y;
24183 if ($svgscale_x < $svgscale_y) {
24184 $svgscale_y = $svgscale_x;
24185 } elseif ($svgscale_x > $svgscale_y) {
24186 $svgscale_x = $svgscale_y;
24190 switch (substr($aspect_ratio_align, 1, 3)) {
24196 $svgoffset_x += (($w * $this->k) - ($ow * $this->k * $svgscale_x));
24201 $svgoffset_x += ((($w * $this->k) - ($ow * $this->k * $svgscale_x)) / 2);
24206 switch (substr($aspect_ratio_align, 5)) {
24212 $svgoffset_y -= (($h * $this->k) - ($oh * $this->k * $svgscale_y));
24217 $svgoffset_y -= ((($h * $this->k) - ($oh * $this->k * $svgscale_y)) / 2);
24223 $page_break_mode = $this->AutoPageBreak;
24224 $page_break_margin = $this->getBreakMargin();
24225 $cell_padding = $this->cell_padding;
24226 $this->SetCellPadding(0);
24227 $this->SetAutoPageBreak(
false);
24229 $this->_out(
'q'.$this->epsmarker);
24231 $this->Rect(
$x,
$y, $w, $h,
'CNZ', array(), array());
24233 $e = $ox * $this->k * (1 - $svgscale_x);
24234 $f = ($this->h - $oy) * $this->k * (1 - $svgscale_y);
24235 $this->_out(sprintf(
'%.3F %.3F %.3F %.3F %.3F %.3F cm', $svgscale_x, 0, 0, $svgscale_y, $e + $svgoffset_x, $f + $svgoffset_y));
24237 $this->parser = xml_parser_create(
'UTF-8');
24239 xml_set_object($this->parser, $this);
24241 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
24243 xml_set_element_handler($this->parser,
'startSVGElementHandler',
'endSVGElementHandler');
24245 xml_set_character_data_handler($this->parser,
'segSVGContentHandler');
24247 if(!xml_parse($this->parser, $svgdata)) {
24248 $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));
24249 $this->Error($error_message);
24252 xml_parser_free($this->parser);
24254 $this->_out($this->epsmarker.
'Q');
24256 $this->setGraphicVars($gvars);
24257 $this->lasth = $gvars[
'lasth'];
24258 if (!empty($border)) {
24266 $this->Cell($w, $h,
'', $border, 0,
'', 0,
'', 0,
true);
24271 $this->Link($ximg,
$y, $w, $h, $link, 0);
24277 $this->x = $this->img_rb_x;
24281 $this->y =
$y + round($h/2);
24282 $this->x = $this->img_rb_x;
24286 $this->y = $this->img_rb_y;
24287 $this->x = $this->img_rb_x;
24291 $this->SetY($this->img_rb_y);
24296 $this->x = $gvars[
'x'];
24297 $this->y = $gvars[
'y'];
24298 $this->page = $gvars[
'page'];
24299 $this->current_column = $gvars[
'current_column'];
24300 $this->tMargin = $gvars[
'tMargin'];
24301 $this->bMargin = $gvars[
'bMargin'];
24302 $this->w = $gvars[
'w'];
24303 $this->h = $gvars[
'h'];
24304 $this->wPt = $gvars[
'wPt'];
24305 $this->hPt = $gvars[
'hPt'];
24306 $this->fwPt = $gvars[
'fwPt'];
24307 $this->fhPt = $gvars[
'fhPt'];
24311 $this->endlinex = $this->img_rb_x;
24313 $this->SetAutoPageBreak($page_break_mode, $page_break_margin);
24314 $this->cell_padding = $cell_padding;
24327 $tm = array(1, 0, 0, 1, 0, 0);
24328 $transform = array();
24329 if (preg_match_all(
'/(matrix|translate|scale|rotate|skewX|skewY)[\s]*\(([^\)]+)\)/si', $attribute, $transform, PREG_SET_ORDER) > 0) {
24330 foreach ($transform as $key =>
$data) {
24331 if (!empty(
$data[2])) {
24339 switch (
$data[1]) {
24341 if (preg_match(
'/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
24351 case 'translate': {
24352 if (preg_match(
'/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
24355 } elseif (preg_match(
'/([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
24361 if (preg_match(
'/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
24364 } elseif (preg_match(
'/([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
24371 if (preg_match(
'/([0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
24372 $ang = deg2rad($regs[1]);
24379 $e = (
$x * (1 - $a)) - (
$y * $c);
24381 } elseif (preg_match(
'/([0-9\-\.]+)/si',
$data[2], $regs)) {
24382 $ang = deg2rad($regs[1]);
24393 if (preg_match(
'/([0-9\-\.]+)/si',
$data[2], $regs)) {
24394 $c = tan(deg2rad($regs[1]));
24399 if (preg_match(
'/([0-9\-\.]+)/si',
$data[2], $regs)) {
24400 $b = tan(deg2rad($regs[1]));
24405 $tm = $this->getTransformationMatrixProduct($tm, array($a, $b, $c,
$d, $e,
$f));
24423 $tm[0] = ($ta[0] * $tb[0]) + ($ta[2] * $tb[1]);
24424 $tm[1] = ($ta[1] * $tb[0]) + ($ta[3] * $tb[1]);
24425 $tm[2] = ($ta[0] * $tb[2]) + ($ta[2] * $tb[3]);
24426 $tm[3] = ($ta[1] * $tb[2]) + ($ta[3] * $tb[3]);
24427 $tm[4] = ($ta[0] * $tb[4]) + ($ta[2] * $tb[5]) + $ta[4];
24428 $tm[5] = ($ta[1] * $tb[4]) + ($ta[3] * $tb[5]) + $ta[5];
24444 $e = $this->getHTMLUnitToUnits($tm[4], 1, $this->svgunit,
false) * $this->k;
24445 $f = -$this->getHTMLUnitToUnits($tm[5], 1, $this->svgunit,
false) * $this->k;
24447 $y = $this->h * $this->k;
24448 $e = (
$x * (1 - $a)) - (
$y * $c) + $e;
24450 return array($a, $b, $c,
$d, $e,
$f);
24460 $this->Transform($this->convertSVGtMatrix($tm));
24478 protected function setSVGStyles($svgstyle, $prevsvgstyle,
$x=0,
$y=0, $w=1, $h=1, $clip_function=
'', $clip_params=array()) {
24480 if(!isset($svgstyle[
'opacity'])) {
24485 if (preg_match(
'/url\([\s]*\#([^\)]*)\)/si', $svgstyle[
'clip-path'], $regs)) {
24486 $clip_path = $this->svgclippaths[$regs[1]];
24487 foreach ($clip_path as $cp) {
24488 $this->startSVGElementHandler(
'clip-path', $cp[
'name'], $cp[
'attribs'], $cp[
'tm']);
24492 if ($svgstyle[
'opacity'] != 1) {
24493 $this->SetAlpha($svgstyle[
'opacity']);
24496 $fill_color = $this->convertHTMLColorToDec($svgstyle[
'color']);
24497 $this->SetFillColorArray($fill_color);
24499 $text_color = $this->convertHTMLColorToDec($svgstyle[
'text-color']);
24500 $this->SetTextColorArray($text_color);
24502 if (preg_match(
'/rect\(([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)\)/si', $svgstyle[
'clip'], $regs)) {
24503 $top = (isset($regs[1])?$this->getHTMLUnitToUnits($regs[1], 0, $this->svgunit,
false):0);
24504 $right = (isset($regs[2])?$this->getHTMLUnitToUnits($regs[2], 0, $this->svgunit,
false):0);
24505 $bottom = (isset($regs[3])?$this->getHTMLUnitToUnits($regs[3], 0, $this->svgunit,
false):0);
24506 $left = (isset($regs[4])?$this->getHTMLUnitToUnits($regs[4], 0, $this->svgunit,
false):0);
24509 $cw = $w - $left - $right;
24510 $ch = $h - $top - $bottom;
24511 if ($svgstyle[
'clip-rule'] ==
'evenodd') {
24512 $clip_rule =
'CNZ';
24514 $clip_rule =
'CEO';
24516 $this->Rect($cx, $cy,
$cw, $ch, $clip_rule, array(), array());
24520 if (preg_match(
'/url\([\s]*\#([^\)]*)\)/si', $svgstyle[
'fill'], $regs)) {
24522 $gradient = $this->svggradients[$regs[1]];
24523 if (isset($gradient[
'xref'])) {
24525 $newgradient = $this->svggradients[$gradient[
'xref']];
24526 $newgradient[
'coords'] = $gradient[
'coords'];
24527 $newgradient[
'mode'] = $gradient[
'mode'];
24528 $newgradient[
'gradientUnits'] = $gradient[
'gradientUnits'];
24529 if (isset($gradient[
'gradientTransform'])) {
24530 $newgradient[
'gradientTransform'] = $gradient[
'gradientTransform'];
24532 $gradient = $newgradient;
24537 if (!empty($clip_function) AND method_exists($this, $clip_function)) {
24538 $bbox = call_user_func_array(array($this, $clip_function), $clip_params);
24539 if (is_array($bbox) AND (count($bbox) == 4)) {
24540 list(
$x,
$y, $w, $h) = $bbox;
24543 if ($gradient[
'mode'] ==
'measure') {
24544 if (isset($gradient[
'gradientTransform']) AND !empty($gradient[
'gradientTransform'])) {
24545 $gtm = $gradient[
'gradientTransform'];
24547 $xa = ($gtm[0] * $gradient[
'coords'][0]) + ($gtm[2] * $gradient[
'coords'][1]) + $gtm[4];
24548 $ya = ($gtm[1] * $gradient[
'coords'][0]) + ($gtm[3] * $gradient[
'coords'][1]) + $gtm[5];
24549 $xb = ($gtm[0] * $gradient[
'coords'][2]) + ($gtm[2] * $gradient[
'coords'][3]) + $gtm[4];
24550 $yb = ($gtm[1] * $gradient[
'coords'][2]) + ($gtm[3] * $gradient[
'coords'][3]) + $gtm[5];
24551 if (isset($gradient[
'coords'][4])) {
24552 $gradient[
'coords'][4] = sqrt(pow(($gtm[0] * $gradient[
'coords'][4]), 2) + pow(($gtm[1] * $gradient[
'coords'][4]), 2));
24554 $gradient[
'coords'][0] = $xa;
24555 $gradient[
'coords'][1] = $ya;
24556 $gradient[
'coords'][2] = $xb;
24557 $gradient[
'coords'][3] = $yb;
24561 $gradient[
'coords'][0] = $this->getHTMLUnitToUnits($gradient[
'coords'][0], 0, $this->svgunit,
false);
24562 $gradient[
'coords'][1] = $this->getHTMLUnitToUnits($gradient[
'coords'][1], 0, $this->svgunit,
false);
24563 $gradient[
'coords'][2] = $this->getHTMLUnitToUnits($gradient[
'coords'][2], 0, $this->svgunit,
false);
24564 $gradient[
'coords'][3] = $this->getHTMLUnitToUnits($gradient[
'coords'][3], 0, $this->svgunit,
false);
24565 if (isset($gradient[
'coords'][4])) {
24566 $gradient[
'coords'][4] = $this->getHTMLUnitToUnits($gradient[
'coords'][4], 0, $this->svgunit,
false);
24569 if ($gradient[
'gradientUnits'] ==
'objectBoundingBox') {
24571 $gradient[
'coords'][0] +=
$x;
24572 $gradient[
'coords'][1] +=
$y;
24573 $gradient[
'coords'][2] +=
$x;
24574 $gradient[
'coords'][3] +=
$y;
24577 $gradient[
'coords'][0] = ($gradient[
'coords'][0] -
$x) / $w;
24578 $gradient[
'coords'][1] = ($gradient[
'coords'][1] -
$y) / $h;
24579 $gradient[
'coords'][2] = ($gradient[
'coords'][2] -
$x) / $w;
24580 $gradient[
'coords'][3] = ($gradient[
'coords'][3] -
$y) / $h;
24581 if (isset($gradient[
'coords'][4])) {
24582 $gradient[
'coords'][4] /= $w;
24585 foreach($gradient[
'coords'] as $key => $val) {
24587 $gradient[
'coords'][$key] = 0;
24588 } elseif ($val > 1) {
24589 $gradient[
'coords'][$key] = 1;
24592 if (($gradient[
'type'] == 2) AND ($gradient[
'coords'][0] == $gradient[
'coords'][2]) AND ($gradient[
'coords'][1] == $gradient[
'coords'][3])) {
24594 $gradient[
'coords'][0] = 1;
24595 $gradient[
'coords'][1] = 0;
24596 $gradient[
'coords'][2] = 0.999;
24597 $gradient[
'coords'][3] = 0;
24601 $tmp = $gradient[
'coords'][1];
24602 $gradient[
'coords'][1] = $gradient[
'coords'][3];
24603 $gradient[
'coords'][3] = $tmp;
24605 if (($gradient[
'type'] == 3) AND ($gradient[
'mode'] ==
'measure')) {
24607 $cy = $this->h -
$y - ($gradient[
'coords'][1] * ($w + $h));
24608 $this->_out(sprintf(
'%.3F 0 0 %.3F %.3F %.3F cm', $w*$this->k, $w*$this->k,
$x*$this->k, $cy*$this->k));
24610 $this->_out(sprintf(
'%.3F 0 0 %.3F %.3F %.3F cm', $w*$this->k, $h*$this->k,
$x*$this->k, ($this->h-(
$y+$h))*$this->k));
24612 if (count($gradient[
'stops']) > 1) {
24613 $this->Gradient($gradient[
'type'], $gradient[
'coords'], $gradient[
'stops'], array(),
false);
24615 } elseif ($svgstyle[
'fill'] !=
'none') {
24616 $fill_color = $this->convertHTMLColorToDec($svgstyle[
'fill']);
24617 if ($svgstyle[
'fill-opacity'] != 1) {
24618 $this->SetAlpha($svgstyle[
'fill-opacity']);
24620 $this->SetFillColorArray($fill_color);
24621 if ($svgstyle[
'fill-rule'] ==
'evenodd') {
24628 if ($svgstyle[
'stroke'] !=
'none') {
24629 $stroke_style = array(
24630 'color' => $this->convertHTMLColorToDec($svgstyle[
'stroke']),
24631 'width' => $this->getHTMLUnitToUnits($svgstyle[
'stroke-width'], 0, $this->svgunit,
false),
24632 'cap' => $svgstyle[
'stroke-linecap'],
24633 'join' => $svgstyle[
'stroke-linejoin']
24635 if (isset($svgstyle[
'stroke-dasharray']) AND !empty($svgstyle[
'stroke-dasharray']) AND ($svgstyle[
'stroke-dasharray'] !=
'none')) {
24636 $stroke_style[
'dash'] = $svgstyle[
'stroke-dasharray'];
24638 $this->SetLineStyle($stroke_style);
24643 if (!empty($svgstyle[
'font'])) {
24644 if (preg_match(
'/font-family[\s]*:[\s]*([^\;\"]*)/si', $svgstyle[
'font'], $regs)) {
24645 $font_family = $this->getFontFamilyName($regs[1]);
24647 $font_family = $svgstyle[
'font-family'];
24649 if (preg_match(
'/font-size[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
24650 $font_size = trim($regs[1]);
24652 $font_size = $svgstyle[
'font-size'];
24654 if (preg_match(
'/font-style[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
24655 $font_style = trim($regs[1]);
24657 $font_style = $svgstyle[
'font-style'];
24659 if (preg_match(
'/font-weight[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
24660 $font_weight = trim($regs[1]);
24662 $font_weight = $svgstyle[
'font-weight'];
24664 if (preg_match(
'/font-stretch[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
24665 $font_stretch = trim($regs[1]);
24667 $font_stretch = $svgstyle[
'font-stretch'];
24669 if (preg_match(
'/letter-spacing[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle[
'font'], $regs)) {
24670 $font_spacing = trim($regs[1]);
24672 $font_spacing = $svgstyle[
'letter-spacing'];
24675 $font_family = $this->getFontFamilyName($svgstyle[
'font-family']);
24676 $font_size = $svgstyle[
'font-size'];
24677 $font_style = $svgstyle[
'font-style'];
24678 $font_weight = $svgstyle[
'font-weight'];
24679 $font_stretch = $svgstyle[
'font-stretch'];
24680 $font_spacing = $svgstyle[
'letter-spacing'];
24682 $font_size = $this->getHTMLUnitToUnits($font_size, $prevsvgstyle[
'font-size'], $this->svgunit,
false) * $this->k;
24683 $font_stretch = $this->getCSSFontStretching($font_stretch, $svgstyle[
'font-stretch']);
24684 $font_spacing = $this->getCSSFontSpacing($font_spacing, $svgstyle[
'letter-spacing']);
24685 switch ($font_style) {
24700 switch ($font_weight) {
24703 $font_style .=
'B';
24707 switch ($svgstyle[
'text-decoration']) {
24708 case 'underline': {
24709 $font_style .=
'U';
24713 $font_style .=
'O';
24716 case 'line-through': {
24717 $font_style .=
'D';
24725 $this->SetFont($font_family, $font_style, $font_size);
24726 $this->setFontStretching($font_stretch);
24727 $this->setFontSpacing($font_spacing);
24751 $op = $this->getPathPaintOperator($style,
'');
24756 $d = str_replace(
'-',
' -',
$d);
24757 $d = str_replace(
'+',
' +',
$d);
24758 preg_match_all(
'/([a-zA-Z])[\s]*([^a-zA-Z\"]*)/si',
$d, $paths, PREG_SET_ORDER);
24765 $xmin = 2147483647;
24767 $ymin = 2147483647;
24771 foreach ($paths as $key => $val) {
24773 $cmd = trim($val[1]);
24785 if (isset($val[2])) {
24787 $rawparams = preg_split(
'/([\,\s]+)/si', trim($val[2]));
24789 foreach ($rawparams as $ck => $cp) {
24790 $params[$ck] = $this->getHTMLUnitToUnits($cp, 0, $this->svgunit,
false);
24793 switch (strtoupper(
$cmd)) {
24795 foreach ($params as $ck => $cp) {
24796 if (($ck % 2) == 0) {
24797 $x = $cp + $xoffset;
24799 $y = $cp + $yoffset;
24801 $this->_outPoint(
$x,
$y);
24803 $this->_outLine(
$x,
$y);
24805 $xmin = min($xmin,
$x);
24806 $ymin = min($ymin,
$y);
24807 $xmax = max($xmax,
$x);
24808 $ymax = max($ymax,
$y);
24818 foreach ($params as $ck => $cp) {
24819 if (($ck % 2) == 0) {
24820 $x = $cp + $xoffset;
24822 $y = $cp + $yoffset;
24823 $this->_outLine(
$x,
$y);
24824 $xmin = min($xmin,
$x);
24825 $ymin = min($ymin,
$y);
24826 $xmax = max($xmax,
$x);
24827 $ymax = max($ymax,
$y);
24837 foreach ($params as $ck => $cp) {
24838 $x = $cp + $xoffset;
24839 $this->_outLine(
$x,
$y);
24840 $xmin = min($xmin,
$x);
24841 $xmax = max($xmax,
$x);
24849 foreach ($params as $ck => $cp) {
24850 $y = $cp + $yoffset;
24851 $this->_outLine(
$x,
$y);
24852 $ymin = min($ymin,
$y);
24853 $ymax = max($ymax,
$y);
24861 foreach ($params as $ck => $cp) {
24862 $params[$ck] = $cp;
24863 if ((($ck + 1) % 6) == 0) {
24864 $x1 = $params[($ck - 5)] + $xoffset;
24865 $y1 = $params[($ck - 4)] + $yoffset;
24866 $x2 = $params[($ck - 3)] + $xoffset;
24867 $y2 = $params[($ck - 2)] + $yoffset;
24868 $x = $params[($ck - 1)] + $xoffset;
24869 $y = $params[($ck)] + $yoffset;
24870 $this->_outCurve($x1, $y1, $x2, $y2, $x, $y);
24871 $xmin = min($xmin, $x, $x1, $x2);
24872 $ymin = min($ymin, $y, $y1, $y2);
24873 $xmax = max($xmax, $x, $x1, $x2);
24874 $ymax = max($ymax, $y, $y1, $y2);
24884 foreach ($params as $ck => $cp) {
24885 $params[$ck] = $cp;
24886 if ((($ck + 1) % 4) == 0) {
24887 if (($key > 0) AND ((strtoupper($paths[($key - 1)][1]) ==
'C') OR (strtoupper($paths[($key - 1)][1]) ==
'S'))) {
24888 $x1 = (2 *
$x) - $x2;
24889 $y1 = (2 *
$y) - $y2;
24894 $x2 = $params[($ck - 3)] + $xoffset;
24895 $y2 = $params[($ck - 2)] + $yoffset;
24896 $x = $params[($ck - 1)] + $xoffset;
24897 $y = $params[($ck)] + $yoffset;
24898 $this->_outCurve($x1, $y1, $x2, $y2, $x, $y);
24899 $xmin = min($xmin, $x, $x1, $x2);
24900 $ymin = min($ymin, $y, $y1, $y2);
24901 $xmax = max($xmax, $x, $x1, $x2);
24902 $ymax = max($ymax, $y, $y1, $y2);
24912 foreach ($params as $ck => $cp) {
24913 $params[$ck] = $cp;
24914 if ((($ck + 1) % 4) == 0) {
24916 $x1 = $params[($ck - 3)] + $xoffset;
24917 $y1 = $params[($ck - 2)] + $yoffset;
24918 $xa = (
$x + (2 * $x1)) / 3;
24919 $ya = (
$y + (2 * $y1)) / 3;
24920 $x = $params[($ck - 1)] + $xoffset;
24921 $y = $params[($ck)] + $yoffset;
24922 $xb = (
$x + (2 * $x1)) / 3;
24923 $yb = ($y + (2 * $y1)) / 3;
24924 $this->_outCurve($xa, $ya, $xb, $yb,
$x, $y);
24925 $xmin = min($xmin,
$x, $xa, $xb);
24926 $ymin = min($ymin, $y, $ya, $yb);
24927 $xmax = max($xmax,
$x, $xa, $xb);
24928 $ymax = max($ymax, $y, $ya, $yb);
24938 foreach ($params as $ck => $cp) {
24939 $params[$ck] = $cp;
24940 if (($ck % 2) != 0) {
24941 if (($key > 0) AND ((strtoupper($paths[($key - 1)][1]) ==
'Q') OR (strtoupper($paths[($key - 1)][1]) ==
'T'))) {
24942 $x1 = (2 *
$x) - $x1;
24943 $y1 = (2 *
$y) - $y1;
24949 $xa = (
$x + (2 * $x1)) / 3;
24950 $ya = (
$y + (2 * $y1)) / 3;
24951 $x = $params[($ck - 1)] + $xoffset;
24952 $y = $params[($ck)] + $yoffset;
24953 $xb = (
$x + (2 * $x1)) / 3;
24954 $yb = ($y + (2 * $y1)) / 3;
24955 $this->_outCurve($xa, $ya, $xb, $yb,
$x, $y);
24956 $xmin = min($xmin,
$x, $x1, $x2);
24957 $ymin = min($ymin, $y, $y1, $y2);
24958 $xmax = max($xmax,
$x, $x1, $x2);
24959 $ymax = max($ymax, $y, $y1, $y2);
24969 foreach ($params as $ck => $cp) {
24970 $params[$ck] = $cp;
24971 if ((($ck + 1) % 7) == 0) {
24974 $rx = abs($params[($ck - 6)]);
24975 $ry = abs($params[($ck - 5)]);
24976 $ang = -$rawparams[($ck - 4)];
24977 $angle = deg2rad($ang);
24978 $fa = $rawparams[($ck - 3)];
24979 $fs = $rawparams[($ck - 2)];
24980 $x = $params[($ck - 1)] + $xoffset;
24981 $y = $params[$ck] + $yoffset;
24982 $cos_ang = cos($angle);
24983 $sin_ang = sin($angle);
24984 $a = ($x0 -
$x) / 2;
24985 $b = ($y0 -
$y) / 2;
24986 $xa = ($a * $cos_ang) - ($b * $sin_ang);
24987 $ya = ($a * $sin_ang) + ($b * $cos_ang);
24992 $delta = ($xa2 / $rx2) + ($ya2 / $ry2);
24994 $rx *= sqrt($delta);
24995 $ry *= sqrt($delta);
24999 $numerator = (($rx2 * $ry2) - ($rx2 * $ya2) - ($ry2 * $xa2));
25000 if ($numerator < 0) {
25003 $root = sqrt($numerator / (($rx2 * $ya2) + ($ry2 * $xa2)));
25008 $cax = $root * (($rx * $ya) / $ry);
25009 $cay = -$root * (($ry * $xa) / $rx);
25011 $cx = ($cax * $cos_ang) - ($cay * $sin_ang) + (($x0 +
$x) / 2);
25012 $cy = ($cax * $sin_ang) + ($cay * $cos_ang) + (($y0 +
$y) / 2);
25014 $angs = $this->getVectorsAngle(1, 0, (($xa - $cax) / $rx), (($cay - $ya) / $ry));
25015 $dang = $this->getVectorsAngle((($xa - $cax) / $rx), (($ya - $cay) / $ry), ((-$xa - $cax) / $rx), ((-$ya - $cay) / $ry));
25016 if (($fs == 0) AND ($dang > 0)) {
25017 $dang -= (2 * M_PI);
25018 } elseif (($fs == 1) AND ($dang < 0)) {
25019 $dang += (2 * M_PI);
25021 $angf = $angs - $dang;
25022 if (($fs == 1) AND ($angs > $angf)) {
25027 $angs = rad2deg($angs);
25028 $angf = rad2deg($angf);
25030 if ((isset($paths[($key + 1)][1])) AND (trim($paths[($key + 1)][1]) ==
'z')) {
25033 $this->_outellipticalarc($cx, $cy, $rx, $ry, $ang, $angs, $angf, $pie, 2);
25034 $this->_outPoint($x, $y);
25035 $xmin = min($xmin, $x);
25036 $ymin = min($ymin, $y);
25037 $xmax = max($xmax, $x);
25038 $ymax = max($ymax, $y);
25056 return array($xmin, $ymin, ($xmax - $xmin), ($ymax - $ymin));
25070 $dprod = ($x1 * $x2) + ($y1 * $y2);
25071 $dist1 = sqrt(($x1 * $x1) + ($y1 * $y1));
25072 $dist2 = sqrt(($x2 * $x2) + ($y2 * $y2));
25073 $angle = acos($dprod / ($dist1 * $dist2));
25074 if (is_nan($angle)) {
25077 if ((($x1 * $y2) - ($x2 * $y1)) < 0) {
25095 if ($this->svgclipmode) {
25096 $this->svgclippaths[$this->svgclipid][] = array(
'name' =>
$name,
'attribs' => $attribs,
'tm' => $this->svgcliptm[$this->svgclipid]);
25099 if ($this->svgdefsmode AND !in_array(
$name, array(
'clipPath',
'linearGradient',
'radialGradient',
'stop'))) {
25100 if (!isset($attribs[
'id'])) {
25101 $attribs[
'id'] =
'DF_'.(count($this->svgdefs) + 1);
25103 $this->svgdefs[$attribs[
'id']] = array(
'name' =>
$name,
'attribs' => $attribs);
25107 if ($parser ==
'clip-path') {
25112 $prev_svgstyle = $this->svgstyles[(count($this->svgstyles) - 1)];
25113 $svgstyle = $this->svgstyles[0];
25114 if (isset($attribs[
'style']) AND !$this->empty_string($attribs[
'style'])) {
25116 $attribs[
'style'] =
';'.$attribs[
'style'];
25118 foreach ($prev_svgstyle as $key => $val) {
25119 if (in_array($key, $this->svginheritprop)) {
25121 $svgstyle[$key] = $val;
25123 if (isset($attribs[$key]) AND !$this->empty_string($attribs[$key])) {
25125 if ($attribs[$key] ==
'inherit') {
25126 $svgstyle[$key] = $val;
25128 $svgstyle[$key] = $attribs[$key];
25130 } elseif (isset($attribs[
'style']) AND !$this->empty_string($attribs[
'style'])) {
25132 $attrval = array();
25133 if (preg_match(
'/[;\"\s]{1}'.$key.
'[\s]*:[\s]*([^;\"]*)/si', $attribs[
'style'], $attrval) AND isset($attrval[1])) {
25134 if ($attrval[1] ==
'inherit') {
25135 $svgstyle[$key] = $val;
25137 $svgstyle[$key] = $attrval[1];
25143 if (!empty($ctm)) {
25146 $tm = $this->svgstyles[(count($this->svgstyles) - 1)][
'transfmatrix'];
25148 if (isset($attribs[
'transform']) AND !empty($attribs[
'transform'])) {
25149 $tm = $this->getTransformationMatrixProduct($tm, $this->getSVGTransformMatrix($attribs[
'transform']));
25151 $svgstyle[
'transfmatrix'] = $tm;
25152 $invisible =
false;
25153 if (($svgstyle[
'visibility'] ==
'hidden') OR ($svgstyle[
'visibility'] ==
'collapse') OR ($svgstyle[
'display'] ==
'none')) {
25160 $this->svgdefsmode =
true;
25168 $this->svgclipmode =
true;
25169 if (!isset($attribs[
'id'])) {
25170 $attribs[
'id'] =
'CP_'.(count($this->svgcliptm) + 1);
25172 $this->svgclipid = $attribs[
'id'];
25173 $this->svgclippaths[$this->svgclipid] = array();
25174 $this->svgcliptm[$this->svgclipid] = $tm;
25183 array_push($this->svgstyles, $svgstyle);
25184 $this->StartTransform();
25185 $this->setSVGStyles($svgstyle, $prev_svgstyle);
25188 case 'linearGradient': {
25189 if (!isset($attribs[
'id'])) {
25190 $attribs[
'id'] =
'GR_'.(count($this->svggradients) + 1);
25192 $this->svggradientid = $attribs[
'id'];
25193 $this->svggradients[$this->svggradientid] = array();
25194 $this->svggradients[$this->svggradientid][
'type'] = 2;
25195 $this->svggradients[$this->svggradientid][
'stops'] = array();
25196 if (isset($attribs[
'gradientUnits'])) {
25197 $this->svggradients[$this->svggradientid][
'gradientUnits'] = $attribs[
'gradientUnits'];
25199 $this->svggradients[$this->svggradientid][
'gradientUnits'] =
'objectBoundingBox';
25202 $x1 = (isset($attribs[
'x1'])?$attribs[
'x1']:0);
25203 $y1 = (isset($attribs[
'y1'])?$attribs[
'y1']:0);
25204 $x2 = (isset($attribs[
'x2'])?$attribs[
'x2']:1);
25205 $y2 = (isset($attribs[
'y2'])?$attribs[
'y2']:0);
25206 if (isset($attribs[
'x1']) AND (substr($attribs[
'x1'], -1) !=
'%')) {
25207 $this->svggradients[$this->svggradientid][
'mode'] =
'measure';
25209 $this->svggradients[$this->svggradientid][
'mode'] =
'percentage';
25211 if (isset($attribs[
'gradientTransform'])) {
25212 $this->svggradients[$this->svggradientid][
'gradientTransform'] = $this->getSVGTransformMatrix($attribs[
'gradientTransform']);
25214 $this->svggradients[$this->svggradientid][
'coords'] = array($x1, $y1, $x2, $y2);
25215 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
25217 $this->svggradients[$this->svggradientid][
'xref'] = substr($attribs[
'xlink:href'], 1);
25221 case 'radialGradient': {
25222 if (!isset($attribs[
'id'])) {
25223 $attribs[
'id'] =
'GR_'.(count($this->svggradients) + 1);
25225 $this->svggradientid = $attribs[
'id'];
25226 $this->svggradients[$this->svggradientid] = array();
25227 $this->svggradients[$this->svggradientid][
'type'] = 3;
25228 $this->svggradients[$this->svggradientid][
'stops'] = array();
25229 if (isset($attribs[
'gradientUnits'])) {
25230 $this->svggradients[$this->svggradientid][
'gradientUnits'] = $attribs[
'gradientUnits'];
25232 $this->svggradients[$this->svggradientid][
'gradientUnits'] =
'objectBoundingBox';
25235 $cx = (isset($attribs[
'cx'])?$attribs[
'cx']:0.5);
25236 $cy = (isset($attribs[
'cy'])?$attribs[
'cy']:0.5);
25237 $fx = (isset($attribs[
'fx'])?$attribs[
'fx']:$cx);
25238 $fy = (isset($attribs[
'fy'])?$attribs[
'fy']:$cy);
25239 $r = (isset($attribs[
'r'])?$attribs[
'r']:0.5);
25240 if (isset($attribs[
'cx']) AND (substr($attribs[
'cx'], -1) !=
'%')) {
25241 $this->svggradients[$this->svggradientid][
'mode'] =
'measure';
25243 $this->svggradients[$this->svggradientid][
'mode'] =
'percentage';
25245 if (isset($attribs[
'gradientTransform'])) {
25246 $this->svggradients[$this->svggradientid][
'gradientTransform'] = $this->getSVGTransformMatrix($attribs[
'gradientTransform']);
25248 $this->svggradients[$this->svggradientid][
'coords'] = array($cx, $cy, $fx, $fy, $r);
25249 if (isset($attribs[
'xlink:href']) AND !empty($attribs[
'xlink:href'])) {
25251 $this->svggradients[$this->svggradientid][
'xref'] = substr($attribs[
'xlink:href'], 1);
25257 if (substr($attribs[
'offset'], -1) ==
'%') {
25258 $offset = floatval(substr($attribs[
'offset'], -1)) / 100;
25260 $offset = floatval($attribs[
'offset']);
25265 $stop_color = isset($svgstyle[
'stop-color'])?$this->convertHTMLColorToDec($svgstyle[
'stop-color']):
'black';
25266 $opacity = isset($svgstyle[
'stop-opacity'])?$svgstyle[
'stop-opacity']:1;
25267 $this->svggradients[$this->svggradientid][
'stops'][] = array(
'offset' => $offset,
'color' => $stop_color,
'opacity' => $opacity);
25275 $d = trim($attribs[
'd']);
25277 $this->SVGTransform($tm);
25278 $this->SVGPath(
$d,
'CNZ');
25280 $this->StartTransform();
25281 $this->SVGTransform($tm);
25282 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, 0, 0, 1, 1,
'SVGPath', array(
$d,
'CNZ'));
25283 if (!empty($obstyle)) {
25284 $this->SVGPath(
$d, $obstyle);
25286 $this->StopTransform();
25295 $x = (isset($attribs[
'x'])?$this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false):0);
25296 $y = (isset($attribs[
'y'])?$this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false):0);
25297 $w = (isset($attribs[
'width'])?$this->getHTMLUnitToUnits($attribs[
'width'], 0, $this->svgunit,
false):0);
25298 $h = (isset($attribs[
'height'])?$this->getHTMLUnitToUnits($attribs[
'height'], 0, $this->svgunit,
false):0);
25299 $rx = (isset($attribs[
'rx'])?$this->getHTMLUnitToUnits($attribs[
'rx'], 0, $this->svgunit,
false):0);
25300 $ry = (isset($attribs[
'ry'])?$this->getHTMLUnitToUnits($attribs[
'ry'], 0, $this->svgunit,
false):$rx);
25302 $this->SVGTransform($tm);
25303 $this->RoundedRectXY(
$x,
$y, $w, $h, $rx, $ry,
'1111',
'CNZ', array(), array());
25305 $this->StartTransform();
25306 $this->SVGTransform($tm);
25307 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y, $w, $h,
'RoundedRectXY', array(
$x,
$y, $w, $h, $rx, $ry,
'1111',
'CNZ'));
25308 if (!empty($obstyle)) {
25309 $this->RoundedRectXY(
$x,
$y, $w, $h, $rx, $ry,
'1111', $obstyle, array(), array());
25311 $this->StopTransform();
25319 $cx = (isset($attribs[
'cx'])?$this->getHTMLUnitToUnits($attribs[
'cx'], 0, $this->svgunit,
false):0);
25320 $cy = (isset($attribs[
'cy'])?$this->getHTMLUnitToUnits($attribs[
'cy'], 0, $this->svgunit,
false):0);
25321 $r = (isset($attribs[
'r'])?$this->getHTMLUnitToUnits($attribs[
'r'], 0, $this->svgunit,
false):0);
25327 $this->SVGTransform($tm);
25328 $this->Circle($cx, $cy, $r, 0, 360,
'CNZ', array(), array(), 8);
25330 $this->StartTransform();
25331 $this->SVGTransform($tm);
25332 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y, $w, $h,
'Circle', array($cx, $cy, $r, 0, 360,
'CNZ'));
25333 if (!empty($obstyle)) {
25334 $this->Circle($cx, $cy, $r, 0, 360, $obstyle, array(), array(), 8);
25336 $this->StopTransform();
25344 $cx = (isset($attribs[
'cx'])?$this->getHTMLUnitToUnits($attribs[
'cx'], 0, $this->svgunit,
false):0);
25345 $cy = (isset($attribs[
'cy'])?$this->getHTMLUnitToUnits($attribs[
'cy'], 0, $this->svgunit,
false):0);
25346 $rx = (isset($attribs[
'rx'])?$this->getHTMLUnitToUnits($attribs[
'rx'], 0, $this->svgunit,
false):0);
25347 $ry = (isset($attribs[
'ry'])?$this->getHTMLUnitToUnits($attribs[
'ry'], 0, $this->svgunit,
false):0);
25353 $this->SVGTransform($tm);
25354 $this->Ellipse($cx, $cy, $rx, $ry, 0, 0, 360,
'CNZ', array(), array(), 8);
25356 $this->StartTransform();
25357 $this->SVGTransform($tm);
25358 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y, $w, $h,
'Ellipse', array($cx, $cy, $rx, $ry, 0, 0, 360,
'CNZ'));
25359 if (!empty($obstyle)) {
25360 $this->Ellipse($cx, $cy, $rx, $ry, 0, 0, 360, $obstyle, array(), array(), 8);
25362 $this->StopTransform();
25370 $x1 = (isset($attribs[
'x1'])?$this->getHTMLUnitToUnits($attribs[
'x1'], 0, $this->svgunit,
false):0);
25371 $y1 = (isset($attribs[
'y1'])?$this->getHTMLUnitToUnits($attribs[
'y1'], 0, $this->svgunit,
false):0);
25372 $x2 = (isset($attribs[
'x2'])?$this->getHTMLUnitToUnits($attribs[
'x2'], 0, $this->svgunit,
false):0);
25373 $y2 = (isset($attribs[
'y2'])?$this->getHTMLUnitToUnits($attribs[
'y2'], 0, $this->svgunit,
false):0);
25376 $w = abs($x2 - $x1);
25377 $h = abs($y2 - $y1);
25379 $this->StartTransform();
25380 $this->SVGTransform($tm);
25381 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y, $w, $h,
'Line', array($x1, $y1, $x2, $y2));
25382 $this->Line($x1, $y1, $x2, $y2);
25383 $this->StopTransform();
25392 $points = (isset($attribs[
'points'])?$attribs[
'points']:
'0 0');
25400 $xmin = 2147483647;
25402 $ymin = 2147483647;
25404 foreach (
$points as $key => $val) {
25405 $p[$key] = $this->getHTMLUnitToUnits($val, 0, $this->svgunit,
false);
25406 if (($key % 2) == 0) {
25408 $xmin = min($xmin, $p[$key]);
25409 $xmax = max($xmax, $p[$key]);
25412 $ymin = min($ymin, $p[$key]);
25413 $ymax = max($ymax, $p[$key]);
25418 $w = ($xmax - $xmin);
25419 $h = ($ymax - $ymin);
25420 if (
$name ==
'polyline') {
25421 $this->StartTransform();
25422 $this->SVGTransform($tm);
25423 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y, $w, $h,
'PolyLine', array($p,
'CNZ'));
25424 $this->PolyLine($p,
'D', array(), array());
25425 $this->StopTransform();
25428 $this->SVGTransform($tm);
25429 $this->Polygon($p,
'CNZ', array(), array(),
true);
25431 $this->StartTransform();
25432 $this->SVGTransform($tm);
25433 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y, $w, $h,
'Polygon', array($p,
'CNZ'));
25434 if (!empty($obstyle)) {
25435 $this->Polygon($p, $obstyle, array(), array(),
true);
25437 $this->StopTransform();
25447 if (!isset($attribs[
'xlink:href']) OR empty($attribs[
'xlink:href'])) {
25450 $x = (isset($attribs[
'x'])?$this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false):0);
25451 $y = (isset($attribs[
'y'])?$this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false):0);
25452 $w = (isset($attribs[
'width'])?$this->getHTMLUnitToUnits($attribs[
'width'], 0, $this->svgunit,
false):0);
25453 $h = (isset($attribs[
'height'])?$this->getHTMLUnitToUnits($attribs[
'height'], 0, $this->svgunit,
false):0);
25454 $img = $attribs[
'xlink:href'];
25456 $this->StartTransform();
25457 $this->SVGTransform($tm);
25458 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y, $w, $h);
25460 if (!$this->empty_string($this->svgdir) AND ((
$img{0} ==
'.') OR (basename(
$img) ==
$img))) {
25464 if ((
$img{0} ==
'/') AND ($_SERVER[
'DOCUMENT_ROOT'] !=
'/')) {
25465 $findroot = strpos(
$img, $_SERVER[
'DOCUMENT_ROOT']);
25466 if (($findroot ===
false) OR ($findroot > 1)) {
25468 $img = $_SERVER[
'DOCUMENT_ROOT'].$img;
25472 $testscrtype = @parse_url(
$img);
25473 if (!isset($testscrtype[
'query']) OR empty($testscrtype[
'query'])) {
25477 $this->Image(
$img,
$x,
$y, $w, $h);
25478 $this->StopTransform();
25485 $this->svgtextmode[
'invisible'] = $invisible;
25489 array_push($this->svgstyles, $svgstyle);
25491 $x = (isset($attribs[
'x'])?$this->getHTMLUnitToUnits($attribs[
'x'], 0, $this->svgunit,
false):
$this->x);
25492 $y = (isset($attribs[
'y'])?$this->getHTMLUnitToUnits($attribs[
'y'], 0, $this->svgunit,
false):
$this->y);
25493 $svgstyle[
'text-color'] = $svgstyle[
'fill'];
25494 $this->svgtext =
'';
25495 if (isset($svgstyle[
'text-anchor'])) {
25496 $this->svgtextmode[
'text-anchor'] = $svgstyle[
'text-anchor'];
25498 $this->svgtextmode[
'text-anchor'] =
'start';
25500 if (isset($svgstyle[
'direction'])) {
25501 if ($svgstyle[
'direction'] ==
'rtl') {
25502 $this->svgtextmode[
'rtl'] =
true;
25504 $this->svgtextmode[
'rtl'] =
false;
25507 $this->svgtextmode[
'rtl'] =
false;
25509 if (isset($svgstyle[
'stroke']) AND ($svgstyle[
'stroke'] !=
'none') AND isset($svgstyle[
'stroke-width']) AND ($svgstyle[
'stroke-width'] > 0)) {
25510 $this->svgtextmode[
'stroke'] = $this->getHTMLUnitToUnits($svgstyle[
'stroke-width'], 0, $this->svgunit,
false);
25512 $this->svgtextmode[
'stroke'] =
false;
25514 $this->StartTransform();
25515 $this->SVGTransform($tm);
25516 $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle,
$x,
$y, 1, 1);
25523 if (isset($attribs[
'xlink:href'])) {
25524 $use = $this->svgdefs[substr($attribs[
'xlink:href'], 1)];
25525 if (isset($attribs[
'xlink:href'])) {
25526 unset($attribs[
'xlink:href']);
25528 if (isset($attribs[
'id'])) {
25529 unset($attribs[
'id']);
25531 $attribs = array_merge($use[
'attribs'], $attribs);
25532 $this->startSVGElementHandler($parser, $use[
'name'], $use[
'attribs']);
25553 $this->svgdefsmode =
false;
25558 $this->svgclipmode =
false;
25563 array_pop($this->svgstyles);
25564 $this->StopTransform();
25569 if ($this->svgtextmode[
'invisible']) {
25575 $text = $this->stringTrim($this->svgtext);
25576 if ($this->svgtextmode[
'text-anchor'] !=
'start') {
25577 $textlen = $this->GetStringWidth($text);
25579 if ($this->svgtextmode[
'text-anchor'] ==
'end') {
25580 if ($this->svgtextmode[
'rtl']) {
25581 $this->x += $textlen;
25583 $this->x -= $textlen;
25585 } elseif ($this->svgtextmode[
'text-anchor'] ==
'middle') {
25586 if ($this->svgtextmode[
'rtl']) {
25587 $this->x += ($textlen / 2);
25589 $this->x -= ($textlen / 2);
25593 $textrendermode = $this->textrendermode;
25594 $textstrokewidth = $this->textstrokewidth;
25595 $this->setTextRenderingMode($this->svgtextmode[
'stroke'],
true,
false);
25596 $this->Cell(0, 0, $text, 0, 0,
'',
false,
'', 0,
false,
'L',
'T');
25598 $this->textrendermode = $textrendermode;
25599 $this->textstrokewidth = $textstrokewidth;
25600 $this->svgtext =
'';
25601 $this->StopTransform();
25602 array_pop($this->svgstyles);
25620 $this->svgtext .=
$data;