Re: rtf and rtfd (Related to Getting at Some Hidden Clipboard Contents)
Re: rtf and rtfd (Related to Getting at Some Hidden Clipboard Contents)
- Subject: Re: rtf and rtfd (Related to Getting at Some Hidden Clipboard Contents)
- From: Laine Lee <email@hidden>
- Date: Mon, 09 Apr 2007 12:22:57 -0500
- Thread-topic: rtf and rtfd (Related to Getting at Some Hidden Clipboard Contents)
On 4/6/07 7:01 PM, "Douglas Davidson" <email@hidden> wrote:
> If I understand you correctly, you're handling rtf by writing the rtf
> contents of the pasteboard to a file, then using textutil on that
> file. I believe you should be able to handle rtfd in the same way.
> The usual on-disk file format for rtfd is as a file package; the
> pasteboard format for rtfd is a special serialized version of that,
> something which is not normally stored on disk. However, I believe
> that textutil should still be able to handle it if you were to put
> the rtfd pasteboard contents into a file on the disk.
>
> Douglas Davidson
>
Thanks, Douglas. I haven't yet found a way to get the rtfd data into a file
so that textutil can convert it to html the way my brute force TextEdit GUI
script can. Here's a brief example of what I've tried. It assumes you've
copied to the clipboard a selection in a Safari window which includes some
images. The rtf data isn't a problem, but I don't know how to handle the
additional types of data that make up the rtfd, other than to make TextEdit
create the rtfd package using the contents of its window.
set newdata to get the clipboard
--I've also tried:
--set newdata to get the clipboard as "rtfd"
--set newdata to get the clipboard as record
--set newdata to get the clipboard as data
set rtfd_path to (path to desktop as Unicode text)
tell application "Finder"
set newone to make new file at rtfd_path with properties
{name:"webpage.rtfd"}
end tell
set rtfd_ref to open for access (newone as alias) with write permission
set eof rtfd_ref to 0
write newdata to rtfd_ref
close access rtfd_ref
set convert_target to (POSIX path of (newone as alias))
do shell script "textutil -convert html" & space & (quoted form of
convert_target)
tell application "Finder"
delete newone as alias
end tell
--
Laine Lee
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden