简体   繁体   中英

How to know where is Libreoffice installed in a Docker image?

I am trying to convert a docx document to PDF by using libreoffice as follows:

from subprocess import  Popen
LIBRE_OFFICE = r"C:\Program Files\LibreOffice\program\soffice.exe"

def convert_to_pdf(input_docx, out_folder):
    p = Popen([LIBRE_OFFICE, '--headless', '--convert-to', 'pdf', '--outdir',
               out_folder, input_docx])
    print([LIBRE_OFFICE, '--convert-to', 'pdf', input_docx])
    p.communicate()


sample_doc = 'file.docx'
out_folder = 'some_folder'
convert_to_pdf(sample_doc, out_folder)

However, I am working on a Linux Docker image. So I don't need what route should I specify in the LIBRE_OFFICE variable. Does anybody knows it?

The command I am using in my Dockerfile to install libreoffice is RUN apt-get update && apt-get -y install libreoffice

On linux the which command will tell you where an executible is installed. For example on my system

$ which libreoffice 
/usr/bin/libreoffice

You can generally do this for every executable, and also to check IF an executable is installed. This approach will work even if the output of the which command is a symbolic link.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM