• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: RS: NSString from RTF file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RS: NSString from RTF file


  • Subject: Re: RS: NSString from RTF file
  • From: Robert Walker <email@hidden>
  • Date: Mon, 4 Jun 2007 11:18:03 -0400

Sorry, I just noticed that initWithPath... as suggested in the previous post handles both RTF and RTFD. But, the reference to the document might still be useful.

On Jun 4, 2007, at 11:12 AM, Robert Walker wrote:

Have you tried this:

- (id)initWithRTF:(NSData *)rtfData documentAttributes: (NSDictionary **)docAttributes


In this document:
http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/Classes/NSAttributedString_AppKitAdditions/Reference/ Reference.html


On Jun 4, 2007, at 10:14 AM, glenn andreas wrote:


On Jun 4, 2007, at 9:01 AM, Roland Silver wrote:

Can anyone suggest Cocoa code to (1) read an RTF file; (2) create an NSString containing the contents of that file, devoid of the attributes?

For example, I have a short test file whose content, converted to a string by initWithData:data encoding:NSISOLatin1StringEncoding, looks like this:

{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
{\fonttbl\f0\froman\fcharset77 TimesNewRomanMS;\f1\froman \fcharset77 TimesNewRomanItMS;}
{\colortbl;\red255\green255\blue255;\red255\green0\blue0;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\deftab720
\pard\pardeftab720\sa360\qj


\f0\fs37\fsmilli18667 \cf0 Arma \cf2 virumque\cf0 cano, Troiae qui
\f1\i primus
\f0\i0 ab oris\uc0\u8232 Italiam, fato profugus, Laviniaque venit \u8232 }


So: can you suggest a code fragment to convert that (or any similar attributed string) to the NSString

@"Arma virumque cano, Troiae qui primus ab oris
Italiam, fato profugus, Laviniaque venit"?



NSString *unformattedText = [[[[NSAttributedString alloc] initWithPath: filepath documentAttributes: nil] autorelease] string];



Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | flame : flame fractals & strange attractors : build, mutate, evolve, animate




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden

-- Robert Walker email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden

-- Robert Walker email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >RS: NSString from RTF file (From: Roland Silver <email@hidden>)
 >Re: RS: NSString from RTF file (From: glenn andreas <email@hidden>)
 >Re: RS: NSString from RTF file (From: Robert Walker <email@hidden>)

  • Prev by Date: Re: RS: NSString from RTF file
  • Next by Date: Re: Cocoa controls on top of an OpenGL view
  • Previous by thread: Re: RS: NSString from RTF file
  • Next by thread: Re: RS: NSString from RTF file
  • Index(es):
    • Date
    • Thread