conv / README.md
ketannnn's picture
Fix Hugging Face port binding issues (default to 7860)
b27b096
|
Raw
History Blame Contribute Delete
3.45 kB
metadata
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

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:

docker-compose up --build -d

Accessing the Web Page

Once the container starts, open your web browser and navigate to: http://localhost:5000

Stopping the Service

docker-compose down

2. Using Docker CLI Directly

If you prefer using standard Docker commands instead of Docker Compose:

Build the Docker Image

docker build -t doc-to-pdf-converter .

Run the Web Server

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

docker run --rm -v "<local_dir_path>:/data" doc-to-pdf-converter python /app/converter.py /data/<input_filename> /data

Examples

  • PowerShell (Windows):
    docker run --rm -v "${PWD}:/data" doc-to-pdf-converter python /app/converter.py /data/report.docx /data
    
  • CMD (Windows):
    docker run --rm -v "%cd%:/data" doc-to-pdf-converter python /app/converter.py /data/report.docx /data
    
  • Bash (Linux / macOS):
    docker run --rm -v "$(pwd):/data" doc-to-pdf-converter python /app/converter.py /data/report.docx /data