• 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
Attributed string to HTML: invalid image URLs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Attributed string to HTML: invalid image URLs


  • Subject: Attributed string to HTML: invalid image URLs
  • From: David Sinclair <email@hidden>
  • Date: Thu, 19 Feb 2009 16:53:47 -0800

Hi,

I just wrote some code to export an attributed string to a HTML file wrapper, with images within a folder. It works fine, except the image URLs in the HTML are invalid; they are just "file:///" and the image name. Omitting that prefix would make them valid relative URLs. How can I get them to be relative URLs, other than editing the HTML and doing it after creation? I tried specifying a NSBaseURLDocumentOption attribute, but that doesn't seem to be used when saving.

I couldn't find an answer to this, though I found someone else asking the same question just a few days ago (without any response so far):

<http://www.cocoabuilder.com/archive/message/cocoa/2009/2/16/230320>

My code is simply (where "output" is an attributed string and "path" is the destination path):


NSDictionary *attributes = [NSDictionary dictionaryWithObject:NSHTMLTextDocumentType forKey:NSDocumentTypeDocumentAttribute];
NSFileWrapper *wrapper = [output fileWrapperFromRange:NSMakeRange(0, [output length]) documentAttributes:attributes error:nil];


return (wrapper && [wrapper writeToFile:path atomically:NO updateFilenames:YES]);

--

David Sinclair, Dejal Systems, LLC - email@hidden
Dejal blog - http://www.dejal.com/blog/
Cocoa code - http://www.dejal.com/developer/
Twitter - http://twitter.com/dejal/






_______________________________________________

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: Memory Leak, part I
  • Next by Date: Re: Running a timer on a separate thread
  • Previous by thread: Re: Running a timer on a separate thread
  • Next by thread: Reading from online Byte Array to UITableview best method?
  • Index(es):
    • Date
    • Thread