mikehaertl\pdftk\Pdf::burst PHP Method

burst() public method

Split the PDF document into pages
public burst ( string | null $filepattern = null ) : boolean
$filepattern string | null the output name in sprintf format or null for default 'pg_%04d.pdf'
return boolean whether the burst command was successful
    public function burst($filepattern = null)
    {
        $this->constrainSingleFile();
        $this->getCommand()->setOperation('burst');
        $this->_output = $filepattern === null ? 'pg_%04d.pdf' : $filepattern;
        return $this->execute();
    }

Usage Example

Exemplo n.º 1
-1
 public function testCanBurstWithFilePattern()
 {
     $document = $this->getDocument1();
     $dir = __DIR__;
     $filepattern = $dir . '/burst_page_%d.pdf';
     chdir($dir);
     $pdf = new Pdf($document);
     $this->assertTrue($pdf->burst($filepattern));
     for ($x = 1; $x <= 5; $x++) {
         $filename = sprintf($filepattern, $x);
         $this->assertFileExists($filename);
         @unlink($filename);
     }
     @unlink($dir . '/doc_data.txt');
 }