PageRenderTime 75ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 4ms

/plugins/sfTCPDFPlugin/lib/tcpdf/tcpdf.php

https://github.com/retrofox/Huemul
PHP | 14076 lines | 8723 code | 555 blank | 4798 comment | 1962 complexity | 2d6110f8561ef661543a831dd9a5a240 MD5 | raw file
Possible License(s): ISC, MIT, Apache-2.0, GPL-3.0, LGPL-2.1

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

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

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