Tuesday, 15 April 2014

php - Where to get and how to use zend_pdf standalone -



php - Where to get and how to use zend_pdf standalone -

i spent lastly 2 days looking answers on how utilize zend_pdf standalone. found on google refers pdf.php can't find anywhere.

i have found zend_pdf here ( https://github.com/zendframework/zendpdf )

i don't want install entire framework on server , don't want people tell me utilize fpdf or tcpdf or else. zend_pdf seems perfect solution. want know how utilize asstandalon.

any clear instructions?

thank you

to begin with, worth noting version of zendpdf referring version included in zf2 dropped framework time in 2011. side note, spoke matthew weier o'phinney (zf2 project lead) @ zendcon 2012 , said if wants set hand maintain class can zf2 framework.

the zf2 version we're talking here, although semantically identical zf1 version, syntactically different due fact zf2 developers did conversion namespaces , other refactoring before decided split off main project. (maybe all?) of zendpdf examples zend_pdf zf1 , won't work version unless deal autoloading , other syntactical differences.

i hadn't used standalone version until today , discovered not render resulting pdf document unless include 1 folder of source code zf2 framework. in order create sample code below run, need grab re-create of zf2 framework , re-create zend/memory folder library folder created when downloaded zendpdf github.

once you've done that, next stand-alone php code allow utilize zendpdf create pdf file:

<?php function simplebootloader( $stack ) { require_once './library/' . str_replace( '\\', directory_separator, $stack ) . '.php'; } spl_autoload_register( 'simplebootloader' ); utilize zendpdf\pdfdocument; utilize zendpdf\page; utilize zendpdf\font; $pdf = new pdfdocument(); $pdf->pages[0] = new page( page::size_a4 ); $pdf->pages[0]->setfont( font::fontwithname( font::font_helvetica ), 24 ); $pdf->pages[0]->drawtext( 'hello world!', 240, 400 ); $pdf->save( 'example.pdf' );

this not production-ready code stretch of imagination. you'll want more robust autoloader starters.

anyway, hope solves immediate problem and/or gets on right track. luck!

php zend-pdf

No comments:

Post a Comment