Skip to content

Containerized REST API for converting Office files to PDF using LibreOffice

License

Notifications You must be signed in to change notification settings

codeinchq/office2pdf

Repository files navigation

Office2Pdf

Code Inc. Docker Image CI Docker Image Version

This repository contains a simple containerized API to convert Office documents to PDF documents using LibreOffice headless.

The image is available on Docker Hub under the name codeinchq/office2pdf.

Configuration

By default, the container listens on port 3000. The port is configurable using the PORT environment variable.

Usage

All requests must by send in POST to the /convert endpoint with a multipart/form-data content type. The request must contain an Office file with the key file.

The server returns 200 if the conversion was successful and the images are available in the response body. In case of error, the server returns a 400 status code with a JSON object containing the error message (format: {error: string}).

A PHP 8 client is available at on GitHub and Packagist.

Example

Step 1: run the container using Docker

docker run -p "3000:3000" codeinchq/office2pdf 

Step 2: convert an Office file to PDF

curl -X POST -F "file=@/path/to/file.docx" http://localhost:3000/convert -o example.pdf

Health check

A health check is available at the /health endpoint. The server returns a status code of 200 if the service is healthy, along with a JSON object:

{ "status": "up" }

Client

A PHP 8 client is available at on GitHub and Packagist.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Containerized REST API for converting Office files to PDF using LibreOffice

Resources

License

Stars

Watchers

Forks

Packages

No packages published