Libreoffice error source file could not be loaded

Libreoffice returns zero status when it errors: awead@pooh T $ soffice --invisible --headless --convert-to doc --outdir /. non-existent-file.txt Error: source file could not be loaded awead@pooh T ...

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account


Open

awead opened this issue

Oct 13, 2016

· 2 comments


Open

libreoffice silently fails

#116

awead opened this issue

Oct 13, 2016

· 2 comments

Comments

@awead

Libreoffice returns zero status when it errors:

awead@pooh T $ soffice --invisible --headless --convert-to doc --outdir /. non-existent-file.txt
Error: source file could not be loaded
awead@pooh T $ echo $?
0

Output is directed to STDERR, so maybe we should parse that and raise something?

@rifuentesm

Hi, i have the same problem on Ubuntu Server 16.04 when trying to convert files, only the «file could not be loaded». I think its something that is not installed.
The problem was solved installing the complete libreoffice suite (sudo apt-get install libreoffice) not only the «commons» package (sudo apt-get install libreoffice-common).
Hope this helps.

atz, botzill, haseeb2k9, yogs174, mmizutani, reddimohan, BenBals, Reeeemi, zealot128, moyom96, and 15 more reacted with thumbs up emoji
ashenwgt, aCodeAlchemist, sinabakh, and iamAliAsgharKhan reacted with laugh emoji
ashenwgt, aCodeAlchemist, JohnMcLear, sinabakh, and MurKit reacted with hooray emoji
reddimohan, BenBals, haelbouhad, eujc21, arturnawrot, ashenwgt, aCodeAlchemist, sinabakh, and iamAliAsgharKhan reacted with heart emoji
ashenwgt, aCodeAlchemist, and sinabakh reacted with rocket emoji

dgcliff

added a commit
to NEU-Libraries/cerberus
that referenced
this issue

Apr 27, 2017

@dgcliff

…ce required for some odd reason, instead of headless. Provision script will need to be updated

muschellij2

added a commit
to muschellij2/docxtractr
that referenced
this issue

Jul 12, 2019

@muschellij2

@AbhijitManepatil

A Python code to resolve issue : Error: source file could not be loaded
following code worked

import subprocess
subprocess.call(['soffice',
                    '--headless',
                    '--convert-to',
                    'docx',                    
                    sourceFileLocation,
                    '--outdir',
                    destiFileLocation
                    ])


Description


Dieter Schmeer



2014-08-06 20:34:34 UTC

Created attachment 104179 [details]
Used test document

Call the following on command line:
"c:Program Files (x86)LibreOffice 4programswriter.exe" --headless --convert-to doc "test3.odt"
No PDF file is generated, only the file WERAB7E.tmp.WERInternalMetadata.xml.
In Version 4.2.x.x, this still worked.
It seems the problem occurs for all documents containing a paragraph which is longer than one line. If you shorten all paragraphs to have only one line it works.


Comment 2


Joel Madero



2014-08-07 04:53:30 UTC

Just tested with:
Ubuntu 14.04 x64
LibreOffice 4.3.0.4

I cannot confirm - converts fine.

Note: "c:Program Files (x86)LibreOffice 4programswriter.exe" --headless --convert-to doc "test3.odt" converts to a DOC not a pdf.

To convert to a PDF you need to replace "doc" with "pdf" in the above line.


Comment 3


Dieter Schmeer



2014-08-07 05:39:07 UTC

Sorry, "doc" was a copy and paste error, because I also tried converting to doc.
On my Windows installation, neither pdf nor doc works, both conversions fail.
Can anybody please try to confirm this on Windows?


Comment 4


michaelp



2014-08-14 22:27:06 UTC

I seem to be experiencing the same problem. Headless conversion to pdf is failing silently (ie not outputting any errors, but not generating the pdf). LO 3.6 and 4.2 are working, but 4.3.0.4 and 4.3.1.1 (ie the release candidate) are both failing.


Comment 5


Robinson Tryon (qubit)



2014-08-15 03:14:03 UTC

