Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To begin with, it is worth noting that the version of <code>ZendPdf</code> that you are referring to is the version that was originally included in ZF2 but was dropped from the framework some time in 2011. As a side note, I spoke to Matthew Weier O'Phinney (ZF2 project lead) about this at ZendCon 2012 and he said that if anybody wants to put their hand up to maintain this class we can get it back into the ZF2 framework.</p> <p>The ZF2 version that we're talking about here, although semantically identical to the ZF1 version, is syntactically different due to the fact that the ZF2 developers did the conversion to namespaces and some other refactoring before they decided to split it off from the main project. Most (maybe even all?) of the <code>ZendPdf</code> examples are for <code>Zend_Pdf</code> from ZF1 and they won't work with this version unless you deal with the autoloading and the other syntactical differences.</p> <p>I hadn't used this standalone version until today and discovered that it DOES NOT RENDER the resulting PDF document unless you include one folder of source code from the ZF2 framework. In order to make the sample code below run, you will need to grab a copy of the ZF2 framework and copy the <code>Zend/Memory</code> folder into the <code>library</code> folder that was created when you downloaded <code>ZendPdf</code> from Github.</p> <p>Once you've done that, the following stand-alone PHP code will allow you to use <code>ZendPdf</code> to create a PDF file:</p> <pre><code>&lt;?php function simpleBootLoader( $stack ) { require_once './library/' . str_replace( '\\', DIRECTORY_SEPARATOR, $stack ) . '.php'; } spl_autoload_register( 'simpleBootLoader' ); use ZendPdf\PdfDocument; use ZendPdf\Page; use ZendPdf\Font; $pdf = new PdfDocument(); $pdf-&gt;pages[0] = new Page( Page::SIZE_A4 ); $pdf-&gt;pages[0]-&gt;setFont( Font::fontWithName( Font::FONT_HELVETICA ), 24 ); $pdf-&gt;pages[0]-&gt;drawText( 'Hello world!', 240, 400 ); $pdf-&gt;save( 'example.pdf' ); </code></pre> <p>This is not production-ready code by any stretch of the imagination. You'll want a more robust autoloader for starters.</p> <p>Anyway, I hope this solves your immediate problem and/or gets you on the right track. Good luck!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload