命令`libreoffice --headless --convert-to pdf test.docx --outdir / pdf`不起作用

时间:2021-09-19 21:08:13

I have to wait for long after using this LibreOffice command which is intended to convert DOCX into PDF:

在使用这个旨在将DOCX转换为PDF的LibreOffice命令后,我必须等待很长时间:

libreoffice --headless --convert-to pdf test.docx --outdir /pdf

libreoffice --headless --convert-to pdf test.docx --outdir / pdf

But I'm getting no response and no error. No file is converted. It looks like terminal is hanging.

但我没有得到任何回应,没有错误。没有文件被转换。看起来终端正在悬挂。

So, is there is any way to track the error?

那么,有没有办法跟踪错误?

4 个解决方案

#1


68  

  1. I would first of all try it with giving absolute paths to the command.

    我首先尝试给出命令的绝对路径。

  2. I suspect that the libreoffice binary does not work -- you have to locate the soffice binary and see if that works.

    我怀疑libreoffice二进制文件不起作用 - 你必须找到soffice二进制文件,看看它是否有效。

  3. Then, your --convert-to pdf is not sufficient. It needs to be:

    然后,你的--convert-to pdf是不够的。它需要是:

    --convert-to pdf:writer_pdf_Export
    

    Be sure to follow exactly this capitalization!

    一定要完全遵循这个大写!

  4. Next, the command will not work if there is already a LibreOffice GUI instance up and running on your system. It is caused by bug known since 2011. Add this additional parameter to your command:

    接下来,如果已在系统上启动并运行LibreOffice GUI实例,则该命令将不起作用。它是由自2011年以来已知的错误引起的。将此附加参数添加到您的命令:

     "-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}"
    

    This will create a new, separate environment which can be used by a second, headless LO instance without interfering with a possibly running first GUI LO instance started by the same user.

    这将创建一个新的独立环境,该环境可由第二个无头LO实例使用,而不会干扰由同一用户启动的可能正在运行的第一个GUI LO实例。

  5. Also, make sure that the --outdir /pdf you specify does exist, and that you have write permission to it. Or, rather use a different output dir. Even if it is just for the first testing and this debugging round:

    此外,请确保您指定的--outdir / pdf确实存在,并且您具有写入权限。或者,而是使用不同的输出目录。即使它仅用于第一次测试和本次调试:

    $ mkdir ${HOME}/lo_pdfs
    
  6. Hence:

    因此:

    /path/to/soffice                                                     \
      --headless                                                         \
      "-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}" \
      --convert-to pdf:writer_pdf_Export                                 \
      --outdir ${HOME}/lo_pdfs                                           \
    /path/to/test.docx
    

    This works for me on Mac OS X Mavericks 10.9.5 with LibreOffice v4.4.3.2 (using my specific path for the binary soffice which will be different for you anyway...).

    这适用于Mac OS X Mavericks 10.9.5和LibreOffice v4.4.3.2(使用我对二进制soffice的特定路径,无论如何都会对你不同......)。

    If all this doesn't work:

    如果这一切都不起作用:

  7. It may be a problem with the specific DOCX file you try the command with... So create a very simple DOCX document of your own first. Use LibreOffice itself for this. Write "Hello World!" on an otherwise empty page. Save it as DOCX.

    对于您尝试使用命令的特定DOCX文件可能存在问题...因此,首先创建一个非常简单的DOCX文档。为此使用LibreOffice本身。写下“Hello World!”在一个空的页面上。将其另存为DOCX。

  8. Try again. Does it work with the simple DOCX?

    再试一次。它与简单的DOCX一起使用吗?

  9. If it again doesn't work, repeat step 7, but save as ODT this time.

    如果它再次不起作用,请重复步骤7,但这次保存为ODT。

  10. Repeat step 8, but make sure to reference the ODT this time.

    重复步骤8,但这次确保参考ODT。

  11. Last: Use full path to soffice, to soffice.bin and to libreoffice and run each with the -h parameter:

    最后:使用soffice的完整路径,soffice.bin和libreoffice并使用-h参数运行每个:

    $ /path/to/libreoffice -h
    $ /path/to/soffice -h
    $ /path/to/soffice.bin -h
    
    • Do you even get an output here?
    • 你甚至在这里得到一个输出?
    • For which one of the three binaries/symlinks?
    • 三个二进制文件/符号链接中的哪一个?
    • Record the outputs.
    • 记录输出。
    • Tell us your outputs!!!
    • 告诉我们你的输出!

    Compare them to the command line you used:

    将它们与您使用的命令行进行比较:

    Are there any changes in parameter names, capitalizations, number of dashes used, etc.??

    参数名称,大小写,使用的破折号等都有变化吗?

    For comparison, my own output is here:

    为了比较,我自己的输出在这里:

    $ /Applications/LibreOffice.app/Contents/MacOS/soffice -h
    
      LibreOffice 4.4.3.2 88805f81e9fe61362df02b9941de8e38a9b5fd16
    
      Usage: soffice [options] [documents...]
    
      Options:
      --minimized    keep startup bitmap minimized.
      --invisible    no startup screen, no default document and no UI.
      --norestore    suppress restart/restore after fatal errors.
      --quickstart   starts the quickstart service
      --nologo       don't show startup screen.
      --nolockcheck  don't check for remote instances using the installation
      --nodefault    don't start with an empty document
      --headless     like invisible but no userinteraction at all.
      --help/-h/-?   show this message and exit.
      --version      display the version information.
      --writer       create new text document.
      --calc         create new spreadsheet document.
      --draw         create new drawing.
      --impress      create new presentation.
      --base         create new database.
      --math         create new formula.
      --global       create new global document.
      --web          create new HTML document.
      -o             open documents regardless whether they are templates or not.
      -n             always open documents as new files (use as template).
    
      --display <display>
            Specify X-Display to use in Unix/X11 versions.
      -p <documents...>
            print the specified documents on the default printer.
      --pt <printer> <documents...>
            print the specified documents on the specified printer.
      --view <documents...>
            open the specified documents in viewer-(readonly-)mode.
      --show <presentation>
            open the specified presentation and start it immediately
      --accept=<accept-string>
            Specify an UNO connect-string to create an UNO acceptor through which
            other programs can connect to access the API
      --unaccept=<accept-string>
            Close an acceptor that was created with --accept=<accept-string>
            Use --unnaccept=all to close all open acceptors
      --infilter=<filter>[:filter_options]
            Force an input filter type if possible
            Eg. --infilter="Calc Office Open XML"
                --infilter="Text (encoded):UTF8,LF,,,"
      --convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir output_dir] files
            Batch convert files.
            If --outdir is not specified then current working dir is used as output_dir.
            Eg. --convert-to pdf *.doc
                --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc
                --convert-to "html:XHTML Writer File:UTF8" *.doc
                --convert-to "txt:Text (encoded):UTF8" *.doc
      --print-to-file [-printer-name printer_name] [--outdir output_dir] files
            Batch print files to file.
            If --outdir is not specified then current working dir is used as output_dir.
            Eg. --print-to-file *.doc
                --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc
      --cat files
            Dump text content of the files to console
            Eg. --cat *.odt
      --pidfile file
            Store soffice.bin pid to file.
      -env:<VAR>[=<VALUE>]
            Set a bootstrap variable.
            Eg. -env:UserInstallation=file:///tmp/test to set a non-default user profile path.
    
      Remaining arguments will be treated as filenames or URLs of documents to open.
    
  12. Add one more argument to your command line to enforce the application of an input filter when soffice opens your DOCX file:

    在soffice打开DOCX文件时,在命令行中再添加一个参数以强制应用输入过滤器:

    --infilter="Microsoft Word 2007/2010/2013 XML"
    

    or

    要么

    --infilter="Microsoft Word 2007/2010/2013 XML"
    --infilter="Microsoft Word 2007-2013 XML"
    --infilter="Microsoft Word 2007-2013 XML Template"
    --infilter="Microsoft Word 95 Template"
    --infilter="MS Word 95 Vorlage"
    --infilter="Microsoft Word 97/2000/XP Template"
    --infilter="MS Word 97 Vorlage"
    --infilter="Microsoft Word 2003 XML"
    --infilter="MS Word 2003 XML"
    --infilter="Microsoft Word 2007 XML Template"
    --infilter="MS Word 2007 XML Template"
    --infilter="Microsoft Word 6.0"
    --infilter="MS WinWord 6.0"
    --infilter="Microsoft Word 95"
    --infilter="MS Word 95"
    --infilter="Microsoft Word 97/2000/XP"
    --infilter="MS Word 97"
    --infilter="Microsoft Word 2007 XML"
    --infilter="MS Word 2007 XML"
    --infilter="Microsoft WinWord 5"
    --infilter="MS WinWord 5"
    

