/** * Draw an image at the specified position on the page. * * @param \Zend\Pdf\Image $image * @param float $x1 * @param float $y1 * @param float $x2 * @param float $y2 * @return \Zend\Pdf\Page */ public function drawImage(Resource\Image\AbstractImage $image, $x1, $y1, $x2, $y2) { $this->_addProcSet('PDF'); $imageName = $this->_attachResource('XObject', $image); $imageNameObj = new InternalType\NameObject($imageName); $x1Obj = new InternalType\NumericObject($x1); $y1Obj = new InternalType\NumericObject($y1); $widthObj = new InternalType\NumericObject($x2 - $x1); $heightObj = new InternalType\NumericObject($y2 - $y1); $this->_contents .= "q\n" . '1 0 0 1 ' . $x1Obj->toString() . ' ' . $y1Obj->toString() . " cm\n" . $widthObj->toString() . ' 0 0 ' . $heightObj->toString() . " 0 0 cm\n" . $imageNameObj->toString() . " Do\n" . "Q\n"; return $this; }
/** * Return object as string * * @param \Zend\Pdf\ObjectFactory $factory * @return string */ public function toString(Pdf\ObjectFactory $factory = null) { $outStr = '<<'; $lastNL = 0; foreach ($this->_items as $name => $element) { if (!is_object($element)) { throw new Exception\RuntimeException('Wrong data'); } if (strlen($outStr) - $lastNL > 128) { $outStr .= "\n"; $lastNL = strlen($outStr); } $nameObj = new NameObject($name); $outStr .= $nameObj->toString($factory) . ' ' . $element->toString($factory) . ' '; } $outStr .= '>>'; return $outStr; }
public function testToString() { $nameObj = new InternalType\NameObject('MyName'); $this->assertEquals($nameObj->toString(), '/MyName'); }