| --- |
| title: Conv |
| emoji: π |
| colorFrom: green |
| colorTo: green |
| sdk: docker |
| pinned: false |
| short_description: ALL to pdf converter |
| app_port: 7860 |
| --- |
| |
| # Docker-based Document to PDF Converter & Web Service |
|
|
| A robust, Docker-based Python service that converts `.doc`, `.docx`, `.ppt`, `.pptx`, `.xls`, and `.xlsx` files to PDF. It supports both a **modern, drag-and-drop web UI** (with batch ZIP downloads) and a **command-line script** for local automation. |
|
|
| It uses **LibreOffice headless mode** for high-fidelity conversion, preserving original fonts, layouts, images, and alignments. |
|
|
|
|
| --- |
|
|
| ## Features |
| - **Sleek Web UI**: A beautiful, premium dark-themed web page featuring glassmorphism design and responsive drag-and-drop file inputs. |
| - **Multiple File Upload**: Upload and convert multiple files in a single batch. |
| - **On-the-Fly ZIP Download**: Compiles all converted PDFs into a single, non-nested ZIP file download. |
| - **Zero-Footprint Storage**: Converts files in a containerized temporary directory, which is automatically and immediately deleted once the conversion and download are completed. |
| - **Microsoft Core Fonts**: Pre-accepts and installs Microsoft Core Fonts (`msttcorefonts`) alongside other metric-compatible fallback fonts to maintain accurate layout proportions. |
| - **Dual Support**: Operates as a Flask web service or as a one-off CLI tool. |
| - **Docker Compose Integration**: Easily orchestrate the service with single command setup. |
|
|
| --- |
|
|
| ## File Structure |
|
|
| ```text |
| conv/ |
| βββ Dockerfile # Installs dependencies, fonts, Flask, and setups entrypoint |
| βββ docker-compose.yml # Compose file mapping port 5000 and service build |
| βββ app.py # Flask server handling route routing, conversion and ZIP generation |
| βββ converter.py # CLI converter script (one-off single file conversions) |
| βββ templates/ |
| β βββ index.html # Responsive drag-and-drop HTML, CSS, and JS web interface |
| βββ README.md # Documentation |
| ``` |
|
|
| --- |
|
|
| ## 1. Using Docker Compose (Recommended) |
|
|
| To build and run the web application in background (headless) mode: |
|
|
| ```bash |
| docker-compose up --build -d |
| ``` |
|
|
| ### Accessing the Web Page |
| Once the container starts, open your web browser and navigate to: |
| **[http://localhost:5000](http://localhost:5000)** |
|
|
| ### Stopping the Service |
| ```bash |
| docker-compose down |
| ``` |
|
|
| --- |
|
|
| ## 2. Using Docker CLI Directly |
|
|
| If you prefer using standard Docker commands instead of Docker Compose: |
|
|
| ### Build the Docker Image |
| ```bash |
| docker build -t doc-to-pdf-converter . |
| ``` |
|
|
| ### Run the Web Server |
| ```bash |
| docker run --rm -p 5000:7860 doc-to-pdf-converter |
| ``` |
|
|
| --- |
|
|
| ## 3. Using the CLI Script (Alternative) |
|
|
| If you wish to use the one-off CLI converter script instead of the web server, override the default command and mount the target document folder: |
|
|
| ### Syntax |
| ```bash |
| docker run --rm -v "<local_dir_path>:/data" doc-to-pdf-converter python /app/converter.py /data/<input_filename> /data |
| ``` |
|
|
| ### Examples |
| - **PowerShell (Windows)**: |
| ```powershell |
| docker run --rm -v "${PWD}:/data" doc-to-pdf-converter python /app/converter.py /data/report.docx /data |
| ``` |
| - **CMD (Windows)**: |
| ```cmd |
| docker run --rm -v "%cd%:/data" doc-to-pdf-converter python /app/converter.py /data/report.docx /data |
| ``` |
| - **Bash (Linux / macOS)**: |
| ```bash |
| docker run --rm -v "$(pwd):/data" doc-to-pdf-converter python /app/converter.py /data/report.docx /data |
| ``` |
|
|