如何在Linux/PHP堆栈上将文档转换为PDF? [英] How to convert documents to PDF on a Linux/PHP stack?

查看:54
本文介绍了如何在Linux/PHP堆栈上将文档转换为PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站上显示文档.该服务器托管在Debian机器上.我当时想我可以允许上传支持文档,然后使用Linux应用程序或PHP应用程序将文档转换为PDF并将其显示在HTML页面中.有没有允许我执行此操作的API或二进制文件?

I want to display documents on my website. The server is hosted on a Debian machine. I was thinking I can allow the upload of support documents then use a Linux app or PHP app to convert the doc into PDF and display that in an HTML page. Are there any APIs or binaries that allow me to do this?

推荐答案

如果是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.

这篇关于如何在Linux/PHP堆栈上将文档转换为PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