Automator & AppleScript: How do I import the texts of Notes and Reminders as PDFs and RTFs?

I would like to export and save the Notes and Reminders documents or texts as PDFs and RTFs, keeping or preserving the formatting and the background of Notes or Reminders, but the Notes doesn't have the option.

I would like to know if it's possible to use Automator and AppleScript to export the Notes and Reminders as PDFs and RTFs.


Another way to export notes is to move them to an email account first. For example:

  • Move notes to a Gmail account in Notes.app
  • Move the notes to some other folder in Gmail's web interface
  • Select the notes in Mail.app and save them as rich text or plain text

Here is another AppleScript for exporting notes as RTF:

set i to 1
tell application "Notes"
    repeat with n in notes
        do shell script "printf %s " & quoted form of (get body of n) & " | textutil -inputencoding UTF-8 -format html -convert rtf -stdin -output /tmp/" & i & ".rtf"
    set i to i + 1
    end repeat
end tell

It doesn't keep images, and it doesn't work with notes that are longer than getconf ARG_MAX. -inputencoding UTF-8 is required for preserving U+100 and characters above it.


The simplest way to get a note into PDF format is to use OS X's built-in Print to PDF function. Just select the note you want, open the print dialog, click the PDF button in the lower left corner, and select Save as PDF.

If you want to script/automate it, you can either do some GUI scripting to Automate the PDF printing process (which is a bit clunky, but there are many examples of how to do this around), or you can get the note text as HTML via AppleScript and convert it to RTF. Note that in either case, you just get plain text, the legal paper style of Notes is part of the GUI, not the note format.

If you want to get the text of a note in RTF, you can use this AppleScript:

tell application "Notes"
    set theNote to first note
    set theFile to ((path to desktop as text) & "output.html")
    my write_to_file(body of theNote, theFile, false)
end tell

do shell script "textutil -convert rtf " & (POSIX path of theFile)

on write_to_file(this_data, target_file, append_data) -- (string, file path as string, boolean)
    try
        set the target_file to the target_file as text
        set the open_target_file to ¬
            open for access file target_file with write permission
        if append_data is false then ¬
            set eof of the open_target_file to 0
        write this_data to the open_target_file starting at eof
        close access the open_target_file
        return true
    on error
        try
            close access file target_file
        end try
        return false
    end try
end write_to_file

This prints the first note in the list, if you want a specific one, or all of them, you can modify it to loop over the notes.

Hopefully that's a helpful starting point. I haven't had the time to look at how to export Reminders, perhaps someone else can chime in with that.