Created attachment 132548 [details]
Simple script to convert a docx file to a pdf.
I have written a simple BASH script to convert docx files to PDFs, but it fails when the DISPLAY variable is not set. I want to be able to run this script in contexts where there isn't a display (like in batch or cron jobs).
The error message is:
/usr/lib64/libreoffice/program/soffice.bin X11 error: Can't open display:
Set DISPLAY environment variable, use -display option
or check permissions of your X-Server
(See "man X" resp. "man xhost" for details)
I think you will need to use xvfb to simulate a display at least -> https://en.wikipedia.org/wiki/Xvfb
LibreOffice needs DISPLAY to be set in order to be launched.
Closing as RESOLVED NOTOURBUG
OK, I'd like to make a comment and suggest a feature request.
First, could the documentation for --headless note that the DISPLAY variable (and thus some sort of X Display) is still needed, even when the --headless option is specified. As it is now (as I read it), it is implied that --headless means that things can be done without an X display -- this appearently is not true.
Secondly, I'd like to see a purely CLI tool for converting word processing documents (eg .doc, .docx, .rtf, etc.) to PDF. A tool that does not need a running X display (not even a dummy one). Something that could be run on a headless server or VM to batch convert documents.
If libreoffice still needs a "head" (eg some sort of X-Display) when using the --headless option, then what exactly is the point of the --headless option? How does it meaningfully differ from --nologo and/or --nosplash or --invisible?
The *documentation* (from the man page on my CentOS 6 box) says:
Starts in "headless mode", which allows using the application
without user a interface.
This special mode can be used when the application is controlled
by external clients via the API.
It implies --invisible and strictly ignores any GUI environment.
--quickstart does not work with this parameter.
It states that --headless "strictly ignores any GUI environment". Since libreoffice crashes when there is no GUI environment (eg DISPLAY is not set), it obviously is not "strictly ignoring" the GUI environment, since it complains where there isn't one. Either the documentation is wrong (or needs clarification) or the the program is broken (eg this is a real live bug, if only a documentation bug).
Can someone answer this question?