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

/lib/tcpdf/tcpdf.php

http://github.com/moodle/moodle
PHP | 13907 lines | 8473 code | 556 blank | 4878 comment | 1757 complexity | b384cf9e37aedd36c736919085cd2463 MD5 | raw file
Possible License(s): MIT, AGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, Apache-2.0, LGPL-2.1, BSD-3-Clause

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

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