Draw text on a loaded pdf file with Zend Framework

Posted by Rick de Graaf on Stack Overflow See other posts from Stack Overflow or by Rick de Graaf
Published on 2010-06-14T09:20:19Z Indexed on 2010/06/14 9:22 UTC
Read the original article Hit count: 281

Filed under:
|
|

Hello,

I'm trying to load a existing pdf file, and fill this with database information. Loading the file and everything is working, except for writing data to the loaded page. It doesn't write text to the loaded page. If I add a new page en use a foreach to apply drawing to all pages, all added pages are written, except for the loaded one. Below is the code I'm using:

$pdf = Zend_Pdf::load('./documents/agreements/_root/gegevens.pdf'); // Load pdf
$pdf->pages = array_reverse($pdf->pages); // reverse pages
$pdf->pages[] = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4); // Add a page (A4)
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA); // Set font
foreach($pdf->pages as $page) // Apply settings+text to every page (total of 2)
{
    $page->setFont($font, 36);
    $page->setAlpha(0.25);
    $page->drawText('LALALALALALALA', 62, 260, 'UTF-8');
}
$pdf->save('./documents/agreements/Gegevens_'.$this->school_id.'.pdf'); // Save file

© Stack Overflow or respective owner

Related posts about pdf

Related posts about framework