

Convert any document to PDF in Bash by piggy backing Google Docs Viewer - zx2c4
http://www.youtube.com/watch?v=hJZ3zuD50r0

======
zx2c4
Here's the code -- pretty simple:

    
    
        #!/bin/sh
        
        # by Jason A. Donenfeld
        # www.zx2c4.com
        
        if [ $# -ne 2 ]; then
            echo "Usage: $0 url output-pdf-file"
            exit 1
        fi
        
        set -e
        documenturl="$(echo -n "$1" | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')"
        viewerurl="http://docs.google.com/viewer?url=$documenturl"
        pdfurl="$(printf "$(curl -s "$viewerurl" | sed -n "s/.*gpUrl:'\\([^']*\\)'.*/\\1/p" | sed 's/%/%%/g')")"
        cookiejar="$(mktemp)"
        curl -s -L -c "$cookiejar" -o "$2" "$pdfurl"
        rm -f "$cookiejar"

