GAzie PHP Cross Reference Customer Relationship Management

Source: /library/tcpdf/tcpdf.php - 29927 lines - 1087989 bytes - Summary - Text - Print

   1  <?php
   2  //============================================================+
   3  // File name   : tcpdf.php
   4  // Version     : 5.9.206
   5  // Begin       : 2002-08-03
   6  // Last Update : 2013-02-22
   7  // Author      : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com
   8  // License     : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3
   9  // -------------------------------------------------------------------
  10  // Copyright (C) 2002-2013 Nicola Asuni - Tecnick.com LTD
  11  //
  12  // This file is part of TCPDF software library.
  13  //
  14  // TCPDF is free software: you can redistribute it and/or modify it
  15  // under the terms of the GNU Lesser General Public License as
  16  // published by the Free Software Foundation, either version 3 of the
  17  // License, or (at your option) any later version.
  18  //
  19  // TCPDF is distributed in the hope that it will be useful, but
  20  // WITHOUT ANY WARRANTY; without even the implied warranty of
  21  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  22  // See the GNU Lesser General Public License for more details.
  23  //
  24  // You should have received a copy of the License
  25  // along with TCPDF. If not, see
  26  // <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
  27  //
  28  // See LICENSE.TXT file for more information.
  29  // -------------------------------------------------------------------
  30  //
  31  // Description :
  32  //   This is a PHP class for generating PDF documents without requiring external extensions.
  33  //
  34  // NOTE:
  35  //   This class was originally derived in 2002 from the Public
  36  //   Domain FPDF class by Olivier Plathey (http://www.fpdf.org),
  37  //   but now is almost entirely rewritten and contains thousands of
  38  //   new lines of code and hundreds new features.
  39  //
  40  // Main features:
  41  //  * no external libraries are required for the basic functions;
  42  //  * all standard page formats, custom page formats, custom margins and units of measure;
  43  //  * UTF-8 Unicode and Right-To-Left languages;
  44  //  * TrueTypeUnicode, TrueType, Type1 and CID-0 fonts;
  45  //  * font subsetting;
  46  //  * methods to publish some XHTML + CSS code, Javascript and Forms;
  47  //  * images, graphic (geometric figures) and transformation methods;
  48  //  * supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/www/formats.html)
  49  //  * 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix, QR-Code, PDF417;
  50  //  * JPEG and PNG ICC profiles, Grayscale, RGB, CMYK, Spot Colors and Transparencies;
  51  //  * automatic page header and footer management;
  52  //  * document encryption up to 256 bit and digital signature certifications;
  53  //  * transactions to UNDO commands;
  54  //  * PDF annotations, including links, text and file attachments;
  55  //  * text rendering modes (fill, stroke and clipping);
  56  //  * multiple columns mode;
  57  //  * no-write page regions;
  58  //  * bookmarks, named destinations and table of content;
  59  //  * text hyphenation;
  60  //  * text stretching and spacing (tracking);
  61  //  * automatic page break, line break and text alignments including justification;
  62  //  * automatic page numbering and page groups;
  63  //  * move and delete pages;
  64  //  * page compression (requires php-zlib extension);
  65  //  * XOBject Templates;
  66  //  * Layers and object visibility.
  67  //    * PDF/A-1b support.
  68  //
  69  // -----------------------------------------------------------
  70  // THANKS TO:
  71  //
  72  // Olivier Plathey (http://www.fpdf.org) for original FPDF.
  73  // Efthimios Mavrogeorgiadis (emavro@yahoo.com) for suggestions on RTL language support.
  74  // Klemen Vodopivec (http://www.fpdf.de/downloads/addons/37/) for Encryption algorithm.
  75  // Warren Sherliker (wsherliker@gmail.com) for better image handling.
  76  // dullus for text Justification.
  77  // Bob Vincent (pillarsdotnet@users.sourceforge.net) for <li> value attribute.
  78  // Patrick Benny for text stretch suggestion on Cell().
  79  // Johannes Güntert for JavaScript support.
  80  // Denis Van Nuffelen for Dynamic Form.
  81  // Jacek Czekaj for multibyte justification
  82  // Anthony Ferrara for the reintroduction of legacy image methods.
  83  // Sourceforge user 1707880 (hucste) for line-trough mode.
  84  // Larry Stanbery for page groups.
  85  // Martin Hall-May for transparency.
  86  // Aaron C. Spike for Polycurve method.
  87  // Mohamad Ali Golkar, Saleh AlMatrafe, Charles Abbott for Arabic and Persian support.
  88  // Moritz Wagner and Andreas Wurmser for graphic functions.
  89  // Andrew Whitehead for core fonts support.
  90  // Esteban Joël Marín for OpenType font conversion.
  91  // Teus Hagen for several suggestions and fixes.
  92  // Yukihiro Nakadaira for CID-0 CJK fonts fixes.
  93  // Kosmas Papachristos for some CSS improvements.
  94  // Marcel Partap for some fixes.
  95  // Won Kyu Park for several suggestions, fixes and patches.
  96  // Dominik Dzienia for QR-code support.
  97  // Laurent Minguet for some suggestions.
  98  // Christian Deligant for some suggestions and fixes.
  99  // Travis Harris for crop mark suggestion.
 100  // Aleksey Kuznetsov for some suggestions and text shadows.
 101  // Jim Hanlon for several suggestions and patches.
 102  // Anyone else that has reported a bug or sent a suggestion.
 103  //============================================================+
 104  
 105  /**
 106   * @file
 107   * This is a PHP class for generating PDF documents without requiring external extensions.<br>
 108   * 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>
 109   * <h3>TCPDF main features are:</h3>
 110   * <ul>
 111   * <li>no external libraries are required for the basic functions;</li>
 112   * <li>all standard page formats, custom page formats, custom margins and units of measure;</li>
 113   * <li>UTF-8 Unicode and Right-To-Left languages;</li>
 114   * <li>TrueTypeUnicode, TrueType, Type1 and CID-0 fonts;</li>
 115   * <li>font subsetting;</li>
 116   * <li>methods to publish some XHTML + CSS code, Javascript and Forms;</li>
 117   * <li>images, graphic (geometric figures) and transformation methods;
 118   * <li>supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/www/formats.html)</li>
 119   * <li>1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix, QR-Code, PDF417;</li>
 120   * <li>JPEG and PNG ICC profiles, Grayscale, RGB, CMYK, Spot Colors and Transparencies;</li>
 121   * <li>automatic page header and footer management;</li>
 122   * <li>document encryption up to 256 bit and digital signature certifications;</li>
 123   * <li>transactions to UNDO commands;</li>
 124   * <li>PDF annotations, including links, text and file attachments;</li>
 125   * <li>text rendering modes (fill, stroke and clipping);</li>
 126   * <li>multiple columns mode;</li>
 127   * <li>no-write page regions;</li>
 128   * <li>bookmarks, named destinations and table of content;</li>
 129   * <li>text hyphenation;</li>
 130   * <li>text stretching and spacing (tracking);</li>
 131   * <li>automatic page break, line break and text alignments including justification;</li>
 132   * <li>automatic page numbering and page groups;</li>
 133   * <li>move and delete pages;</li>
 134   * <li>page compression (requires php-zlib extension);</li>
 135   * <li>XOBject Templates;</li>
 136   * <li>Layers and object visibility;</li>
 137   * <li>PDF/A-1b support.</li>
 138   * </ul>
 139   * Tools to encode your unicode fonts are on fonts/utils directory.</p>
 140   * @package com.tecnick.tcpdf
 141   * @author Nicola Asuni
 142   * @version 5.9.206
 143   */
 144  
 145  // Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
 146  require_once(dirname(__FILE__).'/config/tcpdf_config.php');
 147  
 148  /**
 149   * @class TCPDF
 150   * PHP class for generating PDF documents without requiring external extensions.
 151   * 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>
 152   * @package com.tecnick.tcpdf
 153   * @brief PHP class for generating PDF documents without requiring external extensions.
 154   * @version 5.9.206
 155   * @author Nicola Asuni - info@tecnick.com
 156   */
 157  class TCPDF {
 158  
 159      // private properties
 160  
 161      /**
 162       * Current TCPDF version.
 163       * @private
 164       */
 165      private $tcpdf_version = '5.9.206';
 166  
 167      // Protected properties
 168  
 169      /**
 170       * Current page number.
 171       * @protected
 172       */
 173      protected $page;
 174  
 175      /**
 176       * Current object number.
 177       * @protected
 178       */
 179      protected $n;
 180  
 181      /**
 182       * Array of object offsets.
 183       * @protected
 184       */
 185      protected $offsets = array();
 186  
 187      /**
 188       * Array of object IDs for each page.
 189       * @protected
 190       */
 191      protected $pageobjects = array();
 192  
 193      /**
 194       * Buffer holding in-memory PDF.
 195       * @protected
 196       */
 197      protected $buffer;
 198  
 199      /**
 200       * Array containing pages.
 201       * @protected
 202       */
 203      protected $pages = array();
 204  
 205      /**
 206       * Current document state.
 207       * @protected
 208       */
 209      protected $state;
 210  
 211      /**
 212       * Compression flag.
 213       * @protected
 214       */
 215      protected $compress;
 216  
 217      /**
 218       * Current page orientation (P = Portrait, L = Landscape).
 219       * @protected
 220       */
 221      protected $CurOrientation;
 222  
 223      /**
 224       * Page dimensions.
 225       * @protected
 226       */
 227      protected $pagedim = array();
 228  
 229      /**
 230       * Scale factor (number of points in user unit).
 231       * @protected
 232       */
 233      protected $k;
 234  
 235      /**
 236       * Width of page format in points.
 237       * @protected
 238       */
 239      protected $fwPt;
 240  
 241      /**
 242       * Height of page format in points.
 243       * @protected
 244       */
 245      protected $fhPt;
 246  
 247      /**
 248       * Current width of page in points.
 249       * @protected
 250       */
 251      protected $wPt;
 252  
 253      /**
 254       * Current height of page in points.
 255       * @protected
 256       */
 257      protected $hPt;
 258  
 259      /**
 260       * Current width of page in user unit.
 261       * @protected
 262       */
 263      protected $w;
 264  
 265      /**
 266       * Current height of page in user unit.
 267       * @protected
 268       */
 269      protected $h;
 270  
 271      /**
 272       * Left margin.
 273       * @protected
 274       */
 275      protected $lMargin;
 276  
 277      /**
 278       * Right margin.
 279       * @protected
 280       */
 281      protected $rMargin;
 282  
 283      /**
 284       * Cell left margin (used by regions).
 285       * @protected
 286       */
 287      protected $clMargin;
 288  
 289      /**
 290       * Cell right margin (used by regions).
 291       * @protected
 292       */
 293      protected $crMargin;
 294  
 295      /**
 296       * Top margin.
 297       * @protected
 298       */
 299      protected $tMargin;
 300  
 301      /**
 302       * Page break margin.
 303       * @protected
 304       */
 305      protected $bMargin;
 306  
 307      /**
 308       * Array of cell internal paddings ('T' => top, 'R' => right, 'B' => bottom, 'L' => left).
 309       * @since 5.9.000 (2010-10-03)
 310       * @protected
 311       */
 312      protected $cell_padding = array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0);
 313  
 314      /**
 315       * Array of cell margins ('T' => top, 'R' => right, 'B' => bottom, 'L' => left).
 316       * @since 5.9.000 (2010-10-04)
 317       * @protected
 318       */
 319      protected $cell_margin = array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0);
 320  
 321      /**
 322       * Current horizontal position in user unit for cell positioning.
 323       * @protected
 324       */
 325      protected $x;
 326  
 327      /**
 328       * Current vertical position in user unit for cell positioning.
 329       * @protected
 330       */
 331      protected $y;
 332  
 333      /**
 334       * Height of last cell printed.
 335       * @protected
 336       */
 337      protected $lasth;
 338  
 339      /**
 340       * Line width in user unit.
 341       * @protected
 342       */
 343      protected $LineWidth;
 344  
 345      /**
 346       * Array of standard font names.
 347       * @protected
 348       */
 349      protected $CoreFonts;
 350  
 351      /**
 352       * Array of used fonts.
 353       * @protected
 354       */
 355      protected $fonts = array();
 356  
 357      /**
 358       * Array of font files.
 359       * @protected
 360       */
 361      protected $FontFiles = array();
 362  
 363      /**
 364       * Array of encoding differences.
 365       * @protected
 366       */
 367      protected $diffs = array();
 368  
 369      /**
 370       * Array of used images.
 371       * @protected
 372       */
 373      protected $images = array();
 374  
 375      /**
 376       * Array of cached files.
 377       * @protected
 378       */
 379      protected $cached_files = array();
 380  
 381      /**
 382       * Array of Annotations in pages.
 383       * @protected
 384       */
 385      protected $PageAnnots = array();
 386  
 387      /**
 388       * Array of internal links.
 389       * @protected
 390       */
 391      protected $links = array();
 392  
 393      /**
 394       * Current font family.
 395       * @protected
 396       */
 397      protected $FontFamily;
 398  
 399      /**
 400       * Current font style.
 401       * @protected
 402       */
 403      protected $FontStyle;
 404  
 405      /**
 406       * Current font ascent (distance between font top and baseline).
 407       * @protected
 408       * @since 2.8.000 (2007-03-29)
 409       */
 410      protected $FontAscent;
 411  
 412      /**
 413       * Current font descent (distance between font bottom and baseline).
 414       * @protected
 415       * @since 2.8.000 (2007-03-29)
 416       */
 417      protected $FontDescent;
 418  
 419      /**
 420       * Underlining flag.
 421       * @protected
 422       */
 423      protected $underline;
 424  
 425      /**
 426       * Overlining flag.
 427       * @protected
 428       */
 429      protected $overline;
 430  
 431      /**
 432       * Current font info.
 433       * @protected
 434       */
 435      protected $CurrentFont;
 436  
 437      /**
 438       * Current font size in points.
 439       * @protected
 440       */
 441      protected $FontSizePt;
 442  
 443      /**
 444       * Current font size in user unit.
 445       * @protected
 446       */
 447      protected $FontSize;
 448  
 449      /**
 450       * Commands for drawing color.
 451       * @protected
 452       */
 453      protected $DrawColor;
 454  
 455      /**
 456       * Commands for filling color.
 457       * @protected
 458       */
 459      protected $FillColor;
 460  
 461      /**
 462       * Commands for text color.
 463       * @protected
 464       */
 465      protected $TextColor;
 466  
 467      /**
 468       * Indicates whether fill and text colors are different.
 469       * @protected
 470       */
 471      protected $ColorFlag;
 472  
 473      /**
 474       * Automatic page breaking.
 475       * @protected
 476       */
 477      protected $AutoPageBreak;
 478  
 479      /**
 480       * Threshold used to trigger page breaks.
 481       * @protected
 482       */
 483      protected $PageBreakTrigger;
 484  
 485      /**
 486       * Flag set when processing page header.
 487       * @protected
 488       */
 489      protected $InHeader = false;
 490  
 491      /**
 492       * Flag set when processing page footer.
 493       * @protected
 494       */
 495      protected $InFooter = false;
 496  
 497      /**
 498       * Zoom display mode.
 499       * @protected
 500       */
 501      protected $ZoomMode;
 502  
 503      /**
 504       * Layout display mode.
 505       * @protected
 506       */
 507      protected $LayoutMode;
 508  
 509      /**
 510       * If true set the document information dictionary in Unicode.
 511       * @protected
 512       */
 513      protected $docinfounicode = true;
 514  
 515      /**
 516       * Document title.
 517       * @protected
 518       */
 519      protected $title = '';
 520  
 521      /**
 522       * Document subject.
 523       * @protected
 524       */
 525      protected $subject = '';
 526  
 527      /**
 528       * Document author.
 529       * @protected
 530       */
 531      protected $author = '';
 532  
 533      /**
 534       * Document keywords.
 535       * @protected
 536       */
 537      protected $keywords = '';
 538  
 539      /**
 540       * Document creator.
 541       * @protected
 542       */
 543      protected $creator = '';
 544  
 545      /**
 546       * Starting page number.
 547       * @protected
 548       */
 549      protected $starting_page_number = 1;
 550  
 551      /**
 552       * String alias for total number of pages.
 553       * @protected
 554       */
 555      protected $alias_tot_pages = '{:ptp:}';
 556  
 557      /**
 558       * String alias for page number.
 559       * @protected
 560       */
 561      protected $alias_num_page = '{:pnp:}';
 562  
 563      /**
 564       * String alias for total number of pages in a single group.
 565       * @protected
 566       */
 567      protected $alias_group_tot_pages = '{:ptg:}';
 568  
 569      /**
 570       * String alias for group page number.
 571       * @protected
 572       */
 573      protected $alias_group_num_page = '{:png:}';
 574  
 575      /**
 576       * String alias for right shift compensation used to correctly align page numbers on the right.
 577       * @protected
 578       */
 579      protected $alias_right_shift = '{rsc:';
 580  
 581      /**
 582       * The right-bottom (or left-bottom for RTL) corner X coordinate of last inserted image.
 583       * @since 2002-07-31
 584       * @author Nicola Asuni
 585       * @protected
 586       */
 587      protected $img_rb_x;
 588  
 589      /**
 590       * The right-bottom corner Y coordinate of last inserted image.
 591       * @since 2002-07-31
 592       * @author Nicola Asuni
 593       * @protected
 594       */
 595      protected $img_rb_y;
 596  
 597      /**
 598       * Adjusting factor to convert pixels to user units.
 599       * @since 2004-06-14
 600       * @author Nicola Asuni
 601       * @protected
 602       */
 603      protected $imgscale = 1;
 604  
 605      /**
 606       * Boolean flag set to true when the input text is unicode (require unicode fonts).
 607       * @since 2005-01-02
 608       * @author Nicola Asuni
 609       * @protected
 610       */
 611      protected $isunicode = false;
 612  
 613      /**
 614       * Object containing unicode data.
 615       * @since 5.9.004 (2010-10-18)
 616       * @author Nicola Asuni
 617       * @protected
 618       */
 619      protected $unicode;
 620  
 621      /**
 622       * Object containing font encoding maps.
 623       * @since 5.9.123 (2011-10-01)
 624       * @author Nicola Asuni
 625       * @protected
 626       */
 627      protected $encmaps;
 628  
 629      /**
 630       * PDF version.
 631       * @since 1.5.3
 632       * @protected
 633       */
 634      protected $PDFVersion = '1.7';
 635  
 636      /**
 637       * ID of the stored default header template (-1 = not set).
 638       * @protected
 639       */
 640      protected $header_xobjid = -1;
 641  
 642      /**
 643       * If true reset the Header Xobject template at each page
 644       * @protected
 645       */
 646      protected $header_xobj_autoreset = false;
 647  
 648      /**
 649       * Minimum distance between header and top page margin.
 650       * @protected
 651       */
 652      protected $header_margin;
 653  
 654      /**
 655       * Minimum distance between footer and bottom page margin.
 656       * @protected
 657       */
 658      protected $footer_margin;
 659  
 660      /**
 661       * Original left margin value.
 662       * @protected
 663       * @since 1.53.0.TC013
 664       */
 665      protected $original_lMargin;
 666  
 667      /**
 668       * Original right margin value.
 669       * @protected
 670       * @since 1.53.0.TC013
 671       */
 672      protected $original_rMargin;
 673  
 674      /**
 675       * Default font used on page header.
 676       * @protected
 677       */
 678      protected $header_font;
 679  
 680      /**
 681       * Default font used on page footer.
 682       * @protected
 683       */
 684      protected $footer_font;
 685  
 686      /**
 687       * Language templates.
 688       * @protected
 689       */
 690      protected $l;
 691  
 692      /**
 693       * Barcode to print on page footer (only if set).
 694       * @protected
 695       */
 696      protected $barcode = false;
 697  
 698      /**
 699       * Boolean flag to print/hide page header.
 700       * @protected
 701       */
 702      protected $print_header = true;
 703  
 704      /**
 705       * Boolean flag to print/hide page footer.
 706       * @protected
 707       */
 708      protected $print_footer = true;
 709  
 710      /**
 711       * Header image logo.
 712       * @protected
 713       */
 714      protected $header_logo = '';
 715  
 716      /**
 717       * Width of header image logo in user units.
 718       * @protected
 719       */
 720      protected $header_logo_width = 30;
 721  
 722      /**
 723       * Title to be printed on default page header.
 724       * @protected
 725       */
 726      protected $header_title = '';
 727  
 728      /**
 729       * String to pring on page header after title.
 730       * @protected
 731       */
 732      protected $header_string = '';
 733  
 734      /**
 735       * Color for header text (RGB array).
 736       * @since 5.9.174 (2012-07-25)
 737       * @protected
 738       */
 739      protected $header_text_color = array(0,0,0);
 740  
 741      /**
 742       * Color for header line (RGB array).
 743       * @since 5.9.174 (2012-07-25)
 744       * @protected
 745       */
 746      protected $header_line_color = array(0,0,0);
 747  
 748      /**
 749       * Color for footer text (RGB array).
 750       * @since 5.9.174 (2012-07-25)
 751       * @protected
 752       */
 753      protected $footer_text_color = array(0,0,0);
 754  
 755      /**
 756       * Color for footer line (RGB array).
 757       * @since 5.9.174 (2012-07-25)
 758       * @protected
 759       */
 760      protected $footer_line_color = array(0,0,0);
 761  
 762      /**
 763       * Text shadow data array.
 764       * @since 5.9.174 (2012-07-25)
 765       * @protected
 766       */
 767      protected $txtshadow = array('enabled'=>false, 'depth_w'=>0, 'depth_h'=>0, 'color'=>false, 'opacity'=>1, 'blend_mode'=>'Normal');
 768  
 769      /**
 770       * Default number of columns for html table.
 771       * @protected
 772       */
 773      protected $default_table_columns = 4;
 774  
 775      // variables for html parser
 776  
 777      /**
 778       * HTML PARSER: array to store current link and rendering styles.
 779       * @protected
 780       */
 781      protected $HREF = array();
 782  
 783      /**
 784       * List of available fonts on filesystem.
 785       * @protected
 786       */
 787      protected $fontlist = array();
 788  
 789      /**
 790       * Current foreground color.
 791       * @protected
 792       */
 793      protected $fgcolor;
 794  
 795      /**
 796       * HTML PARSER: array of boolean values, true in case of ordered list (OL), false otherwise.
 797       * @protected
 798       */
 799      protected $listordered = array();
 800  
 801      /**
 802       * HTML PARSER: array count list items on nested lists.
 803       * @protected
 804       */
 805      protected $listcount = array();
 806  
 807      /**
 808       * HTML PARSER: current list nesting level.
 809       * @protected
 810       */
 811      protected $listnum = 0;
 812  
 813      /**
 814       * HTML PARSER: indent amount for lists.
 815       * @protected
 816       */
 817      protected $listindent = 0;
 818  
 819      /**
 820       * HTML PARSER: current list indententation level.
 821       * @protected
 822       */
 823      protected $listindentlevel = 0;
 824  
 825      /**
 826       * Current background color.
 827       * @protected
 828       */
 829      protected $bgcolor;
 830  
 831      /**
 832       * Temporary font size in points.
 833       * @protected
 834       */
 835      protected $tempfontsize = 10;
 836  
 837      /**
 838       * Spacer string for LI tags.
 839       * @protected
 840       */
 841      protected $lispacer = '';
 842  
 843      /**
 844       * Default encoding.
 845       * @protected
 846       * @since 1.53.0.TC010
 847       */
 848      protected $encoding = 'UTF-8';
 849  
 850      /**
 851       * PHP internal encoding.
 852       * @protected
 853       * @since 1.53.0.TC016
 854       */
 855      protected $internal_encoding;
 856  
 857      /**
 858       * Boolean flag to indicate if the document language is Right-To-Left.
 859       * @protected
 860       * @since 2.0.000
 861       */
 862      protected $rtl = false;
 863  
 864      /**
 865       * Boolean flag used to force RTL or LTR string direction.
 866       * @protected
 867       * @since 2.0.000
 868       */
 869      protected $tmprtl = false;
 870  
 871      // --- Variables used for document encryption:
 872  
 873      /**
 874       * IBoolean flag indicating whether document is protected.
 875       * @protected
 876       * @since 2.0.000 (2008-01-02)
 877       */
 878      protected $encrypted;
 879  
 880      /**
 881       * Array containing encryption settings.
 882       * @protected
 883       * @since 5.0.005 (2010-05-11)
 884       */
 885      protected $encryptdata = array();
 886  
 887      /**
 888       * Last RC4 key encrypted (cached for optimisation).
 889       * @protected
 890       * @since 2.0.000 (2008-01-02)
 891       */
 892      protected $last_enc_key;
 893  
 894      /**
 895       * Last RC4 computed key.
 896       * @protected
 897       * @since 2.0.000 (2008-01-02)
 898       */
 899      protected $last_enc_key_c;
 900  
 901      /**
 902       * Encryption padding string.
 903       * @protected
 904       */
 905      protected $enc_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";
 906  
 907      /**
 908       * File ID (used on document trailer).
 909       * @protected
 910       * @since 5.0.005 (2010-05-12)
 911       */
 912      protected $file_id;
 913  
 914      // --- bookmark ---
 915  
 916      /**
 917       * Outlines for bookmark.
 918       * @protected
 919       * @since 2.1.002 (2008-02-12)
 920       */
 921      protected $outlines = array();
 922  
 923      /**
 924       * Outline root for bookmark.
 925       * @protected
 926       * @since 2.1.002 (2008-02-12)
 927       */
 928      protected $OutlineRoot;
 929  
 930      // --- javascript and form ---
 931  
 932      /**
 933       * Javascript code.
 934       * @protected
 935       * @since 2.1.002 (2008-02-12)
 936       */
 937      protected $javascript = '';
 938  
 939      /**
 940       * Javascript counter.
 941       * @protected
 942       * @since 2.1.002 (2008-02-12)
 943       */
 944      protected $n_js;
 945  
 946      /**
 947       * line trough state
 948       * @protected
 949       * @since 2.8.000 (2008-03-19)
 950       */
 951      protected $linethrough;
 952  
 953      /**
 954       * Array with additional document-wide usage rights for the document.
 955       * @protected
 956       * @since 5.8.014 (2010-08-23)
 957       */
 958      protected $ur = array();
 959  
 960      /**
 961       * DPI (Dot Per Inch) Document Resolution (do not change).
 962       * @protected
 963       * @since 3.0.000 (2008-03-27)
 964       */
 965      protected $dpi = 72;
 966  
 967      /**
 968       * Array of page numbers were a new page group was started (the page numbers are the keys of the array).
 969       * @protected
 970       * @since 3.0.000 (2008-03-27)
 971       */
 972      protected $newpagegroup = array();
 973  
 974      /**
 975       * Array that contains the number of pages in each page group.
 976       * @protected
 977       * @since 3.0.000 (2008-03-27)
 978       */
 979      protected $pagegroups = array();
 980  
 981      /**
 982       * Current page group number.
 983       * @protected
 984       * @since 3.0.000 (2008-03-27)
 985       */
 986      protected $currpagegroup = 0;
 987  
 988      /**
 989       * Array of transparency objects and parameters.
 990       * @protected
 991       * @since 3.0.000 (2008-03-27)
 992       */
 993      protected $extgstates;
 994  
 995      /**
 996       * Set the default JPEG compression quality (1-100).
 997       * @protected
 998       * @since 3.0.000 (2008-03-27)
 999       */
