- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
在使用这个旨在将 DOCX 转换为 PDF 的 LibreOffice 命令后,我必须等待很长时间:
libreoffice --headless --convert-to pdf test.docx --outdir /pdf
但我没有得到任何回应,也没有错误。没有文件被转换。看起来终端挂了。
那么,有什么方法可以跟踪错误吗?
最佳答案
我会首先尝试为命令提供绝对路径。
我怀疑 libreoffice
二进制文件不起作用——您必须找到 soffice
二进制文件并查看它是否有效。
那么,您的 --convert-to pdf
是不够的。它必须是:
--convert-to pdf:writer_pdf_Export
一定要严格遵守这个大写字母!
接下来,如果您的系统上已经启动并运行了 LibreOffice GUI 实例,则该命令将不起作用。这是由错误引起的 known since 2011 .将此附加参数添加到您的命令中:
"-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}"
这将创建一个新的独立环境,可供第二个 headless LO 实例使用,而不会干扰由同一用户启动的可能正在运行的第一个 GUI LO 实例。
此外,请确保您指定的 --outdir/pdf
确实存在,并且您有写入权限。或者,而是使用不同的输出目录。即使只是第一次测试和这一轮调试:
$ mkdir ${HOME}/lo_pdfs
因此:
/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
这对我在 Mac OS X Mavericks 10.9.5 和 LibreOffice v4.4.3.2 上有效(使用我的二进制文件 soffice
的特定路径,无论如何这对你来说都是不同的...)。
如果这一切都不起作用:
您尝试使用命令的特定 DOCX 文件可能有问题...因此,请先创建一个您自己的非常简单的 DOCX 文档。为此使用 LibreOffice 本身。写“ Hello World !”在一个空白的页面上。将其保存为 DOCX。
再试一次。 它适用于简单的 DOCX 吗?
如果还是不行,重复第 7 步,但这次另存为 ODT。
重复第 8 步,但确保这次引用 ODT。
最后:使用 soffice
、soffice.bin
和 libreoffice
的完整路径,并使用 运行每个-h
参数:
$ /path/to/libreoffice -h
$ /path/to/soffice -h
$ /path/to/soffice.bin -h
将它们与您使用的命令行进行比较:
Are there any changes in parameter names, capitalizations, number of dashes used, etc.??
为了比较,我自己的输出在这里:
$ /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.
在命令行中再添加一个参数,以在soffice
打开您的 DOCX 文件时强制应用输入过滤器:
--infilter="Microsoft Word 2007/2010/2013 XML"
或
--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"
LibreOffice 不能只在命令行上将 DOCX 转换为 PDF:
当然,结果永远不会是完美的,有时甚至会让你无法接受。
回复。输出为 PDF:
要控制哪个 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
回复。 非 DOCX 的输入:
要对非 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
回复。 非 PDF 的输出:
要转换为特定的输出格式,您可以使用(列表不完整):
--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
关于libreoffice - 命令 `libreoffice --headless --convert-to pdf test.docx --outdir/pdf` 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30349542/
我使用 apt-get install libgtest-dev 安装了 gtest 我正在尝试检查它是否有效。 所以我在 eclipse 中编写了简单的测试代码。 但是有错误, undefined
($test) = (@test); $test = @test; 用一个括号括住变量,它访问数组的第一个元素。我找不到有关数组括号的信息。 最佳答案 ($test) = (@test); 这会将@t
在 clojure.test 中有一个允许同时测试多个设备的宏: are . 在 clojure.test 中,可以结合 are宏与 testing ? IE。就像是: (are [scenario
通常,Rust 中的单元测试被赋予一个单独的模块,该模块使用 #[cfg(test)] 进行条件编译: #[cfg(test)] mod tests { #[test] fn test
在过去,编程很少涉及猜测。我会写几行代码,一眼就能 100% 确定代码做什么和不做什么。错误主要是拼写错误,但与功能无关。 我相信在过去的几年中存在这种“试错”编程的趋势:编写代码(就像在草稿中一样)
在building the Kotlin compiler之后(在提交e80a01a处): ./gradlew dist 测试未成功通过: ./gradlew compiler:test 由于很少有测
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 9 年前。 Improve this qu
最近一直在思考模糊测试和猴子测试的区别。根据 wiki,猴子测试似乎“只是”一个单元测试,而模糊测试则不是。安卓有 UI/Application Exerciser monkey而且它看起来不像是单元
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
现在我正在使用 CMake 设置一个 C++ 测试环境。其实我已经意识到我想做什么,但我对两种不同的测试输出风格感到困惑。在我下面的示例中,“make test”实际上做了什么?我认为“make te
在 VS2012 中运行单个测试时,测试资源管理器底部会显示一个窗口,其中包括(假设失败)旁边带有“测试失败”的红色图标。紧随其后的是带有“已用时间”的失败消息。 我想简单地知道是否有办法清除这个窗口
bash 是否可以从 shell 执行命令,如果它返回某个值(或空值)则执行命令? if [ "echo test" == "test"]; then echo "echo test output
这个问题在这里已经有了答案: 8年前关闭。 Possible Duplicate: What is a smoke testing and what will it do for me? 为什么“冒烟
x86 下的并行编程可能很困难,尤其是在多核 CPU 下。假设我们有多核 x86 CPU 和更多不同的多线程通信组合。 单一作者和单一读者 单个读者多个作者 多个读者和单个作者 多个读者和多个作者 那
我使用Ctest来运行一堆使用add_test()注册的Google测试。当前,这些测试没有任何参数。但是,我想在运行--gtest_output=xml时为它们提供所有参数(所有参数都通用,特别是c
我有下表和数据: CREATE TABLE `test` ( `id` int(11) NOT NULL auto_increment, `name` varchar(8) NOT NULL,
go test 的两个标志 -parallel 和 -test.parallel 之间的区别以及哪个标志优先? -parallel n Allow parallel execu
在我的组件 AudioPlayer 中,我有一个 download() 方法: download() { this.audio.pause(); window.open(this.file,
您必须承认,对于 Rails 和数据库的新手来说,rubyonrails.org 上的官方解释使所有这四个任务听起来完全一样。引用: rake db:test:clone Recreate the
我过去曾讨论过这个话题,我想我可能知道答案,但我无法正确地表达出来。 这是我认为我所知道的: 如果您在编写测试之前已经有了关于事情如何工作的想法,那么我怀疑您是测试优先而不是测试驱动,因此您首先编写测
我是一名优秀的程序员,十分优秀!