witam
wyszła potrzeba ze musze wygenerować PDF-a z danymi z bazy a ich co nieco jest wiec na pewno sie na jednej stronie nie zmieści
przerabiam tutorial z https://www6.software.ibm.com/developerworks/education/os-php-zend5/index.html
używam ZF w wersji 1.03 a serwer to XAMPP 1.65
wszystko ładnie pięknie ( małe niezgodności wynikające z wersji ZF ale z tym sobie poradziłem ) a nie chce mi działaś generowanie wielostronicowego dokumentu
mam poniższy kod i generuje mi jedną stronę dokumentu
co to jest w komentarzu ma odpowiadać za przenoszenie i tworzenie nowych stron
<?php class Admin_PdfController extends Cyber_Controllers_Admin { public function init(){ parent::init(); } private function newPdfPage(){ $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4); $style = new Zend_Pdf_Style(); $style->setLineColor(new Zend_Pdf_Color_RGB(0.9, 0, 0)); $style->setFillColor(new Zend_Pdf_Color_GrayScale(0.2)); $style->setLineWidth(0.1); $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32); $page->setStyle($style); $pageHeight = $page->getHeight(); $pageWidth = $page->getWidth(); //$page->drawRectangle(10, $pageHeight - 28, $pageWidth - 28,10, Zend_Pdf_Page::SHAPE_DRAW_STROKE); return $page; } public function indexAction (){ $pdf = new Zend_Pdf(); $page = $this->newPdfPage(); $pageHeight = $page->getHeight(); $pageWidth = $page->getWidth(); $startPos = $pageHeight - 20; $style = new Zend_Pdf_Style(); for($i=0; $i<50;$i++){ $title = 'Phasellus. '.$startPos; $entrydata = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus et elit. Cur
abitur quis augue convallis mauris venenatis tristique. Sed quam. Praesent malesu
ada augue vel neque. Duis et orci. Donec posuere lorem. Praesent luctus volutpat
nibh. Sed turpis. Nulla tellus. Nunc nec augue. Mauris pede. Praesent molestie pl
acerat lacus. Praesent pharetra imperdiet massa. Cras vel metus ullamcorper sapie
n congue mattis. Morbi convallis. Curabitur aliquam felis eu arcu. Nunc molestie.
Ut ut augue.'; /* if ($startPos < 72){ array_push($pdf->pages, $page); $page = $this->newPdfPage(); $startPos = $pageHeight - 48; }//*/ $headlineStyle = new Zend_Pdf_Style(); $headlineStyle->setFillColor(new Zend_Pdf_Color_RGB(0.9, 0, 0)); $headlineStyle->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 12); $page->setStyle($headlineStyle); $title = http://www.php.net/strip_tags($title ); $title = http://www.php.net/wordwrap($title , 55, '\n'); $headlineArray = http://www.php.net/explode('\n', $title ); foreach ($headlineArray as $line) { $line = http://www.php.net/ltrim($line); $page->drawText($line, 30, $startPos,'UTF-8'); $startPos = $startPos - 10; } $articleStyle = new Zend_Pdf_Style(); $articleStyle->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0)); $articleStyle->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 9); $articleStyle->setFontSize(8); $page->setStyle($articleStyle); $entrydata = http://www.php.net/strip_tags($entrydata); $entrydata = http://www.php.net/wordwrap($entrydata, 150, '\n'); $articleArray = http://www.php.net/explode('\n', $entrydata); foreach ($articleArray as $line) { /*if ($startPos < 48){ array_push($pdf->pages, $page); $page = $this->newPdfPage(); $articleStyle = new Zend_Pdf_Style(); $articleStyle->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0)); $articleStyle->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12); $page->setStyle($articleStyle); $startPos = $pageHeight - 48; }*/ $page->drawText($line, 36, $startPos); $startPos = $startPos - 10; } $startPos = $startPos - 5; } http://www.php.net/array_push($pdf->pages, $page); $pdfData=$pdf->render(); http://www.php.net/header("Content-Disposition: inline; filename=result.pdf"); http://www.php.net/header("Content-type: application/pdf"); http://www.php.net/echo $pdfData; } public function noRouteAction(){ $this->_redirect('/Admin/Ciecze/'); } } ?>
sproboj dac exit; po echo $pdfData;
dzięki pomogło nigdy bym na to nie wpadł
Swoją drogą zainteresuj się komponentem Zend_Layout Ominiesz na przyszłość takie błędy
http://framework.zend.com/wiki/display/ZFPROP/Zend_Layout
Pozdrawiam
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)