views:

1525

answers:

4

Hi, Does anyone know any good library (free or commercial) for Delphi that can read/parse/modify MS Word documents (preferably with Word 2007 support) without MS Word OLE Automation? I've found some for .Net, but none for Delphi.

For example, here are two .Net/Java libraries - Aspose, Word.net

I don't want to add .Net dependencies in my application. A library that compiles right inside the exe will be most preferable, but any ActiveX will also work.

Thank you.

A: 

You could use the .NET library and create an ActiveX/COM wrapper for it, which you can use from Delphi.

This article describes the interop possibilities between COM and .NET. Look at "Using .NET Objects from COM"

DR
I thought about it. That's the last choice for me as I don't want to add dependency on .Net framework
J K Kunil
Depending on your budget, you could use a .NET linker on the wrapper.http://www.remotesoft.com/linker/
Craig Peterson
+2  A: 

I know (a simple non-commercial) variant for Excel, but not for Word. And not for very new ones.

DR: the problem is that that needs Word installed. The options above don't. Moreover OLE can get slow, e.g. when you want to make umpteen personal letters for a mailing in it.

The only other routine I can imagine is automating Open Office. But that has the same speed problems (or worse) probably, so that would depend on why you exactly want this.

The Office format is horribly complicated, and nearly every solution will be more expensive (in either vast time or money) than just coughing up a copy of word. (and with OOo you could even avoid that)

Marco van de Voort
The OP said, he had a .NET library which supports native access. Why does creating a wrapper for that library introduce a dependence on a Word installation?
DR
It doesn't. I misread I guess. Anyway, it makes no sense to bicker over that without knowing what he exactly wants to avoid. Speed/money/dependancies.
Marco van de Voort
I don't think the .NET way is worse though than the OOo way. Except that the latter is free.
Marco van de Voort
I need it for Speed, and avoiding COM automation automatically get rid of dependency. But depending on a .Net library is even worse for me. A 3MB exe will require 24+MB of framework :(
J K Kunil
+1  A: 

Scalabium has TSMWordDocument component that can extract the plain text and is entirely in native code. It doesn't support modifying them or extracting graphics/styles though. Their SM Export component set allows generating Word documents, but I don't think it supports reading them. We use the TSMWordDocument one and it's ridiculously fast compared to COM automation. The only downside we've hit is that it even though it's Delphi 2009 compatible, it still doesn't handle international text unless the system codepage matches (so Japanese on a Japanese system is ok, but not on an English one).

Craig Peterson
If it cannot modify document, TSMWordDocument is not for me in this case. Thanks for your suggestion though...
J K Kunil
A: 

Microsoft's formats are so complex that it is a lot of work to write, and keep up to date, a set of components to do what you want without automation.

There is Winsoft's Office Component Suite, but you'll see that hasn't been updated to work with the latest version of Office, or with Delphi 2009+.

lkessler