PageRenderTime 83ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 2ms

/templates/pdf/tcpdf/tcpdf.php

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

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