KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

We are getting error "Could not execute phantomjs" #135

Closed Matt Ford opened this topic on on Oct 24, 2017 - 40 comments

Matt Ford commented on Oct 24, 2017

We are getting error "Could not execute phantomjs". We have uploaded phantomjs for linux server. All permissions are set properly. It is working on our local system. When we try same on server it is not working. we are getting error

[24-Oct-2017 06:38:24 UTC] PHP Fatal error: Uncaught exception 'Exception' with message 'Could not execute phantomjs' in /home/wiseprm/public_html/odm/vendor/koolreport/packages/export/Handler.php:49 Stack trace: #0 /home/wiseprm/public_html/odm/vendor/koolreport/packages/export/Handler.php(120): koolreport\export\Handler->runPhantom('/home/wiseprm/p...', '/tmp/59eedfe051...', '/tmp/59eedfe051...', 'eyJmb3JtYXQiOiJ...') #1 /home/wiseprm/public_html/odm/backend/koolreport/reports/advanced/input_and_export/export.php(9): koolreport\export\Handler->pdf(Array) #2 {main} thrown in /home/wiseprm/public_html/odm/vendor/koolreport/packages/export/Handler.php on line 49

KoolReport commented on Oct 24, 2017

Could you please run this script on your server:

echo ini_get('disable_functions');

I suspect that there would be a disabled function. Please let me know the result

Matt Ford commented on Oct 24, 2017

It returns empty. No output. Can any one help me.

Matt Ford commented on Oct 24, 2017

Could not save content to temporary folder

KoolReport commented on Oct 24, 2017

I see, by default temporary folder can be written by any system user, could you please check and enable "write" permission for all users.

Matt Ford commented on Oct 24, 2017

shell_exec() command does not run on our server. Page goes blank. disabale_function does not include shell_exec Do we need to check any other setting.

KoolReport commented on Oct 24, 2017

Could you please check if any of those functions is NOT disabled in your system

  1. exec()
  2. system()
  3. passthru()
  4. popen()

So I see two solutions:

  1. You can enable the shell_exec() so that php can communicate with phamtomjs
  2. We try to rewrite export using one of above functions if that function is enabled by your server.
Matt Ford commented on Oct 25, 2017

We have done with all settings. hell is running now. But again we are getting error "Could not execute phantomjs"

KoolReport commented on Oct 25, 2017

I will contact you by email to setup an experiment on your server.

Matt Ford commented on Oct 25, 2017

Ok

KoolReport commented on Oct 25, 2017

Have you received my email?

Matt Ford commented on Oct 25, 2017

yes setting up same

Matt Ford commented on Oct 25, 2017

do you want me to reply on email with details ?

Matt Ford commented on Oct 25, 2017

Ok my developer emailed you details.

KoolReport commented on Oct 25, 2017

Thanks! I received email and working on that.

KoolReport commented on Oct 28, 2017

The problem has been solved and I have emailed you details.

KoolReport commented on Oct 30, 2017

Have you been able to get it work on your production server? Do you need our further assistance?

Matt Ford commented on Oct 30, 2017

My developers will be in the office today...I will confirm status once I receive feedback. Thanks for your help!

KoolReport commented on Oct 30, 2017

Sure, anything please let us know.

Matt Ford commented on Nov 3, 2017

I want to set size of pdf to 8.5 x 11. So once i download pdf and view properties, it should show size as 8.5 x 11in Can you help me in same.

KoolReport commented on Nov 3, 2017

Well, I guess you use the "Letter" size, you can do this:

...
->pdf(array(
    "format"=>"letter",
    "orientation"=>"portrait"
))
...
Matt Ford commented on Nov 3, 2017

It gives 3.35 X 4.33in

Matt Ford commented on Nov 3, 2017

"format"=>"Tabloid", Gives 4.33 X 6.69in. But we need 8.5 x 11in

KoolReport commented on Nov 3, 2017

Let try to do this:

->pdf(array(
    "format"=>"letter",
    "orientation"=>"portrait",
    "dpi"=>183
))
Matt Ford commented on Nov 4, 2017

no luck, it 3.35 X 4.33in

KoolReport commented on Nov 4, 2017

You may try to set manual size like this:

->pdf(array(
    "width"=>"8.5in",
    "height"=>"11in",
))

Let me know if it work for you.

Matt Ford commented on Nov 6, 2017

Hi ,

NO luck with same. there is no change with this 2 parameters

KoolReport commented on Nov 6, 2017

We have examples online to Export pdf. Could you please check the size of it with your software

Matt Ford commented on Nov 7, 2017

tried with same details. Still same issue

KoolReport commented on Nov 7, 2017

Do you mean the PDF exported from our example here having the same issue?

Navnit Bhaktwarti commented on Nov 30, 2017

We are also getting the same error - "Could not execute phantomjs". Any solutions?

disable_functions is empty in php.ini

