Docker and Spatie PdfToText error exit code: 127 - php

I have this code:
Global $windows;
$libiary_path = "./pdftotext";
if($windows)
{
$libiary_path .= ".exe";
}
$text = (new Pdf($libiary_path))->setPdf($file_name)->text();
return $text;
On linux in VM it works. I switched an docker and I get this error:
Fatal error: Uncaught Spatie\PdfToText\Exceptions\CouldNotExtractText: The command "'./pdftotext' 'this.pdf' '-'" failed. Exit Code: 127(Command not found) Working directory: /var/www/html Output: ================ Error Output: ================ ./pdftotext: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory in /var/www/html/pdf-to-text-main/src/Pdf.php:73 Stack trace: #0 /var/www/html/get_data.php(18): Spatie\PdfToText\Pdf->text() #1 /var/www/html/get_data.php(59): parsePDF('this.pdf') #2 /var/www/html/get_data.php(69): GetDataFromPDF('this.pdf') #3 {main} thrown in /var/www/html/pdf-to-text-main/src/Pdf.php on line 73
Everything is there. Exactly the same set of files on the Ubuntu VM and lampp works, not on the Ubuntu docker. I'm a beginner and maybe I don't understand something, but I can't find the answer on the web. Perhaps this is some very basic mistake.

Related

how to fix Spatie/Browsershot error somehow Chrome did not write a file at `screenshot.pdf`

I am trying to create a pdf file using browsershot but getting error.
I installed Browsershot on my cpanel hosting
Here is my code
<?php
require('/home/user name/vendor/autoload.php');
use Spatie\Browsershot\Browsershot;
$url= "https://google.com";
$html= Browsershot::url($url)->setNodeBinary('/home/username/nodevenv/test/12/bin/node')->setNpmBinary('/home/username/nodevenv/test/12/bin/npm')->save('google.pdf');
echo 'done';
?>
And i am end up with this error
Fatal error: Uncaught Spatie\Browsershot\Exceptions\CouldNotTakeBrowsershot: For some reason Chrome did not write a file at google.pdf. Command payload: [] in /home/username/vendor/spatie/browsershot/src/Exceptions/CouldNotTakeBrowsershot.php:13 Stack trace: #0 /home/username/vendor/spatie/browsershot/src/Browsershot.php(601): Spatie\Browsershot\Exceptions\CouldNotTakeBrowsershot::chromeOutputEmpty('google.pdf') #1 /home/username/vendor/spatie/browsershot/src/Browsershot.php(528): Spatie\Browsershot\Browsershot->savePdf('google.pdf') #2 /home/username/public_html/a.php(9): Spatie\Browsershot\Browsershot->save('google.pdf') #3 {main} thrown in /home/username/vendor/spatie/browsershot/src/Exceptions/CouldNotTakeBrowsershot.php on line 13
I don't know what's wrong. How can i fix this error?
It worked for me with
npm install -g puppeteer
npm install -g chromium

How to repeat an example with Ratchet Push?

I would like to repeat the Ratchet Push example. Downloaded Composer. In the project folder via the console (CLI) I entered: php composer.phar require cboden/ratchet, after which the vendor folder and a pair of files from Composer appeared. I installed ZeroMQ and tried two installation options:
Downloaded the necessary files from
https://pecl.php.net/package/zmq/1.1.3/windows. - libzmq.dll unpacked in C:\xampp\php,- php_zmq.php in C:\xampp\php\ext.Added the C:\xampp\php\ext to system variable PATH,+ restarted the computer, + restarted the web server.
Downloaded the necessary files from
https://pecl.php.net/package/zmq/1.1.3/windows.- libzmq.dll unpacked
in C:\xampp\php\windowsXamppPhp,- php_zmq.php in C:\xampp\php\windowsXamppPhp\ext.Added the C:\xampp\php\windowsXamppPhp\ext to system variable PATH,+ restarted the computer,+ restarted the web server.
I also tried to throw the file libzmq.dll into the same folder as php_zmq.php.
The installation was guided by:https://wiki.zeromq.org/bindings:php+
https://superuser.com/questions/585291/installing-...
After all, started the xampp server, then in the console entered: php push-server.php, but the console throws an error :
> PHP Fatal error: Uncaught Error: Class 'React\ZMQ\Context' not found
> in C:\xampp\htdocs\test\push-server.php:9 Stack trace:
> #0 {main} thrown in C:\xampp\htdocs\test\push-server.php on line 9
>
> Fatal error: Uncaught Error: Class 'React\ZMQ\Context' not found in
> C:\xampp\htdocs\test\push-server.php:9 Stack trace:
> #0 {main} thrown in C:\xampp\htdocs\test\push-server.php on line 9
P.S.: I believe that something is wrong with the installation of ZeroMQ since the file was not working.
ОС: windows 10
Server: XAMPP
PHP version: 7.4.2

