Search code examples
phppdftk

is this the right php header for pdftk


I'm writing a very basic catenation script and lifted this straight off the pdftk 0.10.0 packagist site:

    use mikehaertl\pdftk\Pdf;


// Extract pages 1-2 into a new file
$pdf = new Pdf('sourcefile.pdf');
$result = $pdf->cat(1, 2)
        ->saveAs('newfile.pdf');
if ($result === false) {
    $error = $pdf->getError();
}

But I'm getting this error:

Fatal error: Uncaught Error: Class "mikehaertl\pdftk\Pdf" not found in C:\PHP8\index.php:7 Stack trace: #0 {main} thrown in C:\PHP8\index.php on line 7

All the sample scripts I've seen have that same header. I'm sure it's something really basic that I'm not seeing here.


Solution

  • Apparently, when installed via composer, the pdftk.exe file is not downloaded for some reason. I downloaded it manually from the github page and referred to it in the header.