Merging RTF text blocks into Word2003 document using Apose.Words


#1

We are about to start evaluating Aspose.Words today for a project and have a few basic questions. I saw some of the answers scattered around the forums but for completeness I'll ask them here anyway:

- We need to be able to take RTF snippets (using RTF encoding") and merge those blocks into a "Word" document through merge fields - can this be done? My big concern is taking the RTF block with its formatting and integrating that with the document.

- Can I add/remove merge fields through Aspose.Words into a document?

- Is there a plan to support WordML still and how do you forsee this effecting your previous releases of the component?

Thanks.

KJQ


#2

Thank you for your interest in Aspose.Words.

Answering your questions:

- Yes, you can insert parts of the MS Word document (it can be rtf template documents) into the other documents. This process can be combined with merge fields execution with some amount of additional user coding.

- You can add/remove merge fields to/from document using Aspose.Words. Look for description of DocumentBuilder.InsertField method in Aspose.Words API Reference.

- We have plans to support WordML in the near future, but I don't have any timeline just yet.

Don't hesitate to ask if you have more questions.


#3

Thank you for the quick response, one last question in regards to the RTF, do they have to be RTF files or can I work with them at the "string" or "stream" level?

Thanks.

KJQ


#4

Inline insertion of formatted text is currently supported only for HTML. It is in our plans to add this kind of functionality however.

Sorry for maybe misinforming you in the previous post, but working with RTF is not yet supported in Aspose.Words.

Only DOC format is fully supported now.

HTML format is supported but with several limitations, which are listed in:

http://www.aspose.com/Products/Aspose.Words/Aspose.Words.Converters.xls


#5

Hello again,

Well, i can't use HTML because there are at a best case slight differences and the format of the document must be exact.

What are the options then?

Can I create multiple instances of a DocumentBuilder, one for the master and then subsequent ones for the rtf streams and simulate that the rtf streams are files? If so how does that effect memory and performance?

Thanks.

KJQ


#6

I am afraid that RTF is not supported in any form right now.

Please tell me more about your task and dataflow and maybe I could muster up some workaround solution for you.


#7

Here is a summary of what I need to do:

1) I have a database with various RTF encoded blocks of text.

2) I have a master document in Word that has merge fields

What I need to do is:

1) Get a list ofthe "merge" fields from the Word doc

2) Iterate through that list and retreive the corresponding RTF snippet (there may be a point where I have to regex "psuedo" tags into actual "merge" tags (so in essence I need to read the RTF block and convert to a word format and embed it into the master). As a note, this may be a recursive exercise where I have to do this within a block of RTF also.

Basically, I need to build a template of templates to produce the "master" template. From that point I can use your component to actually "merge" the data only.

Ideally I'd like the ability to intermix both Word "doc" type snippets and RTF type snippets into some sort of master document - again, ideally Word 2003.

Let me know if this makes any sense.

Thanks.

KJQ


#8

Here's an idea to bounce off you before I try it...

Can I take the RTF text and stream it in to the DocumentBuilder as a "doc" type?

Maybe I would have to generate temp files for each block so that I can load it?

Reason i'm asking is because I created a RTF file and saved as a doc from Wordpad then openend in Word and vice versa. I lose stuff like fields if I save back again from wordpad but the format of the file seems to remain relatively the same between the two apps.

Thanks.

KJQ


#9

Yes, that makes perfect sense. The bad news is that Aspose.Word cannot deal with rtf right now. This feature will be available only in 2-3 months from now. So we cannot actually read and embed rtf snippets from database into word document now.

Please come again in a few months when we'll have this functionality implemented.