Office docs fail to convert

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
memphisraynz
Posts: 6
Joined: 2015-04-30T17:42:44-07:00
Authentication code: 6789

Office docs fail to convert

Post by memphisraynz » 2015-04-30T22:14:38-07:00

Hi,
I am having some issues when trying to convert Office Docs. I have install ghostscript and libreoffice-headless but when I try and and convert a file i get the below error.

[root@pydio tmp]# convert BoardReport.docx BoardReport.jpg
convert /tmp/magick-27873XnB2L2LJTex -> /tmp/_dirname/magick-27873XnB2L2LJTex.pdf using writer_pdf_Export
mv: cannot stat ‘/tmp/magick-27873XnB2L2LJTex.pdf’: No such file or directory
convert: delegate failed "soffice" --headless --convert-to pdf --outdirdirname “%i”` “%i” 2> “%Z”; mv “%i.pdf” “%o”‘ @ error/delegate.c/InvokeDelegate/1329.
convert: no decode delegate for this image format `DOCX’ @ error/constitute.c/ReadImage/535.
convert: no images defined `BoardReport.jpg’ @ error/convert.c/ConvertImageCommand/3212.

For some reason it is adding _dirname to the file path.
The file to exist in the /tmp/_dirname/ but I am unsure on why it is placing it there, instead of in the /tmp/

Thanks

memphisraynz
Posts: 6
Joined: 2015-04-30T17:42:44-07:00
Authentication code: 6789

Re: Office docs fail to convert

Post by memphisraynz » 2015-05-09T05:02:34-07:00

Has anyone seen this before, or any idea on where I can look?
I am completely out of ideas and this is my last resort.

Thanks for any help
Cheers

snibgo
Posts: 9399
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Office docs fail to convert

Post by snibgo » 2015-05-09T05:45:29-07:00

I know nothing about running OpenOffice non-interactively, ie "--headless". I assume you have installed this. Does the command "soffice --headless" work?

"-verbose" may show the actual command given. Failing that, "-debug all" might.
snibgo's IM pages: im.snibgo.com

memphisraynz
Posts: 6
Joined: 2015-04-30T17:42:44-07:00
Authentication code: 6789

Re: Office docs fail to convert

Post by memphisraynz » 2015-05-09T05:57:52-07:00

Thanks for the reply, yes I have the headless version of LibreOffice, there is no OpenOffice package available for Centos7. When I checked the xml file with the conversion strings the soffice string was already in there, lead me to believe it was put in there by the imagemagick team.

I have tried what you suggested, running the conversion manually, converting the docx to pdf via soffice and it worked without an issue. Which brought me back to ImageMagick. Maybe there is a clash somewhere in the string? I just couldn't work it out myself, and i couldnt find anyone else witht he same problem.

I will give the -verbose flag a go.

Thanks

memphisraynz
Posts: 6
Joined: 2015-04-30T17:42:44-07:00
Authentication code: 6789

Re: Office docs fail to convert

Post by memphisraynz » 2015-05-10T15:34:07-07:00

Hi,
I ran the -verbose but didn't seem to give any more information. So I ran the -debug all, but I personally don't see anything in the results.
I also ran the soffice convert to pdf manually again to double check and it worked;

[root@pydio tmp]# soffice --headless --convert-to pdf BoardReport.docx
convert /tmp/BoardReport.docx -> /tmp/BoardReport.pdf using writer_pdf_Export
Overwriting: /tmp/BoardReport.pdf

Here are the results of the debug all. Hopefulyl someone might have an idea from this.

[root@pydio tmp]# convert BoardReport.docx BoardReport.jpg -debug all
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: utility.c/ExpandFilenames/936/Configure
Command line: convert {BoardReport.docx} {BoardReport.jpg} {-debug} {all}
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Policy convert[33944]: policy.c/IsRightsAuthorized/574/Policy
Domain: Path; rights=Read; pattern="BoardReport.docx" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Blob convert[33944]: blob.c/OpenBlob/2584/Blob
read 3 magic header bytes
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Cache convert[33944]: cache.c/DestroyPixelCache/934/Cache
destroy
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/usr/share/ImageMagick-6/magic.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/usr/lib/ImageMagick-6.9.1//config-Q16/magic.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/usr/etc/ImageMagick-6/magic.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/usr/share/doc/ImageMagick-6/magic.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/root/.config/ImageMagick/magic.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/root/.magick/magic.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: magic.c/LoadMagicCache/773/Configure
Loading magic configure file "/usr/etc/ImageMagick-6/magic.xml" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Policy convert[33944]: policy.c/IsRightsAuthorized/574/Policy
Domain: Coder; rights=Read; pattern="DOCX" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/usr/share/ImageMagick-6/delegates.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/usr/lib/ImageMagick-6.9.1//config-Q16/delegates.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/usr/etc/ImageMagick-6/delegates.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/usr/share/doc/ImageMagick-6/delegates.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/root/.config/ImageMagick/delegates.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: configure.c/GetConfigureOptions/679/Configure
Searching for configure file: "/root/.magick/delegates.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: delegate.c/LoadDelegateCache/1494/Configure
Loading delegate configuration file "/usr/etc/ImageMagick-6/delegates.xml" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Policy convert[33944]: policy.c/IsRightsAuthorized/574/Policy
Domain: Delegate; rights=Execute; pattern="DOCX" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Policy convert[33944]: policy.c/IsRightsAuthorized/574/Policy
Domain: Delegate; rights=Execute; pattern="(null)" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/AcquireUniqueFileResource/501/Resource
...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/AcquireUniqueFileResource/550/Resource
Acquire /tmp/magick-33944gx56DQWTcVNN
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/AcquireUniqueFileResource/501/Resource
...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/AcquireUniqueFileResource/550/Resource
Acquire /tmp/magick-33944li9CaBKndM99
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/RelinquishUniqueFileResource/1039/Resource
Relinquish /tmp/magick-33944li9CaBKndM99
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: utility.c/ShredFile/1815/Exception
Failed to remove: /tmp/magick-33944li9CaBKndM99.cache
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/AcquireUniqueFileResource/501/Resource
...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/AcquireUniqueFileResource/550/Resource
Acquire /tmp/magick-33944DoL9mKVBHFvw
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/AcquireUniqueFileResource/501/Resource
...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/AcquireUniqueFileResource/550/Resource
Acquire /tmp/magick-33944ycOuDFfpmBRS
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/AcquireUniqueFileResource/501/Resource
...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/AcquireUniqueFileResource/550/Resource
Acquire /tmp/magick-33944Vsyf3DR2nydf
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/RelinquishUniqueFileResource/1039/Resource
Relinquish /tmp/magick-33944Vsyf3DR2nydf
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: utility.c/ShredFile/1815/Exception
Failed to remove: /tmp/magick-33944Vsyf3DR2nydf.cache
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Policy convert[33944]: policy.c/IsRightsAuthorized/574/Policy
Domain: Delegate; rights=Execute; pattern="soffice" ...
convert /tmp/magick-33944Vsyf3DR2nydf -> /tmp/_dirname/magick-33944Vsyf3DR2nydf.pdf using writer_pdf_Export
mv: cannot stat ‘/tmp/magick-33944Vsyf3DR2nydf.pdf’: No such file or directory
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/RelinquishUniqueFileResource/1039/Resource
Relinquish /tmp/magick-33944li9CaBKndM99
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: utility.c/ShredFile/1815/Exception
Failed to remove: /tmp/magick-33944li9CaBKndM99.cache
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/RelinquishUniqueFileResource/1039/Resource
Relinquish /tmp/magick-33944DoL9mKVBHFvw
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: utility.c/ShredFile/1815/Exception
Failed to remove: /tmp/magick-33944DoL9mKVBHFvw.cache
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/RelinquishUniqueFileResource/1039/Resource
Relinquish /tmp/magick-33944ycOuDFfpmBRS
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: utility.c/ShredFile/1815/Exception
Failed to remove: /tmp/magick-33944ycOuDFfpmBRS.cache
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/RelinquishUniqueFileResource/1039/Resource
Relinquish /tmp/magick-33944li9CaBKndM99
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: utility.c/ShredFile/1815/Exception
Failed to remove: /tmp/magick-33944li9CaBKndM99.cache
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: utility.c/ShredFile/1815/Exception
Failed to remove: /tmp/magick-33944li9CaBKndM99
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Resource convert[33944]: resource.c/RelinquishUniqueFileResource/1039/Resource
Relinquish /tmp/magick-33944Vsyf3DR2nydf
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: utility.c/ShredFile/1815/Exception
Failed to remove: /tmp/magick-33944Vsyf3DR2nydf.cache
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/usr/share/ImageMagick-6/locale.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/usr/lib/ImageMagick-6.9.1//config-Q16/locale.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/usr/etc/ImageMagick-6/locale.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/usr/share/doc/ImageMagick-6/locale.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/root/.config/ImageMagick/locale.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/root/.magick/locale.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: locale.c/LoadLocaleCache/1173/Configure
Loading locale configure file "/usr/share/ImageMagick-6/locale.xml" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/usr/share/ImageMagick-6/english.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/usr/lib/ImageMagick-6.9.1//config-Q16/english.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/usr/etc/ImageMagick-6/english.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/usr/share/doc/ImageMagick-6/english.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/root/.config/ImageMagick/english.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Locale convert[33944]: locale.c/GetLocaleOptions/822/Locale
Searching for locale file: "/root/.magick/english.xml"
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Configure convert[33944]: locale.c/LoadLocaleCache/1173/Configure
Loading locale configure file "/usr/share/ImageMagick-6/english.xml" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: delegate.c/InvokeDelegate/1329/Exception
delegate failed `"soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o"'
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Cache convert[33944]: cache.c/DestroyPixelCache/934/Cache
destroy
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Policy convert[33944]: policy.c/IsRightsAuthorized/574/Policy
Domain: Path; rights=Read; pattern="/tmp/magick-33944gx56DQWTcVNN" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Blob convert[33944]: blob.c/OpenBlob/2584/Blob
read 0 magic header bytes
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Cache convert[33944]: cache.c/DestroyPixelCache/934/Cache
destroy
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: constitute.c/ReadImage/535/Exception
no decode delegate for this image format `DOCX'
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Policy convert[33944]: policy.c/IsRightsAuthorized/574/Policy
Domain: Path; rights=Read; pattern="BoardReport.jpg" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: blob.c/OpenBlob/2692/Exception
unable to open image `BoardReport.jpg': No such file or directory
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Cache convert[33944]: cache.c/DestroyPixelCache/934/Cache
destroy
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Policy convert[33944]: policy.c/IsRightsAuthorized/574/Policy
Domain: Coder; rights=Read; pattern="JPG" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Policy convert[33944]: policy.c/IsRightsAuthorized/574/Policy
Domain: Path; rights=Read; pattern="BoardReport.jpg" ...
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: blob.c/OpenBlob/2692/Exception
unable to open image `BoardReport.jpg': No such file or directory
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Cache convert[33944]: cache.c/DestroyPixelCache/934/Cache
destroy
2015-05-11T08:28:13+10:00 0:00.000 0.000u 6.9.1 Exception convert[33944]: convert.c/ConvertImageCommand/3209/Exception
missing an image filename `all'
convert: delegate failed `"soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o"' @ error/delegate.c/InvokeDelegate/1329.
convert: no decode delegate for this image format `DOCX' @ error/constitute.c/ReadImage/535.
convert: unable to open image `BoardReport.jpg': No such file or directory @ error/blob.c/OpenBlob/2692.
convert: missing an image filename `all' @ error/convert.c/ConvertImageCommand/3209.


