Author Topic: TCPDF ERROR: Could not include font definition file: helvetica  (Read 538 times)

Twototango

  • Beginner
  • *
  • Posts: 9
  • A beginner
TCPDF ERROR: Could not include font definition file: helvetica
« 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

StefanSTS

  • Global Moderator
  • Full Member
  • *
  • Posts: 520
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: TCPDF ERROR: Could not include font definition file: helvetica
« Reply #1 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
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

Twototango

  • Beginner
  • *
  • Posts: 9
  • A beginner
Re: TCPDF ERROR: Could not include font definition file: helvetica
« Reply #2 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


stAn99

  • Contributing Developer
  • Jr. Member
  • *
  • Posts: 85
    • One Page Checkout for Virtuemart 2
Re: TCPDF ERROR: Could not include font definition file: helvetica
« Reply #3 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
----
RuposTel.com
www.rupostel.com
Your customized checkout solution for Virtuemart

Twototango

  • Beginner
  • *
  • Posts: 9
  • A beginner
Re: TCPDF ERROR: Could not include font definition file: helvetica
« Reply #4 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

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9997
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: TCPDF ERROR: Could not include font definition file: helvetica
« Reply #5 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.
Code: [Select]
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.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Twototango

  • Beginner
  • *
  • Posts: 9
  • A beginner
Re: TCPDF ERROR: Could not include font definition file: helvetica
« Reply #6 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