Re: Creating a file containing both an image and text
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