After someone stole my iPad they also took my notes from me. Hopefully NotesPlus includes an option to automatically backup your notes to Dropbox.
Fortunately, the backup format that the app uses on Dropbox is pretty simple: it stores the background PDF you've used and a SVG file per each page with your annotations (and a lot of metadata I'm deliberately ignoring).
I've created a simple bash script for Linux/OSX (anywhere you've got BASH+ImageMagick, really) that uses the wonderful ImageMagick to extract the pages of the PDF one by one, overlay the SVG over it and then convert everything into a single PDF file once again.
Obviously it only covers one of the many use cases for NotesPlus, but it did the trick for me.
I leave it here in case it's ever useful to anybody:
Obviously, you must install ImageMagick on your system if you haven't already done so.#!/bin/bash# Clear environment, just in caseexport DYLD_LIBRARY_PATH=""export LD_LIBRARY_PATH=""# Determine my running dirMYDIR=$(dirname $0)cd "$MYDIR"MYDIR="$(pwd)"# This'll save us a lot of headachesSAVEIFS=$IFSIFS=$(echo -en "\n\b")# Iterate on all the notebooks foundfor NOTEBOOK in $(ls | sort -n); doif [ -d "$NOTEBOOK" ]; thenecho "Processing '$NOTEBOOK'"echo "=========================="cd "$NOTEBOOK"FILES=""# Do this thing for each page foundfor PAGE in $(ls | sort -n); do# Make sure the directory's name is an integerexpr "$PAGE" + 1 &> /dev/nullRETVAL=$?if [ -d "$PAGE" -a "$RETVAL" -eq 0 ]; thencd "$PAGE"echo "$PAGE"# The number of the page-1PAGE_1=$(expr $PAGE - 1)# Make the background of the SVG file transparentsed -i '' 's/fill:#FFFFFF; stroke-width:2.0;/fill:#FFFFFF; fill-opacity: 0; stroke-width:2.0;/g' page.svg # Convert the background and the foregroung to PNGsconvert -antialias -background transparent -resize 826x1169 page.svg page.pngconvert -density 400 -resize 826x1169 ../background.pdf[$PAGE_1] background.png# Compose an output PNG from the background+foregroundconvert -flatten background.png page.png $PAGE.jpgFILES="$FILES $PAGE/$PAGE.jpg"# Remove unneeded filesrm -f background.png page.pngcd "$MYDIR/$NOTEBOOK"fidonecd "$MYDIR/$NOTEBOOK"if ! [ -z "$FILES" ]; thenecho "Creating final PDF for $(pwd)"IFS=$SAVEIFSconvert -compress JPEG -adjoin -limit area 1 $FILES "$NOTEBOOK".pdfIFS=$(echo -en "\n\b")fificd "$MYDIR"done
0 komentar:
Post a Comment