Devblog

Mes notes de développeur

  • You must have at least Zend Framework 1.11
  • You must clone page from the PDF you want to merge, else, your application will print an error (self explanatory one) found thanks to this slideshare which is very interesting for Zend_Pdf)
  • The static PDF must be a PDF

    Initializing the merged PDF
     $pdf2show = new Zend_Pdf();
     // $pdfContent
    is the generated one
     $pdf1 = Zend_Pdf::parse($pdfContent, 1); 
     //
    cloning the page (a must do)
     $template = clone $pdf1->pages[0]; 
     //
    Creating the first page of the merged PDF with the previous content
     $page1 =
    new Zend_Pdf_Page($template); 
     // Adding this page to the final PDF
    
    $pdf2show->pages[] = $page1; 
     // Loading the statif PDF
     $pdf2 =
    Zend_Pdf::load('urlToYourPDF.pdf'); 
     // cloning the page (a must do)
    
    $template2 = clone $pdf2->pages[0]; 
     // Creating the second page of the
    merged PDF with the previous content
     $page2 = new
    Zend_Pdf_Page($template2);
     // Adding this page to the final PDF 
    
    $pdf2show->pages[] = $page2; 
     sendToWebBrowser('title',
    $pdf2show->render());

sendToWebBrowser is a function sending the PDF content to browser with the title as... title.

$pdf2show->render() produces the merged PDF content as a string.