Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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.

share|improve this answer
    
It worked very well, but there's one little fail. After exporting, the RTF and HTML said there were missing plug-ins (I inserted the images in the notes) and the images weren't there and became "missing plug-ins". When I clicked the missing plugin-in and the dialog said: "This page contains content of “application/x-apple-msg-attachment” type. You do not have the plug-in required to view this content." –  Gustavo Reis Costa Nov 30 '12 at 15:10

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"
    end repeat
    set i to i + 1
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.

share|improve this answer
    
Technically you should swap these two lines: "end repeat" and "set i to i + 1" because you need to increment the counter as you are creating the files. –  Matt Nov 13 at 5:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.