I can't execute pdftk in php. As in documentation, it is just mentioned as follow to saveas.
use mikehaertl\pdftk\Pdf;
$pdf = new Pdf('/path/my.pdf');
$pdf->allow('AllFeatures') // Change permissions
->compress($value) // Compress/Uncompress
->saveAs('new.pdf');
But my code doesn't give any output. I try to debug like
// Check for errors
if (!$pdf->saveAs('new.pdf')) {
$error = $pdf->getError();
}
No message. Later I found, Pdftk hasn't been executed
public function saveAs($name)
{
if (!$this->getCommand()->getExecuted() && !$this->execute()) {
echo 'test'; // it is printing
return false;
}
}
What does it mean ? I have installed from composer. When reading github issue, developer's reply likely my problem. is You need to set the path to your pdftk command, see https://github.com/mikehaertl/php-pdftk#execution
I can't clear about how to set path, it is not highlighted in documentation. Only mentioned here
The class uses php-shellcommand to execute pdftk. You can pass $options for its Command class as second argument to the constructor: As example.
$pdf = new Pdf('/path/my.pdf', [
'command' => '/some/other/path/to/pdftk',
// or on most Windows systems:
// 'command' => 'C:\Program Files (x86)\PDFtk\bin\pdftk.exe',
'useExec' => true, // May help on Windows systems if execution fails
]);
I am using xampp. Regarding pdftk, I have a directory within project which was created from composer. phpand what is this path ? this project can be moved in linux or window server ? Do I need any third party software installation for this ?