Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: com-tecnick-tcpdf

License

Content on this site is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Source code for file /tcpdf/tcpdf.php

Documentation is available at tcpdf.php

  1. <?php
  2. //============================================================+
  3. // File name   : tcpdf.php
  4. // Begin       : 2002-08-03
  5. // Last Update : 2007-09-12
  6. // Author      : Nicola Asuni
  7. // Version     : 1.53.0.TC034_PHP4
  8. // License     : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
  9. //
  10. // Description : This is a PHP4 class for generating PDF files 
  11. //               on-the-fly without requiring external 
  12. //               extensions.
  13. //
  14. // IMPORTANT:
  15. // This class is an extension and improvement of the public Domain 
  16. // FPDF class by Olivier Plathey (http://www.fpdf.org).
  17. //
  18. // Main changes by Nicola Asuni:
  19. //    PHP5 porting;
  20. //    UTF-8 Unicode support;
  21. //    code refactoring;
  22. //    source code clean up;
  23. //    code style and formatting;
  24. //    source code documentation using phpDocumentor (www.phpdoc.org);
  25. //    All ISO page formats were included;
  26. //    image scale factor;
  27. //    includes methods to parse and printsome XHTML code, supporting the following elements: h1, h2, h3, h4, h5, h6, b, u, i, a, img, p, br, strong, em, font, blockquote, li, ul, ol, hr, td, th, tr, table, sup, sub, small;
  28. //    includes a method to print various barcode formats using an improved version of "Generic Barcode Render Class" by Karim Mribti (http://www.mribti.com/barcode/) (require GD library: http://www.boutell.com/gd/);
  29. //    defines standard Header() and Footer() methods.
  30. //============================================================+
  31.  
  32.  
  33.  
  34. /**
  35.  * TCPDF Class.
  36.  * @package com.tecnick.tcpdf
  37.  */
  38.  
  39. /**
  40.  * include configuration file
  41.  */
  42. require_once(dirname(__FILE__).'/config/tcpdf_config.php');
  43.  
  44. /**
  45.  * This is a PHP4 class for generating PDF files on-the-fly without requiring external extensions.<br>
  46.  * TCPDF project (http://tcpdf.sourceforge.net) is based on the public Domain FPDF class by Olivier Plathey (http://www.fpdf.org).<br>
  47.  * <h3>TCPDF main changes from FPDF are:</h3><ul>
  48.  * <li>PHP4 porting</li>
  49.  * <li>UTF-8 Unicode support</li>
  50.  * <li>source code clean up</li>
  51.  * <li>code style and formatting</li>
  52.  * <li>source code documentation using phpDocumentor (www.phpdoc.org)</li>
  53.  * <li>All ISO page formats were included</li>
  54.  * <li>image scale factor</li>
  55.  * <li>includes methods to parse and printsome XHTML code, supporting the following elements: h1, h2, h3, h4, h5, h6, b, u, i, a, img, p, br, strong, em, font, blockquote, li, ul, ol, hr, td, th, tr, table, sup, sub, small;</li>
  56.  * <li>includes a method to print various barcode formats using an improved version of "Generic Barcode Render Class" by Karim Mribti (http://www.mribti.com/barcode/) (require GD library: http://www.boutell.com/gd/)</li>
  57.  * <li>defines standard Header() and Footer() methods.</li>
  58.  * </ul>
  59.  * Tools to encode your unicode fonts are on fonts/ttf2ufm directory.</p>
  60.  * @name TCPDF
  61.  * @package com.tecnick.tcpdf
  62.  * @abstract Class for generating PDF files on-the-fly without requiring external extensions.
  63.  * @author Nicola Asuni
  64.  * @copyright 2004-2006 Tecnick.com S.r.l (www.tecnick.com) Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com - info@tecnick.com
  65.  * @link http://tcpdf.sourceforge.net
  66.  * @license http://www.gnu.org/copyleft/lesser.html LGPL
  67.  @version 1.53.0.TC034_PHP4
  68.  */
  69.  
  70. if(!class_exists('TCPDF')) {
  71.     /**
  72.      * define default PDF document producer
  73.      */ 
  74.     define('PDF_PRODUCER','TCPDF 1.53.0.TC034_PHP4 (http://tcpdf.sourceforge.net)');
  75.     
  76.     /**
  77.     * This is a PHP4 class for generating PDF files on-the-fly without requiring external extensions.<br>
  78.     * This class is an extension and improvement of the FPDF class by Olivier Plathey (http://www.fpdf.org).<br>
  79.     * This version contains some changes: [porting to PHP4, support for UTF-8 Unicode, code style and formatting, php documentation (www.phpdoc.org), ISO page formats, minor improvements, image scale factor]<br>
  80.     * TCPDF project (http://tcpdf.sourceforge.net) is based on the public Domain FPDF class by Olivier Plathey (http://www.fpdf.org).<br>
  81.     * To add your own TTF fonts please read /fonts/README.TXT
  82.     * @name TCPDF
  83.     * @package com.tecnick.tcpdf
  84.     * @version 1.53.0.TC034_PHP4
  85.     * @author Nicola Asuni
  86.     * @link http://tcpdf.sourceforge.net
  87.     * @license http://www.gnu.org/copyleft/lesser.html LGPL
  88.     */
  89.     class TCPDF {
  90.         //var properties
  91.  
  92.         
  93.  
  94.         /**
  95.         * @var current page number
  96.         * @access protected
  97.         */
  98.         var $page;
  99.  
  100.         /**
  101.         * @var current object number
  102.         * @access protected
  103.         */
  104.         var $n;
  105.  
  106.         /**
  107.         * @var array of object offsets
  108.         * @access protected
  109.         */
  110.         var $offsets;
  111.  
  112.         /**
  113.         * @var buffer holding in-memory PDF
  114.         * @access protected
  115.         */
  116.         var $buffer;
  117.  
  118.         /**
  119.         * @var array containing pages
  120.         * @access protected
  121.         */
  122.         var $pages;
  123.  
  124.         /**
  125.         * @var current document state
  126.         * @access protected
  127.         */
  128.         var $state;
  129.  
  130.         /**
  131.         * @var compression flag
  132.         * @access protected
  133.         */
  134.         var $compress;
  135.  
  136.         /**
  137.         * @var default orientation
  138.         * @access protected
  139.         */
  140.         var $DefOrientation;
  141.  
  142.         /**
  143.         * @var current orientation
  144.         * @access protected
  145.         */
  146.         var $CurOrientation;
  147.  
  148.         /**
  149.         * @var array indicating orientation changes
  150.         * @access protected
  151.         */
  152.         var $OrientationChanges;
  153.  
  154.         /**
  155.         * @var scale factor (number of points in user unit)
  156.         * @access protected
  157.         */
  158.         var $k;
  159.  
  160.         /**
  161.         * @var width of page format in points
  162.         * @access protected
  163.         */
  164.         var $fwPt;
  165.  
  166.         /**
  167.         * @var height of page format in points
  168.         * @access protected
  169.         */
  170.         var $fhPt;
  171.  
  172.         /**
  173.         * @var width of page format in user unit
  174.         * @access protected
  175.         */
  176.         var $fw;
  177.  
  178.         /**
  179.         * @var height of page format in user unit
  180.         * @access protected
  181.         */
  182.         var $fh;
  183.  
  184.         /**
  185.         * @var current width of page in points
  186.         * @access protected
  187.         */
  188.         var $wPt;
  189.  
  190.         /**
  191.         * @var current height of page in points
  192.         * @access protected
  193.         */
  194.         var $hPt;
  195.  
  196.         /**
  197.         * @var current width of page in user unit
  198.         * @access protected
  199.         */
  200.         var $w;
  201.  
  202.         /**
  203.         * @var current height of page in user unit
  204.         * @access protected
  205.         */
  206.         var $h;
  207.  
  208.         /**
  209.         * @var left margin
  210.         * @access protected
  211.         */
  212.         var $lMargin;
  213.  
  214.         /**
  215.         * @var top margin
  216.         * @access protected
  217.         */
  218.         var $tMargin;
  219.  
  220.         /**
  221.         * @var right margin
  222.         * @access protected
  223.         */
  224.         var $rMargin;
  225.  
  226.         /**
  227.         * @var page break margin
  228.         * @access protected
  229.         */
  230.         var $bMargin;
  231.  
  232.         /**
  233.         * @var cell margin
  234.         * @access protected
  235.         */
  236.         var $cMargin;
  237.  
  238.         /**
  239.         * @var current horizontal position in user unit for cell positioning
  240.         * @access protected
  241.         */
  242.         var $x;
  243.  
  244.         /**
  245.         * @var current vertical position in user unit for cell positioning
  246.         * @access protected
  247.         */
  248.         var $y;
  249.  
  250.         /**
  251.         * @var height of last cell printed
  252.         * @access protected
  253.         */
  254.         var $lasth;
  255.  
  256.         /**
  257.         * @var line width in user unit
  258.         * @access protected
  259.         */
  260.         var $LineWidth;
  261.  
  262.         /**
  263.         * @var array of standard font names
  264.         * @access protected
  265.         */
  266.         var $CoreFonts;
  267.  
  268.         /**
  269.         * @var array of used fonts
  270.         * @access protected
  271.         */
  272.         var $fonts;
  273.  
  274.         /**
  275.         * @var array of font files
  276.         * @access protected
  277.         */
  278.         var $FontFiles;
  279.  
  280.         /**
  281.         * @var array of encoding differences
  282.         * @access protected
  283.         */
  284.         var $diffs;
  285.  
  286.         /**
  287.         * @var array of used images
  288.         * @access protected
  289.         */
  290.         var $images;
  291.  
  292.         /**
  293.         * @var array of links in pages
  294.         * @access protected
  295.         */
  296.         var $PageLinks;
  297.  
  298.         /**
  299.         * @var array of internal links
  300.         * @access protected
  301.         */
  302.         var $links;
  303.  
  304.         /**
  305.         * @var current font family
  306.         * @access protected
  307.         */
  308.         var $FontFamily;
  309.  
  310.         /**
  311.         * @var current font style
  312.         * @access protected
  313.         */
  314.         var $FontStyle;
  315.  
  316.         /**
  317.         * @var underlining flag
  318.         * @access protected
  319.         */
  320.         var $underline;
  321.  
  322.         /**
  323.         * @var current font info
  324.         * @access protected
  325.         */
  326.         var $CurrentFont;
  327.  
  328.         /**
  329.         * @var current font size in points
  330.         * @access protected
  331.         */
  332.         var $FontSizePt;
  333.  
  334.         /**
  335.         * @var current font size in user unit
  336.         * @access protected
  337.         */
  338.         var $FontSize;
  339.  
  340.         /**
  341.         * @var commands for drawing color
  342.         * @access protected
  343.         */
  344.         var $DrawColor;
  345.  
  346.         /**
  347.         * @var commands for filling color
  348.         * @access protected
  349.         */
  350.         var $FillColor;
  351.  
  352.         /**
  353.         * @var commands for text color
  354.         * @access protected
  355.         */
  356.         var $TextColor;
  357.  
  358.         /**
  359.         * @var indicates whether fill and text colors are different
  360.         * @access protected
  361.         */
  362.         var $ColorFlag;
  363.  
  364.         /**
  365.         * @var word spacing
  366.         * @access protected
  367.         */
  368.         var $ws;
  369.  
  370.         /**
  371.         * @var automatic page breaking
  372.         * @access protected
  373.         */
  374.         var $AutoPageBreak;
  375.  
  376.         /**
  377.         * @var threshold used to trigger page breaks
  378.         * @access protected
  379.         */
  380.         var $PageBreakTrigger;
  381.  
  382.         /**
  383.         * @var flag set when processing footer
  384.         * @access protected
  385.         */
  386.         var $InFooter;
  387.  
  388.         /**
  389.         * @var zoom display mode
  390.         * @access protected
  391.         */
  392.         var $ZoomMode;
  393.  
  394.         /**
  395.         * @var layout display mode
  396.         * @access protected
  397.         */
  398.         var $LayoutMode;
  399.  
  400.         /**
  401.         * @var title 
  402.         * @access protected
  403.         */
  404.         var $title;
  405.  
  406.         /**
  407.         * @var subject 
  408.         * @access protected
  409.         */
  410.         var $subject;
  411.  
  412.         /**
  413.         * @var author 
  414.         * @access protected
  415.         */
  416.         var $author;
  417.  
  418.         /**
  419.         * @var keywords 
  420.         * @access protected
  421.         */
  422.         var $keywords;
  423.  
  424.         /**
  425.         * @var creator 
  426.         * @access protected
  427.         */
  428.         var $creator;
  429.  
  430.         /**
  431.         * @var alias for total number of pages
  432.         * @access protected
  433.         */
  434.         var $AliasNbPages;
  435.  
  436.         /**
  437.         * @var right-bottom corner X coordinate of inserted image
  438.         * @since 2002-07-31
  439.         * @author Nicola Asuni
  440.         * @access protected
  441.         */
  442.         var $img_rb_x;
  443.  
  444.         /**
  445.         * @var right-bottom corner Y coordinate of inserted image
  446.         * @since 2002-07-31
  447.         * @author Nicola Asuni
  448.         * @access protected
  449.         */
  450.         var $img_rb_y;
  451.  
  452.         /**
  453.         * @var image scale factor
  454.         * @since 2004-06-14
  455.         * @author Nicola Asuni
  456.         * @access protected
  457.         */
  458.         var $imgscale = 1;
  459.  
  460.         /**
  461.         * @var boolean set to true when the input text is unicode (require unicode fonts)
  462.         * @since 2005-01-02
  463.         * @author Nicola Asuni
  464.         * @access protected
  465.         */
  466.         var $isunicode = false;
  467.  
  468.         /**
  469.         * @var PDF version
  470.         * @since 1.5.3
  471.         * @access protected
  472.         */
  473.         var $PDFVersion = "1.3";
  474.         
  475.         
  476.         // ----------------------
  477.         
  478.         
  479.         
  480.         /**
  481.          * @var Minimum distance between header and top page margin.
  482.          * @access private
  483.          */
  484.         var $header_margin;
  485.         
  486.         /**
  487.          * @var Minimum distance between footer and bottom page margin.
  488.          * @access private
  489.          */
  490.         var $footer_margin;
  491.         
  492.         /**
  493.          * @var original left margin value
  494.          * @access private
  495.          * @since 1.53.0.TC013
  496.          */
  497.         var $original_lMargin;
  498.         
  499.         /**
  500.          * @var original right margin value
  501.          * @access private
  502.          * @since 1.53.0.TC013
  503.          */
  504.         var $original_rMargin;
  505.             
  506.         /**
  507.          * @var Header font.
  508.          * @access private
  509.          */
  510.         var $header_font;
  511.         
  512.         /**
  513.          * @var Footer font.
  514.          * @access private
  515.          */
  516.         var $footer_font;
  517.         
  518.         /**
  519.          * @var Language templates.
  520.          * @access private
  521.          */
  522.         var $l;
  523.         
  524.         /**
  525.          * @var Barcode to print on page footer (only if set).
  526.          * @access private
  527.          */
  528.         var $barcode false;
  529.         
  530.         /**
  531.          * @var If true prints header
  532.          * @access private
  533.          */
  534.         var $print_header true;
  535.         
  536.         /**
  537.          * @var If true prints footer.
  538.          * @access private
  539.          */
  540.         var $print_footer true;
  541.         
  542.         /**
  543.          * @var Header width (0 = full page width).
  544.          * @access private
  545.          */
  546.         var $header_width 0;
  547.         
  548.         /**
  549.          * @var Header image logo.
  550.          * @access private
  551.          */
  552.         var $header_logo "";
  553.         
  554.         /**
  555.          * @var Header image logo width in mm.
  556.          * @access private
  557.          */
  558.         var $header_logo_width 30;
  559.         
  560.         /**
  561.          * @var String to print as title on document header.
  562.          * @access private
  563.          */
  564.         var $header_title "";
  565.         
  566.         /**
  567.          * @var String to print on document header.
  568.          * @access private
  569.          */
  570.         var $header_string "";
  571.         
  572.         /**
  573.          * @var Default number of columns for html table.
  574.          * @access private
  575.          */
  576.         var $default_table_columns 4;
  577.         
  578.         
  579.         // variables for html parser
  580.         
  581.         
  582.         
  583.         /**
  584.          * @var HTML PARSER: store current link.
  585.          * @access private
  586.          */
  587.         var $HREF;
  588.         
  589.         /**
  590.          * @var HTML PARSER: store font list.
  591.          * @access private
  592.          */
  593.         var $fontList;
  594.         
  595.         /**
  596.          * @var HTML PARSER: true when font attribute is set.
  597.          * @access private
  598.          */
  599.         var $issetfont;
  600.         
  601.         /**
  602.          * @var HTML PARSER: true when color attribute is set.
  603.          * @access private
  604.          */
  605.         var $issetcolor;
  606.         
  607.         /**
  608.          * @var HTML PARSER: true in case of ordered list (OL), false otherwise.
  609.          * @access private
  610.          */
  611.         var $listordered false;
  612.         
  613.         /**
  614.          * @var HTML PARSER: count list items.
  615.          * @access private
  616.          */
  617.         var $listcount 0;
  618.         
  619.         /**
  620.          * @var HTML PARSER: size of table border.