PageRenderTime 66ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 2ms

/lib/tcpdf/tcpdf.php

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

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