This is a file conversion backend built with Node.js that allows users to convert files like .docx, .txt, .pptx, etc., into PDF format using LibreOffice via the libreoffice-convert Node.js library. It supports multiple file uploads, uses Multer for handling file uploads, and Docker to ensure consistent LibreOffice availability across environments.
- β Convert files to PDF (e.g. DOCX β PDF, TXT β PDF, PPTX β PDF)
- β Multiple file upload support
- β Uses LibreOffice for high-quality conversion
- β Optional Docker setup for consistent environment
- β EJS web interface for quick browser testing
- β Organized code structure and response format
- Node.js
- Express.js
- Multer (File Upload Middleware)
- LibreOffice (via
libreoffice-convert) - Docker (optional)
- EJS (for testing via browser)
pdf-converter/
βββ upload/ # Uploaded input files
βββ download/ # Converted output PDFs
βββ components/
β βββ fileConverter.js # Conversion logic using libreoffice-convert
βββ views/
β βββ homepage.ejs # Web form to test file upload and conversion
βββ app.js # Main Express server
βββ Dockerfile # Docker config for LibreOffice
βββ README.md
The following MIME types and extensions can be accepted and converted to PDF:
<input type="file" name="files" accept=".doc,.docx,.xls,.xlsx,.ppt,.pptx,.odt,.ods,.odp,.txt,.rtf,.html,.csv" multiple /> Supported extensions: .doc, .docx .xls, .xlsx .ppt, .pptx .odt, .ods, .odp .txt, .rtf, .csv .html, .htm βοΈ Setup Instructions 1. Clone the Repository git clone https://github.com/CoderAyushman/pdf-converter.git cd pdf-converter 2. Install Dependencies npm install π³ Docker Setup To ensure LibreOffice works in all environments, use Docker: 1. Build Docker Image docker build -t pdf-converter . 2. Run Docker Container docker run -p 4000:4000 pdf-converter LibreOffice is installed inside the Docker container, so you donβt need to install it manually. π Web Interface (EJS) A simple HTML frontend is available: http://localhost:4000