Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [ZF] genrowanie PDF kilkustronnicowego
krzyszbi
post 28.02.2008, 13:29:18
Post #1





Grupa: Zarejestrowani
Postów: 251
Pomógł: 13
Dołączył: 15.09.2005

Ostrzeżenie: (0%)
-----


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/developerwork...end5/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

  1. <?php
  2. class Admin_PdfController extends Cyber_Controllers_Admin {
  3. public function init(){
  4. parent::init();
  5. }
  6. private function newPdfPage(){
  7. $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
  8. $style = new Zend_Pdf_Style();
  9. $style->setLineColor(new Zend_Pdf_Color_RGB(0.9, 0, 0));
  10. $style->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
  11. $style->setLineWidth(0.1);
  12. $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32);
  13. $page->setStyle($style);
  14. $pageHeight = $page->getHeight();
  15. $pageWidth = $page->getWidth();
  16. //$page->drawRectangle(10, $pageHeight - 28, $pageWidth - 28,10, Zend_Pdf_Page::SHAPE_DRAW_STROKE);
  17. return $page;
  18. }
  19. public function indexAction (){
  20. $pdf = new Zend_Pdf();
  21. $page = $this->newPdfPage();
  22. $pageHeight = $page->getHeight();
  23. $pageWidth = $page->getWidth();
  24. $startPos = $pageHeight - 20;
  25. $style = new Zend_Pdf_Style();
  26.  for($i=0; $i<50;$i++){
  27. $title = 'Phasellus. '.$startPos;
  28. $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.'
    ;
  29. /*
  30. if ($startPos < 72){
  31.  array_push($pdf->pages, $page);
  32.  $page = $this->newPdfPage();
  33.  $startPos = $pageHeight - 48;
  34. }//*/
  35. $headlineStyle = new Zend_Pdf_Style();
  36. $headlineStyle->setFillColor(new Zend_Pdf_Color_RGB(0.9, 0, 0));
  37. $headlineStyle->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 12);
  38. $page->setStyle($headlineStyle);
  39. $title = strip_tags($title );
  40. $title = wordwrap($title , 55, '\n');
  41. $headlineArray = explode('\n', $title );
  42. foreach ($headlineArray as $line) {
  43. $line = ltrim($line);
  44. $page->drawText($line, 30, $startPos,'UTF-8');
  45. $startPos = $startPos - 10;
  46. }
  47. $articleStyle = new Zend_Pdf_Style();
  48. $articleStyle->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
  49. $articleStyle->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 9);
  50. $articleStyle->setFontSize(8);
  51. $page->setStyle($articleStyle);
  52. $entrydata = strip_tags($entrydata);
  53. $entrydata = wordwrap($entrydata, 150, '\n');
  54. $articleArray = explode('\n', $entrydata);
  55. foreach ($articleArray as $line) {
  56. /*if ($startPos < 48){
  57.  array_push($pdf->pages, $page);
  58.  $page = $this->newPdfPage();
  59.  $articleStyle = new Zend_Pdf_Style();
  60.  $articleStyle->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
  61.  $articleStyle->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
  62.  $page->setStyle($articleStyle);
  63.  $startPos = $pageHeight - 48;
  64. }*/
  65. $page->drawText($line, 36, $startPos);
  66. $startPos = $startPos - 10;
  67. }
  68. $startPos = $startPos - 5;
  69.  }
  70. array_push($pdf->pages, $page);
  71. $pdfData=$pdf->render();
  72. header("Content-Disposition: inline; filename=result.pdf"); 
  73. header("Content-type: application/pdf");
  74. echo $pdfData;
  75.  
  76. }
  77. public function noRouteAction(){
  78. $this->_redirect('/Admin/Ciecze/');
  79. }
  80. }
  81. ?>


i tutaj dostaje po generacji następujący komunikat
Kod
Plik jest uszkodzony i nie mógł być naprawiony.


i nie wiem od czego to jest kombinuje na różne sposoby i mi nie odzie
jakieś sugestie, wskazówki


--------------------
Everything should be made as simple as possible, but not simpler. - A.Eainstein
Go to the top of the page
+Quote Post
GrayHat
post 28.02.2008, 13:35:31
Post #2





Grupa: Zarejestrowani
Postów: 566
Pomógł: 18
Dołączył: 23.08.2003
Skąd: Łomża

Ostrzeżenie: (0%)
-----


sproboj dac exit; po echo $pdfData;


--------------------
*Note: No animals were killed durning the construction of this post.
Go to the top of the page
+Quote Post
krzyszbi
post 28.02.2008, 13:45:02
Post #3





Grupa: Zarejestrowani
Postów: 251
Pomógł: 13
Dołączył: 15.09.2005

Ostrzeżenie: (0%)
-----


dzięki pomogło smile.gif nigdy bym na to nie wpadł


--------------------
Everything should be made as simple as possible, but not simpler. - A.Eainstein
Go to the top of the page
+Quote Post
GrayHat
post 28.02.2008, 13:48:59
Post #4





Grupa: Zarejestrowani
Postów: 566
Pomógł: 18
Dołączył: 23.08.2003
Skąd: Łomża

Ostrzeżenie: (0%)
-----


Swoją drogą zainteresuj się komponentem Zend_Layout winksmiley.jpg Ominiesz na przyszłość takie błędy

http://framework.zend.com/wiki/display/ZFPROP/Zend_Layout


Pozdrawiam


--------------------
*Note: No animals were killed durning the construction of this post.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.04.2024 - 05:21