Can someone tell me what is the best way that I can automatically insert a blank line at the top and bottom of these newly-created .rtf files, for these two separate pieces of code?
First piece of code (for when the clipboard contains rich text):
try
set richTextfromClipboard to get the clipboard as «class RTF »
on error eStr number eNum
display dialog eStr & " number " & eNum buttons {"OK"} default button 1 with icon caution
return
end try
try
set fileHandle to open for access theRichTextFilepath with write permission
write richTextfromClipboard to fileHandle
close access fileHandle
on error eStr number eNum
display dialog eStr & " number " & eNum buttons {"OK"} default button 1 with title "File I/O Error..." with icon caution
try
close access fileHandle
end try
end try
Second piece of code (for when the clipboard contains HTML):
try
do shell script "osascript -e 'try' -e 'get the clipboard as «class HTML»' -e 'end try' | awk '{sub(/«data HTML/, \"3C68746D6C3E\") sub(/»/, \"3C2F68746D6C3E\")} {print}' | xxd -r -p | textutil -convert rtf -stdin -stdout > " & quoted form of theRichTextFilepath
on error eStr number eNum
display dialog eStr & " number " & eNum buttons {"OK"} default button 1 with icon caution
end try
The blank lines do not have to be of a predetermined font type or font size; the blank lines should simply match the style of the surrounding .rtf file (that is, the style of the rich text on the clipboard).