Update

LibreOffice cannot only convert DOCX to PDF on the command line:

LibreOffice不仅可以在命令行上将DOCX转换为PDF:

  • It can process any input format which it can open and "read": DOC, XLS, XLSX, PPT, PPTX, ...
  • 它可以处理任何可以打开和“读取”的输入格式:DOC,XLS,XLSX,PPT,PPTX,......
  • It can convert to any output format which it can "write": DOC, XLS, XLSX, PPT, PPTX, ...
  • 它可以转换为任何可以“写”的输出格式:DOC,XLS,XLSX,PPT,PPTX,......

Of course, results will never be perfect, and sometimes they will even be un-acceptable to you.

当然,结果永远不会是完美的,有时它们甚至会让你无法接受。

Re. output as PDF:

回覆。输出为PDF:

To control, which LibreOffice component generates PDF output, you can use these variants:

要控制哪个LibreOffice组件生成PDF输出,您可以使用以下变体:

--convert-to pdf:writer_pdf_Export
--convert-to pdf:calc_pdf_Export
--convert-to pdf:draw_pdf_Export
--convert-to pdf:impress_pdf_Export
--convert-to pdf:writer_web_pdf_Export

Re. input which is not DOCX:

回覆。输入不是DOCX:

To enforce infilters for non-DOCX input formats, you could use (list is not complete):

