更新时间:2023-11-11 22:26:28
如果是Office文档,一种选择是在无头模式下使用openoffice.请参阅此处以获取显示以下内容的python脚本: http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.html
If it is an office document, one option would be to use openoffice in headless mode. See here for a python script that shows how: http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.html
如果它是任何其他类型的文档(例如您自己的XML文档),则您需要做更多的工作.使用XSL定义到docbook格式的翻译,然后使用docbook工具生成PDF(以及其他各种格式),我取得了一些成功.如果您需要对外观进行更精确的控制,也可以使用XSL直接使用PDF.
If it is any other kind of document (e.g. your own XML document), then you would need to do a bit more work. I have had some success using XSL to define a translation to docbook format, then using docbook tools to generate the PDF (and various other formats). You could also use XSL to go straight to PDF if you need more precise control over how things look.