Ejemplo n.º 1
0
 /**
  * Read dictionary PDF object
  * Also reads trailing '>>' from a pdf stream
  *
  * @return \ZendPdf\InternalType\DictionaryObject
  * @throws \ZendPdf\Exception\ExceptionInterface
  */
 private function _readDictionary()
 {
     $dictionary = new InternalType\DictionaryObject();
     while (strlen($nextLexeme = $this->readLexeme()) != 0) {
         if ($nextLexeme != '>>') {
             $nameStart = $this->offset - strlen($nextLexeme);
             $name = $this->readElement($nextLexeme);
             $value = $this->readElement();
             if (!$name instanceof InternalType\NameObject) {
                 throw new Exception\CorruptedPdfException(sprintf('PDF file syntax error. Name object expected while dictionary reading. Offset - 0x%X.', $nameStart));
             }
             $dictionary->add($name, $value);
         } else {
             return $dictionary;
         }
     }
     throw new Exception\CorruptedPdfException(sprintf('PDF file syntax error. Unexpected end of file while dictionary reading. Offset - 0x%X. \'>>\' expected.', $this->offset));
 }