要强制使用非DOCX输入格式的渗透程序,您可以使用(列表不完整):

--infilter="HTML Document"                      # for HTML input
--infilter="MediaWiki"                          # for MediaWiki input
--infilter="Text CSV"                           # for CSV spreadsheet input
--infilter="Microsoft PowerPoint 2007/2010 XML" # for PPTX input
--infilter="Microsoft PowerPoint 97/2000/XP"    # for PPT input
--infilter="Windows Metafile"                   # for WMF input
--infilter="Enhanced Metafile"                  # for EMF input
--infilter="Scalable Vector Graphics"           # for SVG input
--infilter="Microsoft Excel 2007/2010 XML"      # for XLSX input
--infilter="Microsoft Excel 97/2000/XP"         # for XLS input
--infilter="Microsoft Excel 95"                 # for some XLS input
--infilter="Microsoft Excel 5.0"                # for some XLS input

Re. output which is not PDF:

回覆。输出不是PDF:

To convert to specific output formats, you could use (list not complete):

要转换为特定的输出格式,您可以使用(列表不完整):

--convert-to html:HTML
--convert-to html:draw_html_Export                 # force "Draw" to generate the HTML
--convert-to mediawiki:MediaWiki_Web               # generate MediaWiki output
--convert-to csv:"Text - txt - csv (StarCalc)"     # generate CSV spreadsheet output
--convert-to pptx:"Impress MS PowerPoint 2007 XML" # generate PPTX
--convert-to ppt:"MS PowerPoint 97"                # generate PPT
--convert-to wmf:impress_wmf_Export                # force "Impress" to generate the WMF
--convert-to wmf:draw_wmf_Export                   # force "Draw" to generate the WMF
--convert-to emf:impress_emf_Export                # force "Impress" to generate the EMF
--convert-to emf:draw_emf_Export                   # force "Draw" to generate the EMF
--convert-to svg:impress_svg_Export                # force "Impress" to generate the SVG
--convert-to svg:draw_svg_Export                   # force "Draw" to generate the SVG
--convert-to xlsx:"Calc MS Excel 2007 XML"         # generate XLSX
--convert-to xls:"MS Excel 97"                     # generate XLS like Excel 97
--convert-to xls:"MS Excel 95"                     # generate XLS like Excel 95
--convert-to xls:"MS Excel 5.0/95"                 # generate XLS like Excel 5.0/95

#2


4  

Might sound stupid but I suffered from just this: In Ubuntu 14.04 it is not enough to install only the package libreoffice-core or -common to convert to PDF, but you need to install libreoffice-writer instead/additionally. The important thing to note is that libreoffice-core|common seems to bring in some functional libreoffice base, hence the name ;-), which doesn't error out if executed to convert some file, but instead just seems to wait on some socket or such for input or whatever... After I installed libreoffice-writer, which has -core|common as a dependency, converting some ODT file to PDF worked like a charm with the exact same command line like used before.

可能听起来很愚蠢,但我还是遭受了这样的困难:在Ubuntu 14.04中,只安装libreoffice-core包或者-common转换为PDF是不够的,但你需要安装libreoffice-writer而不是另外。需要注意的重要一点是,libreoffice-core | common似乎带来了一些功能性的libreoffice基础,因此名称;-),如果执行转换某些文件,它不会出错,而只是似乎等待某个套接字或者这样的输入或者其他......在我安装了libreoffice-writer之后,将-core | common作为依赖项,将一些ODT文件转换为PDF就像一个魅力一样,使用与之前使用的完全相同的命令行。

Seems a bit crazy that the application looks like it works somehow, but simply couldn't ever because of missing packages, and doesn't tell anything about it.

似乎有点疯狂,应用程序看起来像是以某种方式工作,但根本不可能因为缺少包,并且没有告诉它任何事情。

#3


2  

Update

更新

The current Version of libreoffice is working: v5.2.6.2 (mac)

当前版本的libreoffice正在运行:v5.2.6.2(mac)

I'm using the following command

我正在使用以下命令

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf --outdir . the_file_to_convert

OLD

It seems that the conversion is not working in newer version (> 4.2.4.2) I'm using libreoffice 4.2.4.2 You can download older versions from http://downloadarchive.documentfoundation.org/libreoffice/old/4.2.4.2/

似乎转换不适用于较新版本(> 4.2.4.2)我正在使用libreoffice 4.2.4.2您可以从http://downloadarchive.documentfoundation.org/libreoffice/old/4.2.4.2/下载旧版本

  • linux (using the deb package):

    linux(使用deb包):

    libreoffice4.2 --headless --convert-to pdf  myfile.odt
    
  • windows:

    视窗:

    swriter.exe --headless --convert-to pdf myfile.odt
    

#4


0  

I'm using LibreOffice 4.2.8.2 too (on GNU/Linux) but I tried to convert a DOC file to a HTML file. I've installed libreoffice-headless, but the terminal was hanging too. I've tried each bullet of Kurt Pfeifle, but it was not working…

我也在使用LibreOffice 4.2.8.2(在GNU / Linux上),但我试图将DOC文件转换为HTML文件。我已经安装了libreoffice-headless,但终端也挂了。我已经尝试了Kurt Pfeifle的每一颗子弹,但它没有工作......