Thank you very much

User avatar
fmw42
Posts: 22101
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Office docs fail to convert

Post by fmw42 » 2015-05-10T17:26:20-07:00

@ error/delegate.c/InvokeDelegate/1329.
convert: no decode delegate for this image format `DOCX' @ error/constitute.c/ReadImage/535.
I do not know much about converting MS Word Docs in IM. But the error message above seems to imply you are missing some delegate needed to open the DOCX format.

Now being a Windows user of IM, I have no idea that IM can or cannot handle DOCX input files. And if it can, I would not know what delegate is needed. But it might be a configuration issue in your delegates.xml file.

Perhaps one of the Windows users can give you more help.

memphisraynz
Posts: 6
Joined: 2015-04-30T17:42:44-07:00
Authentication code: 6789

Re: Office docs fail to convert

Post by memphisraynz » 2015-05-10T18:12:25-07:00

Hi there,
Thanks for the reply. To be honest I have been slightly ignoring that no delegate error because it is actually converting the DOCX to PDF but it is always adding it to a subdirectory called "_dirname". The problem is that when it goes to convert that PDF to a JPG it doesn't know that it has been added to that _dirname subdirectory.

I checked the delegates.xml file, it has the delegate information and the query to use. I can't see in the query where it is adding in the random _dirname subdirectory.

pipitas
Posts: 163
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Office docs fail to convert

Post by pipitas » 2015-05-10T20:18:04-07:00

snibgo wrote:I know nothing about running OpenOffice non-interactively, ie "--headless". I assume you have installed this. [....]
This should be working an all platforms, for OpenOffice as well as for LibreOffice. (I think that the syntax of LibreOffice may have evolved a bit since the fork...)

The headless mode is meant for exactly that: importing of all supported file formats and exporting (supported) file formats on the command line. And there are many! Many dozens of import and export filters...

The basic command for it is this (using Unix/Linux/OSX-type conventions to specify variables, paths and line continuation markers):

Code: Select all

soffice                                                             \
   -env:UserInstallation=file:///tmp/LibreOfficeConversion_${USER}" \
   --headless                                                       \
   --infilter=<filter>                                              \
   --convert-to <TargetFileExtension>:<NameOfFilter>                \
   --outdir /path/to/wherever/you/want                              \
     file_to_convert.xxx
  • Without the `-env:UserInstallation=` parameter, the command may fail because it can then conflict with a potentially already running GUI, non-headless instance of `soffice`. Adding this parameter will use a different environment and allow an additional instance of `soffice` to start up.
  • The `<TargetFileExtension>` may be `pdf`, `docx`, `xlsx`, ...whatever is supported by Open/LibreOffice for exported file formats.
  • The `<NameOfFilter>` must match the previous target file extension as well as the input format. One possible value is `calc_pdf_Export` (note the weird capitalization!), if you want PDF export from an .xxx == .xls imported file. Other possible values are `writer_pdf_Export` (for an imported `docx`) or `draw_pdf_Export` (for an imported `.spl` with -infilter="EMF - MS Windows Metafile").
    A (complete?) list of filters is here:
  • The `--infilter=<filter>` parameter is optional. It forces an input filter type if possible, for example `-infilter="Calc Office Open XML"`.
    Look here: for the input filter names in the *.xcu files. For example the `MS_Excel_95.xcu` contains the line:

    Code: Select all

    <node oor:name="MS Excel 95" oor:op="replace">
    Another list of filters I found here: You have to use the "API names" given there. The syntax is not consistent, it changes from `calc_pdf_Export` to `"MS Excel 97"` (when there are spaces in the name, make sure to use quotes!)
I remember some users having reported that `--headless` should be given last on the command line. This did work for them:

Code: Select all

soffice --convert-to pdf:... filename.doc  --headless
But this didn't work for them:

Code: Select all

soffice  --headless --convert-to pdf:... filename.doc
I myself have never experienced this problem.

Some Windows users have reported the need of adding `start /wait` to the command. Otherwise the shell may collapse before soffice could complete the conversion (at least in some cases):

Code: Select all

start /wait soffice --headless --convert-to pdf:... file_to_convert.doc
On OSX I'm using this feature to create PDF documents which are styled according to an ODT reference document by using the great `pandoc` command line tool to convert simple Markdown input text. I'm doing this semi-automatically via a Makefile.

Here I had the problem that the $PATH environment variable didn't work reliably in order to find the soffice binary. Here I found it safest to first change into the directory where the `soffice` binary lives. My Makefile snippet therefor reads:

Code: Select all

 ( cd /Applications/LibreOffice.app/Contents/MacOS ;                    \
 ./soffice "-env:UserInstallation=file:///tmp/LibO_Conversion__$(USER)" \
                --headless                                              \
                --convert-to pdf:writer_pdf_Export                      \
                --outdir $(CURRDIR)/$(FINAL)                            \
                  $(CURRDIR)/$(BUILD)/$(subst .letterpdf,.odt,$@) ;     \
 cd - ; )

pipitas
Posts: 163
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Office docs fail to convert

Post by pipitas » 2015-05-11T16:09:06-07:00

memphisraynz wrote:I checked the delegates.xml file, it has the delegate information and the query to use. I can't see in the query where it is adding in the random _dirname subdirectory.
If you gave an exact quote of the relevant lines from your delegates.xml file, somebody could really help to debug it.

Everything else is pure speculation.

There are two delegates involved here:
  • first one, the ODT->PDF conversion (soffice)
  • second one, the PDF->JPEG conversion (Ghostscript for creating some raster image for ImageMagick to take over)

memphisraynz
Posts: 6
Joined: 2015-04-30T17:42:44-07:00
Authentication code: 6789

Re: Office docs fail to convert

Post by memphisraynz » 2015-05-11T18:49:10-07:00

Hi piptas,

Using soffice manually I can crete a pdf from docx, and through imagemagic I can convert a pdf to jpg. So I think something is wrong like you are suggesting. I tried to change some of the settings in the delegates file but nothing helped.
I understand that "dirname" should return the current directory but for somereason it returns _dirname, not sure if this is an issue with Centos7

<delegatemap>
<delegate decode="autotrace" stealth="True" command=""convert" "%i" "pnm:%u"\n"autotrace" -input-format pnm -output-format svg -output-file "%o" "%u""/>
<delegate decode="bpg" command=""bpgdec" -b 16 -o "%o.png" "%i"; mv "%o.png" "%o""/>
<delegate decode="png" encode="bpg" command=""bpgenc" -b 12 -o "%o" "%i""/>
<delegate decode="blender" command=""blender" -b "%i" -F PNG -o "%o""\n"convert" -concatenate "%o*.png" "%o""/>
<delegate decode="browse" stealth="True" spawn="True" command=""xdg-open" http://www.imagemagick.org/; rm "%i""/>
<delegate decode="cdr" command=""uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o""/>
<delegate decode="cgm" command=""uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o""/>
<delegate decode="dng:decode" command=""ufraw-batch" --silent --create-id=also --out-type=png --out-depth=16 "--output=%u.png" "%i""/>
<delegate decode="doc" command=""soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o""/>
<delegate decode="docx" command=""soffice" --headless --convert-to pdf --outdir 'dirname'"%i" "%i" 2> "%Z"; mv "%i.pdf" "%o""/>
<delegate decode="dot" command='"dot" -Tsvg "%i" -o "%o"' />
<delegate decode="dvi" command=""dvips" -q -o "%o" "%i""/>
<delegate decode="dxf" command=""uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o""/>
<delegate decode="edit" stealth="True" command=""xterm" -title "Edit Image Comment" -e vi "%o""/>
<delegate decode="eps" encode="pdf" mode="bi" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i""/>
<delegate decode="eps" encode="ps" mode="bi" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=ps2write" "-sOutputFile=%o" "-f%i""/>
<delegate decode="fig" command=""uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o""/>
<delegate decode="hpg" command=""hp2xx" -q -m eps -f `basename "%o"` "%i"; mv -f `basename "%o"` "%o""/>
<delegate decode="hpgl" command=""hp2xx" -q -m eps -f `basename "%o"` "%i"; mv -f `basename "%o"` "%o""/>
<delegate decode="htm" command=""html2ps" -U -o "%o" "%i""/>
<delegate decode="html" command=""html2ps" -U -o "%o" "%i""/>
<delegate decode="https" command=""curl" -s -k -L -o "%o" "https:%M""/>
<delegate decode="ilbm" command=""ilbmtoppm" "%i" > "%o""/>
<delegate decode="jxr" command="mv "%i" "%i.jxr"; "JxrDecApp" -i "%i.jxr" -o "%o.bmp" -c 0; mv "%i.jxr" "%i"; mv "%o.bmp" "%o""/>
<delegate decode="man" command=""groff" -man -Tps "%i" > "%o""/>
<delegate decode="miff" encode="show" spawn="True" command=""display" -delay 0 -window-group %[group] -title "%l " "ephemeral:%i""/>
<delegate decode="miff" encode="win" stealth="True" spawn="True" command=""display" -immutable -delay 0 -window-group %[group] -title "%l " "ephemeral:%i""/>
<delegate decode="mpeg:decode" command=""ffmpeg" -v -1 -i "%i" -vframes %S -vcodec pam -an -f rawvideo -y "%u.pam" 2> "%Z""/>
<delegate decode="odt" command=""soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o""/>
<delegate decode="pcl:cmyk" stealth="True" command=""pcl6" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s""/>
<delegate decode="pcl:color" stealth="True" command=""pcl6" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=ppmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s""/>
<delegate decode="pcl:mono" stealth="True" command=""pcl6" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pbmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s""/>
<delegate decode="pdf" encode="eps" mode="bi" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=eps2write" "-sOutputFile=%o" "-f%i""/>
<delegate decode="pdf" encode="ps" mode="bi" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=ps2write" "-sOutputFile=%o" "-f%i""/>
<delegate decode="plt" command=""echo" "set size 1.25,0.62; set terminal postscript portrait color solid; set output \'%o\'; load \'%i\'" > "%u";"gnuplot" "%u""/>
<delegate decode="png" encode="webp" command=""cwebp" -quiet -q %Q "%i" -o "%o""/>
<delegate decode="pnm" encode="ilbm" mode="encode" command=""ppmtoilbm" -24if "%i" > "%o""/>
<delegate decode="bmp" encode="jxr" command="mv "%i" "%i.bmp"; "JxrEncApp" -i "%i.bmp" -o "%o.jxr"; mv "%i.bmp" "%i"; mv "%o.jxr" "%o""/>
<delegate decode="bmp" encode="wdp" command="mv "%i" "%i.bmp"; "JxrEncApp" -i "%i.bmp" -o "%o.jxr"; mv "%i.bmp" "%i"; mv "%o.jxr" "%o""/>
<delegate decode="pov" command=""povray" "+i%i" -D0 "+o%o" +fn%q +w%w +h%h +a -q9 "-kfi%s" "-kff%n";"convert" -concatenate "%o*.png" "%o""/>
<delegate decode="ppt" command=""soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o""/>
<delegate decode="pptx" command=""soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o""/>
<delegate decode="ps:alpha" stealth="True" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>
<delegate decode="ps:cmyk" stealth="True" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pam" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>
<delegate decode="ps:color" stealth="True" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pnmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>
<delegate decode="ps" encode="eps" mode="bi" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=eps2write" "-sOutputFile=%o" "-f%i""/>
<delegate decode="ps" encode="pdf" mode="bi" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i""/>
<delegate decode="ps" encode="print" mode="encode" command="lpr "%i""/>
<delegate decode="ps:mono" stealth="True" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pbmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>
<delegate decode="rgba" encode="rle" mode="encode" command=""rawtorle" -o "%o" -v "%i""/>
<delegate decode="scan" command=""scanimage" -d "%i" > "%o""/>
<delegate decode="scanx" command=""scanimage" > "%o""/>
<delegate decode="shtml" command=""html2ps" -U -o "%o" "%i""/>
<delegate decode="sid" command=""mrsidgeodecode" -if sid -i "%i" -of tif -o "%o" > "%u""/>
<delegate decode="svg" command=""rsvg-convert" -o "%o" "%i""/>
<delegate decode="svg:decode" stealth="True" command=""inkscape" "%s" --export-png="%s" --export-dpi="%s" --export-background="%s" --export-background-opacity="%s" > "%s" 2>&1"/>
<delegate decode="tiff" encode="launch" mode="encode" command=""gimp" "%i""/>
<delegate decode="txt" encode="ps" mode="bi" command=""enscript" -o "%o" "%i""/>
<delegate decode="wdp" command="mv "%i" "%i.jxr"; "JxrDecApp" -i "%i.jxr" -o "%o.bmp"; mv "%i.jxr" "%i"; mv "%o.bmp" "%o""/>
<delegate decode="webp" command=""dwebp" -pam "%i" -o "%o""/>
<delegate decode="wmf" command=""wmf2eps" -o "%o" "%i""/>
<delegate decode="xls" command=""soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o""/>
<delegate decode="xlsx" command=""soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o""/>
<delegate decode="xps:cmyk" stealth="True" command=""gxps" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=bmpsep8" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s""/>
<delegate decode="xps:color" stealth="True" command=""gxps" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=ppmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s""/>
<delegate decode="xps:mono" stealth="True" command=""gxps" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pbmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s""/>
<delegate encode="mpeg:encode" stealth="True" command=""ffmpeg" -v -1 -i "%M%%d.jpg" "%u.%m" 2> "%Z""/>
</delegatemap>

Lekensteyn
Posts: 4
Joined: 2015-06-03T01:25:21-07:00
Authentication code: 6789

Re: Office docs fail to convert

Post by Lekensteyn » 2015-06-05T12:31:22-07:00

It seems that the backtick operator got subtituted by an underscore (since https://github.com/ImageMagick/ImageMag ... it/90ee513?). There should probably be a percent-option for specifying a temporary directory.

Anyway, even with when `dirname "%i"` is replaced by /tmp, conversion still fails:

Code: Select all

$ convert -verbose foo.xlsx foo1.pdf
"soffice" --headless --convert-to pdf --outdir /tmp "/tmp/magick-4346u95gJrXCHVSq" 2> "/tmp/magick-4346PMDP9cxFPhTW"; mv "/tmp/magick-4346u95gJrXCHVSq.pdf" "/tmp/magick-4346lJNGQpJ840TY"
convert /tmp/magick-4346u95gJrXCHVSq -> /tmp/magick-4346u95gJrXCHVSq.pdf using filter : calc_pdf_Export
convert: no decode delegate for this image format `XLSX' @ error/constitute.c/ReadImage/535.
convert: no images defined `foo1.pdf' @ error/convert.c/ConvertImageCommand/3212.

chrisl
Posts: 1
Joined: 2015-08-06T01:53:25-07:00
Authentication code: 1151

Re: Office docs fail to convert

Post by chrisl » 2015-08-06T02:01:09-07:00

Are there any new insights? I'm having the same issues with Ubuntu 15.04 (ImageMagick 6.8.9-9 Q16). I installed ImageMagick 6.9.1-10 Q16 manually and it doesn't work either. But with a different error message:

Code: Select all

convert /tmp/magick-106690qYV1A8uzMY6 -> /tmp/magick-106690qYV1A8uzMY6.pdf using filter : impress_pdf_Export
convert: no decode delegate for this image format `PNG' @ error/constitute.c/ReadImage/501.
convert: no images defined `test_pptx.pdf' @ error/convert.c/ConvertImageCommand/3230.
Thanks for any help!
Chris

jga129
Posts: 1
Joined: 2017-08-29T19:45:27-07:00
Authentication code: 1151

Re: Office docs fail to convert

Post by jga129 » 2017-08-29T19:47:44-07:00

Hi, has this been resolved?

I am having the same issue with converting .doc to .pdf

best,

Jorge

Post Reply