An AppleScript to convert PDFs to Safari bookmarks

Jul 31, '08 07:30:01AM

Contributed by: PizzaCake

Copy the following AppleScript into Script Editor, and save as an application:

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\n";' < " & 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
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.]

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080725071447247