Example #1
0
 /**
  * Read binary string PDF object
  * Also reads trailing '>' from a pdf stream
  *
  * @return Zend_Pdf_Element_String_Binary
  * @throws Zend_Pdf_Exception
  */
 private function _readBinaryString()
 {
     $start = $this->offset;
     while ($this->offset < strlen($this->data)) {
         if (self::isWhiteSpace(ord($this->data[$this->offset])) || ctype_xdigit($this->data[$this->offset])) {
             $this->offset++;
         } else {
             if ($this->data[$this->offset] == '>') {
                 $this->offset++;
                 return new Zend_Pdf_Element_String_Binary(Zend_Pdf_Element_String_Binary::unescape(substr($this->data, $start, $this->offset - $start - 1)));
             } else {
                 throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Unexpected character while binary string reading. Offset - 0x%X.', $this->offset));
             }
         }
     }
     throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Unexpected end of file while binary string reading. Offset - 0x%X. \'>\' expected.', $start));
 }
Example #2
0
 /**
  * Read binary string PDF object
  * Also reads trailing '>' from a pdf stream
  *
  * @return Zend_Pdf_Element_String_Binary
  * @throws Zend_Pdf_Exception
  */
 private function _readBinaryString()
 {
     $start = $this->offset;
     $this->offset += strspn($this->data, "\t\n\f\r 0123456789abcdefABCDEF", $this->offset);
     if ($this->offset >= strlen($this->data) - 1) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Unexpected end of file while reading binary string. Offset - 0x%X. \'>\' expected.', $start));
     }
     if ($this->data[$this->offset++] != '>') {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Unexpected character while binary string reading. Offset - 0x%X.', $this->offset));
     }
     return new Zend_Pdf_Element_String_Binary(Zend_Pdf_Element_String_Binary::unescape(substr($this->data, $start, $this->offset - $start - 1)));
 }
Example #3
0
 public function testUnescape2()
 {
     $this->assertEquals(Zend_Pdf_Element_String_Binary::unescape('01020304FF2'), "ΓΏ ");
 }