This demo showcases how to use Trigger.dev with Python to extract structured form data from a PDF file available at a URL.
- A Trigger.dev task to trigger the Python script
- Trigger.dev Python build extension to install the dependencies and run the Python script
- PyMuPDF to extract form data from PDF files
- Requests to download PDF files from URLs
- After cloning the repo, run
npm install
to install the dependencies. - Create a virtual environment
python -m venv venv
- Activate the virtual environment, depending on your OS: On Mac/Linux:
source venv/bin/activate
, on Windows:venv\Scripts\activate
- Install the Python dependencies
pip install -r requirements.txt
- Copy the project ref from your Trigger.dev dashboard and add it to the
trigger.config.ts
file. - Run the Trigger.dev CLI dev command (it may ask you to authorize the CLI if you haven't already).
- Test the task in the dashboard by providing a valid PDF URL.
- Deploy the task to production using the Trigger.dev CLI deploy command.
- pythonPdfTask.ts triggers the Python script and returns the structured form data as JSON
- trigger.config.ts uses the Trigger.dev Python extension to install the dependencies and run the script
- extract-pdf-form.py is the main Python script that takes a URL and returns the form data from the PDF in JSON format