OpenOffice 命令行 PDF 创建

发布于 2024-07-10 05:46:16 字数 121 浏览 9 评论 0原文

我有一些用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

迟月 2024-07-17 05:46:16

截至 2012 年 9 月,LibreOffice 可以从命令行将文档转换为 PDF:

lowriter --headless --convert-to pdf yourfile.odt

它还具有批量转换支持:

lowriter --headless --convert-to pdf yourfiles*.odt

将所有与模式匹配的文件转换为相应的 PDF 文件。

运行此命令时不得打开任何 LibreOffice 窗口。

As of September 2012, LibreOffice can convert a document to PDF from the command line:

lowriter --headless --convert-to pdf yourfile.odt

It also has bulk conversion support:

lowriter --headless --convert-to pdf yourfiles*.odt

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.

佞臣 2024-07-17 05:46:16

有一个很棒的工具叫做“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.

花间憩 2024-07-17 05:46:16

Art of Solving 还有一个非常好的 API 来执行 Java 中的转换。 它有点慢,但很简单。 这就是我使用它的方式:

        File inputFile = new File("C:\\oreyes\\hola.doc"); 
        File outputFile = new File("C:\\oreyes\\hola.pdf"); 
        OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
        try { 
            connection.connect(); 
        } catch(Exception e) {}

        DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
        converter.convert(inputFile, outputFile); 
        connection.disconnect(); 

您可以用它创建一个 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:

        File inputFile = new File("C:\\oreyes\\hola.doc"); 
        File outputFile = new File("C:\\oreyes\\hola.pdf"); 
        OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
        try { 
            connection.connect(); 
        } catch(Exception e) {}

        DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
        converter.convert(inputFile, outputFile); 
        connection.disconnect(); 

You can create a jar with that and process it from the command line.

泼猴你往哪里跑 2024-07-17 05:46:16

虽然这个问题有点老了,但这里是为了记录 LibreOffice 解决方案的一些常见陷阱:

  • 如果 lowriter 不适合您,因为它忽略命令行参数并调出gui 只需尝试调用 libreofficeloffice 二进制文件:

    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 the libreoffice or loffice 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.

蛮可爱 2024-07-17 05:46:16

anytopdf。 我自己没试过。

引用...

anytopdf 是一个 Perl 脚本,可将 OpenOffice.org、Microsoft Office(Word DOC、Excel XLS)、RTF、HTML 和其他 openoffice.org 可读文件格式转换为 PDF 格式。 如果当前用户的 OpenOffice.org 配置中尚不存在支持的“AnyToPDF”OpenOffice.org Basic 宏库,它将自动安装该宏库。

致力于和平、爱、理解和尊重一切众生。

There is anytopdf. Haven't tried it myself.

Quoting...

anytopdf is a perl script that converts OpenOffice.org, Microsoft Office (Word DOC, Excel XLS), RTF, HTML, and other openoffice.org readable file formats to the PDF format. It will automatically install the supporting 'AnyToPDF' OpenOffice.org Basic macro library in the current user's OpenOffice.org configuration if it's not already present.

Dedicated to peace, love, understanding and respect for all beings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文