Hello all,
I've been trying to insert an image into the page footer of a custom NSView, so that when I print it, it will display text and an image in the footer. Here is the code that I am using:
- (NSAttributedString *)pageFooter {
NSString *imgName = @"Logo.tif";
NSFileWrapper *fwrap = [[[NSFileWrapper alloc] initRegularFileWithContents:
[[NSImage imageNamed:@"Logo"] TIFFRepresentation]] autorelease];
[fwrap setFilename:imgName];
[fwrap setPreferredFilename:imgName];
NSTextAttachment * ta = [[[NSTextAttachment alloc] initWithFileWrapper:fwrap] autorelease];
NSString *aString = @"Foo";
NSMutableAttributedString *bString = [[NSMutableAttributedString alloc]initWithString:aString]];
[bString appendAttributedString:[NSAttributedString attributedStringWithAttachment:ta]];
return bString;
[bString release];
}
This doesn't display the image, however it does display the text. What have I done wrong?
I've got the Logo.tif in the Resources folder in Xcode, and it is in the main project folder on my desktop. I've also tried with Logo.tiff (with the extra 'f')
Thanks,
Michael