Template2PDF is a web app that converts an HTML template with custom variables into a PDF.
My motivation comes from having to customize a template I made for cover letters. Whenever I am changing certain fields/placeholders, I have the troubles of:
- forgetting to change the customized details (e.g. company name, position, address, etc.).
- taking a long time to find the parts that are customizable and making sure that I didn't miss any.
- accidentally removing or adding parts that are not meant to be customized.
Essentially, this web app:
- enables users to upload an HTML file (with customized variables that looks like:
{{ variable }}
), - scans the file for the variables and list them in a form,
- then users fill in the variables with actually content,
- converts these information into a PDF.
Upload Page (with a file uploaded)
Download Page + Form with Custom Variables in Input Fields
Frontend:
- React
- JavaScript
- HTML/CSS
- Material UI
- Axios
- React Router
Backend:
- Django
- Python
- Django Rest Framework
- Django CORS Headers
- xhtml2pdf
- SQLite (Built-in with Django)
-
Download the dependencies:
- Backend:
django django-rest-framework django-cors-headers xhtml2pdf
- Frontend:
Run the command
npm install
-
Open two terminals (one for backend and one for frontend)
-
There are some secret keys that you will have to create on your own:
- DJANGO_SECRET_KEY (use Django's built-in get_random_secret_key() to generate one)
- FE_DOMAIN (this is the url for your frontend server)
- VITE_API_BASE (this is the url for your backend server)
-
For frontend, run
cd frontend && npm start
-
For backend, run
cd backend && python manage.py runserver
-
Go to the url of the frontend server to see the app!