开发者

Manipulating word docs (doc, docx, etc) in linux with php or ruby

开发者 https://www.devze.com 2023-04-02 09:49 出处:网络
I have users uploading word documents on my webpage. I need to open these documents, display them in html, and allow the user to download a manipulated version.

I have users uploading word documents on my webpage. I need to open these documents, display them in html, and allow the user to download a manipulated version.

My webserver allows me to use PHP and Rails. So a solution in either language would be acceptable.

I have found numerous other posts in my research such as LiveDocx which seems to be more geared only towards creating word documents with known templates. And Java POI which isn't supported by my we开发者_如何学Gobserver. I have also found information on docx such that I can just unzip it and tweak the xml files -- which would be great except that I would like to accept more extensions than docx alone.

This is my last ditch attempt to find another solution to this problem. Any suggestions? Am I just going to have to switch to a windows server? (even with a windows server, can I do what I want?)


You are not saying what kinds of manipulations you need to apply, nor whether you can install anything new on the server, but if you can, you could install OpenOffice (or Libreoffice as pointed out by @Rok) and access it from your script through the command line.

OoO can convert all sorts of office formats, including past and current Microsoft office ones, PDF and HTML, and is I think the best tool available for this kind of job.

You could display documents in a converted HTML view, or if that doesn't work (I imagine it would break a lot inside complex documents, if it works at all!), a PDF embedded in an iframe, which should be just as well.

This OpenOffice.org Forum entry provides some starting points.

Edit: If you can't install any software, there are third party web services that do conversions, most for a fee. Here is an example.


I would do it like this:

  1. Install libreoffice on the server
  2. Call libreoffice python scripting with either php or ruby

And don't switch to windows, it won't make the problem easier.

0

精彩评论

暂无评论...
验证码 换一张
取 消