Generating PDFs on Android

How to create a PDF for the visible DOM elements using the jsPDF library.

Step-by-step guide

  1. You need to use the latest code from their github page.
  2. You need to add jsPDF and rasterizeHTML.js (or html2canvas.js) as external JS in answerSpace setup.
  3. You will need to use the Cordova 3.3.0 File API to save/copy the generated PDF to the desired location on the device. 
  4. To generate the pdf, simply do:
Example
var pdf = new jsPDF();
pdf.addHTML($(":visible").html()); // Generates PDF for the visible DOM elements
pdf.save(‘/path/to/save/test.pdf’);