Page 1 of 1

Modify RTF, substitute complexer placeholder

Posted: Mon Aug 08, 2022 6:46 am
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)

Re: Modify RTF, substitute complexer placeholder

Posted: Mon Aug 08, 2022 9:48 am
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.

Re: Modify RTF, substitute complexer placeholder

Posted: Tue Aug 09, 2022 12:19 pm
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é