/** * Map the objects * * @return void */ protected function mapObjects() { foreach ($this->objectStreams as $stream) { switch ($this->getStreamType($stream)) { case 'root': $root = Object\RootObject::parse($stream); $root->setImported(true); $root->setVersion(substr($this->data, 5, 3)); $this->objectMap['root'] = ['stream' => $stream, 'object' => $root, 'index' => $root->getIndex(), 'parent' => $root->getParentIndex()]; break; case 'parent': $parent = Object\ParentObject::parse($stream); $parent->setImported(true); $this->objectMap['parent'] = ['stream' => $stream, 'object' => $parent, 'index' => $parent->getIndex(), 'count' => $parent->getCount(), 'kids' => $parent->getKids()]; break; case 'info': $info = Object\InfoObject::parse($stream); $info->setImported(true); $this->objectMap['info'] = ['stream' => $stream, 'object' => $info, 'index' => $info->getIndex()]; break; case 'page': if (!isset($this->objectMap['pages'])) { $this->objectMap['pages'] = []; } $page = Object\PageObject::parse($stream); $page->setImported(true); $this->objectMap['pages'][$page->getIndex()] = ['stream' => $stream, 'object' => $page, 'index' => $page->getIndex(), 'parent' => $page->getParentIndex(), 'width' => $page->getWidth(), 'height' => $page->getHeight(), 'content' => $page->getContent(), 'annots' => $page->getAnnots(), 'fonts' => $page->getFonts(), 'xObjects' => $page->getXObjects()]; break; case 'stream': if (!isset($this->objectMap['streams'])) { $this->objectMap['streams'] = []; } $stream = Object\StreamObject::parse($stream); $stream->setImported(true); $this->objectMap['streams'][$stream->getIndex()] = ['stream' => $stream, 'object' => $stream, 'index' => $stream->getIndex()]; break; } } }
/** * Set the parent object * * @param Object\ParentObject $parent * @return Compiler */ protected function setParent(Object\ParentObject $parent) { $this->parent = $parent; $this->objects[$this->parent->getIndex()] = $this->parent; return $this; }