Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-06

RTF

4 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

David G Jenkins

rtfpars
Contains a RTF (Rich Text Format) parsing class. All that needs to be done is set some event handlers and you can display RTF wherever you want.

I would like to use this to generate RTF files but don't have any documentation about the functionality of this unit.

Can anyone help?

David Jenkins FIEE FBCS CEng 11 Auchineden Court, St Andrew's Rise, Bearsden, East Dunbartonshire, G61 4NN Scotland UK tel: +44-141-563-0781 fax: -0781 call first mobile +44-77 65 888 598
Alan Mead
to David G Jenkins
--- David G Jenkins wrote 9 lines
rtfpars Contains a RTF (Rich Text Format) parsing class. All that needs to be done is set some event handlers and you can display RTF wherever you want. I would like to use this to generate RTF files but don't have any documentation about the functionality of this unit.

I can't help with rtfpars but I have had luck in the past using templates. RTF is pretty complicated and so constructing brand-new documents from scratch might be complex. But if you just need to create a single kind of document, perhaps with some data changed, then you can often solve the problem much more simply by: (1) create an RTF document in your favorite software; (2) Insert tags like ##ADDRESS1## where you want to substitute text; (3) read in the template and replace the tags with the text of your choice.

If you have more slightly more complex needs... such as wanting to insert the text of a letter, then the RTF that marks up standard text is pretty simple, so: (1) create the RTF file; (2) break it into a "header" part and a "tail" part; (3) examine the simple mark-up for the body and write your conversion routine.

This approach has some advantages: it's quick and relatively simple and it practically garuantees that the generated RTF can be read properly by your favorite software. But it can also be really cumbersome to change the template and it doesn't work if you need the fancy RTF features.

There used to be a thick-ish RTF spec on the microsoft.com website that you could examine if you wanted a better understanding of RTF.

-Alan

Jan Je/lowicki
Show quoted text 47 lines
From: Alan Mead Subject: Re: [fpc-pascal]RTF To: Send reply to: Date sent: Mon, 28 Jun 2004 09:25:19 -0700 (PDT) --- David G Jenkins wrote: > rtfpars > Contains a RTF (Rich Text Format) parsing class. All that > needs to > be done is set some event handlers and you can display RTF wherever > you > want. > > I would like to use this to generate RTF files but don't have any > documentation about the functionality of this unit. I can't help with rtfpars but I have had luck in the past using templates. RTF is pretty complicated and so constructing brand-new documents from scratch might be complex. But if you just need to create a single kind of document, perhaps with some data changed, then you can often solve the problem much more simply by: (1) create an RTF document in your favorite software; (2) Insert tags like ##ADDRESS1## where you want to substitute text; (3) read in the template and replace the tags with the text of your choice. If you have more slightly more complex needs... such as wanting to insert the text of a letter, then the RTF that marks up standard text is pretty simple, so: (1) create the RTF file; (2) break it into a "header" part and a "tail" part; (3) examine the simple mark-up for the body and write your conversion routine. This approach has some advantages: it's quick and relatively simple and it practically garuantees that the generated RTF can be read properly by your favorite software. But it can also be really cumbersome to change the template and it doesn't work if you need the fancy RTF features. There used to be a thick-ish RTF spec on the microsoft.com website that you could examine if you wanted a better understanding of RTF. -Alan _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

And if you only are able to to so, abandon RTF and turn into fully transparent an more flexible XML. Thre is a serious chance that
your-data --(your-app)--> xml --(standard xsl)--> rtf scenario would be easier to handle.

With regards,

Jan Jelowicki

------------------------------------------------------------------- Wroclaw University of Agriculture Akademia Rolnicza we Wroclawiu Department of Mathematics Katedra Matematyki -------------------------------------------------------------------

David Emerson
Show quoted text 6 lines
But if you just need to create a single kind of document, perhaps with some data changed, then you can often solve the problem much more simply by: (1) create an RTF document in your favorite software; (2) Insert tags like ##ADDRESS1## where you want to substitute text; (3) read in the template and replace the tags with the text of your choice.

I recently wrote a program that does this. My primary problem arose from microsoft word being stupid (big surprise, huh?) Suppose I inserted a tag such as the above example, ##ADDRESS1## (I think I used greater-than/less-than brackets rather than pound symbols -- but those don't email well!) MS Word would sometimes insert rtf tags right in the middle of the word, for no obvious reason. So I would get something like:

##ADDR{\bizarre rtf tag, sometimes

containing carriage returns in the middle} ESS1##

My solution was to save as Word version 2, close and reopen, then save as rtf. It might not be a bad idea to go with the XML or LaTeX. But if you'd like a copy of the program I wrote, let me know and I'll post it or email it to you.

~David