Skip to content

About

Self-hosted REST API for privacy-focused, programmatic conversion of Microsoft Word (.DOC/.DOCX) documents to PDF

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Repository files navigation




Self-hosted REST API for privacy-focused, programmatic conversion of Microsoft Word (.DOC/.DOCX) documents to PDF


Quickstart

Prerequisites

  1. Ensure you have the latest stable version of Docker Compose installed on your machine:
docker compose version

Start the server

Note: The initial build may take a while as LibreOffice is a large dependency. Subsequent builds and container starts will be near-instant due to Docker's layer caching.

docker compose up

Check if the application is working

Via automated tests

  1. Install the test dependencies inside the running container:
docker exec -it flask_api poetry install --with test
  1. Run the test suite:
docker exec -it flask_api poetry run pytest -rfsxE --capture=no --log-cli-level=DEBUG --maxfail=1 ./test

Via Web UI

  1. Navigate to http://localhost:5000/doc_to_pdf.
  2. Select a local DOC or DOCX file (e.g. dummy_doc.docx).
  3. Click the Upload button.
  4. Check that the resulting PDF either appears directly in the browser or starts downloading automatically.

Dev mode

Prerequisites

  1. Complete the Quickstart and ensure the server is already up and running.

Note: Since Flask is running in debug mode, the server will automatically reload whenever changes are saved to server.py.

  1. Ensure you have the latest stable version of Python installed:
python --version

Local Environment Setup

  1. Create a Virtual Enviroment:
python -m venv .venv
  1. Activate the Virtual Enviroment:
activate_venv() {
    if [[ $(uname) == "Darwin" ]]; then
        source .venv/bin/activate
    elif [[ $(uname) == "Linux" ]]; then
        source .venv/bin/activate
    elif [[ $(uname) == CYGWIN* || $(uname) == MINGW* ]]; then
        source .venv/Scripts/activate
    else
        echo "Unsupported operating system"
    fi
}

activate_venv
  1. Ensure the Virtual Enviroment is active:
PYTHON_PATH=$(which python)
if [[ "$PYTHON_PATH" == *".venv"* ]]; then
  echo "Python is using a .venv environment: $PYTHON_PATH"
else
  echo "Python is NOT using a .venv environment: $PYTHON_PATH"
fi
  1. Install the Poetry package manager:
pip install poetry
  1. Install the project dependencies from all dependency groups:
poetry install --with test,format
  1. The test and task commands will now run without the docker exec -it flask_api prefix.

Useful commands

Code Formatting

  1. Install the required dependencies inside the running container:
docker exec -it flask_api poetry install --with format
  1. Run the formatting task:
docker exec -it flask_api poetry run python ./tasks/format.py

About

Self-hosted REST API for privacy-focused, programmatic conversion of Microsoft Word (.DOC/.DOCX) documents to PDF

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages