Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'An AppleScript to convert PDFs to Safari bookmarks' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to convert PDFs to Safari bookmarks
Authored by: ctierney on Jul 31, '08 10:37:26AM
Looks like some of the extra escaping in the shell script was lost. This version has back slashes converted to character entities:

on open pdfFiles
	tell application "Finder"
		repeat with pdfFile in pdfFiles
			set thedestination to folder of pdfFile
			set theName to displayed name of pdfFile
			-- convert pdf to base64 and copy result to clipboard
			do shell script "/usr/bin/perl -0777 -e 'use MIME::Base64; $text = <>; $text = encode_base64($text); $text =~ s/\\s+//g; print \"data:application/pdf;charset=utf-8;base64,$text
\";' < " & quoted form of POSIX path of pdfFile & " | pbcopy"
			set theurl to the clipboard
			make new internet location file to theurl at thedestination with properties {name:theName}
		end repeat
	end tell
end open


[ Reply to This | # ]
An AppleScript to convert PDFs to Safari bookmarks
Authored by: ctierney on Jul 31, '08 11:44:47AM
Minor note: applescript will capture the stdout of do shell script. So you don't need the clipboard (unless you want a copy there):
set theurl to do shell script "echo 'data:application/pdf;charset=utf-8;base64,'`openssl base64 < " & quoted form of POSIX path of pdfFile & " | tr -d '\n'`"
Do shell script is a great way to combine with the gui with the command line. Thanks for posting!

[ Reply to This | # ]