mikehaertl/php-pdftk

Split PDF pages into seprate files.

koundalsandeep opened this issue · 7 comments

Split PDF pages into separate files. This is my code:

require_once('../../Users/acer/vendor/autoload.php');

use mikehaertl\pdftk\Pdf;
$path = str_replace("\\","/",__DIR__);
$pdf = new Pdf($path.'/SupplierInvoices_FPJ0003014351.pdf');
$pdf = new Pdf($path.'/SupplierInvoices_FPJ0003014351.pdf', [
    'command' => 'C:\Program Files (x86)\PDFtk\bin\pdftk.exe',
    'useExec' => true,
]);
$result = $pdf->burst(sprintf("%s/SupplierInvoices_FPJ0003014351_%d.pdf",$path,null));     // Supply a printf() pattern
print_r($result);

if ($result === false) {
    $error = $pdf->getError();
}

Problem is only split last page of PDF. In the actual file there is 18 pages in PDF. But burst function save last page of PDF in separate file. Please give me some solution to save all pages in to separate Files.

(Edited by owner for better readibility)

The argument you pass to burst() must contain a %d placeholder. You should not have that call to sprintf() there which will already replace the placeholders.

I have also used this,but not working:

$result = $pdf->burst($path."/SupplierInvoices_FPJ0003014351_%d.pdf"); // Supply a printf() pattern

Does it work on the command line when you call pdftk.exe directly?

Is this functionality in your SDK or not? I have use same code as you given in readme file but doesn't work. So please let me know if you have some solution regarding this issue. Also let me know if functionality is available in pro version or not?

Our library is free software and there is no pro version or something. It's only a wrapper for PHP around pdftk.exe. We are not related to the pdftk project so if things don't work as expected we need to find out if the problem is on our side or in pdftk.exe.

If you don't like the terms of use feel free to use another library.

Its working but only split last page to separate file not for other. can you please have a look for solution?

As I explained, this project is not pdftk. If the command does not work as expected you should better open an issue there.