KoolReport commented on Dec 1, 2017

Please make sure the phantomjs has the permission to run

Navnit Bhaktwarti commented on Dec 1, 2017

phantomjs has full permission (777). File does not create in tmp folder either.

Fatal error: Uncaught exception 'Exception' with message 'Could not execute phantomjs' in /var/www/html/snb/reporting/koolreport/packages/export/Handler.php:65 Stack trace: #0 /var/www/html/snb/reporting/koolreport/packages/export/Handler.php(149): koolreport\export\Handler->runPhantom('/var/www/html/s...', '/tmp/5a20e17645...', '/tmp/5a20e17645...', 'eyJmb3JtYXQiOiJ...') #1 /var/www/html/snb/reporting/reports/reports/general/member/memberExport.php(14): koolreport\export\Handler->pdf(Array) #2 {main} thrown in /var/www/html/snb/reporting/koolreport/packages/export/Handler.php on line 65

KoolReport commented on Dec 2, 2017

@Navnit: Could you please let me know your server and php information.

Navnit Bhaktwarti commented on Dec 2, 2017

phpserver1:~$ php -v PHP 5.5.9-1ubuntu4.21 (cli) (built: Feb 9 2017 20:54:58) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
Navnit Bhaktwarti commented on Dec 4, 2017

@KoolPHP - any luck on the error?

KoolReport commented on Dec 5, 2017

We could not been able to test with ubuntu4.21 since we use the ubuntu12 & 14 and 16. Please try to install phantomjs with command is “apt-get install phantomjs”. Then to export, you do:

$report->export()
->settings(array(
    "phantomjs"=>"/path/to/phantomjs"
))
->pdf(...)->toBrowser(...);
Thangavel commented on Mar 20, 2019

We are getting an error "Could not execute phantomjs". All permissions(executable for all users) are set properly. It is not working on our local system too.

Source Code:

require_once "SakilaRental.php";

$report = new SakilaRental;

$report->run()->export('SakilaRentalPdf')->pdf(array("format"=>"A4","orientation"=>"portrait"))->toBrowser("sakila_rental.pdf");

Error

*phantomjs path*: /opt/lampp/htdocs/koolreport/packages/export/bin/phantomjs

Fatal error: Uncaught exception 'Exception' with message 'Could not execute phantomjs' in /opt/lampp/htdocs/koolreport/packages/export/Handler.php:72 Stack trace: #0 /opt/lampp/htdocs/koolreport/packages/export/Handler.php(237): koolreport\export\Handler->runPhantom('/opt/lampp/htdo...', '/tmp/5c91cdc31d...', '/tmp/5c91cdc31d...', 'eyJmb3JtYXQiOiJ...') #1 /opt/lampp/htdocs/koolreport_examples/reports/export/sakila_rental/export.php(13): koolreport\export\Handler->pdf(Array) #2 {main} thrown in /opt/lampp/htdocs/koolreport/packages/export/Handler.php on line 72

Then I installed the phantomjs in the local system and using the path of phantomjs same error occurs.

Source Code:

$report->run()->export('SakilaRentalPdf')
->settings(array("phantomjs"=>"/usr/bin/phantomjs"))->pdf(array(	"format"=>"A4","orientation"=>"portrait"))
->toBrowser("sakila_rental.pdf");

Error:

Fatal error: Uncaught exception 'Exception' with message 'Could not execute phantomjs' in /opt/lampp/htdocs/koolreport/packages/export/Handler.php:72 Stack trace: #0 /opt/lampp/htdocs/koolreport/packages/export/Handler.php(237): koolreport\export\Handler->runPhantom('/opt/lampp/htdo...', '/tmp/5c91d3bbbc...', '/tmp/5c91d3bbbc...', 'eyJmb3JtYXQiOiJ...') #1 /opt/lampp/htdocs/koolreport_examples/reports/export/sakila_rental/export.php(12): koolreport\export\Handler->pdf(Array) #2 {main} thrown in /opt/lampp/htdocs/koolreport/packages/export/Handler.php on line 72

Please help us to solve the issue.

hsw commented on Feb 26, 2020

Hi Koolreport,

Same problem "cannot execute phantomjs" encountered when I tested the Export package. When checked with our web host, they said that they have disabled the execution of phantomjs as it was actually discontinued for few years already. If allowed to execute, our site will be at risk of the phantomjs been maliciously used by hackers. Refer to https://en.wikipedia.org/wiki/PhantomJS.

Is there other ways to get the Export PDF to work?

Thank you

KoolReport commented on Feb 26, 2020

If you are using the shared host, it is hard to get phantomjs run even before it is discontinued. VM should be solution. Another option is to use our CloudExport package. Using CloudExport, you will not need to install phantomjs, it will use our ChromeHeadlessio to create pdf file for you.

hsw commented on Feb 26, 2020

Ok thank you. Will try the CloudExport.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

Export