Example #1
0
 def readFromStream(stream, pdf):
     debug = False
     if debug: print((stream.tell()))
     name = stream.read(1)
     if name != NameObject.surfix:
         raise utils.PdfReadError("name read error")
     name += utils.readUntilRegex(stream, NameObject.delimiterPattern, 
         ignore_eof=True)
     if debug: print(name)
     try:
         return NameObject(name.decode('utf-8'))
     except (UnicodeEncodeError, UnicodeDecodeError) as e:
         # Name objects should represent irregular characters
         # with a '#' followed by the symbol's hex number
         if not pdf.strict:
             warnings.warn("Illegal character in Name Object", utils.PdfReadWarning)
             return NameObject(name)
         else:
             raise utils.PdfReadError("Illegal character in Name Object")
Example #2
0
 def readFromStream(stream, pdf):
     debug = False
     if debug: print((stream.tell()))
     name = stream.read(1)
     if name != NameObject.surfix:
         raise utils.PdfReadError("name read error")
     name += utils.readUntilRegex(stream,
                                  NameObject.delimiterPattern,
                                  ignore_eof=True)
     if debug: print(name)
     try:
         return NameObject(name.decode('utf-8'))
     except (UnicodeEncodeError, UnicodeDecodeError) as e:
         # Name objects should represent irregular characters
         # with a '#' followed by the symbol's hex number
         if not pdf.strict:
             warnings.warn("Illegal character in Name Object",
                           utils.PdfReadWarning)
             return NameObject(name)
         else:
             raise utils.PdfReadError("Illegal character in Name Object")
Example #3
0
 def readFromStream(stream):
     num = utils.readUntilRegex(stream, NumberObject.NumberPattern)
     if num.find(NumberObject.ByteDot) != -1:
         return FloatObject(num)
     else:
         return NumberObject(num)
Example #4
0
 def readFromStream(stream):
     num = utils.readUntilRegex(stream, NumberObject.NumberPattern)
     if num.find(NumberObject.ByteDot) != -1:
         return FloatObject(num)
     else:
         return NumberObject(num)