Exemplo n.º 1
0
    def readObjectHeader(self, stream):
        # Should never be necessary to read out whitespace, since the
        # cross-reference table should put us in the right spot to read the
        # object header.  In reality... some files have stupid cross reference
        # tables that are off by whitespace bytes.
        extra = False
        utils.skipOverComment(stream)

        extra |= utils.skipOverWhitespace(stream)
        stream.seek(-1, 1)

        idnum = readUntilWhitespace(stream)

        extra |= utils.skipOverWhitespace(stream)
        stream.seek(-1, 1)

        generation = readUntilWhitespace(stream)
        stream.read(3)
        readNonWhitespace(stream)
        stream.seek(-1, 1)
        if (extra and self.strict):
            #not a fatal error
            warnings.warn(
                "Superfluous whitespace found in "
                "object header %s %s" % (idnum, generation),
                utils.PdfReadWarning)
        return int(idnum), int(generation)
Exemplo n.º 2
0
 def readObjectHeader(self, stream):
     idnum = readUntilWhitespace(stream)
     generation = readUntilWhitespace(stream)
     obj = stream.read(3)
     readNonWhitespace(stream)
     stream.seek(-1, 1)
     return int(idnum), int(generation)
Exemplo n.º 3
0
 def readObjectHeader(self, stream):
     # Should never be necessary to read out whitespace, since the
     # cross-reference table should put us in the right spot to read the
     # object header.  In reality... some files have stupid cross reference
     # tables that are off by whitespace bytes.
     readNonWhitespace(stream); stream.seek(-1, 1)
     idnum = readUntilWhitespace(stream)
     generation = readUntilWhitespace(stream)
     obj = stream.read(3)
     readNonWhitespace(stream)
     stream.seek(-1, 1)
     return int(idnum), int(generation)
Exemplo n.º 4
0
 def __parseContentStream(self, stream):
     # file("f:\\tmp.txt", "w").write(stream.read())
     stream.seek(0, 0)
     operands = []
     while True:
         peek = readNonWhitespace(stream)
         if peek == "":
             break
         stream.seek(-1, 1)
         if peek.isalpha() or peek == "'" or peek == '"':
             operator = readUntilWhitespace(stream, maxchars=2)
             if operator == "BI":
                 # begin inline image - a completely different parsing
                 # mechanism is required, of course... thanks buddy...
                 assert operands == []
                 ii = self._readInlineImage(stream)
                 self.operations.append((ii, "INLINE IMAGE"))
             else:
                 self.operations.append((operands, operator))
                 operands = []
         else:
             operands.append(readObject(stream, None))
Exemplo n.º 5
-4
    def readObjectHeader(self, stream):
        # Should never be necessary to read out whitespace, since the
        # cross-reference table should put us in the right spot to read the
        # object header.  In reality... some files have stupid cross reference
        # tables that are off by whitespace bytes.
        extra = False
        utils.skipOverComment(stream)

        extra |= utils.skipOverWhitespace(stream)
        stream.seek(-1, 1)

        idnum = readUntilWhitespace(stream)

        extra |= utils.skipOverWhitespace(stream)
        stream.seek(-1, 1)

        generation = readUntilWhitespace(stream)
        stream.read(3)
        readNonWhitespace(stream)
        stream.seek(-1, 1)
        if (extra and self.strict):
            #not a fatal error
            warnings.warn("Superfluous whitespace found in "
                          "object header %s %s" % (idnum, generation),
                          utils.PdfReadWarning)
        return int(idnum), int(generation)