Она работает должным образом.
Код: Выделить всё
# docker run --rm -v .:/workspace shantanuo/libreoffice-converter /workspace/pm_in_paris.odt --outdir /workspace
Код: Выделить всё
# vi Dockerfile
FROM ubuntu:latest
RUN apt-get update && \
apt-get install -y libreoffice
WORKDIR /workspace
ENTRYPOINT ["libreoffice", "--headless", "--convert-to", "pdf"]
Код: Выделить всё
FROM ubuntu:latest
RUN apt-get update && apt-get install -y libreoffice python3 python3-venv
RUN python3 -m venv /workspace/venv
RUN /workspace/venv/bin/pip install --upgrade pip
RUN /workspace/venv/bin/pip install unotools
COPY * /workspace/
WORKDIR /workspace
CMD ["/workspace/venv/bin/python3", "/workspace/convert_to_pdf.py", "/workspace/paris.odt", "/workspace/template.ott", "/workspace/output.pdf"]
Код: Выделить всё
docker run -it shantanuo/libreoffice-converter2 bash
Код: Выделить всё
root@8a6d5682dcfa:/workspace# soffice --headless --accept="pipe,name=libreoffice;urp;StarOffice.ComponentContext" & python3 /workspace/convert_to_pdf.py /workspace/in_paris.odt /workspace/maaya.ott /workspace/
Код: Выделить всё
Traceback (most recent call last):
File "/workspace/convert_to_pdf.py", line 42, in
apply_template_and_convert_to_pdf(args.document, args.template, args.output)
File "/workspace/convert_to_pdf.py", line 22, in apply_template_and_convert_to_pdf
document.applyTemplate(template)
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: applyTemplate
Код: Выделить всё
cat convert_to_pdf.py
import uno
import argparse
def apply_template_and_convert_to_pdf(document_path, template_path, output_path):
# Create the LibreOffice UNO connection
local_context = uno.getComponentContext()
resolver = local_context.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local_context)
...
...
document.applyTemplate(template)
...
...
Подробнее здесь: https://stackoverflow.com/questions/790 ... dless-mode