Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PDFplumber
#1
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())
Reply
#2
(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()
pprod likes this post
Reply
#3
(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!
Atekka likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Extracting Data into Columns using pdfplumber arvin 17 5,208 Dec-17-2022, 11:59 AM
Last Post: arvin
  pdfminer vs pdfplumber pprod 2 6,010 Jan-30-2021, 01:35 PM
Last Post: pprod
  PDFplumber pprod 2 4,889 Jan-26-2021, 06:12 PM
Last Post: pprod
  PDFplumber pprod 2 2,014 Nov-06-2020, 08:34 AM
Last Post: pprod

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020