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

An AppleScript to convert PDFs to Safari bookmarks iOS devices
Copy the following AppleScript into Script Editor, and save as an application: To use the script, drop a PDF (or multiple PDFs) onto this application, and an internet location file/s will be created in the same folder. Drag these internet location files into Safari's Bookmarks window. Now sync your iPhone/Touch (make sure you have it set to sync Safari bookmarks) and open one of these bookmarks.

You can now view your PDF, even in landscape mode. I cobbled this script together with some help from posts at MacScripter.

[robg adds: This is a home-built alternative to the method used in this prior hint. I haven't tested this one.]
    •    
  • Currently 1.22 / 5
  You rated: 1 / 5 (9 votes cast)
 
[7,953 views]  

An AppleScript to convert PDFs to Safari bookmarks | 4 comments | Create New Account
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 | # ]
osax: convert PDFs to Safari b/m -- why UTF8?
Authored by: zahadum on Jul 31, '08 10:44:40AM

why is the (print) command locked down to UTF8?

does this assumes that the name of the url (taken from the name from of the pdf) will not have asian (or special math/wingding) characters?

posix3 filenames can support unicode natively, correct?

---
mailto:osxinfo _at_ yahoo.ca



[ Reply to This | # ]
An AppleScript to convert PDFs to Safari bookmarks
Authored by: russellstevens on Aug 02, '08 04:02:31PM

I would just like to say thanks to PizzaCake and ctierney for this Applescript. Clever and generous people like yourselves make the iPhone (a truly breakthrough platform) more and more useful with every passing day.



[ Reply to This | # ]