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

/phpMyAdmin/libraries/tcpdf/tcpdf.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip
PHP | 13952 lines | 8849 code | 485 blank | 4618 comment | 1693 complexity | 5961b6a722f3607ac94f56fe976b534d MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.0, JSON, GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT

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

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