Brian
Brian

Reputation: 27392

Add 1 Page to each PDF in folder

I have a folder with 100s of PDF versions of PPT presentations. I also have a one page PDF file that I want to add to the beginning of each PDF file. Is there a way I can do this with PHP? Could I maybe use the Zend Framework?

Upvotes: 1

Views: 177

Answers (1)

David Snabel-Caunt
David Snabel-Caunt

Reputation: 58361

It certainly can be done by Zend_Framework!

$pdf = Zend_Pdf::load($fileName);
$frontPdf = Zend_Pdf::load('/path/to/template.pdf');

$frontPage = $frontPdf->pages[0];

//prepend our template front page to PDF
array_unshift($pdf->pages, $frontPage);

//update original document
$pdf->save($fileName, true);

I haven't tested the code here but we have an application working on the same principle.

Check the documentation for pages within Zend_Pdf if you have any problems.

Upvotes: 1

Related Questions