The solution was simple: installing libreoffice-writer (maybe libreoffice-filters is ok too, but it depends on libreoffice-writer plus the other big components of LibreOffice).

解决方案很简单:安装libreoffice-writer(也许libreoffice-filters也可以,但它依赖于libreoffice-writer以及LibreOffice的其他重要组件)。

Hope this will help.

希望这会有所帮助。

#1


68  

  1. I would first of all try it with giving absolute paths to the command.

    我首先尝试给出命令的绝对路径。

  2. I suspect that the libreoffice binary does not work -- you have to locate the soffice binary and see if that works.

    我怀疑libreoffice二进制文件不起作用 - 你必须找到soffice二进制文件,看看它是否有效。

  3. Then, your --convert-to pdf is not sufficient. It needs to be:

    然后,你的--convert-to pdf是不够的。它需要是:

    --convert-to pdf:writer_pdf_Export
    

    Be sure to follow exactly this capitalization!

    一定要完全遵循这个大写!

  4. Next, the command will not work if there is already a LibreOffice GUI instance up and running on your system. It is caused by bug known since 2011. Add this additional parameter to your command:

    接下来,如果已在系统上启动并运行LibreOffice GUI实例,则该命令将不起作用。它是由自2011年以来已知的错误引起的。将此附加参数添加到您的命令:

     "-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}"
    

    This will create a new, separate environment which can be used by a second, headless LO instance without interfering with a possibly running first GUI LO instance started by the same user.

    这将创建一个新的独立环境,该环境可由第二个无头LO实例使用,而不会干扰由同一用户启动的可能正在运行的第一个GUI LO实例。

  5. Also, make sure that the --outdir /pdf you specify does exist, and that you have write permission to it. Or, rather use a different output dir. Even if it is just for the first testing and this debugging round:

    此外,请确保您指定的--outdir / pdf确实存在,并且您具有写入权限。或者,而是使用不同的输出目录。即使它仅用于第一次测试和本次调试:

    $ mkdir ${HOME}/lo_pdfs
    
  6. Hence:

    因此:

    /path/to/soffice                                                     \
      --headless                                                         \
      "-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}" \
      --convert-to pdf:writer_pdf_Export                                 \
      --outdir ${HOME}/lo_pdfs                                           \
    /path/to/test.docx
    

    This works for me on Mac OS X Mavericks 10.9.5 with LibreOffice v4.4.3.2 (using my specific path for the binary soffice which will be different for you anyway...).

    这适用于Mac OS X Mavericks 10.9.5和LibreOffice v4.4.3.2(使用我对二进制soffice的特定路径,无论如何都会对你不同......)。

    If all this doesn't work:

    如果这一切都不起作用:

  7. It may be a problem with the specific DOCX file you try the command with... So create a very simple DOCX document of your own first. Use LibreOffice itself for this. Write "Hello World!" on an otherwise empty page. Save it as DOCX.

    对于您尝试使用命令的特定DOCX文件可能存在问题...因此,首先创建一个非常简单的DOCX文档。为此使用LibreOffice本身。写下“Hello World!”在一个空的页面上。将其另存为DOCX。

  8. Try again. Does it work with the simple DOCX?

    再试一次。它与简单的DOCX一起使用吗?

  9. If it again doesn't work, repeat step 7, but save as ODT this time.

    如果它再次不起作用,请重复步骤7,但这次保存为ODT。

  10. Repeat step 8, but make sure to reference the ODT this time.

    重复步骤8,但这次确保参考ODT。

  11. Last: Use full path to soffice, to soffice.bin and to libreoffice and run each with the -h parameter:

    最后:使用soffice的完整路径,soffice.bin和libreoffice并使用-h参数运行每个:

    $ /path/to/libreoffice -h
    $ /path/to/soffice -h
    $ /path/to/soffice.bin -h
    
    • Do you even get an output here?
    • 你甚至在这里得到一个输出?
    • For which one of the three binaries/symlinks?
    • 三个二进制文件/符号链接中的哪一个?
    • Record the outputs.
    • 记录输出。
    • Tell us your outputs!!!
    • 告诉我们你的输出!

    Compare them to the command line you used:

    将它们与您使用的命令行进行比较:

    Are there any changes in parameter names, capitalizations, number of dashes used, etc.??

    参数名称,大小写,使用的破折号等都有变化吗?

    For comparison, my own output is here:

    为了比较,我自己的输出在这里:

    $ /Applications/LibreOffice.app/Contents/MacOS/soffice -h
    
      LibreOffice 4.4.3.2 88805f81e9fe61362df02b9941de8e38a9b5fd16
    
      Usage: soffice [options] [documents...]
    
      Options:
      --minimized    keep startup bitmap minimized.
      --invisible    no startup screen, no default document and no UI.
      --norestore    suppress restart/restore after fatal errors.
      --quickstart   starts the quickstart service
      --nologo       don't show startup screen.
      --nolockcheck  don't check for remote instances using the installation
      --nodefault    don't start with an empty document
      --headless     like invisible but no userinteraction at all.
      --help/-h/-?   show this message and exit.
      --version      display the version information.
      --writer       create new text document.
      --calc         create new spreadsheet document.
      --draw         create new drawing.
      --impress      create new presentation.
      --base         create new database.
      --math         create new formula.
      --global       create new global document.
      --web          create new HTML document.
      -o             open documents regardless whether they are templates or not.
      -n             always open documents as new files (use as template).
    
      --display <display>
            Specify X-Display to use in Unix/X11 versions.
      -p <documents...>
            print the specified documents on the default printer.
      --pt <printer> <documents...>
            print the specified documents on the specified printer.
      --view <documents...>
            open the specified documents in viewer-(readonly-)mode.
      --show <presentation>
            open the specified presentation and start it immediately
      --accept=<accept-string>
            Specify an UNO connect-string to create an UNO acceptor through which
            other programs can connect to access the API
      --unaccept=<accept-string>
            Close an acceptor that was created with --accept=<accept-string>
            Use --unnaccept=all to close all open acceptors
      --infilter=<filter>[:filter_options]
            Force an input filter type if possible
            Eg. --infilter="Calc Office Open XML"
                --infilter="Text (encoded):UTF8,LF,,,"
      --convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir output_dir] files
            Batch convert files.
            If --outdir is not specified then current working dir is used as output_dir.
            Eg. --convert-to pdf *.doc
                --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc
                --convert-to "html:XHTML Writer File:UTF8" *.doc
                --convert-to "txt:Text (encoded):UTF8" *.doc
      --print-to-file [-printer-name printer_name] [--outdir output_dir] files
            Batch print files to file.
            If --outdir is not specified then current working dir is used as output_dir.
            Eg. --print-to-file *.doc
                --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc
      --cat files
            Dump text content of the files to console
            Eg. --cat *.odt
      --pidfile file
            Store soffice.bin pid to file.
      -env:<VAR>[=<VALUE>]
            Set a bootstrap variable.
            Eg. -env:UserInstallation=file:///tmp/test to set a non-default user profile path.
    
      Remaining arguments will be treated as filenames or URLs of documents to open.
    
  12. Add one more argument to your command line to enforce the application of an input filter when soffice opens your DOCX file:

    在soffice打开DOCX文件时,在命令行中再添加一个参数以强制应用输入过滤器:

    --infilter="Microsoft Word 2007/2010/2013 XML"
    

    or

    要么

    --infilter="Microsoft Word 2007/2010/2013 XML"
    --infilter="Microsoft Word 2007-2013 XML"
    --infilter="Microsoft Word 2007-2013 XML Template"
    --infilter="Microsoft Word 95 Template"
    --infilter="MS Word 95 Vorlage"
    --infilter="Microsoft Word 97/2000/XP Template"
    --infilter="MS Word 97 Vorlage"
    --infilter="Microsoft Word 2003 XML"
    --infilter="MS Word 2003 XML"
    --infilter="Microsoft Word 2007 XML Template"
    --infilter="MS Word 2007 XML Template"
    --infilter="Microsoft Word 6.0"
    --infilter="MS WinWord 6.0"
    --infilter="Microsoft Word 95"
    --infilter="MS Word 95"
    --infilter="Microsoft Word 97/2000/XP"
    --infilter="MS Word 97"
    --infilter="Microsoft Word 2007 XML"
    --infilter="MS Word 2007 XML"
    --infilter="Microsoft WinWord 5"
    --infilter="MS WinWord 5"
    