(In reply to comment #4)
> I seem to be experiencing the same problem. Headless conversion to pdf is
> failing silently (ie not outputting any errors, but not generating the pdf).
> LO 3.6 and 4.2 are working, but 4.3.0.4 and 4.3.1.1 (ie the release
> candidate) are both failing.

Hi michael,
On what OS are you testing?


Comment 6


michaelp



2014-08-17 23:12:15 UTC

I'm using Linux, but our clients are also having problems in Windows. The Linux distribution is a bit old - it's running under Ubuntu Lucid (10.04)


Comment 7


pablo.olmos



2014-08-28 14:52:43 UTC

I am having the same problem while trying to convert a docx file on Windows 7 (64bit with service pack 1) with version 4.3.1.2: Headless conversion to pdf is failing silently (ie not outputting any errors, but not generating the pdf).


Comment 8


Florian Reisinger



2014-08-28 16:31:03 UTC

Working with 4.3.0.4 and your test document

Can you enter "echo Exit Code is %errorlevel%" (without the ").
If the exit code is "9009" the file does not exist (at least in my case here)
So cannot reproduce


Comment 9


michaelp



2014-09-02 01:40:13 UTC

On Linux, I get a result code of 0, but nothing has happened. It seems to exit with 0 regardless of whether the source file (ie the file I'm trying to convert) exists or not.


Comment 10


tommy27



2015-01-04 15:13:29 UTC

status NEW since confirmations in comment 4 and comment 7
however it would be interesting to know from affected users if the issue persists in latest 4.3.5.2 release


Comment 11


Dieter Schmeer



2015-01-17 23:16:37 UTC

Update for newer LibreOffice Versions 4.3.5.2 and 4.4.0.2:
The command line
"c:Program Files (x86)LibreOffice 4programswriter.exe" --headless --convert-to pdf "test3.odt"
does still not create a pdf file, the is no output file at all, the command silently fails.

echo Exit Code is %errorlevel%
outputs an exit code of 0.

If I remove some letters in test3.odt until there is only one line of text it works fine.

OS is Windows 7 x64 with all current updates installed. Version 4.2.8 still works fine.


Comment 12


michaelp



2015-05-14 04:21:17 UTC

I just tried again with 4.4.3.2 on Linux and it worked to convert an odt to pdf!

I'm not sure if there's something in our installation that changed or if it was fixed in LO, but it's probably worth while for others who were having this problem to try out that version.


Comment 13


Florian Reisinger



2015-05-14 06:15:18 UTC

As per comment before this one


Comment 14


michaelp



2015-05-14 22:14:41 UTC

BTW - it is still exiting with a result code of 0 on Linux, though it is now nicely printing an error to stderr. Not an issue for my usage, but may be of concern to others. In the example below, the file "blah.odt" does not exist:

./libreoffice4.4/program/swriter --headless --convert-to pdf blah.odt
Error: source file could not be loaded
# echo $?
0


Comment 15


Robinson Tryon (qubit)



2015-12-17 10:57:50 UTC

Migrating Whiteboard tags to Keywords: (notBibisectable)
[NinjaEdit]

I use a script via my file manager context menu to convert various document formats (e.g. *.DOC) to ODT format like this:

for filename in "${@}"; do
    if [[ -f "${filename%.*}.odt" ]]
    then
        newfile="${filename%.*}_$(stat "$filename" | grep "Modify" | awk -F " " '{print $2}').odt"
        mv "${filename%.*}.odt" "${filename%.*}.tmp"
        libreoffice --headless --convert-to odt "$filename"
        mv "${filename%.*}.odt" "$newfile"
        touch "$newfile" -r "$filename"
        mv "${filename%.*}.odt.tmp" "${filename%.*}.odt"
        rm "$filename"
    else
        libreoffice --headless --convert-to odt "$filename"
        touch "${filename%.*}.odt" -r "$filename"
        rm "$filename"
    fi
done

Unfortunately, this results in removing a file without conversion if it is password-protected.

Terminal output in such case is «Error: source file could not be loaded»

I guess (and hope) it would take just a little bit more shell scripting skills to improve the very basic script above so that the input file is not removed but simply skipped (perhaps with an error message or log file as well).

asked May 11, 2022 at 13:39

Sadi's user avatar

SadiSadi

4296 silver badges17 bronze badges

In an ideal world libreoffice will let you know with an exit code that the conversion did not take place. But it seems that’s not the case.

So you have at least two alternatives, one is parsing the standard error and remove the file only if the error message is not there (you check the exit code from grep and hope for the pipe not be broken before that):

for filename in "${@}"; do
    libreoffice --headless --convert-to odt "$filename" 2>&1 | grep "source file could not be loaded" || rm "$filename"
done

Another possibility is to check if the odt file has been created before removing the source (an incomplete conversion might trigger the removal though). Something like this:

for filename in "${@}"; do
    libreoffice --headless --convert-to odt "$filename"
    test -f ${filename%.*}.odt && rm "$filename"
done

answered May 11, 2022 at 14:26

Eduardo Trápani's user avatar

Eduardo TrápaniEduardo Trápani

10.9k1 gold badge14 silver badges31 bronze badges

3

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Libreoffice calc ошибка 511
  • Libreoffice calc как изменить ориентацию страницы
  • Libreoffice basic runtime error
  • Libreoffice base ошибка вставки новой записи
  • Libreoffice api ms win crt runtime l1 1 0 dll отсутствует как исправить

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии