Example #1
0
 private function createImage($path)
 {
     try {
         return $this->imagine->open($path);
     } catch (\Imagine\Exception\Exception $e) {
         throw InvalidResourceException::invalidImageException($path, $e);
     }
 }
Example #2
0
 public function loadEngine($file, $encoding)
 {
     try {
         $image = $this->imagine->open($file);
         $gc = new GraphicsContext($this->imagine, $image);
         $engine = new self($this->imagine, $this->outputFormat, $this->unitConverter);
         $engine->attachGraphicsContext($gc);
         return $engine;
     } catch (\Imagine\Exception\RuntimeException $e) {
         throw InvalidResourceException::invalidImageException($file, $e);
     }
 }
Example #3
0
 private function createImage($path)
 {
     try {
         $imageType = $this->type;
         if ($imageType === IMAGETYPE_JPEG || $imageType === IMAGETYPE_JPEG2000) {
             return new Jpeg($path);
         } elseif ($imageType === IMAGETYPE_PNG) {
             return new Png($path);
         } elseif ($imageType === IMAGETYPE_TIFF_II || $imageType === IMAGETYPE_TIFF_MM) {
             return new Tiff($path);
         } else {
             throw InvalidResourceException::unsupportetImageTypeException($path);
         }
     } catch (\ZendPdf\Exception $e) {
         throw InvalidResourceException::invalidImageException($path, $e);
     }
 }
Example #4
0
 private function getResourceByStyle($style)
 {
     try {
         if (!isset($this->fonts[$style])) {
             $data = $this->fontResources[$style];
             if ($this->isNamedFont($data)) {
                 $name = $this->retrieveFontName($data);
                 $this->fonts[$style] = ZendFont::fontWithName($name);
             } else {
                 $this->fonts[$style] = ZendFont::fontWithPath($data);
             }
         }
         return $this->fonts[$style];
     } catch (\ZendPdf\Exception\ExceptionInterface $e) {
         throw InvalidResourceException::invalidFontException($this->fontResources[$style], $e);
     }
 }
Example #5
0
 public function loadEngine($file, $encoding)
 {
     if (isset(self::$loadedEngines[$file])) {
         return self::$loadedEngines[$file];
     }
     if (!is_readable($file)) {
         throw InvalidResourceException::fileDosntExistException($file);
     }
     try {
         $pdf = PdfDocument::load($file);
         $engine = new self($pdf, $this->unitConverter);
         foreach ($pdf->pages as $page) {
             $gc = new GraphicsContext($engine, $page, $encoding);
             $engine->attachGraphicsContext($gc);
         }
         self::$loadedEngines[$file] = $engine;
         return $engine;
     } catch (\ZendPdf\Exception $e) {
         throw InvalidResourceException::invalidPdfFileException($file, $e);
     }
 }