RTF documents as templates

Peter Haworth pete at mollysrevenge.com
Tue Jun 1 13:24:10 EDT 2010


I've been trying to figure out how to use an RTF document as a  
template using pretty much this same methodology.  The problem I ran  
into is that sometimes, for reasons I don;t understand,  the token  
names I put into the document get interspersed with RTF commands, so  
something that looks like "[myToken]" when displayed in Word ends up  
looking like "[my<RTF commands>token]".  That stops my search for  
tokens dead in it's tracks.

Another method I've tried is to set up a Word document with merge  
fields in it and have my application write out a comma delimited file  
that is the source for the merge data.  That works well if you have a  
predictable number of lines you want to print, not so good for  
variable number of lines.

Right now, I've settled on writing out html code from templates that  
are defined within my Application.  I have some conventions to deal  
with "repeating lines".  For example, if I was printing an invoice,  
I'd define one html line in the format of an invoice line and its  
definition would include a code that tells me I need to repeat that  
line for each invoice line I'm printing.  That works quite well  
although so far I haven't figured out how to deal with printing a  
heading at the top of each page.

I guess I should break down and spend some money on a real report  
writer, especially since all my data is stored in an sqlite database  
but it's a fun challenge to figure this stuff out sometimes!

Pete Haworth

On Jun 1, 2010, at 10:00 AM, use-revolution-request at lists.runrev.com  
wrote:

> Message: 16
> Date: Tue, 1 Jun 2010 14:38:10 +0200
> From: Robert Brenstein <rjb at robelko.com>
> Subject: Re: RTF documents as templates
> To: How to use Revolution <use-revolution at lists.runrev.com>
> Message-ID: <p06240805c82aae20435c@[192.168.1.94]>
> Content-Type: text/plain; charset="us-ascii" ; format="flowed"
>
> On 31.05.10 at 10:50 -0700 JosepM apparently wrote:
>> Nop. My solution was store the entire document and search and  
>> replace before
>> to build the document, and then out as PDF using Quartam PDF  
>> Library and
>> Quartam Reports, but also you can print from a card.
>>
>
> If you need to just print, producing PDF files might be a way to go.
> Using RTF works as well. I used RTF documents as templates to produce
> Word docs. Basically, I created a full blown, properly formatted Word
> doc as template, then replaced variable elements with tokens, in my
> case things like [title], [description]. Rev stack read RTF directly
> into a variable and replaced the tokens, then saved new file. One
> needs to use RTF commands for marking new paragraphs, styles, and
> code non-English characters. I even used to produce Word table with
> varying numbers of rows by marking a repeating code for row in RTF
> and replicating it as many times as needed. Some sleuthing required,
> though, to decipher blocks in RTF.
>
> Robert




More information about the use-livecode mailing list