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

/libs/tcpdf/tcpdf.php

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

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