Skip to content

Successful implimentation of tqdm progress bar in pdfplumber. #541

Answered by samkit-jain
LeeSugden asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @LeeSugden Appreciate your interest in the library. I tried with a different approach and it works fine. Here it is

from tqdm import tqdm
import pdfplumber

def progress_bar_test():
	pdf = pdfplumber.open("file.pdf")
	pbar = tqdm(total=len(pdf.pages))

	for page in pdf.pages:
		text = page.extract_text()
		pbar.update(1)

	pbar.close()

if __name__ == "__main__":
	progress_bar_test()

The final output was

$ python main.py 
100%|█████████████████████████████████████████████| 8/8 [00:02<00:00,  3.49it/s]

It goes from 1 to the number of pages but you can easily configure it if you want to go from 10 to 100.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by samkit-jain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants