Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem in NameObject.readFromStream when stream.read(1) does not advance #6

Open
ccurvey opened this issue Sep 17, 2010 · 1 comment

Comments

@ccurvey
Copy link

ccurvey commented Sep 17, 2010

I'm in way over my head here...kind of feel like the blind pig that found an acorn. Anyway, I'm trying to process a PDF that contains the following items:

10 0 obj
/DeviceGray
endobj

The problem is that when the line "/DeviceGray" is read, tok = stream.read(1) does not seem to advance the file pointer. (I checked by looking at the value of stream.tell() before and after the stream.read())

I don't know why the pointer does not get advanced, but making the code look like this fixes the problem, and things seem to move along just fine.

    while True:
        pre_read = stream.tell() # new
        tok = stream.read(1)
        if tok.isspace() or tok in NameObject.delimiterCharacters or stream.tell() == pre_read:
            stream.seek(-1, 1)
            break
        name += tok
    return NameObject(name)

I can provide a copy of the PDF to someone if they want an example. (Note to self: this is 98421_SupLegal 2008-02 Stmt_p83_r8.pdf)

@ccurvey
Copy link
Author

ccurvey commented Sep 17, 2010

woops...I just noticed that in the regular post, the PDF formatting got messed up. The "endobj" is on the next line from "/DeviceGray" (at least in vim with the PDF plugin). That might explain the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant