PageRenderTime 631ms CodeModel.GetById 242ms app.highlight 119ms RepoModel.GetById 92ms app.codeStats 7ms

/framework/lib/classes/PHPExcel/Shared/PDF/tcpdf.php

https://bitbucket.org/designbyheart/original
PHP | 13678 lines | 8325 code | 518 blank | 4835 comment | 1728 complexity | 48aaa955d5f2857a2437e30f5e29414a MD5 | raw file

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

   1<?php
   2//============================================================+
   3// File name   : tcpdf.php
   4// Version     : 5.9.009
   5// Begin       : 2002-08-03
   6// Last Update : 2010-10-21
   7// Author      : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
   8// License     : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
   9// -------------------------------------------------------------------
  10// Copyright (C) 2002-2010  Nicola Asuni - Tecnick.com S.r.l.
  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 GNU Lesser General Public License
  25// along with TCPDF.  If not, see <http://www.gnu.org/licenses/>.
  26//
  27// See LICENSE.TXT file for more information.
  28// -------------------------------------------------------------------
  29//
  30// Description : This is a PHP class for generating PDF documents without
  31//               requiring external extensions.
  32//
  33// NOTE:
  34//   This class was originally derived in 2002 from the Public
  35//   Domain FPDF class by Olivier Plathey (http://www.fpdf.org),
  36//   but now is almost entirely rewritten and contains thousands of
  37//   new lines of code and hundreds new features.
  38//
  39// Main features:
  40//  * no external libraries are required for the basic functions;
  41//  * all standard page formats, custom page formats, custom margins and units of measure;
  42//  * UTF-8 Unicode and Right-To-Left languages;
  43//  * TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;
  44//  * font subsetting;
  45//  * methods to publish some XHTML + CSS code, Javascript and Forms;
  46//  * images, graphic (geometric figures) and transformation methods;
  47//  * 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)
  48//  * 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;
  49//  * Grayscale, RGB, CMYK, Spot Colors and Transparencies;
  50//  * automatic page header and footer management;
  51//  * document encryption up to 256 bit and digital signature certifications;
  52//  * transactions to UNDO commands;
  53//  * PDF annotations, including links, text and file attachments;
  54//  * text rendering modes (fill, stroke and clipping);
  55//  * multiple columns mode;
  56//  * no-write page regions;
  57//  * bookmarks and table of content;
  58//  * text hyphenation;
  59//  * text stretching and spacing (tracking/kerning);
  60//  * automatic page break, line break and text alignments including justification;
  61//  * automatic page numbering and page groups;
  62//  * move and delete pages;
  63//  * page compression (requires php-zlib extension);
  64//  * XOBject Templates;
  65//
  66// -----------------------------------------------------------
  67// THANKS TO:
  68//
  69// Olivier Plathey (http://www.fpdf.org) for original FPDF.
  70// Efthimios Mavrogeorgiadis (emavro@yahoo.com) for suggestions on RTL language support.
  71// Klemen Vodopivec (http://www.fpdf.de/downloads/addons/37/) for Encryption algorithm.
  72// Warren Sherliker (wsherliker@gmail.com) for better image handling.
  73// dullus for text Justification.
  74// Bob Vincent (pillarsdotnet@users.sourceforge.net) for <li> value attribute.
  75// Patrick Benny for text stretch suggestion on Cell().
  76// Johannes G�ntert for JavaScript support.
  77// Denis Van Nuffelen for Dynamic Form.
  78// Jacek Czekaj for multibyte justification
  79// Anthony Ferrara for the reintroduction of legacy image methods.
  80// Sourceforge user 1707880 (hucste) for line-trough mode.
  81// Larry Stanbery for page groups.
  82// Martin Hall-May for transparency.
  83// Aaron C. Spike for Polycurve method.
  84// Mohamad Ali Golkar, Saleh AlMatrafe, Charles Abbott for Arabic and Persian support.
  85// Moritz Wagner and Andreas Wurmser for graphic functions.
  86// Andrew Whitehead for core fonts support.
  87// Esteban Jo�l Mar�n for OpenType font conversion.
  88// Teus Hagen for several suggestions and fixes.
  89// Yukihiro Nakadaira for CID-0 CJK fonts fixes.
  90// Kosmas Papachristos for some CSS improvements.
  91// Marcel Partap for some fixes.
  92// Won Kyu Park for several suggestions, fixes and patches.
  93// Dominik Dzienia for QR-code support.
  94// Laurent Minguet for some suggestions.
  95// Christian Deligant for some suggestions and fixes.
  96// Anyone that has reported a bug or sent a suggestion.
  97//============================================================+
  98
  99/**
 100 * This is a PHP class for generating PDF documents without requiring external extensions.<br>
 101 * 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>
 102 * <h3>TCPDF main features are:</h3>
 103 * <ul>
 104 * <li>no external libraries are required for the basic functions;</li>
 105 * <li>all standard page formats, custom page formats, custom margins and units of measure;</li>
 106 * <li>UTF-8 Unicode and Right-To-Left languages;</li>
 107 * <li>TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;</li>
 108 * <li>font subsetting;</li>
 109 * <li>methods to publish some XHTML + CSS code, Javascript and Forms;</li>
 110 * <li>images, graphic (geometric figures) and transformation methods;
 111 * <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>
 112 * <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>
 113 * <li>Grayscale, RGB, CMYK, Spot Colors and Transparencies;</li>
 114 * <li>automatic page header and footer management;</li>
 115 * <li>document encryption up to 256 bit and digital signature certifications;</li>
 116 * <li>transactions to UNDO commands;</li>
 117 * <li>PDF annotations, including links, text and file attachments;</li>
 118 * <li>text rendering modes (fill, stroke and clipping);</li>
 119 * <li>multiple columns mode;</li>
 120 * <li>no-write page regions;</li>
 121 * <li>bookmarks and table of content;</li>
 122 * <li>text hyphenation;</li>
 123 * <li>text stretching and spacing (tracking/kerning);</li>
 124 * <li>automatic page break, line break and text alignments including justification;</li>
 125 * <li>automatic page numbering and page groups;</li>
 126 * <li>move and delete pages;</li>
 127 * <li>page compression (requires php-zlib extension);</li>
 128 * <li>XOBject Templates;</li>
 129 * </ul>
 130 * Tools to encode your unicode fonts are on fonts/utils directory.</p>
 131 * @package com.tecnick.tcpdf
 132 * @abstract Class for generating PDF files on-the-fly without requiring external extensions.
 133 * @author Nicola Asuni
 134 * @copyright 2002-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
 135 * @link http://www.tcpdf.org
 136 * @license http://www.gnu.org/copyleft/lesser.html LGPL
 137 * @version 5.9.009
 138 */
 139
 140/**
 141 * main configuration file
 142 * (define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file)
 143 */
 144require_once(dirname(__FILE__).'/config/tcpdf_config.php');
 145
 146/**
 147 * define default PDF document producer
 148 */
 149define('PDF_PRODUCER', 'TCPDF 5.9.009 (http://www.tcpdf.org)');
 150
 151/**
 152* This is a PHP class for generating PDF documents without requiring external extensions.<br>
 153* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
 154* @name TCPDF
 155* @package com.tecnick.tcpdf
 156* @version 5.9.009
 157* @author Nicola Asuni - info@tecnick.com
 158* @link http://www.tcpdf.org
 159* @license http://www.gnu.org/copyleft/lesser.html LGPL
 160*/
 161class TCPDF {
 162
 163	// Protected properties
 164
 165	/**
 166	 * @var current page number
 167	 * @access protected
 168	 */
 169	protected $page;
 170
 171	/**
 172	 * @var current object number
 173	 * @access protected
 174	 */
 175	protected $n;
 176
 177	/**
 178	 * @var array of object offsets
 179	 * @access protected
 180	 */
 181	protected $offsets;
 182
 183	/**
 184	 * @var buffer holding in-memory PDF
 185	 * @access protected
 186	 */
 187	protected $buffer;
 188
 189	/**
 190	 * @var array containing pages
 191	 * @access protected
 192	 */
 193	protected $pages = array();
 194
 195	/**
 196	 * @var current document state
 197	 * @access protected
 198	 */
 199	protected $state;
 200
 201	/**
 202	 * @var compression flag
 203	 * @access protected
 204	 */
 205	protected $compress;
 206
 207	/**
 208	 * @var current page orientation (P = Portrait, L = Landscape)
 209	 * @access protected
 210	 */
 211	protected $CurOrientation;
 212
 213	/**
 214	 * @var Page dimensions
 215	 * @access protected
 216	 */
 217	protected $pagedim = array();
 218
 219	/**
 220	 * @var scale factor (number of points in user unit)
 221	 * @access protected
 222	 */
 223	protected $k;
 224
 225	/**
 226	 * @var width of page format in points
 227	 * @access protected
 228	 */
 229	protected $fwPt;
 230
 231	/**
 232	 * @var height of page format in points
 233	 * @access protected
 234	 */
 235	protected $fhPt;
 236
 237	/**
 238	 * @var current width of page in points
 239	 * @access protected
 240	 */
 241	protected $wPt;
 242
 243	/**
 244	 * @var current height of page in points
 245	 * @access protected
 246	 */
 247	protected $hPt;
 248
 249	/**
 250	 * @var current width of page in user unit
 251	 * @access protected
 252	 */
 253	protected $w;
 254
 255	/**
 256	 * @var current height of page in user unit
 257	 * @access protected
 258	 */
 259	protected $h;
 260
 261	/**
 262	 * @var left margin
 263	 * @access protected
 264	 */
 265	protected $lMargin;
 266
 267	/**
 268	 * @var top margin
 269	 * @access protected
 270	 */
 271	protected $tMargin;
 272
 273	/**
 274	 * @var right margin
 275	 * @access protected
 276	 */
 277	protected $rMargin;
 278
 279	/**
 280	 * @var page break margin
 281	 * @access protected
 282	 */
 283	protected $bMargin;
 284
 285	/**
 286	 * @var array of cell internal paddings ('T' => top, 'R' => right, 'B' => bottom, 'L' => left)
 287	 * @since 5.9.000 (2010-10-03)
 288	 * @access protected
 289	 */
 290	protected $cell_padding = array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0);
 291
 292	/**
 293	 * @var array of cell margins ('T' => top, 'R' => right, 'B' => bottom, 'L' => left)
 294	 * @since 5.9.000 (2010-10-04)
 295	 * @access protected
 296	 */
 297	protected $cell_margin = array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0);
 298
 299	/**
 300	 * @var current horizontal position in user unit for cell positioning
 301	 * @access protected
 302	 */
 303	protected $x;
 304
 305	/**
 306	 * @var current vertical position in user unit for cell positioning
 307	 * @access protected
 308	 */
 309	protected $y;
 310
 311	/**
 312	 * @var height of last cell printed
 313	 * @access protected
 314	 */
 315	protected $lasth;
 316
 317	/**
 318	 * @var line width in user unit
 319	 * @access protected
 320	 */
 321	protected $LineWidth;
 322
 323	/**
 324	 * @var array of standard font names
 325	 * @access protected
 326	 */
 327	protected $CoreFonts;
 328
 329	/**
 330	 * @var array of used fonts
 331	 * @access protected
 332	 */
 333	protected $fonts = array();
 334
 335	/**
 336	 * @var array of font files
 337	 * @access protected
 338	 */
 339	protected $FontFiles = array();
 340
 341	/**
 342	 * @var array of encoding differences
 343	 * @access protected
 344	 */
 345	protected $diffs = array();
 346
 347	/**
 348	 * @var array of used images
 349	 * @access protected
 350	 */
 351	protected $images = array();
 352
 353	/**
 354	 * @var array of Annotations in pages
 355	 * @access protected
 356	 */
 357	protected $PageAnnots = array();
 358
 359	/**
 360	 * @var array of internal links
 361	 * @access protected
 362	 */
 363	protected $links = array();
 364
 365	/**
 366	 * @var current font family
 367	 * @access protected
 368	 */
 369	protected $FontFamily;
 370
 371	/**
 372	 * @var current font style
 373	 * @access protected
 374	 */
 375	protected $FontStyle;
 376
 377	/**
 378	 * @var current font ascent (distance between font top and baseline)
 379	 * @access protected
 380	 * @since 2.8.000 (2007-03-29)
 381	 */
 382	protected $FontAscent;
 383
 384	/**
 385	 * @var current font descent (distance between font bottom and baseline)
 386	 * @access protected
 387	 * @since 2.8.000 (2007-03-29)
 388	 */
 389	protected $FontDescent;
 390
 391	/**
 392	 * @var underlining flag
 393	 * @access protected
 394	 */
 395	protected $underline;
 396
 397	/**
 398	 * @var overlining flag
 399	 * @access protected
 400	 */
 401	protected $overline;
 402
 403	/**
 404	 * @var current font info
 405	 * @access protected
 406	 */
 407	protected $CurrentFont;
 408
 409	/**
 410	 * @var current font size in points
 411	 * @access protected
 412	 */
 413	protected $FontSizePt;
 414
 415	/**
 416	 * @var current font size in user unit
 417	 * @access protected
 418	 */
 419	protected $FontSize;
 420
 421	/**
 422	 * @var commands for drawing color
 423	 * @access protected
 424	 */
 425	protected $DrawColor;
 426
 427	/**
 428	 * @var commands for filling color
 429	 * @access protected
 430	 */
 431	protected $FillColor;
 432
 433	/**
 434	 * @var commands for text color
 435	 * @access protected
 436	 */
 437	protected $TextColor;
 438
 439	/**
 440	 * @var indicates whether fill and text colors are different
 441	 * @access protected
 442	 */
 443	protected $ColorFlag;
 444
 445	/**
 446	 * @var automatic page breaking
 447	 * @access protected
 448	 */
 449	protected $AutoPageBreak;
 450
 451	/**
 452	 * @var threshold used to trigger page breaks
 453	 * @access protected
 454	 */
 455	protected $PageBreakTrigger;
 456
 457	/**
 458	 * @var flag set when processing footer
 459	 * @access protected
 460	 */
 461	protected $InFooter = false;
 462
 463	/**
 464	 * @var zoom display mode
 465	 * @access protected
 466	 */
 467	protected $ZoomMode;
 468
 469	/**
 470	 * @var layout display mode
 471	 * @access protected
 472	 */
 473	protected $LayoutMode;
 474
 475	/**
 476	 * @var title
 477	 * @access protected
 478	 */
 479	protected $title = '';
 480
 481	/**
 482	 * @var subject
 483	 * @access protected
 484	 */
 485	protected $subject = '';
 486
 487	/**
 488	 * @var author
 489	 * @access protected
 490	 */
 491	protected $author = '';
 492
 493	/**
 494	 * @var keywords
 495	 * @access protected
 496	 */
 497	protected $keywords = '';
 498
 499	/**
 500	 * @var creator
 501	 * @access protected
 502	 */
 503	protected $creator = '';
 504
 505	/**
 506	 * @var alias for total number of pages
 507	 * @access protected
 508	 */
 509	protected $AliasNbPages = '{nb}';
 510
 511	/**
 512	 * @var alias for page number
 513	 * @access protected
 514	 */
 515	protected $AliasNumPage = '{pnb}';
 516
 517	/**
 518	 * @var right-bottom corner X coordinate of inserted image
 519	 * @since 2002-07-31
 520	 * @author Nicola Asuni
 521	 * @access protected
 522	 */
 523	protected $img_rb_x;
 524
 525	/**
 526	 * @var right-bottom corner Y coordinate of inserted image
 527	 * @since 2002-07-31
 528	 * @author Nicola Asuni
 529	 * @access protected
 530	 */
 531	protected $img_rb_y;
 532
 533	/**
 534	 * @var adjusting factor to convert pixels to user units.
 535	 * @since 2004-06-14
 536	 * @author Nicola Asuni
 537	 * @access protected
 538	 */
 539	protected $imgscale = 1;
 540
 541	/**
 542	 * @var boolean set to true when the input text is unicode (require unicode fonts)
 543	 * @since 2005-01-02
 544	 * @author Nicola Asuni
 545	 * @access protected
 546	 */
 547	protected $isunicode = false;
 548
 549	/**
 550	 * @var object containing unicode data
 551	 * @since 5.9.004 (2010-10-18)
 552	 * @author Nicola Asuni
 553	 * @access protected
 554	 */
 555	protected $unicode;
 556
 557	/**
 558	 * @var PDF version
 559	 * @since 1.5.3
 560	 * @access protected
 561	 */
 562	protected $PDFVersion = '1.7';
 563
 564	/**
 565	 * @var Minimum distance between header and top page margin.
 566	 * @access protected
 567	 */
 568	protected $header_margin;
 569
 570	/**
 571	 * @var Minimum distance between footer and bottom page margin.
 572	 * @access protected
 573	 */
 574	protected $footer_margin;
 575
 576	/**
 577	 * @var original left margin value
 578	 * @access protected
 579	 * @since 1.53.0.TC013
 580	 */
 581	protected $original_lMargin;
 582
 583	/**
 584	 * @var original right margin value
 585	 * @access protected
 586	 * @since 1.53.0.TC013
 587	 */
 588	protected $original_rMargin;
 589
 590	/**
 591	 * @var Header font.
 592	 * @access protected
 593	 */
 594	protected $header_font;
 595
 596	/**
 597	 * @var Footer font.
 598	 * @access protected
 599	 */
 600	protected $footer_font;
 601
 602	/**
 603	 * @var Language templates.
 604	 * @access protected
 605	 */
 606	protected $l;
 607
 608	/**
 609	 * @var Barcode to print on page footer (only if set).
 610	 * @access protected
 611	 */
 612	protected $barcode = false;
 613
 614	/**
 615	 * @var If true prints header
 616	 * @access protected
 617	 */
 618	protected $print_header = true;
 619
 620	/**
 621	 * @var If true prints footer.
 622	 * @access protected
 623	 */
 624	protected $print_footer = true;
 625
 626	/**
 627	 * @var Header image logo.
 628	 * @access protected
 629	 */
 630	protected $header_logo = '';
 631
 632	/**
 633	 * @var Header image logo width in mm.
 634	 * @access protected
 635	 */
 636	protected $header_logo_width = 30;
 637
 638	/**
 639	 * @var String to print as title on document header.
 640	 * @access protected
 641	 */
 642	protected $header_title = '';
 643
 644	/**
 645	 * @var String to print on document header.
 646	 * @access protected
 647	 */
 648	protected $header_string = '';
 649
 650	/**
 651	 * @var Default number of columns for html table.
 652	 * @access protected
 653	 */
 654	protected $default_table_columns = 4;
 655
 656	// variables for html parser
 657
 658	/**
 659	 * @var HTML PARSER: array to store current link and rendering styles.
 660	 * @access protected
 661	 */
 662	protected $HREF = array();
 663
 664	/**
 665	 * @var store a list of available fonts on filesystem.
 666	 * @access protected
 667	 */
 668	protected $fontlist = array();
 669
 670	/**
 671	 * @var current foreground color
 672	 * @access protected
 673	 */
 674	protected $fgcolor;
 675
 676	/**
 677	 * @var HTML PARSER: array of boolean values, true in case of ordered list (OL), false otherwise.
 678	 * @access protected
 679	 */
 680	protected $listordered = array();
 681
 682	/**
 683	 * @var HTML PARSER: array count list items on nested lists.
 684	 * @access protected
 685	 */
 686	protected $listcount = array();
 687
 688	/**
 689	 * @var HTML PARSER: current list nesting level.
 690	 * @access protected
 691	 */
 692	protected $listnum = 0;
 693
 694	/**
 695	 * @var HTML PARSER: indent amount for lists.
 696	 * @access protected
 697	 */
 698	protected $listindent = 0;
 699
 700	/**
 701	 * @var HTML PARSER: current list indententation level.
 702	 * @access protected
 703	 */
 704	protected $listindentlevel = 0;
 705
 706	/**
 707	 * @var current background color
 708	 * @access protected
 709	 */
 710	protected $bgcolor;
 711
 712	/**
 713	 * @var Store temporary font size in points.
 714	 * @access protected
 715	 */
 716	protected $tempfontsize = 10;
 717
 718	/**
 719	 * @var spacer for LI tags.
 720	 * @access protected
 721	 */
 722	protected $lispacer = '';
 723
 724	/**
 725	 * @var default encoding
 726	 * @access protected
 727	 * @since 1.53.0.TC010
 728	 */
 729	protected $encoding = 'UTF-8';
 730
 731	/**
 732	 * @var PHP internal encoding
 733	 * @access protected
 734	 * @since 1.53.0.TC016
 735	 */
 736	protected $internal_encoding;
 737
 738	/**
 739	 * @var indicates if the document language is Right-To-Left
 740	 * @access protected
 741	 * @since 2.0.000
 742	 */
 743	protected $rtl = false;
 744
 745	/**
 746	 * @var used to force RTL or LTR string inversion
 747	 * @access protected
 748	 * @since 2.0.000
 749	 */
 750	protected $tmprtl = false;
 751
 752	// --- Variables used for document encryption:
 753
 754	/**
 755	 * Indicates whether document is protected
 756	 * @access protected
 757	 * @since 2.0.000 (2008-01-02)
 758	 */
 759	protected $encrypted;
 760
 761	/**
 762	 * Array containing encryption settings
 763	 * @access protected
 764	 * @since 5.0.005 (2010-05-11)
 765	 */
 766	protected $encryptdata = array();
 767
 768	/**
 769	 * last RC4 key encrypted (cached for optimisation)
 770	 * @access protected
 771	 * @since 2.0.000 (2008-01-02)
 772	 */
 773	protected $last_enc_key;
 774
 775	/**
 776	 * last RC4 computed key
 777	 * @access protected
 778	 * @since 2.0.000 (2008-01-02)
 779	 */
 780	protected $last_enc_key_c;
 781
 782	/**
 783	 * Encryption padding
 784	 * @access protected
 785	 */
 786	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";
 787
 788	/**
 789	 * File ID (used on trailer)
 790	 * @access protected
 791	 * @since 5.0.005 (2010-05-12)
 792	 */
 793	protected $file_id;
 794
 795	// --- bookmark ---
 796
 797	/**
 798	 * Outlines for bookmark
 799	 * @access protected
 800	 * @since 2.1.002 (2008-02-12)
 801	 */
 802	protected $outlines = array();
 803
 804	/**
 805	 * Outline root for bookmark
 806	 * @access protected
 807	 * @since 2.1.002 (2008-02-12)
 808	 */
 809	protected $OutlineRoot;
 810
 811	// --- javascript and form ---
 812
 813	/**
 814	 * javascript code
 815	 * @access protected
 816	 * @since 2.1.002 (2008-02-12)
 817	 */
 818	protected $javascript = '';
 819
 820	/**
 821	 * javascript counter
 822	 * @access protected
 823	 * @since 2.1.002 (2008-02-12)
 824	 */
 825	protected $n_js;
 826
 827	/**
 828	 * line trough state
 829	 * @access protected
 830	 * @since 2.8.000 (2008-03-19)
 831	 */
 832	protected $linethrough;
 833
 834	/**
 835	 * Array with additional document-wide usage rights for the document.
 836	 * @access protected
 837	 * @since 5.8.014 (2010-08-23)
 838	 */
 839	protected $ur = array();
 840
 841	/**
 842	 * Dot Per Inch Document Resolution (do not change)
 843	 * @access protected
 844	 * @since 3.0.000 (2008-03-27)
 845	 */
 846	protected $dpi = 72;
 847
 848	/**
 849	 * Array of page numbers were a new page group was started
 850	 * @access protected
 851	 * @since 3.0.000 (2008-03-27)
 852	 */
 853	protected $newpagegroup = array();
 854
 855	/**
 856	 * Contains the number of pages of the groups
 857	 * @access protected
 858	 * @since 3.0.000 (2008-03-27)
 859	 */
 860	protected $pagegroups;
 861
 862	/**
 863	 * Contains the alias of the current page group
 864	 * @access protected
 865	 * @since 3.0.000 (2008-03-27)
 866	 */
 867	protected $currpagegroup;
 868
 869	/**
 870	 * Restrict the rendering of some elements to screen or printout.
 871	 * @access protected
 872	 * @since 3.0.000 (2008-03-27)
 873	 */
 874	protected $visibility = 'all';
 875
 876	/**
 877	 * Print visibility.
 878	 * @access protected
 879	 * @since 3.0.000 (2008-03-27)
 880	 */
 881	protected $n_ocg_print;
 882
 883	/**
 884	 * View visibility.
 885	 * @access protected
 886	 * @since 3.0.000 (2008-03-27)
 887	 */
 888	protected $n_ocg_view;
 889
 890	/**
 891	 * Array of transparency objects and parameters.
 892	 * @access protected
 893	 * @since 3.0.000 (2008-03-27)
 894	 */
 895	protected $extgstates;
 896
 897	/**
 898	 * Set the default JPEG compression quality (1-100)
 899	 * @access protected
 900	 * @since 3.0.000 (2008-03-27)
 901	 */
 902	protected $jpeg_quality;
 903
 904	/**
 905	 * Default cell height ratio.
 906	 * @access protected
 907	 * @since 3.0.014 (2008-05-23)
 908	 */
 909	protected $cell_height_ratio = K_CELL_HEIGHT_RATIO;
 910
 911	/**
 912	 * PDF viewer preferences.
 913	 * @access protected
 914	 * @since 3.1.000 (2008-06-09)
 915	 */
 916	protected $viewer_preferences;
 917
 918	/**
 919	 * A name object specifying how the document should be displayed when opened.
 920	 * @access protected
 921	 * @since 3.1.000 (2008-06-09)
 922	 */
 923	protected $PageMode;
 924
 925	/**
 926	 * Array for storing gradient information.
 927	 * @access protected
 928	 * @since 3.1.000 (2008-06-09)
 929	 */
 930	protected $gradients = array();
 931
 932	/**
 933	 * Array used to store positions inside the pages buffer.
 934	 * keys are the page numbers
 935	 * @access protected
 936	 * @since 3.2.000 (2008-06-26)
 937	 */
 938	protected $intmrk = array();
 939
 940	/**
 941	 * Array used to store positions inside the pages buffer.
 942	 * keys are the page numbers
 943	 * @access protected
 944	 * @since 5.7.000 (2010-08-03)
 945	 */
 946	protected $bordermrk = array();
 947
 948	/**
 949	 * Array used to store page positions to track empty pages.
 950	 * keys are the page numbers
 951	 * @access protected
 952	 * @since 5.8.007 (2010-08-18)
 953	 */
 954	protected $emptypagemrk = array();
 955
 956	/**
 957	 * Array used to store content positions inside the pages buffer.
 958	 * keys are the page numbers
 959	 * @access protected
 960	 * @since 4.6.021 (2009-07-20)
 961	 */
 962	protected $cntmrk = array();
 963
 964	/**
 965	 * Array used to store footer positions of each page.
 966	 * @access protected
 967	 * @since 3.2.000 (2008-07-01)
 968	 */
 969	protected $footerpos = array();
 970
 971	/**
 972	 * Array used to store footer length of each page.
 973	 * @access protected
 974	 * @since 4.0.014 (2008-07-29)
 975	 */
 976	protected $footerlen = array();
 977
 978	/**
 979	 * True if a newline is created.
 980	 * @access protected
 981	 * @since 3.2.000 (2008-07-01)
 982	 */
 983	protected $newline = true;
 984
 985	/**
 986	 * End position of the latest inserted line
 987	 * @access protected
 988	 * @since 3.2.000 (2008-07-01)
 989	 */
 990	protected $endlinex = 0;
 991
 992	/**
 993	 * PDF string for last line width
 994	 * @access protected
 995	 * @since 4.0.006 (2008-07-16)
 996	 */
 997	protected $linestyleWidth = '';
 998
 999	/**
1000	 * PDF string for last line width
1001	 * @access protected
1002	 * @since 4.0.006 (2008-07-16)
1003	 */
1004	protected $linestyleCap = '0 J';
1005
1006	/**
1007	 * PDF string for last line width
1008	 * @access protected
1009	 * @since 4.0.006 (2008-07-16)
1010	 */
1011	protected $linestyleJoin = '0 j';
1012
1013	/**
1014	 * PDF string for last line width
1015	 * @access protected
1016	 * @since 4.0.006 (2008-07-16)
1017	 */
1018	protected $linestyleDash = '[] 0 d';
1019
1020	/**
1021	 * True if marked-content sequence is open
1022	 * @access protected
1023	 * @since 4.0.013 (2008-07-28)
1024	 */
1025	protected $openMarkedContent = false;
1026
1027	/**
1028	 * Count the latest inserted vertical spaces on HTML
1029	 * @access protected
1030	 * @since 4.0.021 (2008-08-24)
1031	 */
1032	protected $htmlvspace = 0;
1033
1034	/**
1035	 * Array of Spot colors
1036	 * @access protected
1037	 * @since 4.0.024 (2008-09-12)
1038	 */
1039	protected $spot_colors = array();
1040
1041	/**
1042	 * Symbol used for HTML unordered list items
1043	 * @access protected
1044	 * @since 4.0.028 (2008-09-26)
1045	 */
1046	protected $lisymbol = '';
1047
1048	/**
1049	 * String used to mark the beginning and end of EPS image blocks
1050	 * @access protected
1051	 * @since 4.1.000 (2008-10-18)
1052	 */
1053	protected $epsmarker = 'x#!#EPS#!#x';
1054
1055	/**
1056	 * Array of transformation matrix
1057	 * @access protected
1058	 * @since 4.2.000 (2008-10-29)
1059	 */
1060	protected $transfmatrix = array();
1061
1062	/**
1063	 * Current key for transformation matrix
1064	 * @access protected
1065	 * @since 4.8.005 (2009-09-17)
1066	 */
1067	protected $transfmatrix_key = 0;
1068
1069	/**
1070	 * Booklet mode for double-sided pages
1071	 * @access protected
1072	 * @since 4.2.000 (2008-10-29)
1073	 */
1074	protected $booklet = false;
1075
1076	/**
1077	 * Epsilon value used for float calculations
1078	 * @access protected
1079	 * @since 4.2.000 (2008-10-29)
1080	 */
1081	protected $feps = 0.005;
1082
1083	/**
1084	 * Array used for custom vertical spaces for HTML tags
1085	 * @access protected
1086	 * @since 4.2.001 (2008-10-30)
1087	 */
1088	protected $tagvspaces = array();
1089
1090	/**
1091	 * @var HTML PARSER: custom indent amount for lists.
1092	 * Negative value means disabled.
1093	 * @access protected
1094	 * @since 4.2.007 (2008-11-12)
1095	 */
1096	protected $customlistindent = -1;
1097
1098	/**
1099	 * @var if true keeps the border open for the cell sides that cross the page.
1100	 * @access protected
1101	 * @since 4.2.010 (2008-11-14)
1102	 */
1103	protected $opencell = true;
1104
1105	/**
1106	 * @var array of files to embedd
1107	 * @access protected
1108	 * @since 4.4.000 (2008-12-07)
1109	 */
1110	protected $embeddedfiles = array();
1111
1112	/**
1113	 * @var boolean true when inside html pre tag
1114	 * @access protected
1115	 * @since 4.4.001 (2008-12-08)
1116	 */
1117	protected $premode = false;
1118
1119	/**
1120	 * Array used to store positions of graphics transformation blocks inside the page buffer.
1121	 * keys are the page numbers
1122	 * @access protected
1123	 * @since 4.4.002 (2008-12-09)
1124	 */
1125	protected $transfmrk = array();
1126
1127	/**
1128	 * Default color for html links
1129	 * @access protected
1130	 * @since 4.4.003 (2008-12-09)
1131	 */
1132	protected $htmlLinkColorArray = array(0, 0, 255);
1133
1134	/**
1135	 * Default font style to add to html links
1136	 * @access protected
1137	 * @since 4.4.003 (2008-12-09)
1138	 */
1139	protected $htmlLinkFontStyle = 'U';
1140
1141	/**
1142	 * Counts the number of pages.
1143	 * @access protected
1144	 * @since 4.5.000 (2008-12-31)
1145	 */
1146	protected $numpages = 0;
1147
1148	/**
1149	 * Array containing page lengths in bytes.
1150	 * @access protected
1151	 * @since 4.5.000 (2008-12-31)
1152	 */
1153	protected $pagelen = array();
1154
1155	/**
1156	 * Counts the number of pages.
1157	 * @access protected
1158	 * @since 4.5.000 (2008-12-31)
1159	 */
1160	protected $numimages = 0;
1161
1162	/**
1163	 * Store the image keys.
1164	 * @access protected
1165	 * @since 4.5.000 (2008-12-31)
1166	 */
1167	protected $imagekeys = array();
1168
1169	/**
1170	 * Length of the buffer in bytes.
1171	 * @access protected
1172	 * @since 4.5.000 (2008-12-31)
1173	 */
1174	protected $bufferlen = 0;
1175
1176	/**
1177	 * If true enables disk caching.
1178	 * @access protected
1179	 * @since 4.5.000 (2008-12-31)
1180	 */
1181	protected $diskcache = false;
1182
1183	/**
1184	 * Counts the number of fonts.
1185	 * @access protected
1186	 * @since 4.5.000 (2009-01-02)
1187	 */
1188	protected $numfonts = 0;
1189
1190	/**
1191	 * Store the font keys.
1192	 * @access protected
1193	 * @since 4.5.000 (2009-01-02)
1194	 */
1195	protected $fontkeys = array();
1196
1197	/**
1198	 * Store the font object IDs.
1199	 * @access protected
1200	 * @since 4.8.001 (2009-09-09)
1201	 */
1202	protected $font_obj_ids = array();
1203
1204	/**
1205	 * Store the fage status (true when opened, false when closed).
1206	 * @access protected
1207	 * @since 4.5.000 (2009-01-02)
1208	 */
1209	protected $pageopen = array();
1210
1211	/**
1212	 * Default monospaced font
1213	 * @access protected
1214	 * @since 4.5.025 (2009-03-10)
1215	 */
1216	protected $default_monospaced_font = 'courier';
1217
1218	/**
1219	 * Used to store a cloned copy of the current class object
1220	 * @access protected
1221	 * @since 4.5.029 (2009-03-19)
1222	 */
1223	protected $objcopy;
1224
1225	/**
1226	 * Array used to store the lengths of cache files
1227	 * @access protected
1228	 * @since 4.5.029 (2009-03-19)
1229	 */
1230	protected $cache_file_length = array();
1231
1232	/**
1233	 * Table header content to be repeated on each new page
1234	 * @access protected
1235	 * @since 4.5.030 (2009-03-20)
1236	 */
1237	protected $thead = '';
1238
1239	/**
1240	 * Margins used for table header.
1241	 * @access protected
1242	 * @since 4.5.030 (2009-03-20)
1243	 */
1244	protected $theadMargins = array();
1245
1246	/**
1247	 * Cache array for UTF8StringToArray() method.
1248	 * @access protected
1249	 * @since 4.5.037 (2009-04-07)
1250	 */
1251	protected $cache_UTF8StringToArray = array();
1252
1253	/**
1254	 * Maximum size of cache array used for UTF8StringToArray() method.
1255	 * @access protected
1256	 * @since 4.5.037 (2009-04-07)
1257	 */
1258	protected $cache_maxsize_UTF8StringToArray = 8;
1259
1260	/**
1261	 * Current size of cache array used for UTF8StringToArray() method.
1262	 * @access protected
1263	 * @since 4.5.037 (2009-04-07)
1264	 */
1265	protected $cache_size_UTF8StringToArray = 0;
1266
1267	/**
1268	 * If true enables document signing
1269	 * @access protected
1270	 * @since 4.6.005 (2009-04-24)
1271	 */
1272	protected $sign = false;
1273
1274	/**
1275	 * Signature data
1276	 * @access protected
1277	 * @since 4.6.005 (2009-04-24)
1278	 */
1279	protected $signature_data = array();
1280
1281	/**
1282	 * Signature max length
1283	 * @access protected
1284	 * @since 4.6.005 (2009-04-24)
1285	 */
1286	protected $signature_max_length = 11742;
1287
1288	/**
1289	 * data for signature appearance
1290	 * @access protected
1291	 * @since 5.3.011 (2010-06-16)
1292	 */
1293	protected $signature_appearance = array('page' => 1, 'rect' => '0 0 0 0');
1294
1295	/**
1296	 * Regular expression used to find blank characters used for word-wrapping.
1297	 * @access protected
1298	 * @since 4.6.006 (2009-04-28)
1299	 */
1300	protected $re_spaces = '/[^\S\xa0]/';
1301
1302	/**
1303	 * Array of parts $re_spaces
1304	 * @access protected
1305	 * @since 5.5.011 (2010-07-09)
1306	 */
1307	protected $re_space = array('p' => '[^\S\xa0]', 'm' => '');
1308
1309	/**
1310	 * Signature object ID
1311	 * @access protected
1312	 * @since 4.6.022 (2009-06-23)
1313	 */
1314	protected $sig_obj_id = 0;
1315
1316	/**
1317	 * ByteRange placemark used during signature process.
1318	 * @access protected
1319	 * @since 4.6.028 (2009-08-25)
1320	 */
1321	protected $byterange_string = '/ByteRange[0 ********** ********** **********]';
1322
1323	/**
1324	 * Placemark used during signature process.
1325	 * @access protected
1326	 * @since 4.6.028 (2009-08-25)
1327	 */
1328	protected $sig_annot_ref = '***SIGANNREF*** 0 R';
1329
1330	/**
1331	 * ID of page objects
1332	 * @access protected
1333	 * @since 4.7.000 (2009-08-29)
1334	 */
1335	protected $page_obj_id = array();
1336
1337	/**
1338	 * List of form annotations IDs
1339	 * @access protected
1340	 * @since 4.8.000 (2009-09-07)
1341	 */
1342	protected $form_obj_id = array();
1343
1344	/**
1345	 * 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.
1346	 * @access protected
1347	 * @since 4.8.000 (2009-09-07)
1348	 */
1349	protected $default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
1350
1351	/**
1352	 * Javascript objects array
1353	 * @access protected
1354	 * @since 4.8.000 (2009-09-07)
1355	 */
1356	protected $js_objects = array();
1357
1358	/**
1359	 * Current form action (used during XHTML rendering)
1360	 * @access protected
1361	 * @since 4.8.000 (2009-09-07)
1362	 */
1363	protected $form_action = '';
1364
1365	/**
1366	 * Current form encryption type (used during XHTML rendering)
1367	 * @access protected
1368	 * @since 4.8.000 (2009-09-07)
1369	 */
1370	protected $form_enctype = 'application/x-www-form-urlencoded';
1371
1372	/**
1373	 * Current method to submit forms.
1374	 * @access protected
1375	 * @since 4.8.000 (2009-09-07)
1376	 */
1377	protected $form_mode = 'post';
1378
1379	/**
1380	 * List of fonts used on form fields (fontname => fontkey).
1381	 * @access protected
1382	 * @since 4.8.001 (2009-09-09)
1383	 */
1384	protected $annotation_fonts = array();
1385
1386	/**
1387	 * List of radio buttons parent objects.
1388	 * @access protected
1389	 * @since 4.8.001 (2009-09-09)
1390	 */
1391	protected $radiobutton_groups = array();
1392
1393	/**
1394	 * List of radio group objects IDs
1395	 * @access protected
1396	 * @since 4.8.001 (2009-09-09)
1397	 */
1398	protected $radio_groups = array();
1399
1400	/**
1401	 * Text indentation value (used for text-indent CSS attribute)
1402	 * @access protected
1403	 * @since 4.8.006 (2009-09-23)
1404	 */
1405	protected $textindent = 0;
1406
1407	/**
1408	 * Store page number when startTransaction() is called.
1409	 * @access protected
1410	 * @since 4.8.006 (2009-09-23)
1411	 */
1412	protected $start_transaction_page = 0;
1413
1414	/**
1415	 * Store Y position when startTransaction() is called.
1416	 * @access protected
1417	 * @since 4.9.001 (2010-03-28)
1418	 */
1419	protected $start_transaction_y = 0;
1420
1421	/**
1422	 * True when we are printing the thead section on a new page
1423	 * @access protected
1424	 * @since 4.8.027 (2010-01-25)
1425	 */
1426	protected $inthead = false;
1427
1428	/**
1429	 * Array of column measures (width, space, starting Y position)
1430	 * @access protected
1431	 * @since 4.9.001 (2010-03-28)
1432	 */
1433	protected $columns = array();
1434
1435	/**
1436	 * Number of colums
1437	 * @access protected
1438	 * @since 4.9.001 (2010-03-28)
1439	 */
1440	protected $num_columns = 1;
1441
1442	/**
1443	 * Current column number
1444	 * @access protected
1445	 * @since 4.9.001 (2010-03-28)
1446	 */
1447	protected $current_column = 0;
1448
1449	/**
1450	 * Starting page for columns
1451	 * @access protected
1452	 * @since 4.9.001 (2010-03-28)
1453	 */
1454	protected $column_start_page = 0;
1455
1456	/**
1457	 * Maximum page and column selected
1458	 * @access protected
1459	 * @since 5.8.000 (2010-08-11)
1460	 */
1461	protected $maxselcol = array('page' => 0, 'column' => 0);
1462
1463	/**
1464	 * Array of: X difference between table cell x start and starting page margin, cellspacing, cellpadding
1465	 * @access protected
1466	 * @since 5.8.000 (2010-08-11)
1467	 */
1468	protected $colxshift = array('x' => 0, 's' => 0, 'p' => 0);
1469
1470	/**
1471	 * 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.
1472	 * @access protected
1473	 * @since 4.9.008 (2010-04-03)
1474	 */
1475	protected $textrendermode = 0;
1476
1477	/**
1478	 * Text stroke width in doc units
1479	 * @access protected
1480	 * @since 4.9.008 (2010-04-03)
1481	 */
1482	protected $textstrokewidth = 0;
1483
1484	/**
1485	 * @var current stroke color
1486	 * @access protected
1487	 * @since 4.9.008 (2010-04-03)
1488	 */
1489	protected $strokecolor;
1490
1491	/**
1492	 * @var default unit of measure for document
1493	 * @access protected
1494	 * @since 5.0.000 (2010-04-22)
1495	 */
1496	protected $pdfunit = 'mm';
1497
1498	/**
1499	 * @var true when we are on TOC (Table Of Content) page
1500	 * @access protected
1501	 */
1502	protected $tocpage = false;
1503
1504	/**
1505	 * @var If true convert vector images (SVG, EPS) to raster image using GD or ImageMagick library.
1506	 * @access protected
1507	 * @since 5.0.000 (2010-04-26)
1508	 */
1509	protected $rasterize_vector_images = false;
1510
1511	/**
1512	 * @var If true enables font subsetting by default
1513	 * @access protected
1514	 * @since 5.3.002 (2010-06-07)
1515	 */
1516	protected $font_subsetting = true;
1517
1518	/**
1519	 * @var Array of default graphic settings
1520	 * @access protected
1521	 * @since 5.5.008 (2010-07-02)
1522	 */
1523	protected $default_graphic_vars = array();
1524
1525	/**
1526	 * @var Array of XObjects
1527	 * @access protected
1528	 * @since 5.8.014 (2010-08-23)
1529	 */
1530	protected $xobjects = array();
1531
1532	/**
1533	 * @var boolean true when we are inside an XObject
1534	 * @access protected
1535	 * @since 5.8.017 (2010-08-24)
1536	 */
1537	protected $inxobj = false;
1538
1539	/**
1540	 * @var current XObject ID
1541	 * @access protected
1542	 * @since 5.8.017 (2010-08-24)
1543	 */
1544	protected $xobjid = '';
1545
1546	/**
1547	 * @var percentage of character stretching
1548	 * @access protected
1549	 * @since 5.9.000 (2010-09-29)
1550	 */
1551	protected $font_stretching = 100;
1552
1553	/**
1554	 * @var increases or decreases the space between characters in a text by the specified amount (tracking/kerning).
1555	 * @access protected
1556	 * @since 5.9.000 (2010-09-29)
1557	 */
1558	protected $font_spacing = 0;
1559
1560	/**
1561	 * @var array of no-write regions
1562	 * ('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)
1563	 * @access protected
1564	 * @since 5.9.003 (2010-10-14)
1565	 */
1566	protected $page_regions = array();
1567
1568	/**
1569	 * @var array containing HTML color names and values
1570	 * @access protected
1571	 * @since 5.9.004 (2010-10-18)
1572	 */
1573	protected $webcolor = array();
1574
1575	/**
1576	 * @var directory used for the last SVG image
1577	 * @access protected
1578	 * @since 5.0.000 (2010-05-05)
1579	 */
1580	protected $svgdir = '';
1581
1582	/**
1583	 * @var Deafult unit of measure for SVG
1584	 * @access protected
1585	 * @since 5.0.000 (2010-05-02)
1586	 */
1587	protected $svgunit = 'px';
1588
1589	/**
1590	 * @var array of SVG gradients
1591	 * @access protected
1592	 * @since 5.0.000 (2010-05-02)
1593	 */
1594	protected $svggradients = array();
1595
1596	/**
1597	 * @var ID of last SVG gradient
1598	 * @access protected
1599	 * @since 5.0.000 (2010-05-02)
1600	 */
1601	protected $svggradientid = 0;
1602
1603	/**
1604	 * @var true when in SVG defs group
1605	 * @access protected
1606	 * @since 5.0.000 (2010-05-02)
1607	 */
1608	protected $svgdefsmode = false;
1609
1610	/**
1611	 * @var array of SVG defs
1612	 * @access protected
1613	 * @since 5.0.000 (2010-05-02)
1614	 */
1615	protected $svgdefs = array();
1616
1617	/**
1618	 * @var true when in SVG clipPath tag
1619	 * @access protected
1620	 * @since 5.0.000 (2010-04-26)
1621	 */
1622	protected $svgclipmode = false;
1623
1624	/**
1625	 * @var array of SVG clipPath commands
1626	 * @access protected
1627	 * @since 5.0.000 (2010-05-02)
1628	 */
1629	protected $svgclippaths = array();
1630
1631	/**
1632	 * @var array of SVG clipPath tranformation matrix
1633	 * @access protected
1634	 * @since 5.8.022 (2010-08-31)
1635	 */
1636	protected $svgcliptm = array();
1637
1638	/**
1639	 * @var ID of last SVG clipPath
1640	 * @access protected
1641	 * @since 5.0.000 (2010-05-02)
1642	 */
1643	protected $svgclipid = 0;
1644
1645	/**
1646	 * @var svg text
1647	 * @access protected
1648	 * @since 5.0.000 (2010-05-02)
1649	 */
1650	protected $svgtext = '';
1651
1652	/**
1653	 * @var svg text properties
1654	 * @access protected
1655	 * @since 5.8.013 (2010-08-23)
1656	 */
1657	protected $svgtextmode = array();
1658
1659	/**
1660	 * @var array of hinheritable SVG properties
1661	 * @access protected
1662	 * @since 5.0.000 (2010-05-02)
1663	 */
1664	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');
1665
1666	/**
1667	 * @var array of SVG properties
1668	 * @access protected
1669	 * @since 5.0.000 (2010-05-02)
1670	 */
1671	protected $svgstyles = array(array(
1672		'alignment-baseline' => 'auto',
1673		'baseline-shift' => 'baseline',
1674		'clip' => 'auto',
1675		'clip-path' => 'none',
1676		'clip-rule' => 'nonzero',
1677		'color' => 'black',
1678		'color-interpolation' => 'sRGB',
1679		'color-interpolation-filters' => 'linearRGB',
1680		'color-profile' => 'auto',
1681		'color-rendering' => 'auto',
1682		'cursor' => 'auto',
1683		'direction' => 'ltr',
1684		'display' => 'inline',
1685		'dominant-baseline' => 'auto',
1686		'enable-background' => 'accumulate',
1687		'fill' => 'black',
1688		'fill-opacity' => 1,
1689		'fill-rule' => 'nonzero',
1690		'filter' => 'none',
1691		'flood-color' => 'black',
1692		'flood-opacity' => 1,
1693		'font' => '',
1694		'font-family' => 'helvetica',
1695		'font-size' => 'medium',
1696		'font-size-adjust' => 'none',
1697		'font-stretch' => 'normal',
1698		'font-style' => 'normal',
1699		'font-variant' => 'normal',
1700		'font-weight' => 'normal',
1701		'glyph-orientation-horizontal' => '0deg',
1702		'glyph-orientation-vertical' => 'auto',
1703		'image-rendering' => 'auto',
1704		'kerning' => 'auto',
1705		'letter-spacing' => 'normal',
1706		'lighting-color' => 'white',
1707		'marker' => '',
1708		'marker-end' => 'none',
1709		'marker-mid' => 'none',
1710		'marker-start' => 'none',
1711		'mask' => 'none',
1712		'opacity' => 1,
1713		'overflow' => 'auto',
1714		'pointer-events' => 'visiblePainted',
1715		'shape-rendering' => 'auto',
1716		'stop-color' => 'black',
1717		'stop-opacity' => 1,
1718		'stroke' => 'none',
1719		'stroke-dasharray' => 'none',
1720		'stroke-dashoffset' => 0,
1721		'stroke-linecap' => 'butt',
1722		'stroke-linejoin' => 'miter',
1723		'stroke-miterlimit' => 4,
1724		'stroke-opacity' => 1,
1725		'stroke-width' => 1,
1726		'text-anchor' => 'start',
1727		'text-decoration' => 'none',
1728		'text-rendering' => 'auto',
1729		'unicode-bidi' => 'normal',
1730		'visibility' => 'visible',
1731		'word-spacing' => 'normal',
1732		'writing-mode' => 'lr-tb',
1733		'text-color' => 'black',
1734		'transfmatrix' => array(1, 0, 0, 1, 0, 0)
1735		));
1736
1737	//------------------------------------------------------------
1738	// METHODS
1739	//------------------------------------------------------------
1740
1741	/**
1742	 * This is the class constructor.
1743	 * It allows to set up the page format, the orientation and the measure unit used in all the methods (except for the font sizes).
1744	 * @param string $orientation 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>
1745	 * @param string $unit User measure unit. Possible values are:<ul><li>pt: point</li><li>mm: millimeter (default)</li><li>cm: centimeter</li><li>in: inch</li></ul><br />A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.
1746	 * @param mixed $format 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().
1747	 * @param boolean $unicode TRUE means that the input text is unicode (default = true)
1748	 * @param boolean $diskcache if TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower).
1749	 * @param String $encoding charset encoding; default is UTF-8
1750	 * @access public
1751	 * @see getPageSizeFromFormat(), setPageFormat()
1752	 */
1753	public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false) {
1754		/* Set internal character encoding to ASCII */
1755		if (function_exists('mb_internal_encoding') AND mb_internal_encoding()) {
1756			$this->internal_encoding = mb_internal_encoding();
1757			mb_internal_encoding('ASCII');
1758		}
1759		require(dirname(__FILE__).'/htmlcolors.php');
1760		$this->webcolor = $webcolor;
1761		require_once(dirname(__FILE__).'/unicode_data.php');
1762		$this->unicode = new TCPDF_UNICODE_DATA();
1763		$this->font_obj_ids = array();
1764		$this->page_obj_id = array();
1765		$this->form_obj_id = array();
1766		// set disk caching
1767		$this->diskcache = $diskcache ? true : false;
1768		// set language direction
1769		$this->rtl = false;
1770		$this->tmprtl = false;
1771		// some checks
1772		$this->_dochecks();
1773		// initialization of properties
1774		$this->isunicode = $unicode;
1775		$this->page = 0;
1776		$this->transfmrk[0] = array();
1777		$this->pagedim = array();
1778		$this->n = 2;
1779		$this->buffer = '';
1780		$this->pages = array();
1781		$this->state = 0;
1782		$this->fonts = array();
1783		$this->FontFiles = array();
1784		$this->diffs = array();
1785		$this->images = array();
1786		$this->links = array();
1787		$this->gradients = array();
1788		$this->InFooter = false;
1789		$this->lasth = 0;
1790		$this->FontFamily = 'helvetica';
1791		$this->FontStyle = '';
1792		$this->FontSizePt = 12;
1793		$this->underline = false;
1794		$this->overline = false;
1795		$this->linethrough = false;
1796		$this->DrawColor = '0 G';
1797		$this->FillColor = '0 g';
1798		$this->TextColor = '0 g';
1799		$this->ColorFlag = false;
1800		// encryption values
1801		$this->encrypted = false;
1802		$this->last_enc_key = '';
1803		// standard Unicode fonts
1804		$this->CoreFonts = array(
1805			'courier'=>'Courier',
1806			'courierB'=>'Courier-Bold',
1807			'courierI'=>'Courier-Oblique',
1808			'courierBI'=>'Courier-BoldOblique',
1809			'helvetica'=>'Helvetica',
1810			'helveticaB'=>'Helvetica-Bold',
1811			'helveticaI'=>'Helvetica-Oblique',
1812			'helveticaBI'=>'Helvetica-BoldOblique',
1813			'times'=>'Times-Roman',
1814			'timesB'=>'Times-Bold',
1815			'timesI'=>'Times-Italic',
1816			'timesBI'=>'Times-BoldItalic',
1817			'symbol'=>'Symbol',
1818			'zapfdingbats'=>'ZapfDingbats'
1819		);
1820		// set scale factor
1821		$this->setPageUnit($unit);
1822		// set page format and orientation
1823		$this->setPageFormat($format, $orientation);
1824		// page margins (1 cm)
1825		$margin = 28.35 / $this->k;
1826		$this->SetMargins($margin, $margin);
1827		// internal cell padding
1828		$cpadding = $margin / 10;
1829		$this->setCellPaddings($cpadding, 0, $cpadding, 0);
1830		// cell margins
1831		$this->setCellMargins(0, 0, 0, 0);
1832		// line width (0.2 mm)
1833		$this->LineWidth = 0.57 / $this->k;
1834		$this->linestyleWidth = sprintf('%.2F w', ($this->LineWidth * $this->k));
1835		$this->linestyleCap = '0 J';
1836		$this->linestyleJoin = '0 j';
1837		$this->linestyleDash = '[] 0 d';
1838		// automatic page break
1839		$this->SetAutoPageBreak(true, (2 * $margin));
1840		// full width display mode
1841		$this->SetDisplayMode('fullwidth');
1842		// compression
1843		$this->SetCompression(true);
1844		// set default PDF version number
1845		$this->PDFVersion = '1.7';
1846		$this->encoding = $encoding;
1847		$this->HREF = array();
1848		$this->getFontsList();
1849		$this->fgcolor = array('R' => 0, 'G' => 0, 'B' => 0);
1850		$this->strokecolor = array('R' => 0, 'G' => 0, 'B' => 0);
1851		$this->bgcolor = array('R' => 255, 'G' => 255, 'B' => 255);
1852		$this->extgstates = array();
1853		// user's rights
1854		$this->sign = false;
1855		$this->ur['enabled'] = false;
1856		$this->ur['document'] = '/FullSave';
1857		$this->ur['annots'] = '/Create/Delete/Modify/Copy/Import/Export';
1858		$this->ur['form'] = '/Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate';
1859		$this->ur['signature'] = '/Modify';
1860		$this->ur['ef'] = '/Create/Delete/Modify/Import';
1861		$this->ur['formex'] = '';
1862		$this->signature_appearance = array('page' => 1, 'rect' => '0 0 0 0');
1863		// set default JPEG quality
1864		$this->jpeg_quality = 75;
1865		// initialize some settings
1866		$this->utf8Bidi(array(''), '');
1867		// set default font
1868		$this->SetFont($this->FontFamily, $this->FontStyle, $this->FontSizePt);
1869		// check if PCRE Unicode support is enabled
1870		if ($this->isunicode AND (@preg_match('/\pL/u', 'a') == 1)) {
1871			// PCRE unicode support is turned ON
1872			// \p{Z} or \p{Separator}: any kind of Unicode whitespace or invisible separator.
1873			// \p{Lo} or \p{Other_Letter}: a Unicode letter or ideograph that does not have lowercase and uppercase variants.
1874			// \p{Lo} is needed because Chinese characters are packed next to each other without spaces in between.
1875			//$this->setSpacesRE('/[^\S\P{Z}\P{Lo}\xa0]/u');
1876			$this->setSpacesRE('/[^\S\P{Z}\xa0]/u');
1877		} else {
1878			// PCRE unicode support is turned OFF
1879			$this->setSpacesRE('/[^\S\xa0]/');
1880		}
1881		$this->default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
1882		// set file ID for trailer
1883		$this->file_id = md5($this->getRandomSeed('TCPDF'.$orientation.$unit.$format.$encoding));
1884		// get default graphic vars
1885		$this->default_graphic_vars = $this->getGraphicVars();
1886	}
1887
1888	/**
1889	 * Default destructor.
1890	 * @access public
1891	 * @since 1.53.0.TC016
1892	 */
1893	public function __destruct() {
1894		// restore internal encoding
1895		if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
1896			mb_internal_encoding($this->internal_encoding);
1897		}
1898		// unset all class variables
1899		$this->_destroy(true);
1900	}
1901
1902	/**
1903	 * Set the units of measure for the document.
1904	 * @param string $unit User measure unit. Possible values are:<ul><li>pt: point</li><li>mm: millimeter (default)</li><li>cm: centimeter</li><li>in: inch</li></ul><br />A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.
1905	 * @access public
1906	 * @since 3.0.015 (2008-06-06)
1907	 */
1908	public function setPageUnit($unit) {
1909		$unit = strtolower($unit);
1910		//Set scale factor
1911		switch ($unit) {
1912			// points
1913			case 'px':
1914			case 'pt': {
1915				$this->k = 1;
1916				break;
1917			}
1918			// millimeters
1919			case 'mm': {
1920				$this->k = $this->dpi / 25.4;
1921				break;
1922			}
1923			// centimeters
1924			case 'cm': {
1925				$this->k = $this->dpi / 2.54;
1926				break;
1927			}
1928			// inches
1929			case 'in': {
1930				$this->k = $this->dpi;
1931				break;
1932			}
1933			// unsupported unit
1934			default : {
1935				$this->Error('Incorrect unit: '.$unit);
1936				break;
1937			}
1938		}
1939		$this->pdfunit = $unit;
1940		if (isset($this->CurOrientation)) {
1941			$this->setPageOrientation($this->CurOrientation);
1942		}
1943	}
1944
1945	/**
1946	 * Get page dimensions from format name.
1947	 * @param mixed $format The format name. It can be: <ul>
1948	 * <li><b>ISO 216 A Series + 2 SIS 014711 extensions</b></li>
1949	 * <li>A0 (841x1189 mm ; 33.11x46.81 in)</li>
1950	 * <li>A1 (594x841 mm ; 23.39x33.11 in)</li>
1951	 * <li>A2 (420x594 mm ; 16.54x23.39 in)</li>
1952	 * <li>A3 (297x420 mm ; 11.69x16.54 in)</li>
1953	 * <li>A4 (210x297 mm ; 8.27x11.69 in)</li>
1954	 * <li>A5 (148x210 mm ; 5.83x8.27 in)</li>
1955	 * <li>A6 (105x148 mm ; 4.13x5.83 in)</li>
1956	 * <li>A7 (74x105 mm ; 2.91x4.13 in)</li>
1957	 * <li>A8 (52x74 mm ; 2.05x2.91 in)</li>
1958	 * <li>A9 (37x52 mm ; 1.46x2.05 in)</li>
1959	 * <li>A10 (26x37 mm ; 1.02x1.46 in)</li>
1960	 * <li>A11 (18x26 mm ; 0.71x1.02 in)</li>
1961	 * <li>A12 (13x18 mm ; 0.51x0.71 in)</li>
1962	 * <li><b>ISO 216 B Series + 2 SIS 014711 extensions</b></li>
1963	 * <li>B0 (1000x1414 mm ; 39.37x55.67 in)</li>
1964	 * <li>B1 (707x1000 mm ; 27.83x39.37 in)</li>
1965	 * <li>B2 (500x707 mm ; 19.69x27.83 in)</li>
1966	 * <li>B3 (353x500 mm ; 13.90x19.69 in)</li>
1967	 * <li>B4 (250x353 mm ; 9.84x13.90 in)</li>
1968	 * <li>B5 (1

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