New topic: 

How to display a 1 or 2 page RTF document on a Window?

<http://forums.realsoftware.com/viewtopic.php?t=41173>

         Page 1 of 1
   [ 8 posts ]                 Previous topic | Next topic          Author  
Message        SilvrT          Post subject: How to display a 1 or 2 page RTF 
document on a Window?Posted: Wed Oct 26, 2011 12:20 pm                         
Joined: Wed Jul 30, 2008 3:53 pm
Posts: 52                Searched and searched for this ... found some code but 
it doesn't work. 
This is the code I found that doesn't work..
Code:  dim f As FolderItem
  dim t As TextInputStream
  
  f = GetFolderItem("C:\ccim\test.rtf")
  
  if f <> nil then
  t = TextInputStream.Open(f)
  t.Encoding = Encodings.WindowsLatin1
  TextArea1.StyledText.RTFData = t.ReadAll
  t.close
  end if
  

How do I display the contents of an RTF document onto a window?   
                             Top                 kermit          Post subject: 
Re: How to display a 1 or 2 page RTF document on a Window?Posted: Wed Oct 26, 
2011 12:24 pm                         
Joined: Mon May 30, 2011 12:56 am
Posts: 228                Which part doesnt work?

testing for nil is not enough: if the file or the containing folder does not 
exist, that test will still report non-nil
Do you get an error?

if f.exists then ...   
                             Top                 SilvrT          Post subject: 
Re: How to display a 1 or 2 page RTF document on a Window?Posted: Wed Oct 26, 
2011 12:29 pm                         
Joined: Wed Jul 30, 2008 3:53 pm
Posts: 52                kermit wrote:Which part doesnt work?

testing for nil is not enough: if the file or the containing folder does not 
exist, that test will still report non-nil
Do you get an error?

if f.exists then ...

There is no error and the code steps thru correctly but nothing appears in the 
TextArea box on the Window. The rtf file is a very basic 1-page document.  
Also, that code snippet is something I found in this forum which I modified to 
point to a file I created.   
                             Top                 timhare          Post subject: 
Re: How to display a 1 or 2 page RTF document on a Window?Posted: Wed Oct 26, 
2011 1:32 pm                         
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 10324
Location: Portland, OR  USA                Was the document created in RB?  
RTFData is not general purpose.  RTF created by another application may or may 
not work in RB.  Is the encoding correct?   
                             Top                SilvrT          Post subject: 
Re: How to display a 1 or 2 page RTF document on a Window?Posted: Wed Oct 26, 
2011 1:49 pm                         
Joined: Wed Jul 30, 2008 3:53 pm
Posts: 52                timhare wrote:Was the document created in RB?  RTFData 
is not general purpose.  RTF created by another application may or may not work 
in RB.  Is the encoding correct?

It was created in MS Word and saved as an rtf file.   
                             Top                 elChupete          Post 
subject: Re: How to display a 1 or 2 page RTF document on a Window?Posted: Wed 
Oct 26, 2011 1:51 pm                                 
Joined: Fri Jun 05, 2009 11:50 am
Posts: 240
Location: Hamburg, Germany                not sure, but is rtfdata holding only 
the style info?

try setting textarea.styledtext.text in addition      
_________________
Best regards

Stefan

Mac OSX 10.7.2 on a MacBook Pro 2.66 GHz Intel Core i7/ RB Professional 2011 
Release 3  
                             Top                Jym          Post subject: Re: 
How to display a 1 or 2 page RTF document on a Window?Posted: Wed Oct 26, 2011 
1:55 pm                         
Joined: Sat Oct 01, 2005 5:19 pm
Posts: 2690                MS Word does many things a TextArea can't do i.e. 
Tables, pictures, lines...  Cut and Paste from the Word Doc to a TextArea, and 
save the RTF and compare the 2 RTF files when you open them in Notepad and you 
should see a huge difference.  Some Word RTF files won't even open in Word Pad 
because it only does simple RTF   
                             Top                SilvrT          Post subject: 
Re: How to display a 1 or 2 page RTF document on a Window?Posted: Wed Oct 26, 
2011 2:06 pm                         
Joined: Wed Jul 30, 2008 3:53 pm
Posts: 52                Jym wrote:MS Word does many things a TextArea can't do 
i.e. Tables, pictures, lines...  Cut and Paste from the Word Doc to a TextArea, 
and save the RTF and compare the 2 RTF files when you open them in Notepad and 
you should see a huge difference.  Some Word RTF files won't even open in Word 
Pad because it only does simple RTF


AWESOME !! Thank you!  I did not realize the above. I re-did the document in 
Wordpad and saved it as rtf and now the code works!   
                             Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 8 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to