KoolReport's Forum

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

PhantomJS pdf_export error #263

Open High5 software opened this topic on on Apr 27, 2018 - 5 comments

High5 software commented on Apr 27, 2018

Hi, I am on Amazon Linux / Redhat, and I was able to get phantomjs installed and working on the system, but when it calls pdf.js in the Handler.php file, I get the following error in console (I had to try in console since it just hangs). The version of PhantomJS is 2.1.1 -

ReferenceError: Can't find variable: pdf_export

undefined:2 :3 TypeError: null is not an object (evaluating 'viewSettings.margin')

phantomjs://code/pdf.js:185 in processViewSettings phantomjs://code/pdf.js:279 in renderAndExit phantomjs://code/pdf.js:293

Update: Think I figured this out and it has to do with the pathing characters // dependent on the OS.

KoolReport commented on Apr 27, 2018

From what you described, I see that the PhantomJS works well. However the embeded.js could not able to be injected into the page. The embeded.js can be found in the same folder with pdf.js. Could you please check if the file is missing. And one question: do you have the same issue with other OS?

High5 software commented on Apr 27, 2018

Hi thanks for the response. Other than the time it took to get phantomjs set up on Amazon Linux. On Ubuntu type OS I didn't hit this issue, but had a heck of a time on Fedora (switching servers). the issue seemed to be that the OS wanted "//" instead of "/" in the directory path referencing. IE: //tmp//file.tmp instead of /tmp/file.tmp in Handler.php. Was kind of tricky to figure out but if anyone else hits similar errors in linux environment it's worth checking that out. What I ended up doing was -

$script = str_replace("/", "//", $script);
$source = str_replace("/", "//", $source);
$output = str_replace("/", "//", $output);
KoolReport commented on Apr 27, 2018

That's really tricky. Normally we only need the double slash for "backslash" for example "\" will be represented with "\\". And the forward slash "/" does not have this issue and can be used cross OS. That's interesting find out. Thank you so much for sharing this.

High5 software commented on Apr 27, 2018

Yeah I thought the same but I am wondering if it has to do with me using PHP-FPM and Nginx and maybe how it handles shell_exec. It could also maybe be because of the PhantomJS version for some reason. At any rate it's working, so good enough for me. BTW, love your new ChartJS package.

KoolReport commented on Apr 27, 2018

Yep! The most important thing is that it's working.

ChartJS is very powerful and beautiful as well. And it can be used offline. This is strong point against Google Chart. In near future we will add some other well-known chart libraries like C3 for example. Very excited!

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
wiki

Export