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 <45rpmli...@googlemail.com> 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:image001.jpg@01CE8098.AD1C4B20" 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 (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/martin%40nisus.com
> 
> This email sent to mar...@nisus.com


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to