Rearrange php libs/includes and produce sitemap.xml
[busui.git] / lib / tcpdf / tcpdf.php
blob:a/lib/tcpdf/tcpdf.php -> blob:b/lib/tcpdf/tcpdf.php
  <?php
  //============================================================+
  // File name : tcpdf.php
  // Version : 5.9.059
  // Begin : 2002-08-03
  // Last Update : 2011-02-27
  // Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
  // License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 + YOU CAN'T REMOVE ANY TCPDF COPYRIGHT NOTICE OR LINK FROM THE GENERATED PDF DOCUMENTS.
  // -------------------------------------------------------------------
  // Copyright (C) 2002-2011 Nicola Asuni - Tecnick.com S.r.l.
  //
  // This file is part of TCPDF software library.
  //
  // TCPDF is free software: you can redistribute it and/or modify it
  // under the terms of the GNU Lesser General Public License as
  // published by the Free Software Foundation, either version 3 of the
  // License, or (at your option) any later version. Additionally,
  // YOU CAN'T REMOVE ANY TCPDF COPYRIGHT NOTICE OR LINK FROM THE
  // GENERATED PDF DOCUMENTS.
  //
  // TCPDF is distributed in the hope that it will be useful, but
  // WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  // See the GNU Lesser General Public License for more details.
  //
  // You should have received a copy of the License
  // along with TCPDF. If not, see
  // <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
  //
  // See LICENSE.TXT file for more information.
  // -------------------------------------------------------------------
  //
  // Description : This is a PHP class for generating PDF documents without
  // requiring external extensions.
  //
  // NOTE:
  // This class was originally derived in 2002 from the Public
  // Domain FPDF class by Olivier Plathey (http://www.fpdf.org),
  // but now is almost entirely rewritten and contains thousands of
  // new lines of code and hundreds new features.
  //
  // Main features:
  // * no external libraries are required for the basic functions;
  // * all standard page formats, custom page formats, custom margins and units of measure;
  // * UTF-8 Unicode and Right-To-Left languages;
  // * TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;
  // * font subsetting;
  // * methods to publish some XHTML + CSS code, Javascript and Forms;
  // * images, graphic (geometric figures) and transformation methods;
  // * 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)
  // * 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, QR-Code, PDF417;
  // * Grayscale, RGB, CMYK, Spot Colors and Transparencies;
  // * automatic page header and footer management;
  // * document encryption up to 256 bit and digital signature certifications;
  // * transactions to UNDO commands;
  // * PDF annotations, including links, text and file attachments;
  // * text rendering modes (fill, stroke and clipping);
  // * multiple columns mode;
  // * no-write page regions;
  // * bookmarks and table of content;
  // * text hyphenation;
  // * text stretching and spacing (tracking/kerning);
  // * automatic page break, line break and text alignments including justification;
  // * automatic page numbering and page groups;
  // * move and delete pages;
  // * page compression (requires php-zlib extension);
  // * XOBject Templates;
  //
  // -----------------------------------------------------------
  // THANKS TO:
  //
  // Olivier Plathey (http://www.fpdf.org) for original FPDF.
  // Efthimios Mavrogeorgiadis (emavro@yahoo.com) for suggestions on RTL language support.
  // Klemen Vodopivec (http://www.fpdf.de/downloads/addons/37/) for Encryption algorithm.
  // Warren Sherliker (wsherliker@gmail.com) for better image handling.
  // dullus for text Justification.
  // Bob Vincent (pillarsdotnet@users.sourceforge.net) for <li> value attribute.
  // Patrick Benny for text stretch suggestion on Cell().
 
  // Denis Van Nuffelen for Dynamic Form.
  // Jacek Czekaj for multibyte justification
  // Anthony Ferrara for the reintroduction of legacy image methods.
  // Sourceforge user 1707880 (hucste) for line-trough mode.
  // Larry Stanbery for page groups.
  // Martin Hall-May for transparency.
  // Aaron C. Spike for Polycurve method.
  // Mohamad Ali Golkar, Saleh AlMatrafe, Charles Abbott for Arabic and Persian support.
  // Moritz Wagner and Andreas Wurmser for graphic functions.
  // Andrew Whitehead for core fonts support.
 
  // Teus Hagen for several suggestions and fixes.
  // Yukihiro Nakadaira for CID-0 CJK fonts fixes.
  // Kosmas Papachristos for some CSS improvements.
  // Marcel Partap for some fixes.
  // Won Kyu Park for several suggestions, fixes and patches.
  // Dominik Dzienia for QR-code support.
  // Laurent Minguet for some suggestions.
  // Christian Deligant for some suggestions and fixes.
  // Anyone that has reported a bug or sent a suggestion.
  //============================================================+
   
  /**
  * @file
  * This is a PHP class for generating PDF documents without requiring external extensions.<br>
  * 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>
  * <h3>TCPDF main features are:</h3>
  * <ul>
  * <li>no external libraries are required for the basic functions;</li>
  * <li>all standard page formats, custom page formats, custom margins and units of measure;</li>
  * <li>UTF-8 Unicode and Right-To-Left languages;</li>
  * <li>TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;</li>
  * <li>font subsetting;</li>
  * <li>methods to publish some XHTML + CSS code, Javascript and Forms;</li>
  * <li>images, graphic (geometric figures) and transformation methods;
  * <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>
  * <li>1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, QR-Code, PDF417;</li>
  * <li>Grayscale, RGB, CMYK, Spot Colors and Transparencies;</li>
  * <li>automatic page header and footer management;</li>
  * <li>document encryption up to 256 bit and digital signature certifications;</li>
  * <li>transactions to UNDO commands;</li>
  * <li>PDF annotations, including links, text and file attachments;</li>
  * <li>text rendering modes (fill, stroke and clipping);</li>
  * <li>multiple columns mode;</li>
  * <li>no-write page regions;</li>
  * <li>bookmarks and table of content;</li>
  * <li>text hyphenation;</li>
  * <li>text stretching and spacing (tracking/kerning);</li>
  * <li>automatic page break, line break and text alignments including justification;</li>
  * <li>automatic page numbering and page groups;</li>
  * <li>move and delete pages;</li>
  * <li>page compression (requires php-zlib extension);</li>
  * <li>XOBject Templates;</li>
  * </ul>
  * Tools to encode your unicode fonts are on fonts/utils directory.</p>
  * @package com.tecnick.tcpdf
  * @author Nicola Asuni
  * @version 5.9.059
  */
   
  // Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
  require_once(dirname(__FILE__).'/config/tcpdf_config.php');
   
  /**
  * @class TCPDF
  * PHP class for generating PDF documents without requiring external extensions.
  * 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>
  * @package com.tecnick.tcpdf
  * @brief PHP class for generating PDF documents without requiring external extensions.
  * @version 5.9.059
  * @author Nicola Asuni - info@tecnick.com
  */
  class TCPDF {
   
  // private properties
   
  /**
  * Current TCPDF version.
  * @private
  */
  private $tcpdf_version = '5.9.059';
   
  // Protected properties
   
  /**
  * Current page number.
  * @protected
  */
  protected $page;
   
  /**
  * Current object number.
  * @protected
  */
  protected $n;
   
  /**
  * Array of object offsets.
  * @protected
  */
  protected $offsets;
   
  /**
  * Buffer holding in-memory PDF.
  * @protected
  */
  protected $buffer;
   
  /**
  * Array containing pages.
  * @protected
  */
  protected $pages = array();
   
  /**
  * Current document state.
  * @protected
  */
  protected $state;
   
  /**
  * Compression flag.
  * @protected
  */
  protected $compress;
   
  /**
  * Current page orientation (P = Portrait, L = Landscape).
  * @protected
  */
  protected $CurOrientation;
   
  /**
  * Page dimensions.
  * @protected
  */
  protected $pagedim = array();
   
  /**
  * Scale factor (number of points in user unit).
  * @protected
  */
  protected $k;
   
  /**
  * Width of page format in points.
  * @protected
  */
  protected $fwPt;
   
  /**
  * Height of page format in points.
  * @protected
  */
  protected $fhPt;
   
  /**
  * Current width of page in points.
  * @protected
  */
  protected $wPt;
   
  /**
  * Current height of page in points.
  * @protected
  */
  protected $hPt;
   
  /**
  * Current width of page in user unit.
  * @protected
  */
  protected $w;
   
  /**
  * Current height of page in user unit.
  * @protected
  */
  protected $h;
   
  /**
  * Left margin.
  * @protected
  */
  protected $lMargin;
   
  /**
  * Top margin.
  * @protected
  */
  protected $tMargin;
   
  /**
  * Right margin.
  * @protected
  */
  protected $rMargin;
   
  /**
  * Page break margin.
  * @protected
  */
  protected $bMargin;
   
  /**
  * Array of cell internal paddings ('T' => top, 'R' => right, 'B' => bottom, 'L' => left).
  * @since 5.9.000 (2010-10-03)
  * @protected
  */
  protected $cell_padding = array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0);
   
  /**
  * Array of cell margins ('T' => top, 'R' => right, 'B' => bottom, 'L' => left).
  * @since 5.9.000 (2010-10-04)
  * @protected
  */
  protected $cell_margin = array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0);
   
  /**
  * Current horizontal position in user unit for cell positioning.
  * @protected
  */
  protected $x;
   
  /**
  * Current vertical position in user unit for cell positioning.
  * @protected
  */
  protected $y;
   
  /**
  * Height of last cell printed.
  * @protected
  */
  protected $lasth;
   
  /**
  * Line width in user unit.
  * @protected
  */
  protected $LineWidth;
   
  /**
  * Array of standard font names.
  * @protected
  */
  protected $CoreFonts;
   
  /**
  * Array of used fonts.
  * @protected
  */
  protected $fonts = array();
   
  /**
  * Array of font files.
  * @protected
  */
  protected $FontFiles = array();
   
  /**
  * Array of encoding differences.
  * @protected
  */
  protected $diffs = array();
   
  /**
  * Array of used images.
  * @protected
  */
  protected $images = array();
   
  /**
  * Array of Annotations in pages.
  * @protected
  */
  protected $PageAnnots = array();
   
  /**
  * Array of internal links.
  * @protected
  */
  protected $links = array();
   
  /**
  * Current font family.
  * @protected
  */
  protected $FontFamily;
   
  /**
  * Current font style.
  * @protected
  */
  protected $FontStyle;
   
  /**
  * Current font ascent (distance between font top and baseline).
  * @protected
  * @since 2.8.000 (2007-03-29)
  */
  protected $FontAscent;
   
  /**