Exporting all Apple Notes to PDF

Discussion in 'Mac Programming' started by marmiteturkey, Jan 30, 2017.

  1. marmiteturkey macrumors 6502a


    Aug 27, 2005
    I have a bunch of handwritten Apple notes (using the iPad Pro/Pencil) - I'd like to get them all into individual PDFs for importing/sharing/archiving. I can't find an AppleScript or similar that would do that - can anyone help? Printing individually would take an age; drag and drop doesn't work; and the only scripts I can find only deal with text or attachments.

  2. Cordorb macrumors regular

    May 8, 2010
    I have tried an old program that does iPhone Backup extraction from your own non-protected backups

    useful for extracting photos, videos, Photo Stream, call history, notes, contacts, calendars, SMS messages

    Not sure if the notes were in PDF format
  3. marmiteturkey thread starter macrumors 6502a


    Aug 27, 2005
    I'm back here and still don't have an answer to this - I found an old AppleScript but it has errors in it and I am in no way qualified to debug it :( - can't believe this isn't easily fixable - it must be something that people struggle with constantly? Without an easy way to bulk export handwritten notes, it's essentially off limits to me.
  4. superscape macrumors 6502a


    Feb 12, 2008
    East Riding of Yorkshire, UK

    I think the main issue is that there doesn't seem to be any way to tell Notes to output a PDF in the AppleScript dictionary. You can, however, get the name and contents of each note and add them to something that *can* be converted into PDF. Something like this very crude example I lashes together:

    --start the HTML text
    set theSourceHTML to "<html><body>"
    tell application "Notes"
        set theNoteList to every note
        repeat with theNote in theNoteList
            --add to our HTML for each note
            set theBody to body of theNote
            set theName to name of theNote
            set theSourceHTML to theSourceHTML & "NAME: " & theName & "<br>BODY: " & theBody & "<p>---<p>"
        end repeat
    end tell
    --end the HTML text
    set theSourceHTML to theSourceHTML & "</body></html>"
    --write the html to file
    do shell script "echo " & quoted form of theSourceHTML & " > ~/Desktop/notes.html"
    --convert the html to pdf
    do shell script "cupsfilter ~/Desktop/notes.html > ~/Desktop/notes.pdf"

    ...it goes through each note, gets it as html and then created a pdf from the html. You'll probably lose images and possibly lose some formatting, but I suspect that may be the best you'll get.

    Hope that helps at least a little.
  5. chown33 Moderator

    Staff Member

    Aug 9, 2009
    I see that Notes on a Mac can import formats like rtf and rtfd. This suggests it's using the Cocoa text conversion system.

    There's a command-line tool that supports those same conversions: textutil.

    Maybe if Notes can be told to export as rtfd (or a similar format), that can be processed by textutil into HTML (or similar), and then converted to PDF through the cupsfilter as shown above.

    I don't have any Macs here running the Notes app, so I can't explore this myself.

    On a different note, it might help us make more progress if the OP were to post the exact URL of the script that doesn't work. He says he can't debug it, but that doesn't mean no one else can. However, he's the only one who knows what that script is, which does mean no one else can do anything with it until he tells us exactly what the script is.
  6. superscape macrumors 6502a


    Feb 12, 2008
    East Riding of Yorkshire, UK
    A good point.

Share This Page

5 January 30, 2017