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())
Try with a loop.
with pdfplumber.open (r'C:\Users\Me\file.pdf') as pdf:
    for page_nr in rang(5):
        page = pdf.pages[page_nr] #How can I print more than one page at a time?
        text = page.extract_text()
        print(page.extract_text())
(Nov-03-2020, 05:10 PM)snippsat Wrote: [ -> ]Try with a loop.
with pdfplumber.open (r'C:\Users\Me\file.pdf') as pdf:
    for page_nr in rang(5):
        page = pdf.pages[page_nr] #How can I print more than one page at a time?
        text = page.extract_text()
        print(page.extract_text())

Thank you. It works! Much appreciated.