OpenOffice 命令行 PDF 创建
我有一些用 OpenOffice 编写的文档,我想在最终的构建交付中包含其中一些 PDF 文件。 我想使用自动构建脚本来完成此操作。
有没有办法使用命令行命令从 OpenOffice 创建 PDF 文件?
I have some documentation written in OpenOffice, and I would like to include some of it as PDF files in the final build deliveries. I would like to do this with the automated build script.
Is there a way to create a PDF file from OpenOffice with a command line command?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
截至 2012 年 9 月,LibreOffice 可以从命令行将文档转换为 PDF:
它还具有批量转换支持:
将所有与模式匹配的文件转换为相应的 PDF 文件。
运行此命令时不得打开任何 LibreOffice 窗口。
As of September 2012, LibreOffice can convert a document to PDF from the command line:
It also has bulk conversion support:
will convert all the files that match the pattern to the corresponding PDF file.
There must be no LibreOffice windows open when you run this command.
有一个很棒的工具叫做“unoconv”,它在我的 Ubuntu 存储库中。 它转换 ODF、.ods, ... 为 PDF,我认为也为其他格式。
我还可以将 PowerPoint 文件转换为 PDF。
There is a great tool called "unoconv", it was in my Ubuntu repository. It converts ODF, .ods, ... to PDF and I think to other formats too.
I also could convert PowerPoint files to PDF.
Art of Solving 还有一个非常好的 API 来执行 Java 中的转换。 它有点慢,但很简单。 这就是我使用它的方式:
您可以用它创建一个 jar 并从命令行处理它。
Art of Solving has also a very good API to perform the conversion in Java. It is a little slow but it is simple enough. This is how I use it:
You can create a jar with that and process it from the command line.
虽然这个问题有点老了,但这里是为了记录 LibreOffice 解决方案的一些常见陷阱:
如果
lowriter
不适合您,因为它忽略命令行参数并调出gui 只需尝试调用libreoffice
或loffice
二进制文件:loffice --headless --convert-to pdf yourfile.odt
如果您收到此消息
错误:请重新验证输入参数...
尝试以 root 身份运行它(例如通过 sudo)。 这对我在安装了 LibreOffice 3 的 Ubuntu 12.04 LTS 上有所帮助,也可能是在没有正确配置的情况下此转换无法在网络服务器上运行的原因(Libreoffice --headless 拒绝转换,除非 root,否则无法在 PHP 脚本中工作)
同时确保您没有运行任何其他 LibreOffice 实例,否则它会默默地失败并且根本不进行任何转换。
Though this question is a little old, here something for the purpose of documenting some common pitfalls with the LibreOffice solution:
If
lowriter
does not work for you because it ignores command line parameters and brings up the gui just try calling thelibreoffice
orloffice
binaries:loffice --headless --convert-to pdf yourfile.odt
If you get this message
Error: Please reverify input parameters...
try running it as root (e.g. via sudo). This helped me on Ubuntu 12.04 LTS with LibreOffice 3 installed and may also be a reason why this conversion is not running on a webserver without proper configuration (Libreoffice --headless refuses to convert unless root, won't work from PHP script)
Also make sure that you do not have any other instances of LibreOffice running or it will just fail silently and do no conversion at all.
有 anytopdf。 我自己没试过。
引用...
There is anytopdf. Haven't tried it myself.
Quoting...