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); } }
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); } }