• 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: Getting an index for NSMutableAttributed string using tags in RTF
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting an index for NSMutableAttributed string using tags in RTF


  • Subject: Re: Getting an index for NSMutableAttributed string using tags in RTF
  • From: Martin Wierschin <email@hidden>
  • Date: Mon, 28 Apr 2014 17:37:10 -0700

NSAttributedString won't load images from RTF, but it will load images from an RTFD package. Very likely it would not understand images specified using the ugly "htmltag" RTF control. You'll probably need to use the proprietary "NeXTGraphic" RTF control instead.

You can save an RTFD package with an embedded image using TextEdit to see what NSAttributedString expects.

> Second, I wondered if there's a way of getting the index of the last displayed character before the image from the RTF itself.

Once you have the content loaded into an NSAttributedString, you can search for the NSAttachmentCharacter Unicode character to find the image attachment in the string.

~Martin


On Apr 20, 2014, at 2:43 AM, Pax <email@hidden> wrote:

> I have an NSTextView which is being populated using RTF:
>
>    if ([self getContent:@"RTF"]&&useformatting)
>    {
>        [attributedContent appendAttributedString:[[NSAttributedString alloc] initWithRTF:[self getContent:@"RTF"] documentAttributes:NULL]];
>    }
>
> This works beautifully except that the RTF string references images:
>
> {\*\htmltag84 <img border=0 width=224 height=51 id="_x0000_i1033" src="cid:email@hiddenB20" alt="LH_logo600r1idx">}\htmlrtf {\chbrdr\brdrsh LH_logo600r1idx}\htmlrtf0
>
> I would like to make sure that the images are placed into the RTF correctly.  I thought I might be able to do it by saving the image to a cache folder and specifying a root (as WebKit's loadHTMLString does), but this isn't available in NSTextView or NSMutable String.
>
> Second, I wondered if there's a way of getting the index of the last displayed character before the image from the RTF itself.
>
> Does anyone have any ideas how this might be achieved?  As usual, all assistance gratefully received!
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please 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


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: 
 >Getting an index for NSMutableAttributed string using tags in RTF (From: Pax <email@hidden>)

  • Prev by Date: Re: dispatch_semaphore crash on deletion
  • Next by Date: Re: SpriteKit Joints on Mac OS X
  • Previous by thread: Getting an index for NSMutableAttributed string using tags in RTF
  • Next by thread: ARC Retain Cycles
  • Index(es):
    • Date
    • Thread