diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 16636ce..42c9031 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,8 @@ +6.0.017 (2013-05-16) + - The command line tool tcpdf_addfont.php was improved. + - The php logic was removed from configuration files that now contains only constant defines. + - The tcpdf_autoconfig.php file was added to automatically set missing configuration values. + 6.0.016 (2013-05-15) - The tcpdf_addfont.php tool was improved (thanks to Remi Collet). - Constant K_PATH_IMAGES is now automatically set in configuration file. diff --git a/README.TXT b/README.TXT index 9c2c19d..b6d1fff 100644 --- a/README.TXT +++ b/README.TXT @@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 6.0.016 -Release date: 2013-05-15 +Version: 6.0.017 +Release date: 2013-05-16 Author: Nicola Asuni Copyright (c) 2002-2013: @@ -18,8 +18,8 @@ Copyright (c) 2002-2013: www.tecnick.com URLs: - http: www.tcpdf.org - http: www.sourceforge.net/projects/tcpdf + http://www.tcpdf.org + http://www.sourceforge.net/projects/tcpdf Description: TCPDF is a PHP class for generating PDF files on-the-fly without requiring external extensions. diff --git a/composer.json b/composer.json index d2ffdea..fc1b4a3 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "6.0.016", + "version": "6.0.017", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents.", diff --git a/config/tcpdf_config.php b/config/tcpdf_config.php index 39f59dd..e6c1bf0 100644 --- a/config/tcpdf_config.php +++ b/config/tcpdf_config.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tcpdf_config.php // Begin : 2004-06-11 -// Last Update : 2013-05-15 +// Last Update : 2013-05-16 // // Description : Configuration file for TCPDF. // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com @@ -38,255 +38,181 @@ // If you define the constant K_TCPDF_EXTERNAL_CONFIG, the following settings will be ignored. -if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { +/** + * Installation path (/var/www/tcpdf/). + * By default it is automatically calculated but you can also set it as a fixed string to improve performances. + */ +//define ('K_PATH_MAIN', ''); - // DOCUMENT_ROOT fix for IIS Webserver - if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) { - if(isset($_SERVER['SCRIPT_FILENAME'])) { - $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']))); - } elseif(isset($_SERVER['PATH_TRANSLATED'])) { - $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF']))); - } else { - // define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www') - $_SERVER['DOCUMENT_ROOT'] = '/'; - } - } - // be sure that the end slash is present - $_SERVER['DOCUMENT_ROOT'] = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT'].'/'); +/** + * URL path to tcpdf installation folder (http://localhost/tcpdf/). + * By default it is automatically set but you can also set it as a fixed string to improve performances. + */ +//define ('K_PATH_URL', ''); - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Try to automatically set the value for the following K_PATH_MAIN constant. - // NOTE: delete this section and manually set the K_PATH_MAIN constant below for better performances. - $tcpdf_install_dirs = array(); - if ((strpos(dirname(__FILE__), '/config') !== false) OR (strpos(dirname(__FILE__), '\config') !== false)) { - // default config file - $k_path_main_default = str_replace( '\\', '/', realpath(substr(dirname(__FILE__), 0, 0-strlen('config')))); - if (substr($k_path_main_default, -1) != '/') { - $k_path_main_default .= '/'; - } - $tcpdf_install_dirs[] = $k_path_main_default; - } - $tcpdf_install_dirs += array('/usr/share/php/tcpdf/', '/usr/share/tcpdf/', '/usr/share/php-tcpdf/', '/var/www/tcpdf/', '/var/www/html/tcpdf/', '/usr/local/apache2/htdocs/tcpdf/'); - foreach ($tcpdf_install_dirs as $k_path_main) { - if (file_exists($k_path_main.'tcpdf.php')) { - break; - } - } - if (!file_exists($k_path_main)) { - die('TCPDF ERROR: please set the correct path to TCPDF on the configuration file'); - } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +/** + * Path for PDF fonts. + * By default it is automatically set but you can also set it as a fixed string to improve performances. + */ +//define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/'); - /** - * Installation path (/var/www/tcpdf/). - * By default it is automatically calculated but you can also set it as a fixed string to improve performances. - */ - define ('K_PATH_MAIN', $k_path_main); +/** + * Default images directory. + * By default it is automatically set but you can also set it as a fixed string to improve performances. + */ +//define ('K_PATH_IMAGES', ''); - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Try to automatically set the value for the following K_PATH_URL constant. - // NOTE: delete this section and manually set the K_PATH_URL constant below for better performances. - $k_path_url = $k_path_main; // default value for console mode - if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) { - if(isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND (strtolower($_SERVER['HTTPS']) != 'off')) { - $k_path_url = 'https://'; - } else { - $k_path_url = 'http://'; - } - $k_path_url .= $_SERVER['HTTP_HOST']; - $k_path_url .= str_replace( '\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1))); - } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +/** + * Deafult image logo used be the default Header() method. + * Please set here your own logo or an empty string to disable it. + */ +//define ('PDF_HEADER_LOGO', ''); - /** - * URL path to tcpdf installation folder (http://localhost/tcpdf/). - * By default it is automatically set but you can also set it as a fixed string to improve performances. - */ - define ('K_PATH_URL', $k_path_url); +/** + * Header logo image width in user units. + */ +//define ('PDF_HEADER_LOGO_WIDTH', 0); - /** - * Cache directory for temporary files (full path). - */ - define ('K_PATH_CACHE', sys_get_temp_dir().'/'); +/** + * Cache directory for temporary files (full path). + */ +define ('K_PATH_CACHE', sys_get_temp_dir().'/'); - /** - * Path for PDF fonts. - */ - define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/'); +/** + * Generic name for a blank image. + */ +define ('K_BLANK_IMAGE', '_blank.png'); - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Try to automatically set the value for the following K_PATH_IMAGES constant. - // NOTE: delete this section and manually set the K_PATH_IMAGES constant below for better performances. - $tcpdf_images_dirs = array(K_PATH_MAIN.'examples/images/', '/usr/share/doc/tcpdf/examples/images/', '/usr/share/doc/php-tcpdf/examples/images/', '/usr/share/doc/php/tcpdf/examples/images/', '/var/www/tcpdf/images/', '/var/www/html/tcpdf/images/', '/usr/local/apache2/htdocs/tcpdf/images/', K_PATH_MAIN); - foreach ($tcpdf_images_dirs as $tcpdf_images_path) { - if (file_exists($tcpdf_images_path)) { - break; - } - } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +/** + * Page format. + */ +define ('PDF_PAGE_FORMAT', 'A4'); - /** - * Default images directory. - * By default it is automatically set but you can also set it as a fixed string to improve performances. - */ - define ('K_PATH_IMAGES', $tcpdf_images_path); +/** + * Page orientation (P=portrait, L=landscape). + */ +define ('PDF_PAGE_ORIENTATION', 'P'); - /** - * Blank image. - */ - define ('K_BLANK_IMAGE', K_PATH_IMAGES.'_blank.png'); +/** + * Document creator. + */ +define ('PDF_CREATOR', 'TCPDF'); - /** - * Page format. - */ - define ('PDF_PAGE_FORMAT', 'A4'); +/** + * Document author. + */ +define ('PDF_AUTHOR', 'TCPDF'); - /** - * Page orientation (P=portrait, L=landscape). - */ - define ('PDF_PAGE_ORIENTATION', 'P'); +/** + * Header title. + */ +define ('PDF_HEADER_TITLE', 'TCPDF Example'); - /** - * Document creator. - */ - define ('PDF_CREATOR', 'TCPDF'); +/** + * Header description string. + */ +define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); - /** - * Document author. - */ - define ('PDF_AUTHOR', 'TCPDF'); +/** + * Document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]. + */ +define ('PDF_UNIT', 'mm'); - /** - * Header title. - */ - define ('PDF_HEADER_TITLE', 'TCPDF Example'); +/** + * Header margin. + */ +define ('PDF_MARGIN_HEADER', 5); - /** - * Header description string. - */ - define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); +/** + * Footer margin. + */ +define ('PDF_MARGIN_FOOTER', 10); - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Try to automatically set the value for the following K_PATH_IMAGES constant. - // NOTE: delete this section and manually set the K_PATH_IMAGES constant below for better performances. - $tcpdf_header_logo = ''; - if (file_exists(K_PATH_IMAGES.'tcpdf_logo.jpg')) { - $tcpdf_header_logo = 'tcpdf_logo.jpg'; - } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +/** + * Top margin. + */ +define ('PDF_MARGIN_TOP', 27); - /** - * Deafult image logo used be the default Header() method. - * Please set here your own logo or an empty string to disable it. - */ - define ('PDF_HEADER_LOGO', $tcpdf_header_logo); +/** + * Bottom margin. + */ +define ('PDF_MARGIN_BOTTOM', 25); - /** - * Header logo image width [mm]. - */ - define ('PDF_HEADER_LOGO_WIDTH', 30); +/** + * Left margin. + */ +define ('PDF_MARGIN_LEFT', 15); - /** - * Document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]. - */ - define ('PDF_UNIT', 'mm'); +/** + * Right margin. + */ +define ('PDF_MARGIN_RIGHT', 15); - /** - * Header margin. - */ - define ('PDF_MARGIN_HEADER', 5); +/** + * Default main font name. + */ +define ('PDF_FONT_NAME_MAIN', 'helvetica'); - /** - * Footer margin. - */ - define ('PDF_MARGIN_FOOTER', 10); +/** + * Default main font size. + */ +define ('PDF_FONT_SIZE_MAIN', 10); - /** - * Top margin. - */ - define ('PDF_MARGIN_TOP', 27); +/** + * Default data font name. + */ +define ('PDF_FONT_NAME_DATA', 'helvetica'); - /** - * Bottom margin. - */ - define ('PDF_MARGIN_BOTTOM', 25); +/** + * Default data font size. + */ +define ('PDF_FONT_SIZE_DATA', 8); - /** - * Left margin. - */ - define ('PDF_MARGIN_LEFT', 15); +/** + * Default monospaced font name. + */ +define ('PDF_FONT_MONOSPACED', 'courier'); - /** - * Right margin. - */ - define ('PDF_MARGIN_RIGHT', 15); +/** + * Ratio used to adjust the conversion of pixels to user units. + */ +define ('PDF_IMAGE_SCALE_RATIO', 1.25); - /** - * Default main font name. - */ - define ('PDF_FONT_NAME_MAIN', 'helvetica'); +/** + * Magnification factor for titles. + */ +define('HEAD_MAGNIFICATION', 1.1); - /** - * Default main font size. - */ - define ('PDF_FONT_SIZE_MAIN', 10); +/** + * Height of cell respect font height. + */ +define('K_CELL_HEIGHT_RATIO', 1.25); - /** - * Default data font name. - */ - define ('PDF_FONT_NAME_DATA', 'helvetica'); +/** + * Title magnification respect main font size. + */ +define('K_TITLE_MAGNIFICATION', 1.3); - /** - * Default data font size. - */ - define ('PDF_FONT_SIZE_DATA', 8); +/** + * Reduction factor for small font. + */ +define('K_SMALL_RATIO', 2/3); - /** - * Default monospaced font name. - */ - define ('PDF_FONT_MONOSPACED', 'courier'); +/** + * Set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language. + */ +define('K_THAI_TOPCHARS', true); - /** - * Ratio used to adjust the conversion of pixels to user units. - */ - define ('PDF_IMAGE_SCALE_RATIO', 1.25); +/** + * If true allows to call TCPDF methods using HTML syntax + * IMPORTANT: For security reason, disable this feature if you are printing user HTML content. + */ +define('K_TCPDF_CALLS_IN_HTML', true); - /** - * Magnification factor for titles. - */ - define('HEAD_MAGNIFICATION', 1.1); - - /** - * Height of cell respect font height. - */ - define('K_CELL_HEIGHT_RATIO', 1.25); - - /** - * Title magnification respect main font size. - */ - define('K_TITLE_MAGNIFICATION', 1.3); - - /** - * Reduction factor for small font. - */ - define('K_SMALL_RATIO', 2/3); - - /** - * Set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language. - */ - define('K_THAI_TOPCHARS', true); - - /** - * If true allows to call TCPDF methods using HTML syntax - * IMPORTANT: For security reason, disable this feature if you are printing user HTML content. - */ - define('K_TCPDF_CALLS_IN_HTML', true); - - /** - * If true adn PHP version is greater than 5, then the Error() method throw new exception instead of terminating the execution. - */ - define('K_TCPDF_THROW_EXCEPTION_ERROR', false); -} +/** + * If true adn PHP version is greater than 5, then the Error() method throw new exception instead of terminating the execution. + */ +define('K_TCPDF_THROW_EXCEPTION_ERROR', false); //============================================================+ // END OF FILE diff --git a/examples/config/tcpdf_config_alt.php b/examples/config/tcpdf_config_alt.php index 7fe4b59..5450bef 100644 --- a/examples/config/tcpdf_config_alt.php +++ b/examples/config/tcpdf_config_alt.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tcpdf_config.php // Begin : 2004-06-11 -// Last Update : 2013-05-15 +// Last Update : 2013-05-16 // // Description : Example of alternative configuration file for TCPDF. // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com @@ -36,72 +36,45 @@ * @since 2004-10-27 */ -// Define the following constant to ignore the default configuration file. +/** + * Define the following constant to ignore the default configuration file. + */ define ('K_TCPDF_EXTERNAL_CONFIG', true); -// DOCUMENT_ROOT fix for IIS Webserver -if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) { - if(isset($_SERVER['SCRIPT_FILENAME'])) { - $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']))); - } elseif(isset($_SERVER['PATH_TRANSLATED'])) { - $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF']))); - } else { - // define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www') - $_SERVER['DOCUMENT_ROOT'] = '/'; - } -} -// be sure that the end slash is present -$_SERVER['DOCUMENT_ROOT'] = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT'].'/'); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Try to automatically set the value for the following K_PATH_MAIN constant. -// NOTE: delete this section and manually set the K_PATH_MAIN constant below for better performances. -$tcpdf_install_dirs = array(); -if ((strpos(dirname(__FILE__), '/config') !== false) OR (strpos(dirname(__FILE__), '\config') !== false)) { - // default config file - $k_path_main_default = str_replace( '\\', '/', realpath(substr(dirname(__FILE__), 0, 0-strlen('examples/config')))); - if (substr($k_path_main_default, -1) != '/') { - $k_path_main_default .= '/'; - } - $tcpdf_install_dirs[] = $k_path_main_default; -} -$tcpdf_install_dirs += array('/usr/share/php/tcpdf/', '/usr/share/tcpdf/', '/usr/share/php-tcpdf/', '/var/www/tcpdf/', '/var/www/html/tcpdf/', '/usr/local/apache2/htdocs/tcpdf/'); -foreach ($tcpdf_install_dirs as $k_path_main) { - if (file_exists($k_path_main.'tcpdf.php')) { - break; - } -} -if (!file_exists($k_path_main)) { - die('TCPDF ERROR: please set the correct path to TCPDF on the configuration file'); -} -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** * Installation path (/var/www/tcpdf/). * By default it is automatically calculated but you can also set it as a fixed string to improve performances. */ -define ('K_PATH_MAIN', $k_path_main); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Try to automatically set the value for the following K_PATH_URL constant. -// NOTE: delete this section and manually set the K_PATH_URL constant below for better performances. -$k_path_url = $k_path_main; // default value for console mode -if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) { - if(isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND (strtolower($_SERVER['HTTPS']) != 'off')) { - $k_path_url = 'https://'; - } else { - $k_path_url = 'http://'; - } - $k_path_url .= $_SERVER['HTTP_HOST']; - $k_path_url .= str_replace( '\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1))); -} -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +//define ('K_PATH_MAIN', ''); /** * URL path to tcpdf installation folder (http://localhost/tcpdf/). * By default it is automatically set but you can also set it as a fixed string to improve performances. */ -define ('K_PATH_URL', $k_path_url); +//define ('K_PATH_URL', ''); + +/** + * Path for PDF fonts. + * By default it is automatically set but you can also set it as a fixed string to improve performances. + */ +//define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/'); + +/** + * Default images directory. + * By default it is automatically set but you can also set it as a fixed string to improve performances. + */ +define ('K_PATH_IMAGES', __DIR__.'/../images/'); + +/** + * Deafult image logo used be the default Header() method. + * Please set here your own logo or an empty string to disable it. + */ +define ('PDF_HEADER_LOGO', 'tcpdf_logo.jpg'); + +/** + * Header logo image width in user units. + */ +define ('PDF_HEADER_LOGO_WIDTH', 30); /** * Cache directory for temporary files (full path). @@ -109,31 +82,9 @@ define ('K_PATH_URL', $k_path_url); define ('K_PATH_CACHE', sys_get_temp_dir().'/'); /** - * Path for PDF fonts. + * Generic name for a blank image. */ -define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/'); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Try to automatically set the value for the following K_PATH_IMAGES constant. -// NOTE: delete this section and manually set the K_PATH_IMAGES constant below for better performances. -$tcpdf_images_dirs = array(K_PATH_MAIN.'examples/images/', '/usr/share/doc/tcpdf/examples/images/', '/usr/share/doc/php-tcpdf/examples/images/', '/usr/share/doc/php/tcpdf/examples/images/', '/var/www/tcpdf/images/', '/var/www/html/tcpdf/images/', '/usr/local/apache2/htdocs/tcpdf/images/', K_PATH_MAIN); -foreach ($tcpdf_images_dirs as $tcpdf_images_path) { - if (file_exists($tcpdf_images_path)) { - break; - } -} -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/** - * Default images directory. - * By default it is automatically set but you can also set it as a fixed string to improve performances. - */ -define ('K_PATH_IMAGES', $tcpdf_images_path); - -/** - * Blank image. - */ -define ('K_BLANK_IMAGE', K_PATH_IMAGES.'_blank.png'); +define ('K_BLANK_IMAGE', '_blank.png'); /** * Page format. @@ -165,26 +116,6 @@ define ('PDF_HEADER_TITLE', 'TCPDF Example'); */ define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Try to automatically set the value for the following K_PATH_IMAGES constant. -// NOTE: delete this section and manually set the K_PATH_IMAGES constant below for better performances. -$tcpdf_header_logo = ''; -if (file_exists(K_PATH_IMAGES.'tcpdf_logo.jpg')) { - $tcpdf_header_logo = 'tcpdf_logo.jpg'; -} -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/** - * Deafult image logo used be the default Header() method. - * Please set here your own logo or an empty string to disable it. - */ -define ('PDF_HEADER_LOGO', $tcpdf_header_logo); - -/** - * Header logo image width [mm]. - */ -define ('PDF_HEADER_LOGO_WIDTH', 30); - /** * Document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]. */ diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index c1bad9e..b6c4e92 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.0.016'; + private static $tcpdf_version = '6.0.017'; /** * String alias for total number of pages. diff --git a/tcpdf.php b/tcpdf.php index dd0cedd..d875b60 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.0.016 + * @version 6.0.017 */ -// Load main configuration file only if the K_TCPDF_EXTERNAL_CONFIG constant is set to false. -if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { - // define a list of default config files in order of priority - $tcpdf_config_files = array(dirname(__FILE__).'/config/tcpdf_config.php', '/etc/php-tcpdf/tcpdf_config.php', '/etc/tcpdf/tcpdf_config.php', '/etc/tcpdf_config.php'); - foreach ($tcpdf_config_files as $tcpdf_config) { - if (file_exists($tcpdf_config) AND is_readable($tcpdf_config)) { - require_once($tcpdf_config); - break; - } - } -} -if (!defined('K_PATH_MAIN')) { - $this->Error('Unable to include configuration file.'); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// TCPDF configuration +require_once(__DIR__.'/tcpdf_autoconfig.php'); // TCPDF static font methods and data -require_once(dirname(__FILE__).'/include/tcpdf_font_data.php'); +require_once(__DIR__.'/include/tcpdf_font_data.php'); // TCPDF static font methods and data -require_once(dirname(__FILE__).'/include/tcpdf_fonts.php'); +require_once(__DIR__.'/include/tcpdf_fonts.php'); // TCPDF static color methods and data -require_once(dirname(__FILE__).'/include/tcpdf_colors.php'); +require_once(__DIR__.'/include/tcpdf_colors.php'); // TCPDF static image methods and data -require_once(dirname(__FILE__).'/include/tcpdf_images.php'); +require_once(__DIR__.'/include/tcpdf_images.php'); // TCPDF static methods and data -require_once(dirname(__FILE__).'/include/tcpdf_static.php'); +require_once(__DIR__.'/include/tcpdf_static.php'); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -178,7 +163,7 @@ require_once(dirname(__FILE__).'/include/tcpdf_static.php'); * 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.
* @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 6.0.016 + * @version 6.0.017 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { @@ -9628,7 +9613,7 @@ class TCPDF { // if required, add standard sRGB_IEC61966-2.1 blackscaled ICC colour profile if ($this->pdfa_mode OR $this->force_srgb) { $iccobj = $this->_newobj(); - $icc = file_get_contents(dirname(__FILE__).'/include/sRGB.icc'); + $icc = file_get_contents(__DIR__.'/include/sRGB.icc'); $filter = ''; if ($this->compress) { $filter = ' /Filter /FlateDecode'; @@ -15066,7 +15051,7 @@ class TCPDF { if (TCPDF_STATIC::empty_string(trim($code))) { return; } - require_once(dirname(__FILE__).'/tcpdf_barcodes_1d.php'); + require_once(__DIR__.'/tcpdf_barcodes_1d.php'); // save current graphic settings $gvars = $this->getGraphicVars(); // create new barcode object @@ -15382,7 +15367,7 @@ class TCPDF { if (TCPDF_STATIC::empty_string(trim($code))) { return; } - require_once(dirname(__FILE__).'/tcpdf_barcodes_2d.php'); + require_once(__DIR__.'/tcpdf_barcodes_2d.php'); // save current graphic settings $gvars = $this->getGraphicVars(); // create new barcode object diff --git a/tcpdf_autoconfig.php b/tcpdf_autoconfig.php new file mode 100644 index 0000000..c5e5ab7 --- /dev/null +++ b/tcpdf_autoconfig.php @@ -0,0 +1,233 @@ +. +// +// See LICENSE.TXT file for more information. +// ------------------------------------------------------------------- +// +// Description : Try to automatically configure some TCPDF +// constants if not defined. +// +//============================================================+ + +/** + * @file + * Try to automatically configure some TCPDF constants if not defined. + * @package com.tecnick.tcpdf + * @version 1.0.000 + */ + +// DOCUMENT_ROOT fix for IIS Webserver +if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) { + if(isset($_SERVER['SCRIPT_FILENAME'])) { + $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']))); + } elseif(isset($_SERVER['PATH_TRANSLATED'])) { + $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF']))); + } else { + // define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www') + $_SERVER['DOCUMENT_ROOT'] = '/'; + } +} +$_SERVER['DOCUMENT_ROOT'] = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT']); +if (substr($_SERVER['DOCUMENT_ROOT'], -1) != '/') { + $_SERVER['DOCUMENT_ROOT'] .= '/'; +} + +// Load main configuration file only if the K_TCPDF_EXTERNAL_CONFIG constant is set to false. +if (!defined('K_TCPDF_EXTERNAL_CONFIG') OR !K_TCPDF_EXTERNAL_CONFIG) { + // define a list of default config files in order of priority + $tcpdf_config_files = array(__DIR__.'/config/tcpdf_config.php', '/etc/php-tcpdf/tcpdf_config.php', '/etc/tcpdf/tcpdf_config.php', '/etc/tcpdf_config.php'); + foreach ($tcpdf_config_files as $tcpdf_config) { + if (file_exists($tcpdf_config) AND is_readable($tcpdf_config)) { + require_once($tcpdf_config); + break; + } + } +} + +if (!defined('K_PATH_MAIN')) { + define ('K_PATH_MAIN', __DIR__.'/'); +} + +if (!defined('K_PATH_FONTS')) { + define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/'); +} + +if (!defined('K_PATH_URL')) { + $k_path_url = K_PATH_MAIN; // default value for console mode + if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) { + if(isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND (strtolower($_SERVER['HTTPS']) != 'off')) { + $k_path_url = 'https://'; + } else { + $k_path_url = 'http://'; + } + $k_path_url .= $_SERVER['HTTP_HOST']; + $k_path_url .= str_replace( '\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1))); + } + define ('K_PATH_URL', $k_path_url); +} + +if (!defined('K_PATH_IMAGES')) { + $tcpdf_images_dirs = array(K_PATH_MAIN.'examples/images/', K_PATH_MAIN.'images/', '/usr/share/doc/php-tcpdf/examples/images/', '/usr/share/doc/tcpdf/examples/images/', '/usr/share/doc/php/tcpdf/examples/images/', '/var/www/tcpdf/images/', '/var/www/html/tcpdf/images/', '/usr/local/apache2/htdocs/tcpdf/images/', K_PATH_MAIN); + foreach ($tcpdf_images_dirs as $tcpdf_images_path) { + if (file_exists($tcpdf_images_path)) { + break; + } + } + define ('K_PATH_IMAGES', $tcpdf_images_path); +} + +if (!defined('PDF_HEADER_LOGO')) { + $tcpdf_header_logo = ''; + if (file_exists(K_PATH_IMAGES.'tcpdf_logo.jpg')) { + $tcpdf_header_logo = 'tcpdf_logo.jpg'; + } + define ('PDF_HEADER_LOGO', $tcpdf_header_logo); +} + +if (!defined('PDF_HEADER_LOGO_WIDTH')) { + if (!empty($tcpdf_header_logo)) { + define ('PDF_HEADER_LOGO_WIDTH', 30); + } else { + define ('PDF_HEADER_LOGO_WIDTH', 0); + } +} + +if (!defined('K_PATH_CACHE')) { + define ('K_PATH_CACHE', sys_get_temp_dir().'/'); +} + +if (!defined('K_BLANK_IMAGE')) { + define ('K_BLANK_IMAGE', '_blank.png'); +} + +if (!defined('PDF_PAGE_FORMAT')) { + define ('PDF_PAGE_FORMAT', 'A4'); +} + +if (!defined('PDF_PAGE_ORIENTATION')) { + define ('PDF_PAGE_ORIENTATION', 'P'); +} + +if (!defined('PDF_CREATOR')) { + define ('PDF_CREATOR', 'TCPDF'); +} + +if (!defined('PDF_AUTHOR')) { + define ('PDF_AUTHOR', 'TCPDF'); +} + +if (!defined('PDF_HEADER_TITLE')) { + define ('PDF_HEADER_TITLE', 'TCPDF Example'); +} + +if (!defined('PDF_HEADER_STRING')) { + define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); +} + +if (!defined('PDF_UNIT')) { + define ('PDF_UNIT', 'mm'); +} + +if (!defined('PDF_MARGIN_HEADER')) { + define ('PDF_MARGIN_HEADER', 5); +} + +if (!defined('PDF_MARGIN_FOOTER')) { + define ('PDF_MARGIN_FOOTER', 10); +} + +if (!defined('PDF_MARGIN_TOP')) { + define ('PDF_MARGIN_TOP', 27); +} + +if (!defined('PDF_MARGIN_BOTTOM')) { + define ('PDF_MARGIN_BOTTOM', 25); +} + +if (!defined('PDF_MARGIN_LEFT')) { + define ('PDF_MARGIN_LEFT', 15); +} + +if (!defined('PDF_MARGIN_RIGHT')) { + define ('PDF_MARGIN_RIGHT', 15); +} + +if (!defined('PDF_FONT_NAME_MAIN')) { + define ('PDF_FONT_NAME_MAIN', 'helvetica'); +} + +if (!defined('PDF_FONT_SIZE_MAIN')) { + define ('PDF_FONT_SIZE_MAIN', 10); +} + +if (!defined('PDF_FONT_NAME_DATA')) { + define ('PDF_FONT_NAME_DATA', 'helvetica'); +} + +if (!defined('PDF_FONT_SIZE_DATA')) { + define ('PDF_FONT_SIZE_DATA', 8); +} + +if (!defined('PDF_FONT_MONOSPACED')) { + define ('PDF_FONT_MONOSPACED', 'courier'); +} + +if (!defined('PDF_IMAGE_SCALE_RATIO')) { + define ('PDF_IMAGE_SCALE_RATIO', 1.25); +} + +if (!defined('HEAD_MAGNIFICATION')) { + define('HEAD_MAGNIFICATION', 1.1); +} + +if (!defined('K_CELL_HEIGHT_RATIO')) { + define('K_CELL_HEIGHT_RATIO', 1.25); +} + +if (!defined('K_TITLE_MAGNIFICATION')) { + define('K_TITLE_MAGNIFICATION', 1.3); +} + +if (!defined('K_SMALL_RATIO')) { + define('K_SMALL_RATIO', 2/3); +} + +if (!defined('K_THAI_TOPCHARS')) { + define('K_THAI_TOPCHARS', true); +} + +if (!defined('K_TCPDF_CALLS_IN_HTML')) { + define('K_TCPDF_CALLS_IN_HTML', true); +} + +if (!defined('K_TCPDF_THROW_EXCEPTION_ERROR')) { + define('K_TCPDF_THROW_EXCEPTION_ERROR', false); +} + +//============================================================+ +// END OF FILE +//============================================================+ diff --git a/tools/tcpdf_addfont.php b/tools/tcpdf_addfont.php index cfe4943..371ceb7 100755 --- a/tools/tcpdf_addfont.php +++ b/tools/tcpdf_addfont.php @@ -2,9 +2,9 @@