PageRenderTime 74ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 2ms

/framework/lib/classes/PHPExcel/Shared/PDF/tcpdf.php

https://bitbucket.org/designbyheart/original
PHP | 13678 lines | 8325 code | 518 blank | 4835 comment | 1728 complexity | 48aaa955d5f2857a2437e30f5e29414a MD5 | raw file
Possible License(s): GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. //============================================================+
  3. // File name : tcpdf.php
  4. // Version : 5.9.009
  5. // Begin : 2002-08-03
  6. // Last Update : 2010-10-21
  7. // Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
  8. // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
  9. // -------------------------------------------------------------------
  10. // Copyright (C) 2002-2010 Nicola Asuni - Tecnick.com S.r.l.
  11. //
  12. // This file is part of TCPDF software library.
  13. //
  14. // TCPDF is free software: you can redistribute it and/or modify it
  15. // under the terms of the GNU Lesser General Public License as
  16. // published by the Free Software Foundation, either version 3 of the
  17. // License, or (at your option) any later version.
  18. //
  19. // TCPDF is distributed in the hope that it will be useful, but
  20. // WITHOUT ANY WARRANTY; without even the implied warranty of
  21. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  22. // See the GNU Lesser General Public License for more details.
  23. //
  24. // You should have received a copy of the GNU Lesser General Public License
  25. // along with TCPDF. If not, see <http://www.gnu.org/licenses/>.
  26. //
  27. // See LICENSE.TXT file for more information.
  28. // -------------------------------------------------------------------
  29. //
  30. // Description : This is a PHP class for generating PDF documents without
  31. // requiring external extensions.
  32. //
  33. // NOTE:
  34. // This class was originally derived in 2002 from the Public
  35. // Domain FPDF class by Olivier Plathey (http://www.fpdf.org),
  36. // but now is almost entirely rewritten and contains thousands of
  37. // new lines of code and hundreds new features.
  38. //
  39. // Main features:
  40. // * no external libraries are required for the basic functions;
  41. // * all standard page formats, custom page formats, custom margins and units of measure;
  42. // * UTF-8 Unicode and Right-To-Left languages;
  43. // * TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;
  44. // * font subsetting;
  45. // * methods to publish some XHTML + CSS code, Javascript and Forms;
  46. // * images, graphic (geometric figures) and transformation methods;
  47. // * supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/www/formats.html)
  48. // * 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, QR-Code, PDF417;
  49. // * Grayscale, RGB, CMYK, Spot Colors and Transparencies;
  50. // * automatic page header and footer management;
  51. // * document encryption up to 256 bit and digital signature certifications;
  52. // * transactions to UNDO commands;
  53. // * PDF annotations, including links, text and file attachments;
  54. // * text rendering modes (fill, stroke and clipping);
  55. // * multiple columns mode;
  56. // * no-write page regions;
  57. // * bookmarks and table of content;
  58. // * text hyphenation;
  59. // * text stretching and spacing (tracking/kerning);
  60. // * automatic page break, line break and text alignments including justification;
  61. // * automatic page numbering and page groups;
  62. // * move and delete pages;
  63. // * page compression (requires php-zlib extension);
  64. // * XOBject Templates;
  65. //
  66. // -----------------------------------------------------------
  67. // THANKS TO:
  68. //
  69. // Olivier Plathey (http://www.fpdf.org) for original FPDF.
  70. // Efthimios Mavrogeorgiadis (emavro@yahoo.com) for suggestions on RTL language support.
  71. // Klemen Vodopivec (http://www.fpdf.de/downloads/addons/37/) for Encryption algorithm.
  72. // Warren Sherliker (wsherliker@gmail.com) for better image handling.
  73. // dullus for text Justification.
  74. // Bob Vincent (pillarsdotnet@users.sourceforge.net) for <li> value attribute.
  75. // Patrick Benny for text stretch suggestion on Cell().
  76. // Johannes Güntert for JavaScript support.
  77. // Denis Van Nuffelen for Dynamic Form.
  78. // Jacek Czekaj for multibyte justification
  79. // Anthony Ferrara for the reintroduction of legacy image methods.
  80. // Sourceforge user 1707880 (hucste) for line-trough mode.
  81. // Larry Stanbery for page groups.
  82. // Martin Hall-May for transparency.
  83. // Aaron C. Spike for Polycurve method.
  84. // Mohamad Ali Golkar, Saleh AlMatrafe, Charles Abbott for Arabic and Persian support.
  85. // Moritz Wagner and Andreas Wurmser for graphic functions.
  86. // Andrew Whitehead for core fonts support.
  87. // Esteban Joël Marín for OpenType font conversion.
  88. // Teus Hagen for several suggestions and fixes.
  89. // Yukihiro Nakadaira for CID-0 CJK fonts fixes.
  90. // Kosmas Papachristos for some CSS improvements.
  91. // Marcel Partap for some fixes.
  92. // Won Kyu Park for several suggestions, fixes and patches.
  93. // Dominik Dzienia for QR-code support.
  94. // Laurent Minguet for some suggestions.
  95. // Christian Deligant for some suggestions and fixes.
  96. // Anyone that has reported a bug or sent a suggestion.
  97. //============================================================+
  98. /**
  99. * This is a PHP class for generating PDF documents without requiring external extensions.<br>
  100. * TCPDF project (http://www.tcpdf.org) was originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
  101. * <h3>TCPDF main features are:</h3>
  102. * <ul>
  103. * <li>no external libraries are required for the basic functions;</li>
  104. * <li>all standard page formats, custom page formats, custom margins and units of measure;</li>
  105. * <li>UTF-8 Unicode and Right-To-Left languages;</li>
  106. * <li>TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;</li>
  107. * <li>font subsetting;</li>
  108. * <li>methods to publish some XHTML + CSS code, Javascript and Forms;</li>
  109. * <li>images, graphic (geometric figures) and transformation methods;
  110. * <li>supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/www/formats.html)</li>
  111. * <li>1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, QR-Code, PDF417;</li>
  112. * <li>Grayscale, RGB, CMYK, Spot Colors and Transparencies;</li>
  113. * <li>automatic page header and footer management;</li>
  114. * <li>document encryption up to 256 bit and digital signature certifications;</li>
  115. * <li>transactions to UNDO commands;</li>
  116. * <li>PDF annotations, including links, text and file attachments;</li>
  117. * <li>text rendering modes (fill, stroke and clipping);</li>
  118. * <li>multiple columns mode;</li>
  119. * <li>no-write page regions;</li>
  120. * <li>bookmarks and table of content;</li>
  121. * <li>text hyphenation;</li>
  122. * <li>text stretching and spacing (tracking/kerning);</li>
  123. * <li>automatic page break, line break and text alignments including justification;</li>
  124. * <li>automatic page numbering and page groups;</li>
  125. * <li>move and delete pages;</li>
  126. * <li>page compression (requires php-zlib extension);</li>
  127. * <li>XOBject Templates;</li>
  128. * </ul>
  129. * Tools to encode your unicode fonts are on fonts/utils directory.</p>
  130. * @package com.tecnick.tcpdf
  131. * @abstract Class for generating PDF files on-the-fly without requiring external extensions.
  132. * @author Nicola Asuni
  133. * @copyright 2002-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
  134. * @link http://www.tcpdf.org
  135. * @license http://www.gnu.org/copyleft/lesser.html LGPL
  136. * @version 5.9.009
  137. */
  138. /**
  139. * main configuration file
  140. * (define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file)
  141. */
  142. require_once(dirname(__FILE__).'/config/tcpdf_config.php');
  143. /**
  144. * define default PDF document producer
  145. */
  146. define('PDF_PRODUCER', 'TCPDF 5.9.009 (http://www.tcpdf.org)');
  147. /**
  148. * This is a PHP class for generating PDF documents without requiring external extensions.<br>
  149. * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
  150. * @name TCPDF
  151. * @package com.tecnick.tcpdf
  152. * @version 5.9.009
  153. * @author Nicola Asuni - info@tecnick.com
  154. * @link http://www.tcpdf.org
  155. * @license http://www.gnu.org/copyleft/lesser.html LGPL
  156. */
  157. class TCPDF {
  158. // Protected properties
  159. /**
  160. * @var current page number
  161. * @access protected
  162. */
  163. protected $page;
  164. /**
  165. * @var current object number
  166. * @access protected
  167. */
  168. protected $n;
  169. /**
  170. * @var array of object offsets
  171. * @access protected
  172. */
  173. protected $offsets;
  174. /**
  175. * @var buffer holding in-memory PDF
  176. * @access protected
  177. */
  178. protected $buffer;
  179. /**
  180. * @var array containing pages
  181. * @access protected
  182. */
  183. protected $pages = array();
  184. /**
  185. * @var current document state
  186. * @access protected
  187. */
  188. protected $state;
  189. /**
  190. * @var compression flag
  191. * @access protected
  192. */
  193. protected $compress;
  194. /**
  195. * @var current page orientation (P = Portrait, L = Landscape)
  196. * @access protected
  197. */
  198. protected $CurOrientation;
  199. /**
  200. * @var Page dimensions
  201. * @access protected
  202. */
  203. protected $pagedim = array();
  204. /**
  205. * @var scale factor (number of points in user unit)
  206. * @access protected
  207. */
  208. protected $k;
  209. /**
  210. * @var width of page format in points
  211. * @access protected
  212. */
  213. protected $fwPt;
  214. /**
  215. * @var height of page format in points
  216. * @access protected
  217. */
  218. protected $fhPt;
  219. /**
  220. * @var current width of page in points
  221. * @access protected
  222. */
  223. protected $wPt;
  224. /**
  225. * @var current height of page in points
  226. * @access protected
  227. */
  228. protected $hPt;
  229. /**
  230. * @var current width of page in user unit
  231. * @access protected
  232. */
  233. protected $w;
  234. /**
  235. * @var current height of page in user unit
  236. * @access protected
  237. */
  238. protected $h;
  239. /**
  240. * @var left margin
  241. * @access protected
  242. */
  243. protected $lMargin;
  244. /**
  245. * @var top margin
  246. * @access protected
  247. */
  248. protected $tMargin;
  249. /**
  250. * @var right margin
  251. * @access protected
  252. */
  253. protected $rMargin;
  254. /**
  255. * @var page break margin
  256. * @access protected
  257. */
  258. protected $bMargin;
  259. /**
  260. * @var array of cell internal paddings ('T' => top, 'R' => right, 'B' => bottom, 'L' => left)
  261. * @since 5.9.000 (2010-10-03)
  262. * @access protected
  263. */
  264. protected $cell_padding = array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0);
  265. /**
  266. * @var array of cell margins ('T' => top, 'R' => right, 'B' => bottom, 'L' => left)
  267. * @since 5.9.000 (2010-10-04)
  268. * @access protected
  269. */
  270. protected $cell_margin = array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0);
  271. /**
  272. * @var current horizontal position in user unit for cell positioning
  273. * @access protected
  274. */
  275. protected $x;
  276. /**
  277. * @var current vertical position in user unit for cell positioning
  278. * @access protected
  279. */
  280. protected $y;
  281. /**
  282. * @var height of last cell printed
  283. * @access protected
  284. */
  285. protected $lasth;
  286. /**
  287. * @var line width in user unit
  288. * @access protected
  289. */
  290. protected $LineWidth;
  291. /**
  292. * @var array of standard font names
  293. * @access protected
  294. */
  295. protected $CoreFonts;
  296. /**
  297. * @var array of used fonts
  298. * @access protected
  299. */
  300. protected $fonts = array();
  301. /**
  302. * @var array of font files
  303. * @access protected
  304. */
  305. protected $FontFiles = array();
  306. /**
  307. * @var array of encoding differences
  308. * @access protected
  309. */
  310. protected $diffs = array();
  311. /**
  312. * @var array of used images
  313. * @access protected
  314. */
  315. protected $images = array();
  316. /**
  317. * @var array of Annotations in pages
  318. * @access protected
  319. */
  320. protected $PageAnnots = array();
  321. /**
  322. * @var array of internal links
  323. * @access protected
  324. */
  325. protected $links = array();
  326. /**
  327. * @var current font family
  328. * @access protected
  329. */
  330. protected $FontFamily;
  331. /**
  332. * @var current font style
  333. * @access protected
  334. */
  335. protected $FontStyle;
  336. /**
  337. * @var current font ascent (distance between font top and baseline)
  338. * @access protected
  339. * @since 2.8.000 (2007-03-29)
  340. */
  341. protected $FontAscent;
  342. /**
  343. * @var current font descent (distance between font bottom and baseline)
  344. * @access protected
  345. * @since 2.8.000 (2007-03-29)
  346. */
  347. protected $FontDescent;
  348. /**
  349. * @var underlining flag
  350. * @access protected
  351. */
  352. protected $underline;
  353. /**
  354. * @var overlining flag
  355. * @access protected
  356. */
  357. protected $overline;
  358. /**
  359. * @var current font info
  360. * @access protected
  361. */
  362. protected $CurrentFont;
  363. /**
  364. * @var current font size in points
  365. * @access protected
  366. */
  367. protected $FontSizePt;
  368. /**
  369. * @var current font size in user unit
  370. * @access protected
  371. */
  372. protected $FontSize;
  373. /**
  374. * @var commands for drawing color
  375. * @access protected
  376. */
  377. protected $DrawColor;
  378. /**
  379. * @var commands for filling color
  380. * @access protected
  381. */
  382. protected $FillColor;
  383. /**
  384. * @var commands for text color
  385. * @access protected
  386. */
  387. protected $TextColor;
  388. /**
  389. * @var indicates whether fill and text colors are different
  390. * @access protected
  391. */
  392. protected $ColorFlag;
  393. /**
  394. * @var automatic page breaking
  395. * @access protected
  396. */
  397. protected $AutoPageBreak;
  398. /**
  399. * @var threshold used to trigger page breaks
  400. * @access protected
  401. */
  402. protected $PageBreakTrigger;
  403. /**
  404. * @var flag set when processing footer
  405. * @access protected
  406. */
  407. protected $InFooter = false;
  408. /**
  409. * @var zoom display mode
  410. * @access protected
  411. */
  412. protected $ZoomMode;
  413. /**
  414. * @var layout display mode
  415. * @access protected
  416. */
  417. protected $LayoutMode;
  418. /**
  419. * @var title
  420. * @access protected
  421. */
  422. protected $title = '';
  423. /**
  424. * @var subject
  425. * @access protected
  426. */
  427. protected $subject = '';
  428. /**
  429. * @var author
  430. * @access protected
  431. */
  432. protected $author = '';
  433. /**
  434. * @var keywords
  435. * @access protected
  436. */
  437. protected $keywords = '';
  438. /**
  439. * @var creator
  440. * @access protected
  441. */
  442. protected $creator = '';
  443. /**
  444. * @var alias for total number of pages
  445. * @access protected
  446. */
  447. protected $AliasNbPages = '{nb}';
  448. /**
  449. * @var alias for page number
  450. * @access protected
  451. */
  452. protected $AliasNumPage = '{pnb}';
  453. /**
  454. * @var right-bottom corner X coordinate of inserted image
  455. * @since 2002-07-31
  456. * @author Nicola Asuni
  457. * @access protected
  458. */
  459. protected $img_rb_x;
  460. /**
  461. * @var right-bottom corner Y coordinate of inserted image
  462. * @since 2002-07-31
  463. * @author Nicola Asuni
  464. * @access protected
  465. */
  466. protected $img_rb_y;
  467. /**
  468. * @var adjusting factor to convert pixels to user units.
  469. * @since 2004-06-14
  470. * @author Nicola Asuni
  471. * @access protected
  472. */
  473. protected $imgscale = 1;
  474. /**
  475. * @var boolean set to true when the input text is unicode (require unicode fonts)
  476. * @since 2005-01-02
  477. * @author Nicola Asuni
  478. * @access protected
  479. */
  480. protected $isunicode = false;
  481. /**
  482. * @var object containing unicode data
  483. * @since 5.9.004 (2010-10-18)
  484. * @author Nicola Asuni
  485. * @access protected
  486. */
  487. protected $unicode;
  488. /**
  489. * @var PDF version
  490. * @since 1.5.3
  491. * @access protected
  492. */
  493. protected $PDFVersion = '1.7';
  494. /**
  495. * @var Minimum distance between header and top page margin.
  496. * @access protected
  497. */
  498. protected $header_margin;
  499. /**
  500. * @var Minimum distance between footer and bottom page margin.
  501. * @access protected
  502. */
  503. protected $footer_margin;
  504. /**
  505. * @var original left margin value
  506. * @access protected
  507. * @since 1.53.0.TC013
  508. */
  509. protected $original_lMargin;
  510. /**
  511. * @var original right margin value
  512. * @access protected
  513. * @since 1.53.0.TC013
  514. */
  515. protected $original_rMargin;
  516. /**
  517. * @var Header font.
  518. * @access protected
  519. */
  520. protected $header_font;
  521. /**
  522. * @var Footer font.
  523. * @access protected
  524. */
  525. protected $footer_font;
  526. /**
  527. * @var Language templates.
  528. * @access protected
  529. */
  530. protected $l;
  531. /**
  532. * @var Barcode to print on page footer (only if set).
  533. * @access protected
  534. */
  535. protected $barcode = false;
  536. /**
  537. * @var If true prints header
  538. * @access protected
  539. */
  540. protected $print_header = true;
  541. /**
  542. * @var If true prints footer.
  543. * @access protected
  544. */
  545. protected $print_footer = true;
  546. /**
  547. * @var Header image logo.
  548. * @access protected
  549. */
  550. protected $header_logo = '';
  551. /**
  552. * @var Header image logo width in mm.
  553. * @access protected
  554. */
  555. protected $header_logo_width = 30;
  556. /**
  557. * @var String to print as title on document header.
  558. * @access protected
  559. */
  560. protected $header_title = '';
  561. /**
  562. * @var String to print on document header.
  563. * @access protected
  564. */
  565. protected $header_string = '';
  566. /**
  567. * @var Default number of columns for html table.
  568. * @access protected
  569. */
  570. protected $default_table_columns = 4;
  571. // variables for html parser
  572. /**
  573. * @var HTML PARSER: array to store current link and rendering styles.
  574. * @access protected
  575. */
  576. protected $HREF = array();
  577. /**
  578. * @var store a list of available fonts on filesystem.
  579. * @access protected
  580. */
  581. protected $fontlist = array();
  582. /**
  583. * @var current foreground color
  584. * @access protected
  585. */
  586. protected $fgcolor;
  587. /**
  588. * @var HTML PARSER: array of boolean values, true in case of ordered list (OL), false otherwise.
  589. * @access protected
  590. */
  591. protected $listordered = array();
  592. /**
  593. * @var HTML PARSER: array count list items on nested lists.
  594. * @access protected
  595. */
  596. protected $listcount = array();
  597. /**
  598. * @var HTML PARSER: current list nesting level.
  599. * @access protected
  600. */
  601. protected $listnum = 0;
  602. /**
  603. * @var HTML PARSER: indent amount for lists.
  604. * @access protected
  605. */
  606. protected $listindent = 0;
  607. /**
  608. * @var HTML PARSER: current list indententation level.
  609. * @access protected
  610. */
  611. protected $listindentlevel = 0;
  612. /**
  613. * @var current background color
  614. * @access protected
  615. */
  616. protected $bgcolor;
  617. /**
  618. * @var Store temporary font size in points.
  619. * @access protected
  620. */
  621. protected $tempfontsize = 10;
  622. /**
  623. * @var spacer for LI tags.
  624. * @access protected
  625. */
  626. protected $lispacer = '';
  627. /**
  628. * @var default encoding
  629. * @access protected
  630. * @since 1.53.0.TC010
  631. */
  632. protected $encoding = 'UTF-8';
  633. /**
  634. * @var PHP internal encoding
  635. * @access protected
  636. * @since 1.53.0.TC016
  637. */
  638. protected $internal_encoding;
  639. /**
  640. * @var indicates if the document language is Right-To-Left
  641. * @access protected
  642. * @since 2.0.000
  643. */
  644. protected $rtl = false;
  645. /**
  646. * @var used to force RTL or LTR string inversion
  647. * @access protected
  648. * @since 2.0.000
  649. */
  650. protected $tmprtl = false;
  651. // --- Variables used for document encryption:
  652. /**
  653. * Indicates whether document is protected
  654. * @access protected
  655. * @since 2.0.000 (2008-01-02)
  656. */
  657. protected $encrypted;
  658. /**
  659. * Array containing encryption settings
  660. * @access protected
  661. * @since 5.0.005 (2010-05-11)
  662. */
  663. protected $encryptdata = array();
  664. /**
  665. * last RC4 key encrypted (cached for optimisation)
  666. * @access protected
  667. * @since 2.0.000 (2008-01-02)
  668. */
  669. protected $last_enc_key;
  670. /**
  671. * last RC4 computed key
  672. * @access protected
  673. * @since 2.0.000 (2008-01-02)
  674. */
  675. protected $last_enc_key_c;
  676. /**
  677. * Encryption padding
  678. * @access protected
  679. */
  680. 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";
  681. /**
  682. * File ID (used on trailer)
  683. * @access protected
  684. * @since 5.0.005 (2010-05-12)
  685. */
  686. protected $file_id;
  687. // --- bookmark ---
  688. /**
  689. * Outlines for bookmark
  690. * @access protected
  691. * @since 2.1.002 (2008-02-12)
  692. */
  693. protected $outlines = array();
  694. /**
  695. * Outline root for bookmark
  696. * @access protected
  697. * @since 2.1.002 (2008-02-12)
  698. */
  699. protected $OutlineRoot;
  700. // --- javascript and form ---
  701. /**
  702. * javascript code
  703. * @access protected
  704. * @since 2.1.002 (2008-02-12)
  705. */
  706. protected $javascript = '';
  707. /**
  708. * javascript counter
  709. * @access protected
  710. * @since 2.1.002 (2008-02-12)
  711. */
  712. protected $n_js;
  713. /**
  714. * line trough state
  715. * @access protected
  716. * @since 2.8.000 (2008-03-19)
  717. */
  718. protected $linethrough;
  719. /**
  720. * Array with additional document-wide usage rights for the document.
  721. * @access protected
  722. * @since 5.8.014 (2010-08-23)
  723. */
  724. protected $ur = array();
  725. /**
  726. * Dot Per Inch Document Resolution (do not change)
  727. * @access protected
  728. * @since 3.0.000 (2008-03-27)
  729. */
  730. protected $dpi = 72;
  731. /**
  732. * Array of page numbers were a new page group was started
  733. * @access protected
  734. * @since 3.0.000 (2008-03-27)
  735. */
  736. protected $newpagegroup = array();
  737. /**
  738. * Contains the number of pages of the groups
  739. * @access protected
  740. * @since 3.0.000 (2008-03-27)
  741. */
  742. protected $pagegroups;
  743. /**
  744. * Contains the alias of the current page group
  745. * @access protected
  746. * @since 3.0.000 (2008-03-27)
  747. */
  748. protected $currpagegroup;
  749. /**
  750. * Restrict the rendering of some elements to screen or printout.
  751. * @access protected
  752. * @since 3.0.000 (2008-03-27)
  753. */
  754. protected $visibility = 'all';
  755. /**
  756. * Print visibility.
  757. * @access protected
  758. * @since 3.0.000 (2008-03-27)
  759. */
  760. protected $n_ocg_print;
  761. /**
  762. * View visibility.
  763. * @access protected
  764. * @since 3.0.000 (2008-03-27)
  765. */
  766. protected $n_ocg_view;
  767. /**
  768. * Array of transparency objects and parameters.
  769. * @access protected
  770. * @since 3.0.000 (2008-03-27)
  771. */
  772. protected $extgstates;
  773. /**
  774. * Set the default JPEG compression quality (1-100)
  775. * @access protected
  776. * @since 3.0.000 (2008-03-27)
  777. */
  778. protected $jpeg_quality;
  779. /**
  780. * Default cell height ratio.
  781. * @access protected
  782. * @since 3.0.014 (2008-05-23)
  783. */
  784. protected $cell_height_ratio = K_CELL_HEIGHT_RATIO;
  785. /**
  786. * PDF viewer preferences.
  787. * @access protected
  788. * @since 3.1.000 (2008-06-09)
  789. */
  790. protected $viewer_preferences;
  791. /**
  792. * A name object specifying how the document should be displayed when opened.
  793. * @access protected
  794. * @since 3.1.000 (2008-06-09)
  795. */
  796. protected $PageMode;
  797. /**
  798. * Array for storing gradient information.
  799. * @access protected
  800. * @since 3.1.000 (2008-06-09)
  801. */
  802. protected $gradients = array();
  803. /**
  804. * Array used to store positions inside the pages buffer.
  805. * keys are the page numbers
  806. * @access protected
  807. * @since 3.2.000 (2008-06-26)
  808. */
  809. protected $intmrk = array();
  810. /**
  811. * Array used to store positions inside the pages buffer.
  812. * keys are the page numbers
  813. * @access protected
  814. * @since 5.7.000 (2010-08-03)
  815. */
  816. protected $bordermrk = array();
  817. /**
  818. * Array used to store page positions to track empty pages.
  819. * keys are the page numbers
  820. * @access protected
  821. * @since 5.8.007 (2010-08-18)
  822. */
  823. protected $emptypagemrk = array();
  824. /**
  825. * Array used to store content positions inside the pages buffer.
  826. * keys are the page numbers
  827. * @access protected
  828. * @since 4.6.021 (2009-07-20)
  829. */
  830. protected $cntmrk = array();
  831. /**
  832. * Array used to store footer positions of each page.
  833. * @access protected
  834. * @since 3.2.000 (2008-07-01)
  835. */
  836. protected $footerpos = array();
  837. /**
  838. * Array used to store footer length of each page.
  839. * @access protected
  840. * @since 4.0.014 (2008-07-29)
  841. */
  842. protected $footerlen = array();
  843. /**
  844. * True if a newline is created.
  845. * @access protected
  846. * @since 3.2.000 (2008-07-01)
  847. */
  848. protected $newline = true;
  849. /**
  850. * End position of the latest inserted line
  851. * @access protected
  852. * @since 3.2.000 (2008-07-01)
  853. */
  854. protected $endlinex = 0;
  855. /**
  856. * PDF string for last line width
  857. * @access protected
  858. * @since 4.0.006 (2008-07-16)
  859. */
  860. protected $linestyleWidth = '';
  861. /**
  862. * PDF string for last line width
  863. * @access protected
  864. * @since 4.0.006 (2008-07-16)
  865. */
  866. protected $linestyleCap = '0 J';
  867. /**
  868. * PDF string for last line width
  869. * @access protected
  870. * @since 4.0.006 (2008-07-16)
  871. */
  872. protected $linestyleJoin = '0 j';
  873. /**
  874. * PDF string for last line width
  875. * @access protected
  876. * @since 4.0.006 (2008-07-16)
  877. */
  878. protected $linestyleDash = '[] 0 d';
  879. /**
  880. * True if marked-content sequence is open
  881. * @access protected
  882. * @since 4.0.013 (2008-07-28)
  883. */
  884. protected $openMarkedContent = false;
  885. /**
  886. * Count the latest inserted vertical spaces on HTML
  887. * @access protected
  888. * @since 4.0.021 (2008-08-24)
  889. */
  890. protected $htmlvspace = 0;
  891. /**
  892. * Array of Spot colors
  893. * @access protected
  894. * @since 4.0.024 (2008-09-12)
  895. */
  896. protected $spot_colors = array();
  897. /**
  898. * Symbol used for HTML unordered list items
  899. * @access protected
  900. * @since 4.0.028 (2008-09-26)
  901. */
  902. protected $lisymbol = '';
  903. /**
  904. * String used to mark the beginning and end of EPS image blocks
  905. * @access protected
  906. * @since 4.1.000 (2008-10-18)
  907. */
  908. protected $epsmarker = 'x#!#EPS#!#x';
  909. /**
  910. * Array of transformation matrix
  911. * @access protected
  912. * @since 4.2.000 (2008-10-29)
  913. */
  914. protected $transfmatrix = array();
  915. /**
  916. * Current key for transformation matrix
  917. * @access protected
  918. * @since 4.8.005 (2009-09-17)
  919. */
  920. protected $transfmatrix_key = 0;
  921. /**
  922. * Booklet mode for double-sided pages
  923. * @access protected
  924. * @since 4.2.000 (2008-10-29)
  925. */
  926. protected $booklet = false;
  927. /**
  928. * Epsilon value used for float calculations
  929. * @access protected
  930. * @since 4.2.000 (2008-10-29)
  931. */
  932. protected $feps = 0.005;
  933. /**
  934. * Array used for custom vertical spaces for HTML tags
  935. * @access protected
  936. * @since 4.2.001 (2008-10-30)
  937. */
  938. protected $tagvspaces = array();
  939. /**
  940. * @var HTML PARSER: custom indent amount for lists.
  941. * Negative value means disabled.
  942. * @access protected
  943. * @since 4.2.007 (2008-11-12)
  944. */
  945. protected $customlistindent = -1;
  946. /**
  947. * @var if true keeps the border open for the cell sides that cross the page.
  948. * @access protected
  949. * @since 4.2.010 (2008-11-14)
  950. */
  951. protected $opencell = true;
  952. /**
  953. * @var array of files to embedd
  954. * @access protected
  955. * @since 4.4.000 (2008-12-07)
  956. */
  957. protected $embeddedfiles = array();
  958. /**
  959. * @var boolean true when inside html pre tag
  960. * @access protected
  961. * @since 4.4.001 (2008-12-08)
  962. */
  963. protected $premode = false;
  964. /**
  965. * Array used to store positions of graphics transformation blocks inside the page buffer.
  966. * keys are the page numbers
  967. * @access protected
  968. * @since 4.4.002 (2008-12-09)
  969. */
  970. protected $transfmrk = array();
  971. /**
  972. * Default color for html links
  973. * @access protected
  974. * @since 4.4.003 (2008-12-09)
  975. */
  976. protected $htmlLinkColorArray = array(0, 0, 255);
  977. /**
  978. * Default font style to add to html links
  979. * @access protected
  980. * @since 4.4.003 (2008-12-09)
  981. */
  982. protected $htmlLinkFontStyle = 'U';
  983. /**
  984. * Counts the number of pages.
  985. * @access protected
  986. * @since 4.5.000 (2008-12-31)
  987. */
  988. protected $numpages = 0;
  989. /**
  990. * Array containing page lengths in bytes.
  991. * @access protected
  992. * @since 4.5.000 (2008-12-31)
  993. */
  994. protected $pagelen = array();
  995. /**
  996. * Counts the number of pages.
  997. * @access protected
  998. * @since 4.5.000 (2008-12-31)
  999. */
  1000. protected $numimages = 0;
  1001. /**
  1002. * Store the image keys.
  1003. * @access protected
  1004. * @since 4.5.000 (2008-12-31)
  1005. */
  1006. protected $imagekeys = array();
  1007. /**
  1008. * Length of the buffer in bytes.
  1009. * @access protected
  1010. * @since 4.5.000 (2008-12-31)
  1011. */
  1012. protected $bufferlen = 0;
  1013. /**
  1014. * If true enables disk caching.
  1015. * @access protected
  1016. * @since 4.5.000 (2008-12-31)
  1017. */
  1018. protected $diskcache = false;
  1019. /**
  1020. * Counts the number of fonts.
  1021. * @access protected
  1022. * @since 4.5.000 (2009-01-02)
  1023. */
  1024. protected $numfonts = 0;
  1025. /**
  1026. * Store the font keys.
  1027. * @access protected
  1028. * @since 4.5.000 (2009-01-02)
  1029. */
  1030. protected $fontkeys = array();
  1031. /**
  1032. * Store the font object IDs.
  1033. * @access protected
  1034. * @since 4.8.001 (2009-09-09)
  1035. */
  1036. protected $font_obj_ids = array();
  1037. /**
  1038. * Store the fage status (true when opened, false when closed).
  1039. * @access protected
  1040. * @since 4.5.000 (2009-01-02)
  1041. */
  1042. protected $pageopen = array();
  1043. /**
  1044. * Default monospaced font
  1045. * @access protected
  1046. * @since 4.5.025 (2009-03-10)
  1047. */
  1048. protected $default_monospaced_font = 'courier';
  1049. /**
  1050. * Used to store a cloned copy of the current class object
  1051. * @access protected
  1052. * @since 4.5.029 (2009-03-19)
  1053. */
  1054. protected $objcopy;
  1055. /**
  1056. * Array used to store the lengths of cache files
  1057. * @access protected
  1058. * @since 4.5.029 (2009-03-19)
  1059. */
  1060. protected $cache_file_length = array();
  1061. /**
  1062. * Table header content to be repeated on each new page
  1063. * @access protected
  1064. * @since 4.5.030 (2009-03-20)
  1065. */
  1066. protected $thead = '';
  1067. /**
  1068. * Margins used for table header.
  1069. * @access protected
  1070. * @since 4.5.030 (2009-03-20)
  1071. */
  1072. protected $theadMargins = array();
  1073. /**
  1074. * Cache array for UTF8StringToArray() method.
  1075. * @access protected
  1076. * @since 4.5.037 (2009-04-07)
  1077. */
  1078. protected $cache_UTF8StringToArray = array();
  1079. /**
  1080. * Maximum size of cache array used for UTF8StringToArray() method.
  1081. * @access protected
  1082. * @since 4.5.037 (2009-04-07)
  1083. */
  1084. protected $cache_maxsize_UTF8StringToArray = 8;
  1085. /**
  1086. * Current size of cache array used for UTF8StringToArray() method.
  1087. * @access protected
  1088. * @since 4.5.037 (2009-04-07)
  1089. */
  1090. protected $cache_size_UTF8StringToArray = 0;
  1091. /**
  1092. * If true enables document signing
  1093. * @access protected
  1094. * @since 4.6.005 (2009-04-24)
  1095. */
  1096. protected $sign = false;
  1097. /**
  1098. * Signature data
  1099. * @access protected
  1100. * @since 4.6.005 (2009-04-24)
  1101. */
  1102. protected $signature_data = array();
  1103. /**
  1104. * Signature max length
  1105. * @access protected
  1106. * @since 4.6.005 (2009-04-24)
  1107. */
  1108. protected $signature_max_length = 11742;
  1109. /**
  1110. * data for signature appearance
  1111. * @access protected
  1112. * @since 5.3.011 (2010-06-16)
  1113. */
  1114. protected $signature_appearance = array('page' => 1, 'rect' => '0 0 0 0');
  1115. /**
  1116. * Regular expression used to find blank characters used for word-wrapping.
  1117. * @access protected
  1118. * @since 4.6.006 (2009-04-28)
  1119. */
  1120. protected $re_spaces = '/[^\S\xa0]/';
  1121. /**
  1122. * Array of parts $re_spaces
  1123. * @access protected
  1124. * @since 5.5.011 (2010-07-09)
  1125. */
  1126. protected $re_space = array('p' => '[^\S\xa0]', 'm' => '');
  1127. /**
  1128. * Signature object ID
  1129. * @access protected
  1130. * @since 4.6.022 (2009-06-23)
  1131. */
  1132. protected $sig_obj_id = 0;
  1133. /**
  1134. * ByteRange placemark used during signature process.
  1135. * @access protected
  1136. * @since 4.6.028 (2009-08-25)
  1137. */
  1138. protected $byterange_string = '/ByteRange[0 ********** ********** **********]';
  1139. /**
  1140. * Placemark used during signature process.
  1141. * @access protected
  1142. * @since 4.6.028 (2009-08-25)
  1143. */
  1144. protected $sig_annot_ref = '***SIGANNREF*** 0 R';
  1145. /**
  1146. * ID of page objects
  1147. * @access protected
  1148. * @since 4.7.000 (2009-08-29)
  1149. */
  1150. protected $page_obj_id = array();
  1151. /**
  1152. * List of form annotations IDs
  1153. * @access protected
  1154. * @since 4.8.000 (2009-09-07)
  1155. */
  1156. protected $form_obj_id = array();
  1157. /**
  1158. * Deafult Javascript field properties. Possible values are described on official Javascript for Acrobat API reference. Annotation options can be directly specified using the 'aopt' entry.
  1159. * @access protected
  1160. * @since 4.8.000 (2009-09-07)
  1161. */
  1162. protected $default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
  1163. /**
  1164. * Javascript objects array
  1165. * @access protected
  1166. * @since 4.8.000 (2009-09-07)
  1167. */
  1168. protected $js_objects = array();
  1169. /**
  1170. * Current form action (used during XHTML rendering)
  1171. * @access protected
  1172. * @since 4.8.000 (2009-09-07)
  1173. */
  1174. protected $form_action = '';
  1175. /**
  1176. * Current form encryption type (used during XHTML rendering)
  1177. * @access protected
  1178. * @since 4.8.000 (2009-09-07)
  1179. */
  1180. protected $form_enctype = 'application/x-www-form-urlencoded';
  1181. /**
  1182. * Current method to submit forms.
  1183. * @access protected
  1184. * @since 4.8.000 (2009-09-07)
  1185. */
  1186. protected $form_mode = 'post';
  1187. /**
  1188. * List of fonts used on form fields (fontname => fontkey).
  1189. * @access protected
  1190. * @since 4.8.001 (2009-09-09)
  1191. */
  1192. protected $annotation_fonts = array();
  1193. /**
  1194. * List of radio buttons parent objects.
  1195. * @access protected
  1196. * @since 4.8.001 (2009-09-09)
  1197. */
  1198. protected $radiobutton_groups = array();
  1199. /**
  1200. * List of radio group objects IDs
  1201. * @access protected
  1202. * @since 4.8.001 (2009-09-09)
  1203. */
  1204. protected $radio_groups = array();
  1205. /**
  1206. * Text indentation value (used for text-indent CSS attribute)
  1207. * @access protected
  1208. * @since 4.8.006 (2009-09-23)
  1209. */
  1210. protected $textindent = 0;
  1211. /**
  1212. * Store page number when startTransaction() is called.
  1213. * @access protected
  1214. * @since 4.8.006 (2009-09-23)
  1215. */
  1216. protected $start_transaction_page = 0;
  1217. /**
  1218. * Store Y position when startTransaction() is called.
  1219. * @access protected
  1220. * @since 4.9.001 (2010-03-28)
  1221. */
  1222. protected $start_transaction_y = 0;
  1223. /**
  1224. * True when we are printing the thead section on a new page
  1225. * @access protected
  1226. * @since 4.8.027 (2010-01-25)
  1227. */
  1228. protected $inthead = false;
  1229. /**
  1230. * Array of column measures (width, space, starting Y position)
  1231. * @access protected
  1232. * @since 4.9.001 (2010-03-28)
  1233. */
  1234. protected $columns = array();
  1235. /**
  1236. * Number of colums
  1237. * @access protected
  1238. * @since 4.9.001 (2010-03-28)
  1239. */
  1240. protected $num_columns = 1;
  1241. /**
  1242. * Current column number
  1243. * @access protected
  1244. * @since 4.9.001 (2010-03-28)
  1245. */
  1246. protected $current_column = 0;
  1247. /**
  1248. * Starting page for columns
  1249. * @access protected
  1250. * @since 4.9.001 (2010-03-28)
  1251. */
  1252. protected $column_start_page = 0;
  1253. /**
  1254. * Maximum page and column selected
  1255. * @access protected
  1256. * @since 5.8.000 (2010-08-11)
  1257. */
  1258. protected $maxselcol = array('page' => 0, 'column' => 0);
  1259. /**
  1260. * Array of: X difference between table cell x start and starting page margin, cellspacing, cellpadding
  1261. * @access protected
  1262. * @since 5.8.000 (2010-08-11)
  1263. */
  1264. protected $colxshift = array('x' => 0, 's' => 0, 'p' => 0);
  1265. /**
  1266. * Text rendering mode: 0 = Fill text; 1 = Stroke text; 2 = Fill, then stroke text; 3 = Neither fill nor stroke text (invisible); 4 = Fill text and add to path for clipping; 5 = Stroke text and add to path for clipping; 6 = Fill, then stroke text and add to path for clipping; 7 = Add text to path for clipping.
  1267. * @access protected
  1268. * @since 4.9.008 (2010-04-03)
  1269. */
  1270. protected $textrendermode = 0;
  1271. /**
  1272. * Text stroke width in doc units
  1273. * @access protected
  1274. * @since 4.9.008 (2010-04-03)
  1275. */
  1276. protected $textstrokewidth = 0;
  1277. /**
  1278. * @var current stroke color
  1279. * @access protected
  1280. * @since 4.9.008 (2010-04-03)
  1281. */
  1282. protected $strokecolor;
  1283. /**
  1284. * @var default unit of measure for document
  1285. * @access protected
  1286. * @since 5.0.000 (2010-04-22)
  1287. */
  1288. protected $pdfunit = 'mm';
  1289. /**
  1290. * @var true when we are on TOC (Table Of Content) page
  1291. * @access protected
  1292. */
  1293. protected $tocpage = false;
  1294. /**
  1295. * @var If true convert vector images (SVG, EPS) to raster image using GD or ImageMagick library.
  1296. * @access protected
  1297. * @since 5.0.000 (2010-04-26)
  1298. */
  1299. protected $rasterize_vector_images = false;
  1300. /**
  1301. * @var If true enables font subsetting by default
  1302. * @access protected
  1303. * @since 5.3.002 (2010-06-07)
  1304. */
  1305. protected $font_subsetting = true;
  1306. /**
  1307. * @var Array of default graphic settings
  1308. * @access protected
  1309. * @since 5.5.008 (2010-07-02)
  1310. */
  1311. protected $default_graphic_vars = array();
  1312. /**
  1313. * @var Array of XObjects
  1314. * @access protected
  1315. * @since 5.8.014 (2010-08-23)
  1316. */
  1317. protected $xobjects = array();
  1318. /**
  1319. * @var boolean true when we are inside an XObject
  1320. * @access protected
  1321. * @since 5.8.017 (2010-08-24)
  1322. */
  1323. protected $inxobj = false;
  1324. /**
  1325. * @var current XObject ID
  1326. * @access protected
  1327. * @since 5.8.017 (2010-08-24)
  1328. */
  1329. protected $xobjid = '';
  1330. /**
  1331. * @var percentage of character stretching
  1332. * @access protected
  1333. * @since 5.9.000 (2010-09-29)
  1334. */
  1335. protected $font_stretching = 100;
  1336. /**
  1337. * @var increases or decreases the space between characters in a text by the specified amount (tracking/kerning).
  1338. * @access protected
  1339. * @since 5.9.000 (2010-09-29)
  1340. */
  1341. protected $font_spacing = 0;
  1342. /**
  1343. * @var array of no-write regions
  1344. * ('page' => page number or empy for current page, 'xt' => X top, 'yt' => Y top, 'xb' => X bottom, 'yb' => Y bottom, 'side' => page side 'L' = left or 'R' = right)
  1345. * @access protected
  1346. * @since 5.9.003 (2010-10-14)
  1347. */
  1348. protected $page_regions = array();
  1349. /**
  1350. * @var array containing HTML color names and values
  1351. * @access protected
  1352. * @since 5.9.004 (2010-10-18)
  1353. */
  1354. protected $webcolor = array();
  1355. /**
  1356. * @var directory used for the last SVG image
  1357. * @access protected
  1358. * @since 5.0.000 (2010-05-05)
  1359. */
  1360. protected $svgdir = '';
  1361. /**
  1362. * @var Deafult unit of measure for SVG
  1363. * @access protected
  1364. * @since 5.0.000 (2010-05-02)
  1365. */
  1366. protected $svgunit = 'px';
  1367. /**
  1368. * @var array of SVG gradients
  1369. * @access protected
  1370. * @since 5.0.000 (2010-05-02)
  1371. */
  1372. protected $svggradients = array();
  1373. /**
  1374. * @var ID of last SVG gradient
  1375. * @access protected
  1376. * @since 5.0.000 (2010-05-02)
  1377. */
  1378. protected $svggradientid = 0;
  1379. /**
  1380. * @var true when in SVG defs group
  1381. * @access protected
  1382. * @since 5.0.000 (2010-05-02)
  1383. */
  1384. protected $svgdefsmode = false;
  1385. /**
  1386. * @var array of SVG defs
  1387. * @access protected
  1388. * @since 5.0.000 (2010-05-02)
  1389. */
  1390. protected $svgdefs = array();
  1391. /**
  1392. * @var true when in SVG clipPath tag
  1393. * @access protected
  1394. * @since 5.0.000 (2010-04-26)
  1395. */
  1396. protected $svgclipmode = false;
  1397. /**
  1398. * @var array of SVG clipPath commands
  1399. * @access protected
  1400. * @since 5.0.000 (2010-05-02)
  1401. */
  1402. protected $svgclippaths = array();
  1403. /**
  1404. * @var array of SVG clipPath tranformation matrix
  1405. * @access protected
  1406. * @since 5.8.022 (2010-08-31)
  1407. */
  1408. protected $svgcliptm = array();
  1409. /**
  1410. * @var ID of last SVG clipPath
  1411. * @access protected
  1412. * @since 5.0.000 (2010-05-02)
  1413. */
  1414. protected $svgclipid = 0;
  1415. /**
  1416. * @var svg text
  1417. * @access protected
  1418. * @since 5.0.000 (2010-05-02)
  1419. */
  1420. protected $svgtext = '';
  1421. /**
  1422. * @var svg text properties
  1423. * @access protected
  1424. * @since 5.8.013 (2010-08-23)
  1425. */
  1426. protected $svgtextmode = array();
  1427. /**
  1428. * @var array of hinheritable SVG properties
  1429. * @access protected
  1430. * @since 5.0.000 (2010-05-02)
  1431. */
  1432. 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');
  1433. /**
  1434. * @var array of SVG properties
  1435. * @access protected
  1436. * @since 5.0.000 (2010-05-02)
  1437. */
  1438. protected $svgstyles = array(array(
  1439. 'alignment-baseline' => 'auto',
  1440. 'baseline-shift' => 'baseline',
  1441. 'clip' => 'auto',
  1442. 'clip-path' => 'none',
  1443. 'clip-rule' => 'nonzero',
  1444. 'color' => 'black',
  1445. 'color-interpolation' => 'sRGB',
  1446. 'color-interpolation-filters' => 'linearRGB',
  1447. 'color-profile' => 'auto',
  1448. 'color-rendering' => 'auto',
  1449. 'cursor' => 'auto',
  1450. 'direction' => 'ltr',
  1451. 'display' => 'inline',
  1452. 'dominant-baseline' => 'auto',
  1453. 'enable-background' => 'accumulate',
  1454. 'fill' => 'black',
  1455. 'fill-opacity' => 1,
  1456. 'fill-rule' => 'nonzero',
  1457. 'filter' => 'none',
  1458. 'flood-color' => 'black',
  1459. 'flood-opacity' => 1,
  1460. 'font' => '',
  1461. 'font-family' => 'helvetica',
  1462. 'font-size' => 'medium',
  1463. 'font-size-adjust' => 'none',
  1464. 'font-stretch' => 'normal',
  1465. 'font-style' => 'normal',
  1466. 'font-variant' => 'normal',
  1467. 'font-weight' => 'normal',
  1468. 'glyph-orientation-horizontal' => '0deg',
  1469. 'glyph-orientation-vertical' => 'auto',
  1470. 'image-rendering' => 'auto',
  1471. 'kerning' => 'auto',
  1472. 'letter-spacing' => 'normal',
  1473. 'lighting-color' => 'white',
  1474. 'marker' => '',
  1475. 'marker-end' => 'none',
  1476. 'marker-mid' => 'none',
  1477. 'marker-start' => 'none',
  1478. 'mask' => 'none',
  1479. 'opacity' => 1,
  1480. 'overflow' => 'auto',
  1481. 'pointer-events' => 'visiblePainted',
  1482. 'shape-rendering' => 'auto',
  1483. 'stop-color' => 'black',
  1484. 'stop-opacity' => 1,
  1485. 'stroke' => 'none',
  1486. 'stroke-dasharray' => 'none',
  1487. 'stroke-dashoffset' => 0,
  1488. 'stroke-linecap' => 'butt',
  1489. 'stroke-linejoin' => 'miter',
  1490. 'stroke-miterlimit' => 4,
  1491. 'stroke-opacity' => 1,
  1492. 'stroke-width' => 1,
  1493. 'text-anchor' => 'start',
  1494. 'text-decoration' => 'none',
  1495. 'text-rendering' => 'auto',
  1496. 'unicode-bidi' => 'normal',
  1497. 'visibility' => 'visible',
  1498. 'word-spacing' => 'normal',
  1499. 'writing-mode' => 'lr-tb',
  1500. 'text-color' => 'black',
  1501. 'transfmatrix' => array(1, 0, 0, 1, 0, 0)
  1502. ));
  1503. //------------------------------------------------------------
  1504. // METHODS
  1505. //------------------------------------------------------------
  1506. /**
  1507. * This is the class constructor.
  1508. * It allows to set up the page format, the orientation and the measure unit used in all the methods (except for the font sizes).
  1509. * @param string $orientation page orientation. Possible values are (case insensitive):<ul><li>P or Portrait (default)</li><li>L or Landscape</li><li>'' (empty string) for automatic orientation</li></ul>
  1510. * @param string $unit User measure unit. Possible values are:<ul><li>pt: point</li><li>mm: millimeter (default)</li><li>cm: centimeter</li><li>in: inch</li></ul><br />A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.
  1511. * @param mixed $format The format used for pages. It can be either: one of the string values specified at getPageSizeFromFormat() or an array of parameters specified at setPageFormat().
  1512. * @param boolean $unicode TRUE means that the input text is unicode (default = true)
  1513. * @param boolean $diskcache if TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower).
  1514. * @param String $encoding charset encoding; default is UTF-8
  1515. * @access public
  1516. * @see getPageSizeFromFormat(), setPageFormat()
  1517. */
  1518. public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false) {
  1519. /* Set internal character encoding to ASCII */
  1520. if (function_exists('mb_internal_encoding') AND mb_internal_encoding()) {
  1521. $this->internal_encoding = mb_internal_encoding();
  1522. mb_internal_encoding('ASCII');
  1523. }
  1524. require(dirname(__FILE__).'/htmlcolors.php');
  1525. $this->webcolor = $webcolor;
  1526. require_once(dirname(__FILE__).'/unicode_data.php');
  1527. $this->unicode = new TCPDF_UNICODE_DATA();
  1528. $this->font_obj_ids = array();
  1529. $this->page_obj_id = array();
  1530. $this->form_obj_id = array();
  1531. // set disk caching
  1532. $this->diskcache = $diskcache ? true : false;
  1533. // set language direction
  1534. $this->rtl = false;
  1535. $this->tmprtl = false;
  1536. // some checks
  1537. $this->_dochecks();
  1538. // initialization of properties
  1539. $this->isunicode = $unicode;
  1540. $this->page = 0;
  1541. $this->transfmrk[0] = array();
  1542. $this->pagedim = array();
  1543. $this->n = 2;
  1544. $this->buffer = '';
  1545. $this->pages = array();
  1546. $this->state = 0;
  1547. $this->fonts = array();
  1548. $this->FontFiles = array();
  1549. $this->diffs = array();
  1550. $this->images = array();
  1551. $this->links = array();
  1552. $this->gradients = array();
  1553. $this->InFooter = false;
  1554. $this->lasth = 0;
  1555. $this->FontFamily = 'helvetica';
  1556. $this->FontStyle = '';
  1557. $this->FontSizePt = 12;
  1558. $this->underline = false;
  1559. $this->overline = false;
  1560. $this->linethrough = false;
  1561. $this->DrawColor = '0 G';
  1562. $this->FillColor = '0 g';
  1563. $this->TextColor = '0 g';
  1564. $this->ColorFlag = false;
  1565. // encryption values
  1566. $this->encrypted = false;
  1567. $this->last_enc_key = '';
  1568. // standard Unicode fonts
  1569. $this->CoreFonts = array(
  1570. 'courier'=>'Courier',
  1571. 'courierB'=>'Courier-Bold',
  1572. 'courierI'=>'Courier-Oblique',
  1573. 'courierBI'=>'Courier-BoldOblique',
  1574. 'helvetica'=>'Helvetica',
  1575. 'helveticaB'=>'Helvetica-Bold',
  1576. 'helveticaI'=>'Helvetica-Oblique',
  1577. 'helveticaBI'=>'Helvetica-BoldOblique',
  1578. 'times'=>'Times-Roman',
  1579. 'timesB'=>'Times-Bold',
  1580. 'timesI'=>'Times-Italic',
  1581. 'timesBI'=>'Times-BoldItalic',
  1582. 'symbol'=>'Symbol',
  1583. 'zapfdingbats'=>'ZapfDingbats'
  1584. );
  1585. // set scale factor
  1586. $this->setPageUnit($unit);
  1587. // set page format and orientation
  1588. $this->setPageFormat($format, $orientation);
  1589. // page margins (1 cm)
  1590. $margin = 28.35 / $this->k;
  1591. $this->SetMargins($margin, $margin);
  1592. // internal cell padding
  1593. $cpadding = $margin / 10;
  1594. $this->setCellPaddings($cpadding, 0, $cpadding, 0);
  1595. // cell margins
  1596. $this->setCellMargins(0, 0, 0, 0);
  1597. // line width (0.2 mm)
  1598. $this->LineWidth = 0.57 / $this->k;
  1599. $this->linestyleWidth = sprintf('%.2F w', ($this->LineWidth * $this->k));
  1600. $this->linestyleCap = '0 J';
  1601. $this->linestyleJoin = '0 j';
  1602. $this->linestyleDash = '[] 0 d';
  1603. // automatic page break
  1604. $this->SetAutoPageBreak(true, (2 * $margin));
  1605. // full width display mode
  1606. $this->SetDisplayMode('fullwidth');
  1607. // compression
  1608. $this->SetCompression(true);
  1609. // set default PDF version number
  1610. $this->PDFVersion = '1.7';
  1611. $this->encoding = $encoding;
  1612. $this->HREF = array();
  1613. $this->getFontsList();
  1614. $this->fgcolor = array('R' => 0, 'G' => 0, 'B' => 0);
  1615. $this->strokecolor = array('R' => 0, 'G' => 0, 'B' => 0);
  1616. $this->bgcolor = array('R' => 255, 'G' => 255, 'B' => 255);
  1617. $this->extgstates = array();
  1618. // user's rights
  1619. $this->sign = false;
  1620. $this->ur['enabled'] = false;
  1621. $this->ur['document'] = '/FullSave';
  1622. $this->ur['annots'] = '/Create/Delete/Modify/Copy/Import/Export';
  1623. $this->ur['form'] = '/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate';
  1624. $this->ur['signature'] = '/Modify';
  1625. $this->ur['ef'] = '/Create/Delete/Modify/Import';
  1626. $this->ur['formex'] = '';
  1627. $this->signature_appearance = array('page' => 1, 'rect' => '0 0 0 0');
  1628. // set default JPEG quality
  1629. $this->jpeg_quality = 75;
  1630. // initialize some settings
  1631. $this->utf8Bidi(array(''), '');
  1632. // set default font
  1633. $this->SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
  1634. // check if PCRE Unicode support is enabled
  1635. if ($this->isunicode AND (@preg_match('/\pL/u', 'a') == 1)) {
  1636. // PCRE unicode support is turned ON
  1637. // \p{Z} or \p{Separator}: any kind of Unicode whitespace or invisible separator.
  1638. // \p{Lo} or \p{Other_Letter}: a Unicode letter or ideograph that does not have lowercase and uppercase variants.
  1639. // \p{Lo} is needed because Chinese characters are packed next to each other without spaces in between.
  1640. //$this->setSpacesRE('/[^\S\P{Z}\P{Lo}\xa0]/u');
  1641. $this->setSpacesRE('/[^\S\P{Z}\xa0]/u');
  1642. } else {
  1643. // PCRE unicode support is turned OFF
  1644. $this->setSpacesRE('/[^\S\xa0]/');
  1645. }
  1646. $this->default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
  1647. // set file ID for trailer
  1648. $this->file_id = md5($this->getRandomSeed('TCPDF'.$orientation.$unit.$format.$encoding));
  1649. // get default graphic vars
  1650. $this->default_graphic_vars = $this->getGraphicVars();
  1651. }
  1652. /**
  1653. * Default destructor.
  1654. * @access public
  1655. * @since 1.53.0.TC016
  1656. */
  1657. public function __destruct() {
  1658. // restore internal encoding
  1659. if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
  1660. mb_internal_encoding($this->internal_encoding);
  1661. }
  1662. // unset all class variables
  1663. $this->_destroy(true);
  1664. }
  1665. /**
  1666. * Set the units of measure for the document.
  1667. * @param string $unit User measure unit. Possible values are:<ul><li>pt: point</li><li>mm: millimeter (default)</li><li>cm: centimeter</li><li>in: inch</li></ul><br />A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.
  1668. * @access public
  1669. * @since 3.0.015 (2008-06-06)
  1670. */
  1671. public function setPageUnit($unit) {
  1672. $unit = strtolower($unit);
  1673. //Set scale factor
  1674. switch ($unit) {
  1675. // points
  1676. case 'px':
  1677. case 'pt': {
  1678. $this->k = 1;
  1679. break;
  1680. }
  1681. // millimeters
  1682. case 'mm': {
  1683. $this->k = $this->dpi / 25.4;
  1684. break;
  1685. }
  1686. // centimeters
  1687. case 'cm': {
  1688. $this->k = $this->dpi / 2.54;
  1689. break;
  1690. }
  1691. // inches
  1692. case 'in': {
  1693. $this->k = $this->dpi;
  1694. break;
  1695. }
  1696. // unsupported unit
  1697. default : {
  1698. $this->Error('Incorrect unit: '.$unit);
  1699. break;
  1700. }
  1701. }
  1702. $this->pdfunit = $unit;
  1703. if (isset($this->CurOrientation)) {
  1704. $this->setPageOrientation($this->CurOrientation);
  1705. }
  1706. }
  1707. /**
  1708. * Get page dimensions from format name.
  1709. * @param mixed $format The format name. It can be: <ul>
  1710. * <li><b>ISO 216 A Series + 2 SIS 014711 extensions</b></li>
  1711. * <li>A0 (841x1189 mm ; 33.11x46.81 in)</li>
  1712. * <li>A1 (594x841 mm ; 23.39x33.11 in)</li>
  1713. * <li>A2 (420x594 mm ; 16.54x23.39 in)</li>
  1714. * <li>A3 (297x420 mm ; 11.69x16.54 in)</li>
  1715. * <li>A4 (210x297 mm ; 8.27x11.69 in)</li>
  1716. * <li>A5 (148x210 mm ; 5.83x8.27 in)</li>
  1717. * <li>A6 (105x148 mm ; 4.13x5.83 in)</li>
  1718. * <li>A7 (74x105 mm ; 2.91x4.13 in)</li>
  1719. * <li>A8 (52x74 mm ; 2.05x2.91 in)</li>
  1720. * <li>A9 (37x52 mm ; 1.46x2.05 in)</li>
  1721. * <li>A10 (26x37 mm ; 1.02x1.46 in)</li>
  1722. * <li>A11 (18x26 mm ; 0.71x1.02 in)</li>
  1723. * <li>A12 (13x18 mm ; 0.51x0.71 in)</li>
  1724. * <li><b>ISO 216 B Series + 2 SIS 014711 extensions</b></li>
  1725. * <li>B0 (1000x1414 mm ; 39.37x55.67 in)</li>
  1726. * <li>B1 (707x1000 mm ; 27.83x39.37 in)</li>
  1727. * <li>B2 (500x707 mm ; 19.69x27.83 in)</li>
  1728. * <li>B3 (353x500 mm ; 13.90x19.69 in)</li>
  1729. * <li>B4 (250x353 mm ; 9.84x13.90 in)</li>
  1730. * <li>B5 (1…

Large files files are truncated, but you can click here to view the full file