Erstellen von PDFs mit ZF (Zend Framework)
Autor: Norman Rauthe
eingetragen: Donnerstag, 02. September 2010 um 16:23 Uhr (35/2010 Kalenderwoche)
geändert: Donnerstag, 02. September 2010 um 16:23 Uhr (35/2010 Kalenderwoche)
Keywords: PDF Dokumente
Text:
Creating PDF Documents with Zend Framework
http://devzone.zend.com/article/12492-Creating-PDF-Documents-with-...
Quellcode:
<?php
// include auto-loader class
require_once 'Zend/Loader/Autoloader.php';
// register auto-loader
$loader = Zend_Loader_Autoloader::getInstance();
try {
// create PDF
$pdf = new Zend_Pdf();
// create A4 page
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
// define font resource
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// set font for page
// write text to page
$page->setFont($font, 24)
->drawText('That which we call a rose,', 72, 720)
->drawText('By any other name would smell as sweet.', 72, 620);
// add page to document
$pdf->pages[] = $page;
// save as file
$pdf->save('example.pdf');
echo 'SUCCESS: Document saved!';
} catch (Zend_Pdf_Exception $e) {
die ('PDF error: ' . $e->getMessage());
} catch (Exception $e) {
die ('Application error: ' . $e->getMessage());
}
?>