mikehaertl / phpwkhtmltopdf

A slim PHP wrapper around wkhtmltopdf with an easy to use and clean OOP interface
MIT License
1.6k stars 238 forks source link

Could not run command wkhtmltopdf : #356

Closed hlf2016 closed 4 years ago

hlf2016 commented 4 years ago

I got error when I run it with browser. But when I run it with php test.php , it works well. So I don't know what happed.

ERR MESSAGE

Could not run command wkhtmltopdf 'https://www.washingtonpost.com/world/asia_pacific/china-launches-bold-attempt-to-land-rover-on-mars/2020/07/23/fef57f4c-cc9f-11ea-99b0-8426e26d203b_story.html' '/tmp/tmp_wkhtmlto_pdf_KLXUku.pdf'

CODE

<?php

require "vendor/autoload.php";
use mikehaertl\wkhtmlto\Pdf;

$pdf = new Pdf("https://www.washingtonpost.com/world/asia_pacific/china-launches-bold-attempt-to-land-rover-on-mars/2020/07/23/fef57f4c-cc9f-11ea-99b0-8426e26d203b_story.html");
if (!$pdf->saveAs('./page.pdf')) {
    $error = $pdf->getError();
    print_r($error);
    // ... handle error here
}
echo "success";
die;
mikehaertl commented 4 years ago

The error says, that wkhtmltopdf could not be executed from PHP. You need to figure out, why that is. E.g. no permissions or command is not in search path (in which case you could add the full path via the binary option).

I'm closing this as it's not a bug and I can not provide any more help.

hlf2016 commented 4 years ago

The error says, that wkhtmltopdf could not be executed from PHP. You need to figure out, why that is. E.g. no permissions or command is not in search path (in which case you could add the full path via the binary option).

I'm closing this as it's not a bug and I can not provide any more help.

Thank you. Thank you sir! The full path make no use as well