spipu / html2pdf

OFFICIAL PROJECT | HTML to PDF converter written in PHP
http://html2pdf.fr/en/default
Open Software License 3.0
1.67k stars 745 forks source link

Warning: count(): Parameter must be an array or an object that implements Countable in \/var\/www\/html\/xyz\/lib\/html2pdf\/_class\/locale.class.php on line 69 #504

Open sumeetmobiwebtech opened 5 years ago

sumeetmobiwebtech commented 5 years ago

I am using php 7.2.16 and getting this error -

Warning: count(): Parameter must be an array or an object that implements Countable in \/var\/www\/html\/xyz\/lib\/html2pdf\/_class\/locale.class.php on line 69

LittleBigFox commented 5 years ago

Hi!

This error was corrected in one version of Html2pdf, try to DL the lastest release.

Regards, LBF

sumeetmobiwebtech commented 5 years ago

sorry what is DL ?

LittleBigFox commented 5 years ago

Hi!

Download it, use composer: https://github.com/spipu/html2pdf/blob/master/doc/install.md

Regards, LBF

Anton-Korduan commented 4 years ago

I got the same problem, updated and this error now shows up:

Warning: opendir(/tmp/): failed to open dir: Permission denied in xyz/vendor/tecnickcom/tcpdf/tcpdf.php on line 7791

This line 7791 shows: if ($handle = opendir(K_PATH_CACHE)) {

What can I do?

LittleBigFox commented 4 years ago

Hi!

Do you use composer, with last version? It's a TCPDF error, and this error was corrected a long time ago...

Or you don't have RW permission on /tmp/ ?

Regards, LBF

Anton-Korduan commented 4 years ago

Yes, I used composer, lateser version.

But I don't see the tmp directory ... not in Composer nor in Html2Pdf. Where should this be located?

Note, that HTML2PDF worked already in an older version (4.x) under PHP 5.x; now I have to migrate to PHP 7.2 or 7.3 and therefore I need the newest Version of HTML2PDF.

LittleBigFox commented 4 years ago

Or so search in this file: ./vendor/tecnickcom/tcpdf/config/tcpdf_config.php

And modify the path in: define ('K_PATH_CACHE', '/tmp/');

It's seems to be the problem, put a folder you have RW permission.

You may also check answer on the tcpdf repository: https://github.com/tecnickcom/TCPDF

Regards, LBF

Anton-Korduan commented 4 years ago

Thanx - gonna try this.

Anton-Korduan commented 4 years ago

Ah! Found the occurence of "define ('K_PATH_CACHE', '/tmp/');" in tcpdf_config.php

But it is commented, not active. And there is the leading comment:

I am unsure about the "full path". In the exaple is written '/tmp/' which looks like a relative path. So "full path" does not mean "absolute path" right?

But anyway: Where is this path located, where do I have to put the tmp-Folder? Has it to be direct in the "tcpdf"-folder or in the "config"-folder? Where is the starting-point?

(I think it's the "tcpdf"-folder - isnt' it?)

Anton-Korduan commented 4 years ago

Hm ... I wonder if tcpdf is actual, in tcpdf_config stands: "Last Update : 2014-12-11"

The Changelog in tcpdf-root says "6.2.25" as newest Version-Number.

LittleBigFox commented 4 years ago

Hi!

'/tmp/' is an absolute path, a relative path is '../../tmp/' for exemple. '/tmp/' on an unix system allow to put the tempory file in a folder which is emptied by the system.

If you are on a mutual hosting, you may not have access to this folder, so you can create a tmp folder in your www, and give tcpdf this path.

Your tcpdf version is not the last, see https://github.com/tecnickcom/TCPDF/releases

Regards, LBF

Anton-Korduan commented 4 years ago

Ah! Great.

Sounds like we are getting closer to the solution, step by step.

Thank you, I will try.

Anton-Korduan commented 4 years ago

Hm ... strange:

If I try the example_001.php direct in tcpdf, it's working.

But if I try example00.php in spipu... it's not.

And here I am confused about the error, it stays the same (also the directory) but I changed the K_PATH_CACHE to "/vendor/temp2/":

"Warning: opendir(/tmp/): failed to open dir: Permission denied"

Also this "Permission denied" is strange ... the "tmp" Folder does not exist so why does it not say "directory not found"?

Maybe you have an idea. Hope so.

Meanwhile I try to re-install the whole thing ...

(By the way, the second installation of tcpdf is the least version - thats okay so far. Here the tcpdf-test, mentionend above, was successfull)

LittleBigFox commented 4 years ago

So in your tcpdf_autoconfig, you have the definition of K_PATH_CACHE, line 124, maybe in change this value for testing?

Anton-Korduan commented 4 years ago

HA! That's interesting - if I change the path in tcpdf_autoconfig, indeed it's working!

And also reverse-check: if I change it back to original the permission-denid-error comes back.

Here ist my change:

// define ('K_PATH_CACHE', $K_PATH_CACHE);
define ('K_PATH_CACHE', dirname(__FILE__).'/tmp');

So what now - do you have an idea, why the tcp_config seems not to work?