Sign inSign up

vnvsa/docx-pdf-converter

By vnvsa

•Updated 4 days ago

Docker container allowing you to convert docx files to pdf.

Image
0

3.2K

vnvsa/docx-pdf-converter repository overview

⁠Docx PDF Converter

This project contains Docx PDF Converter's code.

This web service allows you to send a docx file and get it in PDF.

⁠Requirements

You need the following softwares installed on your operating system:

  • Python 3.7 with poetry
  • Libreoffice

⁠Installation

⁠Poetry

In order to install poetry and make it available for all users, do the following:

  1. $ sudo mkdir /opt/poetry
  2. $ sudo chown $USER:odoo /opt/poetry
  3. $ chmod g+w /opt/poetry
  4. $ curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python3 -
  5. Make it available in everyone's path
  6. sudo vim /etc/profile.d/poetry.sh
  7. Paste export PATH="/opt/poetry/bin:$PATH", save & exit ([ESC] + :wq)
  8. Logout from ssh and login again

To install the project, do the following:

  1. git clone this repository
  2. run poetry install
  3. configure your WSGI in a Linux service to run the app (for example with gunicorn: gunicorn docx_web_service.app:app)

⁠Client-Side Usage

The route to convert a .docx document to .pdf document is /convert.

The application expects a multipart-data form in the request. If you are using curl you can convert a document by running curl --insecure -X POST http://<docx-converter-host-ip>:8000/convert -F "file=@tests/fixtures/test.docx" --output output.pdf.

The Content-Type of the response is application/pdf so the service's response is a binary response.

⁠Running tests

To run the tests, simply run make test.

To lint the files, run make lint.

To formate the code, run make fix.

⁠Using with docker

Docker container allowing you to convert docx files to pdf.

⁠Use the container

Here is an example of docker-compose.yml.

version: '3.9'
services:

  converter:
    image: vnvsa/docx-pdf-converter:latest
    ports:
      - '8000:8000'

you can then convert files using curl:

curl --request POST \
  --url http://localhost:8000/convert \
  --header 'content-type: multipart/form-data' \
  --form 'file=@full_path_to_file\test.docx'

⁠Contributing

Pull requests, bug reports, and feature requests are welcome.

⁠Note

If you want to use this with Eole :

  • Add the container in your docker-compose.yml file
  • In eole, go to Configuration -> Technical -> System Parameters in debug mode, and set modify the parameter vnv.odt.template.config.pdf.server.url. Set the value http://host.docker.internal:8000 or http://<container_name>:8000 for the parameter. For example : http://odoo-stack-docx_pdf_converter-1:8000 in the second case.

⁠Contacts

⁠License

MIT License. See the LICENSE file.

Tag summary

Content type

Image

Digest

sha256:75ad29407…

Size

695.9 MB

Last updated

4 days ago

docker pull vnvsa/docx-pdf-converter