config
2 months ago
fonts
2 years ago
include
2 months ago
LICENSE.TXT
2 months ago
Makefile
2 months ago
README.md
2 months ago
VERSION
2 months ago
tcpdf.php
2 months ago
tcpdf_autoconfig.php
2 months ago
tcpdf_barcodes_1d.php
2 months ago
tcpdf_barcodes_2d.php
2 months ago
tcpdf_autoconfig.php
218 lines
| 1 | <?php |
| 2 | |
| 3 | namespace { |
| 4 | //============================================================+ |
| 5 | // File name : tcpdf_autoconfig.php |
| 6 | // Version : 1.1.1 |
| 7 | // Begin : 2013-05-16 |
| 8 | // Last Update : 2025-04-18 |
| 9 | // Authors : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com |
| 10 | // License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) |
| 11 | // ------------------------------------------------------------------- |
| 12 | // Copyright (C) 2011-2026 Nicola Asuni - Tecnick.com LTD |
| 13 | // |
| 14 | // This file is part of TCPDF software library. |
| 15 | // |
| 16 | // TCPDF is free software: you can redistribute it and/or modify it |
| 17 | // under the terms of the GNU Lesser General Public License as |
| 18 | // published by the Free Software Foundation, either version 3 of the |
| 19 | // License, or (at your option) any later version. |
| 20 | // |
| 21 | // TCPDF is distributed in the hope that it will be useful, but |
| 22 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 24 | // See the GNU Lesser General Public License for more details. |
| 25 | // |
| 26 | // You should have received a copy of the License |
| 27 | // along with TCPDF. If not, see |
| 28 | // <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>. |
| 29 | // |
| 30 | // See LICENSE.TXT file for more information. |
| 31 | // ------------------------------------------------------------------- |
| 32 | // |
| 33 | // Description : Try to automatically configure some TCPDF |
| 34 | // constants if not defined. |
| 35 | // |
| 36 | //============================================================+ |
| 37 | /** |
| 38 | * @file |
| 39 | * Try to automatically configure some TCPDF constants if not defined. |
| 40 | * @package com.tecnick.tcpdf |
| 41 | * @version 1.2.1 |
| 42 | */ |
| 43 | // Disable phar stream wrapper globally. |
| 44 | // if (in_array('phar', stream_get_wrappers(), true)) { |
| 45 | // stream_wrapper_unregister('phar'); |
| 46 | // } |
| 47 | // DOCUMENT_ROOT fix for IIS Webserver |
| 48 | if (!isset($_SERVER['DOCUMENT_ROOT']) or empty($_SERVER['DOCUMENT_ROOT'])) { |
| 49 | if (isset($_SERVER['SCRIPT_FILENAME'])) { |
| 50 | $_SERVER['DOCUMENT_ROOT'] = \str_replace('\\', '/', \substr($_SERVER['SCRIPT_FILENAME'], 0, 0 - \strlen($_SERVER['PHP_SELF']))); |
| 51 | } elseif (isset($_SERVER['PATH_TRANSLATED'])) { |
| 52 | $_SERVER['DOCUMENT_ROOT'] = \str_replace('\\', '/', \substr(\str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0 - \strlen($_SERVER['PHP_SELF']))); |
| 53 | } else { |
| 54 | // define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www') |
| 55 | $_SERVER['DOCUMENT_ROOT'] = '/'; |
| 56 | } |
| 57 | } |
| 58 | $_SERVER['DOCUMENT_ROOT'] = \str_replace('//', '/', $_SERVER['DOCUMENT_ROOT']); |
| 59 | if (\substr($_SERVER['DOCUMENT_ROOT'], -1) != '/') { |
| 60 | $_SERVER['DOCUMENT_ROOT'] .= '/'; |
| 61 | } |
| 62 | // Load main configuration file only if the K_TCPDF_EXTERNAL_CONFIG constant is set to false. |
| 63 | if (!\defined('K_TCPDF_EXTERNAL_CONFIG') or !\K_TCPDF_EXTERNAL_CONFIG) { |
| 64 | // define a list of default config files in order of priority |
| 65 | $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'); |
| 66 | foreach ($tcpdf_config_files as $tcpdf_config) { |
| 67 | if (@\file_exists($tcpdf_config) and \is_readable($tcpdf_config)) { |
| 68 | require_once $tcpdf_config; |
| 69 | break; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | if (!\defined('K_PATH_MAIN')) { |
| 74 | \define('K_PATH_MAIN', \dirname(__FILE__) . '/'); |
| 75 | } |
| 76 | if (!\defined('K_PATH_FONTS')) { |
| 77 | \define('K_PATH_FONTS', \K_PATH_MAIN . 'fonts/'); |
| 78 | } |
| 79 | if (!\defined('K_PATH_URL')) { |
| 80 | $k_path_url = \K_PATH_MAIN; |
| 81 | // default value for console mode |
| 82 | if (isset($_SERVER['HTTP_HOST']) and !empty($_SERVER['HTTP_HOST'])) { |
| 83 | if (isset($_SERVER['HTTPS']) and !empty($_SERVER['HTTPS']) and \strtolower($_SERVER['HTTPS']) != 'off') { |
| 84 | $k_path_url = 'https://'; |
| 85 | } else { |
| 86 | $k_path_url = 'http://'; |
| 87 | } |
| 88 | $k_path_url .= $_SERVER['HTTP_HOST']; |
| 89 | $k_path_url .= \str_replace('\\', '/', \substr(\K_PATH_MAIN, \strlen($_SERVER['DOCUMENT_ROOT']) - 1)); |
| 90 | } |
| 91 | \define('K_PATH_URL', $k_path_url); |
| 92 | } |
| 93 | if (!\defined('K_PATH_IMAGES')) { |
| 94 | $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); |
| 95 | foreach ($tcpdf_images_dirs as $tcpdf_images_path) { |
| 96 | if (@\file_exists($tcpdf_images_path)) { |
| 97 | \define('K_PATH_IMAGES', $tcpdf_images_path); |
| 98 | break; |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | if (!\defined('PDF_HEADER_LOGO')) { |
| 103 | $tcpdf_header_logo = ''; |
| 104 | if (@\file_exists(\K_PATH_IMAGES . 'tcpdf_logo.jpg')) { |
| 105 | $tcpdf_header_logo = 'tcpdf_logo.jpg'; |
| 106 | } |
| 107 | \define('PDF_HEADER_LOGO', $tcpdf_header_logo); |
| 108 | } |
| 109 | if (!\defined('PDF_HEADER_LOGO_WIDTH')) { |
| 110 | if (!empty($tcpdf_header_logo)) { |
| 111 | \define('PDF_HEADER_LOGO_WIDTH', 30); |
| 112 | } else { |
| 113 | \define('PDF_HEADER_LOGO_WIDTH', 0); |
| 114 | } |
| 115 | } |
| 116 | if (!\defined('K_PATH_CACHE')) { |
| 117 | $K_PATH_CACHE = \ini_get('upload_tmp_dir') ? \ini_get('upload_tmp_dir') : \sys_get_temp_dir(); |
| 118 | if (\substr($K_PATH_CACHE, -1) != '/') { |
| 119 | $K_PATH_CACHE .= '/'; |
| 120 | } |
| 121 | \define('K_PATH_CACHE', $K_PATH_CACHE); |
| 122 | } |
| 123 | if (!\defined('K_BLANK_IMAGE')) { |
| 124 | \define('K_BLANK_IMAGE', '_blank.png'); |
| 125 | } |
| 126 | if (!\defined('PDF_PAGE_FORMAT')) { |
| 127 | \define('PDF_PAGE_FORMAT', 'A4'); |
| 128 | } |
| 129 | if (!\defined('PDF_PAGE_ORIENTATION')) { |
| 130 | \define('PDF_PAGE_ORIENTATION', 'P'); |
| 131 | } |
| 132 | if (!\defined('PDF_CREATOR')) { |
| 133 | \define('PDF_CREATOR', 'TCPDF'); |
| 134 | } |
| 135 | if (!\defined('PDF_AUTHOR')) { |
| 136 | \define('PDF_AUTHOR', 'TCPDF'); |
| 137 | } |
| 138 | if (!\defined('PDF_HEADER_TITLE')) { |
| 139 | \define('PDF_HEADER_TITLE', 'TCPDF Example'); |
| 140 | } |
| 141 | if (!\defined('PDF_HEADER_STRING')) { |
| 142 | \define('PDF_HEADER_STRING', "by2026 Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); |
| 143 | } |
| 144 | if (!\defined('PDF_UNIT')) { |
| 145 | \define('PDF_UNIT', 'mm'); |
| 146 | } |
| 147 | if (!\defined('PDF_MARGIN_HEADER')) { |
| 148 | \define('PDF_MARGIN_HEADER', 5); |
| 149 | } |
| 150 | if (!\defined('PDF_MARGIN_FOOTER')) { |
| 151 | \define('PDF_MARGIN_FOOTER', 10); |
| 152 | } |
| 153 | if (!\defined('PDF_MARGIN_TOP')) { |
| 154 | \define('PDF_MARGIN_TOP', 27); |
| 155 | } |
| 156 | if (!\defined('PDF_MARGIN_BOTTOM')) { |
| 157 | \define('PDF_MARGIN_BOTTOM', 25); |
| 158 | } |
| 159 | if (!\defined('PDF_MARGIN_LEFT')) { |
| 160 | \define('PDF_MARGIN_LEFT', 15); |
| 161 | } |
| 162 | if (!\defined('PDF_MARGIN_RIGHT')) { |
| 163 | \define('PDF_MARGIN_RIGHT', 15); |
| 164 | } |
| 165 | if (!\defined('PDF_FONT_NAME_MAIN')) { |
| 166 | \define('PDF_FONT_NAME_MAIN', 'helvetica'); |
| 167 | } |
| 168 | if (!\defined('PDF_FONT_SIZE_MAIN')) { |
| 169 | \define('PDF_FONT_SIZE_MAIN', 10); |
| 170 | } |
| 171 | if (!\defined('PDF_FONT_NAME_DATA')) { |
| 172 | \define('PDF_FONT_NAME_DATA', 'helvetica'); |
| 173 | } |
| 174 | if (!\defined('PDF_FONT_SIZE_DATA')) { |
| 175 | \define('PDF_FONT_SIZE_DATA', 8); |
| 176 | } |
| 177 | if (!\defined('PDF_FONT_MONOSPACED')) { |
| 178 | \define('PDF_FONT_MONOSPACED', 'courier'); |
| 179 | } |
| 180 | if (!\defined('PDF_IMAGE_SCALE_RATIO')) { |
| 181 | \define('PDF_IMAGE_SCALE_RATIO', 96 / 72); |
| 182 | } |
| 183 | if (!\defined('HEAD_MAGNIFICATION')) { |
| 184 | \define('HEAD_MAGNIFICATION', 1.1); |
| 185 | } |
| 186 | if (!\defined('K_CELL_HEIGHT_RATIO')) { |
| 187 | \define('K_CELL_HEIGHT_RATIO', 1.25); |
| 188 | } |
| 189 | if (!\defined('K_TITLE_MAGNIFICATION')) { |
| 190 | \define('K_TITLE_MAGNIFICATION', 1.3); |
| 191 | } |
| 192 | if (!\defined('K_SMALL_RATIO')) { |
| 193 | \define('K_SMALL_RATIO', 2 / 3); |
| 194 | } |
| 195 | if (!\defined('K_THAI_TOPCHARS')) { |
| 196 | \define('K_THAI_TOPCHARS', \true); |
| 197 | } |
| 198 | if (!\defined('K_TCPDF_CALLS_IN_HTML')) { |
| 199 | \define('K_TCPDF_CALLS_IN_HTML', \false); |
| 200 | } |
| 201 | if (!\defined('K_ALLOWED_TCPDF_TAGS')) { |
| 202 | \define('K_ALLOWED_TCPDF_TAGS', ''); |
| 203 | } |
| 204 | if (!\defined('K_TCPDF_THROW_EXCEPTION_ERROR')) { |
| 205 | \define('K_TCPDF_THROW_EXCEPTION_ERROR', \false); |
| 206 | } |
| 207 | if (!\defined('K_TIMEZONE')) { |
| 208 | \define('K_TIMEZONE', @\date_default_timezone_get()); |
| 209 | } |
| 210 | // Custom cURL options for curl_setopt_array. |
| 211 | if (!\defined('K_CURLOPTS')) { |
| 212 | \define('K_CURLOPTS', array()); |
| 213 | } |
| 214 | //============================================================+ |
| 215 | // END OF FILE |
| 216 | //============================================================+ |
| 217 | } |
| 218 |