Python Forum

Full Version: PDFplumber
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,

A beginner question: I have managed to open an unstructured pdf with pdfplumber, but I have only been able to print one page at at a time. I would like to print more than one page at a time or all pages if possible and inspect them in the Python console. Is this possible? Thanks!

with pdfplumber.open (r'C:\Users\Me\file.pdf') as pdf:
    page = pdf.pages[0] #How can I print more than one page at a time?
    text = page.extract_text()
    print(page.extract_text())
(Nov-03-2020, 09:24 AM)pprod Wrote: [ -> ]Hello everyone,

A beginner question: I have managed to open an unstructured pdf with pdfplumber, but I have only been able to print one page at at a time. I would like to print more than one page at a time or all pages if possible and inspect them in the Python console. Is this possible? Thanks!

with pdfplumber.open (r'C:\Users\Me\file.pdf') as pdf:
    page = pdf.pages[0] #How can I print more than one page at a time?
    text = page.extract_text()
    print(page.extract_text())

This should do the trick
with pdfplumber.open (r'C:\Users\Me\file.pdf') as pdf:
    for page in pdf.pages:
        print(page.extract_text())
        print()
(Nov-03-2020, 03:59 PM)Atekka Wrote: [ -> ]
(Nov-03-2020, 09:24 AM)pprod Wrote: [ -> ]Hello everyone,

A beginner question: I have managed to open an unstructured pdf with pdfplumber, but I have only been able to print one page at at a time. I would like to print more than one page at a time or all pages if possible and inspect them in the Python console. Is this possible? Thanks!

with pdfplumber.open (r'C:\Users\Me\file.pdf') as pdf:
    page = pdf.pages[0] #How can I print more than one page at a time?
    text = page.extract_text()
    print(page.extract_text())

This should do the trick
with pdfplumber.open (r'C:\Users\Me\file.pdf') as pdf:
    for page in pdf.pages:
        print(page.extract_text())
        print()

Thanks a lot. It worked!