• 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: Creating a file containing both an image and text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a file containing both an image and text


  • Subject: Re: Creating a file containing both an image and text
  • From: email@hidden (Stefan Haller)
  • Date: Fri, 18 Jan 2008 09:07:21 +0100
  • Organization: Ableton

Arthur C. <email@hidden> wrote:

> Or alternatively, like in my first attempt, how to include the PDF image
> into an RTFD file.
>
> > I haven't used the text system enough to be
> > exactly sure of the details, but I believe you'll have to create a
> > text attachment for the image to go into.
>
> Indeed, for the latter case I found a piece of code (in "Cocoa
> programming", Anguish, Buck, Yacktman) that uses a text attachment to read
> an image (tiff) file:
>
> NSTextAttachment * att
>   = [[[NSTextAttachment alloc] initWithFileWrapper: wrapper] autorelease];
> NSAttributedString * attStr
>   = [NSAttributedString attributedStringWithAttachment: att];
>
> but I still don't know how to create such an attachment for PDF data in
> memory.

Just create the NSFileWrapper yourself.  You don't need an actual,
existing file for it.

Something like this:

  NSData *data = < NSData containing your PDF >;
  NSFileWrapper *wrapper
    = [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease];
  [wrapper setPreferredFilename:@"SomeAppropriateName.pdf"];
  ... continue with your code ...


--
Stefan Haller
Ableton
http://www.ableton.com/
_______________________________________________

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: 
 >RE: Creating a file containing both an image and text (From: Arthur C. <email@hidden>)

  • Prev by Date: Re: How to popup a panel or window over a runmodal window
  • Next by Date: Re: Inter-Application communication
  • Previous by thread: RE: Creating a file containing both an image and text
  • Next by thread: Starting my application at user login
  • Index(es):
    • Date
    • Thread