Update

LibreOffice cannot only convert DOCX to PDF on the command line:

LibreOffice不仅可以在命令行上将DOCX转换为PDF:

  • It can process any input format which it can open and "read": DOC, XLS, XLSX, PPT, PPTX, ...
  • 它可以处理任何可以打开和“读取”的输入格式:DOC,XLS,XLSX,PPT,PPTX,......
  • It can convert to any output format which it can "write": DOC, XLS, XLSX, PPT, PPTX, ...
  • 它可以转换为任何可以“写”的输出格式:DOC,XLS,XLSX,PPT,PPTX,......

Of course, results will never be perfect, and sometimes they will even be un-acceptable to you.

当然,结果永远不会是完美的,有时它们甚至会让你无法接受。

Re. output as PDF:

回覆。输出为PDF:

To control, which LibreOffice component generates PDF output, you can use these variants:

要控制哪个LibreOffice组件生成PDF输出,您可以使用以下变体:

--convert-to pdf:writer_pdf_Export
--convert-to pdf:calc_pdf_Export
--convert-to pdf:draw_pdf_Export
--convert-to pdf:impress_pdf_Export
--convert-to pdf:writer_web_pdf_Export

Re. input which is not DOCX:

回覆。输入不是DOCX:

To enforce infilters for non-DOCX input formats, you could use (list is not complete):

