Convert-to isn’t working in AstraLinux, Libreoffice 7.0

I have libreoffice LibreOffice 7.0.3.1 00(Build:1).

IF i run


libreoffice  --headless --invisible --convert-to pdf 5.txt --outdir 3.pdf

response


Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/libreoffice/program/platforms" ...
loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

But if i run from with sudo , the convert working!

Please help me, why didn’t convert from user ?

We don’t know your system details. But apparently your user session is in a graphical environment that Qt can’t satisfy. There may be hidden gems in this search "qt.qpa.xcb: could not connect to display" at DuckDuckGo . From a first glance it might be your user session is Xorg but Qt doesn’t support it with its installed platform plugins and would require X11 extras.

Apart from that, qt5 may indicate the KDE plugin is used, try forcing gtk3 instead:

SAL_USE_VCLPLUGIN=gtk3 libreoffice ...

or as it’s for headless anyway with gen instead of gtk3.

Btw, --outdir should be followed by a directory name, not a file name, and input file names should be specified last on the command line.

Note that --headless and --invisible are mutually exclusive options. The latter is intended for GUI usage, just having some special aspects, like having no initial GUI, and not closeable from GUI; while the former is for non-GUI operation (and so, it should not depend on Qt framework).

It might be that your use of both (when you really only needed --headless, or even didn’t need any - because --convert-to already implies --headless) is causing the problem; or it may be that there is a bug that headless mode still somehow depends on some VCL framework other than the headless one … which it shouldn’t.

Hopefully 3.pdf is a directory name - that is what is expected in the --outdir argument.

Note that that is an outdated, unsupported for quite some time already, version. Please try a later version, currently 7.2 or 7.3 - if there is a bug that I mentioned above, it might be fixed in a later version.

we can use to 7.0.

I try to

libreoffice --headless --convert-to pdf 1.txt --outdir /home/user/11.pdf
javaldx: Could not find a Java Runtime Environment!
Please ensure that a JVM and the package libreoffice-java-common
is installed.
If it is already installed then try removing ~/.config/libreoffice/4/user/config/javasettings_Linux_*.xml
Warning: failed to read path from javaldx
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

You could download and install a newer stable release (currently 7.2) from Download LibreOffice | LibreOffice - Free Office Suite - Based on OpenOffice - Compatible with Microsoft which installs to /opt/ not touching a distribution’s version.

If “we can use to 7.0” was meant as “we can only use 7.0” (and even only 7.0.3.1 and not the last 7.0.6.2 of the 7.0 releases) then you should get rid of the cause that hinders you to use anything newer with fixes.

1 Like

QT_QPA_PLATFORM=offscreen helped me:

QT_QPA_PLATFORM=offscreen soffice --headless --norestore --writer --convert-to pdf file.html

Found solution at stackoverflow