@@ -0,0 +1,2 @@
+FROM python:3.8.0a3-alpine
+RUN apk add libreoffice
@@ -0,0 +1,9 @@
+version: '3'
+services:
+ doc2pdf:
+ container_name: doc2pdf
+ build: .
+ working_dir: /usr/src/app
+ command: python main.py
+ volumes:
+ - ./src:/usr/src/app
@@ -0,0 +1,16 @@
+from subprocess import Popen, PIPE
+import glob
+
+files = []
+types = ['doc', 'docx', 'pptx', 'ppt']
+for type in types:
+ files.extend(glob.glob('./input/*.' + type))
+for file in files:
+ p = Popen(['soffice', '--headless', '--convert-to', 'pdf', file, '--outdir', './output'], stdout=PIPE, stderr=PIPE)
+ output, error = p.communicate()
+ if p.returncode != 0:
+ print("Couldn't convert to following file: %d %s %s" % (file, output, error))
+print("Finished converting! Exiting process.")