LibreOffice Command Line Conversion - No Output Fi

2020-04-21 01:21发布

问题:

I am using LibreOffice installed on my Linux box and I seem to be having a weird problem in that the conversion seems to be taking place, and there seem to be no errors, but there is no output file in the specified output directory.

Here is an example of the command I am using:

/opt/libreoffice3.6/program/soffice --headless --invisible --convert-to pdf /dir/file.pptx --outdir /dir

And here is the result of that command:

convert /dir/file.pptx -> /dir/file.pdf using impress_pdf_Export

But the problem is that after running the conversion /dir/file.pdf does not exist.

Do any of you have any suggestions?

回答1:

I cant reproduce your error. It works for me, even with pptx files.

Check the bug-tracker of libreoffice. Try another version (I am still running 3.4.something). Investigate the output directory - e.g. do you have write privileges there?

And a rather stupid idea: Hit F5 (or similar) in your file browser (mine is Dolphin) in order to refresh. I needed to do this in this case, so I could see the new file.



回答2:

If you see no output then the problem may be related to this bug. Just make sure that there is no other instance of libre office running (soffice.bin). Source.



回答3:

I had a similar problem where soffice seemed to run fine (headless mode on server) but there were no output files.

Fixed it by running apt-get install libreoffice-writer



回答4:

Go to the folder your file is in & convert it to that location to see if your conversion works. If it works, try to put "" around your file to convert.

I have a bashscript that you can maybe use for your problem:

#!/bin/bash

# first do chmod +x convert.sh
# then run ./convert.sh

mkdir out
cd testfiles
for file in *; do
    echo "${file}"
    soffice --headless -convert-to pdf:"writer_pdf_Export"      
        --outdir ../Documenten/BLACK/out "${file}" 
done
cd ..