• 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
Converting from RTF to HTML misses out image tags
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Converting from RTF to HTML misses out image tags


  • Subject: Converting from RTF to HTML misses out image tags
  • From: Pax <email@hidden>
  • Date: Fri, 25 Apr 2014 21:20:24 +0100

I'm trying to convert from RTF to HTML like so:

        NSAttributedString* rtfContent = [[NSAttributedString alloc]initWithRTF:rtfData documentAttributes:nil];
        NSData* htmlData = [rtfContent dataFromRange:NSMakeRange(0, rtfContent.length) documentAttributes:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} error:nil];
        NSString* htmlString = [[NSString alloc]initWithData:htmlData encoding:NSUTF8StringEncoding];

It works - up to a point.  The point at which it fails is that the image links in the rtfData are missed out of the resultant htmlString:

RTF
{\*\htmltag84 <a href="mailto:email@hidden";>}\htmlrtf {\field{\*\fldinst{HYPERLINK "mailto:email@hidden"}}{\fldrslt\cf1\ul \htmlrtf0 email@hidden\htmlrtf }\htmlrtf0 \htmlrtf }\htmlrtf0
{\*\htmltag92 </a>}
{\*\htmltag244 <o:p>}
{\*\htmltag252 </o:p>}
{\*\htmltag92 </span>}\htmlrtf }\htmlrtf0 \htmlrtf\par}\htmlrtf0
\htmlrtf \par
\htmlrtf0
{\*\htmltag72 </p>}
{\*\htmltag64 <p class=MsoNormal>}\htmlrtf {\htmlrtf0
{\*\htmltag84 <span style='font-size:10.0pt;color:#1F497D'>}\htmlrtf {\htmlrtf0
{\*\htmltag244 <o:p>}
{\*\htmltag84 &nbsp;}\htmlrtf \'a0\htmlrtf0
{\*\htmltag252 </o:p>}
{\*\htmltag92 </span>}\htmlrtf }\htmlrtf0 \htmlrtf\par}\htmlrtf0
\htmlrtf \par
\htmlrtf0
{\*\htmltag72 </p>}
{\*\htmltag64 <p class=MsoNormal>}\htmlrtf {\htmlrtf0
{\*\htmltag84 <span style='color:#1F497D'>}\htmlrtf {\htmlrtf0
{\*\htmltag84 <img border=0 width=224 height=51 id="_x0000_i1033" src="cid:email@hiddenB20" alt="LH_logo600r1idx">}\htmlrtf {\chbrdr\brdrsh LH_logo600r1idx}\htmlrtf0

HTML
<p class="p3"><span class="s1"><a href="mailto:email@hidden";>email@hidden</a></span></p>
<p class="p2"><br></p>
<p class="p1"> </p>
<p class="p2"><br></p>
<p class="p1">LH_logo600r1idx</p>

Does anyone have any idea how I can ensure that the generated HTML is complete?

Thanks for any help you can provide!
_______________________________________________

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


  • Prev by Date: Re: NSScroller revision?
  • Next by Date: Re: NSScroller revision?
  • Previous by thread: Fwd: NSScroller revision?
  • Next by thread: Authorization Services
  • Index(es):
    • Date
    • Thread