/** * Finish currently generating book * Add product indexes pages * * @var int $page Current page */ public function finishbookAction() { if (!Zend_Auth::getInstance()->hasIdentity()) { throw new Zend_Exception("Page not found", 404); } $this->_helper->layout->disableLayout(); $page = $this->getRequest()->getParam("page"); $startPage = $this->getRequest()->getParam("startPage"); $pageFormat = $this->getRequest()->getParam("pageFormat"); $print = $this->getRequest()->getParam("print"); $pdfBook = new Model_Static_PdfBook($pageFormat, $print); //если формат А4 то мы добавляем дополнительные файлы в конечный архив и также рендерим страници " наше предложение" с нужной номерацией if ($pageFormat == "A4") { $bookOurProduction = $pdfBook->generateOurProduction($page, $print); $page += 2; $saveFilenameOurProduction = "ourProduction.pdf"; $bookOurProduction->save(APPLICATION_ROOT . $this::PDFBOOK_DIR . '/' . $saveFilenameOurProduction); $dir = APPLICATION_ROOT . $this::PDFCOVER_DIR; $files = scandir($dir); //перебераем все файлы которые числяться как добавочные и добавляем их в архив foreach ($files as $file) { if (is_dir($file)) { continue; } $front = Zend_Pdf::load(APPLICATION_ROOT . $this::PDFCOVER_DIR . '/' . $file); $front->save(APPLICATION_ROOT . $this::PDFBOOK_DIR . '/' . $file); } } $book = $pdfBook->IndexPages($page); $this->view->nextpage = $page + count($book->pages); $saveFilename = str_repeat("0", 4 - strlen($page)) . $page . '-' . $this->view->nextpage . '.pdf'; $book->save(APPLICATION_ROOT . $this::PDFBOOK_DIR . '/' . $saveFilename); if ($this->secondTime == 0) { $this->generateContents($startPage, $pageFormat, $print); } $this->view->page = $this->contentPages + $startPage; $this->zipResults(); }
/** * Generate PDF for selected product * * @var int $id Selected product */ public function pdfAction() { $this->getResponse()->setHeader('Content-Type', 'application/pdf'); $productsModel = new Model_DbTable_Products(); // get product $id = $this->getRequest()->getParam("id"); $product = $productsModel->find($id)->current(); // generate pdf $pdfBook = new Model_Static_PdfBook('A5'); $pdfBook->byProduct($product); $this->view->content = $pdfBook->finishBook(); $this->_helper->layout()->disableLayout(); }