Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: generating Word docs


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Last Post: Sep 2, 2016 2:09 AM Last Post By: Matthew Jones
David Schwartz

Posts: 137
Registered: 8/28/00
generating Word docs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 27, 2016 1:48 AM
This question is related to another one I just posted, but I thought it would be best to keep them separate.

Lawyer wants a tool to help compose pleadings and other legal docs, and he wants the output to be collected into a Word doc (docx, I presume).

There will be text as well as images inserted into the final documents.

Are there any libraries or approaches that work better than others for this?

(Gathering up the data seems pretty simple to me; getting it laid out nicely in a Word doc ... not so much.)
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: generating Word docs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 27, 2016 2:40 AM   in response to: David Schwartz in response to: David Schwartz
David Schwartz wrote:

This question is related to another one I just posted, but I thought
it would be best to keep them separate.

Lawyer wants a tool to help compose pleadings and other legal docs,
and he wants the output to be collected into a Word doc (docx, I
presume).

There will be text as well as images inserted into the final
documents.

Are there any libraries or approaches that work better than others
for this?

(Gathering up the data seems pretty simple to me; getting it laid out
nicely in a Word doc ... not so much.)

I would go with VCL and RTF. It would be easy to manipulate the RTF
templates and save it as a final document. Later that file can be
imported into Word to make the final formatting.
David Schwartz

Posts: 137
Registered: 8/28/00
Re: generating Word docs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 27, 2016 5:29 PM   in response to: Lajos Juhasz in response to: Lajos Juhasz
I didn't consider using RTF.

I have TRichView components. They'd work fine for this.

The only question is ... how well will Word respect the RTF formatting?

(Yeah, I know Microsoft originally DEFINED the RTF "standard", but like most of their "standards", they're the worst at following it.)

-David
Jon Robertson

Posts: 254
Registered: 9/22/99
Re: generating Word docs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 29, 2016 1:14 PM   in response to: David Schwartz in response to: David Schwartz
David Schwartz wrote:
I have TRichView components. They'd work fine for this.
I'll also recommend using TRichView. TRichView has a lot of flexibility and can be used to create some very nice documents that can be exported to several formats, including RTF.

Jon
David Schwartz

Posts: 137
Registered: 8/28/00
Re: generating Word docs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 1, 2016 9:51 PM   in response to: Jon Robertson in response to: Jon Robertson
Jon Robertson wrote:
David Schwartz wrote:
I have TRichView components. They'd work fine for this.
I'll also recommend using TRichView. TRichView has a lot of flexibility and can be used to create some very nice documents that can be exported to several formats, including RTF.

Jon

One other benefit that occurred to me is that by working with RTF, the custom meta-tags and related data will be ignored if the doc is imported into another RTF editor that doesn't know what those tags are.

I'm not sure if it brings them in and keeps them intact but simply fails to render them, or strips them out. Do you happen to know?

-David
Matthew Jones

Posts: 337
Registered: 1/25/98
Re: generating Word docs [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 2, 2016 2:09 AM   in response to: David Schwartz in response to: David Schwartz
David Schwartz wrote:

One other benefit that occurred to me is that by working with RTF,
the custom meta-tags and related data will be ignored if the doc is
imported into another RTF editor that doesn't know what those tags
are.

I'm not sure if it brings them in and keeps them intact but simply
fails to render them, or strips them out. Do you happen to know?

You need to be very careful with RTF, and know that it will work as you
want. It will also dictate the format of your document structure quite
a lot if you want to support anything more than the basics. Things like
list numbering are very specific. RTF is basically the documentation of
Microsoft's Word internal format, made into a form that made it open.
And it changed over time. Using it as an export format, or as your
internal form via some editor control, would be fine, but be aware that
it is not in any way simple if you are going to work with it. I started
off with a simple parser and exporter, and had to make a whole big
object tree to handle it as it is cross-referencing things that you
cannot just go get without a decent memory model of it.

But as I say, if your purpose is to build a document in something like
WPTools editor, and then export to Word for import, then it will be
fine.
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: generating Word docs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 27, 2016 6:27 AM   in response to: David Schwartz in response to: David Schwartz
Am 27.08.2016 um 10:48 schrieb David Schwartz:
This question is related to another one I just posted, but I thought it would be best to keep them separate.

Lawyer wants a tool to help compose pleadings and other legal docs, and he wants the output to be collected into a Word doc (docx, I presume).

There will be text as well as images inserted into the final documents.

Are there any libraries or approaches that work better than others for this?

(Gathering up the data seems pretty simple to me; getting it laid out nicely in a Word doc ... not so much.)

Hello,

you can generate Word documents from your app by remote controlling Word
via its COM API.

With this you can start Word, insert text as needed and most likely even
save the document etc.

There even is a component available in your Delphim installation, but
you might need to enable it first via Tools/Packages (not suere if the
menu item name is the right one) and there you need to select one of the
unselected "office control examples".

You can skip these if you use this API in a different form, which I did
a few years ago for reading in data from Excel files which the
generating tool would only save in this format. I started Excel
invisible in the background, opened the file and read out the data from
the Excel sheet.

Greetings

Markus
David Schwartz

Posts: 137
Registered: 8/28/00
Re: generating Word docs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 1, 2016 9:48 PM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:

Hello,

you can generate Word documents from your app by remote controlling Word
via its COM API.

not my preferred approach.

I think I'd rather build something that generates RTF and then launch Word to import it, where they'd then do their polishing and save it.

(I don't like COM -- fat, slow, and somewhat brittle.)
Steven Mitchell

Posts: 16
Registered: 5/8/97
Re: generating Word docs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 27, 2016 2:53 PM   in response to: David Schwartz in response to: David Schwartz
David Schwartz wrote:

This question is related to another one I just posted, but I thought
it would be best to keep them separate.

Lawyer wants a tool to help compose pleadings and other legal docs,
and he wants the output to be collected into a Word doc (docx, I
presume).

There will be text as well as images inserted into the final
documents.

Are there any libraries or approaches that work better than others
for this?

(Gathering up the data seems pretty simple to me; getting it laid out
nicely in a Word doc ... not so much.)

Perhaps the word processing components from WPCubed would be helpful at:
http://www.wpcubed.com/pdf/

Cheers,
Steve
Bernd Maierhofer

Posts: 161
Registered: 9/27/99
Re: generating Word docs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 29, 2016 12:05 AM   in response to: David Schwartz in response to: David Schwartz
David Schwartz wrote:

This question is related to another one I just posted, but I thought
it would be best to keep them separate.

Lawyer wants a tool to help compose pleadings and other legal docs,
and he wants the output to be collected into a Word doc (docx, I
presume).

There will be text as well as images inserted into the final
documents.

Are there any libraries or approaches that work better than others
for this?

(Gathering up the data seems pretty simple to me; getting it laid out
nicely in a Word doc ... not so much.)

We have a combination of WPCubed, which (also!) is good at manipulating
RTF at a low low level and ekRTF http://www.128byte.ru/ which allows
templating with RTFs.

Opening the RTFs with current versions of Word is not the problem, this
works well, OpenOffice sometimes streuggles with tables as well as
older versions of Word.

We had some troubles combining the RTF templates, because of fonts and
formattings, why we used WPCubed to have low level access to the RTFs
templates.

HTH Bernd

--

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02