/**
  * Sets the option $name to $value.
  *
  * @throws ezcBasePropertyNotFoundException
  *         if the property $name is not defined
  * @throws ezcBaseValueException
  *         if $value is not correct for the property $name
  * @param string $name
  * @param mixed $value
  * @ignore
  */
 public function __set($name, $value)
 {
     switch ($name) {
         case 'footer':
         case 'showDocumentTitle':
         case 'showDocumentAuthor':
         case 'showPageNumber':
         case 'centerPageNumber':
             if (!is_bool($value)) {
                 throw new ezcBaseValueException($name, $value, 'boolean');
             }
             $this->properties[$name] = $value;
             break;
         case 'height':
             $this->properties[$name] = ezcDocumentPcssMeasure::create($value);
             break;
         case 'pageNumberOffset':
             if (!is_int($value)) {
                 throw new ezcBaseValueException($name, $value, 'int');
             }
             $this->properties[$name] = $value;
             break;
         default:
             parent::__set($name, $value);
     }
 }
Exemplo n.º 2
0
 public function testUnhandledUnit2()
 {
     $driver = new ezcTestDocumentPdfMockDriver();
     try {
         ezcDocumentPcssMeasure::create('10mm')->get('foo');
         $this->fail('Expected ezcDocumentParserException.');
     } catch (ezcDocumentParserException $e) {
         /* Expected */
     }
 }
Exemplo n.º 3
0
 public function testRenderPolylineOpen()
 {
     $driver = $this->getDriver();
     $driver->createPage(210, 297);
     $color = new ezcDocumentPcssStyleColorValue();
     $color->parse('#204a87');
     $driver->drawPolyline(array(array(200, 10), array(105, 287), array(10, 10)), $color->value, ezcDocumentPcssMeasure::create('1pt')->get(), false);
     $pdf = $driver->save();
     $this->assertPdfDocumentsSimilar($pdf, get_class($driver) . '_' . __FUNCTION__);
 }
Exemplo n.º 4
0
 /**
  * Parse value string representation
  *
  * Parse the string representation of the value into a usable
  * representation.
  * 
  * @param string $value 
  * @return void
  */
 public function parse($value)
 {
     $this->value = ezcDocumentPcssMeasure::create($value)->get();
     return $this;
 }
Exemplo n.º 5
0
 /**
  * Render text decoration
  *
  * Render text decoration, like by a assigned text-decoration setting, or
  * background-colors, and similar.
  * 
  * @param array $styles 
  * @param float $x 
  * @param float $y 
  * @param float $width 
  * @param float $height 
  * @return void
  */
 protected function renderTextDecoration(array $styles, $x, $y, $width, $height)
 {
     // Directly exit, if there are no decorations to render
     if ($styles['text-decoration']->value === 'none' && (!isset($styles['background-color']) || $styles['background-color']->value['alpha'] >= 1)) {
         return;
     }
     if (isset($styles['background-color']) && $styles['background-color']->value['alpha'] < 1) {
         $this->driver->drawPolygon(array(array($x, $y), array($x + $width, $y), array($x + $width, $y + $height * $styles['line-height']->value), array($x, $y + $height * $styles['line-height']->value)), $styles['background-color']->value);
     }
     if (strpos($styles['text-decoration'], 'line-through') !== false) {
         $this->driver->drawPolyline(array(array($x, $y + $height - $styles['font-size']->value / 3), array($x + $width, $y + $height - $styles['font-size']->value / 3)), $styles['color']->value, ezcDocumentPcssMeasure::create('1px')->get(), false);
     }
     if (strpos($styles['text-decoration'], 'overline') !== false) {
         $this->driver->drawPolyline(array(array($x, $y), array($x + $width, $y)), $styles['color']->value, ezcDocumentPcssMeasure::create('1px')->get(), false);
     }
     if (strpos($styles['text-decoration'], 'underline') !== false) {
         $this->driver->drawPolyline(array(array($x, $y + $height * 1.1), array($x + $width, $y + $height * 1.1)), $styles['color']->value, ezcDocumentPcssMeasure::create('1px')->get(), false);
     }
 }
Exemplo n.º 6
0
 /**
  * Draw word at given position
  *
  * Draw the given word at the given position using the currently set text
  * formatting options.
  *
  * The coordinate specifies the left bottom edge of the words bounding box.
  *
  * @param float $x
  * @param float $y
  * @param string $word
  * @return void
  */
 public function drawWord($x, $y, $word)
 {
     $size = ezcDocumentPcssMeasure::create($this->currentFont['size'] . 'pt')->get();
     $this->document->setXY($x, (double) round($y - $size, 4));
     $this->document->Write($size, $word);
 }
 public static function provideDefaultValues()
 {
     return array(array('height', ezcDocumentPcssMeasure::create('15mm')), array('footer', true), array('showDocumentTitle', true), array('showDocumentAuthor', true), array('showPageNumber', true), array('pageNumberOffset', 0), array('centerPageNumber', false));
 }
Exemplo n.º 8
0
 /**
  * Get SVG path string
  *
  * Transform the points array into a SVG path string.
  * 
  * @param array $points 
  * @param bool $close 
  * @return string
  */
 protected function getPointString(array $points, $close = true)
 {
     $pointString = 'M ';
     foreach ($points as $point) {
         $pointString .= sprintf('%.4F,%.4F L ', ezcDocumentPcssMeasure::create($point[0])->get('px', 90) + ezcDocumentPcssMeasure::create($this->offset)->get('px', 90), ezcDocumentPcssMeasure::create($point[1])->get('px', 90));
     }
     return substr($pointString, 0, -3) . ($close ? ' z ' : '');
 }
Exemplo n.º 9
0
 /**
  * Render internal links
  *
  * Internal links can only be rendered at the very last items in a PDF,
  * because *all* internal targets must already be known.
  * 
  * @return void
  */
 protected function renderInternalLinks()
 {
     foreach ($this->pendingInternalLinks as $link) {
         list($page, $x, $y, $width, $height, $target) = $link;
         if (!isset($this->internalTargets[$target])) {
             // Link reference without any target
             continue;
         }
         $page->createLinkAnnotation(array(ezcDocumentPcssMeasure::create($x)->get('pt'), $this->currentPage->getHeight() - ezcDocumentPcssMeasure::create($y + $height)->get('pt'), ezcDocumentPcssMeasure::create($x + $width)->get('pt'), $this->currentPage->getHeight() - ezcDocumentPcssMeasure::create($y)->get('pt')), $this->internalTargets[$target]);
     }
 }