Bug 107151 - Running oowriter with --headless complains about the DISPLAY variable
Summary: Running oowriter with --headless complains about the DISPLAY variable
Status: RESOLVED NOTOURBUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.3.7.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-13 20:54 UTC by Robert Heller
Modified: 2017-04-23 15:36 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Simple script to convert a docx file to a pdf. (96 bytes, application/x-shellscript)
2017-04-13 20:54 UTC, Robert Heller
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Heller 2017-04-13 20:54:49 UTC
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)
Comment 1 Xisco Faulí 2017-04-17 10:50:52 UTC
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
Comment 2 Robert Heller 2017-04-17 12:17:12 UTC
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.
Comment 3 Robert Heller 2017-04-23 15:36:39 UTC
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:

"       --headless
              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?