Fatal error: require_once() [function.require]: Failed opening required '__DIR__/tcpdf_autoconfig.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/public_html/sites/all/libraries/tcpdf/tcpdf.php on line 146

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nicxvan’s picture

Making Progress:
In tcpdf.php Made the following changes.
require_once(__DIR__.'/tcpdf_autoconfig.php');
// TCPDF static font methods and data
require_once(__DIR__.'/include/tcpdf_font_data.php');
// TCPDF static font methods and data
require_once(__DIR__.'/include/tcpdf_fonts.php');
// TCPDF static color methods and data
require_once(__DIR__.'/include/tcpdf_colors.php');
// TCPDF static image methods and data
require_once(__DIR__.'/include/tcpdf_images.php');
// TCPDF static methods and data
require_once(__DIR__.'/include/tcpdf_static.php');

TO

require_once('tcpdf_autoconfig.php');
// TCPDF static font methods and data
require_once('include/tcpdf_font_data.php');
// TCPDF static font methods and data
require_once('include/tcpdf_fonts.php');
// TCPDF static color methods and data
require_once('include/tcpdf_colors.php');
// TCPDF static image methods and data
require_once('include/tcpdf_images.php');
// TCPDF static methods and data
require_once('include/tcpdf_static.php');

More notes to follow: Still getting errors on the page but it loads.

nicxvan’s picture

Got rid of the remaining errors by making the following changes to the tcpdf_autoconfig.php file:
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__.'/');
}

TO

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('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', '');
}

nicxvan’s picture

Since this is a third party library I'm not entirely sure what the protocol is for patching this and fixing it.

gbelot2003’s picture

FileSize
177.55 KB

I have the same problem, I wander if is something related with third party actualizations??

david.goovaerts@gmail.com’s picture

The problem is that __DIR__ only works with php 5.3.0 and higher.
and you probably don't have that installed on your server.

A better solution is to replace '__DIR__' with 'dirname(__FILE__)' that does the same, but works with lower php versions.

that solved all errors for me.

thus
// TCPDF configuration
require_once(dirname(__FILE__).'/tcpdf_autoconfig.php');
// TCPDF static font methods and data
require_once(dirname(__FILE__).'/include/tcpdf_font_data.php');
// TCPDF static font methods and data
require_once(dirname(__FILE__).'/include/tcpdf_fonts.php');
// TCPDF static color methods and data
require_once(dirname(__FILE__).'/include/tcpdf_colors.php');
// TCPDF static image methods and data
require_once(dirname(__FILE__).'/include/tcpdf_images.php');
// TCPDF static methods and data
require_once(dirname(__FILE__).'/include/tcpdf_static.php');

and

// 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(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')) {
define ('K_PATH_MAIN', dirname(__FILE__).'/');
}

killua99’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Assigned: Unassigned » killua99
Status: Active » Needs work
Issue tags: +PHP 5.2

This is a issue for PHP 5.2.x and drupal requirements are: Drupal 7: PHP 5.2.5 or higher (recoment 5.3.x).

killua99’s picture

Assigned: killua99 » Unassigned
Category: bug » support
Priority: Critical » Normal
Status: Needs work » Closed (won't fix)

Ok reading very carefully, this is related with the library. Sorry I was fast editing and classifying all the issues.

The current tcpdf library * @version 6.0.020 include the file with this method:

require_once(dirname(__FILE__).'/include/tcpdf_fonts.php');

So this means you have to update the library. I'm going to close this one. People can still find this solution for older or idk witch version have the __DIR__ magic.

Liam Morland’s picture

Issue summary: View changes