PageRenderTime 73ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 2ms

/tools/tcpdf/tcpdf.php

https://bitbucket.org/enurkov/prestashop
PHP | 13950 lines | 8767 code | 497 blank | 4686 comment | 1678 complexity | 7aa19c022eb2a4c7b2b08d21381d1762 MD5 | raw file

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

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