How to Detect and Save Documents to PDF with HTML5 and JavaScript