Example #1
0
File: main.php Project: bmdevel/ezc
 /**
  * Handle calls to paragraph renderer
  *
  * @param ezcDocumentLocateableDomElement $element
  * @return void
  */
 private function renderParagraph(ezcDocumentLocateableDomElement $element)
 {
     $renderer = new ezcDocumentPdfWrappingTextBoxRenderer($this->driver, $this->styles);
     $page = $this->driver->currentPage();
     $styles = $this->styles->inferenceFormattingRules($element);
     // Just try to render at current position first
     $trans = $this->driver->startTransaction();
     if ($renderer->renderNode($page, $this->hyphenator, $this->tokenizer, $element, $this)) {
         $this->titleTransaction = null;
         $this->handleAnchors($element);
         return true;
     }
     // Check if something requested a rendering restart at a prior point,
     // only continue otherwise.
     if ($this->restart !== false || !$this->checkSkipPrerequisites(($pWidth = $this->calculateTextWidth($page, $element)) + $styles['text-column-spacing']->value, $pWidth)) {
         return false;
     }
     // If that did not work, switch to the next possible location and start
     // there.
     $this->driver->revert($trans);
     $this->getNextRenderingPosition(($pWidth = $this->calculateTextWidth($page, $element)) + $styles['text-column-spacing']->value, $pWidth);
     return $this->renderParagraph($element);
 }
Example #2
0
 /**
  * Renders a literal block.
  *
  * @param ezcDocumentPdfPage $page 
  * @param ezcDocumentPdfHyphenator $hyphenator 
  * @param ezcDocumentPdfTokenizer $tokenizer 
  * @param ezcDocumentLocateableDomElement $text 
  * @param ezcDocumentPdfMainRenderer $mainRenderer 
  * @return bool
  */
 public function renderNode(ezcDocumentPdfPage $page, ezcDocumentPdfHyphenator $hyphenator, ezcDocumentPdfTokenizer $tokenizer, ezcDocumentLocateableDomElement $text, ezcDocumentPdfMainRenderer $mainRenderer)
 {
     // Use a special tokenizer and hyphenator for literal blocks
     return parent::renderNode($page, new ezcDocumentPdfDefaultHyphenator(), new ezcDocumentPdfLiteralTokenizer(), $text, $mainRenderer);
 }
 protected function renderPdf(ezcDocumentPdfDriver $driver, $paragraph = 2)
 {
     $this->checkTestEnv($driver);
     $transactionalDriver = new ezcDocumentPdfTransactionalDriverWrapper();
     $transactionalDriver->setDriver($driver);
     $driver->createPage(108, 108);
     $renderer = new ezcDocumentPdfWrappingTextBoxRenderer($transactionalDriver, $this->styles);
     $renderer->renderNode($this->page, new ezcDocumentPdfDefaultHyphenator(), new ezcDocumentPdfDefaultTokenizer(), $this->xpath->query('//doc:para')->item($paragraph), new ezcDocumentPdfMainRenderer($transactionalDriver, $this->styles));
     $transactionalDriver->commit();
     return $driver->save();
 }