Attached is a *very* simplistic example of what i’m trying to do based on one of the examples in your toolkit.
In a nutshell, what I want to do is find “tags” that are typed into an RTF document and replace them with data. Obviously this can be done with OpenXML using Microsoft’s tools. However, our desire is to provide a well-known tool (Microsoft Word) that allows users to create the template and save as RTF. Next, we will (hopefully using Aspose) open the template and replace the “tags” with real data.
The issue that I am running into with Aspose is related to the limitation where I cannot replace search results that contain “special characters.” Referring to the first post I made in this thread you’ll note that the following RegEx…
Regex regex = new Regex(@"<\s*(?[^<>/]*?)\s*(?::(?[^/]*))*\s*(?/)?\s*>(?:(?.*)(?<\s*/\s*\k\s*>))?", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase)
… will match the following text in the document…
We want the signature to go here.¶
Obviously that run of text includes 2 paragraph marks (not including the final mark) which are considered “special characters” and thus my replace throws an exception in Aspose. So, I am now trying to figure out a nice work around that will allow me to quickly identify “tags” in the RTF document and thus know where my replacement text goes.
I have experimented with creating a class derived from the Run node that I can just insert into the document structure in place of the “tags.” However, I’m finding that simply using e.MatchNode.Parent.InsertBefore(new TagNode(), e.MatchNode) causes Aspose to throw a null reference exception. So, I’m still kind of stuck.
I’ve attached my project (not including my experiments with a class derived from the Run node) so you can see what I’m doing. You’ll see at this point it is extremely simple.
I only have about 24 hours left to make a decission as to whether Aspose will work for us or not, so any advise you have is greatly appreciated. Please let me know if you need any further information and I will be happy to provide you with anything that I can.
Thanks for all of the help you have been to me.