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

Provide support for iter(PDF) interface #13

Open
timClicks opened this issue Nov 24, 2014 · 1 comment
Open

Provide support for iter(PDF) interface #13

timClicks opened this issue Nov 24, 2014 · 1 comment

Comments

@timClicks
Copy link
Owner

We currently only send a whole PDF back as a list of strings. It would be nice to support something like:

with open('nice-info.pdf') as f:
    for page in slate.PDF(f):
        for line in page:
            ...

This would break backward compatibility though.. so perhaps this would be an okay compromise?

with open('nice-info.pdf') as f:
    for page in iter(slate.PDF(f)):
        for line in page:
        # page would now be a `Page` object that yields lines,
        # rather than a plain str
            ...
@cancan101
Copy link
Contributor

I am not sure there is a difference between those two forms.
Perhaps a better compromise would be to have:

with open('nice-info.pdf') as f:
    for page in slate.PDF(f).iter_pages():
        for line in page:

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

2 participants