VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: Twototango on September 18, 2019, 00:17:54 AM

Title: TCPDF ERROR: Could not include font definition file: helvetica
Post by: Twototango on September 18, 2019, 00:17:54 AM
Hi All,

I know this keeps popping from time to time, read several posts with similar issue.
But nothing that gave me a solution.

When generating a PDF invoice this message appears:

"TCPDF ERROR: Could not include font definition file: helvetica"

The error for it is:

Warning: opendir(/www/htdocs/campsenc/shop/libraries/www/htdocs/campsenc/shop/libraries/vendor/tecnickcom/tcpdf/fonts/): failed to open dir:
No such file or directory in /www/htdocs/campsenc/shop/libraries/vendor/tecnickcom/tcpdf/tcpdf.php on line 4147

As you can see the opendir path is incorrect. It sets '/www/htdocs/campsenc/shop/libraries' twice.

Looked up the stated lines in the file:

protected function getFontsList() {
      if (($fontsdir = opendir(TCPDF_FONTS::_getfontpath())) !== false) {
         while (($file = readdir($fontsdir)) !== false) {
            if (substr($file, -4) == '.php') {
               array_push($this->fontlist, strtolower(basename($file, '.php')));
            }
         }
         closedir($fontsdir);
      }
   }

This is a bit over my head I must admit, as I'm not a programmer... not even sure if these are the lines to fix?
Or maybe there's a whole different solution?

can anyone help me out?

VM VirtueMart 3.4.2
Joomla! 3.9.11

Thanks Jack
Title: Re: TCPDF ERROR: Could not include font definition file: helvetica
Post by: StefanSTS on September 18, 2019, 10:36:09 AM
Are you using TCPDF 1.0.8 with VM 3.4.2?
You might consider going back to 1.0.6 then, or updating VM to 3.6.0.

Stefan
Title: Re: TCPDF ERROR: Could not include font definition file: helvetica
Post by: Twototango on September 18, 2019, 17:58:12 PM
Hi Stefan,

No I'm using TCPDF 1.05, that came with the distribution.
Tried 1.08 but that gave me a 500 error...

Updating to 3.60. is not possible at this time...
tried that too, but propped up a problem with the custom build cart.
So that has to be for later...

Jack

Title: Re: TCPDF ERROR: Could not include font definition file: helvetica
Post by: stAn99 on September 19, 2019, 10:05:45 AM
hello, this problem is most probably already fixed by a newer versions of virtuemart, if you want to get it fixed, please see my solution over here:

https://www.rupostel.com/phpBB3/viewtopic.php?f=7&t=3869

best regards, stan
Title: Re: TCPDF ERROR: Could not include font definition file: helvetica
Post by: Twototango on September 19, 2019, 12:31:34 PM
Thanks Stan,

My TCPDF 1.05 did not contain the line mentioned in your solution:

\libraries\vendor\tecnickcom\tcpdf\config\tcpdf_config.php
define("K_PATH_MAIN", VMPATH_LIBS . $cyu.'/');

So installed TCPDF 1.08 and altered it to:
define("K_PATH_MAIN",  $cyu.'/');

Seems to fix the font problem... but gives me this error:

TCPDF ERROR: Unable to create output file: ../fhthtFGDEEjjjrrKK18/invoices/vminvoice_19091924R40512.pdf
(safe path folder is altered for security reasons)

Checked the folders, all are set to CHmod 755


Jack
Title: Re: TCPDF ERROR: Could not include font definition file: helvetica
Post by: Milbo on September 19, 2019, 13:06:21 PM
when you want to use the tcpdf1.0.8 with vm3.4.x than you need to add or adjust the tcpdf function in vmdefines like that.

static public function tcpdf(){

static $tcPath = null;
if($tcPath === null){
$paths = array('/vendor/tecnickcom/tcpdf', '/tcpdf');
foreach($paths as $p){
if(file_exists(VMPATH_LIBS .$p.'/tcpdf.php')){
$tcPath = $p;
break;
}
}
if($tcPath === null){
vmLanguage::loadJLang('com_virtuemart_config');
vmWarn('COM_VIRTUEMART_TCPDF_NINSTALLED');
$tcPath = false;
} else {
defined ('VMPATH_TCPDF') or define ('VMPATH_TCPDF', VMPATH_LIBS .$tcPath );
JLoader::register('TCPDF',VMPATH_TCPDF .'/tcpdf.php');
}
}
return $tcPath;
}


Then you should also not need the "fix" of Stan.
Title: Re: TCPDF ERROR: Could not include font definition file: helvetica
Post by: Twototango on September 19, 2019, 16:30:49 PM
Hi Milbo,

This works...!!!

Reinstalled TCPDF 1.08 just to be sure of a fresh file set.
Added your code to vmdefines file.

Still gave the same error, but resetting the VM safe path fixed it.

Thank you very much... able to save and print the orders again.

Jack