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?
+1
A:
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.
David Caunt
2010-03-10 23:31:21
Is there a way to determine if the front page has already been added? i.e. is there a way to see if the current first page is identical to the single page file?
Brian
2010-03-10 23:53:53
I've never tried to do that - it may be possible to compare the protected $_contents of a page if you make a subclass. Ideally you would convert all docs at one point and just know that they've been processed, but I can appreciate that might not always be possible.
David Caunt
2010-03-11 00:26:05