Looking for all pages with for loop #381
-
I unable to print all pages with for loop
this code only return first page |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @erkin98 , could you confirm that the PDF indeed has more than 1 page and there is no break condition in the code that you may have missed out on adding here? Running import pdfplumber
tb = []
with pdfplumber.open(path) as pdf:
for i in range(len(pdf.pages)):
print(pdf.pages[i].extract_text()) works fine for me. Also, instead of doing for page in pdf.pages:
print(page.extract_text()) since If the PDF indeed has more than 1 page, request you to share the PDF and the output you are getting so that I can investigate this further. |
Beta Was this translation helpful? Give feedback.
Hi @erkin98 , could you confirm that the PDF indeed has more than 1 page and there is no break condition in the code that you may have missed out on adding here?
Running
works fine for me. Also, instead of doing
for i in range
, you can also dosince
pdf.pages
is an iterable and to get the iteration number, you can leverage usingpage.page_number
(it will be 1-based and not 0-based).If the PDF indeed has more than 1 page, request you to share the PDF and the output you are getting so that I can in…