1000      protected $jpeg_quality;
1001  
1002      /**
1003       * Default cell height ratio.
1004       * @protected
1005       * @since 3.0.014 (2008-05-23)
1006       */
1007      protected $cell_height_ratio = K_CELL_HEIGHT_RATIO;
1008  
1009      /**
1010       * PDF viewer preferences.
1011       * @protected
1012       * @since 3.1.000 (2008-06-09)
1013       */
1014      protected $viewer_preferences;
1015  
1016      /**
1017       * A name object specifying how the document should be displayed when opened.
1018       * @protected
1019       * @since 3.1.000 (2008-06-09)
1020       */
1021      protected $PageMode;
1022  
1023      /**
1024       * Array for storing gradient information.
1025       * @protected
1026       * @since 3.1.000 (2008-06-09)
1027       */
1028      protected $gradients = array();
1029  
1030      /**
1031       * Array used to store positions inside the pages buffer (keys are the page numbers).
1032       * @protected
1033       * @since 3.2.000 (2008-06-26)
1034       */
1035      protected $intmrk = array();
1036  
1037      /**
1038       * Array used to store positions inside the pages buffer (keys are the page numbers).
1039       * @protected
1040       * @since 5.7.000 (2010-08-03)
1041       */
1042      protected $bordermrk = array();
1043  
1044      /**
1045       * Array used to store page positions to track empty pages (keys are the page numbers).
1046       * @protected
1047       * @since 5.8.007 (2010-08-18)
1048       */
1049      protected $emptypagemrk = array();
1050  
1051      /**
1052       * Array used to store content positions inside the pages buffer (keys are the page numbers).
1053       * @protected
1054       * @since 4.6.021 (2009-07-20)
1055       */
1056      protected $cntmrk = array();
1057  
1058      /**
1059       * Array used to store footer positions of each page.
1060       * @protected
1061       * @since 3.2.000 (2008-07-01)
1062       */
1063      protected $footerpos = array();
1064  
1065      /**
1066       * Array used to store footer length of each page.
1067       * @protected
1068       * @since 4.0.014 (2008-07-29)
1069       */
1070      protected $footerlen = array();
1071  
1072      /**
1073       * Boolean flag to indicate if a new line is created.
1074       * @protected
1075       * @since 3.2.000 (2008-07-01)
1076       */
1077      protected $newline = true;
1078  
1079      /**
1080       * End position of the latest inserted line.
1081       * @protected
1082       * @since 3.2.000 (2008-07-01)
1083       */
1084      protected $endlinex = 0;
1085  
1086      /**
1087       * PDF string for width value of the last line.
1088       * @protected
1089       * @since 4.0.006 (2008-07-16)
1090       */
1091      protected $linestyleWidth = '';
1092  
1093      /**
1094       * PDF string for CAP value of the last line.
1095       * @protected
1096       * @since 4.0.006 (2008-07-16)
1097       */
1098      protected $linestyleCap = '0 J';
1099  
1100      /**
1101       * PDF string for join value of the last line.
1102       * @protected
1103       * @since 4.0.006 (2008-07-16)
1104       */
1105      protected $linestyleJoin = '0 j';
1106  
1107      /**
1108       * PDF string for dash value of the last line.
1109       * @protected
1110       * @since 4.0.006 (2008-07-16)
1111       */
1112      protected $linestyleDash = '[] 0 d';
1113  
1114      /**
1115       * Boolean flag to indicate if marked-content sequence is open.
1116       * @protected
1117       * @since 4.0.013 (2008-07-28)
1118       */
1119      protected $openMarkedContent = false;
1120  
1121      /**
1122       * Count the latest inserted vertical spaces on HTML.
1123       * @protected
1124       * @since 4.0.021 (2008-08-24)
1125       */
1126      protected $htmlvspace = 0;
1127  
1128      /**
1129       * Array of Spot colors.
1130       * @protected
1131       * @since 4.0.024 (2008-09-12)
1132       */
1133      protected $spot_colors = array();
1134  
1135      /**
1136       * Symbol used for HTML unordered list items.
1137       * @protected
1138       * @since 4.0.028 (2008-09-26)
1139       */
1140      protected $lisymbol = '';
1141  
1142      /**
1143       * String used to mark the beginning and end of EPS image blocks.
1144       * @protected
1145       * @since 4.1.000 (2008-10-18)
1146       */
1147      protected $epsmarker = 'x#!#EPS#!#x';
1148  
1149      /**
1150       * Array of transformation matrix.
1151       * @protected
1152       * @since 4.2.000 (2008-10-29)
1153       */
1154      protected $transfmatrix = array();
1155  
1156      /**
1157       * Current key for transformation matrix.
1158       * @protected
1159       * @since 4.8.005 (2009-09-17)
1160       */
1161      protected $transfmatrix_key = 0;
1162  
1163      /**
1164       * Booklet mode for double-sided pages.
1165       * @protected
1166       * @since 4.2.000 (2008-10-29)
1167       */
1168      protected $booklet = false;
1169  
1170      /**
1171       * Epsilon value used for float calculations.
1172       * @protected
1173       * @since 4.2.000 (2008-10-29)
1174       */
1175      protected $feps = 0.005;
1176  
1177      /**
1178       * Array used for custom vertical spaces for HTML tags.
1179       * @protected
1180       * @since 4.2.001 (2008-10-30)
1181       */
1182      protected $tagvspaces = array();
1183  
1184      /**
1185       * HTML PARSER: custom indent amount for lists. Negative value means disabled.
1186       * @protected
1187       * @since 4.2.007 (2008-11-12)
1188       */
1189      protected $customlistindent = -1;
1190  
1191      /**
1192       * Boolean flag to indicate if the border of the cell sides that cross the page should be removed.
1193       * @protected
1194       * @since 4.2.010 (2008-11-14)
1195       */
1196      protected $opencell = true;
1197  
1198      /**
1199       * Array of files to embedd.
1200       * @protected
1201       * @since 4.4.000 (2008-12-07)
1202       */
1203      protected $embeddedfiles = array();
1204  
1205      /**
1206       * Boolean flag to indicate if we are inside a PRE tag.
1207       * @protected
1208       * @since 4.4.001 (2008-12-08)
1209       */
1210      protected $premode = false;
1211  
1212      /**
1213       * Array used to store positions of graphics transformation blocks inside the page buffer.
1214       * keys are the page numbers
1215       * @protected
1216       * @since 4.4.002 (2008-12-09)
1217       */
1218      protected $transfmrk = array();
1219  
1220      /**
1221       * Default color for html links.
1222       * @protected
1223       * @since 4.4.003 (2008-12-09)
1224       */
1225      protected $htmlLinkColorArray = array(0, 0, 255);
1226  
1227      /**
1228       * Default font style to add to html links.
1229       * @protected
1230       * @since 4.4.003 (2008-12-09)
1231       */
1232      protected $htmlLinkFontStyle = 'U';
1233  
1234      /**
1235       * Counts the number of pages.
1236       * @protected
1237       * @since 4.5.000 (2008-12-31)
1238       */
1239      protected $numpages = 0;
1240  
1241      /**
1242       * Array containing page lengths in bytes.
1243       * @protected
1244       * @since 4.5.000 (2008-12-31)
1245       */
1246      protected $pagelen = array();
1247  
1248      /**
1249       * Counts the number of pages.
1250       * @protected
1251       * @since 4.5.000 (2008-12-31)
1252       */
1253      protected $numimages = 0;
1254  
1255      /**
1256       * Store the image keys.
1257       * @protected
1258       * @since 4.5.000 (2008-12-31)
1259       */
1260      protected $imagekeys = array();
1261  
1262      /**
1263       * Length of the buffer in bytes.
1264       * @protected
1265       * @since 4.5.000 (2008-12-31)
1266       */
1267      protected $bufferlen = 0;
1268  
1269      /**
1270       * If true enables disk caching.
1271       * @protected
1272       * @since 4.5.000 (2008-12-31)
1273       */
1274      protected $diskcache = false;
1275  
1276      /**
1277       * Counts the number of fonts.
1278       * @protected
1279       * @since 4.5.000 (2009-01-02)
1280       */
1281      protected $numfonts = 0;
1282  
1283      /**
1284       * Store the font keys.
1285       * @protected
1286       * @since 4.5.000 (2009-01-02)
1287       */
1288      protected $fontkeys = array();
1289  
1290      /**
1291       * Store the font object IDs.
1292       * @protected
1293       * @since 4.8.001 (2009-09-09)
1294       */
1295      protected $font_obj_ids = array();
1296  
1297      /**
1298       * Store the fage status (true when opened, false when closed).
1299       * @protected
1300       * @since 4.5.000 (2009-01-02)
1301       */
1302      protected $pageopen = array();
1303  
1304      /**
1305       * Default monospace font.
1306       * @protected
1307       * @since 4.5.025 (2009-03-10)
1308       */
1309      protected $default_monospaced_font = 'courier';
1310  
1311      /**
1312       * Cloned copy of the current class object.
1313       * @protected
1314       * @since 4.5.029 (2009-03-19)
1315       */
1316      protected $objcopy;
1317  
1318      /**
1319       * Array used to store the lengths of cache files.
1320       * @protected
1321       * @since 4.5.029 (2009-03-19)
1322       */
1323      protected $cache_file_length = array();
1324  
1325      /**
1326       * Table header content to be repeated on each new page.
1327       * @protected
1328       * @since 4.5.030 (2009-03-20)
1329       */
1330      protected $thead = '';
1331  
1332      /**
1333       * Margins used for table header.
1334       * @protected
1335       * @since 4.5.030 (2009-03-20)
1336       */
1337      protected $theadMargins = array();
1338  
1339      /**
1340       * Cache array for UTF8StringToArray() method.
1341       * @protected
1342       * @since 4.5.037 (2009-04-07)
1343       */
1344      protected $cache_UTF8StringToArray = array();
1345  
1346      /**
1347       * Maximum size of cache array used for UTF8StringToArray() method.
1348       * @protected
1349       * @since 4.5.037 (2009-04-07)
1350       */
1351      protected $cache_maxsize_UTF8StringToArray = 8;
1352  
1353      /**
1354       * Current size of cache array used for UTF8StringToArray() method.
1355       * @protected
1356       * @since 4.5.037 (2009-04-07)
1357       */
1358      protected $cache_size_UTF8StringToArray = 0;
1359  
1360      /**
1361       * Boolean flag to enable document digital signature.
1362       * @protected
1363       * @since 4.6.005 (2009-04-24)
1364       */
1365      protected $sign = false;
1366  
1367      /**
1368       * Digital signature data.
1369       * @protected
1370       * @since 4.6.005 (2009-04-24)
1371       */
1372      protected $signature_data = array();
1373  
1374      /**
1375       * Digital signature max length.
1376       * @protected
1377       * @since 4.6.005 (2009-04-24)
1378       */
1379      protected $signature_max_length = 11742;
1380  
1381      /**
1382       * Data for digital signature appearance.
1383       * @protected
1384       * @since 5.3.011 (2010-06-16)
1385       */
1386      protected $signature_appearance = array('page' => 1, 'rect' => '0 0 0 0');
1387  
1388      /**
1389       * Array of empty digital signature appearances.
1390       * @protected
1391       * @since 5.9.101 (2011-07-06)
1392       */
1393      protected $empty_signature_appearance = array();
1394  
1395      /**
1396       * Regular expression used to find blank characters (required for word-wrapping).
1397       * @protected
1398       * @since 4.6.006 (2009-04-28)
1399       */
1400      protected $re_spaces = '/[^\S\xa0]/';
1401  
1402      /**
1403       * Array of $re_spaces parts.
1404       * @protected
1405       * @since 5.5.011 (2010-07-09)
1406       */
1407      protected $re_space = array('p' => '[^\S\xa0]', 'm' => '');
1408  
1409      /**
1410       * Digital signature object ID.
1411       * @protected
1412       * @since 4.6.022 (2009-06-23)
1413       */
1414      protected $sig_obj_id = 0;
1415  
1416      /**
1417       * ByteRange placemark used during digital signature process.
1418       * @protected
1419       * @since 4.6.028 (2009-08-25)
1420       */
1421      protected $byterange_string = '/ByteRange[0 ********** ********** **********]';
1422  
1423      /**
1424       * Placemark used during digital signature process.
1425       * @protected
1426       * @since 4.6.028 (2009-08-25)
1427       */
1428      protected $sig_annot_ref = '***SIGANNREF*** 0 R';
1429  
1430      /**
1431       * ID of page objects.
1432       * @protected
1433       * @since 4.7.000 (2009-08-29)
1434       */
1435      protected $page_obj_id = array();
1436  
1437      /**
1438       * List of form annotations IDs.
1439       * @protected
1440       * @since 4.8.000 (2009-09-07)
1441       */
1442      protected $form_obj_id = array();
1443  
1444      /**
1445       * 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.
1446       * @protected
1447       * @since 4.8.000 (2009-09-07)
1448       */
1449      protected $default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
1450  
1451      /**
1452       * Javascript objects array.
1453       * @protected
1454       * @since 4.8.000 (2009-09-07)
1455       */
1456      protected $js_objects = array();
1457  
1458      /**
1459       * Current form action (used during XHTML rendering).
1460       * @protected
1461       * @since 4.8.000 (2009-09-07)
1462       */
1463      protected $form_action = '';
1464  
1465      /**
1466       * Current form encryption type (used during XHTML rendering).
1467       * @protected
1468       * @since 4.8.000 (2009-09-07)
1469       */
1470      protected $form_enctype = 'application/x-www-form-urlencoded';
1471  
1472      /**
1473       * Current method to submit forms.
1474       * @protected
1475       * @since 4.8.000 (2009-09-07)
1476       */
1477      protected $form_mode = 'post';
1478  
1479      /**
1480       * List of fonts used on form fields (fontname => fontkey).
1481       * @protected
1482       * @since 4.8.001 (2009-09-09)
1483       */
1484      protected $annotation_fonts = array();
1485  
1486      /**
1487       * List of radio buttons parent objects.
1488       * @protected
1489       * @since 4.8.001 (2009-09-09)
1490       */
1491      protected $radiobutton_groups = array();
1492  
1493      /**
1494       * List of radio group objects IDs.
1495       * @protected
1496       * @since 4.8.001 (2009-09-09)
1497       */
1498      protected $radio_groups = array();
1499  
1500      /**
1501       * Text indentation value (used for text-indent CSS attribute).
1502       * @protected
1503       * @since 4.8.006 (2009-09-23)
1504       */
1505      protected $textindent = 0;
1506  
1507      /**
1508       * Store page number when startTransaction() is called.
1509       * @protected
1510       * @since 4.8.006 (2009-09-23)
1511       */
1512      protected $start_transaction_page = 0;
1513  
1514      /**
1515       * Store Y position when startTransaction() is called.
1516       * @protected
1517       * @since 4.9.001 (2010-03-28)
1518       */
1519      protected $start_transaction_y = 0;
1520  
1521      /**
1522       * True when we are printing the thead section on a new page.
1523       * @protected
1524       * @since 4.8.027 (2010-01-25)
1525       */
1526      protected $inthead = false;
1527  
1528      /**
1529       * Array of column measures (width, space, starting Y position).
1530       * @protected
1531       * @since 4.9.001 (2010-03-28)
1532       */
1533      protected $columns = array();
1534  
1535      /**
1536       * Number of colums.
1537       * @protected
1538       * @since 4.9.001 (2010-03-28)
1539       */
1540      protected $num_columns = 1;
1541  
1542      /**
1543       * Current column number.
1544       * @protected
1545       * @since 4.9.001 (2010-03-28)
1546       */
1547      protected $current_column = 0;
1548  
1549      /**
1550       * Starting page for columns.
1551       * @protected
1552       * @since 4.9.001 (2010-03-28)
1553       */
1554      protected $column_start_page = 0;
1555  
1556      /**
1557       * Maximum page and column selected.
1558       * @protected
1559       * @since 5.8.000 (2010-08-11)
1560       */
1561      protected $maxselcol = array('page' => 0, 'column' => 0);
1562  
1563      /**
1564       * Array of: X difference between table cell x start and starting page margin, cellspacing, cellpadding.
1565       * @protected
1566       * @since 5.8.000 (2010-08-11)
1567       */
1568      protected $colxshift = array('x' => 0, 's' => array('H' => 0, 'V' => 0), 'p' => array('L' => 0, 'T' => 0, 'R' => 0, 'B' => 0));
1569  
1570      /**
1571       * 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.
1572       * @protected
1573       * @since 4.9.008 (2010-04-03)
1574       */
1575      protected $textrendermode = 0;
1576  
1577      /**
1578       * Text stroke width in doc units.
1579       * @protected
1580       * @since 4.9.008 (2010-04-03)
1581       */
1582      protected $textstrokewidth = 0;
1583  
1584      /**
1585       * Current stroke color.
1586       * @protected
1587       * @since 4.9.008 (2010-04-03)
1588       */
1589      protected $strokecolor;
1590  
1591      /**
1592       * Default unit of measure for document.
1593       * @protected
1594       * @since 5.0.000 (2010-04-22)
1595       */
1596      protected $pdfunit = 'mm';
1597  
1598      /**
1599       * Boolean flag true when we are on TOC (Table Of Content) page.
1600       * @protected
1601       */
1602      protected $tocpage = false;
1603  
1604      /**
1605       * Boolean flag: if true convert vector images (SVG, EPS) to raster image using GD or ImageMagick library.
1606       * @protected
1607       * @since 5.0.000 (2010-04-26)
1608       */
1609      protected $rasterize_vector_images = false;
1610  
1611      /**
1612       * Boolean flag: if true enables font subsetting by default.
1613       * @protected
1614       * @since 5.3.002 (2010-06-07)
1615       */
1616      protected $font_subsetting = true;
1617  
1618      /**
1619       * Array of default graphic settings.
1620       * @protected
1621       * @since 5.5.008 (2010-07-02)
1622       */
1623      protected $default_graphic_vars = array();
1624  
1625      /**
1626       * Array of XObjects.
1627       * @protected
1628       * @since 5.8.014 (2010-08-23)
1629       */
1630      protected $xobjects = array();
1631  
1632      /**
1633       * Boolean value true when we are inside an XObject.
1634       * @protected
1635       * @since 5.8.017 (2010-08-24)
1636       */
1637      protected $inxobj = false;
1638  
1639      /**
1640       * Current XObject ID.
1641       * @protected
1642       * @since 5.8.017 (2010-08-24)
1643       */
1644      protected $xobjid = '';
1645  
1646      /**
1647       * Percentage of character stretching.
1648       * @protected
1649       * @since 5.9.000 (2010-09-29)
1650       */
1651      protected $font_stretching = 100;
1652  
1653      /**
1654       * Increases or decreases the space between characters in a text by the specified amount (tracking).
1655       * @protected
1656       * @since 5.9.000 (2010-09-29)
1657       */
1658      protected $font_spacing = 0;
1659  
1660      /**
1661       * Array of no-write regions.
1662       * ('page' => page number or empy for current page, 'xt' => X top, 'yt' => Y top, 'xb' => X bottom, 'yb' => Y bottom, 'side' => page side 'L' = left or 'R' = right)
1663       * @protected
1664       * @since 5.9.003 (2010-10-14)
1665       */
1666      protected $page_regions = array();
1667  
1668      /**
1669       * Boolean value true when page region check is active.
1670       * @protected
1671       */
1672      protected $check_page_regions = true;
1673  
1674      /**
1675       * Array containing HTML color names and values.
1676       * @protected
1677       * @since 5.9.004 (2010-10-18)
1678       */
1679      protected $webcolor = array();
1680  
1681      /**
1682       * Array containing spot color names and values.
1683       * @protected
1684       * @since 5.9.012 (2010-11-11)
1685       */
1686      protected $spotcolor = array();
1687  
1688      /**
1689       * Array of PDF layers data.
1690       * @protected
1691       * @since 5.9.102 (2011-07-13)
1692       */
1693      protected $pdflayers = array();
1694  
1695      /**
1696       * A dictionary of names and corresponding destinations (Dests key on document Catalog).
1697       * @protected
1698       * @since 5.9.097 (2011-06-23)
1699       */
1700      protected $dests = array();
1701  
1702      /**
1703       * Object ID for Named Destinations
1704       * @protected
1705       * @since 5.9.097 (2011-06-23)
1706       */
1707      protected $n_dests;
1708  
1709      /**
1710       * Embedded Files Names
1711       * @protected
1712       * @since 5.9.204 (2013-01-23)
1713       */
1714      protected $efnames = array();
1715  
1716      /**
1717       * Directory used for the last SVG image.
1718       * @protected
1719       * @since 5.0.000 (2010-05-05)
1720       */
1721      protected $svgdir = '';
1722  
1723      /**
1724       *  Deafult unit of measure for SVG.
1725       * @protected
1726       * @since 5.0.000 (2010-05-02)
1727       */
1728      protected $svgunit = 'px';
1729  
1730      /**
1731       * Array of SVG gradients.
1732       * @protected
1733       * @since 5.0.000 (2010-05-02)
1734       */
1735      protected $svggradients = array();
1736  
1737      /**
1738       * ID of last SVG gradient.
1739       * @protected
1740       * @since 5.0.000 (2010-05-02)
1741       */
1742      protected $svggradientid = 0;
1743  
1744      /**
1745       * Boolean value true when in SVG defs group.
1746       * @protected
1747       * @since 5.0.000 (2010-05-02)
1748       */
1749      protected $svgdefsmode = false;
1750  
1751      /**
1752       * Array of SVG defs.
1753       * @protected
1754       * @since 5.0.000 (2010-05-02)
1755       */
1756      protected $svgdefs = array();
1757  
1758      /**
1759       * Boolean value true when in SVG clipPath tag.
1760       * @protected
1761       * @since 5.0.000 (2010-04-26)
1762       */
1763      protected $svgclipmode = false;
1764  
1765      /**
1766       * Array of SVG clipPath commands.
1767       * @protected
1768       * @since 5.0.000 (2010-05-02)
1769       */
1770      protected $svgclippaths = array();
1771  
1772      /**
1773       * Array of SVG clipPath tranformation matrix.
1774       * @protected
1775       * @since 5.8.022 (2010-08-31)
1776       */
1777      protected $svgcliptm = array();
1778  
1779      /**
1780       * ID of last SVG clipPath.
1781       * @protected
1782       * @since 5.0.000 (2010-05-02)
1783       */
1784      protected $svgclipid = 0;
1785  
1786      /**
1787       * SVG text.
1788       * @protected
1789       * @since 5.0.000 (2010-05-02)
1790       */
1791      protected $svgtext = '';
1792  
1793      /**
1794       * SVG text properties.
1795       * @protected
1796       * @since 5.8.013 (2010-08-23)
1797       */
1798      protected $svgtextmode = array();
1799  
1800      /**
1801       * Array of hinheritable SVG properties.
1802       * @protected
1803       * @since 5.0.000 (2010-05-02)
1804       */
1805      protected $svginheritprop = array('clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cursor', 'direction', 'fill', 'fill-opacity', 'fill-rule', 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'image-rendering', 'kerning', 'letter-spacing', 'marker', 'marker-end', 'marker-mid', 'marker-start', 'pointer-events', 'shape-rendering', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-rendering', 'visibility', 'word-spacing', 'writing-mode');
1806  
1807      /**
1808       * Array of SVG properties.
1809       * @protected
1810       * @since 5.0.000 (2010-05-02)
1811       */
1812      protected $svgstyles = array(array(
1813          'alignment-baseline' => 'auto',
1814          'baseline-shift' => 'baseline',
1815          'clip' => 'auto',
1816          'clip-path' => 'none',
1817          'clip-rule' => 'nonzero',
1818          'color' => 'black',
1819          'color-interpolation' => 'sRGB',
1820          'color-interpolation-filters' => 'linearRGB',
1821          'color-profile' => 'auto',
1822          'color-rendering' => 'auto',
1823          'cursor' => 'auto',
1824          'direction' => 'ltr',
1825          'display' => 'inline',
1826          'dominant-baseline' => 'auto',
1827          'enable-background' => 'accumulate',
1828          'fill' => 'black',
1829          'fill-opacity' => 1,
1830          'fill-rule' => 'nonzero',
1831          'filter' => 'none',
1832          'flood-color' => 'black',
1833          'flood-opacity' => 1,
1834          'font' => '',
1835          'font-family' => 'helvetica',
1836          'font-size' => 'medium',
1837          'font-size-adjust' => 'none',
1838          'font-stretch' => 'normal',
1839          'font-style' => 'normal',
1840          'font-variant' => 'normal',
1841          'font-weight' => 'normal',
1842          'glyph-orientation-horizontal' => '0deg',
1843          'glyph-orientation-vertical' => 'auto',
1844          'image-rendering' => 'auto',
1845          'kerning' => 'auto',
1846          'letter-spacing' => 'normal',
1847          'lighting-color' => 'white',
1848          'marker' => '',
1849          'marker-end' => 'none',
1850          'marker-mid' => 'none',
1851          'marker-start' => 'none',
1852          'mask' => 'none',
1853          'opacity' => 1,
1854          'overflow' => 'auto',
1855          'pointer-events' => 'visiblePainted',
1856          'shape-rendering' => 'auto',
1857          'stop-color' => 'black',
1858          'stop-opacity' => 1,
1859          'stroke' => 'none',
1860          'stroke-dasharray' => 'none',
1861          'stroke-dashoffset' => 0,
1862          'stroke-linecap' => 'butt',
1863          'stroke-linejoin' => 'miter',
1864          'stroke-miterlimit' => 4,
1865          'stroke-opacity' => 1,
1866          'stroke-width' => 1,
1867          'text-anchor' => 'start',
1868          'text-decoration' => 'none',
1869          'text-rendering' => 'auto',
1870          'unicode-bidi' => 'normal',
1871          'visibility' => 'visible',
1872          'word-spacing' => 'normal',
1873          'writing-mode' => 'lr-tb',
1874          'text-color' => 'black',
1875          'transfmatrix' => array(1, 0, 0, 1, 0, 0)
1876          ));
1877  
1878      /**
1879       * If true force sRGB color profile for all document.
1880       * @protected
1881       * @since 5.9.121 (2011-09-28)
1882       */
1883      protected $force_srgb = false;
1884  
1885      /**
1886       * If true set the document to PDF/A mode.
1887       * @protected
1888       * @since 5.9.121 (2011-09-27)
1889       */
1890      protected $pdfa_mode = false;
1891  
1892      /**
1893       * Document creation date-time
1894       * @protected
1895       * @since 5.9.152 (2012-03-22)
1896       */
1897      protected $doc_creation_timestamp;
1898  
1899      /**
1900       * Document modification date-time
1901       * @protected
1902       * @since 5.9.152 (2012-03-22)
1903       */
1904      protected $doc_modification_timestamp;
1905  
1906      /**
1907       * Custom XMP data.
1908       * @protected
1909       * @since 5.9.128 (2011-10-06)
1910       */
1911      protected $custom_xmp = '';
1912  
1913      /**
1914       * Overprint mode array.
1915       * (Check the "Entries in a Graphics State Parameter Dictionary" on PDF 32000-1:2008).
1916       * @protected
1917       * @since 5.9.152 (2012-03-23)
1918       */
1919      protected $overprint = array('OP' => false, 'op' => false, 'OPM' => 0);
1920  
1921      /**
1922       * Alpha mode array.
1923       * (Check the "Entries in a Graphics State Parameter Dictionary" on PDF 32000-1:2008).
1924       * @protected
1925       * @since 5.9.152 (2012-03-23)
1926       */
1927      protected $alpha = array('CA' => 1, 'ca' => 1, 'BM' => '/Normal', 'AIS' => false);
1928  
1929      /**
1930       * Define the page boundaries boxes to be set on document.
1931       * @protected
1932       * @since 5.9.152 (2012-03-23)
1933       */
1934      protected $page_boxes = array('MediaBox', 'CropBox', 'BleedBox', 'TrimBox', 'ArtBox');
1935  
1936      /**
1937       * Set the document producer metadata.
1938       * @protected
1939       * @since 5.9.152 (2012-03-23)
1940       */
1941      protected $pdfproducer;
1942  
1943      /**
1944       * If true print TCPDF meta link.
1945       * @protected
1946       * @since 5.9.152 (2012-03-23)
1947       */
1948      protected $tcpdflink = true;
1949  
1950      /**
1951       * Cache array for computed GD gamma values.
1952       * @protected
1953       * @since 5.9.1632 (2012-06-05)
1954       */
1955      protected $gdgammacache = array();
1956  
1957      //------------------------------------------------------------
1958      // METHODS
1959      //------------------------------------------------------------
1960  
1961      /**
1962       * This is the class constructor.
1963       * It allows to set up the page format, the orientation and the measure unit used in all the methods (except for the font sizes).
1964       * @param $orientation (string) page orientation. Possible values are (case insensitive):<ul><li>P or Portrait (default)</li><li>L or Landscape</li><li>'' (empty string) for automatic orientation</li></ul>
1965       * @param $unit (string) User measure unit. Possible values are:<ul><li>pt: point</li><li>mm: millimeter (default)</li><li>cm: centimeter</li><li>in: inch</li></ul><br />A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.
1966       * @param $format (mixed) The format used for pages. It can be either: one of the string values specified at getPageSizeFromFormat() or an array of parameters specified at setPageFormat().
1967       * @param $unicode (boolean) TRUE means that the input text is unicode (default = true)
1968       * @param $encoding (string) Charset encoding; default is UTF-8.
1969       * @param $diskcache (boolean) If TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower).
1970       * @param $pdfa (boolean) If TRUE set the document to PDF/A mode.
1971       * @public
1972       * @see getPageSizeFromFormat(), setPageFormat()
1973       */
1974  	public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false) {
1975          /* Set internal character encoding to ASCII */
1976          if (function_exists('mb_internal_encoding') AND mb_internal_encoding()) {
1977              $this->internal_encoding = mb_internal_encoding();
1978              mb_internal_encoding('ASCII');
1979          }
1980          // get array of HTML colors
1981          require(dirname(__FILE__).'/htmlcolors.php');
1982          $this->webcolor = $webcolor;
1983          // get array of custom spot colors
1984          if (file_exists(dirname(__FILE__).'/spotcolors.php')) {
1985              require(dirname(__FILE__).'/spotcolors.php');
1986              $this->spotcolor = $spotcolor;
1987          } else {
1988              $this->spotcolor = array();
1989          }
1990          require_once(dirname(__FILE__).'/unicode_data.php');
1991          $this->unicode = new TCPDF_UNICODE_DATA();
1992          require_once(dirname(__FILE__).'/encodings_maps.php');
1993          $this->encmaps = new TCPDF_ENCODING_MAPS();
1994          $this->font_obj_ids = array();
1995          $this->page_obj_id = array();
1996          $this->form_obj_id = array();
1997          // set pdf/a mode
1998          $this->pdfa_mode = $pdfa;
1999          $this->force_srgb = false;
2000          // set disk caching
2001          $this->diskcache = $diskcache ? true : false;
2002          // set language direction
2003          $this->rtl = false;
2004          $this->tmprtl = false;
2005          // some checks
2006          $this->_dochecks();
2007          // initialization of properties
2008          $this->isunicode = $unicode;
2009          $this->page = 0;
2010          $this->transfmrk[0] = array();
2011          $this->pagedim = array();
2012          $this->n = 2;
2013          $this->buffer = '';
2014          $this->pages = array();
2015          $this->state = 0;
2016          $this->fonts = array();
2017          $this->FontFiles = array();
2018          $this->diffs = array();
2019          $this->images = array();
2020          $this->links = array();
2021          $this->gradients = array();
2022          $this->InFooter = false;
2023          $this->lasth = 0;
2024          $this->FontFamily = defined('PDF_FONT_NAME_MAIN')?PDF_FONT_NAME_MAIN:'helvetica';
2025          $this->FontStyle = '';
2026          $this->FontSizePt = 12;
2027          $this->underline = false;
2028          $this->overline = false;
2029          $this->linethrough = false;
2030          $this->DrawColor = '0 G';
2031          $this->FillColor = '0 g';
2032          $this->TextColor = '0 g';
2033          $this->ColorFlag = false;
2034          $this->pdflayers = array();
2035          // encryption values
2036          $this->encrypted = false;
2037          $this->last_enc_key = '';
2038          // standard Unicode fonts
2039          $this->CoreFonts = array(
2040              'courier'=>'Courier',
2041              'courierB'=>'Courier-Bold',
2042              'courierI'=>'Courier-Oblique',
2043              'courierBI'=>'Courier-BoldOblique',
2044              'helvetica'=>'Helvetica',
2045              'helveticaB'=>'Helvetica-Bold',
2046              'helveticaI'=>'Helvetica-Oblique',
2047              'helveticaBI'=>'Helvetica-BoldOblique',
2048              'times'=>'Times-Roman',
2049              'timesB'=>'Times-Bold',
2050              'timesI'=>'Times-Italic',
2051              'timesBI'=>'Times-BoldItalic',
2052              'symbol'=>'Symbol',
2053              'zapfdingbats'=>'ZapfDingbats'
2054          );
2055          // set scale factor
2056          $this->setPageUnit($unit);
2057          // set page format and orientation
2058          $this->setPageFormat($format, $orientation);
2059          // page margins (1 cm)
2060          $margin = 28.35 / $this->k;
2061          $this->SetMargins($margin, $margin);
2062          $this->clMargin = $this->lMargin;
2063          $this->crMargin = $this->rMargin;
2064          // internal cell padding
2065          $cpadding = $margin / 10;
2066          $this->setCellPaddings($cpadding, 0, $cpadding, 0);
2067          // cell margins
2068          $this->setCellMargins(0, 0, 0, 0);
2069          // line width (0.2 mm)
2070          $this->LineWidth = 0.57 / $this->k;
2071          $this->linestyleWidth = sprintf('%F w', ($this->LineWidth * $this->k));
2072          $this->linestyleCap = '0 J';
2073          $this->linestyleJoin = '0 j';
2074          $this->linestyleDash = '[] 0 d';
2075          // automatic page break
2076          $this->SetAutoPageBreak(true, (2 * $margin));
2077          // full width display mode
2078          $this->SetDisplayMode('fullwidth');
2079          // compression
2080          $this->SetCompression();
2081          // set default PDF version number
2082          $this->setPDFVersion();
2083          $this->pdfproducer = "\x54\x43\x50\x44\x46\x20".$this->tcpdf_version."\x20\x28\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67\x29";
2084          $this->tcpdflink = true;
2085          $this->encoding = $encoding;
2086          $this->HREF = array();
2087          $this->getFontsList();
2088          $this->fgcolor = array('R' => 0, 'G' => 0, 'B' => 0);
2089          $this->strokecolor = array('R' => 0, 'G' => 0, 'B' => 0);
2090          $this->bgcolor = array('R' => 255, 'G' => 255, 'B' => 255);
2091          $this->extgstates = array();
2092          $this->setTextShadow();
2093          // user's rights
2094          $this->sign = false;
2095          $this->ur['enabled'] = false;
2096          $this->ur['document'] = '/FullSave';
2097          $this->ur['annots'] = '/Create/Delete/Modify/Copy/Import/Export';
2098          $this->ur['form'] = '/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate';
2099          $this->ur['signature'] = '/Modify';
2100          $this->ur['ef'] = '/Create/Delete/Modify/Import';
2101          $this->ur['formex'] = '';
2102          $this->signature_appearance = array('page' => 1, 'rect' => '0 0 0 0');
2103          $this->empty_signature_appearance = array();
2104          // set default JPEG quality
2105          $this->jpeg_quality = 75;
2106          // initialize some settings
2107          $this->utf8Bidi(array(''), '');
2108          // set default font
2109          $this->SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
2110          // check if PCRE Unicode support is enabled
2111          if ($this->isunicode AND (@preg_match('/\pL/u', 'a') == 1)) {
2112              // PCRE unicode support is turned ON
2113              // \p{Z} or \p{Separator}: any kind of Unicode whitespace or invisible separator.
2114              // \p{Lo} or \p{Other_Letter}: a Unicode letter or ideograph that does not have lowercase and uppercase variants.
2115              // \p{Lo} is needed because Chinese characters are packed next to each other without spaces in between.
2116              //$this->setSpacesRE('/[^\S\P{Z}\P{Lo}\xa0]/u');
2117              $this->setSpacesRE('/[^\S\P{Z}\xa0]/u');
2118          } else {
2119              // PCRE unicode support is turned OFF
2120              $this->setSpacesRE('/[^\S\xa0]/');
2121          }
2122          $this->default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
2123          // set file ID for trailer
2124          $serformat = (is_array($format) ? serialize($format) : $format);
2125          $this->file_id = md5($this->getRandomSeed('TCPDF'.$orientation.$unit.$serformat.$encoding));
2126          // set document creation and modification timestamp
2127          $this->doc_creation_timestamp = time();
2128          $this->doc_modification_timestamp = $this->doc_creation_timestamp;
2129          // get default graphic vars
2130          $this->default_graphic_vars = $this->getGraphicVars();
2131          $this->header_xobj_autoreset = false;
2132          $this->custom_xmp = '';
2133      }
2134  
2135      /**
2136       * Default destructor.
2137       * @public
2138       * @since 1.53.0.TC016
2139       */
2140  	public function __destruct() {
2141          // restore internal encoding
2142          if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
2143              mb_internal_encoding($this->internal_encoding);
2144          }
2145          // unset all class variables
2146          $this->_destroy(true);
2147      }
2148  
2149      /**
2150       * Return the current TCPDF version.
2151       * @return TCPDF version string
2152       * @public
2153       * @since 5.9.012 (2010-11-10)
2154       */
2155  	public function getTCPDFVersion() {
2156          return $this->tcpdf_version;
2157      }
2158  
2159      /**
2160       * Set the units of measure for the document.
2161       * @param $unit (string) User measure unit. Possible values are:<ul><li>pt: point</li><li>mm: millimeter (default)</li><li>cm: centimeter</li><li>in: inch</li></ul><br />A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.
2162       * @public
2163       * @since 3.0.015 (2008-06-06)
2164       */
2165  	public function setPageUnit($unit) {
2166          $unit = strtolower($unit);
2167          //Set scale factor
2168          switch ($unit) {
2169              // points
2170              case 'px':
2171              case 'pt': {
2172                  $this->k = 1;
2173                  break;
2174              }
2175              // millimeters
2176              case 'mm': {
2177                  $this->k = $this->dpi / 25.4;
2178                  break;
2179              }
2180              // centimeters
2181              case 'cm': {
2182                  $this->k = $this->dpi / 2.54;
2183                  break;
2184              }
2185              // inches
2186              case 'in': {
2187                  $this->k = $this->dpi;
2188                  break;
2189              }
2190              // unsupported unit
2191              default : {
2192                  $this->Error('Incorrect unit: '.$unit);
2193                  break;
2194              }
2195          }
2196          $this->pdfunit = $unit;
2197          if (isset($this->CurOrientation)) {
2198              $this->setPageOrientation($this->CurOrientation);
2199          }
2200      }
2201  
2202      /**
2203       * Get page dimensions from format name.
2204       * @param $format (mixed) The format name. It can be: <ul>
2205       * <li><b>ISO 216 A Series + 2 SIS 014711 extensions</b></li>
2206       * <li>A0 (841x1189 mm ; 33.11x46.81 in)</li>
2207       * <li>A1 (594x841 mm ; 23.39x33.11 in)</li>
2208       * <li>A2 (420x594 mm ; 16.54x23.39 in)</li>
2209       * <li>A3 (297x420 mm ; 11.69x16.54 in)</li>
2210       * <li>A4 (210x297 mm ; 8.27x11.69 in)</li>
2211       * <li>A5 (148x210 mm ; 5.83x8.27 in)</li>
2212       * <li>A6 (105x148 mm ; 4.13x5.83 in)</li>
2213       * <li>A7 (74x105 mm ; 2.91x4.13 in)</li>
2214       * <li>A8 (52x74 mm ; 2.05x2.91 in)</li>
2215       * <li>A9 (37x52 mm ; 1.46x2.05 in)</li>
2216       * <li>A10 (26x37 mm ; 1.02x1.46 in)</li>
2217       * <li>A11 (18x26 mm ; 0.71x1.02 in)</li>
2218       * <li>A12 (13x18 mm ; 0.51x0.71 in)</li>
2219       * <li><b>ISO 216 B Series + 2 SIS 014711 extensions</b></li>
2220       * <li>B0 (1000x1414 mm ; 39.37x55.67 in)</li>
2221       * <li>B1 (707x1000 mm ; 27.83x39.37 in)</li>
2222       * <li>B2 (500x707 mm ; 19.69x27.83 in)</li>
2223       * <li>B3 (353x500 mm ; 13.90x19.69 in)</li>
2224       * <li>B4 (250x353 mm ; 9.84x13.90 in)</li>
2225       * <li>B5 (176x250 mm ; 6.93x9.84 in)</li>
2226       * <li>B6 (125x176 mm ; 4.92x6.93 in)</li>
2227       * <li>B7 (88x125 mm ; 3.46x4.92 in)</li>
2228       * <li>B8 (62x88 mm ; 2.44x3.46 in)</li>
2229       * <li>B9 (44x62 mm ; 1.73x2.44 in)</li>
2230       * <li>B10 (31x44 mm ; 1.22x1.73 in)</li>
2231       * <li>B11 (22x31 mm ; 0.87x1.22 in)</li>
2232       * <li>B12 (15x22 mm ; 0.59x0.87 in)</li>
2233       * <li><b>ISO 216 C Series + 2 SIS 014711 extensions + 2 EXTENSION</b></li>
2234       * <li>C0 (917x1297 mm ; 36.10x51.06 in)</li>
2235       * <li>C1 (648x917 mm ; 25.51x36.10 in)</li>
2236       * <li>C2 (458x648 mm ; 18.03x25.51 in)</li>
2237       * <li>C3 (324x458 mm ; 12.76x18.03 in)</li>
2238       * <li>C4 (229x324 mm ; 9.02x12.76 in)</li>
2239       * <li>C5 (162x229 mm ; 6.38x9.02 in)</li>
2240       * <li>C6 (114x162 mm ; 4.49x6.38 in)</li>
2241       * <li>C7 (81x114 mm ; 3.19x4.49 in)</li>
2242       * <li>C8 (57x81 mm ; 2.24x3.19 in)</li>
2243       * <li>C9 (40x57 mm ; 1.57x2.24 in)</li>
2244       * <li>C10 (28x40 mm ; 1.10x1.57 in)</li>
2245       * <li>C11 (20x28 mm ; 0.79x1.10 in)</li>
2246       * <li>C12 (14x20 mm ; 0.55x0.79 in)</li>
2247       * <li>C76 (81x162 mm ; 3.19x6.38 in)</li>
2248       * <li>DL (110x220 mm ; 4.33x8.66 in)</li>
2249       * <li><b>SIS 014711 E Series</b></li>
2250       * <li>E0 (879x1241 mm ; 34.61x48.86 in)</li>
2251       * <li>E1 (620x879 mm ; 24.41x34.61 in)</li>
2252       * <li>E2 (440x620 mm ; 17.32x24.41 in)</li>
2253       * <li>E3 (310x440 mm ; 12.20x17.32 in)</li>
2254       * <li>E4 (220x310 mm ; 8.66x12.20 in)</li>
2255       * <li>E5 (155x220 mm ; 6.10x8.66 in)</li>
2256       * <li>E6 (110x155 mm ; 4.33x6.10 in)</li>
2257       * <li>E7 (78x110 mm ; 3.07x4.33 in)</li>
2258       * <li>E8 (55x78 mm ; 2.17x3.07 in)</li>
2259       * <li>E9 (39x55 mm ; 1.54x2.17 in)</li>
2260       * <li>E10 (27x39 mm ; 1.06x1.54 in)</li>
2261       * <li>E11 (19x27 mm ; 0.75x1.06 in)</li>
2262       * <li>E12 (13x19 mm ; 0.51x0.75 in)</li>
2263       * <li><b>SIS 014711 G Series</b></li>
2264       * <li>G0 (958x1354 mm ; 37.72x53.31 in)</li>
2265       * <li>G1 (677x958 mm ; 26.65x37.72 in)</li>
2266       * <li>G2 (479x677 mm ; 18.86x26.65 in)</li>
2267       * <li>G3 (338x479 mm ; 13.31x18.86 in)</li>
2268       * <li>G4 (239x338 mm ; 9.41x13.31 in)</li>
2269       * <li>G5 (169x239 mm ; 6.65x9.41 in)</li>
2270       * <li>G6 (119x169 mm ; 4.69x6.65 in)</li>
2271       * <li>G7 (84x119 mm ; 3.31x4.69 in)</li>
2272       * <li>G8 (59x84 mm ; 2.32x3.31 in)</li>
2273       * <li>G9 (42x59 mm ; 1.65x2.32 in)</li>
2274       * <li>G10 (29x42 mm ; 1.14x1.65 in)</li>
2275       * <li>G11 (21x29 mm ; 0.83x1.14 in)</li>
2276       * <li>G12 (14x21 mm ; 0.55x0.83 in)</li>
2277       * <li><b>ISO Press</b></li>
2278       * <li>RA0 (860x1220 mm ; 33.86x48.03 in)</li>
2279       * <li>RA1 (610x860 mm ; 24.02x33.86 in)</li>
2280       * <li>RA2 (430x610 mm ; 16.93x24.02 in)</li>
2281       * <li>RA3 (305x430 mm ; 12.01x16.93 in)</li>
2282       * <li>RA4 (215x305 mm ; 8.46x12.01 in)</li>
2283       * <li>SRA0 (900x1280 mm ; 35.43x50.39 in)</li>
2284       * <li>SRA1 (640x900 mm ; 25.20x35.43 in)</li>
2285       * <li>SRA2 (450x640 mm ; 17.72x25.20 in)</li>
2286       * <li>SRA3 (320x450 mm ; 12.60x17.72 in)</li>
2287       * <li>SRA4 (225x320 mm ; 8.86x12.60 in)</li>
2288       * <li><b>German DIN 476</b></li>
2289       * <li>4A0 (1682x2378 mm ; 66.22x93.62 in)</li>
2290       * <li>2A0 (1189x1682 mm ; 46.81x66.22 in)</li>
2291       * <li><b>Variations on the ISO Standard</b></li>
2292       * <li>A2_EXTRA (445x619 mm ; 17.52x24.37 in)</li>
2293       * <li>A3+ (329x483 mm ; 12.95x19.02 in)</li>
2294       * <li>A3_EXTRA (322x445 mm ; 12.68x17.52 in)</li>
2295       * <li>A3_SUPER (305x508 mm ; 12.01x20.00 in)</li>
2296       * <li>SUPER_A3 (305x487 mm ; 12.01x19.17 in)</li>
2297       * <li>A4_EXTRA (235x322 mm ; 9.25x12.68 in)</li>
2298       * <li>A4_SUPER (229x322 mm ; 9.02x12.68 in)</li>
2299       * <li>SUPER_A4 (227x356 mm ; 8.94x14.02 in)</li>
2300       * <li>A4_LONG (210x348 mm ; 8.27x13.70 in)</li>
2301       * <li>F4 (210x330 mm ; 8.27x12.99 in)</li>
2302       * <li>SO_B5_EXTRA (202x276 mm ; 7.95x10.87 in)</li>
2303       * <li>A5_EXTRA (173x235 mm ; 6.81x9.25 in)</li>
2304       * <li><b>ANSI Series</b></li>
2305       * <li>ANSI_E (864x1118 mm ; 34.00x44.00 in)</li>
2306       * <li>ANSI_D (559x864 mm ; 22.00x34.00 in)</li>
2307       * <li>ANSI_C (432x559 mm ; 17.00x22.00 in)</li>
2308       * <li>ANSI_B (279x432 mm ; 11.00x17.00 in)</li>
2309       * <li>ANSI_A (216x279 mm ; 8.50x11.00 in)</li>
2310       * <li><b>Traditional 'Loose' North American Paper Sizes</b></li>
2311       * <li>LEDGER, USLEDGER (432x279 mm ; 17.00x11.00 in)</li>
2312       * <li>TABLOID, USTABLOID, BIBLE, ORGANIZERK (279x432 mm ; 11.00x17.00 in)</li>
2313       * <li>LETTER, USLETTER, ORGANIZERM (216x279 mm ; 8.50x11.00 in)</li>
2314       * <li>LEGAL, USLEGAL (216x356 mm ; 8.50x14.00 in)</li>
2315       * <li>GLETTER, GOVERNMENTLETTER (203x267 mm ; 8.00x10.50 in)</li>
2316       * <li>JLEGAL, JUNIORLEGAL (203x127 mm ; 8.00x5.00 in)</li>
2317       * <li><b>Other North American Paper Sizes</b></li>
2318       * <li>QUADDEMY (889x1143 mm ; 35.00x45.00 in)</li>
2319       * <li>SUPER_B (330x483 mm ; 13.00x19.00 in)</li>
2320       * <li>QUARTO (229x279 mm ; 9.00x11.00 in)</li>
2321       * <li>FOLIO, GOVERNMENTLEGAL (216x330 mm ; 8.50x13.00 in)</li>
2322       * <li>EXECUTIVE, MONARCH (184x267 mm ; 7.25x10.50 in)</li>
2323       * <li>MEMO, STATEMENT, ORGANIZERL (140x216 mm ; 5.50x8.50 in)</li>
2324       * <li>FOOLSCAP (210x330 mm ; 8.27x13.00 in)</li>
2325       * <li>COMPACT (108x171 mm ; 4.25x6.75 in)</li>
2326       * <li>ORGANIZERJ (70x127 mm ; 2.75x5.00 in)</li>
2327       * <li><b>Canadian standard CAN 2-9.60M</b></li>
2328       * <li>P1 (560x860 mm ; 22.05x33.86 in)</li>
2329       * <li>P2 (430x560 mm ; 16.93x22.05 in)</li>
2330       * <li>P3 (280x430 mm ; 11.02x16.93 in)</li>
2331       * <li>P4 (215x280 mm ; 8.46x11.02 in)</li>
2332       * <li>P5 (140x215 mm ; 5.51x8.46 in)</li>
2333       * <li>P6 (107x140 mm ; 4.21x5.51 in)</li>
2334       * <li><b>North American Architectural Sizes</b></li>
2335       * <li>ARCH_E (914x1219 mm ; 36.00x48.00 in)</li>
2336       * <li>ARCH_E1 (762x1067 mm ; 30.00x42.00 in)</li>
2337       * <li>ARCH_D (610x914 mm ; 24.00x36.00 in)</li>
2338       * <li>ARCH_C, BROADSHEET (457x610 mm ; 18.00x24.00 in)</li>
2339       * <li>ARCH_B (305x457 mm ; 12.00x18.00 in)</li>
2340       * <li>ARCH_A (229x305 mm ; 9.00x12.00 in)</li>
2341       * <li><b>Announcement Envelopes</b></li>
2342       * <li>ANNENV_A2 (111x146 mm ; 4.37x5.75 in)</li>
2343       * <li>ANNENV_A6 (121x165 mm ; 4.75x6.50 in)</li>
2344       * <li>ANNENV_A7 (133x184 mm ; 5.25x7.25 in)</li>
2345       * <li>ANNENV_A8 (140x206 mm ; 5.50x8.12 in)</li>
2346       * <li>ANNENV_A10 (159x244 mm ; 6.25x9.62 in)</li>
2347       * <li>ANNENV_SLIM (98x225 mm ; 3.87x8.87 in)</li>
2348       * <li><b>Commercial Envelopes</b></li>
2349       * <li>COMMENV_N6_1/4 (89x152 mm ; 3.50x6.00 in)</li>
2350       * <li>COMMENV_N6_3/4 (92x165 mm ; 3.62x6.50 in)</li>
2351       * <li>COMMENV_N8 (98x191 mm ; 3.87x7.50 in)</li>
2352       * <li>COMMENV_N9 (98x225 mm ; 3.87x8.87 in)</li>
2353       * <li>COMMENV_N10 (105x241 mm ; 4.12x9.50 in)</li>
2354       * <li>COMMENV_N11 (114x263 mm ; 4.50x10.37 in)</li>
2355       * <li>COMMENV_N12 (121x279 mm ; 4.75x11.00 in)</li>
2356       * <li>COMMENV_N14 (127x292 mm ; 5.00x11.50 in)</li>
2357       * <li><b>Catalogue Envelopes</b></li>
2358       * <li>CATENV_N1 (152x229 mm ; 6.00x9.00 in)</li>
2359       * <li>CATENV_N1_3/4 (165x241 mm ; 6.50x9.50 in)</li>
2360       * <li>CATENV_N2 (165x254 mm ; 6.50x10.00 in)</li>
2361       * <li>CATENV_N3 (178x254 mm ; 7.00x10.00 in)</li>
2362       * <li>CATENV_N6 (191x267 mm ; 7.50x10.50 in)</li>
2363       * <li>CATENV_N7 (203x279 mm ; 8.00x11.00 in)</li>
2364       * <li>CATENV_N8 (210x286 mm ; 8.25x11.25 in)</li>
2365       * <li>CATENV_N9_1/2 (216x267 mm ; 8.50x10.50 in)</li>
2366       * <li>CATENV_N9_3/4 (222x286 mm ; 8.75x11.25 in)</li>
2367       * <li>CATENV_N10_1/2 (229x305 mm ; 9.00x12.00 in)</li>
2368       * <li>CATENV_N12_1/2 (241x318 mm ; 9.50x12.50 in)</li>
2369       * <li>CATENV_N13_1/2 (254x330 mm ; 10.00x13.00 in)</li>
2370       * <li>CATENV_N14_1/4 (286x311 mm ; 11.25x12.25 in)</li>
2371       * <li>CATENV_N14_1/2 (292x368 mm ; 11.50x14.50 in)</li>
2372       * <li><b>Japanese (JIS P 0138-61) Standard B-Series</b></li>
2373       * <li>JIS_B0 (1030x1456 mm ; 40.55x57.32 in)</li>
2374       * <li>JIS_B1 (728x1030 mm ; 28.66x40.55 in)</li>
2375       * <li>JIS_B2 (515x728 mm ; 20.28x28.66 in)</li>
2376       * <li>JIS_B3 (364x515 mm ; 14.33x20.28 in)</li>
2377       * <li>JIS_B4 (257x364 mm ; 10.12x14.33 in)</li>
2378       * <li>JIS_B5 (182x257 mm ; 7.17x10.12 in)</li>
2379       * <li>JIS_B6 (128x182 mm ; 5.04x7.17 in)</li>
2380       * <li>JIS_B7 (91x128 mm ; 3.58x5.04 in)</li>
2381       * <li>JIS_B8 (64x91 mm ; 2.52x3.58 in)</li>
2382       * <li>JIS_B9 (45x64 mm ; 1.77x2.52 in)</li>
2383       * <li>JIS_B10 (32x45 mm ; 1.26x1.77 in)</li>
2384       * <li>JIS_B11 (22x32 mm ; 0.87x1.26 in)</li>
2385       * <li>JIS_B12 (16x22 mm ; 0.63x0.87 in)</li>
2386       * <li><b>PA Series</b></li>
2387       * <li>PA0 (840x1120 mm ; 33.07x44.09 in)</li>
2388       * <li>PA1 (560x840 mm ; 22.05x33.07 in)</li>
2389       * <li>PA2 (420x560 mm ; 16.54x22.05 in)</li>
2390       * <li>PA3 (280x420 mm ; 11.02x16.54 in)</li>
2391       * <li>PA4 (210x280 mm ; 8.27x11.02 in)</li>
2392       * <li>PA5 (140x210 mm ; 5.51x8.27 in)</li>
2393       * <li>PA6 (105x140 mm ; 4.13x5.51 in)</li>
2394       * <li>PA7 (70x105 mm ; 2.76x4.13 in)</li>
2395       * <li>PA8 (52x70 mm ; 2.05x2.76 in)</li>
2396       * <li>PA9 (35x52 mm ; 1.38x2.05 in)</li>
2397       * <li>PA10 (26x35 mm ; 1.02x1.38 in)</li>
2398       * <li><b>Standard Photographic Print Sizes</b></li>
2399       * <li>PASSPORT_PHOTO (35x45 mm ; 1.38x1.77 in)</li>
2400       * <li>E (82x120 mm ; 3.25x4.72 in)</li>
2401       * <li>3R, L (89x127 mm ; 3.50x5.00 in)</li>
2402       * <li>4R, KG (102x152 mm ; 4.02x5.98 in)</li>
2403       * <li>4D (120x152 mm ; 4.72x5.98 in)</li>
2404       * <li>5R, 2L (127x178 mm ; 5.00x7.01 in)</li>
2405       * <li>6R, 8P (152x203 mm ; 5.98x7.99 in)</li>
2406       * <li>8R, 6P (203x254 mm ; 7.99x10.00 in)</li>
2407       * <li>S8R, 6PW (203x305 mm ; 7.99x12.01 in)</li>
2408       * <li>10R, 4P (254x305 mm ; 10.00x12.01 in)</li>
2409       * <li>S10R, 4PW (254x381 mm ; 10.00x15.00 in)</li>
2410       * <li>11R (279x356 mm ; 10.98x14.02 in)</li>
2411       * <li>S11R (279x432 mm ; 10.98x17.01 in)</li>
2412       * <li>12R (305x381 mm ; 12.01x15.00 in)</li>
2413       * <li>S12R (305x456 mm ; 12.01x17.95 in)</li>
2414       * <li><b>Common Newspaper Sizes</b></li>
2415       * <li>NEWSPAPER_BROADSHEET (750x600 mm ; 29.53x23.62 in)</li>
2416       * <li>NEWSPAPER_BERLINER (470x315 mm ; 18.50x12.40 in)</li>
2417       * <li>NEWSPAPER_COMPACT, NEWSPAPER_TABLOID (430x280 mm ; 16.93x11.02 in)</li>
2418       * <li><b>Business Cards</b></li>
2419       * <li>CREDIT_CARD, BUSINESS_CARD, BUSINESS_CARD_ISO7810 (54x86 mm ; 2.13x3.37 in)</li>
2420       * <li>BUSINESS_CARD_ISO216 (52x74 mm ; 2.05x2.91 in)</li>
2421       * <li>BUSINESS_CARD_IT, BUSINESS_CARD_UK, BUSINESS_CARD_FR, BUSINESS_CARD_DE, BUSINESS_CARD_ES (55x85 mm ; 2.17x3.35 in)</li>
2422       * <li>BUSINESS_CARD_US, BUSINESS_CARD_CA (51x89 mm ; 2.01x3.50 in)</li>
2423       * <li>BUSINESS_CARD_JP (55x91 mm ; 2.17x3.58 in)</li>
2424       * <li>BUSINESS_CARD_HK (54x90 mm ; 2.13x3.54 in)</li>
2425       * <li>BUSINESS_CARD_AU, BUSINESS_CARD_DK, BUSINESS_CARD_SE (55x90 mm ; 2.17x3.54 in)</li>
2426       * <li>BUSINESS_CARD_RU, BUSINESS_CARD_CZ, BUSINESS_CARD_FI, BUSINESS_CARD_HU, BUSINESS_CARD_IL (50x90 mm ; 1.97x3.54 in)</li>
2427       * <li><b>Billboards</b></li>
2428       * <li>4SHEET (1016x1524 mm ; 40.00x60.00 in)</li>
2429       * <li>6SHEET (1200x1800 mm ; 47.24x70.87 in)</li>
2430       * <li>12SHEET (3048x1524 mm ; 120.00x60.00 in)</li>
2431       * <li>16SHEET (2032x3048 mm ; 80.00x120.00 in)</li>
2432       * <li>32SHEET (4064x3048 mm ; 160.00x120.00 in)</li>
2433       * <li>48SHEET (6096x3048 mm ; 240.00x120.00 in)</li>
2434       * <li>64SHEET (8128x3048 mm ; 320.00x120.00 in)</li>
2435       * <li>96SHEET (12192x3048 mm ; 480.00x120.00 in)</li>
2436       * <li><b>Old Imperial English (some are still used in USA)</b></li>
2437       * <li>EN_EMPEROR (1219x1829 mm ; 48.00x72.00 in)</li>
2438       * <li>EN_ANTIQUARIAN (787x1346 mm ; 31.00x53.00 in)</li>
2439       * <li>EN_GRAND_EAGLE (730x1067 mm ; 28.75x42.00 in)</li>
2440       * <li>EN_DOUBLE_ELEPHANT (679x1016 mm ; 26.75x40.00 in)</li>
2441       * <li>EN_ATLAS (660x864 mm ; 26.00x34.00 in)</li>
2442       * <li>EN_COLOMBIER (597x876 mm ; 23.50x34.50 in)</li>
2443       * <li>EN_ELEPHANT (584x711 mm ; 23.00x28.00 in)</li>
2444       * <li>EN_DOUBLE_DEMY (572x902 mm ; 22.50x35.50 in)</li>
2445       * <li>EN_IMPERIAL (559x762 mm ; 22.00x30.00 in)</li>
2446       * <li>EN_PRINCESS (546x711 mm ; 21.50x28.00 in)</li>
2447       * <li>EN_CARTRIDGE (533x660 mm ; 21.00x26.00 in)</li>
2448       * <li>EN_DOUBLE_LARGE_POST (533x838 mm ; 21.00x33.00 in)</li>
2449       * <li>EN_ROYAL (508x635 mm ; 20.00x25.00 in)</li>
2450       * <li>EN_SHEET, EN_HALF_POST (495x597 mm ; 19.50x23.50 in)</li>
2451       * <li>EN_SUPER_ROYAL (483x686 mm ; 19.00x27.00 in)</li>
2452       * <li>EN_DOUBLE_POST (483x775 mm ; 19.00x30.50 in)</li>
2453       * <li>EN_MEDIUM (445x584 mm ; 17.50x23.00 in)</li>
2454       * <li>EN_DEMY (445x572 mm ; 17.50x22.50 in)</li>
2455       * <li>EN_LARGE_POST (419x533 mm ; 16.50x21.00 in)</li>
2456       * <li>EN_COPY_DRAUGHT (406x508 mm ; 16.00x20.00 in)</li>
2457       * <li>EN_POST (394x489 mm ; 15.50x19.25 in)</li>
2458       * <li>EN_CROWN (381x508 mm ; 15.00x20.00 in)</li>
2459       * <li>EN_PINCHED_POST (375x470 mm ; 14.75x18.50 in)</li>
2460       * <li>EN_BRIEF (343x406 mm ; 13.50x16.00 in)</li>
2461       * <li>EN_FOOLSCAP (343x432 mm ; 13.50x17.00 in)</li>
2462       * <li>EN_SMALL_FOOLSCAP (337x419 mm ; 13.25x16.50 in)</li>
2463       * <li>EN_POTT (318x381 mm ; 12.50x15.00 in)</li>
2464       * <li><b>Old Imperial Belgian</b></li>
2465       * <li>BE_GRAND_AIGLE (700x1040 mm ; 27.56x40.94 in)</li>
2466       * <li>BE_COLOMBIER (620x850 mm ; 24.41x33.46 in)</li>
2467       * <li>BE_DOUBLE_CARRE (620x920 mm ; 24.41x36.22 in)</li>
2468       * <li>BE_ELEPHANT (616x770 mm ; 24.25x30.31 in)</li>
2469       * <li>BE_PETIT_AIGLE (600x840 mm ; 23.62x33.07 in)</li>
2470       * <li>BE_GRAND_JESUS (550x730 mm ; 21.65x28.74 in)</li>
2471       * <li>BE_JESUS (540x730 mm ; 21.26x28.74 in)</li>
2472       * <li>BE_RAISIN (500x650 mm ; 19.69x25.59 in)</li>
2473       * <li>BE_GRAND_MEDIAN (460x605 mm ; 18.11x23.82 in)</li>
2474       * <li>BE_DOUBLE_POSTE (435x565 mm ; 17.13x22.24 in)</li>
2475       * <li>BE_COQUILLE (430x560 mm ; 16.93x22.05 in)</li>
2476       * <li>BE_PETIT_MEDIAN (415x530 mm ; 16.34x20.87 in)</li>
2477       * <li>BE_RUCHE (360x460 mm ; 14.17x18.11 in)</li>
2478       * <li>BE_PROPATRIA (345x430 mm ; 13.58x16.93 in)</li>
2479       * <li>BE_LYS (317x397 mm ; 12.48x15.63 in)</li>
2480       * <li>BE_POT (307x384 mm ; 12.09x15.12 in)</li>
2481       * <li>BE_ROSETTE (270x347 mm ; 10.63x13.66 in)</li>
2482       * <li><b>Old Imperial French</b></li>
2483       * <li>FR_UNIVERS (1000x1300 mm ; 39.37x51.18 in)</li>
2484       * <li>FR_DOUBLE_COLOMBIER (900x1260 mm ; 35.43x49.61 in)</li>
2485       * <li>FR_GRANDE_MONDE (900x1260 mm ; 35.43x49.61 in)</li>
2486       * <li>FR_DOUBLE_SOLEIL (800x1200 mm ; 31.50x47.24 in)</li>
2487       * <li>FR_DOUBLE_JESUS (760x1120 mm ; 29.92x44.09 in)</li>
2488       * <li>FR_GRAND_AIGLE (750x1060 mm ; 29.53x41.73 in)</li>
2489       * <li>FR_PETIT_AIGLE (700x940 mm ; 27.56x37.01 in)</li>
2490       * <li>FR_DOUBLE_RAISIN (650x1000 mm ; 25.59x39.37 in)</li>
2491       * <li>FR_JOURNAL (650x940 mm ; 25.59x37.01 in)</li>
2492       * <li>FR_COLOMBIER_AFFICHE (630x900 mm ; 24.80x35.43 in)</li>
2493       * <li>FR_DOUBLE_CAVALIER (620x920 mm ; 24.41x36.22 in)</li>
2494       * <li>FR_CLOCHE (600x800 mm ; 23.62x31.50 in)</li>
2495       * <li>FR_SOLEIL (600x800 mm ; 23.62x31.50 in)</li>
2496       * <li>FR_DOUBLE_CARRE (560x900 mm ; 22.05x35.43 in)</li>
2497       * <li>FR_DOUBLE_COQUILLE (560x880 mm ; 22.05x34.65 in)</li>
2498       * <li>FR_JESUS (560x760 mm ; 22.05x29.92 in)</li>
2499       * <li>FR_RAISIN (500x650 mm ; 19.69x25.59 in)</li>
2500       * <li>FR_CAVALIER (460x620 mm ; 18.11x24.41 in)</li>
2501       * <li>FR_DOUBLE_COURONNE (460x720 mm ; 18.11x28.35 in)</li>
2502       * <li>FR_CARRE (450x560 mm ; 17.72x22.05 in)</li>
2503       * <li>FR_COQUILLE (440x560 mm ; 17.32x22.05 in)</li>
2504       * <li>FR_DOUBLE_TELLIERE (440x680 mm ; 17.32x26.77 in)</li>
2505       * <li>FR_DOUBLE_CLOCHE (400x600 mm ; 15.75x23.62 in)</li>
2506       * <li>FR_DOUBLE_POT (400x620 mm ; 15.75x24.41 in)</li>
2507       * <li>FR_ECU (400x520 mm ; 15.75x20.47 in)</li>
2508       * <li>FR_COURONNE (360x460 mm ; 14.17x18.11 in)</li>
2509       * <li>FR_TELLIERE (340x440 mm ; 13.39x17.32 in)</li>
2510       * <li>FR_POT (310x400 mm ; 12.20x15.75 in)</li>
2511       * </ul>
2512       * @return array containing page width and height in points
2513       * @public
2514       * @since 5.0.010 (2010-05-17)
2515       */
2516  	public function getPageSizeFromFormat($format) {
2517          // Paper cordinates are calculated in this way: (inches * 72) where (1 inch = 25.4 mm)
2518          switch (strtoupper($format)) {
2519              // ISO 216 A Series + 2 SIS 014711 extensions
2520              case 'A0' : {$pf = array( 2383.937, 3370.394); break;}
2521              case 'A1' : {$pf = array( 1683.780, 2383.937); break;}
2522              case 'A2' : {$pf = array( 1190.551, 1683.780); break;}
2523              case 'A3' : {$pf = array(  841.890, 1190.551); break;}
2524              case 'A4' : {$pf = array(  595.276,  841.890); break;}
2525              case 'A5' : {$pf = array(  419.528,  595.276); break;}
2526              case 'A6' : {$pf = array(  297.638,  419.528); break;}
2527              case 'A7' : {$pf = array(  209.764,  297.638); break;}
2528              case 'A8' : {$pf = array(  147.402,  209.764); break;}
2529              case 'A9' : {$pf = array(  104.882,  147.402); break;}
2530              case 'A10': {$pf = array(   73.701,  104.882); break;}
2531              case 'A11': {$pf = array(   51.024,   73.701); break;}
2532              case 'A12': {$pf = array(   36.850,   51.024); break;}
2533              // ISO 216 B Series + 2 SIS 014711 extensions
2534              case 'B0' : {$pf = array( 2834.646, 4008.189); break;}
2535              case 'B1' : {$pf = array( 2004.094, 2834.646); break;}
2536              case 'B2' : {$pf = array( 1417.323, 2004.094); break;}
2537              case 'B3' : {$pf = array( 1000.630, 1417.323); break;}
2538              case 'B4' : {$pf = array(  708.661, 1000.630); break;}
2539              case 'B5' : {$pf = array(  498.898,  708.661); break;}
2540              case 'B6' : {$pf = array(  354.331,  498.898); break;}
2541              case 'B7' : {$pf = array(  249.449,  354.331); break;}
2542              case 'B8' : {$pf = array(  175.748,  249.449); break;}
2543              case 'B9' : {$pf = array(  124.724,  175.748); break;}
2544              case 'B10': {$pf = array(   87.874,  124.724); break;}
2545              case 'B11': {$pf = array(   62.362,   87.874); break;}
2546              case 'B12': {$pf = array(   42.520,   62.362); break;}
2547              // ISO 216 C Series + 2 SIS 014711 extensions + 2 EXTENSION
2548              case 'C0' : {$pf = array( 2599.370, 3676.535); break;}
2549              case 'C1' : {$pf = array( 1836.850, 2599.370); break;}
2550              case 'C2' : {$pf = array( 1298.268, 1836.850); break;}
2551              case 'C3' : {$pf = array(  918.425, 1298.268); break;}
2552              case 'C4' : {$pf = array(  649.134,  918.425); break;}
2553              case 'C5' : {$pf = array(  459.213,  649.134); break;}
2554              case 'C6' : {$pf = array(  323.150,  459.213); break;}
2555              case 'C7' : {$pf = array(  229.606,  323.150); break;}
2556              case 'C8' : {$pf = array(  161.575,  229.606); break;}
2557              case 'C9' : {$pf = array(  113.386,  161.575); break;}
2558              case 'C10': {$pf = array(   79.370,  113.386); break;}
2559              case 'C11': {$pf = array(   56.693,   79.370); break;}
2560              case 'C12': {$pf = array(   39.685,   56.693); break;}
2561              case 'C76': {$pf = array(  229.606,  459.213); break;}
2562              case 'DL' : {$pf = array(  311.811,  623.622); break;}
2563              // SIS 014711 E Series
2564              case 'E0' : {$pf = array( 2491.654, 3517.795); break;}
2565              case 'E1' : {$pf = array( 1757.480, 2491.654); break;}
2566              case 'E2' : {$pf = array( 1247.244, 1757.480); break;}
2567              case 'E3' : {$pf = array(  878.740, 1247.244); break;}
2568              case 'E4' : {$pf = array(  623.622,  878.740); break;}
2569              case 'E5' : {$pf = array(  439.370,  623.622); break;}
2570              case 'E6' : {$pf = array(  311.811,  439.370); break;}
2571              case 'E7' : {$pf = array(  221.102,  311.811); break;}
2572              case 'E8' : {$pf = array(  155.906,  221.102); break;}
2573              case 'E9' : {$pf = array(  110.551,  155.906); break;}
2574              case 'E10': {$pf = array(   76.535,  110.551); break;}
2575              case 'E11': {$pf = array(   53.858,   76.535); break;}
2576              case 'E12': {$pf = array(   36.850,   53.858); break;}
2577              // SIS 014711 G Series
2578              case 'G0' : {$pf = array( 2715.591, 3838.110); break;}
2579              case 'G1' : {$pf = array( 1919.055, 2715.591); break;}
2580              case 'G2' : {$pf = array( 1357.795, 1919.055); break;}
2581              case 'G3' : {$pf = array(  958.110, 1357.795); break;}
2582              case 'G4' : {$pf = array(  677.480,  958.110); break;}
2583              case 'G5' : {$pf = array(  479.055,  677.480); break;}
2584              case 'G6' : {$pf = array(  337.323,  479.055); break;}
2585              case 'G7' : {$pf = array(  238.110,  337.323); break;}
2586              case 'G8' : {$pf = array(  167.244,  238.110); break;}
2587              case 'G9' : {$pf = array(  119.055,  167.244); break;}
2588              case 'G10': {$pf = array(   82.205,  119.055); break;}
2589              case 'G11': {$pf = array(   59.528,   82.205); break;}
2590              case 'G12': {$pf = array(   39.685,   59.528); break;}
2591              // ISO Press
2592              case 'RA0': {$pf = array( 2437.795, 3458.268); break;}
2593              case 'RA1': {$pf = array( 1729.134, 2437.795); break;}
2594              case 'RA2': {$pf = array( 1218.898, 1729.134); break;}
2595              case 'RA3': {$pf = array(  864.567, 1218.898); break;}
2596              case 'RA4': {$pf = array(  609.449,  864.567); break;}
2597              case 'SRA0': {$pf = array( 2551.181, 3628.346); break;}
2598              case 'SRA1': {$pf = array( 1814.173, 2551.181); break;}
2599              case 'SRA2': {$pf = array( 1275.591, 1814.173); break;}
2600              case 'SRA3': {$pf = array(  907.087, 1275.591); break;}
2601              case 'SRA4': {$pf = array(  637.795,  907.087); break;}
2602              // German  DIN 476
2603              case '4A0': {$pf = array( 4767.874, 6740.787); break;}
2604              case '2A0': {$pf = array( 3370.394, 4767.874); break;}
2605              // Variations on the ISO Standard
2606              case 'A2_EXTRA'   : {$pf = array( 1261.417, 1754.646); break;}
2607              case 'A3+'        : {$pf = array(  932.598, 1369.134); break;}
2608              case 'A3_EXTRA'   : {$pf = array(  912.756, 1261.417); break;}
2609              case 'A3_SUPER'   : {$pf = array(  864.567, 1440.000); break;}
2610              case 'SUPER_A3'   : {$pf = array(  864.567, 1380.472); break;}
2611              case 'A4_EXTRA'   : {$pf = array(  666.142,  912.756); break;}
2612              case 'A4_SUPER'   : {$pf = array(  649.134,  912.756); break;}
2613              case 'SUPER_A4'   : {$pf = array(  643.465, 1009.134); break;}
2614              case 'A4_LONG'    : {$pf = array(  595.276,  986.457); break;}
2615              case 'F4'         : {$pf = array(  595.276,  935.433); break;}
2616              case 'SO_B5_EXTRA': {$pf = array(  572.598,  782.362); break;}
2617              case 'A5_EXTRA'   : {$pf = array(  490.394,  666.142); break;}
2618              // ANSI Series
2619              case 'ANSI_E': {$pf = array( 2448.000, 3168.000); break;}
2620              case 'ANSI_D': {$pf = array( 1584.000, 2448.000); break;}
2621              case 'ANSI_C': {$pf = array( 1224.000, 1584.000); break;}
2622              case 'ANSI_B': {$pf = array(  792.000, 1224.000); break;}
2623              case 'ANSI_A': {$pf = array(  612.000,  792.000); break;}
2624              // Traditional 'Loose' North American Paper Sizes
2625              case 'USLEDGER':
2626              case 'LEDGER' : {$pf = array( 1224.000,  792.000); break;}
2627              case 'ORGANIZERK':
2628              case 'BIBLE':
2629              case 'USTABLOID':
2630              case 'TABLOID': {$pf = array(  792.000, 1224.000); break;}
2631              case 'ORGANIZERM':
2632              case 'USLETTER':
2633              case 'LETTER' : {$pf = array(  612.000,  792.000); break;}
2634              case 'USLEGAL':
2635              case 'LEGAL'  : {$pf = array(  612.000, 1008.000); break;}
2636              case 'GOVERNMENTLETTER':
2637              case 'GLETTER': {$pf = array(  576.000,  756.000); break;}
2638              case 'JUNIORLEGAL':
2639              case 'JLEGAL' : {$pf = array(  576.000,  360.000); break;}
2640              // Other North American Paper Sizes
2641              case 'QUADDEMY': {$pf = array( 2520.000, 3240.000); break;}
2642              case 'SUPER_B': {$pf = array(  936.000, 1368.000); break;}
2643              case 'QUARTO': {$pf = array(  648.000,  792.000); break;}
2644              case 'GOVERNMENTLEGAL':
2645              case 'FOLIO': {$pf = array(  612.000,  936.000); break;}
2646              case 'MONARCH':
2647              case 'EXECUTIVE': {$pf = array(  522.000,  756.000); break;}
2648              case 'ORGANIZERL':
2649              case 'STATEMENT':
2650              case 'MEMO': {$pf = array(  396.000,  612.000); break;}
2651              case 'FOOLSCAP': {$pf = array(  595.440,  936.000); break;}
2652              case 'COMPACT': {$pf = array(  306.000,  486.000); break;}
2653              case 'ORGANIZERJ': {$pf = array(  198.000,  360.000); break;}
2654              // Canadian standard CAN 2-9.60M
2655              case 'P1': {$pf = array( 1587.402, 2437.795); break;}
2656              case 'P2': {$pf = array( 1218.898, 1587.402); break;}
2657              case 'P3': {$pf = array(  793.701, 1218.898); break;}
2658              case 'P4': {$pf = array(  609.449,  793.701); break;}
2659              case 'P5': {$pf = array(  396.850,  609.449); break;}
2660              case 'P6': {$pf = array(  303.307,  396.850); break;}
2661              // North American Architectural Sizes
2662              case 'ARCH_E' : {$pf = array( 2592.000, 3456.000); break;}
2663              case 'ARCH_E1': {$pf = array( 2160.000, 3024.000); break;}
2664              case 'ARCH_D' : {$pf = array( 1728.000, 2592.000); break;}
2665              case 'BROADSHEET':
2666              case 'ARCH_C' : {$pf = array( 1296.000, 1728.000); break;}
2667              case 'ARCH_B' : {$pf = array(  864.000, 1296.000); break;}
2668              case 'ARCH_A' : {$pf = array(  648.000,  864.000); break;}
2669              // --- North American Envelope Sizes ---
2670              //   - Announcement Envelopes
2671              case 'ANNENV_A2'  : {$pf = array(  314.640,  414.000); break;}
2672              case 'ANNENV_A6'  : {$pf = array(  342.000,  468.000); break;}
2673              case 'ANNENV_A7'  : {$pf = array(  378.000,  522.000); break;}
2674              case 'ANNENV_A8'  : {$pf = array(  396.000,  584.640); break;}
2675              case 'ANNENV_A10' : {$pf = array(  450.000,  692.640); break;}
2676              case 'ANNENV_SLIM': {$pf = array(  278.640,  638.640); break;}
2677              //   - Commercial Envelopes
2678              case 'COMMENV_N6_1/4': {$pf = array(  252.000,  432.000); break;}
2679              case 'COMMENV_N6_3/4': {$pf = array(  260.640,  468.000); break;}
2680              case 'COMMENV_N8'    : {$pf = array(  278.640,  540.000); break;}
2681              case 'COMMENV_N9'    : {$pf = array(  278.640,  638.640); break;}
2682              case 'COMMENV_N10'   : {$pf = array(  296.640,  684.000); break;}
2683              case 'COMMENV_N11'   : {$pf = array(  324.000,  746.640); break;}
2684              case 'COMMENV_N12'   : {$pf = array(  342.000,  792.000); break;}
2685              case 'COMMENV_N14'   : {$pf = array(  360.000,  828.000); break;}
2686              //   - Catalogue Envelopes
2687              case 'CATENV_N1'     : {$pf = array(  432.000,  648.000); break;}
2688              case 'CATENV_N1_3/4' : {$pf = array(  468.000,  684.000); break;}
2689              case 'CATENV_N2'     : {$pf = array(  468.000,  720.000); break;}
2690              case 'CATENV_N3'     : {$pf = array(  504.000,  720.000); break;}
2691              case 'CATENV_N6'     : {$pf = array(  540.000,  756.000); break;}
2692              case 'CATENV_N7'     : {$pf = array(  576.000,  792.000); break;}
2693              case 'CATENV_N8'     : {$pf = array(  594.000,  810.000); break;}
2694              case 'CATENV_N9_1/2' : {$pf = array(  612.000,  756.000); break;}
2695              case 'CATENV_N9_3/4' : {$pf = array(  630.000,  810.000); break;}
2696              case 'CATENV_N10_1/2': {$pf = array(  648.000,  864.000); break;}
2697              case 'CATENV_N12_1/2': {$pf = array(  684.000,  900.000); break;}
2698              case 'CATENV_N13_1/2': {$pf = array(  720.000,  936.000); break;}
2699              case 'CATENV_N14_1/4': {$pf = array(  810.000,  882.000); break;}
2700              case 'CATENV_N14_1/2': {$pf = array(  828.000, 1044.000); break;}
2701              // Japanese (JIS P 0138-61) Standard B-Series
2702              case 'JIS_B0' : {$pf = array( 2919.685, 4127.244); break;}
2703              case 'JIS_B1' : {$pf = array( 2063.622, 2919.685); break;}
2704              case 'JIS_B2' : {$pf = array( 1459.843, 2063.622); break;}
2705              case 'JIS_B3' : {$pf = array( 1031.811, 1459.843); break;}
2706              case 'JIS_B4' : {$pf = array(  728.504, 1031.811); break;}
2707              case 'JIS_B5' : {$pf = array(  515.906,  728.504); break;}
2708              case 'JIS_B6' : {$pf = array(  362.835,  515.906); break;}
2709              case 'JIS_B7' : {$pf = array(  257.953,  362.835); break;}
2710              case 'JIS_B8' : {$pf = array(  181.417,  257.953); break;}
2711              case 'JIS_B9' : {$pf = array(  127.559,  181.417); break;}
2712              case 'JIS_B10': {$pf = array(   90.709,  127.559); break;}
2713              case 'JIS_B11': {$pf = array(   62.362,   90.709); break;}
2714              case 'JIS_B12': {$pf = array(   45.354,   62.362); break;}
2715              // PA Series
2716              case 'PA0' : {$pf = array( 2381.102, 3174.803,); break;}
2717              case 'PA1' : {$pf = array( 1587.402, 2381.102); break;}
2718              case 'PA2' : {$pf = array( 1190.551, 1587.402); break;}
2719              case 'PA3' : {$pf = array(  793.701, 1190.551); break;}
2720              case 'PA4' : {$pf = array(  595.276,  793.701); break;}
2721              case 'PA5' : {$pf = array(  396.850,  595.276); break;}
2722              case 'PA6' : {$pf = array(  297.638,  396.850); break;}
2723              case 'PA7' : {$pf = array(  198.425,  297.638); break;}
2724              case 'PA8' : {$pf = array(  147.402,  198.425); break;}
2725              case 'PA9' : {$pf = array(   99.213,  147.402); break;}
2726              case 'PA10': {$pf = array(   73.701,   99.213); break;}
2727              // Standard Photographic Print Sizes
2728              case 'PASSPORT_PHOTO': {$pf = array(   99.213,  127.559); break;}
2729              case 'E'   : {$pf = array(  233.858,  340.157); break;}
2730              case 'L':
2731              case '3R'  : {$pf = array(  252.283,  360.000); break;}
2732              case 'KG':
2733              case '4R'  : {$pf = array(  289.134,  430.866); break;}
2734              case '4D'  : {$pf = array(  340.157,  430.866); break;}
2735              case '2L':
2736              case '5R'  : {$pf = array(  360.000,  504.567); break;}
2737              case '8P':
2738              case '6R'  : {$pf = array(  430.866,  575.433); break;}
2739              case '6P':
2740              case '8R'  : {$pf = array(  575.433,  720.000); break;}
2741              case '6PW':
2742              case 'S8R' : {$pf = array(  575.433,  864.567); break;}
2743              case '4P':
2744              case '10R' : {$pf = array(  720.000,  864.567); break;}
2745              case '4PW':
2746              case 'S10R': {$pf = array(  720.000, 1080.000); break;}
2747              case '11R' : {$pf = array(  790.866, 1009.134); break;}
2748              case 'S11R': {$pf = array(  790.866, 1224.567); break;}
2749              case '12R' : {$pf = array(  864.567, 1080.000); break;}
2750              case 'S12R': {$pf = array(  864.567, 1292.598); break;}
2751              // Common Newspaper Sizes
2752              case 'NEWSPAPER_BROADSHEET': {$pf = array( 2125.984, 1700.787); break;}
2753              case 'NEWSPAPER_BERLINER'  : {$pf = array( 1332.283,  892.913); break;}
2754              case 'NEWSPAPER_TABLOID':
2755              case 'NEWSPAPER_COMPACT'   : {$pf = array( 1218.898,  793.701); break;}
2756              // Business Cards
2757              case 'CREDIT_CARD':
2758              case 'BUSINESS_CARD':
2759              case 'BUSINESS_CARD_ISO7810': {$pf = array(  153.014,  242.646); break;}
2760              case 'BUSINESS_CARD_ISO216' : {$pf = array(  147.402,  209.764); break;}
2761              case 'BUSINESS_CARD_IT':
2762              case 'BUSINESS_CARD_UK':
2763              case 'BUSINESS_CARD_FR':
2764              case 'BUSINESS_CARD_DE':
2765              case 'BUSINESS_CARD_ES'     : {$pf = array(  155.906,  240.945); break;}
2766              case 'BUSINESS_CARD_CA':
2767              case 'BUSINESS_CARD_US'     : {$pf = array(  144.567,  252.283); break;}
2768              case 'BUSINESS_CARD_JP'     : {$pf = array(  155.906,  257.953); break;}
2769              case 'BUSINESS_CARD_HK'     : {$pf = array(  153.071,  255.118); break;}
2770              case 'BUSINESS_CARD_AU':
2771              case 'BUSINESS_CARD_DK':
2772              case 'BUSINESS_CARD_SE'     : {$pf = array(  155.906,  255.118); break;}
2773              case 'BUSINESS_CARD_RU':
2774              case 'BUSINESS_CARD_CZ':
2775              case 'BUSINESS_CARD_FI':
2776              case 'BUSINESS_CARD_HU':
2777              case 'BUSINESS_CARD_IL'     : {$pf = array(  141.732,  255.118); break;}
2778              // Billboards
2779              case '4SHEET' : {$pf = array( 2880.000, 4320.000); break;}
2780              case '6SHEET' : {$pf = array( 3401.575, 5102.362); break;}
2781              case '12SHEET': {$pf = array( 8640.000, 4320.000); break;}
2782              case '16SHEET': {$pf = array( 5760.000, 8640.000); break;}
2783              case '32SHEET': {$pf = array(11520.000, 8640.000); break;}
2784              case '48SHEET': {$pf = array(17280.000, 8640.000); break;}
2785              case '64SHEET': {$pf = array(23040.000, 8640.000); break;}
2786              case '96SHEET': {$pf = array(34560.000, 8640.000); break;}
2787              // Old European Sizes
2788              //   - Old Imperial English Sizes
2789              case 'EN_EMPEROR'          : {$pf = array( 3456.000, 5184.000); break;}
2790              case 'EN_ANTIQUARIAN'      : {$pf = array( 2232.000, 3816.000); break;}
2791              case 'EN_GRAND_EAGLE'      : {$pf = array( 2070.000, 3024.000); break;}
2792              case 'EN_DOUBLE_ELEPHANT'  : {$pf = array( 1926.000, 2880.000); break;}
2793              case 'EN_ATLAS'            : {$pf = array( 1872.000, 2448.000); break;}
2794              case 'EN_COLOMBIER'        : {$pf = array( 1692.000, 2484.000); break;}
2795              case 'EN_ELEPHANT'         : {$pf = array( 1656.000, 2016.000); break;}
2796              case 'EN_DOUBLE_DEMY'      : {$pf = array( 1620.000, 2556.000); break;}
2797              case 'EN_IMPERIAL'         : {$pf = array( 1584.000, 2160.000); break;}
2798              case 'EN_PRINCESS'         : {$pf = array( 1548.000, 2016.000); break;}
2799              case 'EN_CARTRIDGE'        : {$pf = array( 1512.000, 1872.000); break;}
2800              case 'EN_DOUBLE_LARGE_POST': {$pf = array( 1512.000, 2376.000); break;}
2801              case 'EN_ROYAL'            : {$pf = array( 1440.000, 1800.000); break;}
2802              case 'EN_SHEET':
2803              case 'EN_HALF_POST'        : {$pf = array( 1404.000, 1692.000); break;}
2804              case 'EN_SUPER_ROYAL'      : {$pf = array( 1368.000, 1944.000); break;}
2805              case 'EN_DOUBLE_POST'      : {$pf = array( 1368.000, 2196.000); break;}
2806              case 'EN_MEDIUM'           : {$pf = array( 1260.000, 1656.000); break;}
2807              case 'EN_DEMY'             : {$pf = array( 1260.000, 1620.000); break;}
2808              case 'EN_LARGE_POST'       : {$pf = array( 1188.000, 1512.000); break;}
2809              case 'EN_COPY_DRAUGHT'     : {$pf = array( 1152.000, 1440.000); break;}
2810              case 'EN_POST'             : {$pf = array( 1116.000, 1386.000); break;}
2811              case 'EN_CROWN'            : {$pf = array( 1080.000, 1440.000); break;}
2812              case 'EN_PINCHED_POST'     : {$pf = array( 1062.000, 1332.000); break;}
2813              case 'EN_BRIEF'            : {$pf = array(  972.000, 1152.000); break;}
2814              case 'EN_FOOLSCAP'         : {$pf = array(  972.000, 1224.000); break;}
2815              case 'EN_SMALL_FOOLSCAP'   : {$pf = array(  954.000, 1188.000); break;}
2816              case 'EN_POTT'             : {$pf = array(  900.000, 1080.000); break;}
2817              //   - Old Imperial Belgian Sizes
2818              case 'BE_GRAND_AIGLE' : {$pf = array( 1984.252, 2948.031); break;}
2819              case 'BE_COLOMBIER'   : {$pf = array( 1757.480, 2409.449); break;}
2820              case 'BE_DOUBLE_CARRE': {$pf = array( 1757.480, 2607.874); break;}
2821              case 'BE_ELEPHANT'    : {$pf = array( 1746.142, 2182.677); break;}
2822              case 'BE_PETIT_AIGLE' : {$pf = array( 1700.787, 2381.102); break;}
2823              case 'BE_GRAND_JESUS' : {$pf = array( 1559.055, 2069.291); break;}
2824              case 'BE_JESUS'       : {$pf = array( 1530.709, 2069.291); break;}
2825              case 'BE_RAISIN'      : {$pf = array( 1417.323, 1842.520); break;}
2826              case 'BE_GRAND_MEDIAN': {$pf = array( 1303.937, 1714.961); break;}
2827              case 'BE_DOUBLE_POSTE': {$pf = array( 1233.071, 1601.575); break;}
2828              case 'BE_COQUILLE'    : {$pf = array( 1218.898, 1587.402); break;}
2829              case 'BE_PETIT_MEDIAN': {$pf = array( 1176.378, 1502.362); break;}
2830              case 'BE_RUCHE'       : {$pf = array( 1020.472, 1303.937); break;}
2831              case 'BE_PROPATRIA'   : {$pf = array(  977.953, 1218.898); break;}
2832              case 'BE_LYS'         : {$pf = array(  898.583, 1125.354); break;}
2833              case 'BE_POT'         : {$pf = array(  870.236, 1088.504); break;}
2834              case 'BE_ROSETTE'     : {$pf = array(  765.354,  983.622); break;}
2835              //   - Old Imperial French Sizes
2836              case 'FR_UNIVERS'          : {$pf = array( 2834.646, 3685.039); break;}
2837              case 'FR_DOUBLE_COLOMBIER' : {$pf = array( 2551.181, 3571.654); break;}
2838              case 'FR_GRANDE_MONDE'     : {$pf = array( 2551.181, 3571.654); break;}
2839              case 'FR_DOUBLE_SOLEIL'    : {$pf = array( 2267.717, 3401.575); break;}
2840              case 'FR_DOUBLE_JESUS'     : {$pf = array( 2154.331, 3174.803); break;}
2841              case 'FR_GRAND_AIGLE'      : {$pf = array( 2125.984, 3004.724); break;}
2842              case 'FR_PETIT_AIGLE'      : {$pf = array( 1984.252, 2664.567); break;}
2843              case 'FR_DOUBLE_RAISIN'    : {$pf = array( 1842.520, 2834.646); break;}
2844              case 'FR_JOURNAL'          : {$pf = array( 1842.520, 2664.567); break;}
2845              case 'FR_COLOMBIER_AFFICHE': {$pf = array( 1785.827, 2551.181); break;}
2846              case 'FR_DOUBLE_CAVALIER'  : {$pf = array( 1757.480, 2607.874); break;}
2847              case 'FR_CLOCHE'           : {$pf = array( 1700.787, 2267.717); break;}
2848              case 'FR_SOLEIL'           : {$pf = array( 1700.787, 2267.717); break;}
2849              case 'FR_DOUBLE_CARRE'     : {$pf = array( 1587.402, 2551.181); break;}
2850              case 'FR_DOUBLE_COQUILLE'  : {$pf = array( 1587.402, 2494.488); break;}
2851              case 'FR_JESUS'            : {$pf = array( 1587.402, 2154.331); break;}
2852              case 'FR_RAISIN'           : {$pf = array( 1417.323, 1842.520); break;}
2853              case 'FR_CAVALIER'         : {$pf = array( 1303.937, 1757.480); break;}
2854              case 'FR_DOUBLE_COURONNE'  : {$pf = array( 1303.937, 2040.945); break;}
2855              case 'FR_CARRE'            : {$pf = array( 1275.591, 1587.402); break;}
2856              case 'FR_COQUILLE'         : {$pf = array( 1247.244, 1587.402); break;}
2857              case 'FR_DOUBLE_TELLIERE'  : {$pf = array( 1247.244, 1927.559); break;}
2858              case 'FR_DOUBLE_CLOCHE'    : {$pf = array( 1133.858, 1700.787); break;}
2859              case 'FR_DOUBLE_POT'       : {$pf = array( 1133.858, 1757.480); break;}
2860              case 'FR_ECU'              : {$pf = array( 1133.858, 1474.016); break;}
2861              case 'FR_COURONNE'         : {$pf = array( 1020.472, 1303.937); break;}
2862              case 'FR_TELLIERE'         : {$pf = array(  963.780, 1247.244); break;}
2863              case 'FR_POT'              : {$pf = array(  878.740, 1133.858); break;}
2864              // DEFAULT ISO A4
2865              default: {$pf = array(  595.276,  841.890); break;}
2866          }
2867          return $pf;
2868      }
2869  
2870      /**
2871       * Change the format of the current page
2872       * @param $format (mixed) The format used for pages. It can be either: one of the string values specified at getPageSizeFromFormat() documentation or an array of two numners (width, height) or an array containing the following measures and options:<ul>
2873       * <li>['format'] = page format name (one of the above);</li>
2874       * <li>['Rotate'] : The number of degrees by which the page shall be rotated clockwise when displayed or printed. The value shall be a multiple of 90.</li>
2875       * <li>['PZ'] : The page's preferred zoom (magnification) factor.</li>
2876       * <li>['MediaBox'] : the boundaries of the physical medium on which the page shall be displayed or printed:</li>
2877       * <li>['MediaBox']['llx'] : lower-left x coordinate in points</li>
2878       * <li>['MediaBox']['lly'] : lower-left y coordinate in points</li>
2879       * <li>['MediaBox']['urx'] : upper-right x coordinate in points</li>
2880       * <li>['MediaBox']['ury'] : upper-right y coordinate in points</li>
2881       * <li>['CropBox'] : the visible region of default user space:</li>
2882       * <li>['CropBox']['llx'] : lower-left x coordinate in points</li>
2883       * <li>['CropBox']['lly'] : lower-left y coordinate in points</li>
2884       * <li>['CropBox']['urx'] : upper-right x coordinate in points</li>
2885       * <li>['CropBox']['ury'] : upper-right y coordinate in points</li>
2886       * <li>['BleedBox'] : the region to which the contents of the page shall be clipped when output in a production environment:</li>
2887       * <li>['BleedBox']['llx'] : lower-left x coordinate in points</li>
2888       * <li>['BleedBox']['lly'] : lower-left y coordinate in points</li>
2889       * <li>['BleedBox']['urx'] : upper-right x coordinate in points</li>
2890       * <li>['BleedBox']['ury'] : upper-right y coordinate in points</li>
2891       * <li>['TrimBox'] : the intended dimensions of the finished page after trimming:</li>
2892       * <li>['TrimBox']['llx'] : lower-left x coordinate in points</li>
2893       * <li>['TrimBox']['lly'] : lower-left y coordinate in points</li>
2894       * <li>['TrimBox']['urx'] : upper-right x coordinate in points</li>
2895       * <li>['TrimBox']['ury'] : upper-right y coordinate in points</li>
2896       * <li>['ArtBox'] : the extent of the page's meaningful content:</li>
2897       * <li>['ArtBox']['llx'] : lower-left x coordinate in points</li>
2898       * <li>['ArtBox']['lly'] : lower-left y coordinate in points</li>
2899       * <li>['ArtBox']['urx'] : upper-right x coordinate in points</li>
2900       * <li>['ArtBox']['ury'] : upper-right y coordinate in points</li>
2901       * <li>['BoxColorInfo'] :specify the colours and other visual characteristics that should be used in displaying guidelines on the screen for each of the possible page boundaries other than the MediaBox:</li>
2902       * <li>['BoxColorInfo'][BOXTYPE]['C'] : an array of three numbers in the range 0-255, representing the components in the DeviceRGB colour space.</li>
2903       * <li>['BoxColorInfo'][BOXTYPE]['W'] : the guideline width in default user units</li>
2904       * <li>['BoxColorInfo'][BOXTYPE]['S'] : the guideline style: S = Solid; D = Dashed</li>
2905       * <li>['BoxColorInfo'][BOXTYPE]['D'] : dash array defining a pattern of dashes and gaps to be used in drawing dashed guidelines</li>
2906       * <li>['trans'] : the style and duration of the visual transition to use when moving from another page to the given page during a presentation</li>
2907       * <li>['trans']['Dur'] : The page's display duration (also called its advance timing): the maximum length of time, in seconds, that the page shall be displayed during presentations before the viewer application shall automatically advance to the next page.</li>
2908       * <li>['trans']['S'] : transition style : Split, Blinds, Box, Wipe, Dissolve, Glitter, R, Fly, Push, Cover, Uncover, Fade</li>
2909       * <li>['trans']['D'] : The duration of the transition effect, in seconds.</li>
2910       * <li>['trans']['Dm'] : (Split and Blinds transition styles only) The dimension in which the specified transition effect shall occur: H = Horizontal, V = Vertical. Default value: H.</li>
2911       * <li>['trans']['M'] : (Split, Box and Fly transition styles only) The direction of motion for the specified transition effect: I = Inward from the edges of the page, O = Outward from the center of the pageDefault value: I.</li>
2912       * <li>['trans']['Di'] : (Wipe, Glitter, Fly, Cover, Uncover and Push transition styles only) The direction in which the specified transition effect shall moves, expressed in degrees counterclockwise starting from a left-to-right direction. If the value is a number, it shall be one of: 0 = Left to right, 90 = Bottom to top (Wipe only), 180 = Right to left (Wipe only), 270 = Top to bottom, 315 = Top-left to bottom-right (Glitter only). If the value is a name, it shall be None, which is relevant only for the Fly transition when the value of SS is not 1.0. Default value: 0.</li>
2913       * <li>['trans']['SS'] : (Fly transition style only) The starting or ending scale at which the changes shall be drawn. If M specifies an inward transition, the scale of the changes drawn shall progress from SS to 1.0 over the course of the transition. If M specifies an outward transition, the scale of the changes drawn shall progress from 1.0 to SS over the course of the transition. Default: 1.0.</li>
2914       * <li>['trans']['B'] : (Fly transition style only) If true, the area that shall be flown in is rectangular and opaque. Default: false.</li>
2915       * </ul>
2916       * @param $orientation (string) page orientation. Possible values are (case insensitive):<ul>
2917       * <li>P or Portrait (default)</li>
2918       * <li>L or Landscape</li>
2919       * <li>'' (empty string) for automatic orientation</li>
2920       * </ul>
2921       * @protected
2922       * @since 3.0.015 (2008-06-06)
2923       * @see getPageSizeFromFormat()
2924       */
2925  	protected function setPageFormat($format, $orientation='P') {
2926          if (!empty($format) AND isset($this->pagedim[$this->page])) {
2927              // remove inherited values
2928              unset($this->pagedim[$this->page]);
2929          }
2930          if (is_string($format)) {
2931              // get page measures from format name
2932              $pf = $this->getPageSizeFromFormat($format);
2933              $this->fwPt = $pf[0];
2934              $this->fhPt = $pf[1];
2935          } else {
2936              // the boundaries of the physical medium on which the page shall be displayed or printed
2937              if (isset($format['MediaBox'])) {
2938                  $this->setPageBoxes($this->page, 'MediaBox', $format['MediaBox']['llx'], $format['MediaBox']['lly'], $format['MediaBox']['urx'], $format['MediaBox']['ury'], false);
2939                  $this->fwPt = (($format['MediaBox']['urx'] - $format['MediaBox']['llx']) * $this->k);
2940                  $this->fhPt = (($format['MediaBox']['ury'] - $format['MediaBox']['lly']) * $this->k);
2941              } else {
2942                  if (isset($format[0]) AND is_numeric($format[0]) AND isset($format[1]) AND is_numeric($format[1])) {
2943                      $pf = array(($format[0] * $this->k), ($format[1] * $this->k));
2944                  } else {
2945                      if (!isset($format['format'])) {
2946                          // default value
2947                          $format['format'] = 'A4';
2948                      }
2949                      $pf = $this->getPageSizeFromFormat($format['format']);
2950                  }
2951                  $this->fwPt = $pf[0];
2952                  $this->fhPt = $pf[1];
2953                  $this->setPageBoxes($this->page, 'MediaBox', 0, 0, $this->fwPt, $this->fhPt, true);
2954              }
2955              // the visible region of default user space
2956              if (isset($format['CropBox'])) {
2957                  $this->setPageBoxes($this->page, 'CropBox', $format['CropBox']['llx'], $format['CropBox']['lly'], $format['CropBox']['urx'], $format['CropBox']['ury'], false);
2958              }
2959              // the region to which the contents of the page shall be clipped when output in a production environment
2960              if (isset($format['BleedBox'])) {
2961                  $this->setPageBoxes($this->page, 'BleedBox', $format['BleedBox']['llx'], $format['BleedBox']['lly'], $format['BleedBox']['urx'], $format['BleedBox']['ury'], false);
2962              }
2963              // the intended dimensions of the finished page after trimming
2964              if (isset($format['TrimBox'])) {
2965                  $this->setPageBoxes($this->page, 'TrimBox', $format['TrimBox']['llx'], $format['TrimBox']['lly'], $format['TrimBox']['urx'], $format['TrimBox']['ury'], false);
2966              }
2967              // the page's meaningful content (including potential white space)
2968              if (isset($format['ArtBox'])) {
2969                  $this->setPageBoxes($this->page, 'ArtBox', $format['ArtBox']['llx'], $format['ArtBox']['lly'], $format['ArtBox']['urx'], $format['ArtBox']['ury'], false);
2970              }
2971              // specify the colours and other visual characteristics that should be used in displaying guidelines on the screen for the various page boundaries
2972              if (isset($format['BoxColorInfo'])) {
2973                  $this->pagedim[$this->page]['BoxColorInfo'] = $format['BoxColorInfo'];
2974              }
2975              if (isset($format['Rotate']) AND (($format['Rotate'] % 90) == 0)) {
2976                  // The number of degrees by which the page shall be rotated clockwise when displayed or printed. The value shall be a multiple of 90.
2977                  $this->pagedim[$this->page]['Rotate'] = intval($format['Rotate']);
2978              }
2979              if (isset($format['PZ'])) {
2980                  // The page's preferred zoom (magnification) factor
2981                  $this->pagedim[$this->page]['PZ'] = floatval($format['PZ']);
2982              }
2983              if (isset($format['trans'])) {
2984                  // The style and duration of the visual transition to use when moving from another page to the given page during a presentation
2985                  if (isset($format['trans']['Dur'])) {
2986                      // The page's display duration
2987                      $this->pagedim[$this->page]['trans']['Dur'] = floatval($format['trans']['Dur']);
2988                  }
2989                  $stansition_styles = array('Split', 'Blinds', 'Box', 'Wipe', 'Dissolve', 'Glitter', 'R', 'Fly', 'Push', 'Cover', 'Uncover', 'Fade');
2990                  if (isset($format['trans']['S']) AND in_array($format['trans']['S'], $stansition_styles)) {
2991                      // The transition style that shall be used when moving to this page from another during a presentation
2992                      $this->pagedim[$this->page]['trans']['S'] = $format['trans']['S'];
2993                      $valid_effect = array('Split', 'Blinds');
2994                      $valid_vals = array('H', 'V');
2995                      if (isset($format['trans']['Dm']) AND in_array($format['trans']['S'], $valid_effect) AND in_array($format['trans']['Dm'], $valid_vals)) {
2996                          $this->pagedim[$this->page]['trans']['Dm'] = $format['trans']['Dm'];
2997                      }
2998                      $valid_effect = array('Split', 'Box', 'Fly');
2999                      $valid_vals = array('I', 'O');
3000                      if (isset($format['trans']['M']) AND in_array($format['trans']['S'], $valid_effect) AND in_array($format['trans']['M'], $valid_vals)) {
3001                          $this->pagedim[$this->page]['trans']['M'] = $format['trans']['M'];
3002                      }
3003                      $valid_effect = array('Wipe', 'Glitter', 'Fly', 'Cover', 'Uncover', 'Push');
3004                      if (isset($format['trans']['Di']) AND in_array($format['trans']['S'], $valid_effect)) {
3005                          if (((($format['trans']['Di'] == 90) OR ($format['trans']['Di'] == 180)) AND ($format['trans']['S'] == 'Wipe'))
3006                              OR (($format['trans']['Di'] == 315) AND ($format['trans']['S'] == 'Glitter'))
3007                              OR (($format['trans']['Di'] == 0) OR ($format['trans']['Di'] == 270))) {
3008                              $this->pagedim[$this->page]['trans']['Di'] = intval($format['trans']['Di']);
3009                          }
3010                      }
3011                      if (isset($format['trans']['SS']) AND ($format['trans']['S'] == 'Fly')) {
3012                          $this->pagedim[$this->page]['trans']['SS'] = floatval($format['trans']['SS']);
3013                      }
3014                      if (isset($format['trans']['B']) AND ($format['trans']['B'] === true) AND ($format['trans']['S'] == 'Fly')) {
3015                          $this->pagedim[$this->page]['trans']['B'] = 'true';
3016                      }
3017                  } else {
3018                      $this->pagedim[$this->page]['trans']['S'] = 'R';
3019                  }
3020                  if (isset($format['trans']['D'])) {
3021                      // The duration of the transition effect, in seconds
3022                      $this->pagedim[$this->page]['trans']['D'] = floatval($format['trans']['D']);
3023                  } else {
3024                      $this->pagedim[$this->page]['trans']['D'] = 1;
3025                  }
3026              }
3027          }
3028          $this->setPageOrientation($orientation);
3029      }
3030  
3031      /**
3032       * Set page boundaries.
3033       * @param $page (int) page number
3034       * @param $type (string) valid values are: <ul><li>'MediaBox' : the boundaries of the physical medium on which the page shall be displayed or printed;</li><li>'CropBox' : the visible region of default user space;</li><li>'BleedBox' : the region to which the contents of the page shall be clipped when output in a production environment;</li><li>'TrimBox' : the intended dimensions of the finished page after trimming;</li><li>'ArtBox' : the page's meaningful content (including potential white space).</li></ul>
3035       * @param $llx (float) lower-left x coordinate in user units
3036       * @param $lly (float) lower-left y coordinate in user units
3037       * @param $urx (float) upper-right x coordinate in user units
3038       * @param $ury (float) upper-right y coordinate in user units
3039       * @param $points (boolean) if true uses user units as unit of measure, otherwise uses PDF points
3040       * @public
3041       * @since 5.0.010 (2010-05-17)
3042       */
3043  	public function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false) {
3044          if (!isset($this->pagedim[$page])) {
3045              // initialize array
3046              $this->pagedim[$page] = array();
3047          }
3048          $pageboxes = array('MediaBox', 'CropBox', 'BleedBox', 'TrimBox', 'ArtBox');
3049          if (!in_array($type, $pageboxes)) {
3050              return;
3051          }
3052          if ($points) {
3053              $k = 1;
3054          } else {
3055              $k = $this->k;
3056          }
3057          $this->pagedim[$page][$type]['llx'] = ($llx * $k);
3058          $this->pagedim[$page][$type]['lly'] = ($lly * $k);
3059          $this->pagedim[$page][$type]['urx'] = ($urx * $k);
3060          $this->pagedim[$page][$type]['ury'] = ($ury * $k);
3061      }
3062  
3063      /**
3064       * Swap X and Y coordinates of page boxes (change page boxes orientation).
3065       * @param $page (int) page number
3066       * @protected
3067       * @since 5.0.010 (2010-05-17)
3068       */
3069  	protected function swapPageBoxCoordinates($page) {
3070          $pageboxes = array('MediaBox', 'CropBox', 'BleedBox', 'TrimBox', 'ArtBox');
3071          foreach ($pageboxes as $type) {
3072              // swap X and Y coordinates
3073              if (isset($this->pagedim[$page][$type])) {
3074                  $tmp = $this->pagedim[$page][$type]['llx'];
3075                  $this->pagedim[$page][$type]['llx'] = $this->pagedim[$page][$type]['lly'];
3076                  $this->pagedim[$page][$type]['lly'] = $tmp;
3077                  $tmp = $this->pagedim[$page][$type]['urx'];
3078                  $this->pagedim[$page][$type]['urx'] = $this->pagedim[$page][$type]['ury'];
3079                  $this->pagedim[$page][$type]['ury'] = $tmp;
3080              }
3081          }
3082      }
3083  
3084      /**
3085       * Set page orientation.
3086       * @param $orientation (string) page orientation. Possible values are (case insensitive):<ul><li>P or Portrait (default)</li><li>L or Landscape</li><li>'' (empty string) for automatic orientation</li></ul>
3087       * @param $autopagebreak (boolean) Boolean indicating if auto-page-break mode should be on or off.
3088       * @param $bottommargin (float) bottom margin of the page.
3089       * @public
3090       * @since 3.0.015 (2008-06-06)
3091       */
3092  	public function setPageOrientation($orientation, $autopagebreak='', $bottommargin='') {
3093          if (!isset($this->pagedim[$this->page]['MediaBox'])) {
3094              // the boundaries of the physical medium on which the page shall be displayed or printed
3095              $this->setPageBoxes($this->page, 'MediaBox', 0, 0, $this->fwPt, $this->fhPt, true);
3096          }
3097          if (!isset($this->pagedim[$this->page]['CropBox'])) {
3098              // the visible region of default user space
3099              $this->setPageBoxes($this->page, 'CropBox', $this->pagedim[$this->page]['MediaBox']['llx'], $this->pagedim[$this->page]['MediaBox']['lly'], $this->pagedim[$this->page]['MediaBox']['urx'], $this->pagedim[$this->page]['MediaBox']['ury'], true);
3100          }
3101          if (!isset($this->pagedim[$this->page]['BleedBox'])) {
3102              // the region to which the contents of the page shall be clipped when output in a production environment
3103              $this->setPageBoxes($this->page, 'BleedBox', $this->pagedim[$this->page]['CropBox']['llx'], $this->pagedim[$this->page]['CropBox']['lly'], $this->pagedim[$this->page]['CropBox']['urx'], $this->pagedim[$this->page]['CropBox']['ury'], true);
3104          }
3105          if (!isset($this->pagedim[$this->page]['TrimBox'])) {
3106              // the intended dimensions of the finished page after trimming
3107              $this->setPageBoxes($this->page, 'TrimBox', $this->pagedim[$this->page]['CropBox']['llx'], $this->pagedim[$this->page]['CropBox']['lly'], $this->pagedim[$this->page]['CropBox']['urx'], $this->pagedim[$this->page]['CropBox']['ury'], true);
3108          }
3109          if (!isset($this->pagedim[$this->page]['ArtBox'])) {
3110              // the page's meaningful content (including potential white space)
3111              $this->setPageBoxes($this->page, 'ArtBox', $this->pagedim[$this->page]['CropBox']['llx'], $this->pagedim[$this->page]['CropBox']['lly'], $this->pagedim[$this->page]['CropBox']['urx'], $this->pagedim[$this->page]['CropBox']['ury'], true);
3112          }
3113          if (!isset($this->pagedim[$this->page]['Rotate'])) {
3114              // The number of degrees by which the page shall be rotated clockwise when displayed or printed. The value shall be a multiple of 90.
3115              $this->pagedim[$this->page]['Rotate'] = 0;
3116          }
3117          if (!isset($this->pagedim[$this->page]['PZ'])) {
3118              // The page's preferred zoom (magnification) factor
3119              $this->pagedim[$this->page]['PZ'] = 1;
3120          }
3121          if ($this->fwPt > $this->fhPt) {
3122              // landscape
3123              $default_orientation = 'L';
3124          } else {
3125              // portrait
3126              $default_orientation = 'P';
3127          }
3128          $valid_orientations = array('P', 'L');
3129          if (empty($orientation)) {
3130              $orientation = $default_orientation;
3131          } else {
3132              $orientation = strtoupper($orientation{0});
3133          }
3134          if (in_array($orientation, $valid_orientations) AND ($orientation != $default_orientation)) {
3135              $this->CurOrientation = $orientation;
3136              $this->wPt = $this->fhPt;
3137              $this->hPt = $this->fwPt;
3138          } else {
3139              $this->CurOrientation = $default_orientation;
3140              $this->wPt = $this->fwPt;
3141              $this->hPt = $this->fhPt;
3142          }
3143          if ((abs($this->pagedim[$this->page]['MediaBox']['urx'] - $this->hPt) < $this->feps) AND (abs($this->pagedim[$this->page]['MediaBox']['ury'] - $this->wPt) < $this->feps)){
3144              // swap X and Y coordinates (change page orientation)
3145              $this->swapPageBoxCoordinates($this->page);
3146          }
3147          $this->w = ($this->wPt / $this->k);
3148          $this->h = ($this->hPt / $this->k);
3149          if ($this->empty_string($autopagebreak)) {
3150              if (isset($this->AutoPageBreak)) {
3151                  $autopagebreak = $this->AutoPageBreak;
3152              } else {
3153                  $autopagebreak = true;
3154              }
3155          }
3156          if ($this->empty_string($bottommargin)) {
3157              if (isset($this->bMargin)) {
3158                  $bottommargin = $this->bMargin;
3159              } else {
3160                  // default value = 2 cm
3161                  $bottommargin = 2 * 28.35 / $this->k;
3162              }
3163          }
3164          $this->SetAutoPageBreak($autopagebreak, $bottommargin);
3165          // store page dimensions
3166          $this->pagedim[$this->page]['w'] = $this->wPt;
3167          $this->pagedim[$this->page]['h'] = $this->hPt;
3168          $this->pagedim[$this->page]['wk'] = $this->w;
3169          $this->pagedim[$this->page]['hk'] = $this->h;
3170          $this->pagedim[$this->page]['tm'] = $this->tMargin;
3171          $this->pagedim[$this->page]['bm'] = $bottommargin;
3172          $this->pagedim[$this->page]['lm'] = $this->lMargin;
3173          $this->pagedim[$this->page]['rm'] = $this->rMargin;
3174          $this->pagedim[$this->page]['pb'] = $autopagebreak;
3175          $this->pagedim[$this->page]['or'] = $this->CurOrientation;
3176          $this->pagedim[$this->page]['olm'] = $this->original_lMargin;
3177          $this->pagedim[$this->page]['orm'] = $this->original_rMargin;
3178      }
3179  
3180      /**
3181       * Set regular expression to detect withespaces or word separators.
3182       * The pattern delimiter must be the forward-slash character "/".
3183       * Some example patterns are:
3184       * <pre>
3185       * Non-Unicode or missing PCRE unicode support: "/[^\S\xa0]/"
3186       * Unicode and PCRE unicode support: "/[^\S\P{Z}\xa0]/u"
3187       * Unicode and PCRE unicode support in Chinese mode: "/[^\S\P{Z}\P{Lo}\xa0]/u"
3188       * if PCRE unicode support is turned ON ("\P" is the negate class of "\p"):
3189       * "\p{Z}" or "\p{Separator}": any kind of Unicode whitespace or invisible separator.
3190       * "\p{Lo}" or "\p{Other_Letter}": a Unicode letter or ideograph that does not have lowercase and uppercase variants.
3191       * "\p{Lo}" is needed for Chinese characters because are packed next to each other without spaces in between.
3192       * </pre>
3193       * @param $re (string) regular expression (leave empty for default).
3194       * @public
3195       * @since 4.6.016 (2009-06-15)
3196       */
3197  	public function setSpacesRE($re='/[^\S\xa0]/') {
3198          $this->re_spaces = $re;
3199          $re_parts = explode('/', $re);
3200          // get pattern parts
3201          $this->re_space = array();
3202          if (isset($re_parts[1]) AND !empty($re_parts[1])) {
3203              $this->re_space['p'] = $re_parts[1];
3204          } else {
3205              $this->re_space['p'] = '[\s]';
3206          }
3207          // set pattern modifiers
3208          if (isset($re_parts[2]) AND !empty($re_parts[2])) {
3209              $this->re_space['m'] = $re_parts[2];
3210          } else {
3211              $this->re_space['m'] = '';
3212          }
3213      }
3214  
3215      /**
3216       * Enable or disable Right-To-Left language mode
3217       * @param $enable (Boolean) if true enable Right-To-Left language mode.
3218       * @param $resetx (Boolean) if true reset the X position on direction change.
3219       * @public
3220       * @since 2.0.000 (2008-01-03)
3221       */
3222  	public function setRTL($enable, $resetx=true) {
3223          $enable = $enable ? true : false;
3224          $resetx = ($resetx AND ($enable != $this->rtl));
3225          $this->rtl = $enable;
3226          $this->tmprtl = false;
3227          if ($resetx) {
3228              $this->Ln(0);
3229          }
3230      }
3231  
3232      /**
3233       * Return the RTL status
3234       * @return boolean
3235       * @public
3236       * @since 4.0.012 (2008-07-24)
3237       */
3238  	public function getRTL() {
3239          return $this->rtl;
3240      }
3241  
3242      /**
3243       * Force temporary RTL language direction
3244       * @param $mode (mixed) can be false, 'L' for LTR or 'R' for RTL
3245       * @public
3246       * @since 2.1.000 (2008-01-09)
3247       */
3248  	public function setTempRTL($mode) {
3249          $newmode = false;
3250          switch (strtoupper($mode)) {
3251              case 'LTR':
3252              case 'L': {
3253                  if ($this->rtl) {
3254                      $newmode = 'L';
3255                  }
3256                  break;
3257              }
3258              case 'RTL':
3259              case 'R': {
3260                  if (!$this->rtl) {
3261                      $newmode = 'R';
3262                  }
3263                  break;
3264              }
3265              case false:
3266              default: {
3267                  $newmode = false;
3268                  break;
3269              }
3270          }
3271          $this->tmprtl = $newmode;
3272      }
3273  
3274      /**
3275       * Return the current temporary RTL status
3276       * @return boolean
3277       * @public
3278       * @since 4.8.014 (2009-11-04)
3279       */
3280  	public function isRTLTextDir() {
3281          return ($this->rtl OR ($this->tmprtl == 'R'));
3282      }
3283  
3284      /**
3285       * Set the last cell height.
3286       * @param $h (float) cell height.
3287       * @author Nicola Asuni
3288       * @public
3289       * @since 1.53.0.TC034
3290       */
3291  	public function setLastH($h) {
3292          $this->lasth = $h;
3293      }
3294  
3295      /**
3296       * Reset the last cell height.
3297       * @public
3298       * @since 5.9.000 (2010-10-03)
3299       */
3300  	public function resetLastH() {
3301          $this->lasth = ($this->FontSize * $this->cell_height_ratio) + $this->cell_padding['T'] + $this->cell_padding['B'];
3302      }
3303  
3304      /**
3305       * Get the last cell height.
3306       * @return last cell height
3307       * @public
3308       * @since 4.0.017 (2008-08-05)
3309       */
3310  	public function getLastH() {
3311          return $this->lasth;
3312      }
3313  
3314      /**
3315       * Set the adjusting factor to convert pixels to user units.
3316       * @param $scale (float) adjusting factor to convert pixels to user units.
3317       * @author Nicola Asuni
3318       * @public
3319       * @since 1.5.2
3320       */
3321  	public function setImageScale($scale) {
3322          $this->imgscale = $scale;
3323      }
3324  
3325      /**
3326       * Returns the adjusting factor to convert pixels to user units.
3327       * @return float adjusting factor to convert pixels to user units.
3328       * @author Nicola Asuni
3329       * @public
3330       * @since 1.5.2
3331       */
3332  	public function getImageScale() {
3333          return $this->imgscale;
3334      }
3335  
3336      /**
3337       * Returns an array of page dimensions:
3338       * <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 user units</li><li>$this->pagedim[$this->page]['hk'] = page height in user units</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><li>$this->pagedim[$this->page]['Rotate'] = The number of degrees by which the page shall be rotated clockwise when displayed or printed. The value shall be a multiple of 90.</li><li>$this->pagedim[$this->page]['PZ'] = The page's preferred zoom (magnification) factor.</li><li>$this->pagedim[$this->page]['trans'] : the style and duration of the visual transition to use when moving from another page to the given page during a presentation<ul><li>$this->pagedim[$this->page]['trans']['Dur'] = The page's display duration (also called its advance timing): the maximum length of time, in seconds, that the page shall be displayed during presentations before the viewer application shall automatically advance to the next page.</li><li>$this->pagedim[$this->page]['trans']['S'] = transition style : Split, Blinds, Box, Wipe, Dissolve, Glitter, R, Fly, Push, Cover, Uncover, Fade</li><li>$this->pagedim[$this->page]['trans']['D'] = The duration of the transition effect, in seconds.</li><li>$this->pagedim[$this->page]['trans']['Dm'] = (Split and Blinds transition styles only) The dimension in which the specified transition effect shall occur: H = Horizontal, V = Vertical. Default value: H.</li><li>$this->pagedim[$this->page]['trans']['M'] = (Split, Box and Fly transition styles only) The direction of motion for the specified transition effect: I = Inward from the edges of the page, O = Outward from the center of the pageDefault value: I.</li><li>$this->pagedim[$this->page]['trans']['Di'] = (Wipe, Glitter, Fly, Cover, Uncover and Push transition styles only) The direction in which the specified transition effect shall moves, expressed in degrees counterclockwise starting from a left-to-right direction. If the value is a number, it shall be one of: 0 = Left to right, 90 = Bottom to top (Wipe only), 180 = Right to left (Wipe only), 270 = Top to bottom, 315 = Top-left to bottom-right (Glitter only). If the value is a name, it shall be None, which is relevant only for the Fly transition when the value of SS is not 1.0. Default value: 0.</li><li>$this->pagedim[$this->page]['trans']['SS'] = (Fly transition style only) The starting or ending scale at which the changes shall be drawn. If M specifies an inward transition, the scale of the changes drawn shall progress from SS to 1.0 over the course of the transition. If M specifies an outward transition, the scale of the changes drawn shall progress from 1.0 to SS over the course of the transition. Default: 1.0. </li><li>$this->pagedim[$this->page]['trans']['B'] = (Fly transition style only) If true, the area that shall be flown in is rectangular and opaque. Default: false.</li></ul></li><li>$this->pagedim[$this->page]['MediaBox'] : the boundaries of the physical medium on which the page shall be displayed or printed<ul><li>$this->pagedim[$this->page]['MediaBox']['llx'] = lower-left x coordinate in points</li><li>$this->pagedim[$this->page]['MediaBox']['lly'] = lower-left y coordinate in points</li><li>$this->pagedim[$this->page]['MediaBox']['urx'] = upper-right x coordinate in points</li><li>$this->pagedim[$this->page]['MediaBox']['ury'] = upper-right y coordinate in points</li></ul></li><li>$this->pagedim[$this->page]['CropBox'] : the visible region of default user space<ul><li>$this->pagedim[$this->page]['CropBox']['llx'] = lower-left x coordinate in points</li><li>$this->pagedim[$this->page]['CropBox']['lly'] = lower-left y coordinate in points</li><li>$this->pagedim[$this->page]['CropBox']['urx'] = upper-right x coordinate in points</li><li>$this->pagedim[$this->page]['CropBox']['ury'] = upper-right y coordinate in points</li></ul></li><li>$this->pagedim[$this->page]['BleedBox'] : the region to which the contents of the page shall be clipped when output in a production environment<ul><li>$this->pagedim[$this->page]['BleedBox']['llx'] = lower-left x coordinate in points</li><li>$this->pagedim[$this->page]['BleedBox']['lly'] = lower-left y coordinate in points</li><li>$this->pagedim[$this->page]['BleedBox']['urx'] = upper-right x coordinate in points</li><li>$this->pagedim[$this->page]['BleedBox']['ury'] = upper-right y coordinate in points</li></ul></li><li>$this->pagedim[$this->page]['TrimBox'] : the intended dimensions of the finished page after trimming<ul><li>$this->pagedim[$this->page]['TrimBox']['llx'] = lower-left x coordinate in points</li><li>$this->pagedim[$this->page]['TrimBox']['lly'] = lower-left y coordinate in points</li><li>$this->pagedim[$this->page]['TrimBox']['urx'] = upper-right x coordinate in points</li><li>$this->pagedim[$this->page]['TrimBox']['ury'] = upper-right y coordinate in points</li></ul></li><li>$this->pagedim[$this->page]['ArtBox'] : the extent of the page's meaningful content<ul><li>$this->pagedim[$this->page]['ArtBox']['llx'] = lower-left x coordinate in points</li><li>$this->pagedim[$this->page]['ArtBox']['lly'] = lower-left y coordinate in points</li><li>$this->pagedim[$this->page]['ArtBox']['urx'] = upper-right x coordinate in points</li><li>$this->pagedim[$this->page]['ArtBox']['ury'] = upper-right y coordinate in points</li></ul></li></ul>
3339       * @param $pagenum (int) page number (empty = current page)
3340       * @return array of page dimensions.
3341       * @author Nicola Asuni
3342       * @public
3343       * @since 4.5.027 (2009-03-16)
3344       */
3345  	public function getPageDimensions($pagenum='') {
3346          if (empty($pagenum)) {
3347              $pagenum = $this->page;
3348          }
3349          return $this->pagedim[$pagenum];
3350      }
3351  
3352      /**
3353       * Returns the page width in units.
3354       * @param $pagenum (int) page number (empty = current page)
3355       * @return int page width.
3356       * @author Nicola Asuni
3357       * @public
3358       * @since 1.5.2
3359       * @see getPageDimensions()
3360       */
3361  	public function getPageWidth($pagenum='') {
3362          if (empty($pagenum)) {
3363              return $this->w;
3364          }
3365          return $this->pagedim[$pagenum]['w'];
3366      }
3367  
3368      /**
3369       * Returns the page height in units.
3370       * @param $pagenum (int) page number (empty = current page)
3371       * @return int page height.
3372       * @author Nicola Asuni
3373       * @public
3374       * @since 1.5.2
3375       * @see getPageDimensions()
3376       */
3377  	public function getPageHeight($pagenum='') {
3378          if (empty($pagenum)) {
3379              return $this->h;
3380          }
3381          return $this->pagedim[$pagenum]['h'];
3382      }
3383  
3384      /**
3385       * Returns the page break margin.
3386       * @param $pagenum (int) page number (empty = current page)
3387       * @return int page break margin.
3388       * @author Nicola Asuni
3389       * @public
3390       * @since 1.5.2
3391       * @see getPageDimensions()
3392       */
3393  	public function getBreakMargin($pagenum='') {
3394          if (empty($pagenum)) {
3395              return $this->bMargin;
3396          }
3397          return $this->pagedim[$pagenum]['bm'];
3398      }
3399  
3400      /**
3401       * Returns the scale factor (number of points in user unit).
3402       * @return int scale factor.
3403       * @author Nicola Asuni
3404       * @public
3405       * @since 1.5.2
3406       */
3407  	public function getScaleFactor() {
3408          return $this->k;
3409      }
3410  
3411      /**
3412       * Defines the left, top and right margins.
3413       * @param $left (float) Left margin.
3414       * @param $top (float) Top margin.
3415       * @param $right (float) Right margin. Default value is the left one.
3416       * @param $keepmargins (boolean) if true overwrites the default page margins
3417       * @public
3418       * @since 1.0
3419       * @see SetLeftMargin(), SetTopMargin(), SetRightMargin(), SetAutoPageBreak()
3420       */
3421  	public function SetMargins($left, $top, $right=-1, $keepmargins=false) {
3422          //Set left, top and right margins
3423          $this->lMargin = $left;
3424          $this->tMargin = $top;
3425          if ($right == -1) {
3426              $right = $left;
3427          }
3428          $this->rMargin = $right;
3429          if ($keepmargins) {
3430              // overwrite original values
3431              $this->original_lMargin = $this->lMargin;
3432              $this->original_rMargin = $this->rMargin;
3433          }
3434      }
3435  
3436      /**
3437       * Defines the left margin. The method can be called before creating the first page. If the current abscissa gets out of page, it is brought back to the margin.
3438       * @param $margin (float) The margin.
3439       * @public
3440       * @since 1.4
3441       * @see SetTopMargin(), SetRightMargin(), SetAutoPageBreak(), SetMargins()
3442       */
3443  	public function SetLeftMargin($margin) {
3444          //Set left margin
3445          $this->lMargin = $margin;
3446          if (($this->page > 0) AND ($this->x < $margin)) {
3447              $this->x = $margin;
3448          }
3449      }
3450  
3451      /**
3452       * Defines the top margin. The method can be called before creating the first page.
3453       * @param $margin (float) The margin.
3454       * @public
3455       * @since 1.5
3456       * @see SetLeftMargin(), SetRightMargin(), SetAutoPageBreak(), SetMargins()
3457       */
3458  	public function SetTopMargin($margin) {
3459          //Set top margin
3460          $this->tMargin = $margin;
3461          if (($this->page > 0) AND ($this->y < $margin)) {
3462              $this->y = $margin;
3463          }
3464      }
3465  
3466      /**
3467       * Defines the right margin. The method can be called before creating the first page.
3468       * @param $margin (float) The margin.
3469       * @public
3470       * @since 1.5
3471       * @see SetLeftMargin(), SetTopMargin(), SetAutoPageBreak(), SetMargins()
3472       */
3473  	public function SetRightMargin($margin) {
3474          $this->rMargin = $margin;
3475          if (($this->page > 0) AND ($this->x > ($this->w - $margin))) {
3476              $this->x = $this->w - $margin;
3477          }
3478      }
3479  
3480      /**
3481       * Set the same internal Cell padding for top, right, bottom, left-
3482       * @param $pad (float) internal padding.
3483       * @public
3484       * @since 2.1.000 (2008-01-09)
3485       * @see getCellPaddings(), setCellPaddings()
3486       */
3487  	public function SetCellPadding($pad) {
3488          if ($pad >= 0) {
3489              $this->cell_padding['L'] = $pad;
3490              $this->cell_padding['T'] = $pad;
3491              $this->cell_padding['R'] = $pad;
3492              $this->cell_padding['B'] = $pad;
3493          }
3494      }
3495  
3496      /**
3497       * Set the internal Cell paddings.
3498       * @param $left (float) left padding
3499       * @param $top (float) top padding
3500       * @param $right (float) right padding
3501       * @param $bottom (float) bottom padding
3502       * @public
3503       * @since 5.9.000 (2010-10-03)
3504       * @see getCellPaddings(), SetCellPadding()
3505       */
3506  	public function setCellPaddings($left='', $top='', $right='', $bottom='') {
3507          if (($left !== '') AND ($left >= 0)) {
3508              $this->cell_padding['L'] = $left;
3509          }
3510          if (($top !== '') AND ($top >= 0)) {
3511              $this->cell_padding['T'] = $top;
3512          }
3513          if (($right !== '') AND ($right >= 0)) {
3514              $this->cell_padding['R'] = $right;
3515          }
3516          if (($bottom !== '') AND ($bottom >= 0)) {
3517              $this->cell_padding['B'] = $bottom;
3518          }
3519      }
3520  
3521      /**
3522       * Get the internal Cell padding array.
3523       * @return array of padding values
3524       * @public
3525       * @since 5.9.000 (2010-10-03)
3526       * @see setCellPaddings(), SetCellPadding()
3527       */
3528  	public function getCellPaddings() {
3529          return $this->cell_padding;
3530      }
3531  
3532      /**
3533       * Set the internal Cell margins.
3534       * @param $left (float) left margin
3535       * @param $top (float) top margin
3536       * @param $right (float) right margin
3537       * @param $bottom (float) bottom margin
3538       * @public
3539       * @since 5.9.000 (2010-10-03)
3540       * @see getCellMargins()
3541       */
3542  	public function setCellMargins($left='', $top='', $right='', $bottom='') {
3543          if (($left !== '') AND ($left >= 0)) {
3544              $this->cell_margin['L'] = $left;
3545          }
3546          if (($top !== '') AND ($top >= 0)) {
3547              $this->cell_margin['T'] = $top;
3548          }
3549          if (($right !== '') AND ($right >= 0)) {
3550              $this->cell_margin['R'] = $right;
3551          }
3552          if (($bottom !== '') AND ($bottom >= 0)) {
3553              $this->cell_margin['B'] = $bottom;
3554          }
3555      }
3556  
3557      /**
3558       * Get the internal Cell margin array.
3559       * @return array of margin values
3560       * @public
3561       * @since 5.9.000 (2010-10-03)
3562       * @see setCellMargins()
3563       */
3564  	public function getCellMargins() {
3565          return $this->cell_margin;
3566      }
3567  
3568      /**
3569       * Adjust the internal Cell padding array to take account of the line width.
3570       * @param $brd (mixed) Indicates if borders must be drawn around the cell. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul> or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
3571       * @return array of adjustments
3572       * @public
3573       * @since 5.9.000 (2010-10-03)
3574       */
3575  	protected function adjustCellPadding($brd=0) {
3576          if (empty($brd)) {
3577              return;
3578          }
3579          if (is_string($brd)) {
3580              // convert string to array
3581              $slen = strlen($brd);
3582              $newbrd = array();
3583              for ($i = 0; $i < $slen; ++$i) {
3584                  $newbrd[$brd[$i]] = true;
3585              }
3586              $brd = $newbrd;
3587          } elseif (($brd === 1) OR ($brd === true) OR (is_numeric($brd) AND (intval($brd) > 0))) {
3588              $brd = array('LRTB' => true);
3589          }
3590          if (!is_array($brd)) {
3591              return;
3592          }
3593          // store current cell padding
3594          $cp = $this->cell_padding;
3595          // select border mode
3596          if (isset($brd['mode'])) {
3597              $mode = $brd['mode'];
3598              unset($brd['mode']);
3599          } else {
3600              $mode = 'normal';
3601          }
3602          // process borders
3603          foreach ($brd as $border => $style) {
3604              $line_width = $this->LineWidth;
3605              if (is_array($style) AND isset($style['width'])) {
3606                  // get border width
3607                  $line_width = $style['width'];
3608              }
3609              $adj = 0; // line width inside the cell
3610              switch ($mode) {
3611                  case 'ext': {
3612                      $adj = 0;
3613                      break;
3614                  }
3615                  case 'int': {
3616                      $adj = $line_width;
3617                      break;
3618                  }
3619                  case 'normal':
3620                  default: {
3621                      $adj = ($line_width / 2);
3622                      break;
3623                  }
3624              }
3625              // correct internal cell padding if required to avoid overlap between text and lines
3626              if ((strpos($border,'T') !== false) AND ($this->cell_padding['T'] < $adj)) {
3627                  $this->cell_padding['T'] = $adj;
3628              }
3629              if ((strpos($border,'R') !== false) AND ($this->cell_padding['R'] < $adj)) {
3630                  $this->cell_padding['R'] = $adj;
3631              }
3632              if ((strpos($border,'B') !== false) AND ($this->cell_padding['B'] < $adj)) {
3633                  $this->cell_padding['B'] = $adj;
3634              }
3635              if ((strpos($border,'L') !== false) AND ($this->cell_padding['L'] < $adj)) {
3636                  $this->cell_padding['L'] = $adj;
3637              }
3638          }
3639          return array('T' => ($this->cell_padding['T'] - $cp['T']), 'R' => ($this->cell_padding['R'] - $cp['R']), 'B' => ($this->cell_padding['B'] - $cp['B']), 'L' => ($this->cell_padding['L'] - $cp['L']));
3640      }
3641  
3642      /**
3643       * Enables or disables the automatic page breaking mode. When enabling, the second parameter is the distance from the bottom of the page that defines the triggering limit. By default, the mode is on and the margin is 2 cm.
3644       * @param $auto (boolean) Boolean indicating if mode should be on or off.
3645       * @param $margin (float) Distance from the bottom of the page.
3646       * @public
3647       * @since 1.0
3648       * @see Cell(), MultiCell(), AcceptPageBreak()
3649       */
3650  	public function SetAutoPageBreak($auto, $margin=0) {
3651          $this->AutoPageBreak = $auto ? true : false;
3652          $this->bMargin = $margin;
3653          $this->PageBreakTrigger = $this->h - $margin;
3654      }
3655  
3656      /**
3657       * Return the auto-page-break mode (true or false).
3658       * @return boolean auto-page-break mode
3659       * @public
3660       * @since 5.9.088
3661       */
3662  	public function getAutoPageBreak() {
3663          return $this->AutoPageBreak;
3664      }
3665  
3666      /**
3667       * Defines the way the document is to be displayed by the viewer.
3668       * @param $zoom (mixed) The zoom to use. It can be one of the following string values or a number indicating the zooming factor to use. <ul><li>fullpage: displays the entire page on screen </li><li>fullwidth: uses maximum width of window</li><li>real: uses real size (equivalent to 100% zoom)</li><li>default: uses viewer default mode</li></ul>
3669       * @param $layout (string) The page layout. Possible values are:<ul><li>SinglePage Display one page at a time</li><li>OneColumn Display the pages in one column</li><li>TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left</li><li>TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right</li><li>TwoPageLeft (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left</li><li>TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right</li></ul>
3670       * @param $mode (string) A name object specifying how the document should be displayed when opened:<ul><li>UseNone Neither document outline nor thumbnail images visible</li><li>UseOutlines Document outline visible</li><li>UseThumbs Thumbnail images visible</li><li>FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible</li><li>UseOC (PDF 1.5) Optional content group panel visible</li><li>UseAttachments (PDF 1.6) Attachments panel visible</li></ul>
3671       * @public
3672       * @since 1.2
3673       */
3674  	public function SetDisplayMode($zoom, $layout='SinglePage', $mode='UseNone') {
3675          if (($zoom == 'fullpage') OR ($zoom == 'fullwidth') OR ($zoom == 'real') OR ($zoom == 'default') OR (!is_string($zoom))) {
3676              $this->ZoomMode = $zoom;
3677          } else {
3678              $this->Error('Incorrect zoom display mode: '.$zoom);
3679          }
3680          switch ($layout) {
3681              case 'default':
3682              case 'single':
3683              case 'SinglePage': {
3684                  $this->LayoutMode = 'SinglePage';
3685                  break;
3686              }
3687              case 'continuous':
3688              case 'OneColumn': {
3689                  $this->LayoutMode = 'OneColumn';
3690                  break;
3691              }
3692              case 'two':
3693              case 'TwoColumnLeft': {
3694                  $this->LayoutMode = 'TwoColumnLeft';
3695                  break;
3696              }
3697              case 'TwoColumnRight': {
3698                  $this->LayoutMode = 'TwoColumnRight';
3699                  break;
3700              }
3701              case 'TwoPageLeft': {
3702                  $this->LayoutMode = 'TwoPageLeft';
3703                  break;
3704              }
3705              case 'TwoPageRight': {
3706                  $this->LayoutMode = 'TwoPageRight';
3707                  break;
3708              }
3709              default: {
3710                  $this->LayoutMode = 'SinglePage';
3711              }
3712          }
3713          switch ($mode) {
3714              case 'UseNone': {
3715                  $this->PageMode = 'UseNone';
3716                  break;
3717              }
3718              case 'UseOutlines': {
3719                  $this->PageMode = 'UseOutlines';
3720                  break;
3721              }
3722              case 'UseThumbs': {
3723                  $this->PageMode = 'UseThumbs';
3724                  break;
3725              }
3726              case 'FullScreen': {
3727                  $this->PageMode = 'FullScreen';
3728                  break;
3729              }
3730              case 'UseOC': {
3731                  $this->PageMode = 'UseOC';
3732                  break;
3733              }
3734              case '': {
3735                  $this->PageMode = 'UseAttachments';
3736                  break;
3737              }
3738              default: {
3739                  $this->PageMode = 'UseNone';
3740              }
3741          }
3742      }
3743  
3744      /**
3745       * Activates or deactivates page compression. When activated, the internal representation of each page is compressed, which leads to a compression ratio of about 2 for the resulting document. Compression is on by default.
3746       * Note: the Zlib extension is required for this feature. If not present, compression will be turned off.
3747       * @param $compress (boolean) Boolean indicating if compression must be enabled.
3748       * @public
3749       * @since 1.4
3750       */
3751  	public function SetCompression($compress=true) {
3752          if (function_exists('gzcompress')) {
3753              $this->compress = $compress ? true : false;
3754          } else {
3755              $this->compress = false;
3756          }
3757      }
3758  
3759      /**
3760       * Set flag to force sRGB_IEC61966-2.1 black scaled ICC color profile for the whole document.
3761       * @param $mode (boolean) If true force sRGB output intent.
3762       * @public
3763       * @since 5.9.121 (2011-09-28)
3764       */
3765  	public function setSRGBmode($mode=false) {
3766          $this->force_srgb = $mode ? true : false;
3767      }
3768  
3769      /**
3770       * Turn on/off Unicode mode for document information dictionary (meta tags).
3771       * This has effect only when unicode mode is set to false.
3772       * @param $unicode (boolean) if true set the meta information in Unicode
3773       * @since 5.9.027 (2010-12-01)
3774       * @public
3775       */
3776  	public function SetDocInfoUnicode($unicode=true) {
3777          $this->docinfounicode = $unicode ? true : false;
3778      }
3779  
3780      /**
3781       * Defines the title of the document.
3782       * @param $title (string) The title.
3783       * @public
3784       * @since 1.2
3785       * @see SetAuthor(), SetCreator(), SetKeywords(), SetSubject()
3786       */
3787  	public function SetTitle($title) {
3788          $this->title = $title;
3789      }
3790  
3791      /**
3792       * Defines the subject of the document.
3793       * @param $subject (string) The subject.
3794       * @public
3795       * @since 1.2
3796       * @see SetAuthor(), SetCreator(), SetKeywords(), SetTitle()
3797       */
3798  	public function SetSubject($subject) {
3799          $this->subject = $subject;
3800      }
3801  
3802      /**
3803       * Defines the author of the document.
3804       * @param $author (string) The name of the author.
3805       * @public
3806       * @since 1.2
3807       * @see SetCreator(), SetKeywords(), SetSubject(), SetTitle()
3808       */
3809  	public function SetAuthor($author) {
3810          $this->author = $author;
3811      }
3812  
3813      /**
3814       * Associates keywords with the document, generally in the form 'keyword1 keyword2 ...'.
3815       * @param $keywords (string) The list of keywords.
3816       * @public
3817       * @since 1.2
3818       * @see SetAuthor(), SetCreator(), SetSubject(), SetTitle()
3819       */
3820  	public function SetKeywords($keywords) {
3821          $this->keywords = $keywords;
3822      }
3823  
3824      /**
3825       * Defines the creator of the document. This is typically the name of the application that generates the PDF.
3826       * @param $creator (string) The name of the creator.
3827       * @public
3828       * @since 1.2
3829       * @see SetAuthor(), SetKeywords(), SetSubject(), SetTitle()
3830       */
3831  	public function SetCreator($creator) {
3832          $this->creator = $creator;
3833      }
3834  
3835      /**
3836       * This method is automatically called in case of fatal error; it simply outputs the message and halts the execution. An inherited class may override it to customize the error handling but should always halt the script, or the resulting document would probably be invalid.
3837       * 2004-06-11 :: Nicola Asuni : changed bold tag with strong
3838       * @param $msg (string) The error message
3839       * @public
3840       * @since 1.0
3841       */
3842  	public function Error($msg) {
3843          // unset all class variables
3844          $this->_destroy(true);
3845          $phpmainver = PHP_VERSION;
3846          // exit program and print error
3847          if ((intval($phpmainver[0]) < 5) OR !defined('K_TCPDF_THROW_EXCEPTION_ERROR') OR !K_TCPDF_THROW_EXCEPTION_ERROR) {
3848              die('<strong>TCPDF ERROR: </strong>'.$msg);
3849          } else {
3850              throw new Exception('TCPDF ERROR: '.$msg);
3851          }
3852      }
3853  
3854      /**
3855       * This method begins the generation of the PDF document.
3856       * It is not necessary to call it explicitly because AddPage() does it automatically.
3857       * Note: no page is created by this method
3858       * @public
3859       * @since 1.0
3860       * @see AddPage(), Close()
3861       */
3862  	public function Open() {
3863          $this->state = 1;
3864      }
3865  
3866      /**
3867       * Terminates the PDF document.
3868       * It is not necessary to call this method explicitly because Output() does it automatically.
3869       * If the document contains no page, AddPage() is called to prevent from getting an invalid document.
3870       * @public
3871       * @since 1.0
3872       * @see Open(), Output()
3873       */
3874  	public function Close() {
3875          if ($this->state == 3) {
3876              return;
3877          }
3878          if ($this->page == 0) {
3879              $this->AddPage();
3880          }
3881          $this->endLayer();
3882          if ($this->tcpdflink) {
3883              // save current graphic settings
3884              $gvars = $this->getGraphicVars();
3885              $this->setEqualColumns();
3886              $this->lastpage(true);
3887              $this->SetAutoPageBreak(false);
3888              $this->x = 0;
3889              $this->y = $this->h - (1 / $this->k);
3890              $this->lMargin = 0;
3891              $this->_out('q');
3892              $font = defined('PDF_FONT_NAME_MAIN')?PDF_FONT_NAME_MAIN:'helvetica';
3893              $this->SetFont($font, '', 1);
3894              $this->setTextRenderingMode(0, false, false);
3895              $msg = "\x50\x6f\x77\x65\x72\x65\x64\x20\x62\x79\x20\x54\x43\x50\x44\x46\x20\x28\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67\x29";
3896              $lnk = "\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67";
3897              $this->Cell(0, 0, $msg, 0, 0, 'L', 0, $lnk, 0, false, 'D', 'B');
3898              $this->_out('Q');
3899              // restore graphic settings
3900              $this->setGraphicVars($gvars);
3901          }
3902          // close page
3903          $this->endPage();
3904          // close document
3905          $this->_enddoc();
3906          // unset all class variables (except critical ones)
3907          $this->_destroy(false);
3908      }
3909  
3910      /**
3911       * Move pointer at the specified document page and update page dimensions.
3912       * @param $pnum (int) page number (1 ... numpages)
3913       * @param $resetmargins (boolean) if true reset left, right, top margins and Y position.
3914       * @public
3915       * @since 2.1.000 (2008-01-07)
3916       * @see getPage(), lastpage(), getNumPages()
3917       */
3918  	public function setPage($pnum, $resetmargins=false) {
3919          if (($pnum == $this->page) AND ($this->state == 2)) {
3920              return;
3921          }
3922          if (($pnum > 0) AND ($pnum <= $this->numpages)) {
3923              $this->state = 2;
3924              // save current graphic settings
3925              //$gvars = $this->getGraphicVars();
3926              $oldpage = $this->page;
3927              $this->page = $pnum;
3928              $this->wPt = $this->pagedim[$this->page]['w'];
3929              $this->hPt = $this->pagedim[$this->page]['h'];
3930              $this->w = $this->pagedim[$this->page]['wk'];
3931              $this->h = $this->pagedim[$this->page]['hk'];
3932              $this->tMargin = $this->pagedim[$this->page]['tm'];
3933              $this->bMargin = $this->pagedim[$this->page]['bm'];
3934              $this->original_lMargin = $this->pagedim[$this->page]['olm'];
3935              $this->original_rMargin = $this->pagedim[$this->page]['orm'];
3936              $this->AutoPageBreak = $this->pagedim[$this->page]['pb'];
3937              $this->CurOrientation = $this->pagedim[$this->page]['or'];
3938              $this->SetAutoPageBreak($this->AutoPageBreak, $this->bMargin);
3939              // restore graphic settings
3940              //$this->setGraphicVars($gvars);
3941              if ($resetmargins) {
3942                  $this->lMargin = $this->pagedim[$this->page]['olm'];
3943                  $this->rMargin = $this->pagedim[$this->page]['orm'];
3944                  $this->SetY($this->tMargin);
3945              } else {
3946                  // account for booklet mode
3947                  if ($this->pagedim[$this->page]['olm'] != $this->pagedim[$oldpage]['olm']) {
3948                      $deltam = $this->pagedim[$this->page]['olm'] - $this->pagedim[$this->page]['orm'];
3949                      $this->lMargin += $deltam;
3950                      $this->rMargin -= $deltam;
3951                  }
3952              }
3953          } else {
3954              $this->Error('Wrong page number on setPage() function: '.$pnum);
3955          }
3956      }
3957  
3958      /**
3959       * Reset pointer to the last document page.
3960       * @param $resetmargins (boolean) if true reset left, right, top margins and Y position.
3961       * @public
3962       * @since 2.0.000 (2008-01-04)
3963       * @see setPage(), getPage(), getNumPages()
3964       */
3965  	public function lastPage($resetmargins=false) {
3966          $this->setPage($this->getNumPages(), $resetmargins);
3967      }
3968  
3969      /**
3970       * Get current document page number.
3971       * @return int page number
3972       * @public
3973       * @since 2.1.000 (2008-01-07)
3974       * @see setPage(), lastpage(), getNumPages()
3975       */
3976  	public function getPage() {
3977          return $this->page;
3978      }
3979  
3980      /**
3981       * Get the total number of insered pages.
3982       * @return int number of pages
3983       * @public
3984       * @since 2.1.000 (2008-01-07)
3985       * @see setPage(), getPage(), lastpage()
3986       */
3987  	public function getNumPages() {
3988          return $this->numpages;
3989      }
3990  
3991      /**
3992       * Adds a new TOC (Table Of Content) page to the document.
3993       * @param $orientation (string) page orientation.
3994       * @param $format (mixed) The format used for pages. It can be either: one of the string values specified at getPageSizeFromFormat() or an array of parameters specified at setPageFormat().
3995       * @param $keepmargins (boolean) if true overwrites the default page margins with the current margins
3996       * @public
3997       * @since 5.0.001 (2010-05-06)
3998       * @see AddPage(), startPage(), endPage(), endTOCPage()
3999       */
4000  	public function addTOCPage($orientation='', $format='', $keepmargins=false) {
4001          $this->AddPage($orientation, $format, $keepmargins, true);
4002      }
4003  
4004      /**
4005       * Terminate the current TOC (Table Of Content) page
4006       * @public
4007       * @since 5.0.001 (2010-05-06)
4008       * @see AddPage(), startPage(), endPage(), addTOCPage()
4009       */
4010  	public function endTOCPage() {
4011          $this->endPage(true);
4012      }
4013  
4014      /**
4015       * Adds a new page to the document. If a page is already present, the Footer() method is called first to output the footer (if enabled). Then the page is added, the current position set to the top-left corner according to the left and top margins (or top-right if in RTL mode), and Header() is called to display the header (if enabled).
4016       * The origin of the coordinate system is at the top-left corner (or top-right for RTL) and increasing ordinates go downwards.
4017       * @param $orientation (string) page orientation. Possible values are (case insensitive):<ul><li>P or PORTRAIT (default)</li><li>L or LANDSCAPE</li></ul>
4018       * @param $format (mixed) The format used for pages. It can be either: one of the string values specified at getPageSizeFromFormat() or an array of parameters specified at setPageFormat().
4019       * @param $keepmargins (boolean) if true overwrites the default page margins with the current margins
4020       * @param $tocpage (boolean) if true set the tocpage state to true (the added page will be used to display Table Of Content).
4021       * @public
4022       * @since 1.0
4023       * @see startPage(), endPage(), addTOCPage(), endTOCPage(), getPageSizeFromFormat(), setPageFormat()
4024       */
4025  	public function AddPage($orientation='', $format='', $keepmargins=false, $tocpage=false) {
4026          if ($this->inxobj) {
4027              // we are inside an XObject template
4028              return;
4029          }
4030          if (!isset($this->original_lMargin) OR $keepmargins) {
4031              $this->original_lMargin = $this->lMargin;
4032          }
4033          if (!isset($this->original_rMargin) OR $keepmargins) {
4034              $this->original_rMargin = $this->rMargin;
4035          }
4036          // terminate previous page
4037          $this->endPage();
4038          // start new page
4039          $this->startPage($orientation, $format, $tocpage);
4040      }
4041  
4042      /**
4043       * Terminate the current page
4044       * @param $tocpage (boolean) if true set the tocpage state to false (end the page used to display Table Of Content).
4045       * @public
4046       * @since 4.2.010 (2008-11-14)
4047       * @see AddPage(), startPage(), addTOCPage(), endTOCPage()
4048       */
4049  	public function endPage($tocpage=false) {
4050          // check if page is already closed
4051          if (($this->page == 0) OR ($this->numpages > $this->page) OR (!$this->pageopen[$this->page])) {
4052              return;
4053          }
4054          // print page footer
4055          $this->setFooter();
4056          // close page
4057          $this->_endpage();
4058          // mark page as closed
4059          $this->pageopen[$this->page] = false;
4060          if ($tocpage) {
4061              $this->tocpage = false;
4062          }
4063      }
4064  
4065      /**
4066       * Starts a new page to the document. The page must be closed using the endPage() function.
4067       * The origin of the coordinate system is at the top-left corner and increasing ordinates go downwards.
4068       * @param $orientation (string) page orientation. Possible values are (case insensitive):<ul><li>P or PORTRAIT (default)</li><li>L or LANDSCAPE</li></ul>
4069       * @param $format (mixed) The format used for pages. It can be either: one of the string values specified at getPageSizeFromFormat() or an array of parameters specified at setPageFormat().
4070       * @param $tocpage (boolean) if true the page is designated to contain the Table-Of-Content.
4071       * @since 4.2.010 (2008-11-14)
4072       * @see AddPage(), endPage(), addTOCPage(), endTOCPage(), getPageSizeFromFormat(), setPageFormat()
4073       * @public
4074       */
4075  	public function startPage($orientation='', $format='', $tocpage=false) {
4076          if ($tocpage) {
4077              $this->tocpage = true;
4078          }
4079          // move page numbers of documents to be attached
4080          if ($this->tocpage) {
4081              // move reference to unexistent pages (used for page attachments)
4082              // adjust outlines
4083              $tmpoutlines = $this->outlines;
4084              foreach ($tmpoutlines as $key => $outline) {
4085                  if ($outline['p'] > $this->numpages) {
4086                      $this->outlines[$key]['p'] = ($outline['p'] + 1);
4087                  }
4088              }
4089              // adjust dests
4090              $tmpdests = $this->dests;
4091              foreach ($tmpdests as $key => $dest) {
4092                  if ($dest['p'] > $this->numpages) {
4093                      $this->dests[$key]['p'] = ($dest['p'] + 1);
4094                  }
4095              }
4096              // adjust links
4097              $tmplinks = $this->links;
4098              foreach ($tmplinks as $key => $link) {
4099                  if ($link[0] > $this->numpages) {
4100                      $this->links[$key][0] = ($link[0] + 1);
4101                  }
4102              }
4103          }
4104          if ($this->numpages > $this->page) {
4105              // this page has been already added
4106              $this->setPage($this->page + 1);
4107              $this->SetY($this->tMargin);
4108              return;
4109          }
4110          // start a new page
4111          if ($this->state == 0) {
4112              $this->Open();
4113          }
4114          ++$this->numpages;
4115          $this->swapMargins($this->booklet);
4116          // save current graphic settings
4117          $gvars = $this->getGraphicVars();
4118          // start new page
4119          $this->_beginpage($orientation, $format);
4120          // mark page as open
4121          $this->pageopen[$this->page] = true;
4122          // restore graphic settings
4123          $this->setGraphicVars($gvars);
4124          // mark this point
4125          $this->setPageMark();
4126          // print page header
4127          $this->setHeader();
4128          // restore graphic settings
4129          $this->setGraphicVars($gvars);
4130          // mark this point
4131          $this->setPageMark();
4132          // print table header (if any)
4133          $this->setTableHeader();
4134          // set mark for empty page check
4135          $this->emptypagemrk[$this->page]= $this->pagelen[$this->page];
4136      }
4137  
4138      /**
4139       * Set start-writing mark on current page stream used to put borders and fills.
4140       * Borders and fills are always created after content and inserted on the position marked by this method.
4141       * This function must be called after calling Image() function for a background image.
4142       * Background images must be always inserted before calling Multicell() or WriteHTMLCell() or WriteHTML() functions.
4143       * @public
4144       * @since 4.0.016 (2008-07-30)
4145       */
4146  	public function setPageMark() {
4147          $this->intmrk[$this->page] = $this->pagelen[$this->page];
4148          $this->bordermrk[$this->page] = $this->intmrk[$this->page];
4149          $this->setContentMark();
4150      }
4151  
4152      /**
4153       * Set start-writing mark on selected page.
4154       * Borders and fills are always created after content and inserted on the position marked by this method.
4155       * @param $page (int) page number (default is the current page)
4156       * @protected
4157       * @since 4.6.021 (2009-07-20)
4158       */
4159  	protected function setContentMark($page=0) {
4160          if ($page <= 0) {
4161              $page = $this->page;
4162          }
4163          if (isset($this->footerlen[$page])) {
4164              $this->cntmrk[$page] = $this->pagelen[$page] - $this->footerlen[$page];
4165          } else {
4166              $this->cntmrk[$page] = $this->pagelen[$page];
4167          }
4168      }
4169  
4170      /**
4171       * Set header data.
4172       * @param $ln (string) header image logo
4173       * @param $lw (string) header image logo width in mm
4174       * @param $ht (string) string to print as title on document header
4175       * @param $hs (string) string to print on document header
4176       * @param $tc (array) RGB array color for text.
4177       * @param $lc (array) RGB array color for line.
4178       * @public
4179       */
4180  	public function setHeaderData($ln='', $lw=0, $ht='', $hs='', $tc=array(0,0,0), $lc=array(0,0,0)) {
4181          $this->header_logo = $ln;
4182          $this->header_logo_width = $lw;
4183          $this->header_title = $ht;
4184          $this->header_string = $hs;
4185          $this->header_text_color = $tc;
4186          $this->header_line_color = $lc;
4187      }
4188  
4189      /**
4190       * Set footer data.
4191       * @param $tc (array) RGB array color for text.
4192       * @param $lc (array) RGB array color for line.
4193       * @public
4194       */
4195  	public function setFooterData($tc=array(0,0,0), $lc=array(0,0,0)) {
4196          $this->footer_text_color = $tc;
4197          $this->footer_line_color = $lc;
4198      }
4199  
4200      /**
4201       * Returns header data:
4202       * <ul><li>$ret['logo'] = logo image</li><li>$ret['logo_width'] = width of the image logo in user units</li><li>$ret['title'] = header title</li><li>$ret['string'] = header description string</li></ul>
4203       * @return array()
4204       * @public
4205       * @since 4.0.012 (2008-07-24)
4206       */
4207  	public function getHeaderData() {
4208          $ret = array();
4209          $ret['logo'] = $this->header_logo;
4210          $ret['logo_width'] = $this->header_logo_width;
4211          $ret['title'] = $this->header_title;
4212          $ret['string'] = $this->header_string;
4213          $ret['text_color'] = $this->header_text_color;
4214          $ret['line_color'] = $this->header_line_color;
4215          return $ret;
4216      }
4217  
4218      /**
4219       * Set header margin.
4220       * (minimum distance between header and top page margin)
4221       * @param $hm (int) distance in user units
4222       * @public
4223       */
4224  	public function setHeaderMargin($hm=10) {
4225          $this->header_margin = $hm;
4226      }
4227  
4228      /**
4229       * Returns header margin in user units.
4230       * @return float
4231       * @since 4.0.012 (2008-07-24)
4232       * @public
4233       */
4234  	public function getHeaderMargin() {
4235          return $this->header_margin;
4236      }
4237  
4238      /**
4239       * Set footer margin.
4240       * (minimum distance between footer and bottom page margin)
4241       * @param $fm (int) distance in user units
4242       * @public
4243       */
4244  	public function setFooterMargin($fm=10) {
4245          $this->footer_margin = $fm;
4246      }
4247  
4248      /**
4249       * Returns footer margin in user units.
4250       * @return float
4251       * @since 4.0.012 (2008-07-24)
4252       * @public
4253       */
4254  	public function getFooterMargin() {
4255          return $this->footer_margin;
4256      }
4257      /**
4258       * Set a flag to print page header.
4259       * @param $val (boolean) set to true to print the page header (default), false otherwise.
4260       * @public
4261       */
4262  	public function setPrintHeader($val=true) {
4263          $this->print_header = $val ? true : false;
4264      }
4265  
4266      /**
4267       * Set a flag to print page footer.
4268       * @param $val (boolean) set to true to print the page footer (default), false otherwise.
4269       * @public
4270       */
4271  	public function setPrintFooter($val=true) {
4272          $this->print_footer = $val ? true : false;
4273      }
4274  
4275      /**
4276       * Return the right-bottom (or left-bottom for RTL) corner X coordinate of last inserted image
4277       * @return float
4278       * @public
4279       */
4280  	public function getImageRBX() {
4281          return $this->img_rb_x;
4282      }
4283  
4284      /**
4285       * Return the right-bottom (or left-bottom for RTL) corner Y coordinate of last inserted image
4286       * @return float
4287       * @public
4288       */
4289  	public function getImageRBY() {
4290          return $this->img_rb_y;
4291      }
4292  
4293      /**
4294       * Reset the xobject template used by Header() method.
4295       * @public
4296       */
4297  	public function resetHeaderTemplate() {
4298          $this->header_xobjid = -1;
4299      }
4300  
4301      /**
4302       * Set a flag to automatically reset the xobject template used by Header() method at each page.
4303       * @param $val (boolean) set to true to reset Header xobject template at each page, false otherwise.
4304       * @public
4305       */
4306  	public function setHeaderTemplateAutoreset($val=true) {
4307          $this->header_xobj_autoreset = $val ? true : false;
4308      }
4309  
4310      /**
4311       * This method is used to render the page header.
4312       * It is automatically called by AddPage() and could be overwritten in your own inherited class.
4313       * @public
4314       */
4315  	public function Header() {
4316          if ($this->header_xobjid < 0) {
4317              // start a new XObject Template
4318              $this->header_xobjid = $this->startTemplate($this->w, $this->tMargin);
4319              $headerfont = $this->getHeaderFont();
4320              $headerdata = $this->getHeaderData();
4321              $this->y = $this->header_margin;
4322              if ($this->rtl) {
4323                  $this->x = $this->w - $this->original_rMargin;
4324              } else {
4325                  $this->x = $this->original_lMargin;
4326              }
4327              if (($headerdata['logo']) AND ($headerdata['logo'] != K_BLANK_IMAGE)) {
4328                  $imgtype = $this->getImageFileType(K_PATH_IMAGES.$headerdata['logo']);
4329                  if (($imgtype == 'eps') OR ($imgtype == 'ai')) {
4330                      $this->ImageEps(K_PATH_IMAGES.$headerdata['logo'], '', '', $headerdata['logo_width']);
4331                  } elseif ($imgtype == 'svg') {
4332                      $this->ImageSVG(K_PATH_IMAGES.$headerdata['logo'], '', '', $headerdata['logo_width']);
4333                  } else {
4334                      $this->Image(K_PATH_IMAGES.$headerdata['logo'], '', '', $headerdata['logo_width']);
4335                  }
4336                  $imgy = $this->getImageRBY();
4337              } else {
4338                  $imgy = $this->y;
4339              }
4340              $cell_height = round(($this->cell_height_ratio * $headerfont[2]) / $this->k, 2);
4341              // set starting margin for text data cell
4342              if ($this->getRTL()) {
4343                  $header_x = $this->original_rMargin + ($headerdata['logo_width'] * 1.1);
4344              } else {
4345                  $header_x = $this->original_lMargin + ($headerdata['logo_width'] * 1.1);
4346              }
4347              $cw = $this->w - $this->original_lMargin - $this->original_rMargin - ($headerdata['logo_width'] * 1.1);
4348              $this->SetTextColorArray($this->header_text_color);
4349              // header title
4350              $this->SetFont($headerfont[0], 'B', $headerfont[2] + 1);
4351              $this->SetX($header_x);
4352              $this->Cell($cw, $cell_height, $headerdata['title'], 0, 1, '', 0, '', 0);
4353              // header string
4354              $this->SetFont($headerfont[0], $headerfont[1], $headerfont[2]);
4355              $this->SetX($header_x);
4356              $this->MultiCell($cw, $cell_height, $headerdata['string'], 0, '', 0, 1, '', '', true, 0, false, true, 0, 'T', false);
4357              // print an ending header line
4358              $this->SetLineStyle(array('width' => 0.85 / $this->k, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => $headerdata['line_color']));
4359              $this->SetY((2.835 / $this->k) + max($imgy, $this->y));
4360              if ($this->rtl) {
4361                  $this->SetX($this->original_rMargin);
4362              } else {
4363                  $this->SetX($this->original_lMargin);
4364              }
4365              $this->Cell(($this->w - $this->original_lMargin - $this->original_rMargin), 0, '', 'T', 0, 'C');
4366              $this->endTemplate();
4367          }
4368          // print header template
4369          $x = 0;
4370          $dx = 0;
4371          if (!$this->header_xobj_autoreset AND $this->booklet AND (($this->page % 2) == 0)) {
4372              // adjust margins for booklet mode
4373              $dx = ($this->original_lMargin - $this->original_rMargin);
4374          }
4375          if ($this->rtl) {
4376              $x = $this->w + $dx;
4377          } else {
4378              $x = 0 + $dx;
4379          }
4380          $this->printTemplate($this->header_xobjid, $x, 0, 0, 0, '', '', false);
4381          if ($this->header_xobj_autoreset) {
4382              // reset header xobject template at each page
4383              $this->header_xobjid = -1;
4384          }
4385      }
4386  
4387      /**
4388       * This method is used to render the page footer.
4389       * It is automatically called by AddPage() and could be overwritten in your own inherited class.
4390       * @public
4391       */
4392  	public function Footer() {
4393          $cur_y = $this->y;
4394          $this->SetTextColorArray($this->footer_text_color);
4395          //set style for cell border
4396          $line_width = (0.85 / $this->k);
4397          $this->SetLineStyle(array('width' => $line_width, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => $this->footer_line_color));
4398          //print document barcode
4399          $barcode = $this->getBarcode();
4400          if (!empty($barcode)) {
4401              $this->Ln($line_width);
4402              $barcode_width = round(($this->w - $this->original_lMargin - $this->original_rMargin) / 3);
4403              $style = array(
4404                  'position' => $this->rtl?'R':'L',
4405                  'align' => $this->rtl?'R':'L',
4406                  'stretch' => false,
4407                  'fitwidth' => true,
4408                  'cellfitalign' => '',
4409                  'border' => false,
4410                  'padding' => 0,
4411                  'fgcolor' => array(0,0,0),
4412                  'bgcolor' => false,
4413                  'text' => false
4414              );
4415              $this->write1DBarcode($barcode, 'C128', '', $cur_y + $line_width, '', (($this->footer_margin / 3) - $line_width), 0.3, $style, '');
4416          }
4417          $w_page = isset($this->l['w_page']) ? $this->l['w_page'].' ' : '';
4418          if (empty($this->pagegroups)) {
4419              $pagenumtxt = $w_page.$this->getAliasNumPage().' / '.$this->getAliasNbPages();
4420          } else {
4421              $pagenumtxt = $w_page.$this->getPageNumGroupAlias().' / '.$this->getPageGroupAlias();
4422          }
4423          $this->SetY($cur_y);
4424          //Print page number
4425          if ($this->getRTL()) {
4426              $this->SetX($this->original_rMargin);
4427              $this->Cell(0, 0, $pagenumtxt, 'T', 0, 'L');
4428          } else {
4429              $this->SetX($this->original_lMargin);
4430              $this->Cell(0, 0, $this->getAliasRightShift().$pagenumtxt, 'T', 0, 'R');
4431          }
4432      }
4433  
4434      /**
4435       * This method is used to render the page header.
4436       * @protected
4437       * @since 4.0.012 (2008-07-24)
4438       */
4439  	protected function setHeader() {
4440          if (!$this->print_header OR ($this->state != 2)) {
4441              return;
4442          }
4443          $this->InHeader = true;
4444          $this->setGraphicVars($this->default_graphic_vars);
4445          $temp_thead = $this->thead;
4446          $temp_theadMargins = $this->theadMargins;
4447          $lasth = $this->lasth;
4448          $this->_out('q');
4449          $this->rMargin = $this->original_rMargin;
4450          $this->lMargin = $this->original_lMargin;
4451          $this->SetCellPadding(0);
4452          //set current position
4453          if ($this->rtl) {
4454              $this->SetXY($this->original_rMargin, $this->header_margin);
4455          } else {
4456              $this->SetXY($this->original_lMargin, $this->header_margin);
4457          }
4458          $this->SetFont($this->header_font[0], $this->header_font[1], $this->header_font[2]);
4459          $this->Header();
4460          //restore position
4461          if ($this->rtl) {
4462              $this->SetXY($this->original_rMargin, $this->tMargin);
4463          } else {
4464              $this->SetXY($this->original_lMargin, $this->tMargin);
4465          }
4466          $this->_out('Q');
4467          $this->lasth = $lasth;
4468          $this->thead = $temp_thead;
4469          $this->theadMargins = $temp_theadMargins;
4470          $this->newline = false;
4471          $this->InHeader = false;
4472      }
4473  
4474      /**
4475       * This method is used to render the page footer.
4476       * @protected
4477       * @since 4.0.012 (2008-07-24)
4478       */
4479  	protected function setFooter() {
4480          if ($this->state != 2) {
4481              return;
4482          }
4483          $this->InFooter = true;
4484          // save current graphic settings
4485          $gvars = $this->getGraphicVars();
4486          // mark this point
4487          $this->footerpos[$this->page] = $this->pagelen[$this->page];
4488          $this->_out("\n");
4489          if ($this->print_footer) {
4490              $this->setGraphicVars($this->default_graphic_vars);
4491              $this->current_column = 0;
4492              $this->num_columns = 1;
4493              $temp_thead = $this->thead;
4494              $temp_theadMargins = $this->theadMargins;
4495              $lasth = $this->lasth;
4496              $this->_out('q');
4497              $this->rMargin = $this->original_rMargin;
4498              $this->lMargin = $this->original_lMargin;
4499              $this->SetCellPadding(0);
4500              //set current position
4501              $footer_y = $this->h - $this->footer_margin;
4502              if ($this->rtl) {
4503                  $this->SetXY($this->original_rMargin, $footer_y);
4504              } else {
4505                  $this->SetXY($this->original_lMargin, $footer_y);
4506              }
4507              $this->SetFont($this->footer_font[0], $this->footer_font[1], $this->footer_font[2]);
4508              $this->Footer();
4509              //restore position
4510              if ($this->rtl) {
4511                  $this->SetXY($this->original_rMargin, $this->tMargin);
4512              } else {
4513                  $this->SetXY($this->original_lMargin, $this->tMargin);
4514              }
4515              $this->_out('Q');
4516              $this->lasth = $lasth;
4517              $this->thead = $temp_thead;
4518              $this->theadMargins = $temp_theadMargins;
4519          }
4520          // restore graphic settings
4521          $this->setGraphicVars($gvars);
4522          $this->current_column = $gvars['current_column'];
4523          $this->num_columns = $gvars['num_columns'];
4524          // calculate footer length
4525          $this->footerlen[$this->page] = $this->pagelen[$this->page] - $this->footerpos[$this->page] + 1;
4526          $this->InFooter = false;
4527      }
4528  
4529      /**
4530       * Check if we are on the page body (excluding page header and footer).
4531       * @return true if we are not in page header nor in page footer, false otherwise.
4532       * @protected
4533       * @since 5.9.091 (2011-06-15)
4534       */
4535  	protected function inPageBody() {
4536          return (($this->InHeader === false) AND ($this->InFooter === false));
4537      }
4538  
4539      /**
4540       * This method is used to render the table header on new page (if any).
4541       * @protected
4542       * @since 4.5.030 (2009-03-25)
4543       */
4544  	protected function setTableHeader() {
4545          if ($this->num_columns > 1) {
4546              // multi column mode
4547              return;
4548          }
4549          if (isset($this->theadMargins['top'])) {
4550              // restore the original top-margin
4551              $this->tMargin = $this->theadMargins['top'];
4552              $this->pagedim[$this->page]['tm'] = $this->tMargin;
4553              $this->y = $this->tMargin;
4554          }
4555          if (!$this->empty_string($this->thead) AND (!$this->inthead)) {
4556              // set margins
4557              $prev_lMargin = $this->lMargin;
4558              $prev_rMargin = $this->rMargin;
4559              $prev_cell_padding = $this->cell_padding;
4560              $this->lMargin = $this->theadMargins['lmargin'] + ($this->pagedim[$this->page]['olm'] - $this->pagedim[$this->theadMargins['page']]['olm']);
4561              $this->rMargin = $this->theadMargins['rmargin'] + ($this->pagedim[$this->page]['orm'] - $this->pagedim[$this->theadMargins['page']]['orm']);
4562              $this->cell_padding = $this->theadMargins['cell_padding'];
4563              if ($this->rtl) {
4564                  $this->x = $this->w - $this->rMargin;
4565              } else {
4566                  $this->x = $this->lMargin;
4567              }
4568              // account for special "cell" mode
4569              if ($this->theadMargins['cell']) {
4570                  if ($this->rtl) {
4571                      $this->x -= $this->cell_padding['R'];
4572                  } else {
4573                      $this->x += $this->cell_padding['L'];
4574                  }
4575              }
4576              // print table header
4577              $this->writeHTML($this->thead, false, false, false, false, '');
4578              // set new top margin to skip the table headers
4579              if (!isset($this->theadMargins['top'])) {
4580                  $this->theadMargins['top'] = $this->tMargin;
4581              }
4582              // store end of header position
4583              if (!isset($this->columns[0]['th'])) {
4584                  $this->columns[0]['th'] = array();
4585              }
4586              $this->columns[0]['th']['\''.$this->page.'\''] = $this->y;
4587              $this->tMargin = $this->y;
4588              $this->pagedim[$this->page]['tm'] = $this->tMargin;
4589              $this->lasth = 0;
4590              $this->lMargin = $prev_lMargin;
4591              $this->rMargin = $prev_rMargin;
4592              $this->cell_padding = $prev_cell_padding;
4593          }
4594      }
4595  
4596      /**
4597       * Returns the current page number.
4598       * @return int page number
4599       * @public
4600       * @since 1.0
4601       * @see getAliasNbPages()
4602       */
4603  	public function PageNo() {
4604          return $this->page;
4605      }
4606  
4607      /**
4608       * Defines a new spot color.
4609       * It can be expressed in RGB components or gray scale.
4610       * The method can be called before the first page is created and the value is retained from page to page.
4611       * @param $name (string) Full name of the spot color.
4612       * @param $c (float) Cyan color for CMYK. Value between 0 and 100.
4613       * @param $m (float) Magenta color for CMYK. Value between 0 and 100.
4614       * @param $y (float) Yellow color for CMYK. Value between 0 and 100.
4615       * @param $k (float) Key (Black) color for CMYK. Value between 0 and 100.
4616       * @public
4617       * @since 4.0.024 (2008-09-12)
4618       * @see SetDrawSpotColor(), SetFillSpotColor(), SetTextSpotColor()
4619       */
4620  	public function AddSpotColor($name, $c, $m, $y, $k) {
4621          if (!isset($this->spot_colors[$name])) {
4622              $i = (1 + count($this->spot_colors));
4623              $this->spot_colors[$name] = array('C' => $c, 'M' => $m, 'Y' => $y, 'K' => $k, 'name' => $name, 'i' => $i);
4624          }
4625      }
4626  
4627      /**
4628       * Return the Spot color array.
4629       * @param $name (string) Name of the spot color.
4630       * @return (array) Spot color array or false if not defined.
4631       * @public
4632       * @since 5.9.125 (2011-10-03)
4633       */
4634  	public function getSpotColor($name) {
4635          if (isset($this->spot_colors[$name])) {
4636              return $this->spot_colors[$name];
4637          }
4638          $color = preg_replace('/[\s]*/', '', $name); // remove extra spaces
4639          $color = strtolower($color);
4640          if (isset($this->spotcolor[$color])) {
4641              $this->AddSpotColor($this->spotcolor[$color][4], $this->spotcolor[$color][0], $this->spotcolor[$color][1], $this->spotcolor[$color][2], $this->spotcolor[$color][3]);
4642              return $this->spot_colors[$this->spotcolor[$color][4]];
4643          }
4644          return false;
4645      }
4646  
4647      /**
4648       * Set the spot color for the specified type ('draw', 'fill', 'text').
4649       * @param $type (string) Type of object affected by this color: ('draw', 'fill', 'text').
4650       * @param $name (string) Name of the spot color.
4651       * @param $tint (float) Intensity of the color (from 0 to 100 ; 100 = full intensity by default).
4652       * @return (string) PDF color command.
4653       * @public
4654       * @since 5.9.125 (2011-10-03)
4655       */
4656  	public function setSpotColor($type, $name, $tint=100) {
4657          $spotcolor = $this->getSpotColor($name);
4658          if ($spotcolor === false) {
4659              $this->Error('Undefined spot color: '.$name.', you must add it on the spotcolors.php file.');
4660          }
4661          $tint = (max(0, min(100, $tint)) / 100);
4662          $pdfcolor = sprintf('/CS%d ', $this->spot_colors[$name]['i']);
4663          switch ($type) {
4664              case 'draw': {
4665                  $pdfcolor .= sprintf('CS %F SCN', $tint);
4666                  $this->DrawColor = $pdfcolor;
4667                  $this->strokecolor = $spotcolor;
4668                  break;
4669              }
4670              case 'fill': {
4671                  $pdfcolor .= sprintf('cs %F scn', $tint);
4672                  $this->FillColor = $pdfcolor;
4673                  $this->bgcolor = $spotcolor;
4674                  break;
4675              }
4676              case 'text': {
4677                  $pdfcolor .= sprintf('cs %F scn', $tint);
4678                  $this->TextColor = $pdfcolor;
4679                  $this->fgcolor = $spotcolor;
4680                  break;
4681              }
4682          }
4683          $this->ColorFlag = ($this->FillColor != $this->TextColor);
4684          if ($this->state == 2) {
4685              $this->_out($pdfcolor);
4686          }
4687          if ($this->inxobj) {
4688              // we are inside an XObject template
4689              $this->xobjects[$this->