Modify RTF, substitute complexer placeholder

General TRichView support forum. Please post your questions here
Post Reply
a.weber
Posts: 58
Joined: Wed Mar 02, 2022 7:02 am

Modify RTF, substitute complexer placeholder

Post by a.weber »

Hello,
I'am try the following and need a little help or a pointer to a good sample. I have rtf files containing simpleplaceholders ##replace## currently I have copied some code from one of the mailer demos to recursivly traverse through RVData simple text substitution works that way.

But now for example I want to Insert a enumeration like this:
  • Person 1
  • Person 2
  • Person 3
Before My RTF Text looks like
Sometext before
This is the list of all persons in the meeting ##replace## this afternoon.
Sometext after

After My RTF Text should look like
Sometext before
This is the list of all persons in the meeting
  • Person 1
  • Person 2
  • Person 3
this afternoon.
Sometext after

Enumerating the items gives me a single "TRVTextItemInfo" for the line with ##replace##.
So I think I have to split the existing TRVTextItemInfo into the parts before and after ##replace## I'am right?
And insert the enumeration between?
The enumeration should inherit the same textstyling as the original text. (that means at least fontname, color, fontsize, style)
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Modify RTF, substitute complexer placeholder

Post by Sergey Tkachenko »

1. If you need a single insertion, the simplest way is to select '##replace##' in the editor, then call InsertRVFFromStreamEd/InsertRTFFromStreamEd/InsertDocXFromStreamEd to insert a new document fragment. Inserting overrides the selection.

2. If you need to perform many replacements:
- consider using ReportWorkshop add-on, https://www.trichview.com/features/reportworkshop.html
- see the examples here: https://www.trichview.com/forums/viewtopic.php?t=8 , specifically mailmerge-text4.zip that allows RVF as field values.
a.weber
Posts: 58
Joined: Wed Mar 02, 2022 7:02 am

Re: Modify RTF, substitute complexer placeholder

Post by a.weber »

Hello Sergey,

thanks again for your quick response - the replacements will occur only some times - speed doesn't matter that much. So I'am going to steal some ideas from MailMerge4 and geoReport sample project - that seems to work for me.

André
Post Reply