RTF-files from Word

I can open and display RTF-files but not when I make a RTF-file with Word and want to open it. Is what Word uses not really RTF or do I make another mistake?

Naamtekst2 is a variable. OpdrachtRTF is a Textarea. Do I need to change code or is there an alternative way to read RTF-files from Word?

OpdrachtRTF.text =""
Dim ftr As FolderItem
Dim tir As TextInputStream
Dim rtf As StyledText

If NaamTekst2 <>"" then
ftr = Volume(V).child(“Meander”).child(“RB”).child(“Teksten”).child(Naamtekst2)
end if

if ftr <> nil and ftr.exists then
if NaamTekst2 <> “” then
tir=TextInputStream.Open(ftr)

  OpdrachtRTF.StyledText.rtfdata = tir.Readall
  
   tir.close
   OpdrachtRTF.visible = true
end if

end if

Tom Prins

I guess it could be both, Word which writes sometimes not very good RTF files and Xojo which doesn’t obviously supports all the features of Word. If you target Cocoa, there are methods to let Cocoa to read RTF files, generally with better results. No luck on Windows…

It has to work on Windows as well as on Mac … :wink: I cannot imagine that I am the only one who has to deal with this. Or is it the we-make-the-standard Microsoftarrogance? I just want to read RTF-files made by Word in my Textarea…:wink:

If you are using windows I find Wordpad does a better job with .rtf files.

If you are using windows I find Wordpad does a better job with making .rtf files that I can then read in Xojo.

I’d rather expect that the difference your seeing is that the TextArea only supports a subset of RTF while a new version of Word probably handles the entire spec (since MS writes the spec)

If you’re looking for better (not perfect) RTF support in Xojo, you can take a look at our Formatted Text Control at http://www.bkeeney.com/formatted-text-control/. It’s not free but it handles a lot of things (inline images, hyperlinks to name a few) better than the built-in TextArea control.

Hi Bob,

I learned a lot from your instructional videos when I started to progra, Well worth the money. Do you also offer instructional videos about FTC? I saw one small one at the time. They really help to get some working knowledge and help people on their way. FTC is not really simple, but when you can assure me that it is possible to read rtf-files directly made by Word I will buy the upgrade. I puchased FTCearlier but left it aside because of other priorities.

Thanks for the kind words about the videos.

Send me a sample RTF made by MS Word and I’ll let you know if it handles it properly. I don’t claim that we handle all RTF but we handle a lot more than the TextArea.

Exactly. The RTF format is from Microsoft.

Still, the RTF output from Word is similar to its HTML output. Unoptimized and unnecessarily obfuscated. It’s always valid, though. And Word (at least older versions) supported the full spec.

The best RTF program out there, though, is Ted. Its aim is to be the most complete RTF program out there and it’s output is beautiful to look at (since RTF is text-based, Ted makes an effort to make it readable as well).

I have several workflows that use Ted RTF to build documents and then “print” them to PDF. The RTF produced by Word I usually run by Ted to “clean it up”. At this stage I trust Ted more on RTF specs than I do Microsoft (as after Office 6 their RTF support hasn’t been a priority).

AFAIK, Xojo read perfectly the files Xojo rtf wrote. Beside that, no hope; unless XOJO™ expand its rtf r/w.

\stylesheet is not supported !

OS X: with TextEdit, I got twice the same character if one of éèàçù, etc.

I created a simple project that tooks (open the file / get the pasted string) a rtf and save it (after eventual modifications) as rtf (or raw text) to my hard disk. 4,3MB.

I am sometimes asking myself about the rtf use with Xojo.

In that case I hope that Bob Keeneys solution with a FTC RTFreader works. I contacted Bob about it. Actually The Textarea should support the whole common RTF-standard. I wonder why they do not.

I know at this stage no editor in the world supports all of the RTF Standard (the closest there is is Ted, and it was updated this year with still some missing support added).

What would be considered the “common” subset of the RTF Standard?

That’s a loaded question in that many of the features in Xojo were developed because they needed it for Xojo. Since they have no need for inline images, hyperlinks, etc, they don’t support it. Whey they needed was a way to display styled text. So that’s what they developed.

I recently added hyperlink support to the Formatted Text Control. It was not a trivial exercise. The original developer of FTC added inline images and that one feature is a rather large chunk of code.

Exactly. I think the next thing FTC might tackle is table support. Is that ‘common’ in RTF? I don’t know but it’s a big request by many of our customers.

[quote=28096:@Bob Keeney]Exactly. I think the next thing FTC might tackle is table support. Is that ‘common’ in RTF? I don’t know but it’s a big request by many of our customers.
[/quote]

Tables are, as are inline images (although what format to store them in is up in the air). To me inline font embed is essential, but this is because I do templating engines and they require the proper fonts.

For the same reason, for me header and footers are essential, but not named styles (I hardcode styles into the elements).

If you don’t know Ted you might want to take a look at it. It’s very impressive the work they’ve done with it and feeding it an rtf and saving it back produces files whose code is almost pretty to look at :smiley:

http://www.nllgg.nl/Ted/

I use a shell script that uses Ted to create PDFs from the RTFs I produce assembling the text by “hand” in merge and templating routines. I use word to create the template since I can give it to users to build their documents. I then run it through ted to make it manageable. We use absolute positioning and sizes (in centimeters) for all, including table cells. That template is also useful later on if they want to do a manual one-off document like the ones the system produces.