Hey 👋 thanks for this tool, I'm definitely going to use it for my presentations!
I propose a new feature for generating previews from PDF url links, since most of the time papers are opened in my navigator.
General Description
This pull request allows to generate previews from PDF url links. The interface now has two input fields: a PDF file uploader and a text input where users can copy paste the url link.
Type of change
New feature (non-breaking change which adds functionality)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
- [x] arXiv PDF links, other academic paper websites
- [x] Any pdf url link as long as the pdf file is in free access
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
Description
I added an utils.py
file which contains two functions:
download_file()
which downloads the pdf file from given url link, and stores it locally.
remove_file()
called at the end of the process, removing the pdf file temporarilly stored.
The streamlit app is modified accordingly. Note that if the two input fields (file upload, url) are filled, the priority is given to the file upload (which is the original feature of pdf2preview).
If the pdf file could not be downloaded from the url, an exception is raised.
Finally, I modified pdf2preview.py#L84: num_pages = file.pageCount
-> num_pages = file.page_count
according to the latest version of pymupdf (docs).
Screenshots: