Re: Read RTF in OS X?
Re: Read RTF in OS X?
- Subject: Re: Read RTF in OS X?
- From: Mr Tea <email@hidden>
- Date: Mon, 22 Apr 2002 12:52:06 +0100
This from Jason Bourque - dated 22/4/02 01.09 am:
>
How do you read an RTF file into a variable.
With difficulty. RTFs seem to come in two flavours in OS X. Some are
straighforward files, while others are packages containing an rtf file
(text.rtf), an icon file, and any images that are used in the document.
Using TextEdit to work with the file means that you don't have to worry
about which type of rtf it is.
I've been doing something like this:
set theRTF to [a suitable item]
tell application "TextEdit"
open theRTF
set theText to every paragraph of text of document 1 as text
end tell
One thing that I've found when doing this is that if I send the contents of
the variable to the clipboard for pasting into a document elsewhere, the
pasted text contains the 'wrong kind' of return characters. I knocked up the
following routine to fix that:
set ASTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to ASCII character 10
set someParas to every text item of theText
set theParaStore to {}
repeat with thePara in someParas
set the end of theParaStore to (thePara & return)
end repeat
set AppleScript's text item delimiters to ASTIDs
set the clipboard to theParaStore as text
Mr Tea
--
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.