要强制使用非DOCX输入格式的渗透程序,您可以使用(列表不完整):

--infilter="HTML Document"                      # for HTML input
--infilter="MediaWiki"                          # for MediaWiki input
--infilter="Text CSV"                           # for CSV spreadsheet input
--infilter="Microsoft PowerPoint 2007/2010 XML" # for PPTX input
--infilter="Microsoft PowerPoint 97/2000/XP"    # for PPT input
--infilter="Windows Metafile"                   # for WMF input
--infilter="Enhanced Metafile"                  # for EMF input
--infilter="Scalable Vector Graphics"           # for SVG input
--infilter="Microsoft Excel 2007/2010 XML"      # for XLSX input
--infilter="Microsoft Excel 97/2000/XP"         # for XLS input
--infilter="Microsoft Excel 95"                 # for some XLS input
--infilter="Microsoft Excel 5.0"                # for some XLS input

Re. output which is not PDF:

回覆。输出不是PDF:

To convert to specific output formats, you could use (list not complete):

要转换为特定的输出格式,您可以使用(列表不完整):

--convert-to html:HTML
--convert-to html:draw_html_Export                 # force "Draw" to generate the HTML
--convert-to mediawiki:MediaWiki_Web               # generate MediaWiki output
--convert-to csv:"Text - txt - csv (StarCalc)"     # generate CSV spreadsheet output
--convert-to pptx:"Impress MS PowerPoint 2007 XML" # generate PPTX
--convert-to ppt:"MS PowerPoint 97"                # generate PPT
--convert-to wmf:impress_wmf_Export                # force "Impress" to generate the WMF
--convert-to wmf:draw_wmf_Export                   # force "Draw" to generate the WMF
--convert-to emf:impress_emf_Export                # force "Impress" to generate the EMF
--convert-to emf:draw_emf_Export                   # force "Draw" to generate the EMF
--convert-to svg:impress_svg_Export                # force "Impress" to generate the SVG
--convert-to svg:draw_svg_Export                   # force "Draw" to generate the SVG
--convert-to xlsx:"Calc MS Excel 2007 XML"         # generate XLSX
--convert-to xls:"MS Excel 97"                     # generate XLS like Excel 97
--convert-to xls:"MS Excel 95"                     # generate XLS like Excel 95
--convert-to xls:"MS Excel 5.0/95"                 # generate XLS like Excel 5.0/95

#2


4  

Might sound stupid but I suffered from just this: In Ubuntu 14.04 it is not enough to install only the package libreoffice-core or -common to convert to PDF, but you need to install libreoffice-writer instead/additionally. The important thing to note is that libreoffice-core|common seems to bring in some functional libreoffice base, hence the name ;-), which doesn't error out if executed to convert some file, but instead just seems to wait on some socket or such for input or whatever... After I installed libreoffice-writer, which has -core|common as a dependency, converting some ODT file to PDF worked like a charm with the exact same command line like used before.

可能听起来很愚蠢,但我还是遭受了这样的困难:在Ubuntu 14.04中,只安装libreoffice-core包或者-common转换为PDF是不够的,但你需要安装libreoffice-writer而不是另外。需要注意的重要一点是,libreoffice-core | common似乎带来了一些功能性的libreoffice基础,因此名称;-),如果执行转换某些文件,它不会出错,而只是似乎等待某个套接字或者这样的输入或者其他......在我安装了libreoffice-writer之后,将-core | common作为依赖项,将一些ODT文件转换为PDF就像一个魅力一样,使用与之前使用的完全相同的命令行。

Seems a bit crazy that the application looks like it works somehow, but simply couldn't ever because of missing packages, and doesn't tell anything about it.

似乎有点疯狂,应用程序看起来像是以某种方式工作,但根本不可能因为缺少包,并且没有告诉它任何事情。

#3


2  

Update

更新

The current Version of libreoffice is working: v5.2.6.2 (mac)

当前版本的libreoffice正在运行:v5.2.6.2(mac)

I'm using the following command

我正在使用以下命令

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf --outdir . the_file_to_convert

OLD

It seems that the conversion is not working in newer version (> 4.2.4.2) I'm using libreoffice 4.2.4.2 You can download older versions from http://downloadarchive.documentfoundation.org/libreoffice/old/4.2.4.2/

似乎转换不适用于较新版本(> 4.2.4.2)我正在使用libreoffice 4.2.4.2您可以从http://downloadarchive.documentfoundation.org/libreoffice/old/4.2.4.2/下载旧版本

  • linux (using the deb package):

    linux(使用deb包):

    libreoffice4.2 --headless --convert-to pdf  myfile.odt
    
  • windows:

    视窗:

    swriter.exe --headless --convert-to pdf myfile.odt
    

#4


0  

I'm using LibreOffice 4.2.8.2 too (on GNU/Linux) but I tried to convert a DOC file to a HTML file. I've installed libreoffice-headless, but the terminal was hanging too. I've tried each bullet of Kurt Pfeifle, but it was not working…

我也在使用LibreOffice 4.2.8.2(在GNU / Linux上),但我试图将DOC文件转换为HTML文件。我已经安装了libreoffice-headless,但终端也挂了。我已经尝试了Kurt Pfeifle的每一颗子弹,但它没有工作......

The solution was simple: installing libreoffice-writer (maybe libreoffice-filters is ok too, but it depends on libreoffice-writer plus the other big components of LibreOffice).

解决方案很简单:安装libreoffice-writer(也许libreoffice-filters也可以,但它依赖于libreoffice-writer以及LibreOffice的其他重要组件)。

Hope this will help.

希望这会有所帮助。