Copy and pasting without carriage returns. Can it be done?

I need to write a script that accomplishes the task of removing the carriage returns from text in PDF documents when I copy them over to another app.

I have seen a couple of scripts that are “App Specific” that allow you to batch remove them. I was wondering if there was any way for applescript to do this without having to tell the application to do it, since I occasionally have apps that are not scriptable. It’s also a wasted step having to highlight and change it after the copy.

I was wondering specifically, if applescript can handle a text manipulation from Preview to the clipboard, such that the carriage returns are removed before the text is ever pasted. Or perhaps a manipulation from the clipboard to the page.

Can something like that be done? Am I barking up the wrong tree asking AppleScript to do it?

Preview isn’t scriptable, but Skim is. :wink:
http://www.macupdate.com/info.php/id/24590/skim

tell application "Finder"
	set filepath to file "Macintosh HD:Users:christoo:Desktop:scpt.pdf" as alias
end tell
tell application "Skim"
	open filepath
	set x to text of document 1
end tell
set com to "echo " & quoted form of x & " | perl -pe 's/\\n//g'"
set y to do shell script com

:confused:

Turns out you don’t need the shell script:

tell application "Finder"
	set filepath to file "Macintosh HD:Users:christoo:Desktop:scpt.pdf" as alias
end tell
tell application "Skim"
	open filepath
	set x to text of document 1
end tell
set y to every paragraph of x as text
display dialog x
display dialog y