/** * Build details array. */ protected function buildDetails() { // Build details array. $details = array(); // Extract document info if ($this->trailer->has('Info')) { /** @var Object $info */ $info = $this->trailer->get('Info'); $details = $info->getHeader()->getDetails(); } // Retrieve the page count try { $pages = $this->getPages(); $details['Pages'] = count($pages); } catch (\Exception $e) { $details['Pages'] = 0; } $this->details = $details; }
/** * @param $document Document * @param $header Header * @param $content string * * @return Object */ public static function factory(Document $document, Header $header, $content) { switch ($header->get('Type')->getContent()) { case 'XObject': switch ($header->get('Subtype')->getContent()) { case 'Image': return new Image($document, $header, $content); case 'Form': return new Form($document, $header, $content); default: return new Object($document, $header, $content); } break; case 'Pages': return new Pages($document, $header, $content); case 'Page': return new Page($document, $header, $content); case 'Encoding': return new Encoding($document, $header, $content); case 'Font': $subtype = $header->get('Subtype')->getContent(); $classname = '\\Smalot\\PdfParser\\Font\\Font' . $subtype; if (class_exists($classname)) { return new $classname($document, $header, $content); } else { return new Font($document, $header, $content); } default: return new Object($document, $header, $content); } }