I have a word f开发者_如何转开发ile () which has many text fields and a startup macro, which, when word file is opened sets, values to fields from file properties ?!
So basically, I need API that can convert MS word (MS Office XP) to PDF. It would be great if API had a startMacro function(), but I know that is not gonna happen.
I have tried Apache POI, but there is so little support to old word format. Also I read about OO API, but I'm not able to have an OO instance running on the server.
I worked on a similar problem a year ago. I finally settled with using OpenOffice.org I'm not positive OpenOffice.org will meet your exact needs here, but I would suggest looking at it.
Can you run OpenOffice on another host (that your server can reach)? If so, you can use the OpenOffice api to open a socket to that other host to do the conversion. Docmosis is a Java library that provides an API for populating DOC and ODT files and having the formats converted. It still relies on OpenOffice being installed somewhere that your server can reach, but you don't have to configure much else.
If your documents were a newer format (Doc-xml) then you could process them directly from Java with XML, but it would be a pretty big learning curve.
If its just a single Word file, why don't you convert it to docx, and then use docx4j (or POI)?
If you need to convert on demand, you could use http://code.google.com/p/jodconverter/ (on another server, if you aren't allowed OO on your server).
精彩评论