why wkhtmltopdf doesn't work with php - php

I ran the codes:
error_reporting(E_ALL);
ini_set( 'display_errors','1');
$d = 'usr/bin/wkhtmltopdf /www/11_07_13/task1/ml.html hd.pdf';
//also used: $d = 'xvfb-run -a wkhtmltopdf ml.html hd.pdf';
//$d = 'xvfb-run -a usr/bin/wkhtmltopdf ml.html hd.pdf';
if (exec($d)) {
echo "success";
}
else{
echo "error";
}
and everytime it shows error.
At first I installed wkhtmltopdf via terminal, dinn't work. Then I downloaded the file: wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2' from the code.google... site, unzipped and placed it in my www/test folder to use with php; with no luck.
but the command 'wkhtmltopdf test.html test.pdf' from terminal woks just fine.
Then where is the problem???
Can anyone please help me out???
p.s. I use ubuntu 12.04. php 5.4.7
The error message from exec call shows: Array ( [0] => /usr/bin/wkhtmltopdf: /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6) )

Related

php mail() working on terminal but not in browser

I have a small php test script with the following code:
if (mail("test#test.com", "Subject", "Message", "From:test#test.com")) {
echo 'OK';
} else {
echo 'failur';
}
When I run the script in the terminal like this:
php test.php
It prints 'OK' but when I open it on my lokal apache via localhost/test.php is says 'failur'.
I also hava a file with phpinfo() in it and the browser and terminal are using the same php version and the same php.ini file.
I can't think of a apache configuration that would prevent mail from working.
Apache 2.4.18 (Mac)
PHP 5.6.23 (installed via homebrew)

PHP extension Dio is not loaded?

I am trying to communicate with the COM Ports using the DIO extension, but it's not working it seems. I have already added the .dll file into my ext folder but I still can't find the Dio support enabled in PHP info(). I have already restarted my XAMPP server more than twice, but still, it's not working. This is my current code for the com port testing.
$portName = 'COM9:';
$baudRate = 9600;
$bits = 8;
$spotBit = 1;
header( 'Content-type: text/plain; charset=utf-8' );
?>
Serial Port Test
================
<?php
function echoFlush($string)
{
echo $string . "\n";
flush();
ob_flush();
}
if(!extension_loaded('dio'))
{
echoFlush( "PHP Direct IO does not appear to be installed for more info see: http://www.php.net/manual/en/book.dio.php" );
exit;
}
This is the error I am getting now.
PHP Direct IO does not appear to be installed for more info see: http://www.php.net/manual/en/book.dio.php
This is the steps I followed while installing the extension:
I downloaded the direct io from the pecl website
Then I copied the php_dio.dll into the PHP/ext folder
Next, I edited the php.ini file by adding the extension=php_dio.dll
Then I restarted my XAMPP webserver
I opened php_info() to check out the php_dio.dll and found that it is not still loaded.
Did you check extension_dir directive in your phpinfo() output?
Try using PHP version 7.2, it works for me, but not in version 7.3.
We got confused with the XAMPP architecture version with Windows. It worked after installing the right. Thank you guys.

PHP TesseractOCR exec command issue

I have installed TesseractOCR from terminal of mac. when i run the following command from terminal it is working.
tesseract "hello.png" /Applications/MAMP/tmp/php/987051047
but the same command is not working in
exec("tesseract "hello.png" /Applications/MAMP/tmp/php/987051047")
and the full code is
$tesseract = new TesseractOCR("hello.png");
$tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir();
$tesseract->setTempDir( $tmp_dir );
$test = $tesseract->recognize();
I feel I have to load tesseract in php.ini or any other configuration file. but I don't know where. I am using mac, MAMP, php 5.4.10
Ok after installation we need to change the path for bin
$path = getenv('PATH');
putenv("PATH=$path:/usr/local/bin");
add these lines and it will work
Thanks

shell_exec() not executing pdftotext command

I installed the required library and its working in terminal but not in my php file.
My code is :
$mypdf = shell_exec('/usr/local/bin/pdftotext test.pdf test.txt');
echo $mypdf;
If I execute this command /usr/local/bin/pdftotext test.pdf test.txt in terminal it works fine.
I also write my code this type :
shell_exec('/usr/local/bin/pdftotext test.pdf test.txt');
$mypdf = file_get_contents("test.txt");
echo $mypdf;
In Error Log the message is :
/usr/local/bin/pdftotext: /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6)
My guess would be that you're expecting $mypdf to contain the PDF document instead of the return value of the executed command. If you're trying to print out 'test.txt', then you'll need to load it up and print it.
Issue was: /usr/local/bin/pdftotext: /opt/lampp/lib/libgcc_s.so.1: version 'GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6)
And the solution was to rename /opt/lampp/lib/libgcc_s.so.1 to libgcc_s.so.1.bak and solves my problem. But confusion is that what was the issue in it :P
I think you have some trouble with a dependency. Check your error.log. Find out which file is missing and add it to the path environment variable of your php installation.

installing codeigniter sparks manager on windows

SOLVED, read bottom of post:
I'm trying to install the Sparks package manager on windows by following the official instructions.
Issuing this command:
php -r "$(curl -fsSL http://getsparks.org/go-sparks)"
results in this errormessage:
Parse error: syntax error, unexpected ':' in Command line code on line 1
If I only execute the curl command within the above line, i.e this:
curl -fsSL http://getsparks.org/go-sparks
it echoes out the php script located on the URL. So I think the problem is piping the curl output to PHP somehow fails. I've tried a couple of variants, using diffrent quotes etc but I'm at a loss.
MY SOLUTION
As DaveRandom pointed out, the instruction didn't apply to windows.
But instead of doing it the manual(normal) way, what I did was taking the output from curl, appending php script tags and executing it as a file with the php -f option.
Here is the output:
<?php
$zip = "http://getsparks.org/static/install/spark-manager-0.0.7.zip";
$loader = "http://getsparks.org/static/install/MY_Loader.php.txt";
if(!file_exists("application/core"))
{
echo "Can't find application/core. Currently this script only works with the default instance of Reactor. You may need to try a manual installation..\n";
exit;
}
echo "Pulling down spark manager from $zip ...\n";
copy($zip, "sparks.zip");
echo "Pulling down Loader class core extension from $loader ...\n";
copy($loader, "application/core/MY_Loader.php");
echo "Extracting zip package ...\n";
if(class_exists('ZipArchive'))
{
$zip = new ZipArchive;
if ($zip->open('sparks.zip') === TRUE)
{
$zip->extractTo('./tools');
$zip->close();
} else {
echo "Extraction failed .. exiting.\n";
exit;
}
} elseif(!!#`unzip`) {
`unzip sparks.zip -d ./tools`;
} else
{
echo "It seems you have no PHP zip library or `unzip` in your path. Use the manual installation.\n";
exit;
}
echo "Cleaning up ...\n";
#unlink('sparks.zip');
echo "Spark Manager has been installed successfully!\n";
echo "Try: `php tools/spark help`\n";
The instructions you linked do explicitly state;
In order to use this quick start option, you should be using OSX or some flavor of linux.
You need to follow the Normal Installation instructions for use on Windows.
You should execute the command php -r "$(curl -fsSL http://getsparks.org/go-sparks)" in your root application folder. Maybe you're executing this command at wrong folder.

Categories