PageRenderTime 88ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 2ms

/vendors/tcpdf/tcpdf.php

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

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