Belval / pdf2image

A python module that wraps the pdftoppm utility to convert PDF to PIL Image object
MIT License
1.52k stars 187 forks source link

I want to add the progress bar using tqdm #197

Open Aditya-R-K opened 3 years ago

Aditya-R-K commented 3 years ago

Tell me which object of variable iterate in the module, so that I can apply "tqdm(iterable)" to display the progress bar in terminal tqdm has no dependencies & it is platform independent no matter which os you are using.

please let me know on which variable or object I apply this method so that I get progress bar in terminal. the iterable should be incrementing one by one when the image is exported

Aditya-R-K commented 3 years ago

I have added the tqdm to processes in for loop on line 200 but it the one processes not incrementing & it only goes to 100% when all the generation completed but I want the variable which changes after each image is generated

StaticRocket commented 3 years ago

Because this hands off the processing to pdftoppm/pdftocario, there isn't a main iterable tied to the pages as they are processed.

To do this you would either have to bypass the batching mechanism provided by the previously mentioned utilities, or capture and parse the output of pdftoppm with the -progress flag. In either case this likely wouldn't play well with the multithreading functions this library offers.

If you still want to take the performance hit for the progress bar I recommend setting up an iterable that steps through converting each page one by one by manually setting the first_page and last_page variables.