This is a Flask application that extracts and handles PDF and HTML attachments from uploaded PDF files. The application can identify and download PDF attachments, as well as decode HTML attachments.
- Upload PDF files
- Extract and download PDF attachments
- Decode and display HTML attachments
- Automatically delete temporary files after download
- Python 3.x
- Flask
- PyMuPDF (fitz)
- werkzeug
We recommend using uv for managing dependencies.
-
Clone the repository:
git clone https://github.com/struk77/pdf-html-extractor.git cd pdf-html-extractor -
Install the dependencies (this will also create a
.venvautomatically):uv sync
Alternative: using pip
-
Clone the repository:
git clone https://github.com/struk77/pdf-html-extractor.git cd pdf-html-extractor -
Create a virtual environment and activate it:
python3 -m venv .venv source .venv/bin/activate -
Install the required packages:
pip install -r requirements.txt
-
Run the Flask application:
uv run python app.py
(If you used
pip, activate your virtual environment and runpython app.pyinstead). -
Open your web browser and go to
http://127.0.0.1:5000. -
Upload a PDF file using the provided form.
-
The application will extract and handle the attachments:
- If the attachment is a PDF, it will be available for download.
- If the attachment is HTML, it will be displayed.
-
Install the Heroku CLI:
brew tap heroku/brew && brew install heroku -
Log in to your Heroku account:
heroku login
-
Create a new Heroku application:
heroku create your-app-name
-
Add a
Procfileto the root directory of your project with the following content:web: python app.py -
Commit your changes:
git add Procfile git commit -m "Add Procfile for Heroku deployment" -
Push your code to Heroku:
git push heroku main
-
Scale the web dyno:
heroku ps:scale web=1
-
Open your Heroku application in the browser:
heroku open
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any changes.