Exemplo n.º 1
0
 public function testUnescape()
 {
     $this->assertEquals(Zend_Pdf_Element_Name::unescape('My#20Cool#20Name#28#29'), 'My Cool Name()');
 }
Exemplo n.º 2
0
 /**
  * Read elemental object from a PDF stream
  *
  * @return Zend_Pdf_Element
  * @throws Zend_Pdf_Exception
  */
 public function readElement($nextLexeme = null)
 {
     if ($nextLexeme === null) {
         $nextLexeme = $this->readLexeme();
     }
     /**
      * Note: readElement() method is a public method and could be invoked from other classes.
      * If readElement() is used not by Zend_Pdf_StringParser::getObject() method, then we should not care
      * about _elements member management.
      */
     switch ($nextLexeme) {
         case '(':
             return $this->_elements[] = $this->_readString();
         case '<':
             return $this->_elements[] = $this->_readBinaryString();
         case '/':
             return $this->_elements[] = new Zend_Pdf_Element_Name(Zend_Pdf_Element_Name::unescape($this->readLexeme()));
         case '[':
             return $this->_elements[] = $this->_readArray();
         case '<<':
             return $this->_elements[] = $this->_readDictionary();
         case ')':
             // fall through to next case
         // fall through to next case
         case '>':
             // fall through to next case
         // fall through to next case
         case ']':
             // fall through to next case
         // fall through to next case
         case '>>':
             // fall through to next case
         // fall through to next case
         case '{':
             // fall through to next case
         // fall through to next case
         case '}':
             require_once 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X.', $this->offset));
         default:
             if (strcasecmp($nextLexeme, 'true') == 0) {
                 return $this->_elements[] = new Zend_Pdf_Element_Boolean(true);
             } else {
                 if (strcasecmp($nextLexeme, 'false') == 0) {
                     return $this->_elements[] = new Zend_Pdf_Element_Boolean(false);
                 } else {
                     if (strcasecmp($nextLexeme, 'null') == 0) {
                         return $this->_elements[] = new Zend_Pdf_Element_Null();
                     }
                 }
             }
             $ref = $this->_readReference($nextLexeme);
             if ($ref !== null) {
                 return $this->_elements[] = $ref;
             }
             return $this->_elements[] = $this->_readNumeric($nextLexeme);
     }
 }
Exemplo n.º 3
0
 /**
  * Read elemental object from a PDF stream
  *
  * @return Zend_Pdf_Element
  * @throws Zend_Pdf_Exception
  */
 private function _readElementalObject($nextLexeme = null)
 {
     if ($nextLexeme === null) {
         $nextLexeme = $this->_readLexeme();
     }
     switch ($nextLexeme) {
         case '(':
             return $this->_elements[] = $this->_readString();
         case '<':
             return $this->_elements[] = $this->_readBinaryString();
         case '/':
             return $this->_elements[] = new Zend_Pdf_Element_Name(Zend_Pdf_Element_Name::unescape($this->_readLexeme()));
         case '[':
             return $this->_elements[] = $this->_readArray();
         case '<<':
             return $this->_elements[] = $this->_readDictionary();
         case ')':
             // fall through to next case
         // fall through to next case
         case '>':
             // fall through to next case
         // fall through to next case
         case ']':
             // fall through to next case
         // fall through to next case
         case '>>':
             // fall through to next case
         // fall through to next case
         case '{':
             // fall through to next case
         // fall through to next case
         case '}':
             throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X.', $this->_current));
         default:
             if (strcasecmp($nextLexeme, 'true') == 0) {
                 return $this->_elements[] = new Zend_Pdf_Element_Boolean(true);
             } else {
                 if (strcasecmp($nextLexeme, 'false') == 0) {
                     return $this->_elements[] = new Zend_Pdf_Element_Boolean(false);
                 } else {
                     if (strcasecmp($nextLexeme, 'null') == 0) {
                         return $this->_elements[] = new Zend_Pdf_Element_Null();
                     }
                 }
             }
             $ref = $this->_readReference($nextLexeme);
             if ($ref !== null) {
                 return $this->_elements[] = $ref;
             }
             return $this->_elements[] = $this->_readNumeric($nextLexeme);
     }
 }