FileWrapper from rtf or rtfd
FileWrapper from rtf or rtfd
- Subject: FileWrapper from rtf or rtfd
- From: Renaud Boisjoly <email@hidden>
- Date: Fri, 22 Aug 2003 12:14:39 -0400
Hi all!
I'm trying to automate my program to save exported files in rtfd or rtf
pages depending on the content of the pages. THis is what I'm doing now:
NSMutableAttributedString *inputValue =
[[[NSMutableAttributedString alloc] initWithRTFD: [thisPage pageData]
documentAttributes:nil] autorelease];
if ([inputValue containsAttachments]) {
//Has images, use rtfd
thisPageWrapper = [[[NSFileWrapper alloc]
initWithSerializedRepresentation:[thisPage pageData]] autorelease];
thisPageName = [NSString stringWithString:[[thisPage name]
stringByAppendingString:@".rtfd"]];
} else {
NSLog(@"No Images found in page");
NSData *theData = [NSData dataWith
Data:[inputValue
RTFFromRange:NSMakeRange(0,[[inputValue string] length])
documentAttributes:nil]];
thisPageWrapper = [[[NSFileWrapper alloc]
initWithSerializedRepresentation:theData] autorelease];
thisPageName = [NSString stringWithString:[[thisPage name]
stringByAppendingString:@".rtf"]];
}
[thisPageWrapper writeToFile:[thisDirectory
stringByAppendingPathComponent:thisPageName] atomically:NO
updateFilenames:YES];
Everything works great with RTFD file, they get saved and everything.
But when it tries to create the FileWrapper from my NSAttributedString
using RTFFromRange:documentAttributes: the fileWrapper is always NULL
I know the data (theData) contains something, although Its all hex
code, so I'm not sure what is in the stream, but this should work no?
Also, does anyone know how to check if a file has any basic formatting?
I want to check this and export to simple text files when the files
only contains a single font attribute... but I'm not sure how to go
about this.
Thanks!
- Renaud
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.