PHP code run in terminal but not working in chrome

I have used pdf-to-image to build my new package. and I got some problem here:
<?php
// die(echo getenv('HOME'););
require_once(__DIR__.'/vendor/autoload.php');
$fileone = realpath('demo.pdf');
$pdf = new Spatie\PdfToImage\Pdf($fileone);
$pdf->saveImage(__DIR__.'upload/');
?>
I required it into index file but I can't run this code on Chrome but it working when I run by terminal, how can I fix it?
UPDATE Adding error shared in comments:
Fatal error: Uncaught ImagickException: Failed to read the file in /opt/lampp/htdocs/pdf2Image/vendor/spatie/pdf-to-image/src/Pdf.php:44 Stack trace: #0 /opt/lampp/htdocs/pdf2Image/vendor/spatie/pdf-to-image/src/Pdf.php(44): Imagick->__construct('/opt/lampp/htdo...') #1 /opt/lampp/htdocs/pdf2Image/index.php(6): Spatie\PdfToImage\Pdf->__construct('/opt/lampp/htdo...') #2 {main} thrown in /opt/lampp/htdocs/pdf2Image/vendor/spatie/pdf-to-image/src/Pdf.php on line 44

Trouble getting cakephp 2.4.0 running - fatal errors when attempting to complete tutorial

I am trying to follow the instructions for the cakephp tutorial found here: http://book.cakephp.org/2.0/en/getting-started.html
I uploaded the CakePHP files to my webserver, created the database using MySQL workbench, and created database.php and updated it to point to my MySQL server.
At this point it sounds like I should be able to open up the website in my browser and see something, but instead I get these errors (I have removed the full path):
Warning: _cake_core_ cache was unable to write 'cake_dev_en-us' to File cache in /caketut/lib/Cake/Cache/Cache.php on line 325
Warning: caketut/app/tmp/cache/persistent/ is not writable in /www/premium/med/pediatrics/www.hobmt.umn.edu/htdocs/caketut/lib/Cake/Cache/Engine/FileEngine.php on line 380
Fatal error: Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured.' in /caketut/lib/Cake/Cache/Cache.php:181
Stack trace:
#0 /caketut/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('_cake_core_')
#1 /caketut/app/Config/core.php(367): Cache::config('_cake_core_', Array)
#2 /caketut/lib/Cake/Core/Configure.php(72): include('/www/premium/me...')
#3 /caketut/lib/Cake/bootstrap.php(177): Configure::bootstrap(true)
#4 /caketut/app/webroot/index.php(92): include('/www/premium/me...')
#5 {main} thrown in /caketut/lib/Cake/Cache/Cache.php on line 181
I tried setting the permissions for the Cache folder located in /caketut/lib/Cake and all subfolders/files to be 0776, and this removes all errors except this one:
Fatal error: Class 'Cache' not found in /caketut/app/Config/core.php on line 361
I tried doing searches but was unsuccessful in finding a solution. I would really appreciate any assistance!
try to chmod the whole script with 0777 permissions .
sudo chmod -R 0777 caketut

CakePHP: Could not load configuration file

I'm trying to get a cakephp project up and running from a svn checkout on my mountain lion computer.
I changed all the cache write permissions find but now I have one last fatal error that's not letting the app run.
Fatal error: Uncaught exception 'ConfigureException' with message 'Could not load configuration file: /Users/mike/cake2cribs/cake2cribs/app/Config/core-production.php' in /Users/mike/cake2cribs/cake2cribs/lib/Cake/Configure/PhpReader.php:77
Stack trace: #0
/Users/mike/cake2cribs/cake2cribs/lib/Cake/Core/Configure.php(267):
PhpReader->read('core-production') #1
/Users/mike/cake2cribs/cake2cribs/app/Config/core.php(287):
Configure::load('core-production') #2
/Users/mike/cake2cribs/cake2cribs/lib/Cake/Core/Configure.php(76):
include('/Users/mike/cak...') #3
/Users/mike/cake2cribs/cake2cribs/lib/Cake/bootstrap.php(146):
Configure::bootstrap(true) #4
/Users/mike/cake2cribs/cake2cribs/app/webroot/index.php(81):
include('/Users/mike/cak...') #5 {main} thrown in
/Users/mike/cake2cribs/cake2cribs/lib/Cake/Configure/PhpReader.php on
line 77
it fails on this line inside index.php inside webroot
if (!include ('Cake' . DS . 'bootstrap.php')) {
$failed = true;
}
Any ideas as to what could be the cause?
I've never done an Ubuntu install, I've always just downloaded the source and put it in my webroot. Anyway, cake always expects to have a file called core.php which holds all the config info. Maybe the Ubuntu install just expects core-production.php, so you might just need to copy the core.php file in app/Config and rename it to core-production.php.

Categories