Exemplo n.º 1
0
 public function onEndParseNode(Document $document, PageCollection $root, Node $node, DocumentParsingContext $context)
 {
     if (!$this->isPage($node) && $this->isPage($node->getParent())) {
         $node->format($document);
         $node->collectUnorderedDrawingTasks($document, $this->behavioursTasks);
     }
     $this->processDynamicPage($document, $node);
     if ($this->isPage($node)) {
         $node->postFormat($document);
         $tasks = new DrawingTaskHeap();
         if (!$this->isDynamicPage($node) || count($node->getPages()) > 0) {
             $node->collectOrderedDrawingTasks($document, $tasks);
         }
         $node->collectPostDrawingTasks($document, $tasks);
         $document->invokeTasks($tasks);
         $node->flush();
         $root->flush();
     }
 }
Exemplo n.º 2
0
 /**
  * Invokes drawing procedure.
  *
  * Formats each of node, retreives drawing tasks and executes them.
  *
  * @param array $pages Array of pages to draw
  */
 public function draw($pages)
 {
     if ($this->isProcessed()) {
         throw new LogicException(sprintf('Pdf has alredy been drawed.'));
     }
     $this->processed = true;
     if (is_array($pages)) {
         $pageCollection = new PageCollection();
         foreach ($pages as $page) {
             if (!$page instanceof Page) {
                 throw new DrawingException(sprintf('Not all elements of passed array are PHPPdf\\Core\\Node\\Page type. One of them is "%s".', get_class($page)));
             }
             $pageCollection->add($page);
         }
     } elseif ($pages instanceof PageCollection) {
         $pageCollection = $pages;
     } else {
         throw new InvalidArgumentException(sprintf('Argument of draw method must be an array of pages or PageCollection object, "%s" given.', get_class($pages)));
     }
     $pageCollection->format($this);
     $tasks = $pageCollection->getAllDrawingTasks($this);
     $this->invokeTasks($tasks);
 }