PageRenderTime 315ms CodeModel.GetById 142ms app.highlight 42ms RepoModel.GetById 37ms app.codeStats 7ms

/lib/tcpdf/tcpdf.php

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

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