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

/administrator/components/com_breezingforms/libraries/tcpdf/tcpdf.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip-alpes
PHP | 13920 lines | 8797 code | 530 blank | 4593 comment | 2046 complexity | 5b3ba900168d878e0a3b27106a20002e MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT, LGPL-3.0, LGPL-2.0, JSON

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

  1. <?php
  2. defined('_JEXEC') or die('Direct Access to this location is not allowed.');
  3. //============================================================+
  4. // File name : tcpdf.php
  5. // Begin : 2002-08-03
  6. // Last Update : 2009-11-27
  7. // Author : Nicola Asuni - info@tecnick.com - http://www.tcpdf.org
  8. // Version : 4.8.017
  9. // License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
  10. // ----------------------------------------------------------------------------
  11. // Copyright (C) 2002-2009 Nicola Asuni - Tecnick.com S.r.l.
  12. //
  13. // This program is free software: you can redistribute it and/or modify
  14. // it under the terms of the GNU Lesser General Public License as published by
  15. // the Free Software Foundation, either version 2.1 of the License, or
  16. // (at your option) any later version.
  17. //
  18. // This program is distributed in the hope that it will be useful,
  19. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. // GNU Lesser General Public License for more details.
  22. //
  23. // You should have received a copy of the GNU Lesser General Public License
  24. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. //
  26. // See LICENSE.TXT file for more information.
  27. // ----------------------------------------------------------------------------
  28. //
  29. // Description : This is a PHP class for generating PDF documents without
  30. // requiring external extensions.
  31. //
  32. // NOTE:
  33. // This class was originally derived in 2002 from the Public
  34. // Domain FPDF class by Olivier Plathey (http://www.fpdf.org),
  35. // but now is almost entirely rewritten.
  36. //
  37. // Main features:
  38. // * no external libraries are required for the basic functions;
  39. // * supports all ISO page formats;
  40. // * supports custom page formats, margins and units of measure;
  41. // * supports UTF-8 Unicode and Right-To-Left languages;
  42. // * supports TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;
  43. // * supports document encryption;
  44. // * includes methods to publish some XHTML code, including forms;
  45. // * includes graphic (geometric) and transformation methods;
  46. // * includes Javascript and Forms support;
  47. // * includes a method to print various barcode formats: 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;
  48. // * includes methods to set Bookmarks and print a Table of Content;
  49. // * includes methods to move and delete pages;
  50. // * includes methods for automatic page header and footer management;
  51. // * supports automatic page break;
  52. // * supports automatic page numbering and page groups;
  53. // * supports automatic line break and text justification;
  54. // * supports JPEG and PNG 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)
  55. // * supports stroke and clipping mode for text;
  56. // * supports clipping masks;
  57. // * supports Grayscale, RGB, CMYK, Spot Colors and Transparencies;
  58. // * supports several annotations, including links, text and file attachments;
  59. // * supports page compression (requires zlib extension);
  60. // * supports text hyphenation.
  61. // * supports transactions to UNDO commands.
  62. // * supports signature certifications.
  63. //
  64. // -----------------------------------------------------------
  65. // THANKS TO:
  66. //
  67. // Olivier Plathey (http://www.fpdf.org) for original FPDF.
  68. // Efthimios Mavrogeorgiadis (emavro@yahoo.com) for suggestions on RTL language support.
  69. // Klemen Vodopivec (http://www.fpdf.de/downloads/addons/37/) for Encryption algorithm.
  70. // Warren Sherliker (wsherliker@gmail.com) for better image handling.
  71. // dullus for text Justification.
  72. // Bob Vincent (pillarsdotnet@users.sourceforge.net) for <li> value attribute.
  73. // Patrick Benny for text stretch suggestion on Cell().
  74. // Johannes G�ntert for JavaScript support.
  75. // Denis Van Nuffelen for Dynamic Form.
  76. // Jacek Czekaj for multibyte justification
  77. // Anthony Ferrara for the reintroduction of legacy image methods.
  78. // Sourceforge user 1707880 (hucste) for line-trough mode.
  79. // Larry Stanbery for page groups.
  80. // Martin Hall-May for transparency.
  81. // Aaron C. Spike for Polycurve method.
  82. // Mohamad Ali Golkar, Saleh AlMatrafe, Charles Abbott for Arabic and Persian support.
  83. // Moritz Wagner and Andreas Wurmser for graphic functions.
  84. // Andrew Whitehead for core fonts support.
  85. // Esteban Jo�l Mar�n for OpenType font conversion.
  86. // Teus Hagen for several suggestions and fixes.
  87. // Yukihiro Nakadaira for CID-0 CJK fonts fixes.
  88. // Kosmas Papachristos for some CSS improvements.
  89. // Marcel Partap for some fixes.
  90. // Won Kyu Park for several suggestions, fixes and patches.
  91. // Anyone that has reported a bug or sent a suggestion.
  92. //============================================================+
  93. /**
  94. * This is a PHP class for generating PDF documents without requiring external extensions.<br>
  95. * 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>
  96. * <h3>TCPDF main features are:</h3>
  97. * <ul>
  98. * <li>no external libraries are required for the basic functions;</li>
  99. * <li>supports all ISO page formats;</li>
  100. * <li>supports custom page formats, margins and units of measure;</li>
  101. * <li>supports UTF-8 Unicode and Right-To-Left languages;</li>
  102. * <li>supports TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;</li>
  103. * <li>supports document encryption;</li>
  104. * <li>includes methods to publish some XHTML code, including forms;</li>
  105. * <li>includes graphic (geometric) and transformation methods;</li>
  106. * <li>includes Javascript and Forms support;</li>
  107. * <li>includes a method to print various barcode formats: 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;</li>
  108. * <li>includes methods to set Bookmarks and print a Table of Content;</li>
  109. * <li>includes methods to move and delete pages;</li>
  110. * <li>includes methods for automatic page header and footer management;</li>
  111. * <li>supports automatic page break;</li>
  112. * <li>supports automatic page numbering and page groups;</li>
  113. * <li>supports automatic line break and text justification;</li>
  114. * <li>supports JPEG and PNG 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>
  115. * <li>supports stroke and clipping mode for text;</li>
  116. * <li>supports clipping masks;</li>
  117. * <li>supports Grayscale, RGB, CMYK, Spot Colors and Transparencies;</li>
  118. * <li>supports several annotations, including links, text and file attachments;</li>
  119. * <li>supports page compression (requires zlib extension);</li>
  120. * <li>supports text hyphenation.</li>
  121. * <li>supports transactions to UNDO commands.</li>
  122. * <li>supports signature certifications.</li>
  123. * </ul>
  124. * Tools to encode your unicode fonts are on fonts/utils directory.</p>
  125. * @package com.tecnick.tcpdf
  126. * @abstract Class for generating PDF files on-the-fly without requiring external extensions.
  127. * @author Nicola Asuni
  128. * @copyright 2002-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
  129. * @link http://www.tcpdf.org
  130. * @license http://www.gnu.org/copyleft/lesser.html LGPL
  131. * @version 4.8.017
  132. */
  133. /**
  134. * main configuration file
  135. */
  136. require_once(dirname(__FILE__).'/config/tcpdf_config.php');
  137. // includes some support files
  138. /**
  139. * unicode data
  140. */
  141. require_once(dirname(__FILE__).'/unicode_data.php');
  142. /**
  143. * html colors table
  144. */
  145. require_once(dirname(__FILE__).'/htmlcolors.php');
  146. if (!class_exists('TCPDF', false)) {
  147. /**
  148. * define default PDF document producer
  149. */
  150. define('PDF_PRODUCER', 'TCPDF 4.8.017 (http://www.tcpdf.org)');
  151. /**
  152. * This is a PHP class for generating PDF documents without requiring external extensions.<br>
  153. * 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>
  154. * @name TCPDF
  155. * @package com.tecnick.tcpdf
  156. * @version 4.8.017
  157. * @author Nicola Asuni - info@tecnick.com
  158. * @link http://www.tcpdf.org
  159. * @license http://www.gnu.org/copyleft/lesser.html LGPL
  160. */
  161. class TCPDF {
  162. // protected or Protected properties
  163. /**
  164. * @var current page number
  165. * @access protected
  166. */
  167. protected $page;
  168. /**
  169. * @var current object number
  170. * @access protected
  171. */
  172. protected $n;
  173. /**
  174. * @var array of object offsets
  175. * @access protected
  176. */
  177. protected $offsets;
  178. /**
  179. * @var buffer holding in-memory PDF
  180. * @access protected
  181. */
  182. protected $buffer;
  183. /**
  184. * @var array containing pages
  185. * @access protected
  186. */
  187. protected $pages = array();
  188. /**
  189. * @var current document state
  190. * @access protected
  191. */
  192. protected $state;
  193. /**
  194. * @var compression flag
  195. * @access protected
  196. */
  197. protected $compress;
  198. /**
  199. * @var current page orientation (P = Portrait, L = Landscape)
  200. * @access protected
  201. */
  202. protected $CurOrientation;
  203. /**
  204. * @var array that stores page dimensions and graphic status.<ul><li>$this->pagedim[$this->page]['w'] => page_width_in_points</li><li>$this->pagedim[$this->page]['h'] => height in points</li><li>$this->pagedim[$this->page]['wk'] => page_width_in_points</li><li>$this->pagedim[$this->page]['hk'] => height</li><li>$this->pagedim[$this->page]['tm'] => top_margin</li><li>$this->pagedim[$this->page]['bm'] => bottom_margin</li><li>$this->pagedim[$this->page]['lm'] => left_margin</li><li>$this->pagedim[$this->page]['rm'] => right_margin</li><li>$this->pagedim[$this->page]['pb'] => auto_page_break</li><li>$this->pagedim[$this->page]['or'] => page_orientation</li><li>$this->pagedim[$this->page]['olm'] => original_left_margin</li><li>$this->pagedim[$this->page]['orm'] => original_right_margin</li></ul>
  205. * @access protected
  206. */
  207. protected $pagedim = array();
  208. /**
  209. * @var scale factor (number of points in user unit)
  210. * @access protected
  211. */
  212. protected $k;
  213. /**
  214. * @var width of page format in points
  215. * @access protected
  216. */
  217. protected $fwPt;
  218. /**
  219. * @var height of page format in points
  220. * @access protected
  221. */
  222. protected $fhPt;
  223. /**
  224. * @var current width of page in points
  225. * @access protected
  226. */
  227. protected $wPt;
  228. /**
  229. * @var current height of page in points
  230. * @access protected
  231. */
  232. protected $hPt;
  233. /**
  234. * @var current width of page in user unit
  235. * @access protected
  236. */
  237. protected $w;
  238. /**
  239. * @var current height of page in user unit
  240. * @access protected
  241. */
  242. protected $h;
  243. /**
  244. * @var left margin
  245. * @access protected
  246. */
  247. protected $lMargin;
  248. /**
  249. * @var top margin
  250. * @access protected
  251. */
  252. protected $tMargin;
  253. /**
  254. * @var right margin
  255. * @access protected
  256. */
  257. protected $rMargin;
  258. /**
  259. * @var page break margin
  260. * @access protected
  261. */
  262. protected $bMargin;
  263. /**
  264. * @var cell internal padding
  265. * @access protected
  266. */
  267. //protected
  268. public $cMargin;
  269. /**
  270. * @var cell internal padding (previous value)
  271. * @access protected
  272. */
  273. protected $oldcMargin;
  274. /**
  275. * @var current horizontal position in user unit for cell positioning
  276. * @access protected
  277. */
  278. protected $x;
  279. /**
  280. * @var current vertical position in user unit for cell positioning
  281. * @access protected
  282. */
  283. protected $y;
  284. /**
  285. * @var height of last cell printed
  286. * @access protected
  287. */
  288. protected $lasth;
  289. /**
  290. * @var line width in user unit
  291. * @access protected
  292. */
  293. protected $LineWidth;
  294. /**
  295. * @var array of standard font names
  296. * @access protected
  297. */
  298. protected $CoreFonts;
  299. /**
  300. * @var array of used fonts
  301. * @access protected
  302. */
  303. protected $fonts = array();
  304. /**
  305. * @var array of font files
  306. * @access protected
  307. */
  308. protected $FontFiles = array();
  309. /**
  310. * @var array of encoding differences
  311. * @access protected
  312. */
  313. protected $diffs = array();
  314. /**
  315. * @var array of used images
  316. * @access protected
  317. */
  318. protected $images = array();
  319. /**
  320. * @var array of Annotations in pages
  321. * @access protected
  322. */
  323. protected $PageAnnots = array();
  324. /**
  325. * @var array of internal links
  326. * @access protected
  327. */
  328. protected $links = array();
  329. /**
  330. * @var current font family
  331. * @access protected
  332. */
  333. protected $FontFamily;
  334. /**
  335. * @var current font style
  336. * @access protected
  337. */
  338. protected $FontStyle;
  339. /**
  340. * @var current font ascent (distance between font top and baseline)
  341. * @access protected
  342. * @since 2.8.000 (2007-03-29)
  343. */
  344. protected $FontAscent;
  345. /**
  346. * @var current font descent (distance between font bottom and baseline)
  347. * @access protected
  348. * @since 2.8.000 (2007-03-29)
  349. */
  350. protected $FontDescent;
  351. /**
  352. * @var underlining flag
  353. * @access protected
  354. */
  355. protected $underline;
  356. /**
  357. * @var current font info
  358. * @access protected
  359. */
  360. protected $CurrentFont;
  361. /**
  362. * @var current font size in points
  363. * @access protected
  364. */
  365. protected $FontSizePt;
  366. /**
  367. * @var current font size in user unit
  368. * @access protected
  369. */
  370. protected $FontSize;
  371. /**
  372. * @var commands for drawing color
  373. * @access protected
  374. */
  375. protected $DrawColor;
  376. /**
  377. * @var commands for filling color
  378. * @access protected
  379. */
  380. protected $FillColor;
  381. /**
  382. * @var commands for text color
  383. * @access protected
  384. */
  385. protected $TextColor;
  386. /**
  387. * @var indicates whether fill and text colors are different
  388. * @access protected
  389. */
  390. protected $ColorFlag;
  391. /**
  392. * @var automatic page breaking
  393. * @access protected
  394. */
  395. protected $AutoPageBreak;
  396. /**
  397. * @var threshold used to trigger page breaks
  398. * @access protected
  399. */
  400. protected $PageBreakTrigger;
  401. /**
  402. * @var flag set when processing footer
  403. * @access protected
  404. */
  405. protected $InFooter = false;
  406. /**
  407. * @var zoom display mode
  408. * @access protected
  409. */
  410. protected $ZoomMode;
  411. /**
  412. * @var layout display mode
  413. * @access protected
  414. */
  415. protected $LayoutMode;
  416. /**
  417. * @var title
  418. * @access protected
  419. */
  420. protected $title = '';
  421. /**
  422. * @var subject
  423. * @access protected
  424. */
  425. protected $subject = '';
  426. /**
  427. * @var author
  428. * @access protected
  429. */
  430. protected $author = '';
  431. /**
  432. * @var keywords
  433. * @access protected
  434. */
  435. protected $keywords = '';
  436. /**
  437. * @var creator
  438. * @access protected
  439. */
  440. protected $creator = '';
  441. /**
  442. * @var alias for total number of pages
  443. * @access protected
  444. */
  445. protected $AliasNbPages = '{nb}';
  446. /**
  447. * @var alias for page number
  448. * @access protected
  449. */
  450. protected $AliasNumPage = '{pnb}';
  451. /**
  452. * @var right-bottom corner X coordinate of inserted image
  453. * @since 2002-07-31
  454. * @author Nicola Asuni
  455. * @access protected
  456. */
  457. protected $img_rb_x;
  458. /**
  459. * @var right-bottom corner Y coordinate of inserted image
  460. * @since 2002-07-31
  461. * @author Nicola Asuni
  462. * @access protected
  463. */
  464. protected $img_rb_y;
  465. /**
  466. * @var adjusting factor to convert pixels to user units.
  467. * @since 2004-06-14
  468. * @author Nicola Asuni
  469. * @access protected
  470. */
  471. protected $imgscale = 1;
  472. /**
  473. * @var boolean set to true when the input text is unicode (require unicode fonts)
  474. * @since 2005-01-02
  475. * @author Nicola Asuni
  476. * @access protected
  477. */
  478. protected $isunicode = false;
  479. /**
  480. * @var PDF version
  481. * @since 1.5.3
  482. * @access protected
  483. */
  484. protected $PDFVersion = '1.7';
  485. // ----------------------
  486. /**
  487. * @var Minimum distance between header and top page margin.
  488. * @access protected
  489. */
  490. protected $header_margin;
  491. /**
  492. * @var Minimum distance between footer and bottom page margin.
  493. * @access protected
  494. */
  495. protected $footer_margin;
  496. /**
  497. * @var original left margin value
  498. * @access protected
  499. * @since 1.53.0.TC013
  500. */
  501. protected $original_lMargin;
  502. /**
  503. * @var original right margin value
  504. * @access protected
  505. * @since 1.53.0.TC013
  506. */
  507. protected $original_rMargin;
  508. /**
  509. * @var Header font.
  510. * @access protected
  511. */
  512. protected $header_font;
  513. /**
  514. * @var Footer font.
  515. * @access protected
  516. */
  517. protected $footer_font;
  518. /**
  519. * @var Language templates.
  520. * @access protected
  521. */
  522. protected $l;
  523. /**
  524. * @var Barcode to print on page footer (only if set).
  525. * @access protected
  526. */
  527. protected $barcode = false;
  528. /**
  529. * @var If true prints header
  530. * @access protected
  531. */
  532. protected $print_header = true;
  533. /**
  534. * @var If true prints footer.
  535. * @access protected
  536. */
  537. protected $print_footer = true;
  538. /**
  539. * @var Header image logo.
  540. * @access protected
  541. */
  542. protected $header_logo = '';
  543. /**
  544. * @var Header image logo width in mm.
  545. * @access protected
  546. */
  547. protected $header_logo_width = 30;
  548. /**
  549. * @var String to print as title on document header.
  550. * @access protected
  551. */
  552. protected $header_title = '';
  553. /**
  554. * @var String to print on document header.
  555. * @access protected
  556. */
  557. protected $header_string = '';
  558. /**
  559. * @var Default number of columns for html table.
  560. * @access protected
  561. */
  562. protected $default_table_columns = 4;
  563. // variables for html parser
  564. /**
  565. * @var HTML PARSER: array to store current link and rendering styles.
  566. * @access protected
  567. */
  568. protected $HREF = array();
  569. /**
  570. * @var store a list of available fonts on filesystem.
  571. * @access protected
  572. */
  573. protected $fontlist = array();
  574. /**
  575. * @var current foreground color
  576. * @access protected
  577. */
  578. protected $fgcolor;
  579. /**
  580. * @var HTML PARSER: array of boolean values, true in case of ordered list (OL), false otherwise.
  581. * @access protected
  582. */
  583. protected $listordered = array();
  584. /**
  585. * @var HTML PARSER: array count list items on nested lists.
  586. * @access protected
  587. */
  588. protected $listcount = array();
  589. /**
  590. * @var HTML PARSER: current list nesting level.
  591. * @access protected
  592. */
  593. protected $listnum = 0;
  594. /**
  595. * @var HTML PARSER: indent amount for lists.
  596. * @access protected
  597. */
  598. protected $listindent;
  599. /**
  600. * @var current background color
  601. * @access protected
  602. */
  603. protected $bgcolor;
  604. /**
  605. * @var Store temporary font size in points.
  606. * @access protected
  607. */
  608. protected $tempfontsize = 10;
  609. /**
  610. * @var spacer for LI tags.
  611. * @access protected
  612. */
  613. protected $lispacer = '';
  614. /**
  615. * @var default encoding
  616. * @access protected
  617. * @since 1.53.0.TC010
  618. */
  619. protected $encoding = 'UTF-8';
  620. /**
  621. * @var PHP internal encoding
  622. * @access protected
  623. * @since 1.53.0.TC016
  624. */
  625. protected $internal_encoding;
  626. /**
  627. * @var indicates if the document language is Right-To-Left
  628. * @access protected
  629. * @since 2.0.000
  630. */
  631. protected $rtl = false;
  632. /**
  633. * @var used to force RTL or LTR string inversion
  634. * @access protected
  635. * @since 2.0.000
  636. */
  637. protected $tmprtl = false;
  638. // --- Variables used for document encryption:
  639. /**
  640. * Indicates whether document is protected
  641. * @access protected
  642. * @since 2.0.000 (2008-01-02)
  643. */
  644. protected $encrypted;
  645. /**
  646. * U entry in pdf document
  647. * @access protected
  648. * @since 2.0.000 (2008-01-02)
  649. */
  650. protected $Uvalue;
  651. /**
  652. * O entry in pdf document
  653. * @access protected
  654. * @since 2.0.000 (2008-01-02)
  655. */
  656. protected $Ovalue;
  657. /**
  658. * P entry in pdf document
  659. * @access protected
  660. * @since 2.0.000 (2008-01-02)
  661. */
  662. protected $Pvalue;
  663. /**
  664. * encryption object id
  665. * @access protected
  666. * @since 2.0.000 (2008-01-02)
  667. */
  668. protected $enc_obj_id;
  669. /**
  670. * last RC4 key encrypted (cached for optimisation)
  671. * @access protected
  672. * @since 2.0.000 (2008-01-02)
  673. */
  674. protected $last_rc4_key;
  675. /**
  676. * last RC4 computed key
  677. * @access protected
  678. * @since 2.0.000 (2008-01-02)
  679. */
  680. protected $last_rc4_key_c;
  681. /**
  682. * RC4 padding
  683. * @access protected
  684. */
  685. protected $padding = "\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A";
  686. /**
  687. * RC4 encryption key
  688. * @access protected
  689. */
  690. protected $encryption_key;
  691. // --- bookmark ---
  692. /**
  693. * Outlines for bookmark
  694. * @access protected
  695. * @since 2.1.002 (2008-02-12)
  696. */
  697. protected $outlines = array();
  698. /**
  699. * Outline root for bookmark
  700. * @access protected
  701. * @since 2.1.002 (2008-02-12)
  702. */
  703. protected $OutlineRoot;
  704. // --- javascript and form ---
  705. /**
  706. * javascript code
  707. * @access protected
  708. * @since 2.1.002 (2008-02-12)
  709. */
  710. protected $javascript = '';
  711. /**
  712. * javascript counter
  713. * @access protected
  714. * @since 2.1.002 (2008-02-12)
  715. */
  716. protected $n_js;
  717. /**
  718. * line trough state
  719. * @access protected
  720. * @since 2.8.000 (2008-03-19)
  721. */
  722. protected $linethrough;
  723. // --- Variables used for User's Rights ---
  724. // See PDF reference chapter 8.7 Digital Signatures
  725. /**
  726. * If true enables user's rights on PDF reader
  727. * @access protected
  728. * @since 2.9.000 (2008-03-26)
  729. */
  730. protected $ur;
  731. /**
  732. * Names specifying additional document-wide usage rights for the document.
  733. * @access protected
  734. * @since 2.9.000 (2008-03-26)
  735. */
  736. protected $ur_document;
  737. /**
  738. * Names specifying additional annotation-related usage rights for the document.
  739. * @access protected
  740. * @since 2.9.000 (2008-03-26)
  741. */
  742. protected $ur_annots;
  743. /**
  744. * Names specifying additional form-field-related usage rights for the document.
  745. * @access protected
  746. * @since 2.9.000 (2008-03-26)
  747. */
  748. protected $ur_form;
  749. /**
  750. * Names specifying additional signature-related usage rights for the document.
  751. * @access protected
  752. * @since 2.9.000 (2008-03-26)
  753. */
  754. protected $ur_signature;
  755. /**
  756. * Dot Per Inch Document Resolution (do not change)
  757. * @access protected
  758. * @since 3.0.000 (2008-03-27)
  759. */
  760. protected $dpi = 72;
  761. /**
  762. * Array of page numbers were a new page group was started
  763. * @access protected
  764. * @since 3.0.000 (2008-03-27)
  765. */
  766. protected $newpagegroup = array();
  767. /**
  768. * Contains the number of pages of the groups
  769. * @access protected
  770. * @since 3.0.000 (2008-03-27)
  771. */
  772. protected $pagegroups;
  773. /**
  774. * Contains the alias of the current page group
  775. * @access protected
  776. * @since 3.0.000 (2008-03-27)
  777. */
  778. protected $currpagegroup;
  779. /**
  780. * Restrict the rendering of some elements to screen or printout.
  781. * @access protected
  782. * @since 3.0.000 (2008-03-27)
  783. */
  784. protected $visibility = 'all';
  785. /**
  786. * Print visibility.
  787. * @access protected
  788. * @since 3.0.000 (2008-03-27)
  789. */
  790. protected $n_ocg_print;
  791. /**
  792. * View visibility.
  793. * @access protected
  794. * @since 3.0.000 (2008-03-27)
  795. */
  796. protected $n_ocg_view;
  797. /**
  798. * Array of transparency objects and parameters.
  799. * @access protected
  800. * @since 3.0.000 (2008-03-27)
  801. */
  802. protected $extgstates;
  803. /**
  804. * Set the default JPEG compression quality (1-100)
  805. * @access protected
  806. * @since 3.0.000 (2008-03-27)
  807. */
  808. protected $jpeg_quality;
  809. /**
  810. * Default cell height ratio.
  811. * @access protected
  812. * @since 3.0.014 (2008-05-23)
  813. */
  814. protected $cell_height_ratio = K_CELL_HEIGHT_RATIO;
  815. /**
  816. * PDF viewer preferences.
  817. * @access protected
  818. * @since 3.1.000 (2008-06-09)
  819. */
  820. protected $viewer_preferences;
  821. /**
  822. * A name object specifying how the document should be displayed when opened.
  823. * @access protected
  824. * @since 3.1.000 (2008-06-09)
  825. */
  826. protected $PageMode;
  827. /**
  828. * Array for storing gradient information.
  829. * @access protected
  830. * @since 3.1.000 (2008-06-09)
  831. */
  832. protected $gradients = array();
  833. /**
  834. * Array used to store positions inside the pages buffer.
  835. * keys are the page numbers
  836. * @access protected
  837. * @since 3.2.000 (2008-06-26)
  838. */
  839. protected $intmrk = array();
  840. /**
  841. * Array used to store content positions inside the pages buffer.
  842. * keys are the page numbers
  843. * @access protected
  844. * @since 4.6.021 (2009-07-20)
  845. */
  846. protected $cntmrk = array();
  847. /**
  848. * Array used to store footer positions of each page.
  849. * @access protected
  850. * @since 3.2.000 (2008-07-01)
  851. */
  852. protected $footerpos = array();
  853. /**
  854. * Array used to store footer lenght of each page.
  855. * @access protected
  856. * @since 4.0.014 (2008-07-29)
  857. */
  858. protected $footerlen = array();
  859. /**
  860. * True if a newline is created.
  861. * @access protected
  862. * @since 3.2.000 (2008-07-01)
  863. */
  864. protected $newline = true;
  865. /**
  866. * End position of the latest inserted line
  867. * @access protected
  868. * @since 3.2.000 (2008-07-01)
  869. */
  870. protected $endlinex = 0;
  871. /**
  872. * PDF string for last line width
  873. * @access protected
  874. * @since 4.0.006 (2008-07-16)
  875. */
  876. protected $linestyleWidth = '';
  877. /**
  878. * PDF string for last line width
  879. * @access protected
  880. * @since 4.0.006 (2008-07-16)
  881. */
  882. protected $linestyleCap = '0 J';
  883. /**
  884. * PDF string for last line width
  885. * @access protected
  886. * @since 4.0.006 (2008-07-16)
  887. */
  888. protected $linestyleJoin = '0 j';
  889. /**
  890. * PDF string for last line width
  891. * @access protected
  892. * @since 4.0.006 (2008-07-16)
  893. */
  894. protected $linestyleDash = '[] 0 d';
  895. /**
  896. * True if marked-content sequence is open
  897. * @access protected
  898. * @since 4.0.013 (2008-07-28)
  899. */
  900. protected $openMarkedContent = false;
  901. /**
  902. * Count the latest inserted vertical spaces on HTML
  903. * @access protected
  904. * @since 4.0.021 (2008-08-24)
  905. */
  906. protected $htmlvspace = 0;
  907. /**
  908. * Array of Spot colors
  909. * @access protected
  910. * @since 4.0.024 (2008-09-12)
  911. */
  912. protected $spot_colors = array();
  913. /**
  914. * Symbol used for HTML unordered list items
  915. * @access protected
  916. * @since 4.0.028 (2008-09-26)
  917. */
  918. protected $lisymbol = '';
  919. /**
  920. * String used to mark the beginning and end of EPS image blocks
  921. * @access protected
  922. * @since 4.1.000 (2008-10-18)
  923. */
  924. protected $epsmarker = 'x#!#EPS#!#x';
  925. /**
  926. * Array of transformation matrix
  927. * @access protected
  928. * @since 4.2.000 (2008-10-29)
  929. */
  930. protected $transfmatrix = array();
  931. /**
  932. * Current key for transformation matrix
  933. * @access protected
  934. * @since 4.8.005 (2009-09-17)
  935. */
  936. protected $transfmatrix_key = 0;
  937. /**
  938. * Booklet mode for double-sided pages
  939. * @access protected
  940. * @since 4.2.000 (2008-10-29)
  941. */
  942. protected $booklet = false;
  943. /**
  944. * Epsilon value used for float calculations
  945. * @access protected
  946. * @since 4.2.000 (2008-10-29)
  947. */
  948. protected $feps = 0.005;
  949. /**
  950. * Array used for custom vertical spaces for HTML tags
  951. * @access protected
  952. * @since 4.2.001 (2008-10-30)
  953. */
  954. protected $tagvspaces = array();
  955. /**
  956. * @var HTML PARSER: custom indent amount for lists.
  957. * Negative value means disabled.
  958. * @access protected
  959. * @since 4.2.007 (2008-11-12)
  960. */
  961. protected $customlistindent = -1;
  962. /**
  963. * @var if true keeps the border open for the cell sides that cross the page.
  964. * @access protected
  965. * @since 4.2.010 (2008-11-14)
  966. */
  967. protected $opencell = true;
  968. /**
  969. * @var array of files to embedd
  970. * @access protected
  971. * @since 4.4.000 (2008-12-07)
  972. */
  973. protected $embeddedfiles = array();
  974. /**
  975. * @var boolean true when inside html pre tag
  976. * @access protected
  977. * @since 4.4.001 (2008-12-08)
  978. */
  979. protected $premode = false;
  980. /**
  981. * Array used to store positions of graphics transformation blocks inside the page buffer.
  982. * keys are the page numbers
  983. * @access protected
  984. * @since 4.4.002 (2008-12-09)
  985. */
  986. protected $transfmrk = array();
  987. /**
  988. * Default color for html links
  989. * @access protected
  990. * @since 4.4.003 (2008-12-09)
  991. */
  992. protected $htmlLinkColorArray = array(0, 0, 255);
  993. /**
  994. * Default font style to add to html links
  995. * @access protected
  996. * @since 4.4.003 (2008-12-09)
  997. */
  998. protected $htmlLinkFontStyle = 'U';
  999. /**
  1000. * Counts the number of pages.
  1001. * @access protected
  1002. * @since 4.5.000 (2008-12-31)
  1003. */
  1004. protected $numpages = 0;
  1005. /**
  1006. * Array containing page lenghts in bytes.
  1007. * @access protected
  1008. * @since 4.5.000 (2008-12-31)
  1009. */
  1010. protected $pagelen = array();
  1011. /**
  1012. * Counts the number of pages.
  1013. * @access protected
  1014. * @since 4.5.000 (2008-12-31)
  1015. */
  1016. protected $numimages = 0;
  1017. /**
  1018. * Store the image keys.
  1019. * @access protected
  1020. * @since 4.5.000 (2008-12-31)
  1021. */
  1022. protected $imagekeys = array();
  1023. /**
  1024. * Lenght of the buffer in bytes.
  1025. * @access protected
  1026. * @since 4.5.000 (2008-12-31)
  1027. */
  1028. protected $bufferlen = 0;
  1029. /**
  1030. * If true enables disk caching.
  1031. * @access protected
  1032. * @since 4.5.000 (2008-12-31)
  1033. */
  1034. protected $diskcache = false;
  1035. /**
  1036. * Counts the number of fonts.
  1037. * @access protected
  1038. * @since 4.5.000 (2009-01-02)
  1039. */
  1040. protected $numfonts = 0;
  1041. /**
  1042. * Store the font keys.
  1043. * @access protected
  1044. * @since 4.5.000 (2009-01-02)
  1045. */
  1046. protected $fontkeys = array();
  1047. /**
  1048. * Store the font object IDs.
  1049. * @access protected
  1050. * @since 4.8.001 (2009-09-09)
  1051. */
  1052. protected $font_obj_ids = array();
  1053. /**
  1054. * Store the fage status (true when opened, false when closed).
  1055. * @access protected
  1056. * @since 4.5.000 (2009-01-02)
  1057. */
  1058. protected $pageopen = array();
  1059. /**
  1060. * Default monospaced font
  1061. * @access protected
  1062. * @since 4.5.025 (2009-03-10)
  1063. */
  1064. protected $default_monospaced_font = 'courier';
  1065. /**
  1066. * Used to store a cloned copy of the current class object
  1067. * @access protected
  1068. * @since 4.5.029 (2009-03-19)
  1069. */
  1070. protected $objcopy;
  1071. /**
  1072. * Array used to store the lenghts of cache files
  1073. * @access protected
  1074. * @since 4.5.029 (2009-03-19)
  1075. */
  1076. protected $cache_file_lenght = array();
  1077. /**
  1078. * Table header content to be repeated on each new page
  1079. * @access protected
  1080. * @since 4.5.030 (2009-03-20)
  1081. */
  1082. protected $thead = '';
  1083. /**
  1084. * Margins used for table header.
  1085. * @access protected
  1086. * @since 4.5.030 (2009-03-20)
  1087. */
  1088. protected $theadMargins = array();
  1089. /**
  1090. * Cache array for UTF8StringToArray() method.
  1091. * @access protected
  1092. * @since 4.5.037 (2009-04-07)
  1093. */
  1094. protected $cache_UTF8StringToArray = array();
  1095. /**
  1096. * Maximum size of cache array used for UTF8StringToArray() method.
  1097. * @access protected
  1098. * @since 4.5.037 (2009-04-07)
  1099. */
  1100. protected $cache_maxsize_UTF8StringToArray = 8;
  1101. /**
  1102. * Current size of cache array used for UTF8StringToArray() method.
  1103. * @access protected
  1104. * @since 4.5.037 (2009-04-07)
  1105. */
  1106. protected $cache_size_UTF8StringToArray = 0;
  1107. /**
  1108. * If true enables document signing
  1109. * @access protected
  1110. * @since 4.6.005 (2009-04-24)
  1111. */
  1112. protected $sign = false;
  1113. /**
  1114. * Signature data
  1115. * @access protected
  1116. * @since 4.6.005 (2009-04-24)
  1117. */
  1118. protected $signature_data = array();
  1119. /**
  1120. * Signature max lenght
  1121. * @access protected
  1122. * @since 4.6.005 (2009-04-24)
  1123. */
  1124. protected $signature_max_lenght = 11742;
  1125. /**
  1126. * Regular expression used to find blank characters used for word-wrapping.
  1127. * @access protected
  1128. * @since 4.6.006 (2009-04-28)
  1129. */
  1130. protected $re_spaces = '/[\s]/';
  1131. /**
  1132. * Signature object ID
  1133. * @access protected
  1134. * @since 4.6.022 (2009-06-23)
  1135. */
  1136. protected $sig_obj_id = 0;
  1137. /**
  1138. * ByteRange placemark used during signature process.
  1139. * @access protected
  1140. * @since 4.6.028 (2009-08-25)
  1141. */
  1142. protected $byterange_string = '/ByteRange[0 ********** ********** **********]';
  1143. /**
  1144. * Placemark used during signature process.
  1145. * @access protected
  1146. * @since 4.6.028 (2009-08-25)
  1147. */
  1148. protected $sig_annot_ref = '***SIGANNREF*** 0 R';
  1149. /**
  1150. * ID of page objects
  1151. * @access protected
  1152. * @since 4.7.000 (2009-08-29)
  1153. */
  1154. protected $page_obj_id = array();
  1155. /**
  1156. * Start ID for embedded file objects
  1157. * @access protected
  1158. * @since 4.7.000 (2009-08-29)
  1159. */
  1160. protected $embedded_start_obj_id = 100000;
  1161. /**
  1162. * Start ID for annotation objects
  1163. * @access protected
  1164. * @since 4.7.000 (2009-08-29)
  1165. */
  1166. protected $annots_start_obj_id = 200000;
  1167. /**
  1168. * Max ID of annotation object
  1169. * @access protected
  1170. * @since 4.7.000 (2009-08-29)
  1171. */
  1172. protected $annot_obj_id = 200000;
  1173. /**
  1174. * Current ID of annotation object
  1175. * @access protected
  1176. * @since 4.8.003 (2009-09-15)
  1177. */
  1178. protected $curr_annot_obj_id = 200000;
  1179. /**
  1180. * List of form annotations IDs
  1181. * @access protected
  1182. * @since 4.8.000 (2009-09-07)
  1183. */
  1184. protected $form_obj_id = array();
  1185. /*
  1186. * 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.
  1187. * @access protected
  1188. * @since 4.8.000 (2009-09-07)
  1189. */
  1190. protected $default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
  1191. /**
  1192. * Javascript objects array
  1193. * @access protected
  1194. * @since 4.8.000 (2009-09-07)
  1195. */
  1196. protected $js_objects = array();
  1197. /**
  1198. * Start ID for javascript objects
  1199. * @access protected
  1200. * @since 4.8.000 (2009-09-07)
  1201. */
  1202. protected $js_start_obj_id = 300000;
  1203. /**
  1204. * Current ID of javascript object
  1205. * @access protected
  1206. * @since 4.8.000 (2009-09-07)
  1207. */
  1208. protected $js_obj_id = 300000;
  1209. /**
  1210. * Current form action (used during XHTML rendering)
  1211. * @access protected
  1212. * @since 4.8.000 (2009-09-07)
  1213. */
  1214. protected $form_action = '';
  1215. /**
  1216. * Current form encryption type (used during XHTML rendering)
  1217. * @access protected
  1218. * @since 4.8.000 (2009-09-07)
  1219. */
  1220. protected $form_enctype = 'application/x-www-form-urlencoded';
  1221. /**
  1222. * Current method to submit forms.
  1223. * @access protected
  1224. * @since 4.8.000 (2009-09-07)
  1225. */
  1226. protected $form_mode = 'post';
  1227. /**
  1228. * Start ID for appearance streams XObjects
  1229. * @access protected
  1230. * @since 4.8.001 (2009-09-09)
  1231. */
  1232. protected $apxo_start_obj_id = 400000;
  1233. /**
  1234. * Current ID of appearance streams XObjects
  1235. * @access protected
  1236. * @since 4.8.001 (2009-09-09)
  1237. */
  1238. protected $apxo_obj_id = 400000;
  1239. /**
  1240. * List of fonts used on form fields (fontname => fontkey).
  1241. * @access protected
  1242. * @since 4.8.001 (2009-09-09)
  1243. */
  1244. protected $annotation_fonts = array();
  1245. /**
  1246. * List of radio buttons parent objects.
  1247. * @access protected
  1248. * @since 4.8.001 (2009-09-09)
  1249. */
  1250. protected $radiobutton_groups = array();
  1251. /**
  1252. * List of radio group objects IDs
  1253. * @access protected
  1254. * @since 4.8.001 (2009-09-09)
  1255. */
  1256. protected $radio_groups = array();
  1257. /**
  1258. * Text indentation value (used for text-indent CSS attribute)
  1259. * @access protected
  1260. * @since 4.8.006 (2009-09-23)
  1261. */
  1262. protected $textindent = 0;
  1263. /**
  1264. * Store page number when startTransaction() is called.
  1265. * @access protected
  1266. * @since 4.8.006 (2009-09-23)
  1267. */
  1268. protected $start_transaction_page = 0;
  1269. //------------------------------------------------------------
  1270. // METHODS
  1271. //------------------------------------------------------------
  1272. /**
  1273. * This is the class constructor.
  1274. * It allows to set up the page format, the orientation and
  1275. * the measure unit used in all the methods (except for the font sizes).
  1276. * @since 1.0
  1277. * @param string $orientation page orientation. Possible values are (case insensitive):<ul><li>P or Portrait (default)</li><li>L or Landscape</li></ul>
  1278. * @param string $unit 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.
  1279. * @param mixed $format The format used for pages. It can be either one of the following values (case insensitive) or a custom format in the form of a two-element array containing the width and the height (expressed in the unit given by unit).<ul><li>4A0</li><li>2A0</li><li>A0</li><li>A1</li><li>A2</li><li>A3</li><li>A4 (default)</li><li>A5</li><li>A6</li><li>A7</li><li>A8</li><li>A9</li><li>A10</li><li>B0</li><li>B1</li><li>B2</li><li>B3</li><li>B4</li><li>B5</li><li>B6</li><li>B7</li><li>B8</li><li>B9</li><li>B10</li><li>C0</li><li>C1</li><li>C2</li><li>C3</li><li>C4</li><li>C5</li><li>C6</li><li>C7</li><li>C8</li><li>C9</li><li>C10</li><li>RA0</li><li>RA1</li><li>RA2</li><li>RA3</li><li>RA4</li><li>SRA0</li><li>SRA1</li><li>SRA2</li><li>SRA3</li><li>SRA4</li><li>LETTER</li><li>LEGAL</li><li>EXECUTIVE</li><li>FOLIO</li></ul>
  1280. * @param boolean $unicode TRUE means that the input text is unicode (default = true)
  1281. * @param boolean $diskcache if TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower).
  1282. * @param String $encoding charset encoding; default is UTF-8
  1283. * @access public
  1284. */
  1285. public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false) {
  1286. /* Set internal character encoding to ASCII */
  1287. if (function_exists('mb_internal_encoding') AND mb_internal_encoding()) {
  1288. $this->internal_encoding = mb_internal_encoding();
  1289. mb_internal_encoding('ASCII');
  1290. }
  1291. // set disk caching
  1292. $this->diskcache = $diskcache ? true : false;
  1293. // set language direction
  1294. $this->rtl = false;
  1295. $this->tmprtl = false;
  1296. //Some checks
  1297. $this->_dochecks();
  1298. //Initialization of properties
  1299. $this->isunicode = $unicode;
  1300. $this->page = 0;
  1301. $this->transfmrk[0] = array();
  1302. $this->pagedim = array();
  1303. $this->n = 2;
  1304. $this->buffer = '';
  1305. $this->pages = array();
  1306. $this->state = 0;
  1307. $this->fonts = array();
  1308. $this->FontFiles = array();
  1309. $this->diffs = array();
  1310. $this->images = array();
  1311. $this->links = array();
  1312. $this->gradients = array();
  1313. $this->InFooter = false;
  1314. $this->lasth = 0;
  1315. $this->FontFamily = 'helvetica';
  1316. $this->FontStyle = '';
  1317. $this->FontSizePt = 12;
  1318. $this->underline = false;
  1319. $this->linethrough = false;
  1320. $this->DrawColor = '0 G';
  1321. $this->FillColor = '0 g';
  1322. $this->TextColor = '0 g';
  1323. $this->ColorFlag = false;
  1324. // encryption values
  1325. $this->encrypted = false;
  1326. $this->last_rc4_key = '';
  1327. $this->padding = "\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A";
  1328. //Standard Unicode fonts
  1329. $this->CoreFonts = array(
  1330. 'courier'=>'Courier',
  1331. 'courierB'=>'Courier-Bold',
  1332. 'courierI'=>'Courier-Oblique',
  1333. 'courierBI'=>'Courier-BoldOblique',
  1334. 'helvetica'=>'Helvetica',
  1335. 'helveticaB'=>'Helvetica-Bold',
  1336. 'helveticaI'=>'Helvetica-Oblique',
  1337. 'helveticaBI'=>'Helvetica-BoldOblique',
  1338. 'times'=>'Times-Roman',
  1339. 'timesB'=>'Times-Bold',
  1340. 'timesI'=>'Times-Italic',
  1341. 'timesBI'=>'Times-BoldItalic',
  1342. 'symbol'=>'Symbol',
  1343. 'zapfdingbats'=>'ZapfDingbats'
  1344. );
  1345. //Set scale factor
  1346. $this->setPageUnit($unit);
  1347. // set page format and orientation
  1348. $this->setPageFormat($format, $orientation);
  1349. //Page margins (1 cm)
  1350. $margin = 28.35 / $this->k;
  1351. $this->SetMargins($margin, $margin);
  1352. //Interior cell margin
  1353. $this->cMargin = $margin / 10;
  1354. //Line width (0.2 mm)
  1355. $this->LineWidth = 0.57 / $this->k;
  1356. $this->linestyleWidth = sprintf('%.2F w', ($this->LineWidth * $this->k));
  1357. $this->linestyleCap = '0 J';
  1358. $this->linestyleJoin = '0 j';
  1359. $this->linestyleDash = '[] 0 d';
  1360. //Automatic page break
  1361. $this->SetAutoPageBreak(true, (2 * $margin));
  1362. //Full width display mode
  1363. $this->SetDisplayMode('fullwidth');
  1364. //Compression
  1365. $this->SetCompression(true);
  1366. //Set default PDF version number
  1367. $this->PDFVersion = '1.7';
  1368. $this->encoding = $encoding;
  1369. $this->HREF = array();
  1370. $this->getFontsList();
  1371. $this->fgcolor = array('R' => 0, 'G' => 0, 'B' => 0);
  1372. $this->bgcolor = array('R' => 255, 'G' => 255, 'B' => 255);
  1373. $this->extgstates = array();
  1374. // user's rights
  1375. $this->sign = false;
  1376. $this->ur = false;
  1377. $this->ur_document = '/FullSave';
  1378. $this->ur_annots = '/Create/Delete/Modify/Copy/Import/Export';
  1379. $this->ur_form = '/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate';
  1380. $this->ur_signature = '/Modify';
  1381. // set default JPEG quality
  1382. $this->jpeg_quality = 75;
  1383. // initialize some settings
  1384. $this->utf8Bidi(array(''), '');
  1385. // set default font
  1386. $this->SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
  1387. // check if PCRE Unicode support is enabled
  1388. if ($this->isunicode AND (@preg_match('/\pL/u', 'a') == 1)) {
  1389. // PCRE unicode support is turned ON
  1390. // \p{Z} or \p{Separator}: any kind of Unicode whitespace or invisible separator.
  1391. // \p{Lo} or \p{Other_Letter}: a Unicode letter or ideograph that does not have lowercase and uppercase variants.
  1392. // \p{Lo} is needed because Chinese characters are packed next to each other without spaces in between.
  1393. //$this->re_spaces = '/[\s\p{Z}\p{Lo}]/u';
  1394. $this->re_spaces = '/[\s\p{Z}]/u';
  1395. } else {
  1396. // PCRE unicode support is turned OFF
  1397. $this->re_spaces = '/[\s]/';
  1398. }
  1399. $this->annot_obj_id = $this->annots_start_obj_id;
  1400. $this->curr_annot_obj_id = $this->annots_start_obj_id;
  1401. $this->apxo_obj_id = $this->apxo_start_obj_id;
  1402. $this->js_obj_id = $this->js_start_obj_id;
  1403. $this->default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
  1404. }
  1405. /**
  1406. * Default destructor.
  1407. * @access public
  1408. * @since 1.53.0.TC016
  1409. */
  1410. public function __destruct() {
  1411. // restore internal encoding
  1412. if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
  1413. mb_internal_encoding($this->internal_encoding);
  1414. }
  1415. // unset all class variables
  1416. $this->_destroy(true);
  1417. }
  1418. /**
  1419. * Set the units of measure for the document.
  1420. * @param string $unit 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.
  1421. * @access public
  1422. * @since 3.0.015 (2008-06-06)
  1423. */
  1424. public function setPageUnit($unit) {
  1425. //Set scale factor
  1426. switch (strtolower($unit)) {
  1427. // points
  1428. case 'px':
  1429. case 'pt': {
  1430. $this->k = 1;
  1431. break;
  1432. }
  1433. // millimeters
  1434. case 'mm': {
  1435. $this->k = $this->dpi / 25.4;
  1436. break;
  1437. }
  1438. // centimeters
  1439. case 'cm': {
  1440. $this->k = $this->dpi / 2.54;
  1441. break;
  1442. }
  1443. // inches
  1444. case 'in': {
  1445. $this->k = $this->dpi;
  1446. break;
  1447. }
  1448. // unsupported unit
  1449. default : {
  1450. $this->Error('Incorrect unit: '.$unit);
  1451. break;
  1452. }
  1453. }
  1454. if (isset($this->CurOrientation)) {
  1455. $this->setPageOrientation($this->CurOrientation);
  1456. }
  1457. }
  1458. /**
  1459. * Set the page format
  1460. * @param mixed $format The format used for pages. It can be either one of the following values (case insensitive) or a custom format in the form of a two-element array containing the width and the height (expressed in the unit given by unit).<ul><li>4A0</li><li>2A0</li><li>A0</li><li>A1</li><li>A2</li><li>A3</li><li>A4 (default)</li><li>A5</li><li>A6</li><li>A7</li><li>A8</li><li>A9</li><li>A10</li><li>B0</li><li>B1</li><li>B2</li><li>B3</li><li>B4</li><li>B5</li><li>B6</li><li>B7</li><li>B8</li><li>B9</li><li>B10</li><li>C0</li><li>C1</li><li>C2</li><li>C3</li><li>C4</li><li>C5</li><li>C6</li><li>C7</li><li>C8</li><li>C9</li><li>C10</li><li>RA0</li><li>RA1</li><li>RA2</li><li>RA3</li><li>RA4</li><li>SRA0</li><li>SRA1</li><li>SRA2</li><li>SRA3</li><li>SRA4</li><li>LETTER</li><li>LEGAL</li><li>EXECUTIVE</li><li>FOLIO</li></ul>
  1461. * @param string $orientation page orientation. Possible values are (case insensitive):<ul><li>P or PORTRAIT (default)</li><li>L or LANDSCAPE</li></ul>
  1462. * @access public
  1463. * @since 3.0.015 (2008-06-06)
  1464. */
  1465. public function setPageFormat($format, $orientation='P') {
  1466. //Page format
  1467. if (is_string($format)) {
  1468. // Page formats (45 standard ISO paper formats and 4 american common formats).
  1469. // Paper cordinates are calculated in this way: (inches * 72) where (1 inch = 2.54 cm)
  1470. switch (strtoupper($format)) {
  1471. case '4A0': {$format = array(4767.87,6740.79); break;}
  1472. case '2A0': {$format = array(3370.39,4767.87); break;}
  1473. case 'A0': {$format = array(2383.94,3370.39); break;}
  1474. case 'A1': {$format = array(1683.78,2383.94); break;}
  1475. case 'A2': {$format = array(1190.55,1683.78); break;}
  1476. case 'A3': {$format = array(841.89,1190.55); break;}
  1477. case 'A4': default: {$format = array(595.28,841.89); break;}
  1478. case 'A5': {$format = array(419.53,595.28); break;}
  1479. case 'A6': {$format = array(297.64,419.53); break;}
  1480. case 'A7': {$format = array(209.76,297.64); break;}
  1481. case 'A8': {$format = array(147.40,209.76); break;}
  1482. case 'A9': {$format = array(104.88,147.40); break;}
  1483. case 'A10': {$format = array(73.70,104.88); break;}
  1484. case 'B0': {$format = array(2834.65,4008.19); break;}
  1485. case 'B1': {$format = array(2004.09,2834.65); break;}
  1486. case 'B2': {$format = array(1417.32,2004.09); break;}
  1487. case 'B3': {$format = array(1000.63,1417.32); break;}
  1488. case 'B4': {$format = array(708.66,1000.63); break;}
  1489. case 'B5': {$format = array(498.90,708.66); break;}
  1490. case 'B6': {$format = array(354.33,498.90); break;}
  1491. case 'B7': {$format = array(249.45,354.33); break;}
  1492. case 'B8': {$format = array(175.75,249.45); break;}
  1493. case 'B9': {$format = array(124.72,175.75); break;}
  1494. case 'B10': {$format = array(87.87,124.72); break;}
  1495. case 'C0': {$format = array(2599.37,3676.54); break;}
  1496. case 'C1': {$format = array(1836.85,2599.37); break;}
  1497. case 'C2': {$format = array(1298.27,1836.85); break;}
  1498. case 'C3': {$format = array(918.43,1298.27); break;}
  1499. case 'C4': {$format = array(649.13,918.43); break;}
  1500. case 'C5': {$format = array(459.21,649.13); break;}
  1501. case 'C6': {$format = array(323.15,459.21); break;}
  1502. case 'C7': {$format = array(229.61,323.15); break;}
  1503. case 'C8': {$format = array(161.57,229.61); break;}
  1504. case 'C9': {$format = array(113.39,161.57); break;}
  1505. case 'C10': {$format = array(79.37,113.39); break;}
  1506. case 'RA0': {$format = array(2437.80,3458.27); break;}
  1507. case 'RA1': {$format = array(1729.13,2437.80); break;}
  1508. case 'RA2': {$format = array(1218.90,1729.13); break;}
  1509. case 'RA3': {$format = array(864.57,1218.90); break;}
  1510. case 'RA4': {$format = array(609.45,864.57); break;}
  1511. case 'SRA0': {$format = array(2551.18,3628.35); break;}
  1512. case 'SRA1': {$format = array(1814.17,2551.18); break;}
  1513. case 'SRA2': {$format = array(1275.59,1814.17); break;}
  1514. case 'SRA3': {$format = array(907.09,1275.59); break;}
  1515. case 'SRA4': {$format = array(637.80,907.09); break;}
  1516. case 'LETTER': {$format = array(612.00,792.00); break;}
  1517. case 'LEGAL': {$format = array(612.00,1008.00); break;}
  1518. case 'EXECUTIVE': {$format = array(521.86,756.00); break;}
  1519. case 'FOLIO': {$format = array(612.00,936.00); break;}
  1520. }
  1521. $this->fwPt = $format[0];
  1522. $this->fhPt = $format[1];
  1523. } else {
  1524. $this->fwPt = $format[0] * $this->k;
  1525. $this->fhPt = $format[1] * $this->k;
  1526. }
  1527. $this->setPageOrientation($orientation);
  1528. }
  1529. /**
  1530. * Set page orientation.
  1531. * @param string $orientation page orientation. Possible values are (case insensitive):<ul><li>P or PORTRAIT (default)</li><li>L or LANDSCAPE</li></ul>
  1532. * @param boolean $autopagebreak Boolean indicating if auto-page-break mode should be on or off.
  1533. * @param float $bottommargin bottom margin of the page.
  1534. * @access public
  1535. * @since 3.0.015 (2008-06-06)
  1536. */
  1537. public function setPageOrientation($orientation, $autopagebreak='', $bottommargin='') {
  1538. $orientation = strtoupper($orientation);
  1539. if (($orientation == 'P') OR ($orientation == 'PORTRAIT')) {
  1540. $this->CurOrientation = 'P';
  1541. $this->wPt = $this->fwPt;
  1542. $this->hPt = $this->fhPt;
  1543. } elseif (($orientation == 'L') OR ($orientation == 'LANDSCAPE')) {
  1544. $this->CurOrientation = 'L';
  1545. $this->wPt = $this->fhPt;
  1546. $this->hPt = $this->fwPt;
  1547. } else {
  1548. $this->Error('Incorrect orientation: '.$orientation);
  1549. }
  1550. $this->w = $this->wPt / $this->k;
  1551. $this->h = $this->hPt / $this->k;
  1552. if ($this->empty_string($autopagebreak)) {
  1553. if (isset($this->AutoPageBreak)) {
  1554. $autopagebreak = $this->AutoPageBreak;
  1555. } else {
  1556. $autopagebreak = true;
  1557. }
  1558. }
  1559. if ($this->empty_string($bottommargin)) {
  1560. if (isset($this->bMargin)) {
  1561. $bottommargin = $this->bMargin;
  1562. } else {
  1563. // default value = 2 cm
  1564. $bottommargin = 2 * 28.35 / $this->k;
  1565. }
  1566. }
  1567. $this->SetAutoPageBreak($autopagebreak, $bottommargin);
  1568. // store page dimensions
  1569. $this->pagedim[$this->page] = array('w' => $this->wPt, 'h' => $this->hPt, 'wk' => $this->w, 'hk' => $this->h, 'tm' => $this->tMargin, 'bm' => $bottommargin, 'lm' => $this->lMargin, 'rm' => $this->rMargin, 'pb' => $autopagebreak, 'or'

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