This is a Flask app that takes uploaded .doc, .docx, .odt, and .pdf files, converts them to .pdf, allows the user to arrange and rename them, optionally include page numbers and a table of contents (including embedded PDF bookmarks) and then merges them into one big file.
Go to https://spiffindustries.com/pdfpublisher/ to try it!
This app was inspired by my father, who was occasionally asking me to take stories that he had written using Microsoft Word and render a full-length .pdf file to submit to Staples for publishing as a hard-cover book. This is an effort to allow him to do it himself without waiting for me to finish. This turned out to be quite challenging due to the proprietary nature of the .docx file format.
sudo apt-get update
sudo apt-get install -y libreoffice libreoffice-java-common
sudo apt-get install -y python3 python3-pip
git clone https://github.com/rbrutherford3/PDF-Publisher.git
cd PDF-Publisher
sudo pip3 install -r requirements.txt
export RECAPTCHA_SITE_KEY="your-site-key"
export RECAPTCHA_SECRET_KEY="your-secret-key"
export CLOUDCONVERT_LIVE_API_KEY="your-live-cloudconvert-api-key"
export CLOUDCONVERT_SANDBOX_API_KEY="your-sandbox-cloudconvert-api-key"
Optional: opt back into the sandbox environment if needed:
export CLOUDCONVERT_SANDBOX=true
If you are deploying to Vercel, set the same values in your Vercel project environment variables so the app can access them at runtime.
export FLASK_DEBUG=0
export FLASK_ENV=development
python3 -m flask run
You should see something like the following:
* Environment: development
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
This means you can now go to localhost:5000 or 127.0.0.1:5000 in your browser to use the program.
This project is also compatible with Vercel, and the same requirements file is used for its Python dependencies.
You can also use Gunicorn to set up this project for production, but that is outside the scope of this document.
For manual CloudConvert testing, open /cloudconvert/test, provide an API key if one is not already configured in the environment, upload a .doc, .docx, or .odt file, and the app will return the converted PDF.
Please contact rbrutherford3 on GitHub if interested in contributing.
Thanks to Dad for providing the inspiration for this program, and for putting up with me over the years.