How do I convert RTF to PDF from my PHP web page using OpenOffice?

梦想的初衷 提交于 2019-11-29 16:45:29

Yay!!!! With the help of a super-duper brainiac here at work, I now have a solution that actually WORKS! Forget all the code I posted earlier, I'm not using any of it anymore. If anyone else needs to convert word docs to PDF from PHP on IIS here's what will work:

1) Install OpenOffice, of course

2) Go here:
http://www.artofsolving.com/opensource/pyodconverter, and download DocumentConverter.py

3) Place DocumentConverter.py in the same OpenOffice folder where soffice.exe resides, probably C:\Program Files\OpenOffice.org 3\program

4) Start OpenOffice as a service:

a)You can do this from the command line:

soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -headless -norestore -nologo -nofirststartwizard

b) Or follow the directions on this website and setup OpenOffice as a windows service with the proper parameters: http://www.artofsolving.com/node/10

5) From PHP run this command:

exec('python "C:\Program Files\OpenOffice.org 3\program\DocumentConverter.py" path_to_doc\test.doc path_to_output_pdf\test.pdf"');

Yay, what a neat and pretty solution!

That sounds like open office needs to interact with the desktop and isn't allowed to since it was invoked by a service without the SERVICE_INTERACTIVE_PROCESS flag.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!